Use the SipUriParser class to parse and construct Session Initiation Protocol (SIP) uniform resource identifiers (URIs) in the Unified Communications Managed API version 1.0 SDK. For more information about SIP URIs, see the SIP: Session Initiation Protocol RFC.
SIP URI Components
The following example SIP URI shows the general form.
Copy Code | |
---|---|
sip:user:password@host:port;uri-parameters?headers |
The following table describes SIP URI components.
Component | Example | Description |
---|---|---|
Scheme |
sip |
Identifies the scheme. Note that SIPS URIs follow the same form as SIP URIs. |
user |
user |
The identifier of a particular resource at the host being addressed. |
password |
password |
A password associated with the user. Using this is not recommended because passing authentication information in clear text is a security risk. |
host |
example.com |
The host providing the SIP resource. Required. |
Port |
5151 |
The port number where the request is sent. |
URI parameters |
user=phone |
Parameters affecting a request constructed from the URI. URI parameters are added after the hostport component and are separated by semicolons. |
Headers |
priority=urgent |
Additional information added after the parameters. |
SIP URI Parameters
The following table describes members of the parameters collection of a SIP URI.
Parameter | Description |
---|---|
transport |
Determines the transport protocol to be used for sending SIP messages. For a SIPS URI, the transport parameter must indicate a reliable transport protocol. |
maddr |
Indicates the server address to be contacted for this user, overriding any address derived from the host field. |
ttl |
Determines the time-to-live value of the UDP multicast packet. Valid only if maddr is a multicast address, and the transport protocol is UDP (User Datagram Protocol). |
user |
Use the user parameter to distinguish telephone numbers from user names that happen to look like telephone numbers. If the user string contains a telephone number formatted as a telephone-subscriber, add the user parameter phone value to identify the value as a user name. |
method |
The method of the SIP request constructed from the URI may be specified with the method parameter. |
lr |
Indicates that the element responsible for this resource implements the routing mechanisms specified in RFC 3261. |
grid |
Identifies endpoints within the application server. |
gruu |
Several applications of SIP require a user agent (UA) to construct and distribute a URI that can be used by anyone on the Internet to route a call to that specific UA instance. A URI that routes to a specific UA instance is called a Globally Routable UA URI (GRUU). |
opaque |
Identifies a specific endpoint. |
SIP URI Header Fields
Header fields in the SIP request can be specified with the ? mechanism within a URI. The header names and values are encoded in ampersand separated name/value pairs. The special name body indicates that the associated value is the message-body of the SIP request.
Parsing SIP URIs
The SipUriParser class provides properties and methods to access data contained in SIP URIs.
Parsing Components
Use SipUriParser properties to parse component values. See the following example code.
Copy Code | |
---|---|
SipUriParser p = new SipUriParser("sip:someone@example.com:2020"); string uriHost = p.Host; string uriHostAndPort = p.HostAndPort; int uriPort = p.Port; string uriUser = p.User; string uriUserAtHost = p.UserAtHost; |
Parsing Parameters
Use the FindParameter method to access parameter values. See the following example code.
Copy Code | |
---|---|
SipUriParser p = new SipUriParser("sip:someone@example.com:2020;maddr=10.0.0.20"); SipUriParameter param = p.FindParameter("maddr"); |
Parsing Headers
Use the FindHeader method to access header values. See the following example code.
Copy Code | |
---|---|
SipUriParser p = new SipUriParser("sip:someone@example.com:2020;maddr=10.0.0.20?replaces=somebodyelse%40example.com%3Btotoag%3Dadf1713ab"); SignalingHeader header = p.FindHeader("replaces"); |