git: 11bc53984b1f - main - libsysdecode: add attribute parsing for PFNL_CMD_GETRULES

Kristof Provost <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src,gmane.os.freebsd.current.scm
Message-ID <[email protected]>
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=11bc53984b1ffd298978b5c48188a010fb34572b

commit 11bc53984b1ffd298978b5c48188a010fb34572b
Author:     Ishan Agrawal <[email protected]>
AuthorDate: 2026-08-08 05:55:56 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2026-08-10 14:33:32 +0000

    libsysdecode: add attribute parsing for PFNL_CMD_GETRULES
    
    Signed-off-by:  Ishan Agrawal <[email protected]>
    Sponsored-by:   Google LLC (GSoC 2026)
    Reviewed by:    kp
---
 lib/libsysdecode/netlink.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/libsysdecode/netlink.c b/lib/libsysdecode/netlink.c
index b8c657b1b4e1..344822f18fcb 100644
--- a/lib/libsysdecode/netlink.c
+++ b/lib/libsysdecode/netlink.c
@@ -237,6 +237,15 @@ nl_decode_attrs_raw(FILE *fp, const struct nlattr *nla_head, size_t len,
 	fprintf(fp, "}");
 }
 
+static const struct nlattr_decoder nla_d_getrules[] = {
+	{ .type = PF_GR_ANCHOR, .attr_name = "anchor", .cb = nlattr_decode_string },
+	{ .type = PF_GR_ACTION, .attr_name = "action", .cb = nlattr_decode_uint8 },
+	{ .type = PF_GR_NR, .attr_name = "nr", .cb = nlattr_decode_uint32 },
+	{ .type = PF_GR_TICKET, .attr_name = "ticket", .cb = nlattr_decode_uint32 },
+	{ .type = PF_GR_CLEAR, .attr_name = "clear", .cb = nlattr_decode_uint8 },
+};
+NL_DECLARE_ATTR_DECODER(getrules_decoder, nla_d_getrules);
+
 static const struct nlattr_decoder nla_d_set_limit[] = {
 	{ .type = PF_LI_INDEX, .attr_name = "index", .cb = nlattr_decode_uint32 },
 	{ .type = PF_LI_LIMIT, .attr_name = "limit", .cb = nlattr_decode_uint32 },
@@ -313,6 +322,10 @@ sysdecode_netlink_pf(FILE *fp, const struct genlmsghdr *genl, size_t nlm_len)
 	    ((const char *)genl + sizeof(struct genlmsghdr));
 
 	switch (cmd) {
+	case PFNL_CMD_GETRULES:
+			nl_decode_attrs_raw(fp, nla, nlm_len,
+			    getrules_decoder.decoders, getrules_decoder.count);
+		break;
 	case PFNL_CMD_GET_LIMIT:
 			nl_decode_attrs_raw(fp, nla, nlm_len,
 			    set_limit_decoder.decoders, set_limit_decoder.count);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.