Parrot.Sip.Headers.Contact (Parrot Platform v0.0.1-alpha.2)
Module for working with SIP Contact headers as defined in RFC 3261 Section 20.10.
The Contact header provides a URI where the user can be reached for subsequent requests. It plays a critical role in dialog establishment, request routing, and registrations. Its meaning depends on the type of request or response it appears in:
- In REGISTER requests: Specifies where the user can be reached
- In INVITE requests: Indicates where the caller can be reached
- In 2xx responses to INVITE: Specifies where the callee can be reached
- In 3xx responses: Provides alternative locations to retry the request
The Contact header can contain parameters:
- expires: Indicates how long the URI is valid (seconds)
- q-value: Indicates preference among multiple contacts
- methods: Specifies which methods the contact supports
- (wildcard): Special form used only in REGISTER requests for removal
References:
- RFC 3261 Section 8.1.1.8: Contact
- RFC 3261 Section 10: Registrations
- RFC 3261 Section 12.1.1: UAC Behavior
- RFC 3261 Section 20.10: Contact Header Field
Summary
Functions
Gets the expires parameter from a Contact header.
Converts a Contact header to a string representation.
Gets a parameter from a Contact header.
Creates a new Contact header.
Parses a Contact header string into a Contact struct.
Gets the q-value parameter from a Contact header.
Creates a new wildcard Contact header.
Sets the expires parameter in a Contact header.
Adds or updates a parameter in a Contact header.
Sets the q-value parameter in a Contact header.
Types
@type t() :: %Parrot.Sip.Headers.Contact{ display_name: String.t() | nil, parameters: map(), uri: String.t() | Parrot.Sip.Uri.t() | nil, wildcard: boolean() }
Functions
Gets the expires parameter from a Contact header.
Converts a Contact header to a string representation.
Gets a parameter from a Contact header.
Creates a new Contact header.
Parses a Contact header string into a Contact struct.
Examples
iex> Parrot.Sip.Headers.Contact.parse("Alice <sip:alice@pc33.atlanta.com>;expires=3600")
%Parrot.Sip.Headers.Contact{display_name: "Alice", uri: %Parrot.Sip.Uri{scheme: "sip", user: "alice", host: "pc33.atlanta.com"}, parameters: %{"expires" => "3600"}, wildcard: false}
iex> Parrot.Sip.Headers.Contact.parse("*")
%Parrot.Sip.Headers.Contact{display_name: nil, uri: nil, parameters: %{}, wildcard: true}
Gets the q-value parameter from a Contact header.
@spec wildcard() :: t()
Creates a new wildcard Contact header.
Sets the expires parameter in a Contact header.
Adds or updates a parameter in a Contact header.
Sets the q-value parameter in a Contact header.