blob: f1362b5447fcbcf6935e49aec748675562eb0b12 [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
Pavel Emelyanov3b09c842012-01-10 22:37:26 +000025struct inet_diag_req {
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030026 __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
Pavel Emelyanovc8991362012-01-10 22:36:35 +000037struct inet_diag_req_v2 {
Pavel Emelyanov126fdc32011-12-06 07:58:21 +000038 __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
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030046enum {
47 INET_DIAG_REQ_NONE,
48 INET_DIAG_REQ_BYTECODE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070049};
50
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030051#define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
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
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030059struct inet_diag_bc_op {
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 unsigned char code;
61 unsigned char yes;
62 unsigned short no;
63};
64
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030065enum {
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,
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030077struct inet_diag_hostcond {
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 __u8 family;
79 __u8 prefix_len;
80 int port;
Al Viro9f855292006-09-27 18:44:30 -070081 __be32 addr[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -070082};
83
84/* Base info structure. It contains socket identity (addrs/ports/cookie)
85 * and, alas, the information shown by netstat. */
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030086struct inet_diag_msg {
87 __u8 idiag_family;
88 __u8 idiag_state;
89 __u8 idiag_timer;
90 __u8 idiag_retrans;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030092 struct inet_diag_sockid id;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030094 __u32 idiag_expires;
95 __u32 idiag_rqueue;
96 __u32 idiag_wqueue;
97 __u32 idiag_uid;
98 __u32 idiag_inode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099};
100
101/* Extensions */
102
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300103enum {
104 INET_DIAG_NONE,
105 INET_DIAG_MEMINFO,
106 INET_DIAG_INFO,
107 INET_DIAG_VEGASINFO,
108 INET_DIAG_CONG,
Murali Raja3ceca742011-10-12 09:00:35 +0000109 INET_DIAG_TOS,
Maciej Żenczykowski06236ac2011-11-07 14:23:11 +0000110 INET_DIAG_TCLASS,
Pavel Emelyanovc0636fa2011-12-30 00:53:32 +0000111 INET_DIAG_SKMEMINFO,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112};
113
Pavel Emelyanovc0636fa2011-12-30 00:53:32 +0000114#define INET_DIAG_MAX INET_DIAG_SKMEMINFO
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
116
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300117/* INET_DIAG_MEM */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300119struct inet_diag_meminfo {
120 __u32 idiag_rmem;
121 __u32 idiag_wmem;
122 __u32 idiag_fmem;
123 __u32 idiag_tmem;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124};
125
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300126/* INET_DIAG_VEGASINFO */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128struct tcpvegas_info {
129 __u32 tcpv_enabled;
130 __u32 tcpv_rttcnt;
131 __u32 tcpv_rtt;
132 __u32 tcpv_minrtt;
133};
134
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -0300135#ifdef __KERNEL__
136struct sock;
137struct inet_hashinfo;
Pavel Emelyanov8d07d152011-12-09 06:22:44 +0000138struct nlattr;
Pavel Emelyanov3c4d05c2011-12-09 06:23:00 +0000139struct nlmsghdr;
140struct sk_buff;
Pavel Emelyanov1942c512011-12-09 06:23:18 +0000141struct netlink_callback;
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -0300142
143struct inet_diag_handler {
Pavel Emelyanov1942c512011-12-09 06:23:18 +0000144 void (*dump)(struct sk_buff *skb,
145 struct netlink_callback *cb,
Pavel Emelyanovc8991362012-01-10 22:36:35 +0000146 struct inet_diag_req_v2 *r,
Pavel Emelyanov1942c512011-12-09 06:23:18 +0000147 struct nlattr *bc);
148
149 int (*dump_one)(struct sk_buff *in_skb,
150 const struct nlmsghdr *nlh,
Pavel Emelyanovc8991362012-01-10 22:36:35 +0000151 struct inet_diag_req_v2 *req);
Pavel Emelyanov1942c512011-12-09 06:23:18 +0000152
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -0300153 void (*idiag_get_info)(struct sock *sk,
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300154 struct inet_diag_msg *r,
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -0300155 void *info);
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -0300156 __u16 idiag_type;
157};
158
Pavel Emelyanov3c4d05c2011-12-09 06:23:00 +0000159struct inet_connection_sock;
160int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
Pavel Emelyanovc8991362012-01-10 22:36:35 +0000161 struct sk_buff *skb, struct inet_diag_req_v2 *req,
Pavel Emelyanov3c4d05c2011-12-09 06:23:00 +0000162 u32 pid, u32 seq, u16 nlmsg_flags,
163 const struct nlmsghdr *unlh);
Pavel Emelyanov1942c512011-12-09 06:23:18 +0000164void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
Pavel Emelyanovc8991362012-01-10 22:36:35 +0000165 struct netlink_callback *cb, struct inet_diag_req_v2 *r,
Pavel Emelyanov1942c512011-12-09 06:23:18 +0000166 struct nlattr *bc);
167int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
168 struct sk_buff *in_skb, const struct nlmsghdr *nlh,
Pavel Emelyanovc8991362012-01-10 22:36:35 +0000169 struct inet_diag_req_v2 *req);
Pavel Emelyanov1942c512011-12-09 06:23:18 +0000170
Pavel Emelyanov8d07d152011-12-09 06:22:44 +0000171int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
Pavel Emelyanovb005ab42011-12-09 06:21:53 +0000172
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -0300173extern int inet_diag_register(const struct inet_diag_handler *handler);
174extern void inet_diag_unregister(const struct inet_diag_handler *handler);
175#endif /* __KERNEL__ */
176
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -0300177#endif /* _INET_DIAG_H_ */