# SIPURL Class Reference

`#include <sippdu.h>`

## Public Types

| ExternalURI
| URI used anywhere outside of protocol.
| RequestURI
| Request-URI (after the INVITE).
| ToURI
| To header field.
| FromURI
| From header field.
| RouteURI
| Record-Route header field.
| RedirectURI
| Redirect Contact header field.
| ContactURI
| General Contact header field.
| RegContactURI
| Registration Contact header field.
| RegisterURI
| URI on REGISTER request line.
enum | UsageContext { ExternalURI, RequestURI, ToURI, FromURI, RouteURI, RedirectURI, ContactURI, RegContactURI, RegisterURI }

## Public Member Functions

| SIPURL ()
| SIPURL (const PURL &url)
SIPURL & | operator= (const PURL &url)
| SIPURL (const char *cstr, const char *defaultScheme=NULL)
SIPURL & | operator= (const char *cstr)
| SIPURL (const PString &str, const char *defaultScheme=NULL)
SIPURL & | operator= (const PString &str)
| SIPURL (const PString &name, const OpalTransportAddress &address, WORD listenerPort=0, const char *scheme=NULL)
| SIPURL (const OpalTransportAddress &address, WORD listenerPort=0, const char *scheme=NULL)
SIPURL & | operator= (const OpalTransportAddress &address)
| SIPURL (const SIPMIMEInfo &mime, const char *name)
virtual Comparison | Compare (const PObject &obj) const
PString | AsQuotedString () const
PString | GetDisplayName (PBoolean useDefault=true) const
void | SetDisplayName (const PString &str)
const PStringOptions & | GetFieldParameters () const
| Return string options in field parameters.
PStringOptions & | GetFieldParameters ()
PCaselessString | GetTransportProto () const
| Return the correct "transport" parameter, using correct default based on scheme.
OpalTransportAddress | GetTransportAddress (PINDEX dnsEntry=P_MAX_INDEX) const
void | SetHostAddress (const OpalTransportAddress &addr)
void | Sanitise (UsageContext context)
void | SetTag (const PString &tag=PString::Empty(), bool force=false)
| Set a tag with a new unique ID.
PString | GetTag () const
| Get a tag.

## Static Public Member Functions

static PString | GenerateTag ()
| Generate a unique string suitable as a dialog tag.

## Static Public Attributes

static const WORD | DefaultPort
static const WORD | DefaultSecurePort

## Protected Member Functions

void | ParseAsAddress (const PString &name, const OpalTransportAddress &address, WORD listenerPort, const char *scheme)
virtual PBoolean | InternalParse (const char *cstr, const char *defaultScheme)
bool | ReallyInternalParse (bool fromField, const char *cstr, const char *defaultScheme)
WORD | GetDefaultPort () const

## Protected Attributes

PString | m_displayName
PStringOptions | m_fieldParameters

## Detailed Description

This class extends PURL to include displayname, optional "<>" delimiters and extended parameters - like tag. It may be used for From:, To: and Contact: lines.

## Member Enumeration Documentation

enum SIPURL::UsageContext

Enumerator:

  ExternalURI | URI used anywhere outside of protocol.
  RequestURI | Request-URI (after the INVITE).
  ToURI | To header field.
  FromURI | From header field.
  RouteURI | Record-Route header field.
  RedirectURI | Redirect Contact header field.
  ContactURI | General Contact header field.
  RegContactURI | Registration Contact header field.
  RegisterURI | URI on REGISTER request line.

## Constructor & Destructor Documentation

SIPURL::SIPURL | ( |  | ) |

SIPURL::SIPURL | ( | const PURL & | url | ) | `[inline]`

SIPURL::SIPURL | ( | const char * | cstr,
|  | const char * | defaultScheme = `NULL` |
| ) |  |  |

str goes straight to Parse()

Parameters:

  cstr | C string representation of the URL.
  defaultScheme | Default scheme for URL

SIPURL::SIPURL | ( | const PString & | str,
|  | const char * | defaultScheme = `NULL` |
| ) |  |  |

str goes straight to Parse()

Parameters:

  str | String representation of the URL.
  defaultScheme | Default scheme for URL

SIPURL::SIPURL | ( | const PString & | name,
|  | const OpalTransportAddress & | address,
|  | WORD | listenerPort = `0`,
|  | const char * | scheme = `NULL` |
| ) |  |  |

