1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 09:56:51 +03:00

dhpc6: Add PD and PD Prefix tests

Add tests for IA PD and PD Prefix options.
This commit is contained in:
Patrik Flykt 2018-01-04 15:11:53 +02:00
parent b47fb949b3
commit 819c56f6fa

View File

@ -189,8 +189,41 @@ static int test_option_status(sd_event *e) {
0x00, 0x0d, 0x00, 0x08, 0x00, 0x00, 'f', 'o',
'o', 'b', 'a', 'r',
};
static const uint8_t option4[] = {
/* IA PD */
0x00, 0x19, 0x00, 0x2f, 0x1a, 0x1d, 0x1a, 0x1d,
0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02,
/* IA PD Prefix */
0x00, 0x1a, 0x00, 0x1f,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x80, 0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe,
0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
/* status option */
0x00, 0x0d, 0x00, 0x02, 0x00, 0x00,
};
static const uint8_t option5[] = {
/* IA PD */
0x00, 0x19, 0x00, 0x52, 0x1a, 0x1d, 0x1a, 0x1d,
0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02,
/* IA PD Prefix #1 */
0x00, 0x1a, 0x00, 0x1f,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x80, 0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe,
0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
/* status option */
0x00, 0x0d, 0x00, 0x02, 0x00, 0x00,
/* IA PD Prefix #2 */
0x00, 0x1a, 0x00, 0x1f,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x80, 0x20, 0x01, 0x0d, 0xb8, 0xc0, 0x0l, 0xd0,
0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x0d, 0x00, 0x02, 0x00, 0x00,
};
DHCP6Option *option;
DHCP6IA ia;
DHCP6IA ia, pd;
int r = 0;
if (verbose)
@ -230,6 +263,25 @@ static int test_option_status(sd_event *e) {
assert_se(r >= 0);
assert_se(ia.addresses != NULL);
zero(pd);
option = (DHCP6Option *)option4;
assert_se(sizeof(option4) == sizeof(DHCP6Option) + be16toh(option->len));
r = dhcp6_option_parse_ia(option, &pd);
assert_se(r == 0);
assert_se(pd.addresses != NULL);
assert_se(memcmp(&pd.ia_pd.id, &option4[4], 4) == 0);
assert_se(memcmp(&pd.ia_pd.lifetime_t1, &option4[8], 4) == 0);
assert_se(memcmp(&pd.ia_pd.lifetime_t2, &option4[12], 4) == 0);
zero(pd);
option = (DHCP6Option *)option5;
assert_se(sizeof(option5) == sizeof(DHCP6Option) + be16toh(option->len));
r = dhcp6_option_parse_ia(option, &pd);
assert_se(r == 0);
assert_se(pd.addresses != NULL);
return 0;
}