Skip to content

Commit 7b4da96

Browse files
committed
test: add more RDNSS testing for PR#193
Reference: radvd-project#193 Signed-off-by: Robin H. Johnson <[email protected]>
1 parent 9a62ece commit 7b4da96

File tree

3 files changed

+82
-7
lines changed

3 files changed

+82
-7
lines changed

test/send.c

+59-6
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,14 @@ START_TEST(test_add_ra_options_rdnss)
194194
ck_assert_msg(0, "\n%s", (char*)&buf);
195195
#else
196196
unsigned char expected[] = {
197-
0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
198-
0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199-
0x00, 0x02, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
197+
0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2, // header
198+
0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // address 1
199+
0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, // address 2
200+
0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // address 3
201+
0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x11, 0xd7, // header
202+
0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, // address 1
203+
0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, // address 2
204+
0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, // address 2
200205
};
201206

202207
ck_assert_int_eq(sizeof(expected), sb.used);
@@ -209,7 +214,8 @@ END_TEST
209214

210215
START_TEST(test_add_ra_options_rdnss2)
211216
{
212-
static struct Interface *iface = 0;
217+
struct Interface *iface = 0;
218+
ck_assert_ptr_eq(0, iface);
213219
iface = readin_config("test/test_rdnss.conf");
214220
ck_assert_ptr_ne(0, iface);
215221

@@ -228,8 +234,54 @@ START_TEST(test_add_ra_options_rdnss2)
228234
ck_assert_msg(0, "\n%s", (char*)&buf);
229235
#else
230236
unsigned char expected[] = {
231-
0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x12, 0x34, 0x04, 0x23,
232-
0xfe, 0xfe, 0x04, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
237+
0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d,
238+
// address 1
239+
0x12, 0x34, 0x04, 0x23, 0xfe, 0xfe, 0x04, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
240+
};
241+
242+
ck_assert_int_eq(sizeof(expected), sb.used);
243+
ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used));
244+
#endif
245+
246+
safe_buffer_free(&sb);
247+
}
248+
END_TEST
249+
250+
START_TEST(test_add_ra_options_rdnss3)
251+
{
252+
struct Interface *iface = 0;
253+
ck_assert_ptr_eq(0, iface);
254+
iface = readin_config("test/test_rdnss_long.conf");
255+
ck_assert_ptr_ne(0, iface);
256+
257+
struct safe_buffer_list *sbl = new_safe_buffer_list();
258+
struct safe_buffer sb = SAFE_BUFFER_INIT;
259+
260+
add_ra_options_rdnss(sbl, iface, iface->AdvRDNSSList, iface->state_info.cease_adv, NULL);
261+
262+
safe_buffer_list_to_safe_buffer(sbl, &sb);
263+
safe_buffer_list_free(sbl);
264+
free_ifaces(iface);
265+
266+
#ifdef PRINT_SAFE_BUFFER
267+
char buf[4096];
268+
snprint_safe_buffer(buf, 4096, &sb);
269+
ck_assert_msg(0, "\n%s", (char*)&buf);
270+
#else
271+
unsigned char expected[] = {
272+
//0x19, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, // header
273+
//0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // address 1
274+
//0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, // address 2
275+
//0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // address 3
276+
//0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, // address 4
277+
//0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, // address 5
278+
//0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, // address 6
279+
//0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, // address 7
280+
//0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, // address 8
281+
0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, // header
282+
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // address 1
283+
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, // address 2
284+
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // address 3
233285
};
234286

235287
ck_assert_int_eq(sizeof(expected), sb.used);
@@ -412,6 +464,7 @@ Suite *send_suite(void)
412464
tcase_add_test(tc_build, test_add_ra_options_route);
413465
tcase_add_test(tc_build, test_add_ra_options_rdnss);
414466
tcase_add_test(tc_build, test_add_ra_options_rdnss2);
467+
tcase_add_test(tc_build, test_add_ra_options_rdnss3);
415468
tcase_add_test(tc_build, test_add_ra_options_dnssl);
416469
tcase_add_test(tc_build, test_add_ra_option_mtu);
417470
tcase_add_test(tc_build, test_add_ra_option_sllao);

test/test1.conf

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ interface eth0 {
6060
RDNSS ff02::1 ff02::2 ff02::3 {
6161
AdvRDNSSLifetime 1234;
6262
};
63+
RDNSS ff03::4 ff03::5 ff03::6 {
64+
AdvRDNSSLifetime 4567;
65+
};
6366

6467
lowpanco {
6568
AdvContextCompressionFlag on;
@@ -71,7 +74,7 @@ interface eth0 {
7174
abro fe80::a200:0:0:1/64 {
7275
AdvVersionLow 10;
7376
AdvVersionHigh 2;
74-
AdvValidLifetime 2;
77+
AdvValidLifeTime 2;
7578
};
7679
};
7780

test/test_rdnss_long.conf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# vim:set ts=2 sw=2 ft=perl noet :
2+
3+
interface eth0
4+
{
5+
AdvSendAdvert on;
6+
# More than 3 RDNSS at this point causes radvd to reject the config
7+
RDNSS 2000::1 2000::2 2000::3 #2000::4 2000::5 2000::6 2000::6 2000::7 2000::8
8+
{
9+
# advised by logs to be <= 2*MaxRtrAdvInterval
10+
AdvRDNSSLifetime 45;
11+
};
12+
13+
DNSSL h.piggy.net
14+
{
15+
AdvDNSSLLifetime 45;
16+
};
17+
18+
};
19+

0 commit comments

Comments
 (0)