]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-dhcp6-client.h
send dhcpv6 release when stopping
[thirdparty/systemd.git] / src / systemd / sd-dhcp6-client.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
139b011a
PF
2#ifndef foosddhcp6clienthfoo
3#define foosddhcp6clienthfoo
4
5/***
810adae9 6 Copyright © 2014 Intel Corporation. All rights reserved.
139b011a
PF
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
85fce6f4 19 along with systemd; If not, see <https://www.gnu.org/licenses/>.
139b011a
PF
20***/
21
04c01369 22#include <inttypes.h>
139b011a 23#include <net/ethernet.h>
04c01369 24#include <sys/types.h>
139b011a 25
793178b9 26#include "sd-device.h"
ea3b3a75 27#include "sd-dhcp6-lease.h"
e7d5fe17 28#include "sd-dhcp6-option.h"
71d35b6b 29#include "sd-event.h"
ea3b3a75 30
04c01369
LP
31#include "_sd-common.h"
32
33_SD_BEGIN_DECLARATIONS;
34
139b011a 35enum {
10c9ce61
DH
36 SD_DHCP6_CLIENT_EVENT_STOP = 0,
37 SD_DHCP6_CLIENT_EVENT_RESEND_EXPIRE = 10,
38 SD_DHCP6_CLIENT_EVENT_RETRANS_MAX = 11,
39 SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE = 12,
5476cb98 40 SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST = 13
139b011a
PF
41};
42
f5e3619b 43/* https://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xhtml#dhcpv6-parameters-2 */
2c1ab8ca 44enum {
f5e3619b
YW
45 SD_DHCP6_OPTION_CLIENTID = 1, /* RFC 8415 */
46 SD_DHCP6_OPTION_SERVERID = 2, /* RFC 8415 */
47 SD_DHCP6_OPTION_IA_NA = 3, /* RFC 8415 */
48 SD_DHCP6_OPTION_IA_TA = 4, /* RFC 8415 */
49 SD_DHCP6_OPTION_IAADDR = 5, /* RFC 8415 */
50 SD_DHCP6_OPTION_ORO = 6, /* RFC 8415 */
51 SD_DHCP6_OPTION_PREFERENCE = 7, /* RFC 8415 */
52 SD_DHCP6_OPTION_ELAPSED_TIME = 8, /* RFC 8415 */
53 SD_DHCP6_OPTION_RELAY_MSG = 9, /* RFC 8415 */
2c1ab8ca 54 /* option code 10 is unassigned */
f5e3619b
YW
55 SD_DHCP6_OPTION_AUTH = 11, /* RFC 8415 */
56 SD_DHCP6_OPTION_UNICAST = 12, /* RFC 8415 */
57 SD_DHCP6_OPTION_STATUS_CODE = 13, /* RFC 8415 */
58 SD_DHCP6_OPTION_RAPID_COMMIT = 14, /* RFC 8415 */
59 SD_DHCP6_OPTION_USER_CLASS = 15, /* RFC 8415 */
60 SD_DHCP6_OPTION_VENDOR_CLASS = 16, /* RFC 8415 */
61 SD_DHCP6_OPTION_VENDOR_OPTS = 17, /* RFC 8415 */
62 SD_DHCP6_OPTION_INTERFACE_ID = 18, /* RFC 8415 */
63 SD_DHCP6_OPTION_RECONF_MSG = 19, /* RFC 8415 */
64 SD_DHCP6_OPTION_RECONF_ACCEPT = 20, /* RFC 8415 */
65 SD_DHCP6_OPTION_SIP_SERVER_DOMAIN_NAME = 21, /* RFC 3319 */
66 SD_DHCP6_OPTION_SIP_SERVER_ADDRESS = 22, /* RFC 3319 */
f697ab35
YW
67 SD_DHCP6_OPTION_DNS_SERVER = 23, /* RFC 3646 */
68 SD_DHCP6_OPTION_DOMAIN = 24, /* RFC 3646 */
f5e3619b
YW
69 SD_DHCP6_OPTION_IA_PD = 25, /* RFC 3633, RFC 8415 */
70 SD_DHCP6_OPTION_IA_PD_PREFIX = 26, /* RFC 3633, RFC 8415 */
f697ab35
YW
71 SD_DHCP6_OPTION_NIS_SERVER = 27, /* RFC 3898 */
72 SD_DHCP6_OPTION_NISP_SERVER = 28, /* RFC 3898 */
f5e3619b
YW
73 SD_DHCP6_OPTION_NIS_DOMAIN_NAME = 29, /* RFC 3898 */
74 SD_DHCP6_OPTION_NISP_DOMAIN_NAME = 30, /* RFC 3898 */
f697ab35 75 SD_DHCP6_OPTION_SNTP_SERVER = 31, /* RFC 4075, deprecated */
f5e3619b
YW
76 SD_DHCP6_OPTION_INFORMATION_REFRESH_TIME = 32, /* RFC 4242, 8415, sec. 21.23 */
77 SD_DHCP6_OPTION_BCMCS_SERVER_D = 33, /* RFC 4280 */
78 SD_DHCP6_OPTION_BCMCS_SERVER_A = 34, /* RFC 4280 */
2c1ab8ca 79 /* option code 35 is unassigned */
f5e3619b
YW
80 SD_DHCP6_OPTION_GEOCONF_CIVIC = 36, /* RFC 4776 */
81 SD_DHCP6_OPTION_REMOTE_ID = 37, /* RFC 4649 */
82 SD_DHCP6_OPTION_SUBSCRIBER_ID = 38, /* RFC 4580 */
83 SD_DHCP6_OPTION_CLIENT_FQDN = 39, /* RFC 4704 */
84 SD_DHCP6_OPTION_PANA_AGENT = 40, /* RFC 5192 */
3d80c57b
YW
85 SD_DHCP6_OPTION_POSIX_TIMEZONE = 41, /* RFC 4833 */
86 SD_DHCP6_OPTION_TZDB_TIMEZONE = 42, /* RFC 4833 */
f5e3619b
YW
87 SD_DHCP6_OPTION_ERO = 43, /* RFC 4994 */
88 SD_DHCP6_OPTION_LQ_QUERY = 44, /* RFC 5007 */
89 SD_DHCP6_OPTION_CLIENT_DATA = 45, /* RFC 5007 */
90 SD_DHCP6_OPTION_CLT_TIME = 46, /* RFC 5007 */
91 SD_DHCP6_OPTION_LQ_RELAY_DATA = 47, /* RFC 5007 */
92 SD_DHCP6_OPTION_LQ_CLIENT_LINK = 48, /* RFC 5007 */
93 SD_DHCP6_OPTION_MIP6_HNIDF = 49, /* RFC 6610 */
94 SD_DHCP6_OPTION_MIP6_VDINF = 50, /* RFC 6610 */
95 SD_DHCP6_OPTION_V6_LOST = 51, /* RFC 5223 */
96 SD_DHCP6_OPTION_CAPWAP_AC_V6 = 52, /* RFC 5417 */
97 SD_DHCP6_OPTION_RELAY_ID = 53, /* RFC 5460 */
98 SD_DHCP6_OPTION_IPV6_ADDRESS_MOS = 54, /* RFC 5678 */
99 SD_DHCP6_OPTION_IPV6_FQDN_MOS = 55, /* RFC 5678 */
2c1ab8ca 100 SD_DHCP6_OPTION_NTP_SERVER = 56, /* RFC 5908 */
f5e3619b
YW
101 SD_DHCP6_OPTION_V6_ACCESS_DOMAIN = 57, /* RFC 5986 */
102 SD_DHCP6_OPTION_SIP_UA_CS_LIST = 58, /* RFC 6011 */
103 SD_DHCP6_OPTION_BOOTFILE_URL = 59, /* RFC 5970 */
104 SD_DHCP6_OPTION_BOOTFILE_PARAM = 60, /* RFC 5970 */
105 SD_DHCP6_OPTION_CLIENT_ARCH_TYPE = 61, /* RFC 5970 */
106 SD_DHCP6_OPTION_NII = 62, /* RFC 5970 */
107 SD_DHCP6_OPTION_GEOLOCATION = 63, /* RFC 6225 */
108 SD_DHCP6_OPTION_AFTR_NAME = 64, /* RFC 6334 */
109 SD_DHCP6_OPTION_ERP_LOCAL_DOMAIN_NAME = 65, /* RFC 6440 */
110 SD_DHCP6_OPTION_RSOO = 66, /* RFC 6422 */
111 SD_DHCP6_OPTION_PD_EXCLUDE = 67, /* RFC 6603 */
112 SD_DHCP6_OPTION_VSS = 68, /* RFC 6607 */
113 SD_DHCP6_OPTION_MIP6_IDINF = 69, /* RFC 6610 */
114 SD_DHCP6_OPTION_MIP6_UDINF = 70, /* RFC 6610 */
115 SD_DHCP6_OPTION_MIP6_HNP = 71, /* RFC 6610 */
116 SD_DHCP6_OPTION_MIP6_HAA = 72, /* RFC 6610 */
117 SD_DHCP6_OPTION_MIP6_HAF = 73, /* RFC 6610 */
118 SD_DHCP6_OPTION_RDNSS_SELECTION = 74, /* RFC 6731 */
119 SD_DHCP6_OPTION_KRB_PRINCIPAL_NAME = 75, /* RFC 6784 */
120 SD_DHCP6_OPTION_KRB_REALM_NAME = 76, /* RFC 6784 */
121 SD_DHCP6_OPTION_KRB_DEFAULT_REALM_NAME = 77, /* RFC 6784 */
122 SD_DHCP6_OPTION_KRB_KDC = 78, /* RFC 6784 */
123 SD_DHCP6_OPTION_CLIENT_LINKLAYER_ADDR = 79, /* RFC 6939 */
124 SD_DHCP6_OPTION_LINK_ADDRESS = 80, /* RFC 6977 */
125 SD_DHCP6_OPTION_RADIUS = 81, /* RFC 7037 */
126 SD_DHCP6_OPTION_SOL_MAX_RT = 82, /* RFC 7083, RFC 8415 */
127 SD_DHCP6_OPTION_INF_MAX_RT = 83, /* RFC 7083, RFC 8415 */
128 SD_DHCP6_OPTION_ADDRSEL = 84, /* RFC 7078 */
129 SD_DHCP6_OPTION_ADDRSEL_TABLE = 85, /* RFC 7078 */
130 SD_DHCP6_OPTION_V6_PCP_SERVER = 86, /* RFC 7291 */
131 SD_DHCP6_OPTION_DHCPV4_MSG = 87, /* RFC 7341 */
132 SD_DHCP6_OPTION_DHCP4_O_DHCP6_SERVER = 88, /* RFC 7341 */
133 SD_DHCP6_OPTION_S46_RULE = 89, /* RFC 7598 */
134 SD_DHCP6_OPTION_S46_BR = 90, /* RFC 7598, RFC 8539 */
135 SD_DHCP6_OPTION_S46_DMR = 91, /* RFC 7598 */
136 SD_DHCP6_OPTION_S46_V4V6BIND = 92, /* RFC 7598 */
137 SD_DHCP6_OPTION_S46_PORTPARAMS = 93, /* RFC 7598 */
138 SD_DHCP6_OPTION_S46_CONT_MAPE = 94, /* RFC 7598 */
139 SD_DHCP6_OPTION_S46_CONT_MAPT = 95, /* RFC 7598 */
140 SD_DHCP6_OPTION_S46_CONT_LW = 96, /* RFC 7598 */
141 SD_DHCP6_OPTION_4RD = 97, /* RFC 7600 */
142 SD_DHCP6_OPTION_4RD_MAP_RULE = 98, /* RFC 7600 */
143 SD_DHCP6_OPTION_4RD_NON_MAP_RULE = 99, /* RFC 7600 */
144 SD_DHCP6_OPTION_LQ_BASE_TIME = 100, /* RFC 7653 */
145 SD_DHCP6_OPTION_LQ_START_TIME = 101, /* RFC 7653 */
146 SD_DHCP6_OPTION_LQ_END_TIME = 102, /* RFC 7653 */
147 SD_DHCP6_OPTION_CAPTIVE_PORTAL = 103, /* RFC 8910 */
148 SD_DHCP6_OPTION_MPL_PARAMETERS = 104, /* RFC 7774 */
149 SD_DHCP6_OPTION_ANI_ATT = 105, /* RFC 7839 */
150 SD_DHCP6_OPTION_ANI_NETWORK_NAME = 106, /* RFC 7839 */
151 SD_DHCP6_OPTION_ANI_AP_NAME = 107, /* RFC 7839 */
152 SD_DHCP6_OPTION_ANI_AP_BSSID = 108, /* RFC 7839 */
153 SD_DHCP6_OPTION_ANI_OPERATOR_ID = 109, /* RFC 7839 */
154 SD_DHCP6_OPTION_ANI_OPERATOR_REALM = 110, /* RFC 7839 */
155 SD_DHCP6_OPTION_S46_PRIORITY = 111, /* RFC 8026 */
156 SD_DHCP6_OPTION_MUD_URL_V6 = 112, /* RFC 8520 */
157 SD_DHCP6_OPTION_V6_PREFIX64 = 113, /* RFC 8115 */
158 SD_DHCP6_OPTION_F_BINDING_STATUS = 114, /* RFC 8156 */
159 SD_DHCP6_OPTION_F_CONNECT_FLAGS = 115, /* RFC 8156 */
160 SD_DHCP6_OPTION_F_DNS_REMOVAL_INFO = 116, /* RFC 8156 */
161 SD_DHCP6_OPTION_F_DNS_HOST_NAME = 117, /* RFC 8156 */
162 SD_DHCP6_OPTION_F_DNS_ZONE_NAME = 118, /* RFC 8156 */
163 SD_DHCP6_OPTION_F_DNS_FLAGS = 119, /* RFC 8156 */
164 SD_DHCP6_OPTION_F_EXPIRATION_TIME = 120, /* RFC 8156 */
165 SD_DHCP6_OPTION_F_MAX_UNACKED_BNDUPD = 121, /* RFC 8156 */
166 SD_DHCP6_OPTION_F_MCLT = 122, /* RFC 8156 */
167 SD_DHCP6_OPTION_F_PARTNER_LIFETIME = 123, /* RFC 8156 */
168 SD_DHCP6_OPTION_F_PARTNER_LIFETIME_SENT = 124, /* RFC 8156 */
169 SD_DHCP6_OPTION_F_PARTNER_DOWN_TIME = 125, /* RFC 8156 */
170 SD_DHCP6_OPTION_F_PARTNER_RAW_CLT_TIME = 126, /* RFC 8156 */
171 SD_DHCP6_OPTION_F_PROTOCOL_VERSION = 127, /* RFC 8156 */
172 SD_DHCP6_OPTION_F_KEEPALIVE_TIME = 128, /* RFC 8156 */
173 SD_DHCP6_OPTION_F_RECONFIGURE_DATA = 129, /* RFC 8156 */
174 SD_DHCP6_OPTION_F_RELATIONSHIP_NAME = 130, /* RFC 8156 */
175 SD_DHCP6_OPTION_F_SERVER_FLAGS = 131, /* RFC 8156 */
176 SD_DHCP6_OPTION_F_SERVER_STATE = 132, /* RFC 8156 */
177 SD_DHCP6_OPTION_F_START_TIME_OF_STATE = 133, /* RFC 8156 */
178 SD_DHCP6_OPTION_F_STATE_EXPIRATION_TIME = 134, /* RFC 8156 */
179 SD_DHCP6_OPTION_RELAY_PORT = 135, /* RFC 8357 */
180 SD_DHCP6_OPTION_V6_SZTP_REDIRECT = 136, /* RFC 8572 */
181 SD_DHCP6_OPTION_S46_BIND_IPV6_PREFIX = 137, /* RFC 8539 */
182 SD_DHCP6_OPTION_IA_LL = 138, /* RFC 8947 */
183 SD_DHCP6_OPTION_LLADDR = 139, /* RFC 8947 */
184 SD_DHCP6_OPTION_SLAP_QUAD = 140, /* RFC 8948 */
185 SD_DHCP6_OPTION_V6_DOTS_RI = 141, /* RFC 8973 */
186 SD_DHCP6_OPTION_V6_DOTS_ADDRESS = 142, /* RFC 8973 */
5476cb98 187 SD_DHCP6_OPTION_IPV6_ADDRESS_ANDSF = 143 /* RFC 6153 */
2c1ab8ca
BG
188 /* option codes 144-65535 are unassigned */
189};
190
139b011a
PF
191typedef struct sd_dhcp6_client sd_dhcp6_client;
192
4b558378
ZJS
193typedef void (*sd_dhcp6_client_callback_t)(sd_dhcp6_client *client, int event, void *userdata);
194int sd_dhcp6_client_set_callback(
195 sd_dhcp6_client *client,
196 sd_dhcp6_client_callback_t cb,
197 void *userdata);
198
2f8e7633 199int sd_dhcp6_client_set_ifindex(
4b558378
ZJS
200 sd_dhcp6_client *client,
201 int interface_index);
61a9fa8f
YW
202int sd_dhcp6_client_set_ifname(
203 sd_dhcp6_client *client,
204 const char *interface_name);
5977b71f 205int sd_dhcp6_client_get_ifname(sd_dhcp6_client *client, const char **ret);
4b558378
ZJS
206int sd_dhcp6_client_set_local_address(
207 sd_dhcp6_client *client,
208 const struct in6_addr *local_address);
209int sd_dhcp6_client_set_mac(
210 sd_dhcp6_client *client,
211 const uint8_t *addr,
212 size_t addr_len,
213 uint16_t arp_type);
214int sd_dhcp6_client_set_duid(
215 sd_dhcp6_client *client,
216 uint16_t duid_type,
f7a92d1a 217 const void *duid,
4b558378 218 size_t duid_len);
7e90a499
YW
219int sd_dhcp6_client_set_duid_llt(
220 sd_dhcp6_client *client,
221 uint64_t llt_time);
4b558378
ZJS
222int sd_dhcp6_client_set_iaid(
223 sd_dhcp6_client *client,
224 uint32_t iaid);
d69d4038
SS
225int sd_dhcp6_client_get_iaid(
226 sd_dhcp6_client *client,
227 uint32_t *iaid);
6b7d5b6e
SS
228int sd_dhcp6_client_duid_as_string(
229 sd_dhcp6_client *client,
230 char **duid);
8006aa32
SA
231int sd_dhcp6_client_set_fqdn(
232 sd_dhcp6_client *client,
233 const char *fqdn);
4b558378
ZJS
234int sd_dhcp6_client_set_information_request(
235 sd_dhcp6_client *client,
236 int enabled);
237int sd_dhcp6_client_get_information_request(
238 sd_dhcp6_client *client,
239 int *enabled);
240int sd_dhcp6_client_set_request_option(
241 sd_dhcp6_client *client,
242 uint16_t option);
de8d6e55
SS
243int sd_dhcp6_client_set_request_mud_url(
244 sd_dhcp6_client *client,
feb7d7a2 245 const char *mudurl);
33923925
SS
246int sd_dhcp6_client_set_request_user_class(
247 sd_dhcp6_client *client,
5a99444e 248 char * const *user_class);
73c8ced7
SS
249int sd_dhcp6_client_set_request_vendor_class(
250 sd_dhcp6_client *client,
019951ec 251 char * const *vendor_class);
2805536b
SS
252int sd_dhcp6_client_set_prefix_delegation_hint(
253 sd_dhcp6_client *client,
254 uint8_t prefixlen,
877bfc78 255 const struct in6_addr *pd_prefix);
d8c51121
PF
256int sd_dhcp6_client_get_prefix_delegation(sd_dhcp6_client *client,
257 int *delegation);
7c3de8f8 258int sd_dhcp6_client_set_prefix_delegation(sd_dhcp6_client *client,
d8c51121 259 int delegation);
f311a62b
PF
260int sd_dhcp6_client_get_address_request(sd_dhcp6_client *client,
261 int *request);
262int sd_dhcp6_client_set_address_request(sd_dhcp6_client *client,
263 int request);
99ccb8ff
SS
264int sd_dhcp6_client_add_vendor_option(sd_dhcp6_client *client,
265 sd_dhcp6_option *v);
4397967f 266int sd_dhcp6_client_set_rapid_commit(sd_dhcp6_client *client, int enable);
b895aa5f 267int sd_dhcp6_client_set_send_release(sd_dhcp6_client *client, int enable);
4b558378
ZJS
268
269int sd_dhcp6_client_get_lease(
270 sd_dhcp6_client *client,
271 sd_dhcp6_lease **ret);
ea3b3a75 272
e7d5fe17
AD
273int sd_dhcp6_client_add_option(sd_dhcp6_client *client, sd_dhcp6_option *v);
274
139b011a
PF
275int sd_dhcp6_client_stop(sd_dhcp6_client *client);
276int sd_dhcp6_client_start(sd_dhcp6_client *client);
f667c150 277int sd_dhcp6_client_is_running(sd_dhcp6_client *client);
4b558378
ZJS
278int sd_dhcp6_client_attach_event(
279 sd_dhcp6_client *client,
280 sd_event *event,
281 int64_t priority);
139b011a
PF
282int sd_dhcp6_client_detach_event(sd_dhcp6_client *client);
283sd_event *sd_dhcp6_client_get_event(sd_dhcp6_client *client);
793178b9 284int sd_dhcp6_client_attach_device(sd_dhcp6_client *client, sd_device *dev);
139b011a
PF
285sd_dhcp6_client *sd_dhcp6_client_ref(sd_dhcp6_client *client);
286sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client);
287int sd_dhcp6_client_new(sd_dhcp6_client **ret);
288
4afd3348
LP
289_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp6_client, sd_dhcp6_client_unref);
290
04c01369
LP
291_SD_END_DECLARATIONS;
292
139b011a 293#endif