Hi,
it's ok now, I've delete all headers and after write news.

my code:
/route[diversion]//
//{//
//    if(is_present_hf("Diversion"))//
//    {//
//
//        if($(hdrcnt(Diversion)) > 5)//
//        {//
// xlog("L_INFO","Diversion header = $(hdrcnt(Diversion)) is > 5, hungup call\n");//
//            sl_send_reply("482","Loop Detected");//
//            exit;//
//        }//
//
//        $var(i) = 0;//
//        $var(sumcounter) = 0;//
///*remove_hf("Diversion");*/
//        while ($var(i) < $(hdrcnt(Diversion)))//
//        {//
// xlog("L_INFO"," dip: $(hdr(Diversion)[$var(i)]{param.value,privacy}) \ dir: $(hdr(Diversion)[$var(i)]{param.value,reason}) \ counter: $(hdr(Diversion)[$var(i)]{param.value,counter}{s.int}) \ di: $(hdr(Diversion)[$var(i)]{nameaddr.uri}) \ number of Diversion header : $(hdrcnt(Diversion))\n");//
//
//if(!$(hdr(Diversion)[$var(i)]{param.value,counter}{s.int}))//
//                {//
//                    $var(counter) = 1;//
//                    $var(sumcounter) = $var(sumcounter) + $var(counter);//
//                }//
//                else//
//                {//
// $var(counter) = $(hdr(Diversion)[$var(i)]{param.value,counter}{s.int});// // $var(sumcounter) = $var(sumcounter) + $(hdr(Diversion)[$var(i)]{param.value,counter}{s.int});//
//                }//
//
//if(!$(hdr(Diversion)[$var(i)]{param.value,privacy}))//
//                {//
//                    $var(privacy) = "off";//
//                }//
//                else//
//                {//
// $var(privacy) = $(hdr(Diversion)[$var(i)]{param.value,privacy});//
//                }//
//
//if(!$(hdr(Diversion)[$var(i)]{param.value,reason}))//
//                {//
//                    $var(reason) = "unknown";//
//                }//
//                else//
//                else//
//                {//
// $var(reason) = $(hdr(Diversion)[$var(i)]{param.value,reason});//
//                }//
//
// xlog("L_INFO","$ci Remove Diversion Header and add Diversion header with counter=$var(counter)\n");//// // append_hf("Diversion: <$(hdr(Diversion)[$var(i)]{nameaddr.uri})>;reason=$var(reason);privacy=$var(privacy);counter=$var(counter)\r\n"); //
//
//            $var(i) = $var(i) + 1;//
//        }//
//
//        if($var(sumcounter) > 5)//
//        {//
// xlog("L_INFO","Diversion header = Sum Counter is $var(sumcounter) > 5, hungup call\n");//
//            sl_send_reply("482","Loop Detected");//
//            exit;//
//        }//
//    }//
//    return;//
//}/


Le 03/05/2013 13:23, Răzvan Crainea a écrit :
Hi, Mickael!

remove_hf() removes all headers, so it should remove both first and the second one. Then you can simply add a new header(using append_hf() function[1]) with the desired information.

[1] http://www.opensips.org/html/docs/modules/1.9.x/sipmsgops.html#id249181

Best regards,

Razvan Crainea
OpenSIPS Core Developer
http://www.opensips-solutions.com

On 05/03/2013 10:58 AM, Mickael HUBERT wrote:
some details:

remove_hf delete all Diversion header, how can I delete or rewrite good
header ?

Le 03/05/2013 10:48, Mickael HUBERT a écrit :
Hi,
I have coded with while for treat all diversion headers.

Ex:
....
/while ($var(i) < $(hdrcnt(Diversion)))//
//{//
//if(!$(hdr(Diversion)[$var(i)]{param.value,counter}{s.int}) ||
!$(hdr(Diversion)[$var(i)]{param.value,privacy}) ||
!$(hdr(Diversion)[$var(i)]{param.value,reason}))//
//    {//
//        ..../

after all these treatments, I can not replace the good diversion
header, if I have multiple diversion.

Ex:
If I have:

/Diversion: <sip:******@hexanet.fr>; reason="user-busy";
privacy="full" ;counter=3//
//Diversion: <sip:******@hexanet.fr>; reason="user-busy"; privacy="off"/

and if I use:
remove_hf("Diversion"), to rewrite the second diversion header.
Opensips delete the first diversion header.

How can I rewrite the good diversion header, here the second ?

thanks

Le 02/05/2013 19:21, Saúl Ibarra Corretgé a écrit :
On May 2, 2013, at 4:20 PM, Mickael HUBERT wrote:

Thank you very much, it's perfect ;)

but, if I have many Diversion header in the same INVITE ? This command works ?

You can index the call to hdr(Diversion), IIRC there is an example in the transformations page showing how to iterate through a list of headers with the same name.

--
Saúl Ibarra Corretgé
AG Projects




_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to