[PATCH 02/26] netlink: add a basic rtnetlink parser of addr messages
Dmitry V. Levin
ldv at altlinux.org
Sat Aug 12 00:05:15 UTC 2017
On Thu, Aug 10, 2017 at 09:04:52AM +0800, JingPiao Chen wrote:
> * rtnl_addr.c: New file.
> * Makefile.am (strace_SOURCES): Add it.
> * configure.ac (AC_CHECK_HEADERS): Add linux/if_addr.h.
> * netlink_route.h (decode_ifaddrmsg): New prototype.
> * netlink_route.c (route_decoders): Add RTM_DELADDR,
> RTM_GETADDR, RTM_GETANYCAST, RTM_GETMULTICAST add RTM_NEWADDR.
> * xlat/ifaddrflags.in: New file.
[...]
> +DECL_NETLINK_ROUTE_DECODER(decode_ifaddrmsg)
> +{
> + struct ifaddrmsg ifaddr = { .ifa_family = family };
> + const size_t offset = sizeof(ifaddr.ifa_family);
> +
> + PRINT_FIELD_XVAL("{", ifaddr, ifa_family, addrfams, "AF_???");
> +
> + tprints(", ");
> + if (len >= sizeof(ifaddr)) {
> + if (!umoven_or_printaddr(tcp, addr + offset,
> + sizeof(ifaddr) - offset,
> + (void *) &ifaddr + offset)) {
> + PRINT_FIELD_U("", ifaddr, ifa_prefixlen);
> + PRINT_FIELD_FLAGS(", ", ifaddr, ifa_flags,
> + ifaddrflags, "IFA_F_???");
> + PRINT_FIELD_U(", ", ifaddr, ifa_scope);
When ifaddr.ifa_flags contains one of RT_SCOPE_* constants defined
in linux/rtnetlink.h, it would be better if this constant was printed
in its symbolic form.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170812/32c267a1/attachment.bin>
More information about the Strace-devel
mailing list