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