The SIP stack can be configured to respond automatically to OPTIONS methods. You must customize several SIP OPTIONS headers in the SIP configuration file to do so. The SIP OPTIONS response is then formed according to those values. The sendAutoResponse configuration field must be set to enable this functionality.
The following example shows the OPTIONS keywords in the SIP Server configurable file:
options.sendAutoResponse = true
options.allow =_INVITE,ACK,BYE,REGISTER,REFER,NOTIFY,PRACK,CANCEL,SUBSCRIBE
options.accept = application/sdp
options.acceptEnc = gzip
options.language = en
options.supported = 100rel
The NCC application can also respond to the OPTIONS methods directly using the nccSendCapabilityResponse function. The parameters for this function specify a line handle (linehd) and a SIP IE list to build the OPTIONS method headers (sipIEs).
This function is called when receiving an NCCEVN_CAPABILITY_INDICATION event and only one SIP context should respond to the event. The NCCEVN_CAPABILITY_INDICATION event provides a SIP_IE_OPTIONS_HANDLE element that should be included in the sipIEs parameter of this function call.
DWORD NMSAPI nccSendCapabilityResponse(CTAHD linehd, void *sipIEs)
Argument |
Description |
linehd |
Line handle used to open the NCC service instance. |
sipIEs |
NULL or pointer to a buffer containing SIP IEs. |
The following table lists the optional and required information elements (IEs):
Information element (IE) |
Required or optional |
Description |
SIP_IE_OTHER_HEADER |
Required |
Use this header IE to specify response header values for the following header types: Allow, Accept, Accept-Encoding, Accept-Language and Supported. |
SIP_IE_RESPONSE_CODE |
Required |
Response code to the received OPTIONS method. |
SIP_IE_OPTIONS_HANDLE |
Required |
Options handle used to send the OPTIONS response. |
SIP_IE_CONTACT_ADDRESS |
Optional |
Contact address. |
SIP_IE_CONTENT_TYPE |
Optional |
Content-type header in the SIP message. |
SIP_IE_BODY |
Optional |
Message Body. |
The following coding example illustrates how to respond with capability information using the nccSendCapabilityResponse function:
DWORD b[2048];
NCC_SIP_INFO *ie;
NCC_SIP_INFO_INIT ( b, &ie );
NCC_SIP_INFO_ADD_NUM ( b, &ie, SIP_IE_RESPONSE_CODE, 200 );
NCC_SIP_INFO_ADD_STR ( b, &ie, SIP_IE_OTHER_HEADER,
"Allow:INVITE,ACK,BYE,REGISTER,REFER,NOTIFY,PRACK,CANCEL,SUBSCRIBE");
NCC_SIP_INFO_ADD_STR ( b, &ie, SIP_IE_OTHER_HEADER, "Accept:application/sdp");
NCC_SIP_INFO_ADD_STR ( b, &ie, SIP_IE_OTHER_HEADER, "Accept-Encoding:gzip");
NCC_SIP_INFO_ADD_STR ( b, &ie, SIP_IE_OTHER_HEADER, "Accept-Language:en");
NCC_SIP_INFO_ADD_STR ( b, &ie, SIP_IE_OTHER_HEADER, "Supported:100rel");
NCC_SIP_INFO_ADD_NUM ( b, &ie, SIP_IE_OPTIONS_HANDLE, hOptions );
NCC_SIP_INFO_ADD_STR ( b, &ie, SIP_IE_CONTACT_ADDRESS, sip.contact );
ret = nccSendCapabilityResponse( ctahd, b);