Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 1 | #ifndef _INET_DIAG_H_ |
| 2 | #define _INET_DIAG_H_ 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | |
Jaswinder Singh Rajput | 2df005b | 2009-01-30 21:42:47 +0530 | [diff] [blame] | 4 | #include <linux/types.h> |
| 5 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | /* Just some random number */ |
| 7 | #define TCPDIAG_GETSOCK 18 |
Arnaldo Carvalho de Melo | 540722f | 2005-08-10 05:54:28 -0300 | [diff] [blame] | 8 | #define DCCPDIAG_GETSOCK 19 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 10 | #define INET_DIAG_GETSOCK_MAX 24 |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | /* Socket identity */ |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 13 | struct inet_diag_sockid { |
Al Viro | 9f85529 | 2006-09-27 18:44:30 -0700 | [diff] [blame] | 14 | __be16 idiag_sport; |
| 15 | __be16 idiag_dport; |
| 16 | __be32 idiag_src[4]; |
| 17 | __be32 idiag_dst[4]; |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 18 | __u32 idiag_if; |
| 19 | __u32 idiag_cookie[2]; |
| 20 | #define INET_DIAG_NOCOOKIE (~0U) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | /* Request structure */ |
| 24 | |
Pavel Emelyanov | 3b09c84 | 2012-01-10 22:37:26 +0000 | [diff] [blame] | 25 | struct inet_diag_req { |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 26 | __u8 idiag_family; /* Family of addresses. */ |
| 27 | __u8 idiag_src_len; |
| 28 | __u8 idiag_dst_len; |
| 29 | __u8 idiag_ext; /* Query extended information */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 31 | struct inet_diag_sockid id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 33 | __u32 idiag_states; /* States to dump */ |
| 34 | __u32 idiag_dbs; /* Tables to dump (NI) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
Pavel Emelyanov | c899136 | 2012-01-10 22:36:35 +0000 | [diff] [blame] | 37 | struct inet_diag_req_v2 { |
Pavel Emelyanov | 126fdc3 | 2011-12-06 07:58:21 +0000 | [diff] [blame] | 38 | __u8 sdiag_family; |
| 39 | __u8 sdiag_protocol; |
| 40 | __u8 idiag_ext; |
| 41 | __u8 pad; |
| 42 | __u32 idiag_states; |
| 43 | struct inet_diag_sockid id; |
| 44 | }; |
| 45 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 46 | enum { |
| 47 | INET_DIAG_REQ_NONE, |
| 48 | INET_DIAG_REQ_BYTECODE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 51 | #define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | /* Bytecode is sequence of 4 byte commands followed by variable arguments. |
| 54 | * All the commands identified by "code" are conditional jumps forward: |
| 55 | * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be |
| 56 | * length of the command and its arguments. |
| 57 | */ |
| 58 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 59 | struct inet_diag_bc_op { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | unsigned char code; |
| 61 | unsigned char yes; |
| 62 | unsigned short no; |
| 63 | }; |
| 64 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 65 | enum { |
| 66 | INET_DIAG_BC_NOP, |
| 67 | INET_DIAG_BC_JMP, |
| 68 | INET_DIAG_BC_S_GE, |
| 69 | INET_DIAG_BC_S_LE, |
| 70 | INET_DIAG_BC_D_GE, |
| 71 | INET_DIAG_BC_D_LE, |
| 72 | INET_DIAG_BC_AUTO, |
| 73 | INET_DIAG_BC_S_COND, |
| 74 | INET_DIAG_BC_D_COND, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 77 | struct inet_diag_hostcond { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | __u8 family; |
| 79 | __u8 prefix_len; |
| 80 | int port; |
Al Viro | 9f85529 | 2006-09-27 18:44:30 -0700 | [diff] [blame] | 81 | __be32 addr[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | /* Base info structure. It contains socket identity (addrs/ports/cookie) |
| 85 | * and, alas, the information shown by netstat. */ |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 86 | struct inet_diag_msg { |
| 87 | __u8 idiag_family; |
| 88 | __u8 idiag_state; |
| 89 | __u8 idiag_timer; |
| 90 | __u8 idiag_retrans; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 92 | struct inet_diag_sockid id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 94 | __u32 idiag_expires; |
| 95 | __u32 idiag_rqueue; |
| 96 | __u32 idiag_wqueue; |
| 97 | __u32 idiag_uid; |
| 98 | __u32 idiag_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | /* Extensions */ |
| 102 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 103 | enum { |
| 104 | INET_DIAG_NONE, |
| 105 | INET_DIAG_MEMINFO, |
| 106 | INET_DIAG_INFO, |
| 107 | INET_DIAG_VEGASINFO, |
| 108 | INET_DIAG_CONG, |
Murali Raja | 3ceca74 | 2011-10-12 09:00:35 +0000 | [diff] [blame] | 109 | INET_DIAG_TOS, |
Maciej Żenczykowski | 06236ac | 2011-11-07 14:23:11 +0000 | [diff] [blame] | 110 | INET_DIAG_TCLASS, |
Pavel Emelyanov | c0636fa | 2011-12-30 00:53:32 +0000 | [diff] [blame] | 111 | INET_DIAG_SKMEMINFO, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | }; |
| 113 | |
Pavel Emelyanov | c0636fa | 2011-12-30 00:53:32 +0000 | [diff] [blame] | 114 | #define INET_DIAG_MAX INET_DIAG_SKMEMINFO |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 117 | /* INET_DIAG_MEM */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 119 | struct inet_diag_meminfo { |
| 120 | __u32 idiag_rmem; |
| 121 | __u32 idiag_wmem; |
| 122 | __u32 idiag_fmem; |
| 123 | __u32 idiag_tmem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | }; |
| 125 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 126 | /* INET_DIAG_VEGASINFO */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
| 128 | struct tcpvegas_info { |
| 129 | __u32 tcpv_enabled; |
| 130 | __u32 tcpv_rttcnt; |
| 131 | __u32 tcpv_rtt; |
| 132 | __u32 tcpv_minrtt; |
| 133 | }; |
| 134 | |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 135 | #ifdef __KERNEL__ |
| 136 | struct sock; |
| 137 | struct inet_hashinfo; |
Pavel Emelyanov | 8d07d15 | 2011-12-09 06:22:44 +0000 | [diff] [blame] | 138 | struct nlattr; |
Pavel Emelyanov | 3c4d05c | 2011-12-09 06:23:00 +0000 | [diff] [blame] | 139 | struct nlmsghdr; |
| 140 | struct sk_buff; |
Pavel Emelyanov | 1942c51 | 2011-12-09 06:23:18 +0000 | [diff] [blame] | 141 | struct netlink_callback; |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 142 | |
| 143 | struct inet_diag_handler { |
Pavel Emelyanov | 1942c51 | 2011-12-09 06:23:18 +0000 | [diff] [blame] | 144 | void (*dump)(struct sk_buff *skb, |
| 145 | struct netlink_callback *cb, |
Pavel Emelyanov | c899136 | 2012-01-10 22:36:35 +0000 | [diff] [blame] | 146 | struct inet_diag_req_v2 *r, |
Pavel Emelyanov | 1942c51 | 2011-12-09 06:23:18 +0000 | [diff] [blame] | 147 | struct nlattr *bc); |
| 148 | |
| 149 | int (*dump_one)(struct sk_buff *in_skb, |
| 150 | const struct nlmsghdr *nlh, |
Pavel Emelyanov | c899136 | 2012-01-10 22:36:35 +0000 | [diff] [blame] | 151 | struct inet_diag_req_v2 *req); |
Pavel Emelyanov | 1942c51 | 2011-12-09 06:23:18 +0000 | [diff] [blame] | 152 | |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 153 | void (*idiag_get_info)(struct sock *sk, |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 154 | struct inet_diag_msg *r, |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 155 | void *info); |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 156 | __u16 idiag_type; |
| 157 | }; |
| 158 | |
Pavel Emelyanov | 3c4d05c | 2011-12-09 06:23:00 +0000 | [diff] [blame] | 159 | struct inet_connection_sock; |
| 160 | int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, |
Pavel Emelyanov | c899136 | 2012-01-10 22:36:35 +0000 | [diff] [blame] | 161 | struct sk_buff *skb, struct inet_diag_req_v2 *req, |
Pavel Emelyanov | 3c4d05c | 2011-12-09 06:23:00 +0000 | [diff] [blame] | 162 | u32 pid, u32 seq, u16 nlmsg_flags, |
| 163 | const struct nlmsghdr *unlh); |
Pavel Emelyanov | 1942c51 | 2011-12-09 06:23:18 +0000 | [diff] [blame] | 164 | void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb, |
Pavel Emelyanov | c899136 | 2012-01-10 22:36:35 +0000 | [diff] [blame] | 165 | struct netlink_callback *cb, struct inet_diag_req_v2 *r, |
Pavel Emelyanov | 1942c51 | 2011-12-09 06:23:18 +0000 | [diff] [blame] | 166 | struct nlattr *bc); |
| 167 | int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo, |
| 168 | struct sk_buff *in_skb, const struct nlmsghdr *nlh, |
Pavel Emelyanov | c899136 | 2012-01-10 22:36:35 +0000 | [diff] [blame] | 169 | struct inet_diag_req_v2 *req); |
Pavel Emelyanov | 1942c51 | 2011-12-09 06:23:18 +0000 | [diff] [blame] | 170 | |
Pavel Emelyanov | 8d07d15 | 2011-12-09 06:22:44 +0000 | [diff] [blame] | 171 | int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk); |
Pavel Emelyanov | b005ab4 | 2011-12-09 06:21:53 +0000 | [diff] [blame] | 172 | |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 173 | extern int inet_diag_register(const struct inet_diag_handler *handler); |
| 174 | extern void inet_diag_unregister(const struct inet_diag_handler *handler); |
| 175 | #endif /* __KERNEL__ */ |
| 176 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 177 | #endif /* _INET_DIAG_H_ */ |