* rtnl_addr.c: Include "nlattr.h" and "xlat/rtnl_addr_attrs.h".
(decode_ifaddrmsg): Call decode_nlattr.
* xlat/rtnl_addr_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.si...@epita.fr>
---
 rtnl_addr.c             | 13 ++++++++++++-
 xlat/rtnl_addr_attrs.in |  9 +++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 xlat/rtnl_addr_attrs.in

diff --git a/rtnl_addr.c b/rtnl_addr.c
index 905bc14..c7e37ea 100644
--- a/rtnl_addr.c
+++ b/rtnl_addr.c
@@ -29,6 +29,7 @@
 
 #include "defs.h"
 #include "netlink_route.h"
+#include "nlattr.h"
 #include "print_fields.h"
 
 #include "netlink.h"
@@ -39,11 +40,13 @@
 
 #include "xlat/ifaddrflags.h"
 #include "xlat/routing_scopes.h"
+#include "xlat/rtnl_addr_attrs.h"
 
 DECL_NETLINK_ROUTE_DECODER(decode_ifaddrmsg)
 {
        struct ifaddrmsg ifaddr = { .ifa_family = family };
-       const size_t offset = sizeof(ifaddr.ifa_family);
+       size_t offset = sizeof(ifaddr.ifa_family);
+       bool decode_nla = false;
 
        PRINT_FIELD_XVAL("{", ifaddr, ifa_family, addrfams, "AF_???");
 
@@ -58,8 +61,16 @@ DECL_NETLINK_ROUTE_DECODER(decode_ifaddrmsg)
                        PRINT_FIELD_XVAL(", ", ifaddr, ifa_scope,
                                         routing_scopes, NULL);
                        PRINT_FIELD_IFINDEX(", ", ifaddr, ifa_index);
+                       decode_nla = true;
                }
        } else
                tprints("...");
        tprints("}");
+
+       offset = NLMSG_ALIGN(sizeof(ifaddr));
+       if (decode_nla && len > offset) {
+               tprints(", ");
+               decode_nlattr(tcp, addr + offset, len - offset,
+                             rtnl_addr_attrs, "IFA_???", NULL, 0, NULL);
+       }
 }
diff --git a/xlat/rtnl_addr_attrs.in b/xlat/rtnl_addr_attrs.in
new file mode 100644
index 0000000..df65905
--- /dev/null
+++ b/xlat/rtnl_addr_attrs.in
@@ -0,0 +1,9 @@
+IFA_UNSPEC             0
+IFA_ADDRESS            1
+IFA_LOCAL              2
+IFA_LABEL              3
+IFA_BROADCAST          4
+IFA_ANYCAST            5
+IFA_CACHEINFO          6
+IFA_MULTICAST          7
+IFA_FLAGS              8
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to