1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #ifndef foosddhcp6clienthfoo 3 #define foosddhcp6clienthfoo 4 5 /*** 6 Copyright © 2014 Intel Corporation. All rights reserved. 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 19 along with systemd; If not, see <http://www.gnu.org/licenses/>. 20 ***/ 21 22 #include <inttypes.h> 23 #include <net/ethernet.h> 24 #include <sys/types.h> 25 26 #include "sd-dhcp6-lease.h" 27 #include "sd-dhcp6-option.h" 28 #include "sd-event.h" 29 30 #include "_sd-common.h" 31 32 _SD_BEGIN_DECLARATIONS; 33 34 enum { 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, 39 SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST = 13, 40 }; 41 42 /* https://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xhtml#dhcpv6-parameters-2 */ 43 enum { 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 */ 53 /* option code 10 is unassigned */ 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 */ 66 SD_DHCP6_OPTION_DNS_SERVER = 23, /* RFC 3646 */ 67 SD_DHCP6_OPTION_DOMAIN = 24, /* RFC 3646 */ 68 SD_DHCP6_OPTION_IA_PD = 25, /* RFC 3633, RFC 8415 */ 69 SD_DHCP6_OPTION_IA_PD_PREFIX = 26, /* RFC 3633, RFC 8415 */ 70 SD_DHCP6_OPTION_NIS_SERVER = 27, /* RFC 3898 */ 71 SD_DHCP6_OPTION_NISP_SERVER = 28, /* RFC 3898 */ 72 SD_DHCP6_OPTION_NIS_DOMAIN_NAME = 29, /* RFC 3898 */ 73 SD_DHCP6_OPTION_NISP_DOMAIN_NAME = 30, /* RFC 3898 */ 74 SD_DHCP6_OPTION_SNTP_SERVER = 31, /* RFC 4075, deprecated */ 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 */ 78 /* option code 35 is unassigned */ 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 */ 84 SD_DHCP6_OPTION_POSIX_TIMEZONE = 41, /* RFC 4833 */ 85 SD_DHCP6_OPTION_TZDB_TIMEZONE = 42, /* RFC 4833 */ 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 */ 99 SD_DHCP6_OPTION_NTP_SERVER = 56, /* RFC 5908 */ 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 */ 186 SD_DHCP6_OPTION_IPV6_ADDRESS_ANDSF = 143, /* RFC 6153 */ 187 /* option codes 144-65535 are unassigned */ 188 }; 189 190 typedef struct sd_dhcp6_client sd_dhcp6_client; 191 192 typedef void (*sd_dhcp6_client_callback_t)(sd_dhcp6_client *client, int event, void *userdata); 193 int sd_dhcp6_client_set_callback( 194 sd_dhcp6_client *client, 195 sd_dhcp6_client_callback_t cb, 196 void *userdata); 197 198 int sd_dhcp6_client_set_ifindex( 199 sd_dhcp6_client *client, 200 int interface_index); 201 int sd_dhcp6_client_set_ifname( 202 sd_dhcp6_client *client, 203 const char *interface_name); 204 int sd_dhcp6_client_get_ifname(sd_dhcp6_client *client, const char **ret); 205 int sd_dhcp6_client_set_local_address( 206 sd_dhcp6_client *client, 207 const struct in6_addr *local_address); 208 int 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); 213 int sd_dhcp6_client_set_duid( 214 sd_dhcp6_client *client, 215 uint16_t duid_type, 216 const void *duid, 217 size_t duid_len); 218 int sd_dhcp6_client_set_duid_llt( 219 sd_dhcp6_client *client, 220 uint64_t llt_time); 221 int sd_dhcp6_client_set_iaid( 222 sd_dhcp6_client *client, 223 uint32_t iaid); 224 int sd_dhcp6_client_get_iaid( 225 sd_dhcp6_client *client, 226 uint32_t *iaid); 227 int sd_dhcp6_client_duid_as_string( 228 sd_dhcp6_client *client, 229 char **duid); 230 int sd_dhcp6_client_set_fqdn( 231 sd_dhcp6_client *client, 232 const char *fqdn); 233 int sd_dhcp6_client_set_information_request( 234 sd_dhcp6_client *client, 235 int enabled); 236 int sd_dhcp6_client_get_information_request( 237 sd_dhcp6_client *client, 238 int *enabled); 239 int sd_dhcp6_client_set_request_option( 240 sd_dhcp6_client *client, 241 uint16_t option); 242 int sd_dhcp6_client_set_request_mud_url( 243 sd_dhcp6_client *client, 244 const char *mudurl); 245 int sd_dhcp6_client_set_request_user_class( 246 sd_dhcp6_client *client, 247 char * const *user_class); 248 int sd_dhcp6_client_set_request_vendor_class( 249 sd_dhcp6_client *client, 250 char * const *vendor_class); 251 int sd_dhcp6_client_set_prefix_delegation_hint( 252 sd_dhcp6_client *client, 253 uint8_t prefixlen, 254 const struct in6_addr *pd_prefix); 255 int sd_dhcp6_client_get_prefix_delegation(sd_dhcp6_client *client, 256 int *delegation); 257 int sd_dhcp6_client_set_prefix_delegation(sd_dhcp6_client *client, 258 int delegation); 259 int sd_dhcp6_client_get_address_request(sd_dhcp6_client *client, 260 int *request); 261 int sd_dhcp6_client_set_address_request(sd_dhcp6_client *client, 262 int request); 263 int sd_dhcp6_client_add_vendor_option(sd_dhcp6_client *client, 264 sd_dhcp6_option *v); 265 266 int sd_dhcp6_client_get_lease( 267 sd_dhcp6_client *client, 268 sd_dhcp6_lease **ret); 269 270 int sd_dhcp6_client_add_option(sd_dhcp6_client *client, sd_dhcp6_option *v); 271 272 int sd_dhcp6_client_stop(sd_dhcp6_client *client); 273 int sd_dhcp6_client_start(sd_dhcp6_client *client); 274 int sd_dhcp6_client_is_running(sd_dhcp6_client *client); 275 int sd_dhcp6_client_attach_event( 276 sd_dhcp6_client *client, 277 sd_event *event, 278 int64_t priority); 279 int sd_dhcp6_client_detach_event(sd_dhcp6_client *client); 280 sd_event *sd_dhcp6_client_get_event(sd_dhcp6_client *client); 281 sd_dhcp6_client *sd_dhcp6_client_ref(sd_dhcp6_client *client); 282 sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client); 283 int sd_dhcp6_client_new(sd_dhcp6_client **ret); 284 285 _SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp6_client, sd_dhcp6_client_unref); 286 287 _SD_END_DECLARATIONS; 288 289 #endif 290