blob: bc8c490220842540e6ea30c49662077c927e6142 [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
Jaswinder Singh Rajput2df005b2009-01-30 21:42:47 +05304#include <linux/types.h>
5
Linus Torvalds1da177e2005-04-16 15:20:36 -07006/* Just some random number */
7#define TCPDIAG_GETSOCK 18
Arnaldo Carvalho de Melo540722f2005-08-10 05:54:28 -03008#define DCCPDIAG_GETSOCK 19
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -030010#define INET_DIAG_GETSOCK_MAX 24
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012/* Socket identity */
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030013struct inet_diag_sockid {
Al Viro9f855292006-09-27 18:44:30 -070014 __be16 idiag_sport;
15 __be16 idiag_dport;
16 __be32 idiag_src[4];
17 __be32 idiag_dst[4];
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030018 __u32 idiag_if;
19 __u32 idiag_cookie[2];
20#define INET_DIAG_NOCOOKIE (~0U)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021};
22
23/* Request structure */
24
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030025struct 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 Torvalds1da177e2005-04-16 15:20:36 -070030
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030031 struct inet_diag_sockid id;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030033 __u32 idiag_states; /* States to dump */
34 __u32 idiag_dbs; /* Tables to dump (NI) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070035};
36
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030037enum {
38 INET_DIAG_REQ_NONE,
39 INET_DIAG_REQ_BYTECODE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070040};
41
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030042#define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
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 Melo73c1f4a2005-08-12 12:51:49 -030050struct inet_diag_bc_op {
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 unsigned char code;
52 unsigned char yes;
53 unsigned short no;
54};
55
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030056enum {
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 Torvalds1da177e2005-04-16 15:20:36 -070066};
67
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030068struct inet_diag_hostcond {
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 __u8 family;
70 __u8 prefix_len;
71 int port;
Al Viro9f855292006-09-27 18:44:30 -070072 __be32 addr[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -070073};
74
75/* Base info structure. It contains socket identity (addrs/ports/cookie)
76 * and, alas, the information shown by netstat. */
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030077struct inet_diag_msg {
78 __u8 idiag_family;
79 __u8 idiag_state;
80 __u8 idiag_timer;
81 __u8 idiag_retrans;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030083 struct inet_diag_sockid id;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030085 __u32 idiag_expires;
86 __u32 idiag_rqueue;
87 __u32 idiag_wqueue;
88 __u32 idiag_uid;
89 __u32 idiag_inode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090};
91
92/* Extensions */
93
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030094enum {
95 INET_DIAG_NONE,
96 INET_DIAG_MEMINFO,
97 INET_DIAG_INFO,
98 INET_DIAG_VEGASINFO,
99 INET_DIAG_CONG,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100};
101
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300102#define INET_DIAG_MAX INET_DIAG_CONG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
104
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300105/* INET_DIAG_MEM */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300107struct inet_diag_meminfo {
108 __u32 idiag_rmem;
109 __u32 idiag_wmem;
110 __u32 idiag_fmem;
111 __u32 idiag_tmem;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112};
113
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300114/* INET_DIAG_VEGASINFO */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
116struct tcpvegas_info {
117 __u32 tcpv_enabled;
118 __u32 tcpv_rttcnt;
119 __u32 tcpv_rtt;
120 __u32 tcpv_minrtt;
121};
122
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -0300123#ifdef __KERNEL__
124struct sock;
125struct inet_hashinfo;
126
127struct inet_diag_handler {
128 struct inet_hashinfo *idiag_hashinfo;
129 void (*idiag_get_info)(struct sock *sk,
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300130 struct inet_diag_msg *r,
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -0300131 void *info);
132 __u16 idiag_info_size;
133 __u16 idiag_type;
134};
135
136extern int inet_diag_register(const struct inet_diag_handler *handler);
137extern void inet_diag_unregister(const struct inet_diag_handler *handler);
138#endif /* __KERNEL__ */
139
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300140#endif /* _INET_DIAG_H_ */