summaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
Diffstat (limited to 'filter')
-rw-r--r--filter/raw2packet/ulogd_raw2packet_BASE.c15
-rw-r--r--filter/ulogd_filter_IP2BIN.c33
-rw-r--r--filter/ulogd_filter_IP2HBIN.c9
3 files changed, 15 insertions, 42 deletions
diff --git a/filter/raw2packet/ulogd_raw2packet_BASE.c b/filter/raw2packet/ulogd_raw2packet_BASE.c
index 9117d27..09e9313 100644
--- a/filter/raw2packet/ulogd_raw2packet_BASE.c
+++ b/filter/raw2packet/ulogd_raw2packet_BASE.c
@@ -645,7 +645,7 @@ static int _interp_icmp(struct ulogd_pluginstance *pi, struct icmphdr *icmph,
break;
case ICMP_REDIRECT:
case ICMP_PARAMETERPROB:
- okey_set_u32(&ret[KEY_ICMP_GATEWAY], ntohl(icmph->un.gateway));
+ okey_set_u32(&ret[KEY_ICMP_GATEWAY], icmph->un.gateway);
break;
case ICMP_DEST_UNREACH:
if (icmph->code == ICMP_FRAG_NEEDED) {
@@ -896,18 +896,23 @@ static int _interp_arp(struct ulogd_pluginstance *pi, uint32_t len)
struct ulogd_key *ret = pi->output.keys;
const struct ether_arp *arph =
ikey_get_ptr(&pi->input.keys[INKEY_RAW_PCKT]);
+ uint32_t arp_spa, arp_tpa;
if (len < sizeof(struct ether_arp))
return ULOGD_IRET_OK;
- okey_set_u16(&ret[KEY_ARP_HTYPE], ntohs(arph->arp_hrd));
- okey_set_u16(&ret[KEY_ARP_PTYPE], ntohs(arph->arp_pro));
+ okey_set_u16(&ret[KEY_ARP_HTYPE], ntohs(arph->arp_hrd));
+ okey_set_u16(&ret[KEY_ARP_PTYPE], ntohs(arph->arp_pro));
okey_set_u16(&ret[KEY_ARP_OPCODE], ntohs(arph->arp_op));
okey_set_ptr(&ret[KEY_ARP_SHA], (void *)&arph->arp_sha);
- okey_set_ptr(&ret[KEY_ARP_SPA], (void *)&arph->arp_spa);
okey_set_ptr(&ret[KEY_ARP_THA], (void *)&arph->arp_tha);
- okey_set_ptr(&ret[KEY_ARP_TPA], (void *)&arph->arp_tpa);
+
+ memcpy(&arp_spa, arph->arp_spa, sizeof(arp_spa));
+ memcpy(&arp_tpa, arph->arp_tpa, sizeof(arp_tpa));
+
+ okey_set_u32(&ret[KEY_ARP_SPA], arp_spa);
+ okey_set_u32(&ret[KEY_ARP_TPA], arp_tpa);
return ULOGD_IRET_OK;
}
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;
}
diff --git a/filter/ulogd_filter_IP2HBIN.c b/filter/ulogd_filter_IP2HBIN.c
index 2711f9c..081616e 100644
--- a/filter/ulogd_filter_IP2HBIN.c
+++ b/filter/ulogd_filter_IP2HBIN.c
@@ -157,15 +157,14 @@ static int interp_ip2hbin(struct ulogd_pluginstance *pi)
if (pp_is_valid(inp, i)) {
switch (convfamily) {
case AF_INET:
- okey_set_u32(&ret[i-START_KEY],
- ntohl(ikey_get_u32(&inp[i])));
+ okey_set_u32(&ret[i - START_KEY],
+ ntohl(ikey_get_u32(&inp[i])));
break;
case AF_INET6:
- okey_set_ptr(&ret[i-START_KEY],
- (struct in6_addr *)ikey_get_u128(&inp[i]));
+ okey_set_u128(&ret[i - START_KEY],
+ ikey_get_u128(&inp[i]));
break;
default:
- ;
break;
}
}