Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[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
10 #define INET_DIAG_GETSOCK_MAX 24
11
12 /* Socket identity */
13 struct inet_diag_sockid {
14         __be16  idiag_sport;
15         __be16  idiag_dport;
16         __be32  idiag_src[4];
17         __be32  idiag_dst[4];
18         __u32   idiag_if;
19         __u32   idiag_cookie[2];
20 #define INET_DIAG_NOCOOKIE (~0U)
21 };
22
23 /* Request structure */
24
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 */
30
31         struct inet_diag_sockid id;
32
33         __u32   idiag_states;           /* States to dump */
34         __u32   idiag_dbs;              /* Tables to dump (NI) */
35 };
36
37 struct inet_diag_req_v2 {
38         __u8    sdiag_family;
39         __u8    sdiag_protocol;
40         __u8    idiag_ext;
41         __u8    pad;
42         __u32   idiag_states;
43         struct inet_diag_sockid id;
44 };
45
46 enum {
47         INET_DIAG_REQ_NONE,
48         INET_DIAG_REQ_BYTECODE,
49 };
50
51 #define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE
52
53 /* Bytecode is sequence of 4 byte commands followed by variable arguments.
54  * All the commands identified by "code" are conditional jumps forward:
55  * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be
56  * length of the command and its arguments.
57  */
58  
59 struct inet_diag_bc_op {
60         unsigned char   code;
61         unsigned char   yes;
62         unsigned short  no;
63 };
64
65 enum {
66         INET_DIAG_BC_NOP,
67         INET_DIAG_BC_JMP,
68         INET_DIAG_BC_S_GE,
69         INET_DIAG_BC_S_LE,
70         INET_DIAG_BC_D_GE,
71         INET_DIAG_BC_D_LE,
72         INET_DIAG_BC_AUTO,
73         INET_DIAG_BC_S_COND,
74         INET_DIAG_BC_D_COND,
75 };
76
77 struct inet_diag_hostcond {
78         __u8    family;
79         __u8    prefix_len;
80         int     port;
81         __be32  addr[0];
82 };
83
84 /* Base info structure. It contains socket identity (addrs/ports/cookie)
85  * and, alas, the information shown by netstat. */
86 struct inet_diag_msg {
87         __u8    idiag_family;
88         __u8    idiag_state;
89         __u8    idiag_timer;
90         __u8    idiag_retrans;
91
92         struct inet_diag_sockid id;
93
94         __u32   idiag_expires;
95         __u32   idiag_rqueue;
96         __u32   idiag_wqueue;
97         __u32   idiag_uid;
98         __u32   idiag_inode;
99 };
100
101 /* Extensions */
102
103 enum {
104         INET_DIAG_NONE,
105         INET_DIAG_MEMINFO,
106         INET_DIAG_INFO,
107         INET_DIAG_VEGASINFO,
108         INET_DIAG_CONG,
109         INET_DIAG_TOS,
110         INET_DIAG_TCLASS,
111         INET_DIAG_SKMEMINFO,
112 };
113
114 #define INET_DIAG_MAX INET_DIAG_SKMEMINFO
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 struct nlmsghdr;
140 struct sk_buff;
141 struct netlink_callback;
142
143 struct inet_diag_handler {
144         void                    (*dump)(struct sk_buff *skb,
145                                         struct netlink_callback *cb,
146                                         struct inet_diag_req_v2 *r,
147                                         struct nlattr *bc);
148
149         int                     (*dump_one)(struct sk_buff *in_skb,
150                                         const struct nlmsghdr *nlh,
151                                         struct inet_diag_req_v2 *req);
152
153         void                    (*idiag_get_info)(struct sock *sk,
154                                                   struct inet_diag_msg *r,
155                                                   void *info);
156         __u16                   idiag_type;
157 };
158
159 struct inet_connection_sock;
160 int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
161                               struct sk_buff *skb, struct inet_diag_req_v2 *req,
162                               struct user_namespace *user_ns,
163                               u32 pid, u32 seq, u16 nlmsg_flags,
164                               const struct nlmsghdr *unlh);
165 void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
166                 struct netlink_callback *cb, struct inet_diag_req_v2 *r,
167                 struct nlattr *bc);
168 int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
169                 struct sk_buff *in_skb, const struct nlmsghdr *nlh,
170                 struct inet_diag_req_v2 *req);
171
172 int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
173
174 extern int  inet_diag_register(const struct inet_diag_handler *handler);
175 extern void inet_diag_unregister(const struct inet_diag_handler *handler);
176 #endif /* __KERNEL__ */
177
178 #endif /* _INET_DIAG_H_ */