Module siprequest

Various functions related to SIP requests.

Introduced in: 15 Nov 2002 by Magnus Ahltorp <ahltorp@nada.kth.se>

Authors: Magnus Ahltorp (ahltorp@nada.kth.se).

Description

Various functions related to SIP requests.

Function Index

add_record_route/2 Prepend a Record-Route header for this proxy, based on the original Request-URI, to Header.
add_record_route/4 Prepend a Record-Route header for Proto:Host:Port to the Header keylist.
binary_make_message/3 Create a binary representing the request/response, ready to be sent out on the wire.
check_proxy_request/1 Prepares a request for proxying.
construct_record_route/1Equivalent to construct_record_route(Proto, undefined, undefined).
construct_record_route/3 Construct a Record-Route header value for this proxy.
create_via/2 Create a Via for this proxy, given the protocol.
fix_content_length/2 Before sending out requests/responses, make sure the Content-Length is correct (don't trust the length computed by some previous hop).
generate_branch/0 Generate a branch that is 'unique across space and time'.
get_approximate_msgsize/1 Approximate how big a request will be when we send it.
get_loop_cookie/3 Generate a loop detection cookie, RFC3261 16.6 #8.
make_answerheader/1 Turn Request-Route header from a response into Route- header to include in another request in the same dialog.
make_base64_md5_token/1 Make md5 of input, base64 of that and RFC3261 token of the result.
make_response/7 Create a response given a request.
myhostname/0 Get my hostname (the first one in the list, or my IP address if I have no list of configured hostnames).
process_route_header/2 Looks at the Route header.
proxy_add_via/4 Generate a Via header for this proxy and add it to Header.
request_to_me/3 Produce a standard 200 OK response to an OPTIONS request an YXA application received.
send_answer/3 Produce a standard '200 OK' response with Content-Type set to 'application/sdp' (so Body better be an SDP).
send_auth_req/4 Send a '401 Authentication Required' response.
send_notavail/2 Send a '480 Temporarily Unavailable' response with a Retry-After: 180 header.
send_notfound/2 Send a '404 Not Found' response.
send_proxyauth_req/4 Send a '407 Proxy Authentication Required' response.
send_redirect/3 Send a '302 Moved Temporarily' response.
set_request_body/2 Set the body of a request record.
set_response_body/2 Set the body of a request record, and calculate Content-Length.
standardcopy/2 Copy the headers that are required for all responses (Via, From, To, Call-Id, CSeq) plus any extra requested headers from a source Header keylist and create a new keylist based on these.
stateless_route_proxy_request/1 Inspect a request that some YXA application has found it should proxy statelessly.

Function Details

add_record_route/2

add_record_route(URL, Header) -> NewHeader

Prepend a Record-Route header for this proxy, based on the original Request-URI, to Header.

add_record_route/4

add_record_route(Proto, Hostname, Port, Header) -> NewHeader

Prepend a Record-Route header for Proto:Host:Port to the Header keylist.

binary_make_message/3

binary_make_message(BinLine1, Header, BinBody) -> Msg

Create a binary representing the request/response, ready to be sent out on the wire.

check_proxy_request/1

check_proxy_request(Request) -> {ok, NewHeader, ApproxMsgSize}

throws {siperror, Status, Reason} | {siperror, Status, Reason, ExtraHeaders}

Prepares a request for proxying. Checks Max-Forwards, etc. Not guaranteed to return, might throw a siperror if the request should not be proxied.

construct_record_route/1

construct_record_route(Proto) -> RRStr

Equivalent to construct_record_route(Proto, undefined, undefined).

construct_record_route/3

construct_record_route(Proto, Hostname, Port) -> RRStr

Construct a Record-Route header value for this proxy.

create_via/2

create_via(Proto, Parameters) -> Via

Create a Via for this proxy, given the protocol.

fix_content_length/2

fix_content_length(Header, Body) -> NewHeader

Before sending out requests/responses, make sure the Content-Length is correct (don't trust the length computed by some previous hop). This is partly for backwards compliance with RFC2543 UAC's who were not required to include a Content-Length.

generate_branch/0

generate_branch() -> Branch

Generate a branch that is 'unique across space and time'.

get_approximate_msgsize/1

get_approximate_msgsize(Request) -> Size

Approximate how big a request will be when we send it. We must know this when determining if it is OK to send it to a UDP destination or not.

get_loop_cookie/3

get_loop_cookie(Header, OrigURI, Proto) -> Cookie

Generate a loop detection cookie, RFC3261 16.6 #8.

make_answerheader/1

make_answerheader(Header) -> NewHeader

Turn Request-Route header from a response into Route- header to include in another request in the same dialog.

make_base64_md5_token/1

make_base64_md5_token(In) -> term()

returns: Result of make_3261_token()

Make md5 of input, base64 of that and RFC3261 token of the result. Tokens are case-insensitive, so we lowercase the ones we generate here to make them easier to read.

make_response/7

make_response(Status, Reason, Body, ExtraHeaders, ViaParameters, SipSocket, Request) -> Response

Create a response given a request.

myhostname/0

myhostname() -> Hostname

Get my hostname (the first one in the list, or my IP address if I have no list of configured hostnames).

process_route_header/2

process_route_header(Header, URI) -> {ok, NewHeader, NewDestURI, NewRequestURI} | nomatch

Looks at the Route header. If it exists, we return a new destination URL for this request, and if there was no loose router flag in the new destination we append the original Request-URI to the list of routes, to traverse strict (RFC2543) proxys.

proxy_add_via/4

proxy_add_via(Header, OrigURI, Parameters, Proto) -> NewHeader

Generate a Via header for this proxy and add it to Header

request_to_me/3

request_to_me(Request, YxaCtx, ExtraHeaders) -> term()

returns: result of transactionlayer:send_response_handler/4

Produce a standard 200 OK response to an OPTIONS request an YXA application received.

send_answer/3

send_answer(Header, Socket, Body) -> term()

returns: send result

Produce a standard '200 OK' response with Content-Type set to 'application/sdp' (so Body better be an SDP).

send_auth_req/4

send_auth_req(Header, Socket, Auth, Stale) -> term()

returns: send result

Send a '401 Authentication Required' response.

send_notavail/2

send_notavail(Header, Socket) -> term()

returns: send result

Send a '480 Temporarily Unavailable' response with a Retry-After: 180 header.

send_notfound/2

send_notfound(Header, Socket) -> term()

returns: send result

Send a '404 Not Found' response.

send_proxyauth_req/4

send_proxyauth_req(Header, Socket, Auth, Stale) -> term()

returns: send result

Send a '407 Proxy Authentication Required' response.

send_redirect/3

send_redirect(Location, Header, Socket) -> term()

returns: send result

Send a '302 Moved Temporarily' response.

set_request_body/2

set_request_body(Request, Body) -> NewRequest

Set the body of a request record.

set_response_body/2

set_response_body(Response::Request, Body) -> NewResponse

Set the body of a request record, and calculate Content-Length.

standardcopy/2

standardcopy(Header, ExtraHeaders) -> NewHeader

Copy the headers that are required for all responses (Via, From, To, Call-Id, CSeq) plus any extra requested headers from a source Header keylist and create a new keylist based on these.

stateless_route_proxy_request/1

stateless_route_proxy_request(Request) -> {ok, Dst, NewRequest}

throws {siperror, Status, Reason} | {siperror, Status, Reason, ExtraHeaders}

Inspect a request that some YXA application has found it should proxy statelessly. Figure out a single sipdst destination for this request (sorry, stateless SIP does not handle multiple destinations) and return that destination plus a new request (the headers might change if we have popped a Route header).


Generated by EDoc, Oct 17 2007, 16:48:26.