Add v6 address support to SocketPool.getaddrinfo (on espressif) · csamuelson/circuitpython@eaa6f99 · GitHub
Skip to content

Commit eaa6f99

Browse files
committed
Add v6 address support to SocketPool.getaddrinfo (on espressif)
1 parent 2f62612 commit eaa6f99

5 files changed

Lines changed: 122 additions & 18 deletions

File tree

ports/espressif/common-hal/socketpool/SocketPool.c

Lines changed: 103 additions & 18 deletions

ports/espressif/mpconfigport.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ CIRCUITPY_SYNTHIO_MAX_CHANNELS ?= 12
4949
CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1
5050
CIRCUITPY_WATCHDOG ?= 1
5151
CIRCUITPY_WIFI ?= 1
52+
CIRCUITPY_SOCKETPOOL_IPV6 ?= 1
5253

5354
# Enable _eve module
5455
CIRCUITPY__EVE ?= 1

py/circuitpy_mpconfig.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,9 @@ CFLAGS += -DCIRCUITPY_SKIP_SAFE_MODE_WAIT=$(CIRCUITPY_SKIP_SAFE_MODE_WAIT)
496496
CIRCUITPY_SOCKETPOOL ?= $(CIRCUITPY_WIFI)
497497
CFLAGS += -DCIRCUITPY_SOCKETPOOL=$(CIRCUITPY_SOCKETPOOL)
498498

499+
CIRCUITPY_SOCKETPOOL_IPV6 ?= 0
500+
CFLAGS += -DCIRCUITPY_SOCKETPOOL_IPV6=$(CIRCUITPY_SOCKETPOOL_IPV6)
501+
499502
CIRCUITPY_SSL ?= $(CIRCUITPY_WIFI)
500503
CFLAGS += -DCIRCUITPY_SSL=$(CIRCUITPY_SSL)
501504

shared-bindings/socketpool/SocketPool.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ static mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t
142142
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
143143
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
144144

145+
#if CIRCUITPY_SOCKETPOOL_IPV6
146+
return common_hal_socketpool_getaddrinfo_raise(
147+
self,
148+
mp_obj_str_get_str(args[ARG_host].u_obj),
149+
args[ARG_port].u_int,
150+
args[ARG_family].u_int,
151+
args[ARG_type].u_int,
152+
args[ARG_proto].u_int,
153+
args[ARG_flags].u_int);
154+
#else
145155
const char *host = mp_obj_str_get_str(args[ARG_host].u_obj);
146156
mp_int_t port = args[ARG_port].u_int;
147157
mp_obj_t ip_str = mp_const_none;
@@ -164,6 +174,7 @@ static mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t
164174
sockaddr->items[1] = MP_OBJ_NEW_SMALL_INT(port);
165175
tuple->items[4] = MP_OBJ_FROM_PTR(sockaddr);
166176
return mp_obj_new_list(1, (mp_obj_t *)&tuple);
177+
#endif
167178
}
168179
static MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_getaddrinfo_obj, 1, socketpool_socketpool_getaddrinfo);
169180

shared-bindings/socketpool/SocketPool.h

Lines changed: 4 additions & 0 deletions

0 commit comments

Comments
 (0)