From a114dd92fe20e4a0cb81a4f7d90aa79ed0e7d26f Mon Sep 17 00:00:00 2001 From: JingPiao Chen Date: Sun, 13 Aug 2017 10:22:22 +0800 Subject: [PATCH] tests: check decoding of rtnetlink route messages * tests/netlink_route.c: Include . (test_rtnl_route): New function. (main): Use it. Co-authored-by: Fabien Siron --- tests/netlink_route.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/netlink_route.c b/tests/netlink_route.c index 872c236d..ff68579b 100644 --- a/tests/netlink_route.c +++ b/tests/netlink_route.c @@ -36,6 +36,7 @@ # include #endif #include +#include #include #ifdef HAVE_IF_INDEXTONAME @@ -234,6 +235,34 @@ test_rtnl_addr(const int fd) printf("}")); } +static void +test_rtnl_route(const int fd) +{ + void *const nlh0 = tail_alloc(NLMSG_HDRLEN); + static const struct rtmsg msg = { + .rtm_family = AF_UNIX, + .rtm_dst_len = 0xaf, + .rtm_src_len = 0xda, + .rtm_tos = IPTOS_LOWDELAY, + .rtm_table = RT_TABLE_DEFAULT, + .rtm_protocol = RTPROT_KERNEL, + .rtm_scope = RT_SCOPE_UNIVERSE, + .rtm_type = RTN_LOCAL, + .rtm_flags = RTM_F_NOTIFY + }; + + TEST_NL_ROUTE(fd, nlh0, RTM_GETROUTE, msg, + printf("{rtm_family=AF_UNIX"), + PRINT_FIELD_U(", ", msg, rtm_dst_len); + PRINT_FIELD_U(", ", msg, rtm_src_len); + printf(", rtm_tos=IPTOS_LOWDELAY" + ", rtm_table=RT_TABLE_DEFAULT" + ", rtm_protocol=RTPROT_KERNEL" + ", rtm_scope=RT_SCOPE_UNIVERSE" + ", rtm_type=RTN_LOCAL" + ", rtm_flags=RTM_F_NOTIFY}")); +} + int main(void) { skip_if_unavailable("/proc/self/fd/"); @@ -246,6 +275,7 @@ int main(void) test_rtnl_unspec(fd); test_rtnl_link(fd); test_rtnl_addr(fd); + test_rtnl_route(fd); printf("+++ exited with 0 +++\n"); -- 2.40.0