Cross reference for modules/ac/access_control.c of index.

# File modules/ac/access_control.c

      $Revision: 1.5 $

      Access control module (ac).

      Status: NOT REVUED, NOT TESTED

## Included Files

- `#include <stdio.h>`

- `#include </space/dbdev/marek/include/glib.h>`
  - `#include </space/dbdev/marek/lib/glib/include/glibconfig.h>`
    - `#include <limits.h>`
    - `#include <float.h>`
  - `#include <stdarg.h>`

- `#include "include/rxroutines.h"`
  - `#include <glib.h>`
  - `#include <pthread.h>`
  - `#include <include/stubs.h>`
    - `#include <stdlib.h>`
  - `#include <include/memwrap.h>`
    - `#include <include/erroutines.h>`
      - `#include <stdio.h>`
      - `#include <unistd.h>`
      - `#include <stdlib.h>`
      - `#include <assert.h>`
      - `#include <time.h>`
      - `#include <stdarg.h>`
      - `#include <strings.h>`
      - `#include <include/bitmask.h>`
      - `#include <include/er_aspects.h>`
      - `#include <stubs.h>`
      - `#include "include/er_facilities.h"`
        - `#include <include/erroutines.h>`
        - `#include "include/er_ER_errors.h"`
        - `#include "include/er_IP_errors.h"`
        - `#include "include/er_RX_errors.h"`
        - `#include "include/er_UT_errors.h"`
        - `#include "include/er_WH_errors.h"`
        - `#include "include/erroutines.h"`
  - `#include <stdio.h>`
  - `#include <include/iproutines.h>`
    - `#include <glib.h>`
    - `#include <include/erroutines.h>`
  - `#include <include/rx_globals.h>`
    - `#include <stddef.h>`
    - `#include <glib.h>`
  - `#include "include/socket.h"`
    - `#include <sys/types.h>`
    - `#include <sys/socket.h>`
    - `#include <netinet/in.h>`
    - `#include <stdlib.h>`
    - `#include <errno.h>`
    - `#include <netdb.h>`
    - `#include <signal.h>`
    - `#include <stdio.h>`
    - `#include <iproutines.h>`
  - `#include "include/thread.h"`
    - `#include <pthread.h>`

- `#include "include/erroutines.h"`

- `#include "modules/ac/access_control.h"`
  - `#include "include/erroutines.h"`
  - `#include "include/iproutines.h"`
  - `#include "include/rxroutines.h"`

- `#include "include/socket.h"`

- `#include "include/mysql_driver.h"`
  - `#include "/usr/local/mysql/include/mysql.h"`
    - `#include <sys/types.h>`
    - `#include "/usr/local/mysql/include/mysql_com.h"`
    - `#include "/usr/local/mysql/include/mysql_version.h"`

- `#include "include/constants.h"`

## Preprocessor definitions

`#define AC_IMPL`

`#define AC_DECAY_TIME 10`

## Global Variable act_runtime

`rx_tree_t* act_runtime`

Included from | modules/ac/access_control.h
Visible in: |  | modules/ac/access_control.c
Used in: | AC_build() | modules/ac/access_control.c
| AC_commit() | modules/ac/access_control.c
| AC_decay() | modules/ac/access_control.c
| AC_fetch_acc() | modules/ac/access_control.c

## Global Variable act_hour

`rx_tree_t* act_hour`

Included from | modules/ac/access_control.h
Visible in: |  | modules/ac/access_control.c
Used in: | AC_build() | modules/ac/access_control.c

## Global Variable act_minute

`rx_tree_t* act_minute`

Included from | modules/ac/access_control.h
Visible in: |  | modules/ac/access_control.c
Used in: | AC_build() | modules/ac/access_control.c

## Global Variable act_acl

`rx_tree_t* act_acl`

Included from | modules/ac/access_control.h
Visible in: |  | modules/ac/access_control.c
Used in: | AC_acc_load() | modules/ac/access_control.c
| AC_build() | modules/ac/access_control.c
| AC_check_acl() | modules/ac/access_control.c

## Global Function AC_acc_addup()

`void AC_acc_addup ( acc_st* a, acc_st* b, int minus )`

Prototyped in: | modules/ac/access_control.h
Called by: | AC_commit() | modules/ac/access_control.c

## Global Function AC_acc_load()

`er_ret_t AC_acc_load ( void )`

Calls: | CO_get_database_port(), CO_get_host(), CO_get_password(), CO_get_user(), RX_bin_node(), SQ_close_connection(), SQ_errno(), SQ_error(), SQ_execute_query(), SQ_free_result(), SQ_get_column_string(), SQ_get_connection(), SQ_row_next(), TH_acquire_write_lock(), TH_release_write_lock(), TH_run2(), fprintf(), memset(), sscanf(), wr_malloc()
References Functions: | AC_decay() | modules/ac/access_control.c
References Variables: | act_acl | modules/ac/access_control.c

