From: Jeremy Sowden <jeremy@azazel.net>
To: Netfilter Devel <netfilter-devel@vger.kernel.org>
Subject: [PATCH ulogd2 v3 01/11] src: record length of integer key values
Date: Mon, 21 Aug 2023 20:42:27 +0100	[thread overview]
Message-ID: <20230821194237.51139-2-jeremy@azazel.net> (raw)
In-Reply-To: <20230821194237.51139-1-jeremy@azazel.net>
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
 include/ulogd/ulogd.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/ulogd/ulogd.h b/include/ulogd/ulogd.h
index 092d9f521a70..cb0174042235 100644
--- a/include/ulogd/ulogd.h
+++ b/include/ulogd/ulogd.h
@@ -134,36 +134,42 @@ static inline void okey_set_b(struct ulogd_key *key, uint8_t value)
 {
 	key->u.value.b = value;
 	key->flags |= ULOGD_RETF_VALID;
+	key->len = sizeof(key->u.value.b);
 }
 
 static inline void okey_set_u8(struct ulogd_key *key, uint8_t value)
 {
 	key->u.value.ui8 = value;
 	key->flags |= ULOGD_RETF_VALID;
+	key->len = sizeof(key->u.value.ui8);
 }
 
 static inline void okey_set_u16(struct ulogd_key *key, uint16_t value)
 {
 	key->u.value.ui16 = value;
 	key->flags |= ULOGD_RETF_VALID;
+	key->len = sizeof(key->u.value.ui16);
 }
 
 static inline void okey_set_u32(struct ulogd_key *key, uint32_t value)
 {
 	key->u.value.ui32 = value;
 	key->flags |= ULOGD_RETF_VALID;
+	key->len = sizeof(key->u.value.ui32);
 }
 
 static inline void okey_set_u64(struct ulogd_key *key, uint64_t value)
 {
 	key->u.value.ui64 = value;
 	key->flags |= ULOGD_RETF_VALID;
+	key->len = sizeof(key->u.value.ui64);
 }
 
 static inline void okey_set_u128(struct ulogd_key *key, const void *value)
 {
-	memcpy(key->u.value.ui128, value, 16);
+	memcpy(key->u.value.ui128, value, sizeof(key->u.value.ui128));
 	key->flags |= ULOGD_RETF_VALID;
+	key->len = sizeof(key->u.value.ui128);
 }
 
 static inline void okey_set_ptr(struct ulogd_key *key, void *value)
@@ -309,6 +315,7 @@ void __ulogd_log(int level, char *file, int line, const char *message, ...)
 #define SET_NEEDED(x)	(x.flags |= ULOGD_RETF_NEEDED)
 
 #define GET_FLAGS(res, x)	(res[x].u.source->flags)
+#define GET_LENGTH(res, x)	(res[x].u.source->len)
 #define pp_is_valid(res, x)	\
 	(res[x].u.source && (GET_FLAGS(res, x) & ULOGD_RETF_VALID))
 
-- 
2.40.1
next prev parent reply	other threads:[~2023-08-21 19:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-21 19:42 [PATCH ulogd2 v3 00/11] Fixes for handling and output of IP addresses Jeremy Sowden
2023-08-21 19:42 ` Jeremy Sowden [this message]
2023-08-21 19:42 ` [PATCH ulogd2 v3 02/11] printpkt: fix statement punctuator Jeremy Sowden
2023-08-21 19:42 ` [PATCH ulogd2 v3 03/11] printpkt, raw2packet_BASE: keep gateway address in NBO Jeremy Sowden
2023-08-21 19:42 ` [PATCH ulogd2 v3 04/11] raw2packet_BASE: store ARP address values as integers Jeremy Sowden
2023-08-21 19:42 ` [PATCH ulogd2 v3 05/11] ip2hbin: store ipv6 address as integer Jeremy Sowden
2023-08-21 19:42 ` [PATCH ulogd2 v3 06/11] ipfix: skip non-ipv4 addresses Jeremy Sowden
2023-08-21 19:42 ` [PATCH ulogd2 v3 07/11] gprint, oprint: use inet_ntop to format ip addresses Jeremy Sowden
2023-08-21 19:42 ` [PATCH ulogd2 v3 08/11] gprint, oprint: add support for printing ipv6 addresses Jeremy Sowden
2023-08-21 19:42 ` [PATCH ulogd2 v3 09/11] sqlite3: correct binding of ipv4 addresses and 64-bit integers Jeremy Sowden
2023-08-21 19:42 ` [PATCH ulogd2 v3 10/11] sqlite3: insert ipv6 addresses as null rather than garbage Jeremy Sowden
2023-08-21 19:42 ` [PATCH ulogd2 v3 11/11] db: insert ipv6 addresses in the same format as ip2bin Jeremy Sowden
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=20230821194237.51139-2-jeremy@azazel.net \
    --to=jeremy@azazel.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).