1 #include "configfile-glue.c"
13 { "1.0.0.1/1", "1.0.0.1", AF_INET
, 1 }
14 ,{ "254.254.254.254/1", "254.0.0.1", AF_INET
, 1 }
15 ,{ "254.254.254.252/31", "254.254.254.253", AF_INET
, 1 }
16 ,{ "254.254.254.253/31", "254.254.254.254", AF_INET
, 0 }
17 ,{ "254.254.254.253/32", "254.254.254.254", AF_INET
, 0 }
18 ,{ "254.254.254.254/32", "254.254.254.254", AF_INET
, 1 }
20 ,{ "2001::/3", "2001::1", AF_INET6
, 1 }
21 ,{ "2f01::/5", "2701::1", AF_INET6
, 0 }
22 ,{ "2f01::/32", "2f01::1", AF_INET6
, 1 }
23 ,{ "2f01::/32", "2f02::1", AF_INET6
, 0 }
24 ,{ "2001::1/127", "2001::1", AF_INET6
, 1 }
25 ,{ "2001::1/127", "2001::2", AF_INET6
, 0 }
26 ,{ "2001::2/128", "2001::2", AF_INET6
, 1 }
27 ,{ "2001::2/128", "2001::3", AF_INET6
, 0 }
28 ,{ "1.0.0.1/1", "::ffff:1.0.0.1", AF_INET6
, 1 }
29 ,{ "254.254.254.254/1", "::ffff:254.0.0.1", AF_INET6
, 1 }
30 ,{ "254.254.254.252/31", "::ffff:254.254.254.253", AF_INET6
, 1 }
31 ,{ "254.254.254.253/31", "::ffff:254.254.254.254", AF_INET6
, 0 }
32 ,{ "254.254.254.253/32", "::ffff:254.254.254.254", AF_INET6
, 0 }
33 ,{ "254.254.254.254/32", "::ffff:254.254.254.254", AF_INET6
, 1 }
34 ,{ "::ffff:1.0.0.1/97", "1.0.0.1", AF_INET
, 1 }
35 ,{ "::ffff:254.254.254.254/97", "254.0.0.1", AF_INET
, 1 }
36 ,{ "::ffff:254.254.254.252/127", "254.254.254.253", AF_INET
, 1 }
37 ,{ "::ffff:254.254.254.253/127", "254.254.254.254", AF_INET
, 0 }
38 ,{ "::ffff:254.254.254.253/128", "254.254.254.254", AF_INET
, 0 }
39 ,{ "::ffff:254.254.254.254/128", "254.254.254.254", AF_INET
, 1 }
43 static void test_configfile_addrbuf_eq_remote_ip_mask (void) {
45 buffer
* const s
= buffer_init();
49 for (i
= 0; i
< (int)(sizeof(rmtmask
)/sizeof(rmtmask
[0])); ++i
) {
50 #ifndef HAVE_INET_PTON
51 rmt
.ipv4
.sin_family
= AF_INET
;
52 rmt
.ipv4
.sin_addr
.s_addr
= inet_addr(rmtmask
[i
].rmtstr
);
54 if (rmtmask
[i
].rmtfamily
== AF_INET
) {
55 rmt
.ipv4
.sin_family
= AF_INET
;
56 inet_pton(AF_INET
, rmtmask
[i
].rmtstr
, &rmt
.ipv4
.sin_addr
);
58 } else if (rmtmask
[i
].rmtfamily
== AF_INET6
) {
59 rmt
.ipv6
.sin6_family
= AF_INET6
;
60 inet_pton(AF_INET6
, rmtmask
[i
].rmtstr
, &rmt
.ipv6
.sin6_addr
);
66 buffer_copy_string(s
, rmtmask
[i
].string
);
67 slash
= strchr(s
->ptr
,'/'); assert(slash
);
68 m
= config_addrbuf_eq_remote_ip_mask(NULL
, s
, slash
, &rmt
);
69 if (m
!= rmtmask
[i
].expect
) {
70 fprintf(stderr
, "failed assertion: %s %s %s\n",
72 rmtmask
[i
].expect
? "==" : "!=",
82 test_configfile_addrbuf_eq_remote_ip_mask();