int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
size_t optlen, const void *optval);
int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia);
-int dhcp6_option_append_pd(uint8_t **buf, size_t *buflen, const DHCP6IA *pd, const DHCP6Address *hint_pd_prefix);
+int dhcp6_option_append_pd(uint8_t **buf, size_t *buflen, const DHCP6IA *pd);
int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char * const *user_class);
int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const *user_class);
return offsetof(DHCP6Option, data) + sizeof(struct iapdprefix);
}
-int dhcp6_option_append_pd(uint8_t **buf, size_t *buflen, const DHCP6IA *pd, const DHCP6Address *hint_pd_prefix) {
+int dhcp6_option_append_pd(uint8_t **buf, size_t *buflen, const DHCP6IA *pd) {
struct ia_header header;
size_t len, pd_buflen;
uint8_t *pd_hdr;
len += r;
}
- if (hint_pd_prefix && hint_pd_prefix->iapdprefix.prefixlen > 0) {
- r = option_append_pd_prefix(buf, buflen, hint_pd_prefix);
- if (r < 0)
- return r;
-
- len += r;
- }
-
return option_append_hdr(&pd_hdr, &pd_buflen, pd->type, len);
}
int event_priority;
int ifindex;
char *ifname;
- DHCP6Address hint_pd_prefix;
struct in6_addr local_address;
uint8_t mac_addr[MAX_MAC_ADDR_LEN];
size_t mac_addr_len;
int sd_dhcp6_client_set_prefix_delegation_hint(
sd_dhcp6_client *client,
uint8_t prefixlen,
- const struct in6_addr *pd_address) {
+ const struct in6_addr *pd_prefix) {
+
+ _cleanup_free_ DHCP6Address *prefix = NULL;
assert_return(client, -EINVAL);
- assert_return(pd_address, -EINVAL);
assert_return(client->state == DHCP6_STATE_STOPPED, -EBUSY);
- client->hint_pd_prefix.iapdprefix.address = *pd_address;
- client->hint_pd_prefix.iapdprefix.prefixlen = prefixlen;
+ if (!pd_prefix) {
+ /* clear previous assignments. */
+ dhcp6_ia_clear_addresses(&client->ia_pd);
+ return 0;
+ }
+
+ assert_return(prefixlen > 0 && prefixlen <= 128, -EINVAL);
- return 0;
+ prefix = new(DHCP6Address, 1);
+ if (!prefix)
+ return -ENOMEM;
+
+ *prefix = (DHCP6Address) {
+ .iapdprefix.address = *pd_prefix,
+ .iapdprefix.prefixlen = prefixlen,
+ };
+
+ LIST_PREPEND(addresses, client->ia_pd.addresses, TAKE_PTR(prefix));
+ return 1;
}
int sd_dhcp6_client_add_vendor_option(sd_dhcp6_client *client, sd_dhcp6_option *v) {
uint8_t **opt,
size_t *optlen,
const DHCP6IA *ia_na,
- const DHCP6IA *ia_pd,
- const DHCP6Address *hint_pd_prefix) {
+ const DHCP6IA *ia_pd) {
int r;
}
if (FLAGS_SET(client->request_ia, DHCP6_REQUEST_IA_PD) && ia_pd) {
- r = dhcp6_option_append_pd(opt, optlen, ia_pd, hint_pd_prefix);
+ r = dhcp6_option_append_pd(opt, optlen, ia_pd);
if (r < 0)
return r;
}
if (r < 0)
return r;
- r = client_append_common_options_in_managed_mode(client, &opt, &optlen, &client->ia_na,
- &client->ia_pd, &client->hint_pd_prefix);
+ r = client_append_common_options_in_managed_mode(client, &opt, &optlen,
+ &client->ia_na, &client->ia_pd);
if (r < 0)
return r;
break;
assert(client->lease);
r = client_append_common_options_in_managed_mode(client, &opt, &optlen,
- client->lease->ia_na, client->lease->ia_pd, NULL);
+ client->lease->ia_na, client->lease->ia_pd);
if (r < 0)
return r;
break;
free(client->req_opts);
free(client->fqdn);
free(client->mudurl);
-
+ dhcp6_ia_clear_addresses(&client->ia_pd);
ordered_hashmap_free(client->extra_options);
strv_free(client->user_class);
strv_free(client->vendor_class);
.request_ia = DHCP6_REQUEST_IA_NA | DHCP6_REQUEST_IA_PD,
.fd = -1,
.req_opts_len = ELEMENTSOF(default_req_opts),
- .hint_pd_prefix.iapdprefix.lifetime_preferred = (be32_t) -1,
- .hint_pd_prefix.iapdprefix.lifetime_valid = (be32_t) -1,
.req_opts = TAKE_PTR(req_opts),
};