If name does not start with 'sip' then construct URI in the form

              sip:name@host:port;transport=transport

where host comes from address, port is listenerPort or port from address if that was 0 transport is udp unless address specified tcp Send name starting with 'sip' or constructed URI to Parse()

SIPURL::SIPURL | ( | const OpalTransportAddress & | address,
|  | WORD | listenerPort = `0`,
|  | const char * | scheme = `NULL` |
| ) |  |  |

SIPURL::SIPURL | ( | const SIPMIMEInfo & | mime,
|  | const char * | name |
| ) |  |  |

## Member Function Documentation

PString SIPURL::AsQuotedString | ( |  | ) | const

Returns complete SIPURL as one string, including displayname (in quotes) and address in angle brackets.

virtual Comparison SIPURL::Compare | ( | const PObject & | obj | ) | const`[virtual]`

Compare the two SIPURLs and return their relative rank. Note that does an intelligent comparison according to the rules in RFC3261 Section 19.1.4.

Returns:
  `LessThan`, `EqualTo` or `GreaterThan` according to the relative rank of the objects.

Parameters:

  obj | Object to compare against.

static PString SIPURL::GenerateTag | ( |  | ) | `[static]`

Generate a unique string suitable as a dialog tag.

WORD SIPURL::GetDefaultPort | ( |  | ) | const`[protected]`

PString SIPURL::GetDisplayName | ( | PBoolean | useDefault = `true` | ) | const

Returns display name only

PStringOptions& SIPURL::GetFieldParameters | ( |  | ) | `[inline]`

const PStringOptions& SIPURL::GetFieldParameters | ( |  | ) | const`[inline]`

Return string options in field parameters.

PString SIPURL::GetTag | ( |  | ) | const

Get a tag.

OpalTransportAddress SIPURL::GetTransportAddress | ( | PINDEX | dnsEntry = `P_MAX_INDEX` | ) | const

Get the host and port as a transport address. If `dnsEntry` is != P_MAX_INDEX, then follows the rules of RFC3263 to get the remote server address, e.g. using DNS SRV records etc. If there are multiple server addresses, then this gets the "entry"th entry.

PCaselessString SIPURL::GetTransportProto | ( |  | ) | const

Return the correct "transport" parameter, using correct default based on scheme.

virtual PBoolean SIPURL::InternalParse | ( | const char * | cstr,
|  | const char * | defaultScheme |
| ) |  |  | `[inline, protected, virtual]`

SIPURL& SIPURL::operator= | ( | const OpalTransportAddress & | address | ) |

SIPURL& SIPURL::operator= | ( | const PString & | str | ) | `[inline]`

SIPURL& SIPURL::operator= | ( | const char * | cstr | ) | `[inline]`

SIPURL& SIPURL::operator= | ( | const PURL & | url | ) | `[inline]`

void SIPURL::ParseAsAddress | ( | const PString & | name,
|  | const OpalTransportAddress & | address,
|  | WORD | listenerPort,
|  | const char * | scheme |
| ) |  |  | `[protected]`

bool SIPURL::ReallyInternalParse | ( | bool | fromField,
|  | const char * | cstr,
|  | const char * | defaultScheme |
| ) |  |  | `[protected]`

void SIPURL::Sanitise | ( | UsageContext | context | ) |

Removes tag parm & query vars and recalculates urlString (scheme, user, password, host, port & URI parms (like transport)) which are not allowed in the context specified, e.g. Request-URI etc According to RFC3261, 19.1.1 Table 1

Parameters:

  context | Context for URI

void SIPURL::SetDisplayName | ( | const PString & | str | ) | `[inline]`

void SIPURL::SetHostAddress | ( | const OpalTransportAddress & | addr | ) |

Set the host and port as a transport address.

void SIPURL::SetTag | ( | const PString & | tag = `PString::Empty()`,
|  | bool | force = `false` |
| ) |  |  |

Set a tag with a new unique ID.

## Field Documentation

const WORD SIPURL::DefaultPort `[static]`

const WORD SIPURL::DefaultSecurePort `[static]`

PString SIPURL::m_displayName `[protected]`

PStringOptions SIPURL::m_fieldParameters `[protected]`

The documentation for this class was generated from the following file:

- sippdu.h