From 7eec4b6c8881bec2a237ef146fb7ba048ea5fc66 Mon Sep 17 00:00:00 2001 From: Floris Bos Date: Fri, 17 Feb 2017 15:36:48 +0100 Subject: [PATCH] Add basic IPv6 support Add IPv6 support to daemon and python library. IPv6 was already supported by the C client library. Currently there is no support for whitelisting IPv6 client addresses implemented, so for now it reverts to listening to IPv4 only when the -n option is specified. Signed-off-by: Floris Bos --- pigpio.c | 75 +++++++++++++++++++++++++++++++++++++++---------------- pigpio.py | 16 +++++------- 2 files changed, 60 insertions(+), 31 deletions(-) diff --git a/pigpio.c b/pigpio.c index 3bacc20..570a8a2 100644 --- a/pigpio.c +++ b/pigpio.c @@ -6972,12 +6972,18 @@ static void *pthSocketThreadHandler(void *fdC) return 0; } -static int addrAllowed(uint32_t addr) +static int addrAllowed(struct sockaddr *saddr) { int i; + uint32_t addr; if (!numSockNetAddr) return 1; + // FIXME: add IPv6 whitelisting support + if (saddr->sa_family != AF_INET) return 0; + + addr = ((struct sockaddr_in *) saddr)->sin_addr.s_addr; + for (i=0; i