<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>To conclude this discussion, I just pushed a commit to master
      branch that masks also the value of the subnet address parameter.
      There was also a github enhancement request in the tracker related
      to the same topic.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 14.03.18 16:56, Daniel-Constantin
      Mierla wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:c7e28014-bfbb-8908-d1af-72ee7efe77e4@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <p>Hi Hugh,</p>
      <p>thanks for digging into it. I guess it would be safe to change
        the condition into:<br>
      </p>
      if ((ip->s_addr & ipv4_mask) == (net_addr.s_addr &
      ipv4_mask))<br>
      <br>
      to be more flexible in matching by providing full ip and its
      netmask. It should not break existing matching with masked subnet
      address.<br>
      <br>
      Anyone having a different opinion on this?<br>
      <br>
      Cheers,<br>
      Daniel<br>
      <br>
      <div class="moz-cite-prefix">On 14.03.18 15:57, Hugh Waite wrote:<br>
      </div>
      <blockquote type="cite"
cite="mid:CAA-nSUsU0CipaUOfWfx138wG_8vRO4f_bKhOzkv6UiEuL1Dr2A@mail.gmail.com">
        <div dir="ltr">Hi,
          <div>It looks from the code that the subnet IP address must be
            masked.</div>
          <div><a
href="https://github.com/kamailio/kamailio/blob/master/src/modules/ipops/ipops_mod.c#L393"
              moz-do-not-send="true">https://github.com/kamailio/kamailio/blob/master/src/modules/ipops/ipops_mod.c#L393</a><br>
          </div>
          <div><br>
          </div>
          <div>
            <div><span style="white-space:pre">   </span>if
              ((ip->s_addr & ipv4_mask) == net_addr.s_addr)</div>
            <div><span style="white-space:pre">           </span>return 1;</div>
            <div><span style="white-space:pre">   </span>return 0;</div>
          </div>
          <div><br>
          </div>
          <div>So <a href="http://10.1.1.0/24" moz-do-not-send="true">10.1.1.0/24</a>
            will match 10.1.1.241</div>
          <div>but <a href="http://10.1.1.128/24"
              moz-do-not-send="true">10.1.1.128/24</a> will NOT match
            10.1.1.241</div>
          <div><br>
          </div>
          <div>Regards,</div>
          <div>Hugh</div>
        </div>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On 14 March 2018 at 12:39,
            Daniel-Constantin Mierla <span dir="ltr"><<a
                href="mailto:miconda@gmail.com" target="_blank"
                moz-do-not-send="true">miconda@gmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
              <br>
              maybe it is what Hugh said in his response, respectively
              that the subnet<br>
              needs to have the lowest bits masked.<br>
              <br>
              Can you run with debug=3? Maybe ipops module writes more
              debug message<br>
              to track it.<br>
              <br>
              Cheers,<br>
              Daniel<br>
              <div class="HOEnZb">
                <div class="h5"><br>
                  <br>
                  On 14.03.18 13:33, <a
                    href="mailto:volga629@networklab.ca"
                    moz-do-not-send="true">volga629@networklab.ca</a>
                  wrote:<br>
                  > Hello Daniel,<br>
                  > I adjusted var to $dd and still not match<br>
                  ><br>
                  >        if(is_method("INVITE")) {<br>
                  >                #$avp(destIP)=$(du{s.select,1,<wbr>:});<br>
                  >                #$avp(subnet) = $avp(destIP) +
                  "/16";<br>
                  >                #xlog("L_INFO", "Initial Request:
                  [$rm] destination ip<br>
                  > [$avp(destIP)] and sourceip [$si]\n");<br>
                  >                xlog("L_INFO", "Initial Request:
                  [$rm] destination ip<br>
                  > [$dd] and sourceip [$si]\n");<br>
                  >                if(!is_in_subnet("$si", "$dd/16"))
                  {<br>
                  >                        xlog("L_INFO", "Subnets
                  not match processing<br>
                  > rtp...destination ip [$dd] and source ip
                  [$si]\n");<br>
                  >                        route(RTP_MANAGE);<br>
                  >                }<br>
                  >        }<br>
                  ><br>
                  ><br>
                  > Mar 14 13:21:06 sbc00 /usr/sbin/kamailio[1104]:
                  {1 2 INVITE<br>
                  > Edz14KmQgLQpO5L323Wodw..} INFO: <script>:
                  Initial Request: [INVITE]<br>
                  > destination ip [10.0.1.241] and sourceip
                  [10.0.1.242]<br>
                  > Mar 14 13:21:06 sbc00 /usr/sbin/kamailio[1104]:
                  {1 2 INVITE<br>
                  > Edz14KmQgLQpO5L323Wodw..} INFO: <script>:
                  Subnets not match processing<br>
                  > rtp...destination ip [<a
                    href="http://10.0.1.241/16" rel="noreferrer"
                    target="_blank" moz-do-not-send="true">10.0.1.241/16</a>]
                  and source ip [10.0.1.242]<br>
                  ><br>
                  ><br>
                  > Slava<br>
                  ><br>
                  > On Wed, Mar 14, 2018 at 6:19 AM,
                  Daniel-Constantin Mierla<br>
                  > <<a href="mailto:miconda@gmail.com"
                    moz-do-not-send="true">miconda@gmail.com</a>>
                  wrote:<br>
                  >> Hello,<br>
                  >><br>
                  >><br>
                  >> On 14.03.18 00:19, <a
                    href="mailto:volga629@networklab.ca"
                    moz-do-not-send="true">volga629@networklab.ca</a>
                  wrote:<br>
                  >>>  Hello Everyone,<br>
                  >>>  Not sure what I am missing, but can't
                  match ip address to subnet<br>
                  >>><br>
                  >>>  Log says<br>
                  >>><br>
                  >>>   INFO: <script>: Subnets not match
                  processing rtp...destination ip<br>
                  >>>  [10.0.1.242] and sourceip [10.0.1.241]<br>
                  >>><br>
                  >>><br>
                  >>>         if(is_method("INVITE")) {<br>
                  >>>                
                  $avp(destip)=$(du{s.select,1,:<wbr>});<br>
                  >>>                 $avp(subnet) =
                  $avp(destip) + "/16";<br>
                  >> if you want to get the host part (ip) of the
                  $du, then just use $dd.<br>
                  >><br>
                  >>>                 xlog("L_INFO", "Initial
                  Request: [$rm] destination ip<br>
                  >>>  [$avp(destip)] and sourceip [$si]\n");<br>
                  >>>                 if(!is_in_subnet("$si",
                  "$avp(subnet)")) {<br>
                  >><br>
                  >> So instead of the above if, get rid of the
                  avps and you can just use:<br>
                  >><br>
                  >>                if(!is_in_subnet("$si",
                  "$dd/16")) {<br>
                  >><br>
                  >> Cheers,<br>
                  >> Daniel<br>
                  >>>                         xlog("L_INFO",
                  "Subnets not match processing<br>
                  >>>  rtp...destination ip [$avp(subnet)] and
                  source ip [$si]\n");<br>
                  >>>                        
                  route(RTP_MANAGE);<br>
                  >>>                 }<br>
                  >>>         }<br>
                  >>><br>
                  >>><br>
                  >>><br>
                  >>>  [root@prx00 ~]# rpm -qa | grep kamailio<br>
                  >>>  kamailio-mysql-5.1.2-2.<wbr>git4c840b7e9.fc27.x86_64<br>
                  >>>  kamailio-5.1.2-2.<wbr>git4c840b7e9.fc27.x86_64<br>
                  >>><br>
                  >>><br>
                  >>>  Slava.<br>
                  >>><br>
                  >>><br>
                  >>>  _____________________________<wbr>__________________<br>
                  >>>  Kamailio (SER) - Users Mailing List<br>
                  >>>  <a
                    href="mailto:sr-users@lists.kamailio.org"
                    moz-do-not-send="true">sr-users@lists.kamailio.org</a><br>
                  >>>  <a
                    href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
                  >><br>
                  >> --<br>
                  >> Daniel-Constantin Mierla<br>
                  >> <a href="http://www.twitter.com/miconda"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">www.twitter.com/miconda</a>
                  -- <a href="http://www.linkedin.com/in/miconda"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">www.linkedin.com/in/miconda</a><br>
                  >> Kamailio Advanced Training - April 16-18,
                  2018, Berlin - <a href="http://www.asipto.com"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">www.asipto.com</a><br>
                  >> Kamailio World Conference - May 14-16, 2018 -
                  <a href="http://www.kamailioworld.com"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">www.kamailioworld.com</a><br>
                  >><br>
                  >><br>
                  ><br>
                  <br>
                  --<br>
                  Daniel-Constantin Mierla<br>
                  <a href="http://www.twitter.com/miconda"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">www.twitter.com/miconda</a>
                  -- <a href="http://www.linkedin.com/in/miconda"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">www.linkedin.com/in/miconda</a><br>
                  Kamailio Advanced Training - April 16-18, 2018, Berlin
                  - <a href="http://www.asipto.com" rel="noreferrer"
                    target="_blank" moz-do-not-send="true">www.asipto.com</a><br>
                  Kamailio World Conference - May 14-16, 2018 - <a
                    href="http://www.kamailioworld.com" rel="noreferrer"
                    target="_blank" moz-do-not-send="true">www.kamailioworld.com</a><br>
                  <br>
                  <br>
                  ______________________________<wbr>_________________<br>
                  Kamailio (SER) - Users Mailing List<br>
                  <a href="mailto:sr-users@lists.kamailio.org"
                    moz-do-not-send="true">sr-users@lists.kamailio.org</a><br>
                  <a
                    href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org" moz-do-not-send="true">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" moz-do-not-send="true">https://lists.kamailio.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-abbreviated" href="http://www.twitter.com/miconda" moz-do-not-send="true">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda" moz-do-not-send="true">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - April 16-18, 2018, Berlin - <a class="moz-txt-link-abbreviated" href="http://www.asipto.com" moz-do-not-send="true">www.asipto.com</a>
Kamailio World Conference - May 14-16, 2018 - <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com" moz-do-not-send="true">www.kamailioworld.com</a></pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - April 16-18, 2018, Berlin - <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
Kamailio World Conference - May 14-16, 2018 - <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
  </body>
</html>