blacklists.c File Reference

Kamailio Blacklist functions. More...

#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"

Include dependency graph for blacklists.c:

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_headcreate_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_headget_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_rootmi_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_headblst_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


Detailed Description

Kamailio Blacklist functions.

Definition in file blacklists.c.


Function Documentation

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 
)

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]

struct bl_head* create_bl_head ( int  owner,
int  flags,
struct bl_rule head,
struct bl_rule tail,
str name 
) [read]

static void delete_expired ( struct bl_head elem,
unsigned int  ticks 
) [inline, static]

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().

struct bl_head* get_bl_head_by_name ( str name  )  [read]

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   ) 

static int ip_class_compare ( struct net net1,
struct net net2 
) [inline, static]

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().

static struct mi_root * mi_print_blacklists ( struct mi_root cmd,
void *  param 
) [static, read]

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]

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]


Variable Documentation

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.

unsigned int max_heads = 8*sizeof(bl_marker) [static]

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]

unsigned int used_heads = 0 [static]


Generated on Thu May 17 12:00:36 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6