From 729d724cae4022786a707bf029188a1737e55595 Mon Sep 17 00:00:00 2001 From: Logan Gunthorpe Date: Mon, 18 Nov 2019 16:58:04 -0700 Subject: [PATCH] dhcp: Set hostname for DISCOVER packets If the hostname is not set in the DISCOVER packet, then some servers might issue an OFFER with hostname configured and consequently reject the REQUEST with any other hostname. Signed-off-by: Logan Gunthorpe Ref IDF-4817 --- src/core/ipv4/dhcp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/ipv4/dhcp.c b/src/core/ipv4/dhcp.c index d6f62c2f..79f9676c 100644 --- a/src/core/ipv4/dhcp.c +++ b/src/core/ipv4/dhcp.c @@ -1033,6 +1033,10 @@ dhcp_discover(struct netif *netif) options_out_len = dhcp_option(options_out_len, msg_out->options, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); options_out_len = dhcp_option_short(options_out_len, msg_out->options, DHCP_MAX_MSG_LEN(netif)); +#if LWIP_NETIF_HOSTNAME && ESP_LWIP + options_out_len = dhcp_option_hostname(options_out_len, msg_out->options, netif); +#endif /* LWIP NETIF HOSTNAME && ESP_LWIP */ + options_out_len = dhcp_option(options_out_len, msg_out->options, DHCP_OPTION_PARAMETER_REQUEST_LIST, LWIP_ARRAYSIZE(dhcp_discover_request_options)); for (i = 0; i < LWIP_ARRAYSIZE(dhcp_discover_request_options); i++) { options_out_len = dhcp_option_byte(options_out_len, msg_out->options, dhcp_discover_request_options[i]);