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 | |
| 4 | /* Just some random number */ |
| 5 | #define TCPDIAG_GETSOCK 18 |
Arnaldo Carvalho de Melo | 540722f | 2005-08-10 05:54:28 -0300 | [diff] [blame] | 6 | #define DCCPDIAG_GETSOCK 19 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 8 | #define INET_DIAG_GETSOCK_MAX 24 |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | /* Socket identity */ |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 11 | struct inet_diag_sockid { |
Al Viro | 9f85529 | 2006-09-27 18:44:30 -0700 | [diff] [blame] | 12 | __be16 idiag_sport; |
| 13 | __be16 idiag_dport; |
| 14 | __be32 idiag_src[4]; |
| 15 | __be32 idiag_dst[4]; |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 16 | __u32 idiag_if; |
| 17 | __u32 idiag_cookie[2]; |
| 18 | #define INET_DIAG_NOCOOKIE (~0U) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | }; |
| 20 | |
| 21 | /* Request structure */ |
| 22 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 23 | struct inet_diag_req { |
| 24 | __u8 idiag_family; /* Family of addresses. */ |
| 25 | __u8 idiag_src_len; |
| 26 | __u8 idiag_dst_len; |
| 27 | __u8 idiag_ext; /* Query extended information */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 29 | struct inet_diag_sockid id; |
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 | __u32 idiag_states; /* States to dump */ |
| 32 | __u32 idiag_dbs; /* Tables to dump (NI) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | }; |
| 34 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 35 | enum { |
| 36 | INET_DIAG_REQ_NONE, |
| 37 | INET_DIAG_REQ_BYTECODE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 40 | #define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
| 42 | /* Bytecode is sequence of 4 byte commands followed by variable arguments. |
| 43 | * All the commands identified by "code" are conditional jumps forward: |
| 44 | * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be |
| 45 | * length of the command and its arguments. |
| 46 | */ |
| 47 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 48 | struct inet_diag_bc_op { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | unsigned char code; |
| 50 | unsigned char yes; |
| 51 | unsigned short no; |
| 52 | }; |
| 53 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 54 | enum { |
| 55 | INET_DIAG_BC_NOP, |
| 56 | INET_DIAG_BC_JMP, |
| 57 | INET_DIAG_BC_S_GE, |
| 58 | INET_DIAG_BC_S_LE, |
| 59 | INET_DIAG_BC_D_GE, |
| 60 | INET_DIAG_BC_D_LE, |
| 61 | INET_DIAG_BC_AUTO, |
| 62 | INET_DIAG_BC_S_COND, |
| 63 | INET_DIAG_BC_D_COND, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 66 | struct inet_diag_hostcond { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | __u8 family; |
| 68 | __u8 prefix_len; |
| 69 | int port; |
Al Viro | 9f85529 | 2006-09-27 18:44:30 -0700 | [diff] [blame] | 70 | __be32 addr[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | /* Base info structure. It contains socket identity (addrs/ports/cookie) |
| 74 | * and, alas, the information shown by netstat. */ |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 75 | struct inet_diag_msg { |
| 76 | __u8 idiag_family; |
| 77 | __u8 idiag_state; |
| 78 | __u8 idiag_timer; |
| 79 | __u8 idiag_retrans; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 81 | struct inet_diag_sockid id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 83 | __u32 idiag_expires; |
| 84 | __u32 idiag_rqueue; |
| 85 | __u32 idiag_wqueue; |
| 86 | __u32 idiag_uid; |
| 87 | __u32 idiag_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | /* Extensions */ |
| 91 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 92 | enum { |
| 93 | INET_DIAG_NONE, |
| 94 | INET_DIAG_MEMINFO, |
| 95 | INET_DIAG_INFO, |
| 96 | INET_DIAG_VEGASINFO, |
| 97 | INET_DIAG_CONG, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 100 | #define INET_DIAG_MAX INET_DIAG_CONG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
| 102 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 103 | /* INET_DIAG_MEM */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 105 | struct inet_diag_meminfo { |
| 106 | __u32 idiag_rmem; |
| 107 | __u32 idiag_wmem; |
| 108 | __u32 idiag_fmem; |
| 109 | __u32 idiag_tmem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | }; |
| 111 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 112 | /* INET_DIAG_VEGASINFO */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | struct tcpvegas_info { |
| 115 | __u32 tcpv_enabled; |
| 116 | __u32 tcpv_rttcnt; |
| 117 | __u32 tcpv_rtt; |
| 118 | __u32 tcpv_minrtt; |
| 119 | }; |
| 120 | |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 121 | #ifdef __KERNEL__ |
| 122 | struct sock; |
| 123 | struct inet_hashinfo; |
| 124 | |
| 125 | struct inet_diag_handler { |
| 126 | struct inet_hashinfo *idiag_hashinfo; |
| 127 | void (*idiag_get_info)(struct sock *sk, |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 128 | struct inet_diag_msg *r, |
Arnaldo Carvalho de Melo | 4f5736c | 2005-08-12 09:27:49 -0300 | [diff] [blame] | 129 | void *info); |
| 130 | __u16 idiag_info_size; |
| 131 | __u16 idiag_type; |
| 132 | }; |
| 133 | |
| 134 | extern int inet_diag_register(const struct inet_diag_handler *handler); |
| 135 | extern void inet_diag_unregister(const struct inet_diag_handler *handler); |
| 136 | #endif /* __KERNEL__ */ |
| 137 | |
Arnaldo Carvalho de Melo | 73c1f4a | 2005-08-12 12:51:49 -0300 | [diff] [blame] | 138 | #endif /* _INET_DIAG_H_ */ |