<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi,<br>
      it's ok now, I've delete all headers and after write news.<br>
      <br>
      my code:<br>
      <i>route[diversion]</i><i><br>
      </i><i>{</i><i><br>
      </i><i>    if(is_present_hf("Diversion"))</i><i><br>
      </i><i>    {</i><i><br>
      </i><i><br>
      </i><i>        if($(hdrcnt(Diversion)) &gt; 5)</i><i><br>
      </i><i>        {</i><i><br>
      </i><i>            xlog("L_INFO","Diversion header =
        $(hdrcnt(Diversion)) is &gt; 5, hungup call\n");</i><i><br>
      </i><i>            sl_send_reply("482","Loop Detected");</i><i><br>
      </i><i>            exit;</i><i><br>
      </i><i>        }</i><i><br>
      </i><i><br>
      </i><i>        $var(i) = 0;</i><i><br>
      </i><i>        $var(sumcounter) = 0;</i><i><br>
      </i><i>        </i><b>remove_hf("Diversion");</b><i><br>
      </i><i>        while ($var(i) &lt; $(hdrcnt(Diversion)))</i><i><br>
      </i><i>        {</i><i><br>
      </i><i>            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");</i><i><br>
      </i><i><br>
      </i><i>               
        if(!$(hdr(Diversion)[$var(i)]{param.value,counter}{s.int}))</i><i><br>
      </i><i>                {</i><i><br>
      </i><i>                    $var(counter) = 1;</i><i><br>
      </i><i>                    $var(sumcounter) = $var(sumcounter) +
        $var(counter);</i><i><br>
      </i><i>                }</i><i><br>
      </i><i>                else</i><i><br>
      </i><i>                {</i><i><br>
      </i><i>                    $var(counter) =
        $(hdr(Diversion)[$var(i)]{param.value,counter}{s.int});</i><i><br>
      </i><i>                    $var(sumcounter) = $var(sumcounter) +
        $(hdr(Diversion)[$var(i)]{param.value,counter}{s.int});</i><i><br>
      </i><i>                }</i><i><br>
      </i><i><br>
      </i><i>               
        if(!$(hdr(Diversion)[$var(i)]{param.value,privacy}))</i><i><br>
      </i><i>                {</i><i><br>
      </i><i>                    $var(privacy) = "off";</i><i><br>
      </i><i>                }</i><i><br>
      </i><i>                else</i><i><br>
      </i><i>                {</i><i><br>
      </i><i>                    $var(privacy) =
        $(hdr(Diversion)[$var(i)]{param.value,privacy});</i><i><br>
      </i><i>                }</i><i><br>
      </i><i><br>
      </i><i>               
        if(!$(hdr(Diversion)[$var(i)]{param.value,reason}))</i><i><br>
      </i><i>                {</i><i><br>
      </i><i>                    $var(reason) = "unknown";</i><i><br>
      </i><i>                }</i><i><br>
      </i><i>                else</i><i><br>
      </i><i>                else</i><i><br>
      </i><i>                {</i><i><br>
      </i><i>                    $var(reason) =
        $(hdr(Diversion)[$var(i)]{param.value,reason});</i><i><br>
      </i><i>                }</i><i><br>
      </i><i><br>
      </i><i>                xlog("L_INFO","$ci Remove Diversion Header
        and add Diversion header with counter=$var(counter)\n");</i><i>     
      </i><i><br>
      </i><i>                append_hf("Diversion:
        &lt;$(hdr(Diversion)[$var(i)]{nameaddr.uri})&gt;;reason=$var(reason);privacy=$var(privacy);counter=$var(counter)\r\n");        
      </i><i><br>
      </i><i><br>
      </i><i>            $var(i) = $var(i) + 1;</i><i><br>
      </i><i>        }</i><i><br>
      </i><i><br>
      </i><i>        if($var(sumcounter) &gt; 5)</i><i><br>
      </i><i>        {</i><i><br>
      </i><i>            xlog("L_INFO","Diversion header = Sum Counter
        is $var(sumcounter) &gt; 5, hungup call\n");</i><i><br>
      </i><i>            sl_send_reply("482","Loop Detected");</i><i><br>
      </i><i>            exit;</i><i><br>
      </i><i>        }</i><i><br>
      </i><i>    }</i><i><br>
      </i><i>    return;</i><i><br>
      </i><i>}</i><br>
      <br>
      <br>
      Le 03/05/2013 13:23, Răzvan Crainea a écrit :<br>
    </div>
    <blockquote cite="mid:51839E39.802@opensips.org" type="cite">Hi,
      Mickael!
      <br>
      <br>
      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.
      <br>
      <br>
      [1]
      <a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/1.9.x/sipmsgops.html#id249181">http://www.opensips.org/html/docs/modules/1.9.x/sipmsgops.html#id249181</a>
      <br>
      <br>
      Best regards,
      <br>
      <br>
      Razvan Crainea
      <br>
      OpenSIPS Core Developer
      <br>
      <a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a>
      <br>
      <br>
      On 05/03/2013 10:58 AM, Mickael HUBERT wrote:
      <br>
      <blockquote type="cite">some details:
        <br>
        <br>
        remove_hf delete all Diversion header, how can I delete or
        rewrite good
        <br>
        header ?
        <br>
        <br>
        Le 03/05/2013 10:48, Mickael HUBERT a écrit :
        <br>
        <blockquote type="cite">Hi,
          <br>
          I have coded with while for treat all diversion headers.
          <br>
          <br>
          Ex:
          <br>
          ....
          <br>
          /while ($var(i) &lt; $(hdrcnt(Diversion)))//
          <br>
          //{//
          <br>
          //if(!$(hdr(Diversion)[$var(i)]{param.value,counter}{s.int})
          ||
          <br>
          !$(hdr(Diversion)[$var(i)]{param.value,privacy}) ||
          <br>
          !$(hdr(Diversion)[$var(i)]{param.value,reason}))//
          <br>
          //    {//
          <br>
          //        ..../
          <br>
          <br>
          after all these treatments, I can not replace the good
          diversion
          <br>
          header, if I have multiple diversion.
          <br>
          <br>
          Ex:
          <br>
          If I have:
          <br>
          <br>
          /Diversion: <a class="moz-txt-link-rfc2396E" href="mailto:sip:******@hexanet.fr">&lt;sip:******@hexanet.fr&gt;</a>; reason="user-busy";
          <br>
          privacy="full" ;counter=3//
          <br>
          //Diversion: <a class="moz-txt-link-rfc2396E" href="mailto:sip:******@hexanet.fr">&lt;sip:******@hexanet.fr&gt;</a>;
          reason="user-busy"; privacy="off"/
          <br>
          <br>
          and if I use:
          <br>
          remove_hf("Diversion"), to rewrite the second diversion
          header.
          <br>
          Opensips delete the first diversion header.
          <br>
          <br>
          How can I rewrite the good diversion header, here the second ?
          <br>
          <br>
          thanks
          <br>
          <br>
          Le 02/05/2013 19:21, Saúl Ibarra Corretgé a écrit :
          <br>
          <blockquote type="cite">On May 2, 2013, at 4:20 PM, Mickael
            HUBERT wrote:
            <br>
            <br>
            <blockquote type="cite">Thank you very much, it's perfect ;)
              <br>
              <br>
              but, if I have many Diversion header in the same INVITE ?
              This command works ?
              <br>
              <br>
            </blockquote>
            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.
            <br>
            <br>
            --
            <br>
            Saúl Ibarra Corretgé
            <br>
            AG Projects
            <br>
            <br>
            <br>
            <br>
            <br>
            _______________________________________________
            <br>
            Users mailing list
            <br>
            <a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
            <br>
            <a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
            <br>
          </blockquote>
          <br>
          <br>
          <br>
          _______________________________________________
          <br>
          Users mailing list
          <br>
          <a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
          <br>
          <a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
          <br>
        </blockquote>
        <br>
        <br>
        <br>
        _______________________________________________
        <br>
        Users mailing list
        <br>
        <a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
        <br>
        <a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
        <br>
        <br>
      </blockquote>
      <br>
      _______________________________________________
      <br>
      Users mailing list
      <br>
      <a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
      <br>
      <a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
      <br>
    </blockquote>
    <br>
  </body>
</html>