summaryrefslogtreecommitdiffstats
path: root/include/netlink/idiag/idiagnl.h
blob: 3b3b57e6317902bba8558a8e7f7e4bfa16043d5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
 * netlink/idiag/idiagnl.h		Inetdiag Netlink
 *
 *	This library is free software; you can redistribute it and/or
 *	modify it under the terms of the GNU Lesser General Public
 *	License as published by the Free Software Foundation version 2.1
 *	of the License.
 *
 * Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com>
 */

#ifndef NETLINK_IDIAGNL_H_
#define NETLINK_IDIAGNL_H_

#include <netlink/netlink.h>
#include <linux/sock_diag.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Inet Diag message types
 *
 * deprecated: use TCPDIAG_GETSOCK, DCCPDIAG_GETSOCK and
 * INET_DIAG_GETSOCK_MAX from linux/inet_diag.h
 */
#define IDIAG_TCPDIAG_GETSOCK	18
#define IDIAG_DCCPDIAG_GETSOCK	19
#define IDIAG_GETSOCK_MAX	24

/**
 * Socket state identifiers
 * @ingroup idiag
 * @deprecated: use instead the TCP_* defines from netinet/tcp.h.
 */
enum {
	IDIAG_SS_UNKNOWN           = 0,

	IDIAG_SS_ESTABLISHED       = 1,  /* TCP_ESTABLISHED */
	IDIAG_SS_SYN_SENT          = 2,  /* TCP_SYN_SENT */
	IDIAG_SS_SYN_RECV          = 3,  /* TCP_SYN_RECV */
	IDIAG_SS_FIN_WAIT1         = 4,  /* TCP_FIN_WAIT1 */
	IDIAG_SS_FIN_WAIT2         = 5,  /* TCP_FIN_WAIT2 */
	IDIAG_SS_TIME_WAIT         = 6,  /* TCP_TIME_WAIT */
	IDIAG_SS_CLOSE             = 7,  /* TCP_CLOSE */
	IDIAG_SS_CLOSE_WAIT        = 8,  /* TCP_CLOSE_WAIT */
	IDIAG_SS_LAST_ACK          = 9,  /* TCP_LAST_ACK */
	IDIAG_SS_LISTEN            = 10, /* TCP_LISTEN */
	IDIAG_SS_CLOSING           = 11, /* TCP_CLOSING */

	IDIAG_SS_MAX               = 12,
};

/**
 * Macro to represent all socket states.
 * @ingroup idiag
 */
#define IDIAGNL_SS_ALL (((1<<12)-1))

/**
 * Macro to represent all socket states.
 * @ingroup idiag
 * @deprecated
 */
#define IDIAG_SS_ALL  IDIAGNL_SS_ALL


/**
 * Inet Diag extended attributes
 * @ingroup idiag
 * @deprecated These attributes should not be used. They mirror the
 * INET_DIAG_* extension flags from kernel headers. Use those instead. */
enum {
	IDIAG_ATTR_NONE         = 0, /* INET_DIAG_NONE */
	IDIAG_ATTR_MEMINFO      = 1, /* INET_DIAG_MEMINFO */
	IDIAG_ATTR_INFO         = 2, /* INET_DIAG_INFO */
	IDIAG_ATTR_VEGASINFO    = 3, /* INET_DIAG_VEGASINFO */
	IDIAG_ATTR_CONG         = 4, /* INET_DIAG_CONG */
	IDIAG_ATTR_TOS          = 5, /* INET_DIAG_TOS */
	IDIAG_ATTR_TCLASS       = 6, /* INET_DIAG_TCLASS */
	IDIAG_ATTR_SKMEMINFO    = 7, /* INET_DIAG_SKMEMINFO */
	IDIAG_ATTR_SHUTDOWN     = 8, /* INET_DIAG_SHUTDOWN */

	/* IDIAG_ATTR_MAX was wrong, because it did not correspond to
	 * INET_DIAG_MAX. Anyway, freeze it to the previous value. */
	IDIAG_ATTR_MAX          = 9,

	IDIAG_ATTR_ALL          = (1<<IDIAG_ATTR_MAX) - 1,
};


/* Keep these only for compatibility, DO NOT USE THEM */
#define	IDIAG_SK_MEMINFO_RMEM_ALLOC SK_MEMINFO_RMEM_ALLOC
#define	IDIAG_SK_MEMINFO_RCVBUF SK_MEMINFO_RCVBUF
#define	IDIAG_SK_MEMINFO_WMEM_ALLOC SK_MEMINFO_WMEM_ALLOC
#define	IDIAG_SK_MEMINFO_SNDBUF SK_MEMINFO_SNDBUF
#define	IDIAG_SK_MEMINFO_FWD_ALLOC SK_MEMINFO_FWD_ALLOC
#define	IDIAG_SK_MEMINFO_WMEM_QUEUED SK_MEMINFO_WMEM_QUEUED
#define	IDIAG_SK_MEMINFO_OPTMEM SK_MEMINFO_OPTMEM
#define	IDIAG_SK_MEMINFO_BACKLOG SK_MEMINFO_BACKLOG
#define	IDIAG_SK_MEMINFO_VARS SK_MEMINFO_VARS

/**
 * Socket timer indentifiers
 * @ingroupd idiag
 */
enum {
	IDIAG_TIMER_OFF,
	IDIAG_TIMER_ON,
	IDIAG_TIMER_KEEPALIVE,
	IDIAG_TIMER_TIMEWAIT,
	IDIAG_TIMER_PERSIST,
	IDIAG_TIMER_UNKNOWN,
};

extern char *	idiagnl_state2str(int, char *, size_t);
extern int	idiagnl_str2state(const char *);

extern int	idiagnl_connect(struct nl_sock *);
extern int	idiagnl_send_simple(struct nl_sock *, int, uint8_t, uint16_t,
                                    uint16_t);

extern char *		idiagnl_timer2str(int, char *, size_t);
extern int		idiagnl_str2timer(const char *);
extern char *		idiagnl_attrs2str(int, char *, size_t);
extern char *		idiagnl_tcpstate2str(uint8_t, char *, size_t);
extern char *		idiagnl_tcpopts2str(uint8_t, char *, size_t);
extern char *		idiagnl_shutdown2str(uint8_t, char *, size_t);
extern char *		idiagnl_exts2str(uint8_t, char *, size_t);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* NETLINK_IDIAGNL_H_ */