SIP API Developer's Guide

SIP Request and Response Creation Functions

int sip_add_response_line(sip_msg_t sip_response, int response, char *response_code);

The sip_add_response_line() function adds a response line that uses the values that are passed in the response and response_code parameters. The response_code parameter is the reason phrase for the response. The value of the response_code parameter cannot be NULL. The SIP version in the response line is SIP/2.0. The sip_add_request_line() function adds a CRLF to the response line before adding the line to the SIP message. For the response listed in Section 21 of RFC 3261, obtain the value of the response_code parameter by using the sip_get_resp_desc() function.

int sip_add_request_line(sip_msg_t sip_request, sip_method_t method, char *request_uri);

The sip_add_request_line() function adds a request line to a SIP message using the method and the request URI. The request URI cannot be NULL. The method can take on the following values:

The added request line has a SIP version of SIP/2.0. The API adds a CRLF to the request line before adding the line to the SIP message.

sip_msg_t sip_create_response(sip_msg_t sip_request, int response, char *response_code, char *totag, char *contacturi);

The sip_create_response() function creates a response for the SIP request that is provided by the sip_request parameter. The response and *response_code parameters serve the same purpose as in the sip_add_response_line() function. You can specify a tag value that the sip_create_response() function adds to the TO header. If you do not specify the tag value, this function adds a tag value unless the response is 100 (Trying). In this case, the application must specifically add the tag. The SIP response message is created by adding a Response line by using the response and *response_code parameters with a SIP version of SIP/2.0. This function then copies the following headers from the request to the response message:

The sip_create_response() function returns the resulting SIP response message.

sip_msg_t sip_create_dialog_req(sip_method_t method, sip_dialog_t dialog, char *transport, char *sent_by, int sent_by_port, char *via_param, uint32_t maxforward, int cseq);

The sip_create_dialog_req() function creates an in-dialog request using the state that is maintained in the dialog parameter. This function uses the method that is specified in the method parameter to create the request line. The request URI is either the contact URI from the specified dialog or the first URI from the Route set, if that set is present. For more details on the Route set, see section 12.2 of RFC 3261. The FROM, TO, CONTACT and Call-ID headers are added to the request using the state that is maintained in the dialog. The Max-Forwards header is added using the value of the maxforward parameter. If the value of the cseq parameter is not negative, this function adds the Cseq header using the provided value. In all other cases, this function increments the dialog's local cseq and uses the result as the sequence number.

This function adds a VIA header to the request. This function constructs the VIA header by using the values in the transport, sent_by, and sent_by_port parameters, as well as any values you specify in the via_params parameter. The VIA header's protocol is SIP and the version number is 2.0.

int sip_create_OKack(sip_msg_t response, sip_msg_t ack_msg, char *transport, char *sent_by, int sent_by_port, char *via_params);

The sip_create_OKack() function constructs an ACK signal for a final 2xx response, in compliance with section 13.2.2.4 of RC 3261. The value of the response parameter is the 2xx response.

This function adds a VIA header to the request. This function constructs the VIA header by using the values in the transport, sent_by, and sent_by_port parameters, as well as any values you specify in the via_params parameter. The VIA header's protocol is SIP and the version number is 2.0.