strace/linux/inet_diag.h
Dmitry V. Levin 2f6510c8a6 Add -yy option: print ip and port associated with socket descriptors
When two ore more -y options are given, print local and remote ip:port
pairs associated with socket descriptors.  This implementation uses
NETLINK_INET_DIAG for sockaddr lookup; it's based on the patch
prepared by Zubin Mithra as a part of his GSoC 2014 strace project.

* Makefile.am (strace_SOURCES): Add socketutils.c
(EXTRA_DIST): Add linux/inet_diag.h and linux/sock_diag.h.
* defs.h (print_sockaddr_by_inode): New prototype.
* linux/inet_diag.h: New file.
* linux/sock_diag.h: Likewise.
* socketutils.c: Likewise.
* strace.1: Document -yy option.
* strace.c (usage): Likewise.
* util.c (printfd): Use print_sockaddr_by_inode.
2014-09-17 20:03:38 +00:00

39 lines
724 B
C

#define TCPDIAG_GETSOCK 18
#define DCCPDIAG_GETSOCK 19
/* Socket identity */
struct inet_diag_sockid {
uint16_t idiag_sport;
uint16_t idiag_dport;
uint32_t idiag_src[4];
uint32_t idiag_dst[4];
uint32_t idiag_if;
uint32_t idiag_cookie[2];
};
/* Request structure */
struct inet_diag_req_v2 {
uint8_t sdiag_family;
uint8_t sdiag_protocol;
uint8_t idiag_ext;
uint8_t pad;
uint32_t idiag_states;
struct inet_diag_sockid id;
};
/* Info structure */
struct inet_diag_msg {
uint8_t idiag_family;
uint8_t idiag_state;
uint8_t idiag_timer;
uint8_t idiag_retrans;
struct inet_diag_sockid id;
uint32_t idiag_expires;
uint32_t idiag_rqueue;
uint32_t idiag_wqueue;
uint32_t idiag_uid;
uint32_t idiag_inode;
};