#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fnmatch.h>
#include <time.h>
#include <unistd.h>
#include "mem/mem.h"
#include "mem/shm_mem.h"
#include "mi/mi.h"
#include "dprint.h"
#include "blacklists.h"
#include "timer.h"
#include "ut.h"

Go to the source code of this file.
Functions | |
| int | add_list_to_head (struct bl_head *head, struct bl_rule *first, struct bl_rule *last, int truncate, int expire_limit) |
| int | add_rule_to_list (struct bl_rule **first, struct bl_rule **last, struct net *ip_net, str *body, unsigned short port, unsigned short proto, int flags) |
| adds a new rule to a list of rules | |
| int | check_against_blacklist (struct ip_addr *ip, str *text, unsigned short port, unsigned short proto) |
| static int | check_against_rule_list (struct ip_addr *ip, str *text, unsigned short port, unsigned short proto, int i) |
| struct bl_head * | create_bl_head (int owner, int flags, struct bl_rule *head, struct bl_rule *tail, str *name) |
| static void | delete_expired (struct bl_head *elem, unsigned int ticks) |
| static void | delete_expired_routine (unsigned int ticks, void *param) |
| void | destroy_black_lists (void) |
| struct bl_head * | get_bl_head_by_name (str *name) |
| int | init_black_lists (void) |
| static int | ip_class_compare (struct net *net1, struct net *net2) |
| int | mark_for_search (struct bl_head *list, int unsigned set) |
| static struct mi_root * | mi_print_blacklists (struct mi_root *cmd, void *param) |
| int | preinit_black_lists (void) |
| static int | reload_permanent_list (struct bl_rule *first, struct bl_rule *last, struct bl_head *head) |
| void | reset_bl_markers (void) |
| static void | rm_dups (struct bl_head *head, struct bl_rule **first, struct bl_rule **last) |
Variables | |
| static unsigned int | bl_default_marker = 0 |
| static unsigned int | bl_marker = 0 |
| static struct bl_head * | blst_heads = 0 |
| static unsigned int | max_heads = 8*sizeof(bl_marker) |
| static mi_export_t | mi_bl_cmds [] |
| static unsigned int | no_shm = 1 |
| static unsigned int | used_heads = 0 |
Definition in file blacklists.c.
| int add_list_to_head | ( | struct bl_head * | head, | |
| struct bl_rule * | first, | |||
| struct bl_rule * | last, | |||
| int | truncate, | |||
| int | expire_limit | |||
| ) |
Definition at line 488 of file blacklists.c.
References BL_DO_EXPIRE, BL_READONLY_LIST, bl_head::count_read, bl_head::count_write, bl_rule::expire_end, bl_head::first, bl_head::flags, get_ticks(), bl_head::last, _str::len, LM_CRIT, LM_DBG, bl_head::lock, bl_head::name, bl_rule::next, NULL, reload_permanent_list(), rm_dups(), _str::s, and sleep_us().
Referenced by get_next_su().
| int add_rule_to_list | ( | struct bl_rule ** | first, | |
| struct bl_rule ** | last, | |||
| struct net * | ip_net, | |||
| str * | body, | |||
| unsigned short | port, | |||
| unsigned short | proto, | |||
| int | flags | |||
| ) |
adds a new rule to a list of rules
Definition at line 339 of file blacklists.c.
References bl_rule::body, bl_rule::expire_end, bl_rule::flags, ip_class_compare(), bl_rule::ip_net, _str::len, LM_ERR, bl_rule::next, no_shm, NULL, pkg_malloc, bl_rule::port, bl_rule::proto, _str::s, and shm_malloc().
Referenced by get_next_su(), and init_black_lists().
| int check_against_blacklist | ( | struct ip_addr * | ip, | |
| str * | text, | |||
| unsigned short | port, | |||
| unsigned short | proto | |||
| ) |
Definition at line 665 of file blacklists.c.
References bl_marker, check_against_rule_list(), and used_heads.
Referenced by check_blacklists().
| static int check_against_rule_list | ( | struct ip_addr * | ip, | |
| str * | text, | |||
| unsigned short | port, | |||
| unsigned short | proto, | |||
| int | i | |||
| ) | [inline, static] |
Definition at line 618 of file blacklists.c.
References BL_READONLY_LIST, BLR_APPLY_CONTRARY, bl_rule::body, bl_head::count_read, bl_rule::flags, bl_rule::ip_net, LM_DBG, lock, matchnet(), bl_head::name, bl_rule::next, NULL, bl_rule::port, bl_rule::proto, PROTO_NONE, _str::s, and sleep_us().
Referenced by check_against_blacklist().
| struct bl_head* create_bl_head | ( | int | owner, | |
| int | flags, | |||
| struct bl_rule * | head, | |||
| struct bl_rule * | tail, | |||
| str * | name | |||
| ) | [read] |
Definition at line 154 of file blacklists.c.
References BL_BY_DEFAULT, bl_default_marker, BL_DO_EXPIRE, BL_READONLY_LIST, bl_head::first, bl_head::flags, get_bl_head_by_name(), bl_head::last, _str::len, LM_CRIT, LM_ERR, lock, max_heads, bl_head::name, no_shm, NULL, bl_head::owner, pkg_malloc, _str::s, shm_free, shm_malloc(), and used_heads.
Referenced by init_black_lists(), and resolv_blacklist_init().
| static void delete_expired | ( | struct bl_head * | elem, | |
| unsigned int | ticks | |||
| ) | [inline, static] |
Definition at line 250 of file blacklists.c.
References bl_head::count_read, bl_head::count_write, bl_rule::expire_end, bl_head::first, bl_head::last, bl_head::lock, bl_rule::next, NULL, shm_free, and sleep_us().
Referenced by delete_expired_routine().
| static void delete_expired_routine | ( | unsigned int | ticks, | |
| void * | param | |||
| ) | [static] |
Definition at line 308 of file blacklists.c.
References BL_DO_EXPIRE, delete_expired(), and used_heads.
Referenced by init_black_lists().
| void destroy_black_lists | ( | void | ) |
Definition at line 218 of file blacklists.c.
References bl_head::first, bl_head::last, lock, bl_rule::next, no_shm, NULL, shm_free, and used_heads.
Referenced by cleanup().
Definition at line 573 of file blacklists.c.
References _str::len, bl_head::name, NULL, _str::s, and used_heads.
Referenced by create_bl_head(), and fix_actions().
| int init_black_lists | ( | void | ) |
Definition at line 81 of file blacklists.c.
References add_rule_to_list(), bl_default_marker, bl_rule::body, create_bl_head(), delete_expired_routine(), bl_head::first, bl_rule::flags, bl_rule::ip_net, LM_CRIT, LM_ERR, max_heads, bl_head::name, bl_rule::next, no_shm, NULL, bl_head::owner, pkg_free, bl_rule::port, bl_rule::proto, register_mi_mod(), register_timer(), shm_malloc(), and used_heads.
Referenced by main().
Definition at line 320 of file blacklists.c.
References ip_addr::addr32, ip_addr::af, net::ip, ip_addr::len, net::mask, and ip_addr::u.
Referenced by add_rule_to_list(), and rm_dups().
| int mark_for_search | ( | struct bl_head * | list, | |
| int unsigned | set | |||
| ) |
Definition at line 588 of file blacklists.c.
References bl_marker, and used_heads.
Referenced by do_action().
Definition at line 679 of file blacklists.c.
References add_mi_attr(), add_mi_node_child(), BL_DO_EXPIRE, BL_READONLY_LIST, bl_rule::body, bl_head::count_read, bl_rule::expire_end, bl_rule::flags, free_mi_tree(), init_mi_tree(), int2str(), net::ip, ip_addr2a(), bl_rule::ip_net, _str::len, len, lock, net::mask, MI_DUP_VALUE, MI_OK_LEN, MI_OK_S, bl_head::name, bl_rule::next, mi_root::node, NULL, bl_rule::port, bl_rule::proto, _str::s, sleep_us(), and used_heads.
| int preinit_black_lists | ( | void | ) |
Definition at line 64 of file blacklists.c.
References LM_ERR, max_heads, NULL, pkg_malloc, and used_heads.
Referenced by main().
| static int reload_permanent_list | ( | struct bl_rule * | first, | |
| struct bl_rule * | last, | |||
| struct bl_head * | head | |||
| ) | [inline, static] |
Definition at line 450 of file blacklists.c.
References bl_head::count_read, bl_head::count_write, bl_head::first, bl_head::last, bl_head::lock, bl_rule::next, shm_free, and sleep_us().
Referenced by add_list_to_head().
| void reset_bl_markers | ( | void | ) |
Definition at line 611 of file blacklists.c.
References bl_default_marker, and bl_marker.
Referenced by run_top_route().
| static void rm_dups | ( | struct bl_head * | head, | |
| struct bl_rule ** | first, | |||
| struct bl_rule ** | last | |||
| ) | [inline, static] |
Definition at line 410 of file blacklists.c.
References bl_rule::body, bl_head::first, bl_rule::flags, ip_class_compare(), bl_rule::ip_net, _str::len, bl_rule::next, no_shm, NULL, pkg_free, bl_rule::port, bl_rule::proto, _str::s, and shm_free.
Referenced by add_list_to_head().
unsigned int bl_default_marker = 0 [static] |
Definition at line 46 of file blacklists.c.
Referenced by create_bl_head(), init_black_lists(), and reset_bl_markers().
unsigned int bl_marker = 0 [static] |
Definition at line 45 of file blacklists.c.
Referenced by check_against_blacklist(), mark_for_search(), and reset_bl_markers().
struct bl_head* blst_heads = 0 [static] |
Definition at line 44 of file blacklists.c.
Definition at line 48 of file blacklists.c.
Referenced by create_bl_head(), init_black_lists(), and preinit_black_lists().
mi_export_t mi_bl_cmds[] [static] |
Initial value:
{
{ "list_blacklists", mi_print_blacklists, MI_NO_INPUT_FLAG , 0, 0 },
{ 0, 0, 0, 0, 0}
}
Definition at line 57 of file blacklists.c.
unsigned int no_shm = 1 [static] |
Definition at line 50 of file blacklists.c.
Referenced by add_rule_to_list(), create_bl_head(), destroy_black_lists(), init_black_lists(), and rm_dups().
unsigned int used_heads = 0 [static] |
Definition at line 49 of file blacklists.c.
Referenced by check_against_blacklist(), create_bl_head(), delete_expired_routine(), destroy_black_lists(), get_bl_head_by_name(), init_black_lists(), mark_for_search(), mi_print_blacklists(), and preinit_black_lists().
1.5.6