reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
DnsInterface.hxx
Go to the documentation of this file.
1#if !defined(RESIP_DNSINTERFACE_HXX)
2#define RESIP_DNSINTERFACE_HXX
3
4#include <set>
5#include <vector>
6
8#include "rutil/Data.hxx"
9#include "rutil/Socket.hxx"
11#include "rutil/dns/DnsStub.hxx"
12#include "rutil/dns/RRVip.hxx"
14
15namespace resip
16{
17class DnsHandler;
18class DnsResultSink;
19class DnsResult;
20class Uri;
21class Via;
22class DnsRawSink;
23
25{
26 public:
27 class Exception final : public BaseException
28 {
29 public:
30 Exception(const Data& msg, const Data& file, const int line) : BaseException(msg,file,line){}
31 const char* name() const noexcept override { return "DnsInterface::Exception"; }
32 };
33
34 // Used to create an asynchronous Dns Interface. Any lookup requests will
35 // be queued for later processing. It is critical that the consumer of the
36 // DnsResult be in the same thread that is processing the async results
37 // since there is no locking on the DnsResult
38 // Will throw DnsInterface::Exception if the Dns provider fails to initialize
39 DnsInterface(DnsStub& dnsStub, bool useDnsVip=false);
40
41 virtual ~DnsInterface();
42
43 //Data errorMessage(int status);
44
45 // set the supported set of types that a UAC wishes to use
46 void addTransportType(TransportType type, IpVersion version);
48
49 // return if the client supports the specified service (e.g. SIP+D2T)
50 bool isSupported(const Data& service);
51 bool isSupported(TransportType t, IpVersion version);
52
53 // this is used if NAPTR doesn't return anything to decide which SRV
54 // records to query
57
58 // For each of the following calls, immediately return a DnsResult to the
59 // caller. If synchronous, the DnsResult is complete and may block for an
60 // arbitrary amount of time. In the synchronous case, the transactionId is
61 // not useful. If asynchronous, the DnsResult will be returned immediately
62 // and is owned by the caller. If queries are outstanding, it is not valid
63 // for the caller to delete the DnsResult.
64 //
65 // First determine a transport. Second, determine a set of ports and ip
66 // addresses. These can be returned to the client by asking the DnsResult
67 // for the next result in the form of a Transport:Tuple. The client can
68 // continue to ask the DnsResult to return more tuples. If the tuples for
69 // the current transport are exhausted, move on to the next preferred
70 // transport (if there is one)
71
73 void lookup(DnsResult* res, const Uri& uri);
74
76
77 bool setUdpOnlyOnNumeric(bool value)
78 {
79 mUdpOnlyOnNumeric = value;
80 return mUdpOnlyOnNumeric;
81 }
82
84 {
85 return mUdpOnlyOnNumeric;
86 }
87
88 protected:
91
92 // When complete or partial results are ready, call DnsHandler::process()
93 // For synchronous DnsInterface, set to 0
94 friend class DnsResult;
95 Mutex mSupportedMutex; // Protects mSupportedNaptrs and mSupportTransports
96 typedef std::map<Data, unsigned int> SupportedNaptrMap; // second is for RefCount
98 typedef std::map<std::pair<TransportType, IpVersion>, unsigned int> TransportMap; // second is for RefCount
100 // Whether transport failover should be disabled on URIs with only a numeric
101 // IP address (only UDP will ever be attempted).
103
105 RRVip mVip; // Ensure all access is from DnsThread/DnsStub fifo for thread safety
106 TupleMarkManager mMarkManager; // Ensure all access is from DnsThread/DnsStub fifo for thread safety
107};
108
109}
110
111#endif
112// Copyright (c) 2003, Jason Fischl
113/* ====================================================================
114 * The Vovida Software License, Version 1.0
115 *
116 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
117 *
118 * Redistribution and use in source and binary forms, with or without
119 * modification, are permitted provided that the following conditions
120 * are met:
121 *
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions and the following disclaimer.
124 *
125 * 2. Redistributions in binary form must reproduce the above copyright
126 * notice, this list of conditions and the following disclaimer in
127 * the documentation and/or other materials provided with the
128 * distribution.
129 *
130 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
131 * and "Vovida Open Communication Application Library (VOCAL)" must
132 * not be used to endorse or promote products derived from this
133 * software without prior written permission. For written
134 * permission, please contact vocal@vovida.org.
135 *
136 * 4. Products derived from this software may not be called "VOCAL", nor
137 * may "VOCAL" appear in their name, without prior written
138 * permission of Vovida Networks, Inc.
139 *
140 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
141 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
142 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
143 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
144 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
145 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
146 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
147 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
148 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
149 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
150 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
151 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
152 * DAMAGE.
153 *
154 * ====================================================================
155 *
156 * This software consists of voluntary contributions made by Vovida
157 * Networks, Inc. and many individuals on behalf of Vovida Networks,
158 * Inc. For more information on Vovida Networks, Inc., please see
159 * <http://www.vovida.org/>.
160 *
161 */
162
163// vim: softtabstop=3:shiftwidth=3:expandtab
164
Handles cross-platform sockets compatibility.
The abstract base-class for all exceptions thrown by resip code.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Exception(const Data &msg, const Data &file, const int line)
const char * name() const noexcept override
const Data * getSupportedNaptrType(TransportType type)
void addTransportType(TransportType type, IpVersion version)
TupleMarkManager mMarkManager
void lookup(DnsResult *res, const Uri &uri)
TransportMap mSupportedTransports
std::map< Data, unsigned int > SupportedNaptrMap
bool setUdpOnlyOnNumeric(bool value)
TupleMarkManager & getMarkManager()
bool isSupportedProtocol(TransportType t)
bool getUdpOnlyOnNumeric() const
SupportedNaptrMap mSupportedNaptrs
std::map< std::pair< TransportType, IpVersion >, unsigned int > TransportMap
void removeTransportType(TransportType type, IpVersion version)
bool isSupported(const Data &service)
DnsResult * createDnsResult(DnsHandler *handler=0)
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
Definition Uri.hxx:22
dcm! – add UnusedChecking(_enum) below;
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
Definition Mutex.hxx:37
TransportType
An enumeration of transport protocols.
IpVersion
An enumeration of IP versions.