diff options
author | Jeremy Sowden <jeremy@azazel.net> | 2025-05-26 18:19:03 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2025-06-01 14:12:47 +0200 |
commit | f699ba550c9f009924d8f5f59a190254938f9bec (patch) | |
tree | 76fe196beb718881d6b7d16c64d86f47189a5260 /filter/ulogd_filter_IP2STR.c | |
parent | c0f9d1950e0968688558c2abbaa41cffd03f19de (diff) |
Use `NFPROTO_*` constants for protocol families
Netfilter has a set of `NFPROTO_*` constants for the protocol families that it
supports, in part because it supports protocols and pseudo-protocols that do not
have `PF_*` (and `AF_*`) constants. Currently, ulogd uses `AF_*` constants for
protocol families, because it does not support any families which do not have
`AF_*` constants. Switch to `NFPROTO_*` constants instead, so we can add ARP
support later.
In the IP2* filters, retain `AF_*` for address family variables.
Remove a stray semicolon.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'filter/ulogd_filter_IP2STR.c')
-rw-r--r-- | filter/ulogd_filter_IP2STR.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/filter/ulogd_filter_IP2STR.c b/filter/ulogd_filter_IP2STR.c index 194a8b1..3d4d6e9 100644 --- a/filter/ulogd_filter_IP2STR.c +++ b/filter/ulogd_filter_IP2STR.c @@ -25,6 +25,7 @@ #include <stdlib.h> #include <string.h> #include <arpa/inet.h> +#include <linux/netfilter.h> #include <ulogd/ulogd.h> #include <netinet/if_ether.h> @@ -170,14 +171,16 @@ static int interp_ip2str(struct ulogd_pluginstance *pi) proto_family = ikey_get_u8(&inp[KEY_OOB_FAMILY]); switch (proto_family) { - case AF_INET6: - case AF_INET: - addr_family = proto_family; + case NFPROTO_IPV6: + addr_family = AF_INET6; + break; + case NFPROTO_IPV4: + addr_family = AF_INET; break; - case AF_BRIDGE: + case NFPROTO_BRIDGE: if (!pp_is_valid(inp, KEY_OOB_PROTOCOL)) { ulogd_log(ULOGD_NOTICE, - "No protocol inside AF_BRIDGE packet\n"); + "No protocol inside NFPROTO_BRIDGE packet\n"); return ULOGD_IRET_ERR; } switch (ikey_get_u16(&inp[KEY_OOB_PROTOCOL])) { @@ -190,13 +193,13 @@ static int interp_ip2str(struct ulogd_pluginstance *pi) break; default: ulogd_log(ULOGD_NOTICE, - "Unknown protocol inside AF_BRIDGE packet\n"); + "Unexpected protocol inside NFPROTO_BRIDGE packet\n"); return ULOGD_IRET_ERR; } break; default: /* TODO error handling */ - ulogd_log(ULOGD_NOTICE, "Unknown protocol family\n"); + ulogd_log(ULOGD_NOTICE, "Unexpected protocol family\n"); return ULOGD_IRET_ERR; } |