4 * resolver related functions
6 * Copyright (C) 2006 iptelorg GmbH
8 * This file is part of ser, a free SIP server.
10 * ser is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version
15 * For a license to use the ser software under conditions
16 * other than those described here, or to purchase support for this
17 * software, please contact iptel.org by e-mail at the following addresses:
20 * ser is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 * 2006-07-29 created by andrei
32 * 2007-07-30 dst blacklist measurements added (Gergo)
35 #ifndef dst_black_list_h
36 #define dst_black_list_h
39 #include "parser/msg_parser.h"
40 #include "timer_ticks.h"
43 #define DEFAULT_BLST_TIMEOUT 60 /* 1 min. */
44 #define DEFAULT_BLST_MAX_MEM 250 /* 250 KB */
47 #define BLST_IS_IPV6 1 /* set if the address is ipv6 */
48 #define BLST_ERR_SEND (1<<1) /* set if send is denied/failed */
49 #define BLST_ERR_CONNECT (1<<2) /* set if connect failed (tcp/tls) */
50 #define BLST_ICMP_RCVD (1<<3) /* set if icmp error */
51 #define BLST_ERR_TIMEOUT (1<<4) /* set if sip timeout */
52 #define BLST_503 (1<<5) /* set for 503 replies */
53 #define BLST_ADM_PROHIBITED (1<<6) /* administratively prohibited */
54 #define BLST_PERMANENT (1<<7) /* never deleted, never expires */
56 /* uncomment the define above to enable blacklist callbacks support */
57 /*#define DST_BLACKLIST_HOOKS*/
59 #define DST_BLACKLIST_CONTINUE 0 /* add: do nothing/ignore, search: ignore */
60 #define DST_BLACKLIST_ACCEPT 1 /* add: force accept, search: force match */
61 #define DST_BLACKLIST_DENY -1 /* add: deny, search: force no match */
63 #define DST_BLACKLIST_ADD_CB 1
64 #define DST_BLACKLIST_SEARCH_CB 2
66 #ifdef DST_BLACKLIST_HOOKS
67 struct blacklist_hook{
68 /* WARNING: msg might be NULL, and it might point to shared memory
69 * without locking, do not modify it! msg can be used typically for checking
70 * the message flags with isflagset() */
71 int (*on_blst_action)(struct dest_info* si, unsigned char* err_flags,
73 /* called before ser shutdown */
74 void (*destroy)(void);
77 int register_blacklist_hook(struct blacklist_hook *h, int type);
78 #endif /* DST_BLACKLIST_HOOKS */
80 int init_dst_blacklist();
81 #ifdef USE_DST_BLACKLIST_STATS
82 int init_dst_blacklist_stats(int iproc_num);
83 #define DST_BLACKLIST_ALL_STATS "bkl_all_stats"
85 void destroy_dst_blacklist();
88 /* like dst_blacklist_add, but the timeout can be also set */
89 int dst_blacklist_add_to(unsigned char err_flags, struct dest_info* si,
90 struct sip_msg* msg, ticks_t timeout);
92 /* adds a dst to the blacklist with default timeout */
93 #define dst_blacklist_add(err_flags, si, msg) \
94 dst_blacklist_add_to((err_flags), (si), (msg), \
95 S_TO_TICKS(cfg_get(core, core_cfg, blst_timeout)))
97 int dst_is_blacklisted(struct dest_info* si, struct sip_msg* msg);
98 /* delete an entry from the blacklist */
99 int dst_blacklist_del(struct dest_info* si, struct sip_msg* msg);
101 /* deletes all the entries from the blacklist except the permanent ones
102 * (which are marked with BLST_PERMANENT)
104 void dst_blst_flush(void);
106 int use_dst_blacklist_fixup(void *handle, str *name, void **val);
107 /* KByte to Byte conversion */
108 int blst_max_mem_fixup(void *handle, str *name, void **val);