Skip to content

Commit b7b1491

Browse files
net_iface: dhcpv4: use dhcp restart
switch to dhcp_restart, when a dhcp lease is already in place, thus forcing zephyr to ask dhcp server for a renewal of the lease
1 parent 392efa6 commit b7b1491

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

libraries/SocketWrapper/SocketHelpers.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
LOG_MODULE_DECLARE(sketch, LOG_LEVEL_NONE);
1111

1212
int NetworkInterface::dhcp() {
13-
net_dhcpv4_start(netif);
13+
// If dhcp was never started on this interface, start it, otherwise restart it, so that we force
14+
// to ask the dhcp server for a new lease
15+
if (netif->config.dhcpv4.state == NET_DHCPV4_DISABLED) {
16+
net_dhcpv4_start(netif);
17+
} else {
18+
net_dhcpv4_restart(netif);
19+
}
1420

1521
LOG_INF("DHCPv4 started...\n");
1622

loader/llext_exports.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ FORCE_EXPORT_SYM(net_mgmt_NET_REQUEST_ETHERNET_SET_MAC_ADDRESS);
160160

161161
#if defined(CONFIG_NET_DHCPV4)
162162
FORCE_EXPORT_SYM(net_dhcpv4_start);
163+
FORCE_EXPORT_SYM(net_dhcpv4_restart);
164+
FORCE_EXPORT_SYM(net_dhcpv4_stop);
163165
#if defined(CONFIG_NET_DHCPV4_OPTION_CALLBACKS)
164166
FORCE_EXPORT_SYM(net_dhcpv4_add_option_callback);
165167
#endif

0 commit comments

Comments
 (0)