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 <fabien.siron@epita.fr>
This commit is contained in:
JingPiao Chen 2017-08-15 12:41:15 +08:00 committed by Dmitry V. Levin
parent daf21282d1
commit 46e2c5226a
2 changed files with 20 additions and 0 deletions

View File

@ -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 <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);
}
}

View File

@ -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