## Global Function AC_acl_to_string()

      Show an access control list structure

      More:

      Authors:
            marek

    Online References:

`char* AC_acl_to_string ( GList* leafptr )`

Calls: | sprintf(), strcpy(), wr_malloc()
Called by: | AC_rxwalkhook_print_acl() | modules/ac/access_control.c

## Global Function AC_build()

`er_ret_t AC_build ( void )`

Prototyped in: | modules/ac/access_control.h
Calls: | RX_tree_cre(), fprintf()
References Variables: | act_acl | modules/ac/access_control.c
| act_hour | modules/ac/access_control.c
| act_minute | modules/ac/access_control.c
| act_runtime | modules/ac/access_control.c

## Global Function AC_check_acl()

      AC_check_acl:

      search for this ip or other applicable record in the access control tree

      if( bonus in combined runtime+connection accountings > max_bonus in acl)
                set denial in the acl for this ip (create if needed)
      if( combined denialcounter > max_denials in acl)
                set the permanent ban in acl; save in SQL too
      calculate credit if pointer provided
      save the access record (ip if created or found/prefix otherwise)
                at *acl_store if provided

      any of the args except address can be NULL

      More:

      Authors:
            marek

    Online References:

`er_ret_t AC_check_acl ( ip_addr_t* addr, acc_st* run_acc, acc_st* query_acc, acc_st* credit_acc, acl_st* acl_store )`

Prototyped in: | modules/ac/access_control.h
Calls: | IP_sizebits(), RX_bin_search(), TH_acquire_read_lock(), TH_acquire_write_lock(), TH_release_read_lock(), TH_release_write_lock(), fprintf(), g_list_length(), g_list_nth_data(), memset()
References Variables: | act_acl | modules/ac/access_control.c

## Global Function AC_commit()

`er_ret_t AC_commit ( ip_addr_t* addr, acc_st* acc_conn )`

Prototyped in: | modules/ac/access_control.h
Calls: | AC_acc_addup() | modules/ac/access_control.c
| IP_sizebits(), RX_bin_node(), RX_bin_search(), TH_acquire_write_lock(), TH_release_write_lock(), fprintf(), g_list_length(), g_list_nth_data(), memcpy(), wr_malloc()
References Variables: | act_runtime | modules/ac/access_control.c

## Global Function AC_decay()

`er_ret_t AC_decay ( void )`

Calls: | TH_acquire_write_lock(), TH_release_write_lock(), printf(), rx_walk_tree(), sleep()
Used in: | AC_acc_load() | modules/ac/access_control.c
References Functions: | AC_decay_hook() | modules/ac/access_control.c
References Variables: | act_runtime | modules/ac/access_control.c

## Global Function AC_decay_hook()

`er_ret_t AC_decay_hook ( rx_node_t* node, int level, int nodecounter, void* con )`

Used in: | AC_decay() | modules/ac/access_control.c

## Global Function AC_fetch_acc()

      Find the runtime accounting record for this IP,
      store a copy of it in acc_store.

      More:

      Authors:
            marek

    Online References:

`er_ret_t AC_fetch_acc ( ip_addr_t* addr, acc_st* acc_store, int tmout )`

Prototyped in: | modules/ac/access_control.h
Calls: | IP_sizebits(), RX_bin_search(), TH_acquire_read_lock(), TH_release_read_lock(), fprintf(), g_list_length(), g_list_nth_data(), memcpy(), memset()
References Variables: | act_runtime | modules/ac/access_control.c

## Global Function AC_rxwalkhook_print()

`er_ret_t AC_rxwalkhook_print ( rx_node_t* node, int level, int nodecounter, void* con )`

Prototyped in: | modules/ac/access_control.h
Calls: | AC_to_string() | modules/ac/access_control.c
| IP_addr_b2a(), SK_cd_puts(), fprintf(), sprintf(), wr_free()

## Global Function AC_rxwalkhook_print_acl()

`er_ret_t AC_rxwalkhook_print_acl ( rx_node_t* node, int level, int nodecounter, void* con )`

Prototyped in: | modules/ac/access_control.h
Calls: | AC_acl_to_string() | modules/ac/access_control.c
| IP_pref_b2a(), SK_cd_puts(), fprintf(), sprintf(), wr_free()

## Global Function AC_to_string()

      Show an access structure

      More:

      Authors:
            marek

    Online References:

`char* AC_to_string ( GList* leafptr )`

Prototyped in: | modules/ac/access_control.h
Calls: | sprintf(), strcpy(), wr_malloc()
Called by: | AC_rxwalkhook_print() | modules/ac/access_control.c