Revision 5e173e9f lib/net.c

View differences:

lib/net.c
58 58
  }
59 59
}
60 60

  
61

  
62
static inline int net_validate_ip4(const net_addr_ip4 *n)
61
int
62
net_compare(const net_addr *a, const net_addr *b)
63 63
{
64
  return (n->pxlen <= IP4_MAX_PREFIX_LENGTH) &&
65
    ip4_zero(ip4_and(n->prefix, ip4_not(ip4_mkmask(n->pxlen))));
66
}
64
  if (a->type != b->type)
65
    return uint_cmp(a->type, b->type);
67 66

  
68
static inline int net_validate_ip6(const net_addr_ip6 *n)
69
{
70
  return (n->pxlen <= IP6_MAX_PREFIX_LENGTH) &&
71
    ip6_zero(ip6_and(n->prefix, ip6_not(ip6_mkmask(n->pxlen))));
67
  switch (a->type)
68
  {
69
  case NET_IP4:
70
    return net_compare_ip4((const net_addr_ip4 *) a, (const net_addr_ip4 *) b);
71
  case NET_IP6:
72
    return net_compare_ip6((const net_addr_ip6 *) a, (const net_addr_ip6 *) b);
73
  case NET_VPN4:
74
    return net_compare_vpn4((const net_addr_vpn4 *) a, (const net_addr_vpn4 *) b);
75
  case NET_VPN6:
76
    return net_compare_vpn6((const net_addr_vpn6 *) a, (const net_addr_vpn6 *) b);
77
  }
78
  return 0;
72 79
}
73 80

  
74 81
int
75 82
net_validate(const net_addr *N)
76 83
{
77
  switch (a->type)
84
  switch (N->type)
78 85
  {
79 86
  case NET_IP4:
80 87
  case NET_VPN4:

Also available in: Unified diff