diff options
author | bharat <bharat@Build64-bharat.vyatta.com> | 2012-09-26 15:17:40 -0700 |
---|---|---|
committer | bharat <bharat@Build64-bharat.vyatta.com> | 2012-09-26 15:17:40 -0700 |
commit | c2fea541719c467678f0967f9e2d5e39e505c3a2 (patch) | |
tree | e2e26a4ff84eab39d0722b04d9730f5195da92b9 /src/check_next_hop.c | |
parent | 6cffc4d634a7a66f04b904f76d88948af6433990 (diff) | |
download | vyatta-cfg-quagga-c2fea541719c467678f0967f9e2d5e39e505c3a2.tar.gz vyatta-cfg-quagga-c2fea541719c467678f0967f9e2d5e39e505c3a2.zip |
- Added Multicast and Broadcast checks for route and next hop for static route command.
Diffstat (limited to 'src/check_next_hop.c')
-rw-r--r-- | src/check_next_hop.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/check_next_hop.c b/src/check_next_hop.c new file mode 100644 index 00000000..0730c43e --- /dev/null +++ b/src/check_next_hop.c @@ -0,0 +1,65 @@ +#include "check_ucast_static.h" + +static void usage(void) +{ + fprintf(stderr, "Usage: check_next_hop [-4|-6] address\n"); + exit(1); +} + +static void get_prefix_1(inet_prefix *dst, char *arg, int family) +{ + + memset(dst, 0, sizeof(*dst)); + get_addr_1(dst, arg, family); + +} + +int main(int argc, char **argv) +{ + int family = AF_UNSPEC; + + while (--argc) { + char *arg = *++argv; + inet_prefix dst; + + if (arg[0] == '-') { + switch(arg[1]) { + case '4': + family = AF_INET; + break; + case '6': + family = AF_INET6; + break; + default: + usage(); + } + continue; + } + + get_prefix_1(&dst, arg, family); + + /* + * Macros to check for Mcast are based on: + * + * Addr dst.data + * 224.1.2.2 ==> 0x030201e0 + * ff01:0203:: ==> 0x030201ff + * + */ + if (family == AF_INET) { + if (IS_MULTICAST(dst.data[0])) { + err("Invalid next_hop...next_hop cannot be multicast\n"); + } + if (IS_BROADCAST(dst.data[0])) { + err("Invalid next_hop...next_hop cannot be broadcast\n"); + } + } else if (family == AF_INET6) { + if (IS_IPV6_MULTICAST(dst.data[0])) { + err("Invalid next_hop...next_hop cannot be IPv6 multicast\n"); + } + } + + } + + return 0; +} |