813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt This file is part of systemd.
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt Copyright (C) 2014 Intel Corporation. All rights reserved.
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt systemd is free software; you can redistribute it and/or modify it
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt under the terms of the GNU Lesser General Public License as published by
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt the Free Software Foundation; either version 2.1 of the License, or
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt (at your option) any later version.
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt systemd is distributed in the hope that it will be useful, but
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt WITHOUT ANY WARRANTY; without even the implied warranty of
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt Lesser General Public License for more details.
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt You should have received a copy of the GNU Lesser General Public License
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt along with systemd; If not, see <http://www.gnu.org/licenses/>.
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt .ether_addr_octet = {'A', 'B', 'C', '1', '2', '3'}
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt assert_se(sd_dhcp6_client_attach_event(client, e, 0) >= 0);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt assert_se(sd_dhcp6_client_set_index(client, 15) == 0);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt assert_se(sd_dhcp6_client_set_index(client, -42) == -EINVAL);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt assert_se(sd_dhcp6_client_set_index(client, -1) == 0);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt assert_se(sd_dhcp6_client_set_index(client, 42) >= 0);
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams assert_se(sd_dhcp6_client_set_mac(client, (const uint8_t *) &mac_addr,
2c1ab8ca9b5dec48c66eb25dd8af71731e70e517Beniamino Galvani assert_se(sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_CLIENTID) == -EINVAL);
2c1ab8ca9b5dec48c66eb25dd8af71731e70e517Beniamino Galvani assert_se(sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_DNS_SERVERS) == -EEXIST);
2c1ab8ca9b5dec48c66eb25dd8af71731e70e517Beniamino Galvani assert_se(sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_NTP_SERVER) == -EEXIST);
2c1ab8ca9b5dec48c66eb25dd8af71731e70e517Beniamino Galvani assert_se(sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_SNTP_SERVERS) == -EEXIST);
2c1ab8ca9b5dec48c66eb25dd8af71731e70e517Beniamino Galvani assert_se(sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_DOMAIN_LIST) == -EEXIST);
da6fe470e17fa02f3adedc779585caf8669252bdPatrik Flykt assert_se(sd_dhcp6_client_set_request_option(client, 10) == -EINVAL);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt assert_se(sd_dhcp6_client_set_callback(client, NULL, NULL) >= 0);
813e3a6ffcd094696001716480bbd68008cc54c8Patrik Flykt assert_se(sd_dhcp6_client_detach_event(client) >= 0);
2c1ab8ca9b5dec48c66eb25dd8af71731e70e517Beniamino Galvani 0x00, SD_DHCP6_OPTION_VENDOR_CLASS, 0x00, 0x09,
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt size_t buflen = sizeof(packet), outlen = sizeof(result);
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt assert_se(dhcp6_option_parse(&buf, &zero, &optcode, &optlen,
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt assert_se(dhcp6_option_parse(&buf, &buflen, &optcode, &optlen,
2c1ab8ca9b5dec48c66eb25dd8af71731e70e517Beniamino Galvani assert_se(optcode == SD_DHCP6_OPTION_ORO);
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt assert_se(dhcp6_option_append(&out, &outlen, optcode, optlen,
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt assert_se(dhcp6_option_parse(&buf, &buflen, &optcode, &optlen,
2c1ab8ca9b5dec48c66eb25dd8af71731e70e517Beniamino Galvani assert_se(optcode == SD_DHCP6_OPTION_VENDOR_CLASS);
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt assert_se(dhcp6_option_append(&out, &outlen, optcode, optlen,
f12ed3bf0b315fc88d5fbdf5bdca14b218c86e0cPatrik Flykt assert_se(memcmp(packet, result, sizeof(packet)) == 0);
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x02, 0x0f, 0xb4, 0xe5, 0x00, 0x01, 0x00, 0x0e,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x00, 0x01, 0x00, 0x01, 0x1a, 0x6b, 0xf3, 0x30,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x3c, 0x97, 0x0e, 0xcf, 0xa3, 0x7d, 0x00, 0x03,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x00, 0x5e, 0x0e, 0xcf, 0xa3, 0x7d, 0x00, 0x00,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x00, 0x50, 0x00, 0x00, 0x00, 0x78, 0x00, 0x05,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x00, 0x18, 0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0xbe, 0xef, 0x78, 0xee, 0x1c, 0xf3, 0x09, 0x3c,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x55, 0xad, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x00, 0xb4, 0x00, 0x0d, 0x00, 0x32, 0x00, 0x00,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x28,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x65, 0x73, 0x29, 0x20, 0x72, 0x65, 0x6e, 0x65,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x77, 0x65, 0x64, 0x2e, 0x20, 0x47, 0x72, 0x65,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x65, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x20, 0x66,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x72, 0x6f, 0x6d, 0x20, 0x70, 0x6c, 0x61, 0x6e,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x65, 0x74, 0x20, 0x45, 0x61, 0x72, 0x74, 0x68,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x00, 0x17, 0x00, 0x10, 0x20, 0x01, 0x0d, 0xb8,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0xde, 0xad, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x0b,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x03, 0x6c, 0x61, 0x62, 0x05, 0x69, 0x6e, 0x74,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x72, 0x61, 0x00, 0x00, 0x1f, 0x00, 0x10, 0x20,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef, 0x00,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x02, 0x00, 0x0e, 0x00, 0x01, 0x00, 0x01, 0x19,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt 0x40, 0x5c, 0x53, 0x78, 0x2b, 0xcb, 0xb3, 0x6d,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x07, 0xf7, 0x4e, 0x57, 0x00, 0x02, 0x00, 0x0e,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x00, 0x01, 0x00, 0x01, 0x19, 0x40, 0x5c, 0x53,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x78, 0x2b, 0xcb, 0xb3, 0x6d, 0x53, 0x00, 0x01,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x00, 0x0e, 0x00, 0x01, 0x00, 0x01, 0x1a, 0x6b,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0xf3, 0x30, 0x3c, 0x97, 0x0e, 0xcf, 0xa3, 0x7d,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x00, 0x03, 0x00, 0x4a, 0x0e, 0xcf, 0xa3, 0x7d,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x78,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x00, 0x05, 0x00, 0x18, 0x20, 0x01, 0x0d, 0xb8,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0xde, 0xad, 0xbe, 0xef, 0x78, 0xee, 0x1c, 0xf3,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x09, 0x3c, 0x55, 0xad, 0x00, 0x00, 0x00, 0x96,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x00, 0x00, 0x00, 0xb4, 0x00, 0x0d, 0x00, 0x1e,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x00, 0x00, 0x41, 0x6c, 0x6c, 0x20, 0x61, 0x64,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x20,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x77, 0x65, 0x72, 0x65, 0x20, 0x61, 0x73, 0x73,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x69, 0x67, 0x6e, 0x65, 0x64, 0x2e, 0x00, 0x17,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x00, 0x10, 0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x00, 0x01, 0x00, 0x18, 0x00, 0x0b, 0x03, 0x6c,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x61, 0x62, 0x05, 0x69, 0x6e, 0x74, 0x72, 0x61,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0x00, 0x00, 0x1f, 0x00, 0x10, 0x20, 0x01, 0x0d,
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt 0xb8, 0xde, 0xad, 0xbe, 0xef, 0x00, 0x00, 0x00,
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering _cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt DHCP6Message *advertise = (DHCP6Message *)msg_advertise;
44481a8b537839cd9ffead4d261491641f5b5260Zbigniew Jędrzejewski-Szmek uint8_t *optval, *opt = msg_advertise + sizeof(DHCP6Message);
d182960ae974a0074010a058d0d909846a2f3f79Patrik Flykt size_t optlen, len = sizeof(msg_advertise) - sizeof(DHCP6Message);
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se((be32toh(advertise->transaction_id) & 0x00ffffff) ==
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt while ((r = dhcp6_option_parse(&opt, &len, &optcode, &optlen,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(!memcmp(optval, &msg_advertise[26], optlen));
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(!memcmp(optval + 4, &val, sizeof(val)));
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(!memcmp(optval + 8, &val, sizeof(val)));
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(dhcp6_option_parse_ia(&optval, &optlen,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(!memcmp(optval, &msg_advertise[179], optlen));
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(dhcp6_lease_set_serverid(lease, optval,
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(dhcp6_lease_set_domains(lease, optval,
e7504d95479455be5cef120fc8e0a48fd74ad5caPatrik Flykt assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
e7504d95479455be5cef120fc8e0a48fd74ad5caPatrik Flykt assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
e7504d95479455be5cef120fc8e0a48fd74ad5caPatrik Flykt assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
e7504d95479455be5cef120fc8e0a48fd74ad5caPatrik Flykt assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
e7504d95479455be5cef120fc8e0a48fd74ad5caPatrik Flykt assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
e7504d95479455be5cef120fc8e0a48fd74ad5caPatrik Flykt assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(dhcp6_lease_get_serverid(lease, &opt, &len) >= 0);
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(!memcmp(opt, &msg_advertise[179], len));
859cca44f834ab1cc3e41fa6b94744f1856ab027Patrik Flykt assert_se(dhcp6_lease_get_preference(lease, &preference) >= 0);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(!memcmp(addrs, &msg_advertise[124], r * 16));
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt r = sd_dhcp6_lease_get_domains(lease, &domains);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt r = sd_dhcp6_lease_get_ntp_addrs(lease, &addrs);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(!memcmp(addrs, &msg_advertise[159], r * 16));
2ea8857effb833615b16d10fc7a19a7104c19e13Patrik Flyktstatic int test_hangcheck(sd_event_source *s, uint64_t usec, void *userdata) {
2ea8857effb833615b16d10fc7a19a7104c19e13Patrik Flykt assert_not_reached("Test case should have completed in 2 seconds");
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flyktstatic void test_client_solicit_cb(sd_dhcp6_client *client, int event,
10c9ce615d98e125bc520efa94aebaef250a4061David Herrmann assert_se(event == SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(sd_dhcp6_client_get_lease(client, &lease) >= 0);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(sd_dhcp6_lease_get_domains(lease, &domains) == 1);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(sd_dhcp6_lease_get_dns(lease, &addrs) == 1);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(!memcmp(addrs, &msg_advertise[124], 16));
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(sd_dhcp6_lease_get_ntp_addrs(lease, &addrs) == 1);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(!memcmp(addrs, &msg_advertise[159], 16));
2c1ab8ca9b5dec48c66eb25dd8af71731e70e517Beniamino Galvani assert_se(sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_DNS_SERVERS) == -EBUSY);
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flyktstatic int test_client_send_reply(DHCP6Message *request) {
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt reply.transaction_id = request->transaction_id;
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt memcpy(&msg_reply[26], test_duid, sizeof(test_duid));
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt memcpy(&msg_reply[44], &test_iaid, sizeof(test_iaid));
947527f8326d3591f252c48fee5426a563f03544Patrik Flykt assert_se(write(test_dhcp_fd[1], msg_reply, sizeof(msg_reply))
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flyktstatic int test_client_verify_request(DHCP6Message *request, uint8_t *option,
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering _cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
d63be95a306bf1e262c7e1c7ad4b2c12b49d371ePatrik Flykt bool found_clientid = false, found_iana = false, found_serverid = false,
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt assert_se(!memcmp(optval, &test_iaid, sizeof(test_iaid)));
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt assert_se(!memcmp(optval + 4, &val, sizeof(val)));
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt assert_se(!memcmp(optval + 8, &val, sizeof(val)));
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt assert_se(!dhcp6_option_parse_ia(&optval, &optlen,
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt assert_se(!memcmp(&msg_advertise[179], optval, optlen));
d63be95a306bf1e262c7e1c7ad4b2c12b49d371ePatrik Flykt assert_se(found_clientid && found_iana && found_serverid &&
e7504d95479455be5cef120fc8e0a48fd74ad5caPatrik Flykt assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt assert_se(!memcmp(&addr, &msg_advertise[42], sizeof(addr)));
e7504d95479455be5cef120fc8e0a48fd74ad5caPatrik Flykt assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
52efd56a6369e19c2400a42981a197cd2eef924aLennart Poetteringstatic int test_client_send_advertise(DHCP6Message *solicit) {
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt advertise.transaction_id = solicit->transaction_id;
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt memcpy(msg_advertise, &advertise.transaction_id, 4);
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt memcpy(&msg_advertise[8], test_duid, sizeof(test_duid));
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt memcpy(&msg_advertise[26], &test_iaid, sizeof(test_iaid));
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt assert_se(write(test_dhcp_fd[1], msg_advertise, sizeof(msg_advertise))
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flyktstatic int test_client_verify_solicit(DHCP6Message *solicit, uint8_t *option,
d63be95a306bf1e262c7e1c7ad4b2c12b49d371ePatrik Flykt bool found_clientid = false, found_iana = false,
d63be95a306bf1e262c7e1c7ad4b2c12b49d371ePatrik Flykt assert_se(found_clientid && found_iana && found_elapsed_time);
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flyktstatic void test_client_information_cb(sd_dhcp6_client *client, int event,
c601ebf79f0c54be14d3c16f0f484c0335cdeec4Tom Gundersen struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } };
10c9ce615d98e125bc520efa94aebaef250a4061David Herrmann assert_se(event == SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(sd_dhcp6_client_get_lease(client, &lease) >= 0);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(sd_dhcp6_lease_get_domains(lease, &domains) == 1);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(sd_dhcp6_lease_get_dns(lease, &addrs) == 1);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(!memcmp(addrs, &msg_advertise[124], 16));
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(sd_dhcp6_lease_get_ntp_addrs(lease, &addrs) == 1);
bc152ff879a79412e358daaaa3677a0fc226bcb0Patrik Flykt assert_se(!memcmp(addrs, &msg_advertise[159], 16));
44598572da523f66872f593be7139b9a0f97deeePatrik Flykt assert_se(sd_dhcp6_client_set_information_request(client, false) == -EBUSY);
44598572da523f66872f593be7139b9a0f97deeePatrik Flykt assert_se(sd_dhcp6_client_set_callback(client, NULL, e) >= 0);
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt assert_se(sd_dhcp6_client_set_information_request(client, false) >= 0);
c601ebf79f0c54be14d3c16f0f484c0335cdeec4Tom Gundersen assert_se(sd_dhcp6_client_set_local_address(client, &address) >= 0);
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flyktstatic int test_client_verify_information_request(DHCP6Message *information_request,
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering _cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt bool found_clientid = false, found_elapsed_time = false;
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt assert_se(information_request->type == DHCP6_INFORMATION_REQUEST);
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt assert_not_reached("IA TA option must not be present");
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt assert_not_reached("Server ID option must not be present");
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt assert_se(found_clientid && found_elapsed_time);
e7504d95479455be5cef120fc8e0a48fd74ad5caPatrik Flykt assert_se(sd_dhcp6_lease_get_address(lease, &addr, <_pref,
2ea8857effb833615b16d10fc7a19a7104c19e13Patrik Flyktint dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address,
2ea8857effb833615b16d10fc7a19a7104c19e13Patrik Flykt IN6ADDR_ALL_DHCP6_RELAY_AGENTS_AND_SERVERS_INIT;
2ea8857effb833615b16d10fc7a19a7104c19e13Patrik Flykt assert_se(IN6_ARE_ADDR_EQUAL(server_address, &mcast));
2ea8857effb833615b16d10fc7a19a7104c19e13Patrik Flykt assert_se(message->transaction_id & 0x00ffffff);
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt test_client_verify_information_request(message, option, len);
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt test_client_verify_solicit(message, option, len);
5e256ea7d3d556b3a1fb5c1faa94ec6a8833e53ePatrik Flykt test_client_verify_request(message, option, len);
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flyktint dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt if (socketpair(AF_UNIX, SOCK_STREAM, 0, test_dhcp_fd) < 0)
fa94c34b083b5b4019975624453e53d0cbad2a5dTom Gundersen usec_t time_now = now(clock_boottime_or_monotonic());
c601ebf79f0c54be14d3c16f0f484c0335cdeec4Tom Gundersen struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } };
2ea8857effb833615b16d10fc7a19a7104c19e13Patrik Flykt assert_se(sd_dhcp6_client_attach_event(client, e, 0) >= 0);
2ea8857effb833615b16d10fc7a19a7104c19e13Patrik Flykt assert_se(sd_dhcp6_client_set_index(client, test_index) == 0);
76253e73f9c9c24fec755e485516f3b55d0707b4Dan Williams assert_se(sd_dhcp6_client_set_mac(client, (const uint8_t *) &mac_addr,
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt assert_se(sd_dhcp6_client_get_information_request(client, &val) >= 0);
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt assert_se(sd_dhcp6_client_set_information_request(client, true) >= 0);
c4e8ceddccfbb14e475e74eb5c57ba32c3c6cf86Patrik Flykt assert_se(sd_dhcp6_client_get_information_request(client, &val) >= 0);
fa94c34b083b5b4019975624453e53d0cbad2a5dTom Gundersen assert_se(sd_event_add_time(e, &hangcheck, clock_boottime_or_monotonic(),