Sippet v0.4.8 Sippet.Proxy
Defines very basic operations commonly used in SIP Proxies.
Summary
Functions
Adds a Record-Route header to the request
Adds a Via header to the request
Adds a Via header to the request with a supplied branch
Returns a binary representing a textual branch identifier obtained from the topmost Via header of the request
Forwards the request
Forwards the request to a given request_uri
Forwards a response
Forwards a response using an existing server transaction key
Forwards the request statelessly
Types
on_request_sent :: {:ok, client_key, request} | {:error, reason :: term} | no_return
on_request_sent_stateless :: {:ok, request} | {:error, reason :: term} | no_return
Functions
add_record_route(Sippet.Message.request, Sippet.URI.t) :: Sippet.Message.request
Adds a Record-Route header to the request.
When a proxy wishes to remain on the path of future requests in a dialog created by this request (assuming the request creates a dialog), it inserts a Record-Route header field value in the request, before forwarding.
The indicated hop
parameter should indicate the destination where requests
and responses in a dialog should pass. The hop
SIP-URI will get a "lr"
parameter, if it does not have one, and will be placed as the first header
value.
add_via(Sippet.Message.request, Sippet.Message.protocol, host :: String.t, dport :: integer) :: Sippet.Message.request
Adds a Via header to the request.
A proxy must insert a Via header field value before the existing request Via
header field values. A "branch"
parameter will be randomly computed as
being a 72-bit random string starting with the magic cookie "z9hG4bK"
.
add_via(Sippet.Message.request, Sippet.Message.protocol, host :: String.t, dport :: integer, branch :: String.t) :: Sippet.Message.request
Adds a Via header to the request with a supplied branch
.
A proxy must insert a Via header field value before the existing request Via
header field values. If the branch
parameter does not start with the magic
cookie "z9hG4bK"
, one will be added.
Returns a binary representing a textual branch identifier obtained from the topmost Via header of the request.
This derived branch has the property to be the same case the topmost Via
header of the request
is also the same, as in the case of retransmissions.
This operation is usually performed for stateless proxying, like in the case
of ACK requests, and contains the magic cookie. In order to correctly derive
the branch, the input request
must not have been modified after reception.
Forwards the request.
If the method is :ack
, the request will be sent directly to the network transport.
Otherwise, a new client transaction will be created.
This function will honor the start line request_uri
.
forward_request(Sippet.Message.request, Sippet.URI.t) :: on_request_sent
Forwards the request to a given request_uri
.
If the method is :ack
, the request will be sent directly to the network transport.
Otherwise, a new client transaction will be created.
This function will override the start line request_uri
with the supplied one.
Forwards a response.
You should check and remove the topmost Via before calling this function.
The response will find its way back to an existing server transaction, if one exists, or will be sent directly to the network transport otherwise.
forward_response(Sippet.Message.response, Sippet.Transactions.Server.Key.t) :: on_response_sent
Forwards a response using an existing server transaction key.
See forward_response/1
.
Forwards the request statelessly.
The request will be sent directly to the network transport.