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:
parent
e591b6ce3a
commit
c49d12e184
|
@ -1 +1 @@
|
|||
Wed Feb 25 13:35:46 CST 2009
|
||||
Wed Feb 25 13:36:25 CST 2009
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue