summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJeremy Sowden <jeremy@azazel.net>2023-08-21 20:42:27 +0100
committerFlorian Westphal <fw@strlen.de>2023-09-14 14:22:49 +0200
commitc2692b0fe414df398f310c38c0261c7e98066f93 (patch)
treef7156c97dc0ff8e927e58db200f9c1175cc1a442 /include
parentacd1194c65a769054a4458fd2750967ec14c8160 (diff)
src: record length of integer key values
Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'include')
-rw-r--r--include/ulogd/ulogd.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/include/ulogd/ulogd.h b/include/ulogd/ulogd.h
index 092d9f5..cb01740 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))