Hello,

you can use cfgutils or siputils.

I plan to add some more IP/dns related functions for config usage (no timelines yet, though):
- netmask comparison using pseudo-variables
- dns resolver for querying and accessing the result in config

So starting a new module like 'ipops' might be a good solution, as well.

Cheers,
Daniel


On 4/27/11 12:50 PM, Iñaki Baz Castillo wrote:
Hi, AFAIK SR doesn't provide a way to binary compare two IPv6 (correct
me if I'm wrong). About IPv4 comparison, I assume it's compared as a
string:

   if ($rd == "1.2.3.4")

so it works. But in case of IPv6 it would not work as the same IPv6
could take different (but equivalent) representations:

   "1080:0000:0000:0000:0008:0800:200C:417A"
   "1080:0:0:0:8:800:200C:417A"
   "1080::8:800:200C:417A"

I'd like to add a function to perform IPv6 binary comparison (as I've
already coded it in a personal project), could you please tell me in
which module should it take place? I mean something as:

--------------------------------------------------------------------------
   compare_ips(ip1, ip2)

   Returns 1 if both IP's are two equal IPv4 or two equal IPv6.
   Returns -1 if both IP's are valid but not equal.
   Returns -2 if at least one give IP is not a valid IPv4 or IPv6.

   Parameters:
   - ip1: An string of pv containing a IPv4 or IPv6 in text representation.
   - ip2: An string of pv containing a IPv4 or IPv6 in text representation.
--------------------------------------------------------------------------

Thanks.


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to