[PATCH] recvmsg: add support for IP_PKTINFO decoding

Gabriel Laskar gabriel at lse.epita.fr
Thu Nov 19 17:16:46 UTC 2015


* net.c (printcmsghdr): add IP_PKTINFO decoding
* xlat/sol_ip_vals.in: new file

Signed-off-by: Gabriel Laskar <gabriel at lse.epita.fr>
Suggested-by: Orion Poplawski <orion at cora.nwra.com>
---
 net.c               | 11 +++++++++++
 xlat/sol_ip_vals.in |  1 +
 2 files changed, 12 insertions(+)
 create mode 100644 xlat/sol_ip_vals.in

diff --git a/net.c b/net.c
index 7e8586a..85e5536 100644
--- a/net.c
+++ b/net.c
@@ -294,6 +294,7 @@ printsock(struct tcb *tcp, long addr, int addrlen)
 #  define SCM_SECURITY 0x03
 # endif
 # include "xlat/scmvals.h"
+# include "xlat/sol_ip_vals.h"
 
 #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
 struct cmsghdr32 {
@@ -423,6 +424,16 @@ printcmsghdr(struct tcb *tcp, unsigned long addr, size_t len)
 					goto next_cmsg;
 				break;
 			}
+		} else if (cmsg_level == SOL_IP) {
+			printxval(sol_ip_vals, cmsg_type, "IP_???");
+			if (cmsg_size + sizeof(struct in_pktinfo) > cmsg_len)
+				break;
+			struct in_pktinfo *pktinfo = (void*)(u.ptr + cmsg_size);
+			tprintf(", {ipi_ifindex=%u, ipi_spec_dst=inet_addr(%s), ipi_addr=inet_addr(%s)}",
+					pktinfo->ipi_ifindex,
+					inet_ntoa(pktinfo->ipi_spec_dst),
+					inet_ntoa(pktinfo->ipi_addr));
+			goto next_cmsg;
 		} else {
 			tprintf("%u", cmsg_type);
 		}
diff --git a/xlat/sol_ip_vals.in b/xlat/sol_ip_vals.in
new file mode 100644
index 0000000..4f8304b
--- /dev/null
+++ b/xlat/sol_ip_vals.in
@@ -0,0 +1 @@
+IP_PKTINFO
-- 
Gabriel Laskar





More information about the Strace-devel mailing list