Class SIPURI
Implements the SIP URI concept from the SIP RFC 3261. This class also handles URIs for http, https, ws, wss, msrp, msrps, cid and im schemes. This class also handles URNs that will appear in the SIP request line for NG9-1-1 applications.
Inherited Members
Namespace: SipLib.Core
Assembly: SipLib.dll
Syntax
public class SIPURI
Constructors
| Edit this page View SourceSIPURI(SIPSchemesEnum, SIPEndPoint)
Constructs a new SIPURI from the scheme and a SIPEndPoint Unspecified parameters are set to their default values
Declaration
public SIPURI(SIPSchemesEnum scheme, SIPEndPoint sipEndPoint)
Parameters
| Type | Name | Description |
|---|---|---|
| SIPSchemesEnum | scheme | Scheme |
| SIPEndPoint | sipEndPoint | SIPEndPoint to build the SIPURI from |
SIPURI(SIPSchemesEnum, IPAddress, int)
Constructs a new SIPURI from a scheme, an IPAddress and a port number Unspecified parameters are set to their default values
Declaration
public SIPURI(SIPSchemesEnum scheme, IPAddress address, int port)
Parameters
| Type | Name | Description |
|---|---|---|
| SIPSchemesEnum | scheme | Scheme |
| IPAddress | address | IPAddress -- may be IPv4 or IPv6 |
| int | port | Port number |
SIPURI(string, string, string)
Constructs a new SIPURI from the user, host and parameters and headers strings. Unspecified parameters are set to their default values
Declaration
public SIPURI(string user, string host, string paramsAndHeaders)
Parameters
| Type | Name | Description |
|---|---|---|
| string | user | User part of the URI. Optional |
| string | host | Host portion of the URI. Required |
| string | paramsAndHeaders | URI parameters and headers. Optional |
SIPURI(string, string, string, SIPSchemesEnum)
Constructs a new SIPURI from the user, host, parameters and headers and scheme. Unspecified parameters are set to their default values
Declaration
public SIPURI(string user, string host, string paramsAndHeaders, SIPSchemesEnum scheme)
Parameters
| Type | Name | Description |
|---|---|---|
| string | user | User part of the URI. Optional |
| string | host | Host portion of the URI. Required |
| string | paramsAndHeaders | URI parameters and headers. Optional |
| SIPSchemesEnum | scheme | URI scheme. |
SIPURI(string, string, string, SIPSchemesEnum, SIPProtocolsEnum)
Constructor
Declaration
public SIPURI(string user, string host, string paramsAndHeaders, SIPSchemesEnum scheme, SIPProtocolsEnum protocol)
Parameters
| Type | Name | Description |
|---|---|---|
| string | user | User part of the URI. Optional |
| string | host | Host portion of the URI. Required |
| string | paramsAndHeaders | URI parameters and headers. Optional |
| SIPSchemesEnum | scheme | URI scheme. |
| SIPProtocolsEnum | protocol | Transport protocol |
Fields
| Edit this page View SourceHeaders
Embedded URI headers
Declaration
public SIPParameters Headers
Field Value
| Type | Description |
|---|---|
| SIPParameters |
Host
Host portion of the URI.
Declaration
public string? Host
Field Value
| Type | Description |
|---|---|
| string |
Parameters
URI parameters
Declaration
public SIPParameters Parameters
Field Value
| Type | Description |
|---|---|
| SIPParameters |
Scheme
SIP scheme (sip, sips, etc.)
Declaration
public SIPSchemesEnum Scheme
Field Value
| Type | Description |
|---|---|
| SIPSchemesEnum |
User
User portion of the URI
Declaration
public string? User
Field Value
| Type | Description |
|---|---|
| string |
Properties
| Edit this page View SourceCanonicalAddress
Gets a string that can be used to compare SIP URI addresses.
Declaration
public string CanonicalAddress { get; }
Property Value
| Type | Description |
|---|---|
| string |
HostAddress
Gets the host address portion of the URI. If the address is an IPv6 address, then it will include the [ and ] delimiters.
Declaration
public string HostAddress { get; }
Property Value
| Type | Description |
|---|---|
| string |
HostPort
Gets the port portion of the host address or null if it is not present
Declaration
public string? HostPort { get; }
Property Value
| Type | Description |
|---|---|
| string |
MAddr
Gets the maddr parameter or null if it is not present
Declaration
public string? MAddr { get; }
Property Value
| Type | Description |
|---|---|
| string |
MAddrOrHostAddress
Gets the maddr parameter or the host address if the maddr parameter is not present
Declaration
public string MAddrOrHostAddress { get; }
Property Value
| Type | Description |
|---|---|
| string |
Protocol
The protocol for a SIP URI is dictated by the scheme of the URI and then by the transport parameter and finally by the use of a default protocol. If the URI is a sips one then the protocol must be TLS. After that if there is a transport parameter specified for the URI it dictates the protocol for the URI. Finally if there is no transport parameter for a sip URI then the default UDP transport is used.
Declaration
public SIPProtocolsEnum Protocol { get; set; }
Property Value
| Type | Description |
|---|---|
| SIPProtocolsEnum |
UnescapedUser
Gets the un-escapted user part of the URI or null if there is no user part.
Declaration
public string? UnescapedUser { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceAreEqual(SIPURI, SIPURI)
Returns true if two SIPURI objects represent the same resource
Declaration
public static bool AreEqual(SIPURI uri1, SIPURI uri2)
Parameters
| Type | Name | Description |
|---|---|---|
| SIPURI | uri1 | First SIPURI object |
| SIPURI | uri2 | Second SIPURI object |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the two SIPURI objects are equal |
CopyOf()
Creates a deep copy if this SIPURI object
Declaration
public SIPURI CopyOf()
Returns
| Type | Description |
|---|---|
| SIPURI |
Equals(object?)
Returns true if the input SIPURI represents the same resource as this one
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | SIPURI object to test |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the input SIPURI is equal to this one |
Overrides
| Edit this page View SourceGetHashCode()
Override of GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
| Edit this page View SourceIsDefaultPort()
Indicates whether the SIP URI is using the default port for its protocol. Default ports are 5060 for UDP and TCP, 5061 for TLS, 80 for WS and 443 for WSS.
Declaration
public bool IsDefaultPort()
Returns
| Type | Description |
|---|---|
| bool | True if the default port is being used, false if not. |
Mangle(SIPURI, IPEndPoint)
Checks whether the specified SIP URI Host field contains a private IPv4 address and if so and the received on IP address is different then "mangles" the host to contain the received on IP end point. The purpose of the mangling is to assist in dealing with IPv4 NAT's. If the SIP URI host is IPv6 or a host name no mangling will be done.
Declaration
public static SIPURI? Mangle(SIPURI uri, IPEndPoint receivedOn)
Parameters
| Type | Name | Description |
|---|---|---|
| SIPURI | uri | The SIP URI to mangle. |
| IPEndPoint | receivedOn | The IP end point that the SIP message was received from. |
Returns
| Type | Description |
|---|---|
| SIPURI | A new SIP URI if mangling took place. Null if no mangling occurred. |
ParseSIPURI(string)
Parses a string into a SIPURI object.
Declaration
public static SIPURI ParseSIPURI(string uri)
Parameters
| Type | Name | Description |
|---|---|---|
| string | uri | Input string |
Returns
| Type | Description |
|---|---|
| SIPURI | Returns a new SIPURI object |
Exceptions
| Type | Condition |
|---|---|
| SIPValidationException | Thrown if the input string is not a valid SIPURI |
ToAOR()
Returns an address of record for the SIP URI which is a string in the format user@host.
Declaration
public string ToAOR()
Returns
| Type | Description |
|---|---|
| string | A string representing the address of record for the URI. |
ToParameterlessString()
Returns a string representation of the URI with any parameter and headers omitted except for the transport parameter. The string returned by this function is used amongst other things to match Route headers set by this SIP agent.
Declaration
public string ToParameterlessString()
Returns
| Type | Description |
|---|---|
| string | A string representation of the URI with headers and parameters omitted except for the transport parameter if it is required. |
ToSIPEndPoint()
Converts this SIPURI object into a SIPEndPoint object.
Declaration
public SIPEndPoint? ToSIPEndPoint()
Returns
| Type | Description |
|---|---|
| SIPEndPoint | Returns a SIPEndPoint object if the SIPURI represents an endpoint or null if it does not (for example: urn:service:sos) |
ToString()
Converts this SIPURI object into a string
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
| Edit this page View SourceTryParse(string, out SIPURI?)
Tests to see if a string can be parsed into a SIPURI object.
Declaration
public static bool TryParse(string uriStr, out SIPURI? uri)
Parameters
| Type | Name | Description |
|---|---|---|
| string | uriStr | Input string |
| SIPURI | uri | Output SIPURI object. Set to a valid SIPURI object if successful |
Returns
| Type | Description |
|---|---|
| bool | Returns true if successful or false if an error occurred. |
Operators
| Edit this page View Sourceoperator ==(SIPURI, SIPURI)
Returns true if two SIPURI objects represent the same resource
Declaration
public static bool operator ==(SIPURI uri1, SIPURI uri2)
Parameters
| Type | Name | Description |
|---|---|---|
| SIPURI | uri1 | Right-hand SIPURI object |
| SIPURI | uri2 | Left-hand SIPURI object |
Returns
| Type | Description |
|---|---|
| bool | Returns true if they are equal or false if they are not |
operator !=(SIPURI, SIPURI)
Override of the != operator
Declaration
public static bool operator !=(SIPURI x, SIPURI y)
Parameters
| Type | Name | Description |
|---|---|---|
| SIPURI | x | Left-hand SIPURI object |
| SIPURI | y | Right-hand SIPURI object |
Returns
| Type | Description |
|---|---|
| bool | Returns true if the SIPURI objects are not equal or false if they are equal |