Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

srv.h File Reference

Go to the source code of this file.

Functions

int ast_get_srv (struct ast_channel *chan, char *host, int hostlen, int *port, const char *service)


Function Documentation

int ast_get_srv struct ast_channel chan,
char *  host,
int  hostlen,
int *  port,
const char *  service
 

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 }


Generated on Fri Oct 31 07:05:18 2003 for Asterisk by doxygen 1.3.4