Skip to content

Commit 21a5c93

Browse files
committed
IPv6: improvments based on review notes
* don't enable ipv6 by default due to privacy concerns * move list of board support for ipv6 to socketpool documentation * removed wifi.supports_ipvx properties * throw an exception when start_dhcp_client(ipv6=True) but not supported
1 parent aa82a3e commit 21a5c93

File tree

7 files changed

+28
-36
lines changed

7 files changed

+28
-36
lines changed

docs/shared_bindings_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"sys": "CIRCUITPY_SYS",
8686
"terminalio": "CIRCUITPY_DISPLAYIO",
8787
"usb": "CIRCUITPY_PYUSB",
88-
"wifi.supports_ipv6": "CIRCUITPY_SOCKETPOOL_IPV6",
88+
"socketpool.socketpool.AF_INET6": "CIRCUITPY_SOCKETPOOL_IPV6",
8989
}
9090

9191
MODULES_NOT_IN_BINDINGS = ["binascii", "errno", "json", "re", "ulab"]

ports/espressif/common-hal/wifi/Radio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,10 @@ void common_hal_wifi_radio_start_dhcp_client(wifi_radio_obj_t *self, bool ipv4,
551551
} else {
552552
dhcp6_disable(esp_netif_get_netif_impl(self->netif));
553553
}
554+
#else
555+
if (ipv6) {
556+
mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_ipv6);
557+
}
554558
#endif
555559
}
556560

ports/espressif/common-hal/wifi/__init__.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ void common_hal_wifi_init(bool user_initiated) {
136136
if (wifi_inited) {
137137
if (user_initiated && !wifi_user_initiated) {
138138
common_hal_wifi_radio_set_enabled(self, true);
139-
// explicitly start dhcp
140-
common_hal_wifi_radio_start_dhcp_client(self, true, true);
141139
}
142140
return;
143141
}
@@ -203,8 +201,6 @@ void common_hal_wifi_init(bool user_initiated) {
203201
common_hal_wifi_radio_start_station(self);
204202
// start wifi
205203
common_hal_wifi_radio_set_enabled(self, true);
206-
// explicitly start dhcp
207-
common_hal_wifi_radio_start_dhcp_client(self, true, true);
208204
}
209205

210206
void wifi_user_reset(void) {

ports/raspberrypi/common-hal/wifi/Radio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ void common_hal_wifi_radio_start_dhcp_client(wifi_radio_obj_t *self, bool ipv4,
412412
} else {
413413
dhcp_stop(NETIF_STA);
414414
}
415+
if (ipv6) {
416+
mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_ipv6);
417+
}
415418
}
416419

417420
void common_hal_wifi_radio_stop_dhcp_client(wifi_radio_obj_t *self) {

shared-bindings/socketpool/__init__.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818
//|
1919
//| For more information about the `socket` module, see the CPython documentation:
2020
//| https://docs.python.org/3/library/socket.html
21+
//|
22+
//| .. jinja
23+
//|
24+
//| .. raw:: html
25+
//|
26+
//| <p>
27+
//| <details>
28+
//| <summary>AF_INET6 (IPv6) supported on these boards</summary>
29+
//| <ul>
30+
//| {% for board in support_matrix_reverse["socketpool.socketpool.AF_INET6"] %}
31+
//| <li> {{ board }}
32+
//| {% endfor %}
33+
//| </ul>
34+
//| </details>
35+
//| </p>
2136
//| """
2237

2338
static const mp_rom_map_elem_t socketpool_globals_table[] = {

shared-bindings/wifi/Radio.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -693,19 +693,19 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_stations_ap_obj, wifi_radio_get_station
693693
MP_PROPERTY_GETTER(wifi_radio_stations_ap_obj,
694694
(mp_obj_t)&wifi_radio_get_stations_ap_obj);
695695

696-
//| def start_dhcp(self, *, ipv4: bool = supports_ipv4, ipv6: bool = supports_ipv6) -> None:
696+
//| def start_dhcp(self, *, ipv4: bool = True, ipv6: bool = False) -> None:
697697
//| """Starts the station DHCP client.
698698
//|
699-
//| By default, calling this function starts all supported types of DHCP.
700-
//| If the ``ipv4`` and ``ipv6`` arguments are specified as `False` then
701-
//| the corresponding DHCP client is stopped if it was active.
699+
//| By default, calling this function starts DHCP for IPv4 networks but not
700+
//| IPv6 networks. When the the ``ipv4`` and ``ipv6`` arguments are `False`
701+
//| then the corresponding DHCP client is stopped if it was active.
702702
//| """
703703
//| ...
704704
static mp_obj_t wifi_radio_start_dhcp_client(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
705705
enum { ARG_ipv4, ARG_ipv6 };
706706
static const mp_arg_t allowed_args[] = {
707707
{ MP_QSTR_ipv4, MP_ARG_KW_ONLY | MP_ARG_BOOL, { .u_bool = MP_ROM_TRUE } },
708-
{ MP_QSTR_ipv6, MP_ARG_KW_ONLY | MP_ARG_BOOL, { .u_bool = CIRCUITPY_SOCKETPOOL_IPV6 ? MP_ROM_TRUE : MP_ROM_FALSE } },
708+
{ MP_QSTR_ipv6, MP_ARG_KW_ONLY | MP_ARG_BOOL, { .u_bool = MP_ROM_FALSE } },
709709
};
710710

711711
wifi_radio_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);

shared-bindings/wifi/__init__.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,8 @@
1414
//| """
1515
//| The `wifi` module provides necessary low-level functionality for managing
1616
//| wifi connections. Use `socketpool` for communicating over the network.
17-
//|
18-
//| .. jinja
1917
//| """
2018

21-
//| supports_ipv6: bool
22-
//| """``True`` when ipv6 is supported. Read-only
23-
//|
24-
//| .. raw:: html
25-
//|
26-
//| <p>
27-
//| <details>
28-
//| <summary>True on these boards</summary>
29-
//| <ul>
30-
//| {% for board in support_matrix_reverse["wifi.supports_ipv6"] %}
31-
//| <li> {{ board }}
32-
//| {% endfor %}
33-
//| </ul>
34-
//| </details>
35-
//| </p>
36-
//|
37-
//| """
38-
39-
//| supports_ipv4: bool
40-
//| """``True`` when ipv4 is supported. Read-only"""
41-
4219
//| radio: Radio
4320
//| """Wifi radio used to manage both station and AP modes.
4421
//| This object is the sole instance of `wifi.Radio`."""
@@ -67,9 +44,6 @@ static const mp_rom_map_elem_t wifi_module_globals_table[] = {
6744

6845
// Properties
6946
{ MP_ROM_QSTR(MP_QSTR_radio), MP_ROM_PTR(&common_hal_wifi_radio_obj) },
70-
71-
{ MP_ROM_QSTR(MP_QSTR_supports_ipv6), MP_ROM_PTR(CIRCUITPY_SOCKETPOOL_IPV6 ? MP_ROM_TRUE : MP_ROM_FALSE) },
72-
{ MP_ROM_QSTR(MP_QSTR_supports_ipv4), MP_ROM_TRUE },
7347
};
7448
static MP_DEFINE_CONST_DICT(wifi_module_globals, wifi_module_globals_table);
7549

0 commit comments

Comments
 (0)