1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 18:27:04 +03:00

dhcp6: Add functionality to request DHCPv6 IA PD

Add a function to request IA Prefix Delegation when the DHCPv6
client is started and PD options to DHCPv6 messages.
This commit is contained in:
Patrik Flykt 2018-01-04 15:11:50 +02:00
parent c77e3db19e
commit 7c3de8f8cf
2 changed files with 39 additions and 0 deletions

View File

@ -55,6 +55,7 @@ struct sd_dhcp6_client {
uint16_t arp_type;
DHCP6IA ia_na;
DHCP6IA ia_pd;
bool prefix_delegation;
be32_t transaction_id;
usec_t transaction_start;
struct sd_dhcp6_lease *lease;
@ -300,6 +301,14 @@ int sd_dhcp6_client_set_request_option(sd_dhcp6_client *client, uint16_t option)
return 0;
}
int sd_dhcp6_client_set_prefix_delegation(sd_dhcp6_client *client, bool delegation) {
assert_return(client, -EINVAL);
client->prefix_delegation = delegation;
return 0;
}
int sd_dhcp6_client_get_lease(sd_dhcp6_client *client, sd_dhcp6_lease **ret) {
assert_return(client, -EINVAL);
@ -413,6 +422,15 @@ static int client_send_message(sd_dhcp6_client *client, usec_t time_now) {
return r;
}
if (client->prefix_delegation) {
r = dhcp6_option_append_pd(opt, optlen, &client->ia_pd);
if (r < 0)
return r;
opt += r;
optlen -= r;
}
break;
case DHCP6_STATE_REQUEST:
@ -439,6 +457,15 @@ static int client_send_message(sd_dhcp6_client *client, usec_t time_now) {
return r;
}
if (client->prefix_delegation) {
r = dhcp6_option_append_pd(opt, optlen, &client->lease->pd);
if (r < 0)
return r;
opt += r;
optlen -= r;
}
break;
case DHCP6_STATE_REBIND:
@ -454,6 +481,15 @@ static int client_send_message(sd_dhcp6_client *client, usec_t time_now) {
return r;
}
if (client->prefix_delegation) {
r = dhcp6_option_append_pd(opt, optlen, &client->lease->pd);
if (r < 0)
return r;
opt += r;
optlen -= r;
}
break;
case DHCP6_STATE_STOPPED:

View File

@ -23,6 +23,7 @@
#include <inttypes.h>
#include <net/ethernet.h>
#include <stdbool.h>
#include <sys/types.h>
#include "sd-dhcp6-lease.h"
@ -118,6 +119,8 @@ int sd_dhcp6_client_get_information_request(
int sd_dhcp6_client_set_request_option(
sd_dhcp6_client *client,
uint16_t option);
int sd_dhcp6_client_set_prefix_delegation(sd_dhcp6_client *client,
bool delegation);
int sd_dhcp6_client_get_lease(
sd_dhcp6_client *client,