inet_diag.h 2.7 KB
Newer Older
1 2
#ifndef _INET_DIAG_H_
#define _INET_DIAG_H_ 1
L
Linus Torvalds 已提交
3

4 5
#include <linux/types.h>

L
Linus Torvalds 已提交
6 7
/* Just some random number */
#define TCPDIAG_GETSOCK 18
8
#define DCCPDIAG_GETSOCK 19
L
Linus Torvalds 已提交
9

10 11
#define INET_DIAG_GETSOCK_MAX 24

L
Linus Torvalds 已提交
12
/* Socket identity */
13
struct inet_diag_sockid {
A
Al Viro 已提交
14 15 16 17
	__be16	idiag_sport;
	__be16	idiag_dport;
	__be32	idiag_src[4];
	__be32	idiag_dst[4];
18 19 20
	__u32	idiag_if;
	__u32	idiag_cookie[2];
#define INET_DIAG_NOCOOKIE (~0U)
L
Linus Torvalds 已提交
21 22 23 24
};

/* Request structure */

25 26 27 28 29
struct inet_diag_req {
	__u8	idiag_family;		/* Family of addresses. */
	__u8	idiag_src_len;
	__u8	idiag_dst_len;
	__u8	idiag_ext;		/* Query extended information */
L
Linus Torvalds 已提交
30

31
	struct inet_diag_sockid id;
L
Linus Torvalds 已提交
32

33 34
	__u32	idiag_states;		/* States to dump */
	__u32	idiag_dbs;		/* Tables to dump (NI) */
L
Linus Torvalds 已提交
35 36
};

37 38 39
enum {
	INET_DIAG_REQ_NONE,
	INET_DIAG_REQ_BYTECODE,
L
Linus Torvalds 已提交
40 41
};

42
#define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE
L
Linus Torvalds 已提交
43 44 45 46 47 48 49

/* Bytecode is sequence of 4 byte commands followed by variable arguments.
 * All the commands identified by "code" are conditional jumps forward:
 * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be
 * length of the command and its arguments.
 */
 
50
struct inet_diag_bc_op {
L
Linus Torvalds 已提交
51 52 53 54 55
	unsigned char	code;
	unsigned char	yes;
	unsigned short	no;
};

56 57 58 59 60 61 62 63 64 65
enum {
	INET_DIAG_BC_NOP,
	INET_DIAG_BC_JMP,
	INET_DIAG_BC_S_GE,
	INET_DIAG_BC_S_LE,
	INET_DIAG_BC_D_GE,
	INET_DIAG_BC_D_LE,
	INET_DIAG_BC_AUTO,
	INET_DIAG_BC_S_COND,
	INET_DIAG_BC_D_COND,
L
Linus Torvalds 已提交
66 67
};

68
struct inet_diag_hostcond {
L
Linus Torvalds 已提交
69 70 71
	__u8	family;
	__u8	prefix_len;
	int	port;
A
Al Viro 已提交
72
	__be32	addr[0];
L
Linus Torvalds 已提交
73 74 75 76
};

/* Base info structure. It contains socket identity (addrs/ports/cookie)
 * and, alas, the information shown by netstat. */
77 78 79 80 81 82 83 84 85 86 87 88 89
struct inet_diag_msg {
	__u8	idiag_family;
	__u8	idiag_state;
	__u8	idiag_timer;
	__u8	idiag_retrans;

	struct inet_diag_sockid id;

	__u32	idiag_expires;
	__u32	idiag_rqueue;
	__u32	idiag_wqueue;
	__u32	idiag_uid;
	__u32	idiag_inode;
L
Linus Torvalds 已提交
90 91 92 93
};

/* Extensions */

94 95 96 97 98 99
enum {
	INET_DIAG_NONE,
	INET_DIAG_MEMINFO,
	INET_DIAG_INFO,
	INET_DIAG_VEGASINFO,
	INET_DIAG_CONG,
100
	INET_DIAG_TOS,
L
Linus Torvalds 已提交
101 102
};

103
#define INET_DIAG_MAX INET_DIAG_TOS
L
Linus Torvalds 已提交
104 105


106
/* INET_DIAG_MEM */
L
Linus Torvalds 已提交
107

108 109 110 111 112
struct inet_diag_meminfo {
	__u32	idiag_rmem;
	__u32	idiag_wmem;
	__u32	idiag_fmem;
	__u32	idiag_tmem;
L
Linus Torvalds 已提交
113 114
};

115
/* INET_DIAG_VEGASINFO */
L
Linus Torvalds 已提交
116 117 118 119 120 121 122 123

struct tcpvegas_info {
	__u32	tcpv_enabled;
	__u32	tcpv_rttcnt;
	__u32	tcpv_rtt;
	__u32	tcpv_minrtt;
};

124 125 126 127 128 129 130
#ifdef __KERNEL__
struct sock;
struct inet_hashinfo;

struct inet_diag_handler {
	struct inet_hashinfo    *idiag_hashinfo;
	void			(*idiag_get_info)(struct sock *sk,
131
						  struct inet_diag_msg *r,
132 133 134 135 136 137 138 139 140
						  void *info);
	__u16                   idiag_info_size;
	__u16                   idiag_type;
};

extern int  inet_diag_register(const struct inet_diag_handler *handler);
extern void inet_diag_unregister(const struct inet_diag_handler *handler);
#endif /* __KERNEL__ */

141
#endif /* _INET_DIAG_H_ */