Module: sip-router
Branch: master
Commit: 6d91574de7f9133328e3f58d94b58bbdaacf1583
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6d91574…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Thu Feb 26 23:09:22 2009 +0000
blst: another blacklist dest. function version
- added dst_blacklist_su(), which is a variant of dst_blacklist_add()
(different way of passing the blacklist target)
---
dst_blacklist.c | 35 +++++++++++++++++++++++++++++++++++
dst_blacklist.h | 15 ++++++++++++++-
2 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/dst_blacklist.c b/dst_blacklist.c
index bb6e35e..7ebd1e6 100644
--- a/dst_blacklist.c
+++ b/dst_blacklist.c
@@ -34,6 +34,7 @@
* 2007-07-30 added dst_blacklist_del() and dst_blacklist_add_to() (andrei)
* 2007-07-30 dst blacklist measurements added (Gergo)
* 2008-02-11 dns_blacklist_init cfg parameter is introduced (Miklos)
+ * 2009-02-26 added dst_blacklist_su* variant (andrei)
*/
@@ -785,6 +786,14 @@ inline static int dst_is_blacklisted_ip(unsigned char proto,
+/** add dst to the blacklist, specifying the timeout.
+ * @param err_flags - reason (bitmap)
+ * @param si - destination (protocol, ip and port)
+ * @param msg - sip message that triggered the blacklisting (can be 0 if
+ * not known)
+ * @param timeout - timeout in ticks
+ * @return 0 on success, -1 on error
+ */
int dst_blacklist_add_to(unsigned char err_flags, struct dest_info* si,
struct sip_msg* msg, ticks_t timeout)
{
@@ -802,6 +811,32 @@ int dst_blacklist_add_to(unsigned char err_flags, struct dest_info*
si,
+/** add dst to the blacklist, specifying the timeout.
+ * (like @function dst_blacklist_add_to)= above, but uses
+ * (proto, sockaddr_union) instead of struct dest_info)
+ */
+int dst_blacklist_su_to(unsigned char err_flags, unsigned char proto,
+ union sockaddr_union* dst,
+ struct sip_msg* msg, ticks_t timeout)
+{
+ struct ip_addr ip;
+#ifdef DST_BLACKLIST_HOOKS
+ struct dest_info si;
+
+ init_dest_info(&si);
+ si.to=*dst;
+ si.proto=proto;
+ if (unlikely (blacklist_run_hooks(&blst_add_cb, &si, &err_flags, msg) ==
+ DST_BLACKLIST_DENY))
+ return 0;
+#endif
+ su2ip_addr(&ip, dst);
+ return dst_blacklist_add_ip(err_flags, proto, &ip,
+ su_getport(dst), timeout);
+}
+
+
+
int dst_is_blacklisted(struct dest_info* si, struct sip_msg* msg)
{
int ires;
diff --git a/dst_blacklist.h b/dst_blacklist.h
index e2ca0b4..b7c3ea1 100644
--- a/dst_blacklist.h
+++ b/dst_blacklist.h
@@ -88,12 +88,25 @@ void destroy_dst_blacklist();
/* like dst_blacklist_add, but the timeout can be also set */
int dst_blacklist_add_to(unsigned char err_flags, struct dest_info* si,
struct sip_msg* msg, ticks_t timeout);
+/* like above, but using a differnt way of passing the target */
+int dst_blacklist_su_to(unsigned char err_flags, unsigned char proto,
+ union sockaddr_union* dst,
+ struct sip_msg* msg, ticks_t timeout);
-/* adds a dst to the blacklist with default timeout */
+/** adds a dst to the blacklist with default timeout.
+ * @see dst_blacklist_add_to for more details.
+ */
#define dst_blacklist_add(err_flags, si, msg) \
dst_blacklist_add_to((err_flags), (si), (msg), \
S_TO_TICKS(cfg_get(core, core_cfg, blst_timeout)))
+/** adds a dst to the blacklist with default timeout.
+ * @see dst_blacklist_su_to for more details.
+ */
+#define dst_blacklist_su(err_flags, proto, dst, msg) \
+ dst_blacklist_su_to((err_flags), (proto), (dst), (msg), \
+ S_TO_TICKS(cfg_get(core, core_cfg, blst_timeout)))
+
int dst_is_blacklisted(struct dest_info* si, struct sip_msg* msg);
/* delete an entry from the blacklist */
int dst_blacklist_del(struct dest_info* si, struct sip_msg* msg);