#include <string.h>#include <fcntl.h>#include <unistd.h>#include <stdlib.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/nameser.h>#include <resolv.h>#include <errno.h>#include <asterisk/logger.h>#include <asterisk/options.h>#include <asterisk/srv.h>#include <asterisk/channel.h>#include <asterisk/config.h>Go to the source code of this file.
Data Structures | |
| struct | dn_answer |
| struct | dns_HEADER |
| struct | srv |
Defines | |
| #define | MAX_SIZE 4096 |
Functions | |
| int | ast_get_srv (struct ast_channel *chan, char *host, int hostlen, int *port, const char *service) |
Variables | |
| dn_answer | __packed__ |
|
|
|
|
||||||||||||||||||||||||
|
Definition at line 243 of file srv.c. References ast_autoservice_start(), ast_autoservice_stop(), ast_log(), LOG_DEBUG, LOG_WARNING, and MAX_SIZE.
00244 {
00245 int res;
00246 int ret = -1;
00247 struct __res_state srvstate;
00248 char answer[MAX_SIZE];
00249
00250 if (*port)
00251 *port = 0;
00252 res_ninit(&srvstate);
00253 if (chan && ast_autoservice_start(chan) < 0)
00254 return -1;
00255 res = res_nsearch(&srvstate, service, C_IN, T_SRV, answer, sizeof(answer));
00256 if (res > 0) {
00257 if ((res = parse_answer(host, hostlen, port, answer, res))) {
00258 ast_log(LOG_WARNING, "Parse error returned %d\n", res);
00259 ret = 0;
00260 } else {
00261 ast_log(LOG_DEBUG, "Found host '%s', port '%d'\n", host, *port);
00262 ret = 1;
00263 }
00264 } else {
00265 ast_log(LOG_DEBUG, "No such service found: %s (%s)\n", service, strerror(errno));
00266 ret = 0;
00267 }
00268 if (chan)
00269 ret |= ast_autoservice_stop(chan);
00270 res_nclose(&srvstate);
00271 return ret;
00272 }
|
|
|
|
1.3.4