Skip to content

Commit

Permalink
Request hostname through DHCP
Browse files Browse the repository at this point in the history
If hostname is provided, request it to local DNS through DHCP.
  • Loading branch information
guilhermerc committed Sep 18, 2024
1 parent 2347ded commit 223b58b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions connectivity/lwipstack/source/LWIPInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 223b58b

Please sign in to comment.