1# DHCPv4 implementation for Zephyr 2 3# Copyright (c) 2016 Intel Corporation. 4# Copyright (c) 2024 Nordic Semiconductor ASA 5# 6# SPDX-License-Identifier: Apache-2.0 7 8config NET_DHCPV4 9 bool "DHCPv4 client" 10 select NET_MGMT 11 select NET_MGMT_EVENT 12 select NET_MGMT_EVENT_INFO if NET_IPV4_ACD 13 depends on NET_IPV4 && NET_UDP 14 15if NET_DHCPV4 16 17module = NET_DHCPV4 18module-dep = NET_LOG 19module-str = Log level for DHCPv4 client 20module-help = Enable debug diagnostic from DHCPV4 client. 21source "subsys/net/Kconfig.template.log_config.net" 22 23config NET_DHCPV4_INITIAL_DELAY_MAX 24 int "Maximum time out for initial discover request" 25 depends on NET_DHCPV4 26 default 10 27 range 2 10 28 help 29 As per RFC2131 4.1.1, we wait a random period between 30 1 and 10 seconds before sending the initial discover. 31 32config NET_DHCPV4_OPTION_CALLBACKS 33 bool "Option callbacks" 34 depends on NET_DHCPV4 35 help 36 If set, custom callbacks for arbitrary DHCP options 37 can be added. These can be used to support otherwise 38 DHCP options not used by the rest of the system. 39 40config NET_DHCPV4_MAX_REQUESTED_OPTIONS 41 int "Maximum number of requested options" 42 depends on NET_DHCPV4 && NET_DHCPV4_OPTION_CALLBACKS 43 default 10 44 range 3 $(UINT8_MAX) 45 help 46 Maximum number of requested options that can be added to the 47 DHCPv4 request message. The options are added using the 48 net_dhcpv4_add_option_callback() API. 49 50config NET_DHCPV4_OPTION_CALLBACKS_VENDOR_SPECIFIC 51 bool "Encapsulated vendor specific option callbacks" 52 depends on NET_DHCPV4 53 select NET_DHCPV4_OPTION_CALLBACKS 54 help 55 If set, custom callbacks for encapsulated vendor-specific 56 information in DHCP option 43 can be added. 57 58config NET_DHCPV4_ACCEPT_UNICAST 59 bool "Accept unicast DHCPv4 traffic" 60 depends on NET_DHCPV4 61 default y 62 help 63 If set, the network stack will accept unicast DHCPv4 responses from 64 servers, before the assigned address is configured on the interface. 65 66config NET_DHCPV4_VENDOR_CLASS_IDENTIFIER 67 bool "Send vendor class identifier in DHCPv4 request" 68 depends on NET_DHCPV4 69 help 70 If set, the network stack will include the specified string in the 71 DHCPv4 vendor class identifier option in the DHCPv4 request. 72 73config NET_DHCPV4_VENDOR_CLASS_IDENTIFIER_STRING 74 string "Vendor class identifier" 75 depends on NET_DHCPV4_VENDOR_CLASS_IDENTIFIER 76 default "" 77 help 78 The string to include in the DHCPv4 vendor class identifier option 79 in the DHCPv4 request. 80 81config NET_DHCPV4_OPTION_NTP_SERVER 82 bool "Use NTP server from DHCPv4 option and save it in the net_if" 83 default y 84 depends on SNTP 85 help 86 If this option is set, then the NTP server can be set from the 87 DHCPv4 option. 88 89config NET_DHCPV4_OPTION_DNS_ADDRESS 90 bool "Use DNS server from DHCPv4 option and save it in the DNS resolver default context" 91 default y 92 depends on DNS_RESOLVER 93 help 94 If this option is set, then the DNS server can be set from the 95 DHCPv4 option. 96 97endif # NET_DHCPV4 98 99config NET_DHCPV4_SERVER 100 bool "DHCPv4 server" 101 depends on NET_IPV4 && NET_UDP 102 select NET_SOCKETS 103 select NET_SOCKETS_SERVICE 104 105if NET_DHCPV4_SERVER 106 107module = NET_DHCPV4_SERVER 108module-dep = NET_LOG 109module-str = Log level for DHCPv4 server 110module-help = Enables DHCPv4 server output debug messages 111source "subsys/net/Kconfig.template.log_config.net" 112 113config NET_DHCPV4_SERVER_INSTANCES 114 int "Maximum number of DHCPv4 server instances" 115 default 1 116 help 117 Maximum number of DHCPv4 server instances supported by the system. 118 Each network interface that wants to act as a DHCPv4 server requires 119 a separate instance. 120 121config NET_DHCPV4_SERVER_ADDR_COUNT 122 int "Number of IPv4 addresses that can be assigned by the server" 123 default 4 124 help 125 Maximum number of IPv4 addresses that can be assigned by the DHCPv4 126 server instance. The base IPv4 address in the address pool is provided 127 at runtime, during server initialization. Consecutive addresses in the 128 pool have the lowest address octet incremented. 129 130config NET_DHCPV4_SERVER_ADDR_LEASE_TIME 131 int "Lease time for IPv4 addresses assigned by the server (seconds)" 132 range 0 $(UINT32_MAX) 133 default 86400 134 help 135 Lease time in seconds for IPv4 addresses assigned by the server. 136 The lease time determines when the IPv4 address lease expires if the 137 client does not renew it. 138 139config NET_DHCPV4_SERVER_ADDR_DECLINE_TIME 140 int "The time IPv4 addresses remains blocked after conflict detection (seconds)" 141 range 0 $(UINT32_MAX) 142 default 86400 143 help 144 In case IPv4 address becomes blocked (either because of receiving 145 Decline message or due to ICMP probe detecting conflict), the address 146 can no longer be assigned. This timeout specifies how long the address 147 remains in the Declined state. 148 Note, that the server may try to reuse the oldest declined address in 149 case it runs out of free addresses to assign. 150 151config NET_DHCPV4_SERVER_ICMP_PROBE_TIMEOUT 152 int "Timeout for ICMP probes sent by the server (milliseconds)" 153 range 0 60000 154 default 1000 155 help 156 DHCPv4 server will probe the offered IP address (send ICMP echo 157 request) and wait for the time specific by this config before offering 158 the address. If set to 0, ICMP probing will be disabled. 159 160config NET_DHCPV4_SERVER_NAK_UNRECOGNIZED_REQUESTS 161 bool "Reply with NAK for DHCP Requests from clients we do not recognize" 162 default y 163 help 164 Zephyr's DHCPv4 server does not implement persistent storage of address 165 leases. As a result, all leases are lost on reboot, which can cause 166 delays with clients starting in INIT-REBOOT state and thus sending 167 (potentially several) Requests before attempting full Discover-Request 168 procedure. Enabling this config will violate the RFC in this regard, as 169 instead of staying silent for unrecognized Request messages, the server 170 will send a NAK, informing the client it should proceed with a full 171 procedure. 172 173config NET_DHCPV4_SERVER_OPTION_DNS_ADDRESS 174 string "DNS Server address" 175 default DNS_SERVER1 if DNS_SERVER_IP_ADDRESSES 176 default "" 177 help 178 This configuration option specifies the DNS server address that the DHCPv4 179 server should provide to clients when they request an IP address. The 180 DHCPv4 server adds this DNS server address in the DHCP offer and 181 acknowledgment messages sent to the clients, allowing them to use the 182 specified DNS server for name resolution. 183 184endif # NET_DHCPV4_SERVER 185