From: Jeremy Sowden <jeremy@azazel.net>
To: Netfilter Devel <netfilter-devel@vger.kernel.org>
Cc: Robert O'Brien <robrien@foxtrot-research.com>
Subject: [PATCH ulogd2 2/3] output: add missing support for int64_t values
Date: Sun, 27 Nov 2022 00:22:59 +0000 [thread overview]
Message-ID: <20221127002300.191936-3-jeremy@azazel.net> (raw)
In-Reply-To: <20221127002300.191936-1-jeremy@azazel.net>
Some of the output plug-ins don't handle 64-bit signed values.
Fix formatting of OPRINT switch.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
output/ulogd_output_GPRINT.c | 4 ++-
output/ulogd_output_JSON.c | 3 ++
output/ulogd_output_OPRINT.c | 55 +++++++++++++++++++-----------------
3 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/output/ulogd_output_GPRINT.c b/output/ulogd_output_GPRINT.c
index aedd08e980f7..eeeec6ac3eb0 100644
--- a/output/ulogd_output_GPRINT.c
+++ b/output/ulogd_output_GPRINT.c
@@ -127,13 +127,15 @@ static int gprint_interp(struct ulogd_pluginstance *upi)
case ULOGD_RET_INT8:
case ULOGD_RET_INT16:
case ULOGD_RET_INT32:
+ case ULOGD_RET_INT64:
ret = snprintf(buf+size, rem, "%s=", key->name);
if (ret < 0)
break;
rem -= ret;
size += ret;
- ret = snprintf(buf+size, rem, "%d,", key->u.value.i32);
+ ret = snprintf(buf+size, rem, "%" PRId64 ",",
+ key->u.value.i64);
if (ret < 0)
break;
rem -= ret;
diff --git a/output/ulogd_output_JSON.c b/output/ulogd_output_JSON.c
index bbc3dba5d41a..32d020ac657a 100644
--- a/output/ulogd_output_JSON.c
+++ b/output/ulogd_output_JSON.c
@@ -366,6 +366,9 @@ static int json_interp(struct ulogd_pluginstance *upi)
case ULOGD_RET_INT32:
json_object_set_new(msg, field_name, json_integer(key->u.value.i32));
break;
+ case ULOGD_RET_INT64:
+ json_object_set_new(msg, field_name, json_integer(key->u.value.i64));
+ break;
case ULOGD_RET_UINT8:
if ((upi->config_kset->ces[JSON_CONF_BOOLEAN_LABEL].u.value != 0)
&& (!strcmp(key->name, "raw.label"))) {
diff --git a/output/ulogd_output_OPRINT.c b/output/ulogd_output_OPRINT.c
index 6fde445ed1e4..8617203237c3 100644
--- a/output/ulogd_output_OPRINT.c
+++ b/output/ulogd_output_OPRINT.c
@@ -65,32 +65,35 @@ static int oprint_interp(struct ulogd_pluginstance *upi)
fprintf(opi->of,"%s=", ret->name);
switch (ret->type) {
- case ULOGD_RET_STRING:
- fprintf(opi->of, "%s\n",
- (char *) ret->u.value.ptr);
- break;
- case ULOGD_RET_BOOL:
- case ULOGD_RET_INT8:
- case ULOGD_RET_INT16:
- case ULOGD_RET_INT32:
- fprintf(opi->of, "%d\n", ret->u.value.i32);
- break;
- case ULOGD_RET_UINT8:
- case ULOGD_RET_UINT16:
- case ULOGD_RET_UINT32:
- fprintf(opi->of, "%u\n", ret->u.value.ui32);
- break;
- case ULOGD_RET_UINT64:
- fprintf(opi->of, "%" PRIu64 "\n", ret->u.value.ui64);
- break;
- case ULOGD_RET_IPADDR:
- fprintf(opi->of, "%u.%u.%u.%u\n",
- HIPQUAD(ret->u.value.ui32));
- break;
- case ULOGD_RET_NONE:
- fprintf(opi->of, "<none>\n");
- break;
- default: fprintf(opi->of, "default\n");
+ case ULOGD_RET_STRING:
+ fprintf(opi->of, "%s\n",
+ (char *) ret->u.value.ptr);
+ break;
+ case ULOGD_RET_BOOL:
+ case ULOGD_RET_INT8:
+ case ULOGD_RET_INT16:
+ case ULOGD_RET_INT32:
+ fprintf(opi->of, "%d\n", ret->u.value.i32);
+ break;
+ case ULOGD_RET_INT64:
+ fprintf(opi->of, "%" PRId64 "\n", ret->u.value.i64);
+ break;
+ case ULOGD_RET_UINT8:
+ case ULOGD_RET_UINT16:
+ case ULOGD_RET_UINT32:
+ fprintf(opi->of, "%u\n", ret->u.value.ui32);
+ break;
+ case ULOGD_RET_UINT64:
+ fprintf(opi->of, "%" PRIu64 "\n", ret->u.value.ui64);
+ break;
+ case ULOGD_RET_IPADDR:
+ fprintf(opi->of, "%u.%u.%u.%u\n",
+ HIPQUAD(ret->u.value.ui32));
+ break;
+ case ULOGD_RET_NONE:
+ fprintf(opi->of, "<none>\n");
+ break;
+ default: fprintf(opi->of, "default\n");
}
}
if (upi->config_kset->ces[1].u.value != 0)
--
2.35.1
next prev parent reply other threads:[~2022-11-27 0:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-27 0:22 [PATCH ulogd2 0/3] IP Address Formatting Fixes Jeremy Sowden
2022-11-27 0:22 ` [PATCH ulogd2 1/3] filter: IP2BIN: correct spelling of variable Jeremy Sowden
2022-12-08 21:45 ` Pablo Neira Ayuso
2022-11-27 0:22 ` Jeremy Sowden [this message]
2022-12-08 21:45 ` [PATCH ulogd2 2/3] output: add missing support for int64_t values Pablo Neira Ayuso
2022-11-27 0:23 ` [PATCH ulogd2 3/3] src: keep IPv4 addresses internally in IPv4-in-IPv6 format Jeremy Sowden
2022-12-08 21:45 ` Pablo Neira Ayuso
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=20221127002300.191936-3-jeremy@azazel.net \
--to=jeremy@azazel.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=robrien@foxtrot-research.com \
/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).