Skip to content

Add stateless auto configuration for IPv4 #9877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/library/network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ parameter should be `id`.
server via DHCP. This method does not block and wait for an address
to be obtained. To check if an address was obtained, use the read-only
property ``has_dhcp4``.
* ``autoconf4`` (``True/False``) obtain an IPv4 address randomly in the
169.254.0.0/16 address space. This method does not block and wait for
an address to be selected and confirmed to be unused on the network. To
check if an address has been selected, use the read-only property
``has_autoconf4``.
* ``gw4`` Get/set the IPv4 default-gateway.
* ``dhcp6`` (``True/False``) obtain a DNS server via stateless DHCPv6.
Obtaining IP Addresses via DHCPv6 is currently not implemented.
Expand Down
17 changes: 17 additions & 0 deletions extmod/network_lwip.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include "lwip/netif.h"
#include "lwip/timeouts.h"
#include "lwip/autoip.h"
#include "lwip/dns.h"
#include "lwip/dhcp.h"
#include "lwip/nd6.h"
Expand Down Expand Up @@ -191,6 +192,11 @@ mp_obj_t mod_network_nic_ipconfig(struct netif *netif, size_t n_args, const mp_o
case MP_QSTR_has_dhcp4: {
return mp_obj_new_bool(dhcp_supplied_address(netif));
}
#if LWIP_AUTOIP
case MP_QSTR_has_autoconf4: {
return mp_obj_new_bool(autoip_supplied_address(netif));
}
#endif
#if LWIP_IPV6_DHCP6
case MP_QSTR_dhcp6: {
struct dhcp6 *dhcp = netif_dhcp6_data(netif);
Expand Down Expand Up @@ -268,13 +274,24 @@ mp_obj_t mod_network_nic_ipconfig(struct netif *netif, size_t n_args, const mp_o
dhcp_renew(netif);
} else {
dhcp_release_and_stop(netif);
#if LWIP_AUTOIP
if (autoip_supplied_address(netif)) {
autoip_stop(netif);
}
#endif
dhcp_start(netif);
}
} else {
dhcp_release_and_stop(netif);
}
break;
}
#if LWIP_AUTOIP
case MP_QSTR_autoconf4: {
dhcp_release_and_stop(netif);
autoip_start(netif);
}
#endif
#if LWIP_IPV6_DHCP6
case MP_QSTR_dhcp6: {
dhcp6_disable(netif);
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy