diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-04-05 16:16:04 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-04-18 13:56:40 +0200 |
commit | 4278abfe272de64556c4d6df19efc0c853527851 (patch) | |
tree | c5797a702855412fc88c04c9f1a14f73c9c71555 /lib/net.c | |
parent | 3484cb9a654cab9bd2c2b1164528d3000a22a79e (diff) |
Check validity of dest w.r.t. net_type
Allow to define static roa/flow routes without dest.
Diffstat (limited to 'lib/net.c')
-rw-r--r-- | lib/net.c | 34 |
1 files changed, 15 insertions, 19 deletions
@@ -177,33 +177,29 @@ net_hash(const net_addr *n) case NET_ROA6: return NET_HASH(n, roa6); case NET_FLOW4: return NET_HASH(n, flow4); case NET_FLOW6: return NET_HASH(n, flow6); + case NET_MPLS: return NET_HASH(n, mpls); default: bug("invalid type"); } } +#define NET_VALIDATE(a,t) net_validate_##t((const net_addr_##t *) a) + int -net_validate(const net_addr *N) +net_validate(const net_addr *n) { - switch (N->type) + switch (n->type) { - case NET_IP4: - case NET_VPN4: - case NET_ROA4: - case NET_FLOW4: - return net_validate_ip4((net_addr_ip4 *) N); - - case NET_IP6: - case NET_VPN6: - case NET_ROA6: - case NET_FLOW6: - return net_validate_ip6((net_addr_ip6 *) N); - - case NET_MPLS: - return net_validate_mpls((net_addr_mpls *) N); - - default: - return 0; + case NET_IP4: return NET_VALIDATE(n, ip4); + case NET_IP6: return NET_VALIDATE(n, ip6); + case NET_VPN4: return NET_VALIDATE(n, vpn4); + case NET_VPN6: return NET_VALIDATE(n, vpn6); + case NET_ROA4: return NET_VALIDATE(n, roa4); + case NET_ROA6: return NET_VALIDATE(n, roa6); + case NET_FLOW4: return NET_VALIDATE(n, flow4); + case NET_FLOW6: return NET_VALIDATE(n, flow6); + case NET_MPLS: return NET_VALIDATE(n, mpls); + default: return 0; } } |