Sippet v0.3.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

client_key()
on_request_sent()
on_request_sent ::
  {:ok, client_key, request} |
  {:error, reason :: term} |
  no_return
on_request_sent_stateless()
on_request_sent_stateless ::
  {:ok, request} |
  {:error, reason :: term} |
  no_return
on_response_sent()
on_response_sent() :: :ok | {:error, reason :: term} | no_return
request()
request() :: Sippet.Message.request

Functions

add_record_route(request, hop)

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(request, protocol, host, port)

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(request, protocol, host, port, branch)
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.

derive_branch(request)
derive_branch(request) :: binary

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.

forward_request(request)

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(request, request_uri)

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.

forward_response(response)

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(response, server_key)

Forwards a response using an existing server transaction key.

See forward_response/1.

stateless_forward_request(request)
stateless_forward_request(request) :: on_request_sent_stateless

Forwards the request statelessly.

The request will be sent directly to the network transport.