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