blob: 6e8bc548635af6a2cb1a685158751ca437dff476 [file] [log] [blame]
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -03001#ifndef _INET_DIAG_H_
2#define _INET_DIAG_H_ 1
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4/* Just some random number */
5#define TCPDIAG_GETSOCK 18
Arnaldo Carvalho de Melo540722f2005-08-10 05:54:28 -03006#define DCCPDIAG_GETSOCK 19
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -03008#define INET_DIAG_GETSOCK_MAX 24
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010/* Socket identity */
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030011struct inet_diag_sockid {
Al Viro9f855292006-09-27 18:44:30 -070012 __be16 idiag_sport;
13 __be16 idiag_dport;
14 __be32 idiag_src[4];
15 __be32 idiag_dst[4];
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030016 __u32 idiag_if;
17 __u32 idiag_cookie[2];
18#define INET_DIAG_NOCOOKIE (~0U)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019};
20
21/* Request structure */
22
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030023struct 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 Torvalds1da177e2005-04-16 15:20:36 -070028
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030029 struct inet_diag_sockid id;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030031 __u32 idiag_states; /* States to dump */
32 __u32 idiag_dbs; /* Tables to dump (NI) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033};
34
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030035enum {
36 INET_DIAG_REQ_NONE,
37 INET_DIAG_REQ_BYTECODE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070038};
39
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030040#define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
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 Melo73c1f4a2005-08-12 12:51:49 -030048struct inet_diag_bc_op {
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 unsigned char code;
50 unsigned char yes;
51 unsigned short no;
52};
53
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030054enum {
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 Torvalds1da177e2005-04-16 15:20:36 -070064};
65
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030066struct inet_diag_hostcond {
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 __u8 family;
68 __u8 prefix_len;
69 int port;
Al Viro9f855292006-09-27 18:44:30 -070070 __be32 addr[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -070071};
72
73/* Base info structure. It contains socket identity (addrs/ports/cookie)
74 * and, alas, the information shown by netstat. */
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030075struct inet_diag_msg {
76 __u8 idiag_family;
77 __u8 idiag_state;
78 __u8 idiag_timer;
79 __u8 idiag_retrans;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030081 struct inet_diag_sockid id;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030083 __u32 idiag_expires;
84 __u32 idiag_rqueue;
85 __u32 idiag_wqueue;
86 __u32 idiag_uid;
87 __u32 idiag_inode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
90/* Extensions */
91
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030092enum {
93 INET_DIAG_NONE,
94 INET_DIAG_MEMINFO,
95 INET_DIAG_INFO,
96 INET_DIAG_VEGASINFO,
97 INET_DIAG_CONG,
Linus Torvalds1da177e2005-04-16 15:20:36 -070098};
99
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300100#define INET_DIAG_MAX INET_DIAG_CONG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
102
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300103/* INET_DIAG_MEM */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300105struct inet_diag_meminfo {
106 __u32 idiag_rmem;
107 __u32 idiag_wmem;
108 __u32 idiag_fmem;
109 __u32 idiag_tmem;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110};
111
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300112/* INET_DIAG_VEGASINFO */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
114struct tcpvegas_info {
115 __u32 tcpv_enabled;
116 __u32 tcpv_rttcnt;
117 __u32 tcpv_rtt;
118 __u32 tcpv_minrtt;
119};
120
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -0300121#ifdef __KERNEL__
122struct sock;
123struct inet_hashinfo;
124
125struct inet_diag_handler {
126 struct inet_hashinfo *idiag_hashinfo;
127 void (*idiag_get_info)(struct sock *sk,
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300128 struct inet_diag_msg *r,
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -0300129 void *info);
130 __u16 idiag_info_size;
131 __u16 idiag_type;
132};
133
134extern int inet_diag_register(const struct inet_diag_handler *handler);
135extern void inet_diag_unregister(const struct inet_diag_handler *handler);
136#endif /* __KERNEL__ */
137
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300138#endif /* _INET_DIAG_H_ */