Skip to content

Commit

Permalink
sys/net/dhcpv6: let dhcpv6_client_req_ia_pd() return error
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Feb 1, 2023
1 parent 54fe031 commit 0a453ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion sys/include/net/dhcpv6/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ void dhcpv6_client_start(void);
* @param[in] netif The interface to request the prefix delegation for.
* @param[in] pfx_len The desired length of the prefix (note that the server
* might not consider this request). Must be <= 128
*
* @retval 0 on success
* @retval -ENOMEM when there is no lease entry available anymore
* @retval -ENOTSUP when module `dhcpv6_client_ia_pd` is not being used
*/
void dhcpv6_client_req_ia_pd(unsigned netif, unsigned pfx_len);
int dhcpv6_client_req_ia_pd(unsigned netif, unsigned pfx_len);
/** @} */

/**
Expand Down
10 changes: 7 additions & 3 deletions sys/net/application_layer/dhcpv6/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,26 +257,30 @@ void dhcpv6_client_start(void)
}
}

void dhcpv6_client_req_ia_pd(unsigned netif, unsigned pfx_len)
int dhcpv6_client_req_ia_pd(unsigned netif, unsigned pfx_len)
{
pfx_lease_t *lease = NULL;

assert(IS_USED(MODULE_DHCPV6_CLIENT_IA_PD));
assert(pfx_len <= 128);

if (!IS_USED(MODULE_DHCPV6_CLIENT_IA_PD)) {
LOG_WARNING("DHCPv6 client: Unable to request IA_PD as module "
"`dhcpv6_client_ia_pd` is not used\n");
return;
return -ENOTSUP;
}

for (unsigned i = 0; i < CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
if (pfx_leases[i].parent.ia_id.id == 0) {
lease = &pfx_leases[i];
lease->parent.ia_id.info.netif = netif;
lease->parent.ia_id.info.type = DHCPV6_OPT_IA_PD;
lease->pfx_len = pfx_len;
break;
return 0;
}
}

return -ENOMEM;
}

int dhcpv6_client_req_ia_na(unsigned netif)
Expand Down

0 comments on commit 0a453ae

Please sign in to comment.