netlink: add basic decoding of NETLINK_ROUTE rtgenmsg attributes
* rtnl_nsid.c: Include "nlattr.h" and "xlat/rtnl_nsid_attrs.h". (decode_rtgenmsg): Call decode_nlattr. * xlat/rtnl_nsid_attrs.in: New file. Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
This commit is contained in:
parent
4c1e85025f
commit
b9afb63fd7
10
rtnl_nsid.c
10
rtnl_nsid.c
@ -29,15 +29,25 @@
|
||||
|
||||
#include "defs.h"
|
||||
#include "netlink_route.h"
|
||||
#include "nlattr.h"
|
||||
#include "print_fields.h"
|
||||
|
||||
#include "netlink.h"
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
#include "xlat/rtnl_nsid_attrs.h"
|
||||
|
||||
DECL_NETLINK_ROUTE_DECODER(decode_rtgenmsg)
|
||||
{
|
||||
struct rtgenmsg rtgenmsg = { .rtgen_family = family };
|
||||
|
||||
PRINT_FIELD_XVAL("{", rtgenmsg, rtgen_family, addrfams, "AF_???");
|
||||
tprints("}");
|
||||
|
||||
const size_t offset = NLMSG_ALIGN(sizeof(rtgenmsg));
|
||||
if (len > offset) {
|
||||
tprints(", ");
|
||||
decode_nlattr(tcp, addr + offset, len - offset,
|
||||
rtnl_nsid_attrs, "NETNSA_???", NULL, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
5
xlat/rtnl_nsid_attrs.in
Normal file
5
xlat/rtnl_nsid_attrs.in
Normal file
@ -0,0 +1,5 @@
|
||||
NETNSA_NSID_NOT_ASSIGNED -1
|
||||
NETNSA_NONE 0
|
||||
NETNSA_NSID 1
|
||||
NETNSA_PID 2
|
||||
NETNSA_FD 3
|
Loading…
x
Reference in New Issue
Block a user