-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
There are already various bugs tracking adding IPv6 to the various ports:
- ESP32: IPv6 Support in micropython for ESP32 (or anything for that matter) #3683, ports/esp32: Add initial support for IPV6. #11111
- RP2: Ipv6 support for cyw43/rp2 #9108
- Other: support various address families in uasyncio open_connection #7563
- Maybe more...?
But, even with these changes, there are some critical missing parts: the APIs. For example, <netif>.ifconfig()
returns a tuple of the IPv4 address configuration. However, there is no API to get the IPv6 addresses of the device, and it looks like such a thing isn't even defined yet.
So I wanted to open this issue to discuss potential API additions to help make IPv6 a first-class citizen in micropython.
Specifically, we need the ability to:
- List the current IPv6 addresses assigned to an interface, along with the status of each address
- Statically configure IPv6 addresses, along with adding the associated on-link routes
- Turn on/off SLAAC (if support is compiled in)
- Turn on/off DHCPv6 (if support is compiled in)
- Set a preference for IPv6 vs IPv4 when performing name lookups that have both A and AAAA records.
We currently don't have any way to do any of this from Micropython, so I think we should at least start to define what this should look like.
For compatibility reasons, I think we should avoid extending the ifconfig()
method. Lots of code seems pretty dependent on how this method works. I was thinking something like this as a starting point:
<netif>.MAX_IPV6_ADDRS
- constant describing the maximum number of IPv6 addresses that can be assigned to this interface. (Compile-time default seems to be 3)<netif>.v6_addrs()
- Returns a list of tuples, one tuple per address. Each tuple would have the following fields:- IPv6 Address (as a string?)
- Flags (Temporary, Deprecated, SLAAC, DHCPv6, Static, on-link, etc)
- remaining preferred lifetime (or
None
) - remaining valid lifetime (or
None
)
<netif>.v6_del_addr(<addr>)
- Removes the given IPv6 address.<netif>.v6_add_addr(<addr>, <prefix-len>)
- Adds the given IPv6 address, optionally adding a route for other on-link devices with the same prefix.<netif>.config('host-lookup-pref', <'v6'|'v4'>)
- Configures the host lookup preference when there are both A and AAAA records.<netif>.config('slaac_en', <True|False>)
- Turns on or off SLAAC.<netif>.config('dhcpv6_en', <True|False>)
- Turns on or off DHCPv6.
I'm sure this could be improved upon, but wanted to go ahead and put this out there as a starting point.
Thoughts?