/usr/include/resip/stack/Uri.hxx is in libresiprocate-1.11-dev 1:1.11.0~beta5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | #if !defined(RESIP_URI_HXX)
#define RESIP_URI_HXX
#include <bitset>
#include "rutil/ResipAssert.h"
#include "resip/stack/ParserCategory.hxx"
#include "resip/stack/Token.hxx"
#include "rutil/TransportType.hxx"
#include "rutil/HeapInstanceCounter.hxx"
namespace resip
{
class SipMessage;
/**
@ingroup sip_grammar
@brief Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261
grammar. Also can be made to represent other URI types (like tel URIs)
*/
class Uri : public ParserCategory
{
public:
RESIP_HeapCount(Uri);
static const size_t uriEncodingTableSize = 256;
Uri(PoolBase* pool=0);
Uri(const HeaderFieldValue& hfv, Headers::Type type, PoolBase* pool=0);
Uri(const Uri& orig,
PoolBase* pool=0);
explicit Uri(const Data& data);
~Uri();
// convert from a tel scheme to sip scheme, adds user=phone param
//static Uri fromTel(const Uri&, const Data& host); // deprecate...
static Uri fromTel(const Uri&, const Uri& hostUri);
Data& host() {checkParsed(); mHostCanonicalized=false; return mHost;}
const Data& host() const {checkParsed(); return mHost;}
Data& user() {checkParsed(); return mUser;}
const Data& user() const {checkParsed(); return mUser;}
Data& userParameters() {checkParsed(); return mUserParameters;}
const Data& userParameters() const {checkParsed(); return mUserParameters;}
Data& opaque() {checkParsed(); return mHost;}
const Data& opaque() const {checkParsed(); return mHost;}
Data& path() {checkParsed(); return mPath;}
const Data& path() const {checkParsed(); return mPath;}
// Returns user@host[:port] (no scheme)
Data getAor() const;
// Returns user@host (no scheme or port)
Data getAorNoPort() const;
// Actually returns the AOR; <scheme>:<user>@<host>
Data getAorNoReally() const
{
return getAOR(false);
}
// Returns the AOR, optionally adding the port
Data getAOR(bool addPort) const;
//strips all paramters - if transport type is specified (ie. not UNKNOWN_TRANSPORT),
//and the default port for the transport is on the Aor, then it is removed
Uri getAorAsUri(TransportType transportTypeToRemoveDefaultPort = UNKNOWN_TRANSPORT) const;
/**
Returns true if the user appears to fit the BNF for the
'telephone-subscriber' element in the RFC 3261 (and by extension, RFC
3966) grammar. This is important because 'telephone-subscriber' can
have parameters, which you could then access easily through the
getUserAsTelephoneSubscriber() and setUserAsTelephoneSubscriber()
calls.
*/
bool userIsTelephoneSubscriber() const;
/**
Returns the user-part as a 'telephone-subscriber' grammar element (in
other words, this parses the user-part into a dial string and
parameters, with the dial-string accessible with Token::value(), and
the parameters accessible with the various Token::param() and
Token::exists() interfaces).
For example, suppose the following is in the Request-URI:
sip:5555551234;phone-context=+86\@example.com;user=dialstring
The user-part of this SIP URI is "5555551234;phone-context=+86", and it
fits the BNF for the 'telephone-subscriber' grammar element. To access
the 'phone-context' parameter, do something like the following:
@code
Uri& reqUri(sip.header(h_RequestLine).uri());
// !bwc! May add native support for this param later
static ExtensionParameter p_phoneContext("phone-context");
Data phoneContextValue;
if(reqUri.isWellFormed())
{
if(reqUri.exists(p_phoneContext))
{
// Phone context as URI param
phoneContextValue=reqUri.param(p_phoneContext);
}
else if(reqUri.scheme()=="sip" || reqUri.scheme()=="sips")
{
// Might have phone-context as a user param (only happens
// in a sip or sips URI)
// Technically, this userIsTelephoneSubscriber() check is
// required:
// sip:bob;phone-context=+86@example.com doesn't have a
// phone-context param according to the BNF in 3261. But,
// interop may require you to parse this as if it did have
// such a param.
if(reqUri.userIsTelephoneSubscriber())
{
Token telSub(reqUri.getUserAsTelephoneSubscriber());
if(telSub.isWellFormed() && telSub.exists(p_phoneContext))
{
// Phone context as user param
phoneContextValue=telSub.param(p_phoneContext);
}
}
}
}
@endcode
*/
Token getUserAsTelephoneSubscriber() const;
/**
Sets the user-part of this URI using the dial-string and parameters
stored in telephoneSubscriber.
@param telephoneSubscriber The user-part, as a 'telephone-subscriber'
grammar element.
*/
void setUserAsTelephoneSubscriber(const Token& telephoneSubscriber);
Data& scheme() {checkParsed(); return mScheme;}
const Data& scheme() const {checkParsed(); return mScheme;}
int& port() {checkParsed(); return mPort;}
int port() const {checkParsed(); return mPort;}
Data& password() {checkParsed(); return mPassword;}
const Data& password() const {checkParsed(); return mPassword;}
Data& netNs() {return(mNetNs);}
const Data& netNs() const {return(mNetNs);}
Data toString() const;
/** Returns true if the uri can be converted into a string that can be
used as an enum lookup */
bool isEnumSearchable() const;
/** Return a vector of domains to do a NAPTR lookup for enum */
std::vector<Data> getEnumLookups(const std::vector<Data>& suffixes) const;
/** Modifies the default URI encoding character sets */
static void setUriUserEncoding(unsigned char c, bool encode);
static void setUriPasswordEncoding(unsigned char c, bool encode);
bool hasEmbedded() const;
SipMessage& embedded();
const SipMessage& embedded() const;
void removeEmbedded();
virtual void parse(ParseBuffer& pb);
virtual ParserCategory* clone() const;
virtual ParserCategory* clone(void* location) const;
virtual ParserCategory* clone(PoolBase* pool) const;
virtual EncodeStream& encodeParsed(EncodeStream& str) const;
// parse the headers into this as SipMessage
void parseEmbeddedHeaders(ParseBuffer& pb);
EncodeStream& encodeEmbeddedHeaders(EncodeStream& str) const;
Uri& operator=(const Uri& rhs);
bool operator==(const Uri& other) const;
bool operator!=(const Uri& other) const;
bool operator<(const Uri& other) const;
bool aorEqual(const Uri& rhs) const;
typedef std::bitset<Uri::uriEncodingTableSize> EncodingTable;
static EncodingTable& getUserEncodingTable()
{
static EncodingTable userEncodingTable(
Data::toBitset("abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
"-_.!~*\\()&=+$,;?/").flip());
return userEncodingTable;
}
static EncodingTable& getPasswordEncodingTable()
{
static EncodingTable passwordEncodingTable(
Data::toBitset("abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
"-_.!~*\\()&=+$").flip());
return passwordEncodingTable;
}
static EncodingTable& getLocalNumberTable()
{
// ?bwc? 'p' and 'w' are allowed in 2806, but have been removed in
// 3966. Should we support these or not?
static EncodingTable localNumberTable(
Data::toBitset("*#-.()0123456789ABCDEFpw"));
return localNumberTable;
}
static EncodingTable& getGlobalNumberTable()
{
static EncodingTable globalNumberTable(
Data::toBitset("-.()0123456789"));
return globalNumberTable;
}
// Inform the compiler that overloads of these may be found in
// ParserCategory, too.
using ParserCategory::exists;
using ParserCategory::remove;
using ParserCategory::param;
virtual Parameter* createParam(ParameterTypes::Type type, ParseBuffer& pb, const std::bitset<256>& terminators, PoolBase* pool);
bool exists(const Param<Uri>& paramType) const;
void remove(const Param<Uri>& paramType);
#define defineParam(_enum, _name, _type, _RFC_ref_ignored) \
const _enum##_Param::DType& param(const _enum##_Param& paramType) const; \
_enum##_Param::DType& param(const _enum##_Param& paramType); \
friend class _enum##_Param
defineParam(ob,"ob",ExistsParameter,"RFC 5626");
defineParam(gr, "gr", ExistsOrDataParameter, "RFC 5627");
defineParam(comp, "comp", DataParameter, "RFC 3486");
defineParam(duration, "duration", UInt32Parameter, "RFC 4240");
defineParam(lr, "lr", ExistsParameter, "RFC 3261");
defineParam(maddr, "maddr", DataParameter, "RFC 3261");
defineParam(method, "method", DataParameter, "RFC 3261");
defineParam(transport, "transport", DataParameter, "RFC 3261");
defineParam(ttl, "ttl", UInt32Parameter, "RFC 3261");
defineParam(user, "user", DataParameter, "RFC 3261, 4967");
defineParam(extension, "ext", DataParameter, "RFC 3966"); // Token is used when ext is a user-parameter
defineParam(sigcompId, "sigcomp-id", QuotedDataParameter, "RFC 5049");
defineParam(rinstance, "rinstance", DataParameter, "proprietary (resip)");
defineParam(addTransport, "addTransport", ExistsParameter, "RESIP INTERNAL");
defineParam(wsSrcIp, "ws-src-ip", DataParameter, "RESIP INTERNAL (WebSocket)");
defineParam(wsSrcPort, "ws-src-port", UInt32Parameter, "RESIP INTERNAL (WebSocket)");
#undef defineParam
protected:
Data mScheme;
Data mHost;
Data mUser;
Data mUserParameters;
int mPort;
Data mPassword;
Data mNetNs; ///< Net namespace name scoping host and port
Data mPath;
void getAorInternal(bool dropScheme, bool addPort, Data& aor) const;
mutable bool mHostCanonicalized;
mutable Data mCanonicalHost; ///< cache for IPv6 host comparison
private:
std::auto_ptr<Data> mEmbeddedHeadersText;
std::auto_ptr<SipMessage> mEmbeddedHeaders;
static ParameterTypes::Factory ParameterFactories[ParameterTypes::MAX_PARAMETER];
/**
Dummy static initialization variable, for ensuring that the encoding
tables are initialized sometime during static initialization,
preventing the scenario where multiple threads try to runtime init the
same table at the same time.
@note Prior to static initialization of this bool, it could be either
true or false; you should not be using this variable to check
whether the tables are initialized. Just call the getXTable()
accessor function; it will init the table if it is not already.
*/
static const bool tablesMightBeInitialized;
};
}
#include "rutil/HashMap.hxx"
HashValue(resip::Uri);
#endif
/* ====================================================================
* The Vovida Software License, Version 1.0
*
* Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The names "VOCAL", "Vovida Open Communication Application Library",
* and "Vovida Open Communication Application Library (VOCAL)" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact vocal@vovida.org.
*
* 4. Products derived from this software may not be called "VOCAL", nor
* may "VOCAL" appear in their name, without prior written
* permission of Vovida Networks, Inc.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* ====================================================================
*
* This software consists of voluntary contributions made by Vovida
* Networks, Inc. and many individuals on behalf of Vovida Networks,
* Inc. For more information on Vovida Networks, Inc., please see
* <http://www.vovida.org/>.
*
*/
|