DNS Support for Asterisk.
More...
#include "asterisk.h"
#include "asterisk/network.h"
#include <arpa/nameser.h>
#include <resolv.h>
#include "asterisk/channel.h"
#include "asterisk/dns.h"
#include "asterisk/endian.h"
Go to the source code of this file.
|
int | ast_search_dns (void *context, const char *dname, int class, int type, int(*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer)) |
| Lookup record in DNS. More...
|
|
static int | dns_parse_answer (void *context, int class, int type, unsigned char *answer, int len, int(*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer)) |
| Parse DNS lookup result, call callback. More...
|
|
static int | skip_name (unsigned char *s, int len) |
|
DNS Support for Asterisk.
- Author
- Thorsten Lockert tholo.nosp@m.@tro.nosp@m.llpho.nosp@m.ne.o.nosp@m.rg
- Reference
-
Definition in file dns.c.
int ast_search_dns |
( |
void * |
context, |
|
|
const char * |
dname, |
|
|
int |
class, |
|
|
int |
type, |
|
|
int(*)(void *context, unsigned char *answer, int len, unsigned char *fullanswer) |
callback |
|
) |
| |
Lookup record in DNS.
Perform DNS lookup (used by DNS, enum and SRV lookups)
- Note
- Asterisk DNS is synchronus at this time. This means that if your DNS does not work properly, Asterisk might not start properly or a channel may lock.
Definition at line 259 of file dns.c.
References ast_debug, ast_log(), ast_mutex_lock, ast_mutex_unlock, dns_parse_answer(), LOG_WARNING, and MAX_SIZE.
Referenced by ast_get_enum(), ast_get_srv(), ast_srv_lookup(), blr_ebl(), and blr_txt().
263 #ifdef HAVE_RES_NINIT
264 struct __res_state dnsstate;
269 #ifdef HAVE_RES_NINIT
270 memset(&dnsstate, 0,
sizeof(dnsstate));
271 res_ninit(&dnsstate);
272 res = res_nsearch(&dnsstate, dname,
class,
type, answer,
sizeof(answer));
276 res = res_search(dname,
class,
type, answer,
sizeof(answer));
282 }
else if (res == 0) {
283 ast_debug(1,
"No matches found in DNS for %s\n", dname);
288 #ifdef HAVE_RES_NINIT
289 #ifdef HAVE_RES_NDESTROY
290 res_ndestroy(&dnsstate);
292 res_nclose(&dnsstate);
295 #ifdef HAVE_RES_CLOSE
#define ast_mutex_lock(a)
#define ast_debug(level,...)
Log a DEBUG message.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static char context[AST_MAX_CONTEXT]
static int dns_parse_answer(void *context, int class, int type, unsigned char *answer, int len, int(*callback)(void *context, unsigned char *answer, int len, unsigned char *fullanswer))
Parse DNS lookup result, call callback.
#define ast_mutex_unlock(a)
static int dns_parse_answer |
( |
void * |
context, |
|
|
int |
class, |
|
|
int |
type, |
|
|
unsigned char * |
answer, |
|
|
int |
len, |
|
|
int(*)(void *context, unsigned char *answer, int len, unsigned char *fullanswer) |
callback |
|
) |
| |
|
static |
Parse DNS lookup result, call callback.
Definition at line 189 of file dns.c.
References dns_HEADER::ancount, ast_log(), dn_answer::class, LOG_WARNING, dns_HEADER::qdcount, dn_answer::rtype, dn_answer::size, and skip_name().
Referenced by ast_search_dns().
193 unsigned char *fullanswer = answer;
204 for (x = 0; x < ntohs(h->
qdcount); x++) {
217 for (x = 0; x < ntohs(h->
ancount); x++) {
238 if ((res = callback(
context, answer, ntohs(ans->
size), fullanswer)) < 0) {
245 answer += ntohs(ans->
size);
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static int skip_name(unsigned char *s, int len)
static char context[AST_MAX_CONTEXT]
static int skip_name |
( |
unsigned char * |
s, |
|
|
int |
len |
|
) |
| |
|
static |
Definition at line 165 of file dns.c.
Referenced by dns_parse_answer().
175 if ((*s & 0xc0) == 0xc0) {
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)