1 /* 2 * Copyright (c) 2023 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** @file 8 * @brief DHCPv6 client 9 */ 10 11 #ifndef ZEPHYR_INCLUDE_NET_DHCPV6_H_ 12 #define ZEPHYR_INCLUDE_NET_DHCPV6_H_ 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 /** 19 * @brief DHCPv6 20 * @defgroup dhcpv6 DHCPv6 21 * @ingroup networking 22 * @{ 23 */ 24 25 /** @cond INTERNAL_HIDDEN */ 26 27 /** Current state of DHCPv6 client address/prefix negotiation. */ 28 enum net_dhcpv6_state { 29 NET_DHCPV6_DISABLED, 30 NET_DHCPV6_INIT, 31 NET_DHCPV6_SOLICITING, 32 NET_DHCPV6_REQUESTING, 33 NET_DHCPV6_CONFIRMING, 34 NET_DHCPV6_RENEWING, 35 NET_DHCPV6_REBINDING, 36 NET_DHCPV6_INFO_REQUESTING, 37 NET_DHCPV6_BOUND, 38 } __packed; 39 40 #define DHCPV6_TID_SIZE 3 41 #define DHCPV6_DUID_MAX_SIZE 20 42 43 struct net_dhcpv6_duid_raw { 44 uint16_t type; 45 uint8_t buf[DHCPV6_DUID_MAX_SIZE]; 46 } __packed; 47 48 struct net_dhcpv6_duid_storage { 49 struct net_dhcpv6_duid_raw duid; 50 uint8_t length; 51 }; 52 53 struct net_if; 54 55 /** @endcond */ 56 57 /** @brief DHCPv6 client configuration parameters. */ 58 struct net_dhcpv6_params { 59 bool request_addr : 1; /**< Request IPv6 address. */ 60 bool request_prefix : 1; /**< Request IPv6 prefix. */ 61 }; 62 63 /** 64 * @brief Start DHCPv6 client on an iface 65 * 66 * @details Start DHCPv6 client on a given interface. DHCPv6 client will start 67 * negotiation for IPv6 address and/or prefix, depending on the configuration. 68 * Once the negotiation is complete, IPv6 address/prefix details will be added 69 * to the interface. 70 * 71 * @param iface A valid pointer to a network interface 72 * @param params DHCPv6 client configuration parameters. 73 */ 74 void net_dhcpv6_start(struct net_if *iface, struct net_dhcpv6_params *params); 75 76 /** 77 * @brief Stop DHCPv6 client on an iface 78 * 79 * @details Stop DHCPv6 client on a given interface. DHCPv6 client 80 * will remove all configuration obtained from a DHCP server from the 81 * interface and stop any further negotiation with the server. 82 * 83 * @param iface A valid pointer to a network interface 84 */ 85 void net_dhcpv6_stop(struct net_if *iface); 86 87 /** 88 * @brief Restart DHCPv6 client on an iface 89 * 90 * @details Restart DHCPv6 client on a given interface. DHCPv6 client 91 * will restart the state machine without any of the initial delays. 92 * 93 * @param iface A valid pointer to a network interface 94 */ 95 void net_dhcpv6_restart(struct net_if *iface); 96 97 /** @cond INTERNAL_HIDDEN */ 98 99 /** 100 * @brief DHCPv6 state name 101 * 102 * @internal 103 */ 104 const char *net_dhcpv6_state_name(enum net_dhcpv6_state state); 105 106 /** @endcond */ 107 108 /** 109 * @} 110 */ 111 112 #ifdef __cplusplus 113 } 114 #endif 115 116 #endif /* ZEPHYR_INCLUDE_NET_DHCPV6_H_ */ 117