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