reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ExternalDns.hxx
Go to the documentation of this file.
1#if !defined(RESIP_EXTERNAL_DNS_HXX)
2#define RESIP_EXTERNAL_DNS_HXX
3
4#include <vector>
5
6#include "rutil/AsyncID.hxx"
8
9struct hostent;
10
11namespace resip
12{
13class ExternalDnsHandler;
14class ExternalDnsRawResult;
15class ExternalDnsHostResult;
16class FdPollGrp;
17
18//used by the asynchronous executive
20{
21 public:
23 {
24 None = 0,
25 TryServersOfNextNetworkUponRcode3 = 1 << 0, // 'No such name'
26 ReturnAllResults = 1 << 1 //Don't discard errors, the precise error values are used to
27 //decide whether the hosts file should be consulted, see
28 //DnsStub.cxx DnsStub::Query::process()
29 };
30
31 //returns Success, BuildMismatch, otherwise ExternalDns specific
32 //error message can be pulled from errorMessage
34 {
36 BuildMismatch = 4777
37 };
38
39 // When enabled, a resolver that can tell when its sockets are connected
40 // (c-ares) calls the socket function a second time, once connected, as
41 // SIP TCP connections do. Set through
42 // Connection::setEnablePostConnectSocketFuncCall().
43 static void setEnablePostConnectSocketFuncCall(bool enabled = true);
45
46
47 //
48 virtual int init(const std::vector<GenericIPAddress>& additionalNameservers,
50 int dnsTimeout = 0,
51 int dnsTries = 0,
52 unsigned int features = 0) = 0; // bit mask of Features
53
54 // reinitializes with the same additionalNameservers and AfterSocketCreationFuncPtr as last call to init
55 virtual int init(int dnsTimeout = 0, int dnsTries = 0, unsigned int features = 0) = 0;
56
57 virtual void changeNameServers(const std::vector<GenericIPAddress>& additional) = 0;
58 //returns 'true' only is there are changes in the DNS server list
59 virtual bool checkDnsChange() = 0;
60
61 //For use in select timeout
62 virtual unsigned int getTimeTillNextProcessMS() = 0;
63
64 //this is scary on windows; the standard way to get a bigger fd_set is to
65 //redefine FD_SETSIZE befor each inclusion of winsock2.h, so make sure
66 //external libraries have been properly configured
67 // MUST not be called when pollGrp (below) is active
68 // Only needed when no FdPollGrp is set (e.g. resip/stack/test/testDns)
69 virtual void buildFdSet(fd_set& read, fd_set& write, int& size) = 0;
70 virtual void process(fd_set& read, fd_set& write) = 0;
71
72 virtual void setPollGrp(FdPollGrp *grp) = 0;
73
74 // called by DnsStub to process timers requested by getTimeTillNext...()
75 // only used when poll group is active
76 virtual void processTimers() = 0;
77
78 virtual void freeResult(ExternalDnsRawResult res) = 0;
79 virtual void freeResult(ExternalDnsHostResult res) = 0;
80
81 //caller must clean up memory
82 virtual char* errorMessage(long errorCode) = 0;
83
84 virtual ~ExternalDns() {}
85
86 virtual void lookup(const char* target, unsigned short type, ExternalDnsHandler* handler, void* userData) = 0;
87
88 virtual bool hostFileLookup(const char* target, in_addr &addr) = 0;
89 virtual bool hostFileLookupLookupOnlyMode() = 0;
90};
91
93{
94 public:
95 ExternalDnsResult(long errorCode, void* uData) : AsyncResult(errorCode) , userData(uData) {}
96 ExternalDnsResult(void* uData) : userData(uData) {}
97 void* userData;
98};
99
100//should this be nested?
102{
103 public:
104 ExternalDnsRawResult(unsigned char* buf, int len, void* uData) :
105 ExternalDnsResult(uData),
106
107 abuf(buf),
108 alen(len)
109 {}
110 ExternalDnsRawResult(long errorCode, unsigned char* buf, int len, void* uData) :
112 abuf(buf),
113 alen(len)
114 {}
115
116 unsigned char* abuf;
117 int alen;
118};
119
121{
122 public:
123 ExternalDnsHostResult(hostent* h, void* uData) :
124 ExternalDnsResult(uData),
125 host(h)
126 {}
128
129 hostent* host;
130};
131
133{
134 public:
135 //underscores are against convention, but pretty impossible to read
136 //otherwise. ?dcm? -- results stack or heap?
137 //the free routines can be dealt w/ iheritence instead if pointers are used
138 //virtual void handle_NAPTR(ExternalDnsRawResult res) = 0;
139 //virtual void handle_SRV(ExternalDnsRawResult res) = 0;
140 //virtual void handle_AAAA(ExternalDnsRawResult res) = 0;
141 //virtual void handle_host(ExternalDnsHostResult res) = 0;
142
143 // new version
145 virtual void handleDnsRaw(ExternalDnsRawResult res) = 0;
146};
147
148}
149
150#endif
151
152
153/* ====================================================================
154 * The Vovida Software License, Version 1.0
155 *
156 * Copyright (c) 2026 SIP Spectrum, Inc. http://www.sipspectrum.com
157 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
158 *
159 * Redistribution and use in source and binary forms, with or without
160 * modification, are permitted provided that the following conditions
161 * are met:
162 *
163 * 1. Redistributions of source code must retain the above copyright
164 * notice, this list of conditions and the following disclaimer.
165 *
166 * 2. Redistributions in binary form must reproduce the above copyright
167 * notice, this list of conditions and the following disclaimer in
168 * the documentation and/or other materials provided with the
169 * distribution.
170 *
171 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
172 * and "Vovida Open Communication Application Library (VOCAL)" must
173 * not be used to endorse or promote products derived from this
174 * software without prior written permission. For written
175 * permission, please contact vocal@vovida.org.
176 *
177 * 4. Products derived from this software may not be called "VOCAL", nor
178 * may "VOCAL" appear in their name, without prior written
179 * permission of Vovida Networks, Inc.
180 *
181 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
182 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
183 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
184 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
185 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
186 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
187 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
188 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
189 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
190 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
191 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
192 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
193 * DAMAGE.
194 *
195 * ====================================================================
196 *
197 * This software consists of voluntary contributions made by Vovida
198 * Networks, Inc. and many individuals on behalf of Vovida Networks,
199 * Inc. For more information on Vovida Networks, Inc., please see
200 * <http://www.vovida.org/>.
201 *
202 */
long errorCode() const
Definition AsyncID.hxx:36
virtual void handleDnsRaw(ExternalDnsRawResult res)=0
ExternalDnsHostResult(hostent *h, void *uData)
ExternalDnsHostResult(long errorCode, void *uData)
ExternalDnsRawResult(long errorCode, unsigned char *buf, int len, void *uData)
ExternalDnsRawResult(unsigned char *buf, int len, void *uData)
ExternalDnsResult(long errorCode, void *uData)
ExternalDnsResult(void *uData)
virtual bool checkDnsChange()=0
virtual void lookup(const char *target, unsigned short type, ExternalDnsHandler *handler, void *userData)=0
virtual int init(const std::vector< GenericIPAddress > &additionalNameservers, AfterSocketCreationFuncPtr, int dnsTimeout=0, int dnsTries=0, unsigned int features=0)=0
virtual void freeResult(ExternalDnsRawResult res)=0
virtual int init(int dnsTimeout=0, int dnsTries=0, unsigned int features=0)=0
virtual bool hostFileLookup(const char *target, in_addr &addr)=0
static bool getEnablePostConnectSocketFuncCall()
static void setEnablePostConnectSocketFuncCall(bool enabled=true)
virtual bool hostFileLookupLookupOnlyMode()=0
virtual unsigned int getTimeTillNextProcessMS()=0
virtual void freeResult(ExternalDnsHostResult res)=0
virtual void buildFdSet(fd_set &read, fd_set &write, int &size)=0
virtual char * errorMessage(long errorCode)=0
virtual void setPollGrp(FdPollGrp *grp)=0
virtual void process(fd_set &read, fd_set &write)=0
virtual void processTimers()=0
virtual void changeNameServers(const std::vector< GenericIPAddress > &additional)=0
dcm! – add UnusedChecking(_enum) below;
void(* AfterSocketCreationFuncPtr)(Socket s, int transportType, const char *file, int line)
Definition Socket.hxx:107
void list()
Definition userAdmin.cxx:66