diff --git a/test/send.c b/test/send.c index 9b432fd..06abd41 100644 --- a/test/send.c +++ b/test/send.c @@ -194,9 +194,14 @@ START_TEST(test_add_ra_options_rdnss) ck_assert_msg(0, "\n%s", (char*)&buf); #else unsigned char expected[] = { - 0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x02, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x04, 0xd2, // header + 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // address 1 + 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, // address 2 + 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // address 3 + 0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x11, 0xd7, // header + 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, // address 1 + 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, // address 2 + 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, // address 2 }; ck_assert_int_eq(sizeof(expected), sb.used); @@ -209,7 +214,8 @@ END_TEST START_TEST(test_add_ra_options_rdnss2) { - static struct Interface *iface = 0; + struct Interface *iface = 0; + ck_assert_ptr_eq(0, iface); iface = readin_config("test/test_rdnss.conf"); ck_assert_ptr_ne(0, iface); @@ -228,8 +234,54 @@ START_TEST(test_add_ra_options_rdnss2) ck_assert_msg(0, "\n%s", (char*)&buf); #else unsigned char expected[] = { - 0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x12, 0x34, 0x04, 0x23, - 0xfe, 0xfe, 0x04, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x19, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, + // address 1 + 0x12, 0x34, 0x04, 0x23, 0xfe, 0xfe, 0x04, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + }; + + ck_assert_int_eq(sizeof(expected), sb.used); + ck_assert_int_eq(0, memcmp(expected, sb.buffer, sb.used)); +#endif + + safe_buffer_free(&sb); +} +END_TEST + +START_TEST(test_add_ra_options_rdnss3) +{ + struct Interface *iface = 0; + ck_assert_ptr_eq(0, iface); + iface = readin_config("test/test_rdnss_long.conf"); + ck_assert_ptr_ne(0, iface); + + struct safe_buffer_list *sbl = new_safe_buffer_list(); + struct safe_buffer sb = SAFE_BUFFER_INIT; + + add_ra_options_rdnss(sbl, iface, iface->AdvRDNSSList, iface->state_info.cease_adv, NULL); + + safe_buffer_list_to_safe_buffer(sbl, &sb); + safe_buffer_list_free(sbl); + free_ifaces(iface); + +#ifdef PRINT_SAFE_BUFFER + char buf[4096]; + snprint_safe_buffer(buf, 4096, &sb); + ck_assert_msg(0, "\n%s", (char*)&buf); +#else + unsigned char expected[] = { + //0x19, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, // header + //0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // address 1 + //0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, // address 2 + //0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // address 3 + //0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, // address 4 + //0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, // address 5 + //0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, // address 6 + //0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, // address 7 + //0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, // address 8 + 0x19, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, // header + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // address 1 + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, // address 2 + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, // address 3 }; ck_assert_int_eq(sizeof(expected), sb.used); @@ -412,6 +464,7 @@ Suite *send_suite(void) tcase_add_test(tc_build, test_add_ra_options_route); tcase_add_test(tc_build, test_add_ra_options_rdnss); tcase_add_test(tc_build, test_add_ra_options_rdnss2); + tcase_add_test(tc_build, test_add_ra_options_rdnss3); tcase_add_test(tc_build, test_add_ra_options_dnssl); tcase_add_test(tc_build, test_add_ra_option_mtu); tcase_add_test(tc_build, test_add_ra_option_sllao); diff --git a/test/test1.conf b/test/test1.conf index 65536ff..f54403e 100644 --- a/test/test1.conf +++ b/test/test1.conf @@ -60,6 +60,9 @@ interface eth0 { RDNSS ff02::1 ff02::2 ff02::3 { AdvRDNSSLifetime 1234; }; + RDNSS ff03::4 ff03::5 ff03::6 { + AdvRDNSSLifetime 4567; + }; lowpanco { AdvContextCompressionFlag on; @@ -71,7 +74,7 @@ interface eth0 { abro fe80::a200:0:0:1/64 { AdvVersionLow 10; AdvVersionHigh 2; - AdvValidLifetime 2; + AdvValidLifeTime 2; }; }; diff --git a/test/test_rdnss_long.conf b/test/test_rdnss_long.conf new file mode 100644 index 0000000..3af806b --- /dev/null +++ b/test/test_rdnss_long.conf @@ -0,0 +1,19 @@ +# vim:set ts=2 sw=2 ft=perl noet : + +interface eth0 +{ + AdvSendAdvert on; + # More than 3 RDNSS at this point causes radvd to reject the config + RDNSS 2000::1 2000::2 2000::3 #2000::4 2000::5 2000::6 2000::6 2000::7 2000::8 + { + # advised by logs to be <= 2*MaxRtrAdvInterval + AdvRDNSSLifetime 45; + }; + + DNSSL h.piggy.net + { + AdvDNSSLLifetime 45; + }; + +}; +