sipxtacklib  Version 3.3
Public Types | Static Public Member Functions | Static Protected Attributes | List of all members
SipSrvLookup Class Reference

A class (with no members) whose 'servers' method implements the RFC 3263 process for determining a list of server entries for a SIP domain name. More...

#include <SipSrvLookup.h>

Public Types

enum  OptionCode {
  OptionCodeNone = 0,
  OptionCodeFirst,
  OptionCodeIgnoreSRV,
  OptionCodeIgnoreNAPTR,
  OptionCodeSortAnswers,
  OptionCodePrintAnswers,
  OptionCodeCNAMELimit,
  OptionCodeNoDefaultTCP,
  OptionCodeLast
}
 Option codes for server lookup. More...
 

Static Public Member Functions

static server_tservers (const char *domain, const char *service, OsSocket::IpProtocolSocketType socketType, int port, const char *srcIp)
 Get the list of server entries for SIP domain name 'domain'. More...
 
static int getOption (OptionCode option)
 Get an option value. More...
 
static void setOption (OptionCode option, int value)
 Set an option value. More...
 
static void setDnsSrvTimeouts (int initialTimeoutInSecs, int retries)
 setOption can be called at any time from any thread without causing harm to any requests that may be being processed. More...
 
static void getDnsSrvTimeouts (int &initialTimeoutInSecs, int &retries)
 Gets the timing paramters for DSN SRV queries. More...
 
static void res_query_and_parse (const char *in_name, int type, res_response *in_response, const char *&out_name, res_response *&out_response)
 Perform a DNS query and parse the results. Follows CNAME records. More...
 

Static Protected Attributes

static OsMutex sMutex
 Mutex to keep the routines thread-safe. More...
 
static int options [OptionCodeLast+1]
 The array of option values. More...
 

Detailed Description

A class (with no members) whose 'servers' method implements the RFC 3263 process for determining a list of server entries for a SIP domain name.

Member Enumeration Documentation

enum OptionCode

Option codes for server lookup.

Enumerator
OptionCodeNone 

Special value.

OptionCodeFirst 

Start of range.

OptionCodeIgnoreSRV 

If 1, do not search for SRV records.

OptionCodeIgnoreNAPTR 

If 1, do not search for NAPTR records.

OptionCodeSortAnswers 

If 1, sort DNS answers before using them.

(For testing only.)

OptionCodePrintAnswers 

If 1, print DNS answers.

(For testing only.)

OptionCodeCNAMELimit 

Max. number of CNAMEs to follow.

OptionCodeNoDefaultTCP 

If 1, do not add TCP contacts by default, for better RFC 3263 conformance.

OptionCodeLast 

End of range.

Member Function Documentation

server_t * servers ( const char *  domain,
const char *  service,
OsSocket::IpProtocolSocketType  socketType,
int  port,
const char *  srcIp 
)
static

Get the list of server entries for SIP domain name 'domain'.

Returns the list of server entries for SIP domain name 'domain'. Implements the processes of RFC 2543. The search process is modified by the parameters:

The 'service' is the URI scheme, "sip" or "sips".

The 'port' argument is the port number supplied in the URI, or a negative number if none was supplied. If none was supplied, SRV records are consulted. If no SRV records are found, port defaults to 5060 for "sip" service and 5061 for "sips" service.

The 'socketType' restricts the search to that sort of transport, and may have the values (within IpProtocolSocketType): TCP UDP SSL_SOCKET UNKNOWN (all of the above are acceptable) It is used if the URI or other context information specifies a transport. If UNKNOWN is specified, servers() attempts to return addresses for all transports that it knows about that are compatible with the service. (If socketType is incompatible with service, no addresses will be returned.)

Returns
Allocates an array of server_t objects and returns the pointer to it. Caller is responsible for delete[]'ing the array. The servers are listed in the array in preference order, with a final entry with a host value of NULL.
Parameters
domainSIP domain name or host name
service"sip" or "sips"
socketTypetypes of transport
portport number from URI, or PORT_NONE
srcIpthe outgoing interface ip to send the request on
static int getOption ( OptionCode  option)
inlinestatic

Get an option value.

void setOption ( OptionCode  option,
int  value 
)
static

Set an option value.

void setDnsSrvTimeouts ( int  initialTimeoutInSecs,
int  retries 
)
static

setOption can be called at any time from any thread without causing harm to any requests that may be being processed.

Sets the DNS SRV times. Defaults: timeout=5, retries=4.

It may, however, block until all current requests are processed before returning to the caller, and current requests may be processed partly under the old configuration and partly under the new configuration.Sets the timing parameters for DNS SRV queries.

Parameters
initialTimeoutInSecsTimeout in seconds for first query, or 0 for no change.
retriesNumber of retries to attempt, or 0 for no change.
void getDnsSrvTimeouts ( int &  initialTimeoutInSecs,
int &  retries 
)
static

Gets the timing paramters for DSN SRV queries.

Defaults are: timeout = 5, retries = 4.

void res_query_and_parse ( const char *  in_name,
int  type,
res_response in_response,
const char *&  out_name,
res_response *&  out_response 
)
static

Perform a DNS query and parse the results. Follows CNAME records.

Performs a DNS query for a particular type of RR on a given name, doing all the work to follow CNAMEs. The 'in_name' and 'type' arguments specify the RRs to look for. If 'in_response' is not NULL, it is the results of some previous search for the same name, for a different type of RR, which might contain RRs for this search.

Returns
out_response is a pointer to a response structure, or NULL. If non-NULL, the RRs of the required type (if any) are in out_response (in either the answer section or the additional section), under the name out_name.

The caller is responsible for freeing out_name if it is non-NULL and != in_name. The caller is responsible for freeing out_response if it is non-NULL and != in_response.

Parameters
in_namedomain name to look up
typeRR type to look up
in_responseresponse structure to look in before calling res_query, or NULL
out_namecanonical name for in_name
out_responseresponse structure containing RRs

Member Data Documentation

OsMutex sMutex
staticprotected

Mutex to keep the routines thread-safe.

int options
staticprotected
Initial value:
= {
0,
0,
0,
0,
0,
0,
0,
0
}

The array of option values.

Set the initial values.


sipXtackLib home page