From e652e5d777809ce2ee82ce01c1299c96c71117a0 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Fri, 22 Jan 2021 00:14:43 +1000 Subject: [PATCH] * use just unsigned char buffer instead struct in_addr/in6_addr types --- src/ipaddr.c | 4 ++-- src/ipaddr.h | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ipaddr.c b/src/ipaddr.c index 7b202a5..45fa6c2 100644 --- a/src/ipaddr.c +++ b/src/ipaddr.c @@ -17,11 +17,11 @@ f2b_ipaddr_create(const char *addr) { strlcpy(a->text, addr, sizeof(a->text)); if (strchr(addr, ':') == NULL) { a->type = AF_INET; - if (inet_pton(a->type, addr, &a->binary.v4) < 1) + if (inet_pton(a->type, addr, &a->binary) < 1) goto cleanup; } else { a->type = AF_INET6; - if (inet_pton(a->type, addr, &a->binary.v6) < 1) + if (inet_pton(a->type, addr, &a->binary) < 1) goto cleanup; } } diff --git a/src/ipaddr.h b/src/ipaddr.h index 8420e2a..88f4323 100644 --- a/src/ipaddr.h +++ b/src/ipaddr.h @@ -34,10 +34,7 @@ typedef struct f2b_ipaddr_t { time_t lastseen; /**< self-descriptive, unixtime */ time_t banned_at; /**< self-descriptive, unixtime */ time_t release_at; /**< self-descriptive, unixtime */ - union { - struct in_addr v4; /**< AF_INET address */ - struct in6_addr v6; /**< AF_INET6 address */ - } binary; /**< binary address representation, see @a type */ + unsigned char binary[16]; /**< AF_INET/AF_INET6 binary address, see inet_pton() */ f2b_matches_t matches; /**< list of matches */ } f2b_ipaddr_t;