diff options
author | Jeremy Sowden <jeremy@azazel.net> | 2023-08-21 20:42:37 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2023-09-14 14:22:49 +0200 |
commit | 9aa04788a317f0bc34050cd07ee81d66fda4cc8c (patch) | |
tree | 160c28717cf7779a254e8731bfa6e199d4a717ae /util/db.c | |
parent | 083d56967d3940a3a29d11c881d1b78e6033c24f (diff) |
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 'util/db.c')
-rw-r--r-- | util/db.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -344,6 +344,9 @@ static void __format_query_db(struct ulogd_pluginstance *upi, char *start) } switch (res->type) { + case ULOGD_RET_BOOL: + sprintf(stmt_ins, "'%d',", res->u.value.b); + break; case ULOGD_RET_INT8: sprintf(stmt_ins, "%d,", res->u.value.i8); break; @@ -363,16 +366,24 @@ static void __format_query_db(struct ulogd_pluginstance *upi, char *start) sprintf(stmt_ins, "%u,", res->u.value.ui16); break; case ULOGD_RET_IPADDR: - /* fallthrough when logging IP as uint32_t */ + if (res->len == sizeof(struct in_addr)) + sprintf(stmt_ins, "%u,", res->u.value.ui32); + else { + struct in6_addr ipv6; + char addrbuf[2 + sizeof(ipv6) * 2 + 1]; + + memcpy(ipv6.s6_addr, res->u.value.ui128, + sizeof(ipv6.s6_addr)); + format_ipv6(addrbuf, sizeof(addrbuf), &ipv6); + sprintf(stmt_ins, "%s,", addrbuf); + } + break; case ULOGD_RET_UINT32: sprintf(stmt_ins, "%u,", res->u.value.ui32); break; case ULOGD_RET_UINT64: sprintf(stmt_ins, "%" PRIu64 ",", res->u.value.ui64); break; - case ULOGD_RET_BOOL: - sprintf(stmt_ins, "'%d',", res->u.value.b); - break; case ULOGD_RET_STRING: *(stmt_ins++) = '\''; if (res->u.value.ptr) { |