Intorduce PRINT_FIELD_INET4_ADDR
* print_fields.h (PRINT_FIELD_INET4_ADDR): New macro. * msghdr.c (print_cmsg_ip_pktinfo): Use it instead of manual tprintf statements. * net.c (print_mreq): Likewise. * sockaddr.c (print_sockaddr_data_in): Likewise.
This commit is contained in:
parent
c3d63a580f
commit
cb0ce38988
7
msghdr.c
7
msghdr.c
@ -124,10 +124,9 @@ print_cmsg_ip_pktinfo(struct tcb *tcp, const void *cmsg_data,
|
||||
const struct in_pktinfo *info = cmsg_data;
|
||||
|
||||
PRINT_FIELD_IFINDEX("{", *info, ipi_ifindex);
|
||||
tprintf(", ipi_spec_dst=inet_addr(\"%s\")",
|
||||
inet_ntoa(info->ipi_spec_dst));
|
||||
tprintf(", ipi_addr=inet_addr(\"%s\")}",
|
||||
inet_ntoa(info->ipi_addr));
|
||||
PRINT_FIELD_INET4_ADDR(", ", *info, ipi_spec_dst);
|
||||
PRINT_FIELD_INET4_ADDR(", ", *info, ipi_addr);
|
||||
tprints("}");
|
||||
}
|
||||
|
||||
static void
|
||||
|
7
net.c
7
net.c
@ -664,10 +664,9 @@ print_mreq(struct tcb *const tcp, const kernel_ulong_t addr,
|
||||
if (umove_or_printaddr(tcp, addr, &mreq))
|
||||
return;
|
||||
|
||||
tprintf("{imr_multiaddr=inet_addr(\"%s\")",
|
||||
inet_ntoa(mreq.imr_multiaddr));
|
||||
tprintf(", imr_interface=inet_addr(\"%s\")}",
|
||||
inet_ntoa(mreq.imr_interface));
|
||||
PRINT_FIELD_INET4_ADDR("{", mreq, imr_multiaddr);
|
||||
PRINT_FIELD_INET4_ADDR(", ", mreq, imr_interface);
|
||||
tprints("}");
|
||||
}
|
||||
#endif /* IP_ADD_MEMBERSHIP */
|
||||
|
||||
|
@ -87,6 +87,10 @@
|
||||
sizeof((where_).field_), #field_); \
|
||||
} while (0)
|
||||
|
||||
#define PRINT_FIELD_INET4_ADDR(prefix_, where_, field_) \
|
||||
STRACE_PRINTF("%s%s=inet_addr(\"%s\")", (prefix_), #field_, \
|
||||
inet_ntoa((where_).field_))
|
||||
|
||||
#define PRINT_FIELD_NET_PORT(prefix_, where_, field_) \
|
||||
STRACE_PRINTF("%s%s=htons(%u)", (prefix_), #field_, \
|
||||
ntohs((where_).field_))
|
||||
|
@ -117,7 +117,7 @@ print_sockaddr_data_in(const void *const buf, const int addrlen)
|
||||
const struct sockaddr_in *const sa_in = buf;
|
||||
|
||||
PRINT_FIELD_NET_PORT("", *sa_in, sin_port);
|
||||
tprintf(", sin_addr=inet_addr(\"%s\")", inet_ntoa(sa_in->sin_addr));
|
||||
PRINT_FIELD_INET4_ADDR(", ", *sa_in, sin_addr);
|
||||
}
|
||||
|
||||
#define SIN6_MIN_LEN offsetof(struct sockaddr_in6, sin6_scope_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user