summaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
authorJeremy Sowden <jeremy@azazel.net>2023-08-21 20:42:37 +0100
committerFlorian Westphal <fw@strlen.de>2023-09-14 14:22:49 +0200
commit9aa04788a317f0bc34050cd07ee81d66fda4cc8c (patch)
tree160c28717cf7779a254e8731bfa6e199d4a717ae /filter
parent083d56967d3940a3a29d11c881d1b78e6033c24f (diff)
db: insert ipv6 addresses in the same format as ip2binHEADmaster
Move a `ULOGD_RET_BOOL` case for consistency. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'filter')
-rw-r--r--filter/ulogd_filter_IP2BIN.c33
1 files changed, 1 insertions, 32 deletions
diff --git a/filter/ulogd_filter_IP2BIN.c b/filter/ulogd_filter_IP2BIN.c
index 74e4683..7f7bea5 100644
--- a/filter/ulogd_filter_IP2BIN.c
+++ b/filter/ulogd_filter_IP2BIN.c
@@ -116,27 +116,12 @@ static struct ulogd_key ip2bin_keys[] = {
static char ipbin_array[MAX_KEY - START_KEY + 1][IPADDR_LENGTH];
-/**
- * Convert IPv4 address (as 32-bit unsigned integer) to IPv6 address:
- * add 96 bits prefix "::ffff:" to get IPv6 address "::ffff:a.b.c.d".
- */
-static inline void uint32_to_ipv6(const uint32_t ipv4, struct in6_addr *ipv6)
-{
- ipv6->s6_addr32[0] = 0x00000000;
- ipv6->s6_addr32[1] = 0x00000000;
- ipv6->s6_addr32[2] = htonl(0xffff);
- ipv6->s6_addr32[3] = ipv4;
-}
-
static int ip2bin(struct ulogd_key *inp, int index, int oindex)
{
char family = ikey_get_u8(&inp[KEY_OOB_FAMILY]);
char convfamily = family;
- unsigned char *addr8;
struct in6_addr *addr;
struct in6_addr ip4_addr;
- char *buffer;
- int i, written;
if (family == AF_BRIDGE) {
if (!pp_is_valid(inp, KEY_OOB_PROTOCOL)) {
@@ -176,23 +161,7 @@ static int ip2bin(struct ulogd_key *inp, int index, int oindex)
return ULOGD_IRET_ERR;
}
- buffer = ipbin_array[oindex];
- /* format IPv6 to BINARY(16) as "0x..." */
- buffer[0] = '0';
- buffer[1] = 'x';
- buffer += 2;
- addr8 = &addr->s6_addr[0];
- for (i = 0; i < 4; i++) {
- written = sprintf(buffer, "%02x%02x%02x%02x",
- addr8[0], addr8[1], addr8[2], addr8[3]);
- if (written != 2 * 4) {
- buffer[0] = 0;
- return ULOGD_IRET_ERR;
- }
- buffer += written;
- addr8 += 4;
- }
- buffer[0] = 0;
+ format_ipv6(ipbin_array[oindex], IPADDR_LENGTH, addr);
return ULOGD_IRET_OK;
}