Skip to content

Commit

Permalink
Merge pull request #195 from robbat2/robbat2/rdnss-test
Browse files Browse the repository at this point in the history
test: add more RDNSS testing for PR#193
  • Loading branch information
robbat2 authored Dec 28, 2024
2 parents b44b930 + 7b4da96 commit 4c2e454
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 7 deletions.
65 changes: 59 additions & 6 deletions test/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion test/test1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -71,7 +74,7 @@ interface eth0 {
abro fe80::a200:0:0:1/64 {
AdvVersionLow 10;
AdvVersionHigh 2;
AdvValidLifetime 2;
AdvValidLifeTime 2;
};
};

19 changes: 19 additions & 0 deletions test/test_rdnss_long.conf
Original file line number Diff line number Diff line change
@@ -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;
};

};

0 comments on commit 4c2e454

Please sign in to comment.