- added dst_blacklist_su(), which is a variant of dst_blacklist_add()
(different way of passing the blacklist target)
... | ... |
@@ -34,6 +34,7 @@ |
34 | 34 |
* 2007-07-30 added dst_blacklist_del() and dst_blacklist_add_to() (andrei) |
35 | 35 |
* 2007-07-30 dst blacklist measurements added (Gergo) |
36 | 36 |
* 2008-02-11 dns_blacklist_init cfg parameter is introduced (Miklos) |
37 |
+ * 2009-02-26 added dst_blacklist_su* variant (andrei) |
|
37 | 38 |
*/ |
38 | 39 |
|
39 | 40 |
|
... | ... |
@@ -785,6 +786,14 @@ inline static int dst_is_blacklisted_ip(unsigned char proto, |
785 | 786 |
|
786 | 787 |
|
787 | 788 |
|
789 |
+/** add dst to the blacklist, specifying the timeout. |
|
790 |
+ * @param err_flags - reason (bitmap) |
|
791 |
+ * @param si - destination (protocol, ip and port) |
|
792 |
+ * @param msg - sip message that triggered the blacklisting (can be 0 if |
|
793 |
+ * not known) |
|
794 |
+ * @param timeout - timeout in ticks |
|
795 |
+ * @return 0 on success, -1 on error |
|
796 |
+ */ |
|
788 | 797 |
int dst_blacklist_add_to(unsigned char err_flags, struct dest_info* si, |
789 | 798 |
struct sip_msg* msg, ticks_t timeout) |
790 | 799 |
{ |
... | ... |
@@ -802,6 +811,32 @@ int dst_blacklist_add_to(unsigned char err_flags, struct dest_info* si, |
802 | 811 |
|
803 | 812 |
|
804 | 813 |
|
814 |
+/** add dst to the blacklist, specifying the timeout. |
|
815 |
+ * (like @function dst_blacklist_add_to)= above, but uses |
|
816 |
+ * (proto, sockaddr_union) instead of struct dest_info) |
|
817 |
+ */ |
|
818 |
+int dst_blacklist_su_to(unsigned char err_flags, unsigned char proto, |
|
819 |
+ union sockaddr_union* dst, |
|
820 |
+ struct sip_msg* msg, ticks_t timeout) |
|
821 |
+{ |
|
822 |
+ struct ip_addr ip; |
|
823 |
+#ifdef DST_BLACKLIST_HOOKS |
|
824 |
+ struct dest_info si; |
|
825 |
+ |
|
826 |
+ init_dest_info(&si); |
|
827 |
+ si.to=*dst; |
|
828 |
+ si.proto=proto; |
|
829 |
+ if (unlikely (blacklist_run_hooks(&blst_add_cb, &si, &err_flags, msg) == |
|
830 |
+ DST_BLACKLIST_DENY)) |
|
831 |
+ return 0; |
|
832 |
+#endif |
|
833 |
+ su2ip_addr(&ip, dst); |
|
834 |
+ return dst_blacklist_add_ip(err_flags, proto, &ip, |
|
835 |
+ su_getport(dst), timeout); |
|
836 |
+} |
|
837 |
+ |
|
838 |
+ |
|
839 |
+ |
|
805 | 840 |
int dst_is_blacklisted(struct dest_info* si, struct sip_msg* msg) |
806 | 841 |
{ |
807 | 842 |
int ires; |
... | ... |
@@ -88,12 +88,25 @@ void destroy_dst_blacklist(); |
88 | 88 |
/* like dst_blacklist_add, but the timeout can be also set */ |
89 | 89 |
int dst_blacklist_add_to(unsigned char err_flags, struct dest_info* si, |
90 | 90 |
struct sip_msg* msg, ticks_t timeout); |
91 |
+/* like above, but using a differnt way of passing the target */ |
|
92 |
+int dst_blacklist_su_to(unsigned char err_flags, unsigned char proto, |
|
93 |
+ union sockaddr_union* dst, |
|
94 |
+ struct sip_msg* msg, ticks_t timeout); |
|
91 | 95 |
|
92 |
-/* adds a dst to the blacklist with default timeout */ |
|
96 |
+/** adds a dst to the blacklist with default timeout. |
|
97 |
+ * @see dst_blacklist_add_to for more details. |
|
98 |
+ */ |
|
93 | 99 |
#define dst_blacklist_add(err_flags, si, msg) \ |
94 | 100 |
dst_blacklist_add_to((err_flags), (si), (msg), \ |
95 | 101 |
S_TO_TICKS(cfg_get(core, core_cfg, blst_timeout))) |
96 | 102 |
|
103 |
+/** adds a dst to the blacklist with default timeout. |
|
104 |
+ * @see dst_blacklist_su_to for more details. |
|
105 |
+ */ |
|
106 |
+#define dst_blacklist_su(err_flags, proto, dst, msg) \ |
|
107 |
+ dst_blacklist_su_to((err_flags), (proto), (dst), (msg), \ |
|
108 |
+ S_TO_TICKS(cfg_get(core, core_cfg, blst_timeout))) |
|
109 |
+ |
|
97 | 110 |
int dst_is_blacklisted(struct dest_info* si, struct sip_msg* msg); |
98 | 111 |
/* delete an entry from the blacklist */ |
99 | 112 |
int dst_blacklist_del(struct dest_info* si, struct sip_msg* msg); |