From: Duncan Roe <duncan_roe@optusnet.com.au>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH libnetfilter_log 2/2] utils: nfulnl_test: Add rather extensive test of nflog_get_packet_hw()
Date: Tue, 21 Sep 2021 18:53:15 +1000 [thread overview]
Message-ID: <20210921085315.4340-3-duncan_roe@optusnet.com.au> (raw)
In-Reply-To: <20210921085315.4340-1-duncan_roe@optusnet.com.au>
Wasn't expecting length in NBO, so code caters for it being either way
Signed-off-by: Duncan Roe <duncan_roe@optusnet.com.au>
---
utils/nfulnl_test.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/utils/nfulnl_test.c b/utils/nfulnl_test.c
index 237adc3..a07c100 100644
--- a/utils/nfulnl_test.c
+++ b/utils/nfulnl_test.c
@@ -15,6 +15,31 @@ static int print_pkt(struct nflog_data *nfad)
char *prefix = nflog_get_prefix(nfad);
char *payload;
int payload_len = nflog_get_payload(nfad, &payload);
+ struct nfulnl_msg_packet_hw *hw = nflog_get_packet_hw(nfad);
+
+ if (!hw)
+ puts("No struct nfulnl_msg_packet_hw returned");
+ else {
+ char *p = "";
+ int i;
+
+ if (hw->hw_addrlen > sizeof hw->hw_addr) {
+ i = htons(hw->hw_addrlen);
+ if (i <= sizeof hw->hw_addr) {
+ hw->hw_addrlen = i;
+ p = " (after htons)";
+ }
+ }
+ printf("hw_addrlen = %d%s\n", hw->hw_addrlen, p);
+ if (i && i <= sizeof hw->hw_addr) {
+ uint8_t *u = hw->hw_addr;
+
+ fputs("HW addr: ", stdout);
+ for (i--; i >=0; i--, u++)
+ printf("%02x%s", *u, i ? ":" : "");
+ puts("");
+ }
+ }
if (ph) {
printf("hw_protocol=0x%04x hook=%u ",
--
2.17.5
next prev parent reply other threads:[~2021-09-21 8:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-21 8:53 [PATCH libnetfilter_log 0/2] utils: nfulnl_test: Test nflog_get_packet_hw Duncan Roe
2021-09-21 8:53 ` [PATCH libnetfilter_log 1/2] utils: nfulnl_test: Agree with man pages Duncan Roe
2021-09-28 10:50 ` Pablo Neira Ayuso
2021-09-21 8:53 ` Duncan Roe [this message]
2021-09-28 10:50 ` [PATCH libnetfilter_log 2/2] utils: nfulnl_test: Add rather extensive test of nflog_get_packet_hw() 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=20210921085315.4340-3-duncan_roe@optusnet.com.au \
--to=duncan_roe@optusnet.com.au \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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).