blob: 0730c43ed45e5633e0ca46fa1575090e4addc3b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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;
}
|