From b9a437c1471f946e93ab33e7befecc7bc8ff6694 Mon Sep 17 00:00:00 2001 From: JingPiao Chen Date: Mon, 28 Aug 2017 00:33:30 +0800 Subject: rtnl_rule: decode fib_rule_hdr netlink attributes * configure.ac (AC_CHECK_FUNCS): Add be64toh. (AC_CHECK_TYPES): Check for struct fib_rule_uid_range in . * nlattr.c: Include . (decode_nla_be64): New function. * nlattr.h (decode_nla_be64): New prototype. * rtnl_rule.c (decode_rule_addr, decode_fib_rule_uid_range): New functions. (fib_rule_hdr_nla_decoders): New array. (decode_fib_rule_hdr): Use it. --- nlattr.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'nlattr.c') diff --git a/nlattr.c b/nlattr.c index 76010c446..847fa3935 100644 --- a/nlattr.c +++ b/nlattr.c @@ -28,6 +28,7 @@ */ #include "defs.h" +#include #include "netlink.h" #include "nlattr.h" #include @@ -220,6 +221,26 @@ decode_nla_ifindex(struct tcb *const tcp, return true; } +bool +decode_nla_be64(struct tcb *const tcp, + const kernel_ulong_t addr, + const unsigned int len, + const void *const opaque_data) +{ +#if defined HAVE_BE64TOH || defined be64toh + uint64_t num; + + if (len < sizeof(num)) + return false; + else if (!umove_or_printaddr(tcp, addr, &num)) + tprintf("htobe64(%" PRIu64 ")", be64toh(num)); + + return true; +#else + return false; +#endif +} + #define DECODE_NLA_INTEGER(name, type, fmt) \ bool \ decode_nla_ ## name(struct tcb *const tcp, \ -- cgit v1.2.1