From 46e2c5226ac1c65dcc88c44ef1135ccf5723b3b1 Mon Sep 17 00:00:00 2001 From: JingPiao Chen Date: Tue, 15 Aug 2017 12:41:15 +0800 Subject: [PATCH] netlink: add basic decoding of NETLINK_ROUTE ndtmsg attributes * 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 --- rtnl_neightbl.c | 10 ++++++++++ xlat/rtnl_neightbl_attrs.in | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 xlat/rtnl_neightbl_attrs.in diff --git a/rtnl_neightbl.c b/rtnl_neightbl.c index ef0b138f..41f8c92b 100644 --- a/rtnl_neightbl.c +++ b/rtnl_neightbl.c @@ -29,6 +29,7 @@ #include "defs.h" #include "netlink_route.h" +#include "nlattr.h" #include "print_fields.h" #include "netlink.h" @@ -37,10 +38,19 @@ # include #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 index 00000000..ea840f66 --- /dev/null +++ b/xlat/rtnl_neightbl_attrs.in @@ -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