netlink: add basic decoding of NETLINK_ROUTE rtmsg attributes
* rtnl_route.c: Include "nlattr.h" and "xlat/rtnl_route_attrs.h". (decode_rtmsg): Call decode_nlattr. * xlat/rtnl_route_attrs.in: New file. Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
This commit is contained in:
parent
ea9d07f0bf
commit
955b69cb79
13
rtnl_route.c
13
rtnl_route.c
@ -29,6 +29,7 @@
|
||||
|
||||
#include "defs.h"
|
||||
#include "netlink_route.h"
|
||||
#include "nlattr.h"
|
||||
#include "print_fields.h"
|
||||
|
||||
#include <linux/ip.h>
|
||||
@ -40,11 +41,13 @@
|
||||
#include "xlat/routing_protocols.h"
|
||||
#include "xlat/routing_table_ids.h"
|
||||
#include "xlat/routing_types.h"
|
||||
#include "xlat/rtnl_route_attrs.h"
|
||||
|
||||
DECL_NETLINK_ROUTE_DECODER(decode_rtmsg)
|
||||
{
|
||||
struct rtmsg rtmsg = { .rtm_family = family };
|
||||
const size_t offset = sizeof(rtmsg.rtm_family);
|
||||
size_t offset = sizeof(rtmsg.rtm_family);
|
||||
bool decode_nla = false;
|
||||
|
||||
PRINT_FIELD_XVAL("{", rtmsg, rtm_family, addrfams, "AF_???");
|
||||
|
||||
@ -67,8 +70,16 @@ DECL_NETLINK_ROUTE_DECODER(decode_rtmsg)
|
||||
routing_types, "RTN_???");
|
||||
PRINT_FIELD_FLAGS(", ", rtmsg, rtm_flags,
|
||||
routing_flags, "RTM_F_???");
|
||||
decode_nla = true;
|
||||
}
|
||||
} else
|
||||
tprints("...");
|
||||
tprints("}");
|
||||
|
||||
offset = NLMSG_ALIGN(sizeof(rtmsg));
|
||||
if (decode_nla && len > offset) {
|
||||
tprints(", ");
|
||||
decode_nlattr(tcp, addr + offset, len - offset,
|
||||
rtnl_route_attrs, "RTA_???", NULL, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
27
xlat/rtnl_route_attrs.in
Normal file
27
xlat/rtnl_route_attrs.in
Normal file
@ -0,0 +1,27 @@
|
||||
RTA_UNSPEC 0
|
||||
RTA_DST 1
|
||||
RTA_SRC 2
|
||||
RTA_IIF 3
|
||||
RTA_OIF 4
|
||||
RTA_GATEWAY 5
|
||||
RTA_PRIORITY 6
|
||||
RTA_PREFSRC 7
|
||||
RTA_METRICS 8
|
||||
RTA_MULTIPATH 9
|
||||
RTA_PROTOINFO 10
|
||||
RTA_FLOW 11
|
||||
RTA_CACHEINFO 12
|
||||
RTA_SESSION 13
|
||||
RTA_MP_ALGO 14
|
||||
RTA_TABLE 15
|
||||
RTA_MARK 16
|
||||
RTA_MFC_STATS 17
|
||||
RTA_VIA 18
|
||||
RTA_NEWDST 19
|
||||
RTA_PREF 20
|
||||
RTA_ENCAP_TYPE 21
|
||||
RTA_ENCAP 22
|
||||
RTA_EXPIRES 23
|
||||
RTA_PAD 24
|
||||
RTA_UID 25
|
||||
RTA_TTL_PROPAGATE 26
|
Loading…
Reference in New Issue
Block a user