Logo Search packages:      
Sourcecode: libnl2 version File versions  Download package

int nl_addr_cmp_prefix ( struct nl_addr *  a,
struct nl_addr *  b 
)

Compares the prefix of two abstract address objects.

  • a A abstract address object.
  • b Another abstract address object.
Returns:
Integer less than, equal to or greather than zero if is found, respectively to be less than, to, or be greater than b.

Definition at line 525 of file addr.c.

{
      int d = a->a_family - b->a_family;

      if (d == 0) {
            int len = min(a->a_prefixlen, b->a_prefixlen);
            int bytes = len / 8;

            d = memcmp(a->a_addr, b->a_addr, bytes);
            if (d == 0) {
                  int mask = (1UL << (len % 8)) - 1UL;

                  d = (a->a_addr[bytes] & mask) -
                      (b->a_addr[bytes] & mask);
            }
      }

      return d;
}


Generated by  Doxygen 1.6.0   Back to index