Skip to content

Commit b73251d

Browse files
committed
feat(net): Enable IPv6 immediately if already connected
If the interface is already connected, try to enable IPv6 immediately. Otherwise the interface would need to go through disconnect/connect cycle for IPv6 to be enabled.
1 parent 4a6437d commit b73251d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

libraries/Network/src/NetworkInterface.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,15 @@ bool NetworkInterface::hasGlobalIPv6() const {
320320
bool NetworkInterface::enableIPv6(bool en) {
321321
if (en) {
322322
setStatusBits(ESP_NETIF_WANT_IP6_BIT);
323+
if (_esp_netif != NULL && connected()) {
324+
// If we are already connected, try to enable IPv6 immediately
325+
esp_err_t err = esp_netif_create_ip6_linklocal(_esp_netif);
326+
if (err != ESP_OK) {
327+
log_e("Failed to enable IPv6 Link Local on %s: [%d] %s", desc(), err, esp_err_to_name(err));
328+
} else {
329+
log_v("Enabled IPv6 Link Local on %s", desc());
330+
}
331+
}
323332
} else {
324333
clearStatusBits(ESP_NETIF_WANT_IP6_BIT);
325334
}

0 commit comments

Comments
 (0)