<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>HI Shehzad,</div><div><br></div><div>First of all thanks to you for writing such a nice module.</div><div><br></div><div>I am also facing the same problem. The module works fine when UAC (PJSIP) sends the encoded SIP packet on UDP transport but when it sends the same encoded packet with TCP transport it never reaches to the nio_msg_received() function in corex_nio.c and so does not print anything in $mb when printed from the kamailio.cfg using the xlog in event_route[network:msg].</div><div><br></div><div>Digging further I also found that when kamailio receives the TCP packet with encoded sip in file tcp_read.c in function tcp_read_headers() then it goes for some tcp_headers parsing and drops the packet. But it works good when the TCP packet data segment is not encoded that is SIP packet is not encoded and transmitted on TCP :</div><div><br></div><div>1) TCP Headers + payload (SIP Packet)  ----> this case works fine</div><div>2) TCP Headers + payload (encoded SIP Packet) ------> this case does not work fine.</div><div><br></div><div>Any pointers where I might be wrong.</div><div><br></div><div><br></div><div>Thanks</div><div>Varun</div><div><br></div><div>Regards</div><div>Varun </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Date: Sat, 20 Sep 2014 19:12:24 +0200<br>
From: Muhammad Shahzad <<a href="mailto:shaheryarkh@gmail.com">shaheryarkh@gmail.com</a>><br>
To: "Kamailio (SER) - Development Mailing List"<br>
        <<a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>><br>
Subject: Re: [sr-dev] Reqd. help on Corex (Obfuscate) - Kamailio 4.2.x<br>
Message-ID:<br>
        <<a href="mailto:CAFZQphwxr6TbVV98tF5bGAcfi7822POMGGhadP4_x77XZw%2BhDg@mail.gmail.com">CAFZQphwxr6TbVV98tF5bGAcfi7822POMGGhadP4_x77XZw+hDg@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
