summaryrefslogtreecommitdiff
path: root/nlattr.c
diff options
context:
space:
mode:
authorJingPiao Chen <chenjingpiao@gmail.com>2017-08-28 00:33:30 +0800
committerJingPiao Chen <chenjingpiao@gmail.com>2017-08-29 15:13:12 +0800
commitb9a437c1471f946e93ab33e7befecc7bc8ff6694 (patch)
treea2726fb24822245352c4464ced9b7b9429dfeee0 /nlattr.c
parent62c573a002f905659cc9f4f21115fa2a9671ff8b (diff)
downloadstrace-b9a437c1471f946e93ab33e7befecc7bc8ff6694.tar.gz
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 <linux/fib_rules.h>. * nlattr.c: Include <endian.h>. (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.
Diffstat (limited to 'nlattr.c')
-rw-r--r--nlattr.c21
1 files changed, 21 insertions, 0 deletions
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 <endian.h>
#include "netlink.h"
#include "nlattr.h"
#include <linux/sock_diag.h>
@@ -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, \