<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    just adding that the tobody transformation could be handy to extract
    the user or uri part of a Diversion header, not to fight with subst
    expressions:<br>
    <br>
    -
<a class="moz-txt-link-freetext" href="http://www.kamailio.org/wiki/cookbooks/devel/transformations#to-body_transformations">http://www.kamailio.org/wiki/cookbooks/devel/transformations#to-body_transformations</a><br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <div class="moz-cite-prefix">On 4/9/13 3:16 PM, Morten Isaksen
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAAyFOkGT3_WF7Zot9opw2naCxFU5seE8R=VMvsW=QfQuw05UFQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>Hi,<br>
                <br>
              </div>
              I have not tested this, but try:<br>
              <br>
              $avp(s:divhdr) = $(hdr(Diversion)[$var(i)]);<br>
            </div>
            avp_subst("$avp(s:divhdr)", "/.*<a class="moz-txt-link-freetext" href="sip:\+45(.*)(@.*)/\1/">sip:\+45(.*)(@.*)/\1/</a>"); #
            Extract number between +45 and @<br>
          </div>
          <br>
          if (is_user_in("$avp(s:divhdr)", "1") { ... }<br>
          <br>
        </div>
        <div>Please note that there can be more than one Diverseion
          header. In that case you can use:<br>
          <br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $var(i)=0;<br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while($(hdr(Diversion)[$var(i)]) !=
          $null ) {<br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $avp(s:divhdr) =
          $(hdr(Diversion)[$var(i)]);<br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlog("L_WARN",
          "$avp(s:divhdr)");<br>
          <br>
          <br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $var(i) = $var(i) +1;<br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
          <br>
          <br>
        </div>
        <div><br>
        </div>
        /Morten<br>
        <div><br>
          <div>
            <div><br>
              <br>
            </div>
          </div>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">
          On Tue, Apr 9, 2013 at 11:12 AM, phillman25 <span dir="ltr">&lt;<a
              moz-do-not-send="true" href="mailto:phillman25@gmail.com"
              target="_blank">phillman25@gmail.com</a>&gt;</span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Dear List
              <div><br>
              </div>
              <div>I am currently using the group module to authenticate
                inbound calls using the From header using the below
                code:</div>
              <div><br>
              </div>
              <div>
                <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!is_user_in("From", "1")) {</div>
                <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sl_send_reply("403", "NOT ALLOWED");</div>
                <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit;</div>
                <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;};</div>
                <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;};</div>
                <div><br>
                </div>
                <div>I want to now authenticate the Diversion header,
                  when the call is diverted, the same way as above using
                  the group module how could i proceed with this?</div>
                <div><br>
                </div>
                <div>thanking you in advance</div>
                <div>Phillip</div>
                <div><br>
                </div>
                <div><br>
                </div>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            SIP Express Router (SER) and Kamailio (OpenSER) - sr-users
            mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
            <a moz-do-not-send="true"
              href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users"
              target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        Morten Isaksen<br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Kamailio World Conference, April 16-17, 2013, Berlin
 - <a class="moz-txt-link-freetext" href="http://conference.kamailio.com">http://conference.kamailio.com</a> -</pre>
  </body>
</html>