00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _BLACKLISTS_H_
00030 #define _BLACKLISTS_H_
00031
00032 #include "ip_addr.h"
00033 #include "str.h"
00034 #include "locking.h"
00035
00036 #define BL_READONLY_LIST (1<<0)
00037 #define BL_DO_EXPIRE (1<<1)
00038 #define BL_BY_DEFAULT (1<<2)
00039
00040 #define BLR_APPLY_CONTRARY (1<<0)
00041
00042 struct bl_rule{
00043 int flags;
00044 struct net ip_net;
00045 unsigned short port;
00046 unsigned short proto;
00047 str body;
00048 struct bl_rule *next;
00049 unsigned int expire_end;
00050 };
00051
00052 struct bl_head{
00053 str name;
00054 int owner;
00055 int flags;
00056 gen_lock_t *lock;
00057 int count_write;
00058 int count_read;
00059
00060 struct bl_rule *first;
00061 struct bl_rule *last;
00062 };
00063
00064
00065 #define BL_CORE_ID 13
00066
00067
00068 int preinit_black_lists(void);
00069
00070 int init_black_lists(void);
00071
00072 void destroy_black_lists(void);
00073
00074
00075 struct bl_head *create_bl_head(int owner, int flags, struct bl_rule *head,
00076 struct bl_rule *tail, str *name);
00077
00078 int add_rule_to_list(struct bl_rule **first, struct bl_rule **last,
00079 struct net *ip_net, str *body, unsigned short port,
00080 unsigned short proto, int flags);
00081
00082 int add_list_to_head(struct bl_head *elem,
00083 struct bl_rule *first, struct bl_rule *last,
00084 int truncate, int expire_limit);
00085
00086 struct bl_head *get_bl_head_by_name(str *name);
00087
00088 int mark_for_search(struct bl_head *list, unsigned int set);
00089
00090 void reset_bl_markers(void);
00091
00092 int check_against_blacklist(struct ip_addr *ip, str *text, unsigned short port,
00093 unsigned short proto);
00094
00095 static inline int check_blacklists( unsigned short proto,
00096 union sockaddr_union *to, char *body_s, int body_len)
00097 {
00098 str body;
00099 struct ip_addr ip;
00100 unsigned short port;
00101
00102 body.s = body_s;
00103 body.len = body_len;
00104 su2ip_addr( &ip, to);
00105 port = su_getport( to );
00106 return check_against_blacklist( &ip, &body, port, proto);
00107 }
00108
00109 #endif
00110