[Freeswitch-svn] [commit] r12283 - in freeswitch/trunk/libs/sofia-sip: . s2check

FreeSWITCH SVN mikej at freeswitch.org
Wed Feb 25 11:36:39 PST 2009


Author: mikej
Date: Wed Feb 25 13:36:39 2009
New Revision: 12283

Log:
Wed Feb 25 12:40:44 CST 2009  Pekka Pessi <first.last at nokia.com>
  * s2dns: added s2_dns_set_filter()
  Ignore-this: dc9bf478b6a90d5b351b56c3d77a7ec9



Modified:
   freeswitch/trunk/libs/sofia-sip/.update
   freeswitch/trunk/libs/sofia-sip/s2check/s2dns.c
   freeswitch/trunk/libs/sofia-sip/s2check/s2dns.h

Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update	(original)
+++ freeswitch/trunk/libs/sofia-sip/.update	Wed Feb 25 13:36:39 2009
@@ -1 +1 @@
-Wed Feb 25 13:35:46 CST 2009
+Wed Feb 25 13:36:25 CST 2009

Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2dns.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/s2check/s2dns.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/s2check/s2dns.c	Wed Feb 25 13:36:39 2009
@@ -18,6 +18,8 @@
   su_socket_t socket;
   su_wait_t wait[1];
   int reg;
+  int (*filter)(void *data, size_t len, void *userdata);
+  void *userdata;
 } s2dns;
 
 static
@@ -94,6 +96,14 @@
   s2dns.socket = socket;
 }
 
+/* Set filter function */
+void s2_dns_set_filter(int (*filter)(void *data, size_t len, void *userdata),
+		       void *userdata)
+{
+  s2dns.filter = filter;
+  s2dns.userdata = userdata;
+}
+
 void s2_dns_teardown(void)
 {
   struct s2_dns_response *r, *next;
@@ -145,7 +155,8 @@
       || ntohs(request.header->mh_qdcount) != 1) {
     flags |= FLAGS_QR | FLAGS_UNIMPL_ERR;
     request.header->mh_flags = htons(flags);
-    su_sendto(socket, request.buffer, len, 0, &su->su_sa, sulen);
+    if (!s2dns.filter || s2dns.filter(request.buffer, len, s2dns.userdata))
+      su_sendto(socket, request.buffer, len, 0, &su->su_sa, sulen);
     return 0;
   }
 
@@ -170,7 +181,8 @@
   }
 
   request.header->mh_flags = htons(flags);
-  su_sendto(socket, request.buffer, len, 0, &su->su_sa, sulen);
+  if (!s2dns.filter || s2dns.filter(request.buffer, len, s2dns.userdata))
+    su_sendto(socket, request.buffer, len, 0, &su->su_sa, sulen);
   return 0;
 }
 

Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2dns.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/s2check/s2dns.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/s2check/s2dns.h	Wed Feb 25 13:36:39 2009
@@ -38,6 +38,8 @@
 SOFIA_BEGIN_DECLS
 
 void s2_dns_setup(su_root_t *root);
+void s2_dns_set_filter(int (*filter)(void *data, size_t len, void *userdata),
+		       void *userdata);
 void s2_dns_teardown(void);
 
 char const *s2_dns_default(char const *domain);



More information about the Freeswitch-svn mailing list