Skip to content

Commit 4598357

Browse files
committed
Request hostname through DHCP
If hostname is provided, request it to local DNS through DHCP.
1 parent 4a3065b commit 4598357

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

connectivity/lwipstack/source/LWIPInterface.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ LWIP::Interface::Interface() :
433433
nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardNetworkStack::Interface **interface_out, NetworkInterface *user_network_interface)
434434
{
435435
#if LWIP_ETHERNET
436+
const char *hostname;
436437
Interface *interface = new (std::nothrow) Interface();
437438
if (!interface) {
438439
return NSAPI_ERROR_NO_MEMORY;
@@ -441,6 +442,11 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN
441442
interface->memory_manager = &memory_manager;
442443
interface->ppp_enabled = false;
443444

445+
hostname = user_network_interface->get_hostname();
446+
if(hostname) {
447+
netif_set_hostname(&interface->netif, hostname);
448+
}
449+
444450
#if (MBED_MAC_ADDRESS_SUM != MBED_MAC_ADDR_INTERFACE)
445451
netif->interface.hwaddr[0] = MBED_MAC_ADDR_0;
446452
netif->interface.hwaddr[1] = MBED_MAC_ADDR_1;

0 commit comments

Comments
 (0)