Wed Feb 25 12:40:44 CST 2009 Pekka Pessi <first.last@nokia.com>

* 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
This commit is contained in:
Michael Jerris 2009-02-25 19:36:39 +00:00
parent e591b6ce3a
commit c49d12e184
3 changed files with 17 additions and 3 deletions

View File

@ -1 +1 @@
Wed Feb 25 13:35:46 CST 2009
Wed Feb 25 13:36:25 CST 2009

View File

@ -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,6 +155,7 @@ 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);
if (!s2dns.filter || s2dns.filter(request.buffer, len, s2dns.userdata))
su_sendto(socket, request.buffer, len, 0, &su->su_sa, sulen);
return 0;
}
@ -170,6 +181,7 @@ s2_dns_query(su_root_magic_t *magic,
}
request.header->mh_flags = htons(flags);
if (!s2dns.filter || s2dns.filter(request.buffer, len, s2dns.userdata))
su_sendto(socket, request.buffer, len, 0, &su->su_sa, sulen);
return 0;
}

View File

@ -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);