[SR-Users] Kamailio second contact header
Daniel-Constantin Mierla
miconda at gmail.com
Fri Jun 5 11:46:02 CEST 2015
Hello,
can you try with latest master branch? I pushed some code to clean up
dropping last branch.
If all ok, I will backport.
Cheers,
Daniel
On 05/06/15 09:26, Ali Taher wrote:
>
> Hi Daniel,
>
>
>
> Here is the log I got :
>
> 2015-06-05T10:04:35.864338+03:00 ubuntu
> /usr/local/sbin/kamailio[25115]: INFO: <script>: Before assigning <null>
>
> 2015-06-05T10:04:35.864382+03:00 ubuntu
> /usr/local/sbin/kamailio[25115]: INFO: <script>: branch uri[0]:
> sip:9612 at C001
>
> 2015-06-05T10:04:35.864433+03:00 ubuntu
> /usr/local/sbin/kamailio[25115]: INFO: <script>: branch uri[1]:
> sip:9612 at 192.168.26.1
>
> 2015-06-05T10:04:35.864452+03:00 ubuntu
> /usr/local/sbin/kamailio[25115]: INFO: <script>: branch uri[2]:
> sip:9612 at 192.168.26.6
>
> 2015-06-05T10:04:35.864469+03:00 ubuntu
> /usr/local/sbin/kamailio[25115]: INFO: <script>: branch uri[3]:
> sip:9612 at 192.168.26.8
>
> 2015-06-05T10:04:35.864498+03:00 ubuntu
> /usr/local/sbin/kamailio[25115]: INFO: <script>: After assigning <null>
>
> 2015-06-05T10:04:35.864513+03:00 ubuntu
> /usr/local/sbin/kamailio[25115]: INFO: <script>: branch uri[0]:
> sip:9612 at C001
>
> 2015-06-05T10:04:35.864531+03:00 ubuntu
> /usr/local/sbin/kamailio[25115]: INFO: <script>: branch uri[1]:
> sip:9612 at 192.168.26.1
>
> 2015-06-05T10:04:35.864547+03:00 ubuntu
> /usr/local/sbin/kamailio[25115]: INFO: <script>: branch uri[2]:
> sip:9612 at 192.168.26.6
>
> 2015-06-05T10:04:35.864564+03:00 ubuntu
> /usr/local/sbin/kamailio[25115]: INFO: <script>: branch uri[3]:
> sip:9612 at 192.168.26.8
>
>
>
> Noting that the order of gateways above is correct , but in contact
> field I’m getting : sip:9612 at 192.168.26.8 , sip:9612 at C001 ,
> sip:9612 at 192.168.26.1 , sip:9612 at 192.168.26.6 , sip:9612 at 192.168.26.8
>
>
>
> Below is full code I’m using:
>
>
>
> if (is_method("INVITE"))
>
> {
>
> if (!load_gws(1, $rU, $fu))
>
> {
>
> sl_send_reply("502", "Unable To lOad GatEwAyS");
>
> exit;
>
> }
>
>
>
> while (next_gw())
>
> {
>
> append_branch();
>
> }
>
>
>
> xlog("L_INFO", "Before assigning $null");
>
> $var(i)=0;
>
> while($var(i)<$branch(count))
>
> {
>
> xlog("L_INFO", "branch uri[$var(i)]: $(branch(uri)[$var(i)])\n");
>
> $var(i) = $var(i) + 1;
>
> }
>
> $(branch(uri)[-1]) = $null;
>
> xlog("L_INFO", "After assigning $null");
>
> $var(i)=0;
>
> while($var(i)<$branch(count))
>
> {
>
> xlog("L_INFO", "branch uri[$var(i)]: $(branch(uri)[$var(i)])\n");
>
> $var(i) = $var(i) + 1;
>
> }
>
> sl_send_reply("300","Multiple Choices");
>
> exit;
>
> }
>
>
>
> Regards,
>
> Ali
>
> *From:*Daniel-Constantin Mierla [mailto:miconda at gmail.com]
> *Sent:* Friday, June 05, 2015 9:56 AM
> *To:* Ali Taher; 'Kamailio (SER) - Users Mailing List'
> *Subject:* Re: [SR-Users] Kamailio second contact header
>
>
>
> Hello,
>
> On 04/06/15 16:43, Ali Taher wrote:
>
> Hi Daniel,
>
>
>
> If it is the case then the ordering shouldn’t be 1,2,3,3 ? but
> I’m getting 3,1,2,3.
>
> I tried to set $(branch(uri)[-1]) = $null; after the while block ,
> but nothing changed L
>
>
> Are you still getting all branches? Isn't the last one removed? Can
> you print branches before and after assiging $null? you can use:
>
> $var(i)=0;
> while($var(i)<$branch(count))
> {
> xlog("branch uri[$var(i)]: $(branch(uri)[$var(i)])\n");
> $var(i) = $var(i) + 1;
> }
>
> Cheers,
> Daniel
>
>
>
> Thanks,
>
> Ali
>
>
>
> *From:*Daniel-Constantin Mierla [mailto:miconda at gmail.com]
> *Sent:* Thursday, June 04, 2015 5:28 PM
> *To:* Ali Taher; 'Kamailio (SER) - Users Mailing List'
> *Subject:* Re: [SR-Users] Kamailio second contact header
>
>
>
> Hello,
>
> next_gw() is also setting the r-uri, so for the last successful
> next_gw() you should not call anymore append_branch(). Try to
> remove the last branch after the while block:
>
> $(branch(uri)[-1]) = $null;
>
> Cheers,
> Daniel
>
> On 04/06/15 16:01, Ali Taher wrote:
>
> Hi Daniel,
>
>
>
> I’m using this method because I’m having issue with
> append_branch where last gateway is listed first.
>
> For example if gateways are ordered in LCR_rule_target as
> 1,2,3 , I’m having them in contact header as : 3,1,2,3
>
>
>
> I’m using below code :
>
>
>
> if (!load_gws(1, $rU, $fu)) {
>
>
>
> sl_send_reply("502", "Unable To lOad GatEwAyS");
>
>
>
> exit;}
>
>
>
> while(next_gw()){
>
> append_branch(); }
>
> sl_send_reply("302","Moved Temporary");
>
> exit;
>
> }
>
>
>
> Any hint regarding the above would be appreciated.
>
>
>
> Regards,
>
> Ali
>
>
>
> *From:*sr-users [mailto:sr-users-bounces at lists.sip-router.org]
> *On Behalf Of *Daniel-Constantin Mierla
> *Sent:* Thursday, June 04, 2015 4:41 PM
> *To:* Kamailio (SER) - Users Mailing List
> *Subject:* Re: [SR-Users] Kamailio second contact header
>
>
>
> Hello,
>
> the r-uri is added as a Contact address for 3xx replies -- I
> don't remember if this is some RFC requirement or just an
> implementation of the sl function for 3xx replies (well, I
> haven't implemented those function either).
>
> The active branches of the request are added as contact header
> to the reply. So you can practically use append_branch() as
> many times as you need and then do sl_send_reply("3xx", ...).
> You don't need to append headers to replies explicitely.
>
> Cheers,
> Daniel
>
> On 04/06/15 13:59, Ali Taher wrote:
>
> Hello,
>
>
>
> I’m trying to build new contact header that will be sent
> from Kamailio as below :
>
>
>
>
>
> load_gws(1, $rU, $fu);
>
> append_to_reply("Contact:");
>
> while
> (next_gw())
>
> {
>
>
> append_to_reply("$ru");
>
> }
>
> append_to_reply("\r\n");
>
>
> sl_send_reply("300","Multiple Choices");
>
> exit;
>
>
>
>
>
> yet I’m getting two Contact headers as shown in below SIP
> message.
>
> How can I remove second contact header (highlighted below
> in gray)
>
>
>
> Via: SIP/2.0/UDP
> 192.168.26.3:42528;branch=z9hG4bK-d8754z-4c2cc56c3145b446-1---d8754z-;rport=42528;received=192.168.26.3
>
> To: “9612"<sip:9612 at 192.168.110.181>
> <sip:9612 at 192.168.110.181>;tag=b27e1a1d33761e85846fc98f5f3a7e58.1a8d
>
> From: "test"<sip:test at 192.168.110.181>
> <sip:test at 192.168.110.181>;tag=8571af74
>
> Call-ID: Y2MzOTNiOGRhMTc2NDkwZjIxNzZhYTAzZmM0OGE3NDY
>
> CSeq: 2 INVITE
>
> Contact:
> sip:9612 at C001,sip:9612 at 192.168.26.1,sip:9612 at 192.168.26.6,sip:9612 at 192.168.26.8
>
> Contact: sip:9612 at 192.168.26.8
>
> Server: kamailio (4.1.8 (x86_64/linux))
>
> Content-Length: 0
>
>
>
>
>
> Thanks,
>
> Ali
>
>
>
>
>
>
> _______________________________________________
>
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>
> sr-users at lists.sip-router.org <mailto:sr-users at lists.sip-router.org>
>
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
>
>
>
> --
>
> Daniel-Constantin Mierla
>
> http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> - http://www.linkedin.com/in/miconda
>
> Book: SIP Routing With Kamailio - http://www.asipto.com
>
>
>
>
> --
>
> Daniel-Constantin Mierla
>
> http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> - http://www.linkedin.com/in/miconda
>
> Book: SIP Routing With Kamailio - http://www.asipto.com
>
>
>
> --
> Daniel-Constantin Mierla
> http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> - http://www.linkedin.com/in/miconda
> Book: SIP Routing With Kamailio - http://www.asipto.com
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Book: SIP Routing With Kamailio - http://www.asipto.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20150605/0b247494/attachment.html>
More information about the sr-users
mailing list