From: Petr C. <pc...@si...> - 2009-01-07 14:06:13
|
Hi According to my opinion, the way how kphone checks content of SIP headers doesn't work properly if the header is present in the message multiple times. I found this out when troubleshooting incoming calls to kphone that were rejected with response code 406. I figured out that kphone believes that there is no Accept header containing "application/sdp" in INVITE request. The request looked like this: INVITE sip:420241420217@159.107.117.98:5062;transport=udp SIP/2.0\r\n Via: SIP/2.0/UDP 88.103.242.244:5060;branch=z9hG4bK40vsesn4c474nulks41l6aoep0\r\n To: "Ericsson 27"<sip:420...@im...;transport=udp>;cscf\r\n From: <sip:224...@im...;user=phone>;tag=1532581713-1231332392347-\r\n Call-ID: BW1...@bs...\r\n CSeq: 412131022 INVITE\r\n Max-Forwards: 68\r\n Content-Length: 161\r\n Contact: <sip:88.103.242.244:5060;transport=udp>\r\n Content-Type: application/sdp\r\n Allow: ACK, BYE, CANCEL, INFO, INVITE, OPTIONS, PRACK, REFER, NOTIFY\r\n Accept: multipart/mixed\r\n Accept: application/media_control+xml\r\n Accept: application/sdp\r\n Supported: timer\r\n P-Asserted-Identity: <sip:224...@im...:5060;user=phone>\r\n Privacy: none\r\n P-Charging-Vector: icid-value="4964a42833239200003849";icid-generated-at=172.30.0.2;ericsson-imt=1;oaid="test"\r\n Min-SE: 1800\r\n Session-Expires: 1800\r\n P-Called-Party-ID: <sip:420...@im...>\r\n \r\n v=0\r\n o=BroadWorks 10634 1 IN IP4 88.103.242.244\r\n s=-\r\n c=IN IP4 88.103.242.244\r\n t=0 0\r\n m=audio 16410 RTP/AVP 96 18 8\r\n a=rtpmap:96 iLBC/8000/1\r\n a=fmtp:96 mode=30\r\n I have made for myself a fix (see the diff below) that works, but I am not sure whether it can possibly be called a clean solution. Best Regards Petr Cisar diff -x '*.[oa]' -Naur kphoneSI/dissipate2/sipclient.cpp kphoneSI-1.2/dissipate2/sipclient.cpp --- kphoneSI/dissipate2/sipclient.cpp 2008-09-01 06:17:01.000000000 +0200 +++ kphoneSI-1.2/dissipate2/sipclient.cpp 2009-01-07 14:21:03.000000000 +0100 @@ -946,13 +946,13 @@ } if( curmessage->hasHeader( SipHeader::Accept ) ) { if( curmessage->getMethod() == Sip::INVITE ) { - if( !curmessage->getHeaderData( SipHeader::Accept ).lower().contains( "application/sdp" ) ) { + if( curmessage->findHeaderData( SipHeader::Accept, QString("application/sdp") )==QString::null ) { sendQuickResponse( curmessage, SipStatus( 406 ) ); delete curmessage; return; } } else if( curmessage->getMethod() == Sip::SUBSCRIBE ) { - if( !curmessage->getHeaderData( SipHeader::Accept ).lower().contains( "application/xpidf+xml" ) ) { + if( curmessage->findHeaderData( SipHeader::Accept, QString("application/xpidf+xml") )==QString::null ) { sendQuickResponse( curmessage, SipStatus( 406 ) ); delete curmessage; return; diff -x '*.[oa]' -Naur kphoneSI/dissipate2/sipmessage.cpp kphoneSI-1.2/dissipate2/sipmessage.cpp --- kphoneSI/dissipate2/sipmessage.cpp 2008-09-01 06:17:01.000000000 +0200 +++ kphoneSI-1.2/dissipate2/sipmessage.cpp 2009-01-07 14:16:26.000000000 +0100 @@ -460,6 +460,36 @@ return QString::null; } +QString SipMessage::findHeaderData( SipHeader::SipHeaderId id, QString searchData ) +{ + SipHeader *curheader; +#if 0 + printf("Searching headers for %s\n",searchData.latin1()); +#endif + // quick optimization + if ( headerlist.current() != 0 ) { + curheader=headerlist.current(); + if ( curheader->id == id && curheader->data.lower().contains(searchData)) { + return curheader->data; + } + } + for ( curheader = headerlist.first(); curheader != 0; curheader = headerlist.next() ) { +#if 0 + printf("Checking header \"%s\": \"%s\"\n",SipHeader::getHeaderString( curheader->id ).latin1(),curheader->data.latin1()); +#endif + if ( curheader->id == id && curheader->data.lower().contains(searchData) ) { +#if 0 + puts("*** Found ***"); +#endif + return curheader->data; + } + } +#if 0 + puts("*** Not found ***"); +#endif + return QString::null; +} + void SipMessage::setRequestUri( const SipUri &newrequri ) { requesturi = newrequri; diff -x '*.[oa]' -Naur kphoneSI/dissipate2/sipmessage.h kphoneSI-1.2/dissipate2/sipmessage.h --- kphoneSI/dissipate2/sipmessage.h 2008-03-01 10:31:41.000000000 +0100 +++ kphoneSI-1.2/dissipate2/sipmessage.h 2009-01-07 14:17:39.000000000 +0100 @@ -139,6 +139,7 @@ * Returns the data contained in the specified header. */ QString getHeaderData( SipHeader::SipHeaderId id ); + QString findHeaderData( SipHeader::SipHeaderId id, QString searchData ); /** * Sets the request URI for the message. Relevant only if it is a SIP |