Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:49:20 2009

## Asterisk developer's documentation

# srv.h File Reference

Support for DNS SRV records, used in to locate SIP services. More...

This graph shows which files directly or indirectly include this file:

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)

## Detailed Description

Support for DNS SRV records, used in to locate SIP services.

Note:
  Note: The Asterisk DNS SRV record support is broken, it only supports the first DNS SRV record and will give no load balancing or failover support.

Definition in file srv.h.

## Function Documentation

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

Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup Only do SRV record lookup if you get a domain without a port. If you get a port #, it's a DNS host name.

Parameters:

  | chan | Ast channel
  | host | host name (return value)
  | hostlen | Length of string "host"
  | port | Port number (return value)
  | service | Service tag for SRV lookup (like "_sip._udp" or "_stun._udp"

Definition at line 114 of file srv.c.

References ast_autoservice_start(), ast_autoservice_stop(), ast_search_dns(), srv_context::host, srv_context::hostlen, srv_context::port, and srv_callback().

Referenced by ast_get_ip_or_srv(), and create_addr().

    00115 {
    00116    struct srv_context context;
    00117    int ret;
    00118
    00119    context.host = host;
    00120    context.hostlen = hostlen;
    00121    context.port = port;
    00122
    00123    if (chan && ast_autoservice_start(chan) < 0)
    00124       return -1;
    00125
    00126    ret = ast_search_dns(&context, service, C_IN, T_SRV, srv_callback);
    00127
    00128    if (chan)
    00129       ret |= ast_autoservice_stop(chan);
    00130
    00131    if (ret <= 0) {
    00132       host[0] = '\0';
    00133       *port = -1;
    00134       return ret;
    00135    }
    00136    return ret;
    00137 }