From c49d12e184c87d88af925f12c449dae6dfd06862 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 25 Feb 2009 19:36:39 +0000 Subject: [PATCH] Wed Feb 25 12:40:44 CST 2009 Pekka Pessi * s2dns: added s2_dns_set_filter() Ignore-this: dc9bf478b6a90d5b351b56c3d77a7ec9 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12283 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/sofia-sip/.update | 2 +- libs/sofia-sip/s2check/s2dns.c | 16 ++++++++++++++-- libs/sofia-sip/s2check/s2dns.h | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 582bb3c23b..ace50befaa 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Wed Feb 25 13:35:46 CST 2009 +Wed Feb 25 13:36:25 CST 2009 diff --git a/libs/sofia-sip/s2check/s2dns.c b/libs/sofia-sip/s2check/s2dns.c index 94aa6c0b5a..a4adf71019 100644 --- a/libs/sofia-sip/s2check/s2dns.c +++ b/libs/sofia-sip/s2check/s2dns.c @@ -18,6 +18,8 @@ static struct s2dns { 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 @@ void s2_dns_setup(su_root_t *root) 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 @@ s2_dns_query(su_root_magic_t *magic, || 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 @@ s2_dns_query(su_root_magic_t *magic, } 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; } diff --git a/libs/sofia-sip/s2check/s2dns.h b/libs/sofia-sip/s2check/s2dns.h index 01f6607211..b176ad15b9 100644 --- a/libs/sofia-sip/s2check/s2dns.h +++ b/libs/sofia-sip/s2check/s2dns.h @@ -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);