Reply Options

October 26, 2015 ยท View on GitHub

Many of the Service's callback functions allows you to send a response back for the received request. Currently recognized options are documented in this page.

Keep in mind that activated pluings can add new options. See the plugins documentation.

ResponseTypesCodeComments
CodeCode::nksip:sip_code()Code
{Code, Opts}Code::nksip:sip_code(), Opts::nksip:optslist()CodeSee options
ringing180
rel_ringing180Reliable responses will be used (must activate plugin)
{rel_ringing, Body}Body::nksip:body()180Reliable responses will be used, send a body (must activate plugin)
session_progress183
rel_session_progress183Reliable responses will be used (must activate plugin)
{rel_session_progress, Body}Body:nksip:body()183Reliable responses will be used, send a body (must activate plugin)
ok200
{ok, Opts}Opts:nksip:optslist()200See options
{answer, Body}Body::nksip:body()200Send a body
accepted202
{redirect, [Contact]}Contact::string()|binary()|nksip:uri()300Generates Contact headers
{redirect_permanent, Contact}Contact::string()|binary()|nksip:uri()301Generates a Contact header
{redirect_temporary, Contact}Contact::string()|binary()|nksip:uri()302Generates a Contact header
invalid_request400
{invalid_request, Phrase}Phrase::string()|binary()400Use custom SIP phrase
authenticate401Generates a new WWW-Authenticate header, using current From domain as realm
{authenticate, Realm}Realm::string()|binary()401Generates a valid new WWW-Authenticate header, using Realm
forbidden403
{forbidden, Text}Text::string()|binary()403Use custom SIP phrase
not_found404
{not_found, Text}Text::string()|binary()404Use custom SIP phrase
{method_not_allowed, Allow}Allow::string()|binary()405Generates an Allow header
proxy_authenticate407Generates a valid new Proxy-Authenticate header, using current From domain as Realm
{proxy_authenticate, Realm}Realm::string()|binary()407Generates a valid new Proxy-Authenticate header, using Realm
timeout408
{timeout, Text}Text::string()|binary()408Use custom SIP phrase
conditional_request_failed412
request_too_large413
{unsupported_media_type, Accept}Accept::string()|binary()415Generates a new Accept header
{unsupported_media_encoding, AcceptEncoding}AcceptEncoding::string()|binary()415Generates a new Accept-Encoding header
unsupported_uri_scheme416
{bad_extension, Unsupported}Unsupported::string()|binary()420Generates a new Unsupported header
{extension_required, Require}Require::string()|binary()421Generates a new Require header
{interval_too_brief, MinExpires}MinExpires::integer()423Generates a new Min-Expires
flow_failed430
first_hop_lacks_outbound439
temporarily_unavailable480
no_transaction481
unknown_dialog481
loop_detected482
too_many_hops483
ambiguous485
busy486
request_terminated487
{not_acceptable, Warning}Warning::string()|binary()488Generates a new Warning header
bad_event489
request_pending491
internal_error500
{internal_error, Text}Text::string()|binary()500Use custom SIP phrase
busy_eveywhere600
decline603

Options

Some previous replies allow including options. The recognized options are:

OptionTypesDescriptionCommment
{body, Body}Body::nksip:body()Sets the request body
{reason_phrase, Phrase}Phrase::string()|binaryUses a custom reason phrase in the SIP response
{local_host, LocalHost}LocalHost::auto|string()|binary()Host or IP to use when auto generating headers like Contact or Record-Route
{local_host6, LocalHost}LocalHost::auto|string()|binary()Host or IP to use when auto generating headers like Contact or Record-Route using IPv6
user_agent-Automatically generates a User-Agent header, replacing any previous value
supported-Automatically generates a Supported header, replacing any previous value
allow-Automatically generates an Allow header, replacing any previous value
accept-Automatically generates an Accept header, replacing any previous value
allow_event-Automatically generates an Allow-Event header, replacing any previous value
contact-Automatically generates a Contact header, if none is already presentUse it in dialog generaing requests as INVITE
www_authenticateGenerates an automatic WWW-Authenticate header, using From header as realm
{www_authenticate, Realm}Realm::string()|binaryGenerates an automatic WWW-Authenticate header, using Realm
proxy_authenticateGenerates an automatic Proxy-Authenticate header, using From header as realm
{proxy_authenticate, Realm}Realm::string()|binaryGenerates an automatic Proxy-Authenticate header, using Realm
{service_route, Routes}Routes::string()|binary|nksip:uri()For REGISTER requests, if code is in the 200-299 range, generates a Service-Route header
{add, Name, Value}Name::nksip:header_name(), Value::nksip:header_value()Adds a new header, after any previous one with the same nameAll header names should be lowercase
{add, {Name, Value}}(same as before)Same as before
{replace, Name, Value}(same as before)Adds a new header, replacing any previous one
{replace, {Name, Value}}(same as before)Same as before
{insert, Name, Value}(same as before)Inserts a new header, before any previous one with the same name
{insert, {Name, Value}}(same as before)Same as before
{content_type, ContentType}ContentType::string()|binary()|nksip:token()Replaces Content-Type header
{require, Require}Require::string()|`binary()Replaces Require header
{supported, Supported}Supported::string()|binary()Replaces Supported header
{expires, Expires}Expires::string()|binary()|integer()Replaces Expires header
{contact, Contact}Contact::string()|binary()|nksip:uri()|[nksip:uri()]Replaces Contact header
{route, Route}Route::string()|binary()|nksip:uri()|[nksip:uri()]Replaces Route header
{reason, Reason}Reason::string()|binary()Replaces Reason header
{event, Reason}Event::string()|binary()|nksip:token()Replaces Event header
timestampIf the request has a Timestamp_ header it is copied to the response
do100relActivates reliable provisional responses, if supported (must activate plugin)
{sip_etag, ETag}ETag::string()|binary()Replaces Sip-ETag headerOnly to be used in PUBLISH requests
no_dialog-Do not process dialogs for this request
ignore-Ignore this option

Automatic processing

NkSIP will make some aditional processing on the response (unless you use Code or {Code, Opts}):

  • If Code>100, and the request had a Timestamp header, it will be copied to the response.
  • If Code>100 and method is INVITE, UPDATE, SUBSCRIBE or REFER, options allow and supported will be added.
  • If Code is in the 101-299 range and method is INVITE or NOTIFY, and the request had any Record-Route header, they will be copied to the response.
  • If Code is in the 101-299 range and method is INVITE, UPDATE, SUBSCRIBE or REFER, a contact option will be added if no Contact is already present on the response.
  • If Code is in the 200-299 range and method is REGISTER, any Path header will be copied from the request to the response.
  • If method is SUBSCRIBE, NOTIFY or PUBLISH, the Event header will be copied from the request to the response.
  • If Code is in the 200-299 range and method is SUBSCRIBE, and Expires header will be added to the response if not already present.