reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TransportType.cxx
Go to the documentation of this file.
1#include <string>
3
4namespace resip
5{
6
8{
9 Data("UNKNOWN_TRANSPORT"),
10 Data("TLS"),
11 Data("TCP"),
12 Data("UDP"),
13 Data("SCTP"),
14 Data("DCCP"),
15 Data("DTLS"),
16 Data("WS"),
17 Data("WSS")
18};
19
21{
22 Data("UNKNOWN_TRANSPORT"),
23 Data("tls"),
24 Data("tcp"),
25 Data("udp"),
26 Data("sctp"),
27 Data("dccp"),
28 Data("dtls"),
29 Data("ws"),
30 Data("wss")
31};
32
34getTransportTypeFromName(const std::string& transportName)
35{
36 return toTransportType(transportName.c_str());
37}
38
40toTransportType(const resip::Data& transportName)
41{
43 i = static_cast<TransportType>(i + 1))
44 {
45 if (isEqualNoCase(transportName, transportNames[i]))
46 {
47 return i;
48 }
49 }
50 return UNKNOWN_TRANSPORT;
51}
52
53std::string
55{
56 return toData(typeEnum).c_str();
57}
58
59std::string
61{
62 return toDataLower(typeEnum).c_str();
63}
64
65const resip::Data&
66toData(const TransportType typeEnum)
67{
68 resip_assert(typeEnum >= UNKNOWN_TRANSPORT && typeEnum < MAX_TRANSPORT);
69 return transportNames[typeEnum];
70}
71
72const resip::Data&
74{
75 resip_assert(typeEnum >= UNKNOWN_TRANSPORT && typeEnum < MAX_TRANSPORT);
76 return transportNamesLower[typeEnum];
77}
78
79bool
81{
82 switch(type)
83 {
84 case TLS:
85 case TCP:
86 case SCTP:
87 case WS:
88 case WSS:
89 return true;
90 case UDP:
91 case DCCP:
92 case DTLS:
93 default:
94 return false;
95 }
96}
97
98bool
100{
101 switch(type)
102 {
103 case TLS:
104 case DTLS:
105 case WSS:
106 return true;
107 case UDP:
108 case TCP:
109 case DCCP:
110 case SCTP:
111 case WS:
112 default:
113 return false;
114 }
115}
116
117bool
119{
120 switch(type)
121 {
122 case WS:
123 case WSS:
124 return true;
125 default:
126 return false;
127 }
128}
129
130}
131
132/* ====================================================================
133 * The Vovida Software License, Version 1.0
134 *
135 * Copyright (c) 2000-2005 Vovida Networks, Inc. All rights reserved.
136 *
137 * Redistribution and use in source and binary forms, with or without
138 * modification, are permitted provided that the following conditions
139 * are met:
140 *
141 * 1. Redistributions of source code must retain the above copyright
142 * notice, this list of conditions and the following disclaimer.
143 *
144 * 2. Redistributions in binary form must reproduce the above copyright
145 * notice, this list of conditions and the following disclaimer in
146 * the documentation and/or other materials provided with the
147 * distribution.
148 *
149 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
150 * and "Vovida Open Communication Application Library (VOCAL)" must
151 * not be used to endorse or promote products derived from this
152 * software without prior written permission. For written
153 * permission, please contact vocal@vovida.org.
154 *
155 * 4. Products derived from this software may not be called "VOCAL", nor
156 * may "VOCAL" appear in their name, without prior written
157 * permission of Vovida Networks, Inc.
158 *
159 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
160 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
161 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
162 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
163 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
164 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
165 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
166 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
167 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
168 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
169 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
170 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
171 * DAMAGE.
172 *
173 * ====================================================================
174 *
175 * This software consists of voluntary contributions made by Vovida
176 * Networks, Inc. and many individuals on behalf of Vovida Networks,
177 * Inc. For more information on Vovida Networks, Inc., please see
178 * <http://www.vovida.org/>.
179 *
180 */
#define resip_assert(x)
This file needs to work for both C and C++ code.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
const char * c_str() const
Returns a null-terminated string representing.
Definition Data.cxx:1097
dcm! – add UnusedChecking(_enum) below;
const resip::Data & toData(const TransportType typeEnum)
static const Data transportNamesLower[MAX_TRANSPORT]
static const Data transportNames[MAX_TRANSPORT]
bool isEqualNoCase(const Data &left, const Data &right)
Definition Data.hxx:1116
bool isWebSocket(TransportType type)
Returns true if passed in transport type is a WebSocket transport protocol.
std::string getTransportNameFromType(const TransportType typeEnum)
Function which translates a transport enum value to its corrisponding name.
TransportType toTransportType(const resip::Data &transportName)
bool isSecure(TransportType type)
Returns true if passed in transport type is a secure transport protocol.
const resip::Data & toDataLower(const TransportType typeEnum)
TransportType getTransportTypeFromName(const std::string &transportName)
Function which translates a transport name to its corrisponding integer enum value.
TransportType
An enumeration of transport protocols.
@ UNKNOWN_TRANSPORT
std::string getTransportNameFromTypeLower(const TransportType typeEnum)
bool isReliable(TransportType type)
Returns true if passed in transport type is a reliable transport protocol.