There is something wrong with your encryption setup, the event_route<br>
[network:msg] gets raw messages that was either just received from the<br>
network interface or the final message that is about to be sent over<br>
network socket. The SIP parsing is done AFTER message has been processed by<br>
this route. So, if SIP parsing fails then it means the message was not<br>
correctly decrypted in event_route [network:msg].<br>
<br>
Thank you.<br>
<br>
<br>
<br>
On Sat, Sep 20, 2014 at 3:25 PM, Rahul MathuR <<a href="mailto:rahul.ultimate@gmail.com">rahul.ultimate@gmail.com</a>><br>
wrote:<br>
<br>
> Hello Gents,<br>
><br>
> Thanks for guiding me in the correct direction.<br>
><br>
> However, it so came out that when encrypted packets come to kamailio over<br>
> transport 'TCP' then it gets rejected from tcp_read.c even before coming to<br>
> corex module.<br>
> I guess, maybe it is getting rejected due to header parsing failure.<br>
><br>
> Any pointers here would be very helpful !!<br>
><br>
> Thanks one again..<br>
><br>
><br>
><br>
> On Wed, Sep 17, 2014 at 12:44 PM, Daniel-Constantin Mierla <<br>
> <a href="mailto:miconda@gmail.com">miconda@gmail.com</a>> wrote:<br>
><br>
>>  Hello,<br>
>><br>
>> the corex has a function to tell if the message is received by kamailio<br>
>> or sent out:<br>
>><br>
>> - <a href="http://kamailio.org/docs/modules/devel/modules/corex.html#idp29928" target="_blank">http://kamailio.org/docs/modules/devel/modules/corex.html#idp29928</a><br>
>><br>
>> If you interconnect with other servers/gateways when you don't what to do<br>
>> special encoding, then you need to test src ip or look ar r-uri/dst uri.<br>
>><br>
>> Cheers,<br>
>> Daniel<br>
>><br>
>><br>
>> On 17/09/14 04:24, Rahul MathuR wrote:<br>
>><br>
>> Hi,<br>
>><br>
>>  Did you get some free cycles to look at it ?<br>
>><br>
>> On Wed, Sep 17, 2014 at 12:12 AM, Rahul MathuR <<a href="mailto:rahul.ultimate@gmail.com">rahul.ultimate@gmail.com</a>><br>
>> wrote:<br>
>><br>
>>> Thanks for replying !<br>
>>><br>
>>>  But how to check whether a particular message received by Kamailio was<br>
>>> sent by UAC or SIP Server ?<br>
>>> Also, on the same lines - how to know whether a particular message about<br>
>>> to be send from Kamailio is bound to UAC or SIP Server ?<br>
>>><br>
>>> On Tue, Sep 16, 2014 at 10:51 PM, Muhammad Shahzad <<br>
>>> <a href="mailto:shaheryarkh@gmail.com">shaheryarkh@gmail.com</a>> wrote:<br>
>>><br>
>>>>  Hi,<br>
>>>><br>
>>>>  The network io intercept feature basically allows kamailio script<br>
>>>> writer to do whatever s/he may want to do with raw SIP packets (that are<br>
>>>> just received by kamailio or about to be sent out by kamailio), e.g.<br>
>>>> encryption, compression or any final touches to sip message before it is<br>
>>>> processed by kamailio core. That is why it is purposely kept abstract and<br>
>>>> any particular use or implementation is left to the script writer.<br>
>>>><br>
>>>>  In your case the encryption / decryption code is in C/C++, you can<br>
>>>> try one of the followings,<br>
>>>><br>
>>>>  1. Writeup a C/C++ program that receives outgoing SIP message as text<br>
>>>> (and some other parameters, e.g. encryption key) in input arguments and<br>
>>>> returns the encrypted message in event_route [ network:msg ] and vice versa<br>
>>>> (for incoming messages). You can call this program directly from<br>
>>>> kamailio.cfg script.<br>
>>>><br>
>>>>  2. Writeup e.g. a PERL wrapper for your encryption / decryption C/C++<br>
>>>> code and call it using kamailio app_perl module within event_route [<br>
>>>> network:msg ] as demonstrated in this example,<br>
>>>><br>
>>>> <a href="http://kamailio.org/docs/modules/devel/modules/corex.html#idp125704" target="_blank">http://kamailio.org/docs/modules/devel/modules/corex.html#idp125704</a><br>
>>>><br>
>>>>  You can also use any other kamailio language bind of you choice as<br>
>>>> well, e.g. Python, LUA, JAVA and so on.<br>
>>>><br>
>>>>  I would recommend the second option, as it has less processing<br>
>>>> overhead for kamailio.<br>
>>>><br>
>>>> Thank you.<br>
>>>><br>
>>>><br>
>>>><br>
>>>>  On Tue, Sep 16, 2014 at 6:09 PM, Rahul MathuR <<br>
>>>> <a href="mailto:rahul.ultimate@gmail.com">rahul.ultimate@gmail.com</a>> wrote:<br>
>>>><br>
>>>>>  Hello,<br>
>>>>><br>
>>>>>  I was going through the new features and stumbled upon this new one<br>
>>>>> - developed by Mohd. Shahzad Shafi.<br>
>>>>> As already mentioned on the wiki about this module, I intend to use it<br>
>>>>> for my custom security layer between UACs and SIP Proxy (Kamailio) but the<br>
>>>>> issue is - the custom security layer (encryption/decryption code) is<br>
>>>>> written in C and should precisely be applied for the messages between UAC<br>
>>>>> and Proxy.<br>
>>>>><br>
>>>>>  Is there a way I can achieve this using Corex module since it does<br>
>>>>> intercept the network I/O messages ?<br>
>>>>><br>
>>>>>  Any help here would be really appreciated.<br>
>>>>><br>
>>>>>  --<br>
>>>>> Warm Regds.<br>
>>>>> MathuRahul<br>
>>>>><br>
>>>>>  _______________________________________________<br>
>>>>> sr-dev mailing list<br>
>>>>> <a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><br>
>>>>> <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
>>>>><br>
>>>>><br>
>>>><br>
>>>> _______________________________________________<br>
>>>> sr-dev mailing list<br>
>>>> <a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><br>
>>>> <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
>>>><br>
>>>><br>
>>><br>
>>><br>
>>>   --<br>
>>> Warm Regds.<br>
>>> MathuRahul<br>
>>><br>
>><br>
>><br>
>><br>
>>  --<br>
>> Warm Regds.<br>
>> MathuRahul<br>
>><br>
>><br>
>> _______________________________________________<br>
>> sr-dev mailing listsr-dev@lists.sip-router.orghttp://<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
>><br>
>><br>
>> --<br>
>> Daniel-Constantin Mierlahttp://<a href="http://twitter.com/#!/miconda" target="_blank">twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a><br>
>> Next Kamailio Advanced Trainings 2014 - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a><br>
>> Sep 22-25, Berlin, Germany<br>
>><br>
>><br>
>> _______________________________________________<br>
>> sr-dev mailing list<br>
>> <a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><br>
>> <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
>><br>
>><br>
><br>
><br>
> --<br>
> Warm Regds.<br>
> MathuRahul<br>
><br>
> _______________________________________________<br>
> sr-dev mailing list<br>
> <a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><br>
> <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.sip-router.org/pipermail/sr-dev/attachments/20140920/2a36e616/attachment.html" target="_blank">http://lists.sip-router.org/pipermail/sr-dev/attachments/20140920/2a36e616/attachment.html</a>><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
sr-dev mailing list<br>
<a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
<br>
<br>
End of sr-dev Digest, Vol 71, Issue 70<br>
**************************************<br>
</blockquote></div><br></div></div>