Skip to content

Commit

Permalink
feat(net): Enable IPv6 immediately if already connected (espressif#9948)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
me-no-dev authored Jul 1, 2024
1 parent 337058a commit fef3c73
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libraries/Network/src/NetworkInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,15 @@ bool NetworkInterface::hasGlobalIPv6() const {
bool NetworkInterface::enableIPv6(bool en) {
if (en) {
setStatusBits(ESP_NETIF_WANT_IP6_BIT);
if (_esp_netif != NULL && connected()) {
// If we are already connected, try to enable IPv6 immediately
esp_err_t err = esp_netif_create_ip6_linklocal(_esp_netif);
if (err != ESP_OK) {
log_e("Failed to enable IPv6 Link Local on %s: [%d] %s", desc(), err, esp_err_to_name(err));
} else {
log_v("Enabled IPv6 Link Local on %s", desc());
}
}
} else {
clearStatusBits(ESP_NETIF_WANT_IP6_BIT);
}
Expand Down

0 comments on commit fef3c73

Please sign in to comment.