OPTIONS Ping Support

Please post requests related to the sipsorcery library to the GitHub repo https://github.com/sipsorcery/sipsorcery/issues.
Locked
SachaD
Posts: 7
Joined: Thu Sep 30, 2010 4:59 am

OPTIONS Ping Support

Post by SachaD » Sun Oct 03, 2010 12:07 am

It appears that SS does not currently handle OPTIONS Ping (OPTIONS requests out of an already established dialogue ). Such OPTIONS requests are frequently used by unauthenticated SIP Trunks / Gateways as a mean to verify peer is still reachable.

Looking at the code (GotRequest in SIPAppServerCore.cs), I believe support for OPTIONS Ping could be implemented with the following minor change:


SIPAppServerCore.cs

Line 48 (Insert):

using SIPSorcery.Net;


Line 239 (Insert):

else if (sipRequest.Method == SIPMethodsEnum.OPTIONS)
{
// Send back the remote SDP.
FireProxyLogEvent(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "OPTIONS request for ANONYMOUS.", fromUser));
SIPNonInviteTransaction optionsTransaction = m_sipTransport.CreateNonInviteTransaction(sipRequest, remoteEndPoint, localSIPEndPoint, m_outboundProxy);
SIPResponse okResponse = SIPTransport.GetResponse(sipRequest, SIPResponseStatusCodesEnum.Ok, null);
okResponse.Body = String.Empty;
okResponse.Header.ContentLength = okResponse.Body.Length;
okResponse.Header.ContentType = SDP.SDP_MIME_CONTENTTYPE;
optionsTransaction.SendFinalResponse(okResponse);
}

Does this make sense?
Thanks for your consideration.

Regards,
Sacha

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: OPTIONS Ping Support

Post by Aaron » Sun Oct 03, 2010 10:12 am

OPTIONS requests wil be repsonded to with a 405 Method Not Allowed response, which happens in the same spot on line 239 in SIPAppServerCore.cs. All the SIP servers I've come across that use OPTIONS requests as a keep-alive mechanism don't care what the response code is as long as they get one and in that case the 405 response will work fine.

Locked