From 223b58bc70ee68b15a66c34048bf5087ef053603 Mon Sep 17 00:00:00 2001 From: Guilherme Ricioli Date: Tue, 16 Apr 2024 10:50:48 -0300 Subject: [PATCH] Request hostname through DHCP If hostname is provided, request it to local DNS through DHCP. --- connectivity/lwipstack/source/LWIPInterface.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/connectivity/lwipstack/source/LWIPInterface.cpp b/connectivity/lwipstack/source/LWIPInterface.cpp index a1cfcf31c41e..35b4cfeb48a8 100644 --- a/connectivity/lwipstack/source/LWIPInterface.cpp +++ b/connectivity/lwipstack/source/LWIPInterface.cpp @@ -433,6 +433,7 @@ LWIP::Interface::Interface() : nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardNetworkStack::Interface **interface_out, NetworkInterface *user_network_interface) { #if LWIP_ETHERNET + const char *hostname; Interface *interface = new (std::nothrow) Interface(); if (!interface) { return NSAPI_ERROR_NO_MEMORY; @@ -441,6 +442,11 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN interface->memory_manager = &memory_manager; interface->ppp_enabled = false; + hostname = user_network_interface->get_hostname(); + if (hostname) { + netif_set_hostname(&interface->netif, hostname); + } + #if (MBED_MAC_ADDRESS_SUM != MBED_MAC_ADDR_INTERFACE) netif->interface.hwaddr[0] = MBED_MAC_ADDR_0; netif->interface.hwaddr[1] = MBED_MAC_ADDR_1;