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_ucast_static.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_ucast_static.c')
-rw-r--r-- | src/check_ucast_static.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/check_ucast_static.c b/src/check_ucast_static.c new file mode 100644 index 00000000..d3c4e557 --- /dev/null +++ b/src/check_ucast_static.c @@ -0,0 +1,38 @@ +#include "check_ucast_static.h" + +void get_addr_1(inet_prefix *addr, const char *name, int family) +{ + memset(addr, 0, sizeof(*addr)); + + if (strchr(name, ':')) { + addr->family = AF_INET6; + addr->bytelen = 16; + if (family != AF_UNSPEC && family != AF_INET6) + err("IPV6 address not allowed\n"); + + if (inet_pton(AF_INET6, name, addr->data) <= 0) + err("Invalid IPV6 address: %s\n", name); + + return; + } + + addr->family = AF_INET; + addr->bytelen = 4; + if (family != AF_UNSPEC && family != AF_INET) + err("IPV4 address not allowed\n"); + + if (inet_pton(AF_INET, name, addr->data) <= 0) + err("Invalid IPV4 address: %s\n", name); + return; +} + +void err(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + exit(1); +} |