[TCPDIAG]: Introduce inet_diag_{register,unregister}
[linux-2.6.git] / include / linux / tcp_diag.h
1 #ifndef _TCP_DIAG_H_
2 #define _TCP_DIAG_H_ 1
3
4 /* Just some random number */
5 #define TCPDIAG_GETSOCK 18
6 #define DCCPDIAG_GETSOCK 19
7
8 #define INET_DIAG_GETSOCK_MAX 24
9
10 /* Socket identity */
11 struct tcpdiag_sockid
12 {
13         __u16   tcpdiag_sport;
14         __u16   tcpdiag_dport;
15         __u32   tcpdiag_src[4];
16         __u32   tcpdiag_dst[4];
17         __u32   tcpdiag_if;
18         __u32   tcpdiag_cookie[2];
19 #define TCPDIAG_NOCOOKIE (~0U)
20 };
21
22 /* Request structure */
23
24 struct tcpdiagreq
25 {
26         __u8    tcpdiag_family;         /* Family of addresses. */
27         __u8    tcpdiag_src_len;
28         __u8    tcpdiag_dst_len;
29         __u8    tcpdiag_ext;            /* Query extended information */
30
31         struct tcpdiag_sockid id;
32
33         __u32   tcpdiag_states;         /* States to dump */
34         __u32   tcpdiag_dbs;            /* Tables to dump (NI) */
35 };
36
37 enum
38 {
39         TCPDIAG_REQ_NONE,
40         TCPDIAG_REQ_BYTECODE,
41 };
42
43 #define TCPDIAG_REQ_MAX TCPDIAG_REQ_BYTECODE
44
45 /* Bytecode is sequence of 4 byte commands followed by variable arguments.
46  * All the commands identified by "code" are conditional jumps forward:
47  * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be
48  * length of the command and its arguments.
49  */
50  
51 struct tcpdiag_bc_op
52 {
53         unsigned char   code;
54         unsigned char   yes;
55         unsigned short  no;
56 };
57
58 enum
59 {
60         TCPDIAG_BC_NOP,
61         TCPDIAG_BC_JMP,
62         TCPDIAG_BC_S_GE,
63         TCPDIAG_BC_S_LE,
64         TCPDIAG_BC_D_GE,
65         TCPDIAG_BC_D_LE,
66         TCPDIAG_BC_AUTO,
67         TCPDIAG_BC_S_COND,
68         TCPDIAG_BC_D_COND,
69 };
70
71 struct tcpdiag_hostcond
72 {
73         __u8    family;
74         __u8    prefix_len;
75         int     port;
76         __u32   addr[0];
77 };
78
79 /* Base info structure. It contains socket identity (addrs/ports/cookie)
80  * and, alas, the information shown by netstat. */
81 struct tcpdiagmsg
82 {
83         __u8    tcpdiag_family;
84         __u8    tcpdiag_state;
85         __u8    tcpdiag_timer;
86         __u8    tcpdiag_retrans;
87
88         struct tcpdiag_sockid id;
89
90         __u32   tcpdiag_expires;
91         __u32   tcpdiag_rqueue;
92         __u32   tcpdiag_wqueue;
93         __u32   tcpdiag_uid;
94         __u32   tcpdiag_inode;
95 };
96
97 /* Extensions */
98
99 enum
100 {
101         TCPDIAG_NONE,
102         TCPDIAG_MEMINFO,
103         TCPDIAG_INFO,
104         TCPDIAG_VEGASINFO,
105         TCPDIAG_CONG,
106 };
107
108 #define TCPDIAG_MAX TCPDIAG_CONG
109
110
111 /* TCPDIAG_MEM */
112
113 struct tcpdiag_meminfo
114 {
115         __u32   tcpdiag_rmem;
116         __u32   tcpdiag_wmem;
117         __u32   tcpdiag_fmem;
118         __u32   tcpdiag_tmem;
119 };
120
121 /* TCPDIAG_VEGASINFO */
122
123 struct tcpvegas_info {
124         __u32   tcpv_enabled;
125         __u32   tcpv_rttcnt;
126         __u32   tcpv_rtt;
127         __u32   tcpv_minrtt;
128 };
129
130 #ifdef __KERNEL__
131 struct sock;
132 struct inet_hashinfo;
133
134 struct inet_diag_handler {
135         struct inet_hashinfo    *idiag_hashinfo;
136         void                    (*idiag_get_info)(struct sock *sk,
137                                                   struct tcpdiagmsg *r,
138                                                   void *info);
139         __u16                   idiag_info_size;
140         __u16                   idiag_type;
141 };
142
143 extern int  inet_diag_register(const struct inet_diag_handler *handler);
144 extern void inet_diag_unregister(const struct inet_diag_handler *handler);
145 #endif /* __KERNEL__ */
146
147 #endif /* _TCP_DIAG_H_ */