Browse Source

* use just unsigned char buffer instead struct in_addr/in6_addr types

master
Alex 'AdUser' Z 4 years ago
parent
commit
e652e5d777
  1. 4
      src/ipaddr.c
  2. 5
      src/ipaddr.h

4
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;
}
}

5
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;

Loading…
Cancel
Save