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 |
Pavel Emelyanov | 8d34172 | 2011-12-06 07:57:06 +0000 | [diff] [blame] | 9 | #define SOCK_DIAG_BY_FAMILY 20 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 11 | #define INET_DIAG_GETSOCK_MAX 24 |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | /* Socket identity */ |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 14 | struct inet_diag_sockid { |
Al Viro | 9f85529 | 2006-09-27 18:44:30 -0700 | [diff] [blame] | 15 | __be16 idiag_sport; |
| 16 | __be16 idiag_dport; |
| 17 | __be32 idiag_src[4]; |
| 18 | __be32 idiag_dst[4]; |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 19 | __u32 idiag_if; |
| 20 | __u32 idiag_cookie[2]; |
| 21 | #define INET_DIAG_NOCOOKIE (~0U) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | }; |
| 23 | |
| 24 | /* Request structure */ |
| 25 | |
Pavel Emelyanov | 126fdc3 | 2011-12-06 07:58:21 +0000 | [diff] [blame] | 26 | struct inet_diag_req_compat { |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 27 | __u8 idiag_family; /* Family of addresses. */ |
| 28 | __u8 idiag_src_len; |
| 29 | __u8 idiag_dst_len; |
| 30 | __u8 idiag_ext; /* Query extended information */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 32 | struct inet_diag_sockid id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 34 | __u32 idiag_states; /* States to dump */ |
| 35 | __u32 idiag_dbs; /* Tables to dump (NI) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | }; |
| 37 | |
Pavel Emelyanov | 126fdc3 | 2011-12-06 07:58:21 +0000 | [diff] [blame] | 38 | struct inet_diag_req { |
| 39 | __u8 sdiag_family; |
| 40 | __u8 sdiag_protocol; |
| 41 | __u8 idiag_ext; |
| 42 | __u8 pad; |
| 43 | __u32 idiag_states; |
| 44 | struct inet_diag_sockid id; |
| 45 | }; |
| 46 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 47 | enum { |
| 48 | INET_DIAG_REQ_NONE, |
| 49 | INET_DIAG_REQ_BYTECODE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 52 | #define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | /* Bytecode is sequence of 4 byte commands followed by variable arguments. |
| 55 | * All the commands identified by "code" are conditional jumps forward: |
| 56 | * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be |
| 57 | * length of the command and its arguments. |
| 58 | */ |
| 59 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 60 | struct inet_diag_bc_op { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | unsigned char code; |
| 62 | unsigned char yes; |
| 63 | unsigned short no; |
| 64 | }; |
| 65 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 66 | enum { |
| 67 | INET_DIAG_BC_NOP, |
| 68 | INET_DIAG_BC_JMP, |
| 69 | INET_DIAG_BC_S_GE, |
| 70 | INET_DIAG_BC_S_LE, |
| 71 | INET_DIAG_BC_D_GE, |
| 72 | INET_DIAG_BC_D_LE, |
| 73 | INET_DIAG_BC_AUTO, |
| 74 | INET_DIAG_BC_S_COND, |
| 75 | INET_DIAG_BC_D_COND, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 78 | struct inet_diag_hostcond { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | __u8 family; |
| 80 | __u8 prefix_len; |
| 81 | int port; |
Al Viro | 9f85529 | 2006-09-27 18:44:30 -0700 | [diff] [blame] | 82 | __be32 addr[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | /* Base info structure. It contains socket identity (addrs/ports/cookie) |
| 86 | * and, alas, the information shown by netstat. */ |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 87 | struct inet_diag_msg { |
| 88 | __u8 idiag_family; |
| 89 | __u8 idiag_state; |
| 90 | __u8 idiag_timer; |
| 91 | __u8 idiag_retrans; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 93 | struct inet_diag_sockid id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 95 | __u32 idiag_expires; |
| 96 | __u32 idiag_rqueue; |
| 97 | __u32 idiag_wqueue; |
| 98 | __u32 idiag_uid; |
| 99 | __u32 idiag_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | /* Extensions */ |
| 103 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 104 | enum { |
| 105 | INET_DIAG_NONE, |
| 106 | INET_DIAG_MEMINFO, |
| 107 | INET_DIAG_INFO, |
| 108 | INET_DIAG_VEGASINFO, |
| 109 | INET_DIAG_CONG, |
Murali Raja | 3ceca74 | 2011-10-12 09:00:35 +0000 | [diff] [blame] | 110 | INET_DIAG_TOS, |
Maciej Żenczykowski | 06236ac | 2011-11-07 14:23:11 +0000 | [diff] [blame] | 111 | INET_DIAG_TCLASS, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | }; |
| 113 | |
Maciej Żenczykowski | 06236ac | 2011-11-07 14:23:11 +0000 | [diff] [blame] | 114 | #define INET_DIAG_MAX INET_DIAG_TCLASS |
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; |
| 138 | |
| 139 | struct inet_diag_handler { |
| 140 | struct inet_hashinfo *idiag_hashinfo; |
| 141 | void (*idiag_get_info)(struct sock *sk, |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 142 | struct inet_diag_msg *r, |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 143 | void *info); |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 144 | __u16 idiag_type; |
| 145 | }; |
| 146 | |
Pavel Emelyanov | b005ab4 | 2011-12-09 06:21:53 +0000 | [diff] [blame^] | 147 | int inet_diag_check_cookie(struct sock *sk, struct inet_diag_req *req); |
| 148 | |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 149 | extern int inet_diag_register(const struct inet_diag_handler *handler); |
| 150 | extern void inet_diag_unregister(const struct inet_diag_handler *handler); |
| 151 | #endif /* __KERNEL__ */ |
| 152 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 153 | #endif /* _INET_DIAG_H_ */ |