From d23ddff97160ff5d1e9d7baff0ed360fa3b6a2d9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 21 Aug 2023 15:57:45 -0500 Subject: [PATCH] Add several constants needed to use multicast UDP This was verified by @todbot to work on esp32 s2 and s3; the constant should match any system that uses LWIP numbering. --- shared-bindings/socketpool/SocketPool.c | 6 ++++++ shared-bindings/socketpool/SocketPool.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index 3023721378..381291fbaf 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -82,6 +82,10 @@ MP_DEFINE_EXCEPTION(gaierror, OSError) //| TCP_NODELAY: int //| //| IPPROTO_TCP: int +//| IPPROTO_IP: int +//| +//| IP_MULTICAST_TTL: int +//| //| def socket(self, family: int = AF_INET, type: int = SOCK_STREAM) -> socketpool.Socket: //| """Create a new socket //| @@ -182,6 +186,8 @@ STATIC const mp_rom_map_elem_t socketpool_socketpool_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_TCP_NODELAY), MP_ROM_INT(SOCKETPOOL_TCP_NODELAY) }, { MP_ROM_QSTR(MP_QSTR_IPPROTO_TCP), MP_ROM_INT(SOCKETPOOL_IPPROTO_TCP) }, + { MP_ROM_QSTR(MP_QSTR_IPPROTO_IP), MP_ROM_INT(SOCKETPOOL_IPPROTO_IP) }, + { MP_ROM_QSTR(MP_QSTR_IP_MULTICAST_TTL), MP_ROM_INT(SOCKETPOOL_IP_MULTICAST_TTL) }, { MP_ROM_QSTR(MP_QSTR_EAI_NONAME), MP_ROM_INT(SOCKETPOOL_EAI_NONAME) }, }; diff --git a/shared-bindings/socketpool/SocketPool.h b/shared-bindings/socketpool/SocketPool.h index 6409f8c763..9e9d7fde4f 100644 --- a/shared-bindings/socketpool/SocketPool.h +++ b/shared-bindings/socketpool/SocketPool.h @@ -45,6 +45,7 @@ typedef enum { } socketpool_socketpool_addressfamily_t; typedef enum { + SOCKETPOOL_IPPROTO_IP = 0, SOCKETPOOL_IPPROTO_TCP = 6, } socketpool_socketpool_ipproto_t; @@ -52,6 +53,10 @@ typedef enum { SOCKETPOOL_TCP_NODELAY = 1, } socketpool_socketpool_tcpopt_t; +typedef enum { + SOCKETPOOL_IP_MULTICAST_TTL = 5, +} socketpool_socketpool_ipopt_t; + typedef enum { SOCKETPOOL_EAI_NONAME = -2, } socketpool_eai_t;