1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 /*** 5 Copyright © 2014-2015 Intel Corporation. All rights reserved. 6 ***/ 7 8 #include <net/ethernet.h> 9 #include <netinet/in.h> 10 11 #include "sd-event.h" 12 #include "sd-dhcp6-client.h" 13 14 #include "dhcp-identifier.h" 15 #include "dhcp6-option.h" 16 #include "dhcp6-protocol.h" 17 #include "ether-addr-util.h" 18 #include "hashmap.h" 19 #include "macro.h" 20 #include "network-common.h" 21 #include "ordered-set.h" 22 #include "sparse-endian.h" 23 #include "time-util.h" 24 25 /* what to request from the server, addresses (IA_NA) and/or prefixes (IA_PD) */ 26 typedef enum DHCP6RequestIA { 27 DHCP6_REQUEST_IA_NA = 1 << 0, 28 DHCP6_REQUEST_IA_TA = 1 << 1, /* currently not used */ 29 DHCP6_REQUEST_IA_PD = 1 << 2, 30 } DHCP6RequestIA; 31 32 struct sd_dhcp6_client { 33 unsigned n_ref; 34 35 int ifindex; 36 char *ifname; 37 38 struct in6_addr local_address; 39 struct hw_addr_data hw_addr; 40 uint16_t arp_type; 41 42 sd_event *event; 43 sd_event_source *receive_message; 44 sd_event_source *timeout_resend; 45 sd_event_source *timeout_expire; 46 sd_event_source *timeout_t1; 47 sd_event_source *timeout_t2; 48 int event_priority; 49 int fd; 50 51 DHCP6State state; 52 bool information_request; 53 usec_t information_request_time_usec; 54 usec_t information_refresh_time_usec; 55 be32_t transaction_id; 56 usec_t transaction_start; 57 usec_t retransmit_time; 58 uint8_t retransmit_count; 59 60 bool iaid_set; 61 DHCP6IA ia_na; 62 DHCP6IA ia_pd; 63 DHCP6RequestIA request_ia; 64 struct duid duid; 65 size_t duid_len; 66 be16_t *req_opts; 67 size_t n_req_opts; 68 char *fqdn; 69 char *mudurl; 70 char **user_class; 71 char **vendor_class; 72 OrderedHashmap *extra_options; 73 OrderedSet *vendor_options; 74 75 struct sd_dhcp6_lease *lease; 76 77 sd_dhcp6_client_callback_t callback; 78 void *userdata; 79 80 /* Ignore ifindex when generating iaid. See dhcp_identifier_set_iaid(). */ 81 bool test_mode; 82 }; 83 84 int dhcp6_network_bind_udp_socket(int ifindex, struct in6_addr *address); 85 int dhcp6_network_send_udp_socket(int s, struct in6_addr *address, 86 const void *packet, size_t len); 87 88 int dhcp6_client_send_message(sd_dhcp6_client *client); 89 void dhcp6_client_set_test_mode(sd_dhcp6_client *client, bool test_mode); 90 int dhcp6_client_set_transaction_id(sd_dhcp6_client *client, uint32_t transaction_id); 91 92 #define log_dhcp6_client_errno(client, error, fmt, ...) \ 93 log_interface_prefix_full_errno( \ 94 "DHCPv6 client: ", \ 95 sd_dhcp6_client, client, \ 96 error, fmt, ##__VA_ARGS__) 97 #define log_dhcp6_client(client, fmt, ...) \ 98 log_interface_prefix_full_errno_zerook( \ 99 "DHCPv6 client: ", \ 100 sd_dhcp6_client, client, \ 101 0, fmt, ##__VA_ARGS__) 102