reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
SdpCandidate.cxx
Go to the documentation of this file.
1#include "SdpCandidate.hxx"
2
3using namespace sdpcontainer;
4
6{
7 "NONE",
8 "UDP",
9 "TCP-SO",
10 "TCP-ACT",
11 "TCP-PASS",
12 "TLS-SO",
13 "TLS-ACT",
14 "TLS-PASS"
15};
16
18{
19 "NONE",
20 "HOST",
21 "SRFLX",
22 "PRFLX",
23 "RELAY"
24};
25
26// Constructor
28 unsigned int id,
30 uint64_t priority,
31 const char * connectionAddress,
32 unsigned int port,
34 const char * relatedAddress,
35 unsigned int relatedPort,
36 bool inUse) :
37 mFoundation(foundation),
38 mId(id),
39 mTransport(transport),
40 mPriority(priority),
41 mConnectionAddress(connectionAddress),
42 mPort(port),
43 mCandidateType(candidateType),
44 mRelatedAddress(relatedAddress),
45 mRelatedPort(relatedPort),
46 mInUse(inUse)
47{
48}
49
50// Copy constructor
55
56// Destructor
60
63{
64 if (this == &rhs) // handle the assignment to self case
65 return *this;
66
67 // Assign values
68 mFoundation = rhs.mFoundation;
69 mId = rhs.mId;
70 mTransport = rhs.mTransport;
71 mPriority = rhs.mPriority;
72 mConnectionAddress = rhs.mConnectionAddress;
73 mPort = rhs.mPort;
74 mCandidateType = rhs.mCandidateType;
75 mRelatedAddress = rhs.mRelatedAddress;
76 mRelatedPort = rhs.mRelatedPort;
77 mInUse = rhs.mInUse;
78 mExtensionAttributes = rhs.mExtensionAttributes;
79
80 return *this;
81}
82
83bool
85{
86 return mFoundation == rhs.mFoundation &&
87 mId == rhs.mId &&
88 mTransport == rhs.mTransport &&
89 mPriority == rhs.mPriority &&
90 mConnectionAddress == rhs.mConnectionAddress &&
91 mPort == rhs.mPort &&
92 mCandidateType == rhs.mCandidateType &&
93 mRelatedAddress == rhs.mRelatedAddress &&
94 mRelatedPort == rhs.mRelatedPort &&
95 mExtensionAttributes == rhs.mExtensionAttributes &&
96 mInUse == rhs.mInUse;
97}
98
99bool
101{
102 return !operator==(rhs);
103}
104
105bool
107{
108 if(mPriority != rhs.mPriority)
109 {
110 return mPriority > rhs.mPriority; // We want to order a list of these from highest priority to lowest - so condition is reversed
111 }
112
113 // Priority should be unique, so we shouldn't get here, but implementation is included for completeness
114 if(mFoundation != rhs.mFoundation)
115 {
116 return mFoundation < rhs.mFoundation;
117 }
118
119 if(mId != rhs.mId)
120 {
121 return mId < rhs.mId;
122 }
123
124 if(mTransport != rhs.mTransport)
125 {
126 return mTransport < rhs.mTransport;
127 }
128
129 if(mConnectionAddress != rhs.mConnectionAddress)
130 {
131 return mConnectionAddress < rhs.mConnectionAddress;
132 }
133
134 if(mPort != rhs.mPort)
135 {
136 return mPort < rhs.mPort;
137 }
138
139 if(mCandidateType != rhs.mCandidateType)
140 {
141 return mCandidateType < rhs.mCandidateType;
142 }
143
144 if(mRelatedAddress != rhs.mRelatedAddress)
145 {
146 return mRelatedAddress < rhs.mRelatedAddress;
147 }
148
149 if(mRelatedPort != rhs.mRelatedPort)
150 {
151 return mRelatedPort < rhs.mRelatedPort;
152 }
153
154 return false; // equal
155}
156
159{
160 resip::Data dataType(type);
161
163 {
165 }
166 else if(resip::isEqualNoCase("tcp-so", dataType))
167 {
169 }
170 else if(resip::isEqualNoCase("tcp-act", dataType))
171 {
173 }
174 else if(resip::isEqualNoCase("tcp-pass", dataType))
175 {
177 }
178 else if(resip::isEqualNoCase("tls-so", dataType))
179 {
181 }
182 else if(resip::isEqualNoCase("tls-act", dataType))
183 {
185 }
186 else if(resip::isEqualNoCase("tls-pass", dataType))
187 {
189 }
190 else
191 {
193 }
194}
195
198{
199 resip::Data dataType(type);
200
201 if(resip::isEqualNoCase("host", dataType))
202 {
203 return CANDIDATE_TYPE_HOST;
204 }
205 else if(resip::isEqualNoCase("srflx", dataType))
206 {
208 }
209 else if(resip::isEqualNoCase("prflx", dataType))
210 {
212 }
213 else if(resip::isEqualNoCase("relay", dataType))
214 {
216 }
217 else
218 {
219 return CANDIDATE_TYPE_NONE;
220 }
221}
222
225{
226 strm << "SdpCandidate: foundation=" << sdpCandidate.mFoundation
227 << ", id=" << sdpCandidate.mId
228 << ", transport=" << SdpCandidate::SdpCandidateTransportTypeString[sdpCandidate.mTransport]
229 << ", priority=" << sdpCandidate.mPriority
230 << ", addr=" << sdpCandidate.mConnectionAddress
231 << ", port=" << sdpCandidate.mPort
232 << ", type=" << SdpCandidate::SdpCandidateTypeString[sdpCandidate.mCandidateType]
233 << ", relatedAddr=" << sdpCandidate.mRelatedAddress
234 << ", relatedPort=" << sdpCandidate.mRelatedPort
235 << ", ";
236
237 SdpCandidate::SdpCandidateExtensionAttributeList::const_iterator it = sdpCandidate.mExtensionAttributes.begin();
238 for(;it != sdpCandidate.mExtensionAttributes.end(); it++)
239 {
240 strm << it->getName() << "=" << it->getValue() << ", ";
241 }
242
243 strm << "inUse=" << sdpCandidate.mInUse << std::endl;
244 return strm;
245}
246
247
248/* ====================================================================
249
250 Copyright (c) 2007-2008, Plantronics, Inc.
251 All rights reserved.
252
253 Redistribution and use in source and binary forms, with or without
254 modification, are permitted provided that the following conditions are
255 met:
256
257 1. Redistributions of source code must retain the above copyright
258 notice, this list of conditions and the following disclaimer.
259
260 2. Redistributions in binary form must reproduce the above copyright
261 notice, this list of conditions and the following disclaimer in the
262 documentation and/or other materials provided with the distribution.
263
264 3. Neither the name of Plantronics nor the names of its contributors
265 may be used to endorse or promote products derived from this
266 software without specific prior written permission.
267
268 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
269 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
270 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
271 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
272 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
273 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
274 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
275 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
276 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
277 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
278 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
279
280 ==================================================================== */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
SdpCandidate & operator=(const SdpCandidate &rhs)
static SdpCandidateType getCandidateTypeFromString(const char *type)
static const char * SdpCandidateTypeString[]
SdpCandidate(const char *foundation=0, unsigned int id=0, SdpCandidateTransportType transport=CANDIDATE_TRANSPORT_TYPE_NONE, uint64_t priority=0, const char *connectionAddress=0, unsigned int port=0, SdpCandidateType candidateType=CANDIDATE_TYPE_NONE, const char *relatedAddress=0, unsigned int relatedPort=0, bool inUse=false)
bool operator<(const SdpCandidate &rhs) const
static SdpCandidateTransportType getCandidateTransportTypeFromString(const char *type)
static const char * SdpCandidateTransportTypeString[]
bool operator!=(const SdpCandidate &rhs) const
bool operator==(const SdpCandidate &rhs) const
bool isEqualNoCase(const Data &left, const Data &right)
Definition Data.hxx:1116
EncodeStream & operator<<(EncodeStream &strm, const Sdp &)
Definition Sdp.cxx:304
#define EncodeStream
unsigned __int64 uint64_t
Definition stdint.h:95
void list()
Definition userAdmin.cxx:66