00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef dst_black_list_h
00036 #define dst_black_list_h
00037
00038 #include "ip_addr.h"
00039 #include "parser/msg_parser.h"
00040 #include "timer_ticks.h"
00041 #include "cfg_core.h"
00042
00043 #define DEFAULT_BLST_TIMEOUT 60
00044 #define DEFAULT_BLST_MAX_MEM 250
00047
00049 #define BLST_IS_IPV6 1
00050 #define BLST_ERR_SEND (1<<1)
00051 #define BLST_ERR_CONNECT (1<<2)
00052 #define BLST_ICMP_RCVD (1<<3)
00053 #define BLST_ERR_TIMEOUT (1<<4)
00054 #define BLST_503 (1<<5)
00055 #define BLST_ADM_PROHIBITED (1<<6)
00056 #define BLST_PERMANENT (1<<7)
00057
00059
00060
00061
00062 #define DST_BLACKLIST_CONTINUE 0
00063 #define DST_BLACKLIST_ACCEPT 1
00064 #define DST_BLACKLIST_DENY -1
00066 #define DST_BLACKLIST_ADD_CB 1
00067 #define DST_BLACKLIST_SEARCH_CB 2
00068
00069
00070 extern unsigned blst_proto_imask[PROTO_LAST+1];
00071
00072 #ifdef DST_BLACKLIST_HOOKS
00073 struct blacklist_hook{
00074
00075
00076
00077 int (*on_blst_action)(struct dest_info* si, unsigned char* err_flags,
00078 struct sip_msg* msg);
00079
00080 void (*destroy)(void);
00081 };
00082
00083 int register_blacklist_hook(struct blacklist_hook *h, int type);
00084 #endif
00085
00086 int init_dst_blacklist(void);
00087 #ifdef USE_DST_BLACKLIST_STATS
00088 int init_dst_blacklist_stats(int iproc_num);
00089 #define DST_BLACKLIST_ALL_STATS "bkl_all_stats"
00090 #endif
00091 void destroy_dst_blacklist(void);
00092
00093
00099 int dst_blacklist_force_add_to(unsigned char err_flags, struct dest_info* si,
00100 struct sip_msg* msg, ticks_t timeout);
00101
00107 int dst_blacklist_force_su_to( unsigned char err_flags,
00108 unsigned char proto,
00109 union sockaddr_union* dst,
00110 struct sip_msg* msg,
00111 ticks_t timeout);
00112
00113
00121 #define should_blacklist(err_flags, si) \
00122 (cfg_get(core, core_cfg, use_dst_blacklist) && \
00123 ((err_flags) & ~blst_proto_imask[(unsigned)((si)->proto)] & \
00124 ~(si)->send_flags.blst_imask ))
00125
00126
00135 #define should_blacklist_su(err_flags, snd_flags, proto, su) \
00136 (cfg_get(core, core_cfg, use_dst_blacklist) && \
00137 ((err_flags) & ~blst_proto_imask[(unsigned)(proto)] & \
00138 ~((snd_flags)?((snd_flags_t*)(snd_flags))->blst_imask:0)))
00139
00140
00149 #define dst_blacklist_add_to(err_flags, si, msg, timeout) \
00150 (should_blacklist(err_flags, si)? \
00151 dst_blacklist_force_add_to((err_flags), (si), (msg), (timeout))\
00152 : 0)
00153
00154
00165 #define dst_blacklist_su_to(err_flags, proto, dst, snd_flags, msg, timeout) \
00166 (should_blacklist_su(err_flags, snd_flags, proto, dst) ? \
00167 dst_blacklist_force_su_to((err_flags), (proto), (dst), (msg), \
00168 (timeout))\
00169 : 0)
00170
00171
00180 #define dst_blacklist_add(err_flags, si, msg) \
00181 dst_blacklist_add_to(err_flags, si, msg, \
00182 S_TO_TICKS(cfg_get(core, core_cfg, blst_timeout)))
00183
00184
00195 #define dst_blacklist_su(err_flags, proto, dst, snd_flags, msg) \
00196 dst_blacklist_su_to(err_flags, proto, dst, snd_flags, msg, \
00197 S_TO_TICKS(cfg_get(core, core_cfg, blst_timeout)))
00198
00199 int dst_is_blacklisted(struct dest_info* si, struct sip_msg* msg);
00200
00202 int dst_blacklist_del(struct dest_info* si, struct sip_msg* msg);
00203
00207 void dst_blst_flush(void);
00208
00209 int use_dst_blacklist_fixup(void *handle, str *gname, str *name, void **val);
00210
00212 int blst_max_mem_fixup(void *handle, str *gname, str *name, void **val);
00213
00214 void blst_reinit_ign_masks(str* gname, str* name);
00215
00216 #endif