]> granicus.if.org Git - strace/commitdiff
netlink: add basic decoding of NETLINK_ROUTE ndtmsg attributes
authorJingPiao Chen <chenjingpiao@gmail.com>
Tue, 15 Aug 2017 04:41:15 +0000 (12:41 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 15 Aug 2017 22:34:46 +0000 (22:34 +0000)
* rtnl_neightbl.c: Include "nlattr.h" and "xlat/rtnl_neightbl_attrs.h".
(decode_ndtmsg): Call decode_nlattr.
* xlat/rtnl_neightbl_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
rtnl_neightbl.c
xlat/rtnl_neightbl_attrs.in [new file with mode: 0644]

index ef0b138f14c39466daad5ebff0f2d735e39e530b..41f8c92bacbccac29755de987d395ac885c057f3 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "defs.h"
 #include "netlink_route.h"
+#include "nlattr.h"
 #include "print_fields.h"
 
 #include "netlink.h"
 # include <linux/neighbour.h>
 #endif
 
+#include "xlat/rtnl_neightbl_attrs.h"
+
 DECL_NETLINK_ROUTE_DECODER(decode_ndtmsg)
 {
        struct ndtmsg ndtmsg = { .ndtm_family = family };
 
        PRINT_FIELD_XVAL("{", ndtmsg, ndtm_family, addrfams, "AF_???");
        tprints("}");
+
+       const size_t offset = NLMSG_ALIGN(sizeof(ndtmsg));
+       if (len > offset) {
+               tprints(", ");
+               decode_nlattr(tcp, addr + offset, len - offset,
+                             rtnl_neightbl_attrs, "NDTA_???", NULL, 0, NULL);
+       }
 }
diff --git a/xlat/rtnl_neightbl_attrs.in b/xlat/rtnl_neightbl_attrs.in
new file mode 100644 (file)
index 0000000..ea840f6
--- /dev/null
@@ -0,0 +1,10 @@
+NDTA_UNSPEC            0
+NDTA_NAME              1
+NDTA_THRESH1           2
+NDTA_THRESH2           3
+NDTA_THRESH3           4
+NDTA_CONFIG            5
+NDTA_PARMS             6
+NDTA_STATS             7
+NDTA_GC_INTERVAL       8
+NDTA_PAD               9