sipxtacklib  Version 3.3
SipSrvLookup.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2004-2006 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 
15 #ifndef _SipSrvLookup_h_
16 #define _SipSrvLookup_h_
17 
18 // SYSTEM INCLUDES
19 #if defined(_WIN32)
20 //# include <resparse/wnt/netinet/in.h>
21 #elif defined(_VXWORKS)
22 # include <netinet/in.h>
23 #elif defined(__pingtel_on_posix__)
24 # include <netinet/in.h>
25 #else
26 # error Unsupported target platform.
27 #endif
28 
29 // APPLICATION INCLUDES
30 #include "os/OsDefs.h"
31 #include "os/OsMutex.h"
32 #include "os/OsSocket.h"
33 
34 // DEFINES
35 // MACROS
36 // EXTERNAL FUNCTIONS
37 // EXTERNAL VARIABLES
38 // CONSTANTS
39 // STRUCTS
40 
41 // TYPEDEFS
42 
43 // FORWARD DECLARATIONS
44 class server_t;
45 typedef struct s_res_response
47 
54 {
55 /* //////////////////////////// PUBLIC //////////////////////////////////// */
56 public:
57 
59  static server_t* servers(const char *domain,
61  const char *service,
63  OsSocket::IpProtocolSocketType socketType,
65  int port,
67  const char* srcIp
69  );
101  enum OptionCode {
115  };
133  static inline int getOption(OptionCode option)
135  {
136  return options[option];
137  }
138 
140  static void setOption(OptionCode option, int value);
150  static void setDnsSrvTimeouts(int initialTimeoutInSecs,
154  int retries
157  );
158 
160  static void getDnsSrvTimeouts(int& initialTimeoutInSecs,
161  int& retries);
162 
164 
166  static void res_query_and_parse(const char* in_name,
168  int type,
170  res_response* in_response,
174  const char*& out_name,
176  res_response*& out_response
178  );
196 /* //////////////////////////// PROTECTED ///////////////////////////////// */
197 protected:
198 
200  static OsMutex sMutex;
201 
203  static int options[OptionCodeLast+1];
204 
205 /* //////////////////////////// PRIVATE /////////////////////////////////// */
206 private:
207 };
208 
209 
213 class server_t {
214  public:
215 
217  static void setDnsSrvResolveEnabled(UtlBoolean& enabled);
218 
219  char *host;
220  OsSocket::IpProtocolSocketType type;
222  struct sockaddr_in sin;
223  unsigned int priority;
224  unsigned int weight;
225  float score;
226 
228  server_t();
229  static UtlBoolean mDnsSrvResolveEnabled;
230 
232  server_t(const server_t& rserver_t);
233 
235  server_t& operator=(const server_t& rhs);
236 
238  ~server_t();
239 
241  UtlBoolean isValidServerT();
243 
245  void getHostNameFromServerT(UtlString& hostName);
246 
248  void getIpAddressFromServerT(UtlString& hostName);
249 
251  int getPortFromServerT();
252 
254  unsigned int getWeightFromServerT();
255 
257  float getScoreFromServerT();
258 
260  unsigned int getPriorityFromServerT();
261 
263  OsSocket::IpProtocolSocketType getProtocolFromServerT();
264 };
265 
266 #endif // _SipSrvLookup_h_
Special value.
Definition: SipSrvLookup.h:103
If 1, do not search for NAPTR records.
Definition: SipSrvLookup.h:106
OptionCode
Option codes for server lookup.
Definition: SipSrvLookup.h:102
unsigned int priority
SRV priority value.
Definition: SipSrvLookup.h:223
float score
Calculated sorting score.
Definition: SipSrvLookup.h:225
Definition: rr.h:285
unsigned int weight
SRV weight.
Definition: SipSrvLookup.h:224
If 1, print DNS answers.
Definition: SipSrvLookup.h:109
A class (with no members) whose &#39;servers&#39; method implements the RFC 3263 process for determining a li...
Definition: SipSrvLookup.h:53
Start of range.
Definition: SipSrvLookup.h:104
End of range.
Definition: SipSrvLookup.h:114
If 1, sort DNS answers before using them.
Definition: SipSrvLookup.h:107
If 1, do not search for SRV records.
Definition: SipSrvLookup.h:105
static int getOption(OptionCode option)
Get an option value.
Definition: SipSrvLookup.h:134
static int options[OptionCodeLast+1]
The array of option values.
Definition: SipSrvLookup.h:203
Max. number of CNAMEs to follow.
Definition: SipSrvLookup.h:111
static server_t * servers(const char *domain, const char *service, OsSocket::IpProtocolSocketType socketType, int port, const char *srcIp)
Get the list of server entries for SIP domain name &#39;domain&#39;.
Definition: SipSrvLookup.cpp:245
char * host
Host name. (Owned by this object.)
Definition: SipSrvLookup.h:219
Structure to describe a server found for a SIP domain.
Definition: SipSrvLookup.h:213
OsSocket::IpProtocolSocketType type
OsSocket:{TCP,UDP,SSL_SOCKET}.
Definition: SipSrvLookup.h:220
static OsMutex sMutex
Mutex to keep the routines thread-safe.
Definition: SipSrvLookup.h:200
static UtlBoolean mDnsSrvResolveEnabled
Definition: SipSrvLookup.h:229
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.
Definition: SipSrvLookup.cpp:764
If 1, do not add TCP contacts by default, for better RFC 3263 conformance.
Definition: SipSrvLookup.h:112
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 ...
Definition: SipSrvLookup.cpp:416
static void getDnsSrvTimeouts(int &initialTimeoutInSecs, int &retries)
Gets the timing paramters for DSN SRV queries.
Definition: SipSrvLookup.cpp:445
static void setOption(OptionCode option, int value)
Set an option value.
Definition: SipSrvLookup.cpp:407

sipXtackLib home page