| 1 |
/* SPDX-License-Identifier: LGPL-2.1-only */ |
| 2 |
/* |
| 3 |
* Copyright (c) 2013 Sassano Systems LLC <[email protected]> |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef NETLINK_IDIAGNL_H_ |
| 7 |
#define NETLINK_IDIAGNL_H_ |
| 8 |
|
| 9 |
#include <netlink/netlink.h> |
| 10 |
#include <linux/sock_diag.h> |
| 11 |
|
| 12 |
#ifdef __cplusplus |
| 13 |
extern "C" { |
| 14 |
#endif |
| 15 |
|
| 16 |
/************************************************************* |
| 17 |
* The following part contains DEPRECATED names and defines. |
| 18 |
* Don't use them. |
| 19 |
*************************************************************/ |
| 20 |
|
| 21 |
/** |
| 22 |
* Inet Diag message types |
| 23 |
* |
| 24 |
* deprecated: use TCPDIAG_GETSOCK, DCCPDIAG_GETSOCK and |
| 25 |
* INET_DIAG_GETSOCK_MAX from linux/inet_diag.h |
| 26 |
*/ |
| 27 |
#define IDIAG_TCPDIAG_GETSOCK 18 |
| 28 |
#define IDIAG_DCCPDIAG_GETSOCK 19 |
| 29 |
#define IDIAG_GETSOCK_MAX 24 |
| 30 |
|
| 31 |
/** |
| 32 |
* Socket state identifiers |
| 33 |
* @ingroup idiag |
| 34 |
* @deprecated: use instead the TCP_* defines from netinet/tcp.h. |
| 35 |
*/ |
| 36 |
enum { |
| 37 |
IDIAG_SS_UNKNOWN = 0, |
| 38 |
|
| 39 |
IDIAG_SS_ESTABLISHED = 1, /* TCP_ESTABLISHED */ |
| 40 |
IDIAG_SS_SYN_SENT = 2, /* TCP_SYN_SENT */ |
| 41 |
IDIAG_SS_SYN_RECV = 3, /* TCP_SYN_RECV */ |
| 42 |
IDIAG_SS_FIN_WAIT1 = 4, /* TCP_FIN_WAIT1 */ |
| 43 |
IDIAG_SS_FIN_WAIT2 = 5, /* TCP_FIN_WAIT2 */ |
| 44 |
IDIAG_SS_TIME_WAIT = 6, /* TCP_TIME_WAIT */ |
| 45 |
IDIAG_SS_CLOSE = 7, /* TCP_CLOSE */ |
| 46 |
IDIAG_SS_CLOSE_WAIT = 8, /* TCP_CLOSE_WAIT */ |
| 47 |
IDIAG_SS_LAST_ACK = 9, /* TCP_LAST_ACK */ |
| 48 |
IDIAG_SS_LISTEN = 10, /* TCP_LISTEN */ |
| 49 |
IDIAG_SS_CLOSING = 11, /* TCP_CLOSING */ |
| 50 |
|
| 51 |
IDIAG_SS_MAX = 12, |
| 52 |
}; |
| 53 |
|
| 54 |
/** |
| 55 |
* Macro to represent all socket states. |
| 56 |
* @ingroup idiag |
| 57 |
* @deprecated |
| 58 |
*/ |
| 59 |
#define IDIAG_SS_ALL IDIAGNL_SS_ALL |
| 60 |
|
| 61 |
|
| 62 |
/** |
| 63 |
* Inet Diag extended attributes |
| 64 |
* @ingroup idiag |
| 65 |
* @deprecated These attributes should not be used. They mirror the |
| 66 |
* INET_DIAG_* extension flags from kernel headers. Use those instead. */ |
| 67 |
enum { |
| 68 |
IDIAG_ATTR_NONE = 0, /* INET_DIAG_NONE */ |
| 69 |
IDIAG_ATTR_MEMINFO = 1, /* INET_DIAG_MEMINFO */ |
| 70 |
IDIAG_ATTR_INFO = 2, /* INET_DIAG_INFO */ |
| 71 |
IDIAG_ATTR_VEGASINFO = 3, /* INET_DIAG_VEGASINFO */ |
| 72 |
IDIAG_ATTR_CONG = 4, /* INET_DIAG_CONG */ |
| 73 |
IDIAG_ATTR_TOS = 5, /* INET_DIAG_TOS */ |
| 74 |
IDIAG_ATTR_TCLASS = 6, /* INET_DIAG_TCLASS */ |
| 75 |
IDIAG_ATTR_SKMEMINFO = 7, /* INET_DIAG_SKMEMINFO */ |
| 76 |
IDIAG_ATTR_SHUTDOWN = 8, /* INET_DIAG_SHUTDOWN */ |
| 77 |
|
| 78 |
/* IDIAG_ATTR_MAX was wrong, because it did not correspond to |
| 79 |
* INET_DIAG_MAX. Anyway, freeze it to the previous value. */ |
| 80 |
IDIAG_ATTR_MAX = 9, |
| 81 |
|
| 82 |
IDIAG_ATTR_ALL = (1<<IDIAG_ATTR_MAX) - 1, |
| 83 |
}; |
| 84 |
|
| 85 |
|
| 86 |
/* deprectated keep these only for compatibility, DO NOT USE THEM */ |
| 87 |
#define IDIAG_SK_MEMINFO_RMEM_ALLOC 0 /* SK_MEMINFO_RMEM_ALLOC */ |
| 88 |
#define IDIAG_SK_MEMINFO_RCVBUF 1 /* SK_MEMINFO_RCVBUF */ |
| 89 |
#define IDIAG_SK_MEMINFO_WMEM_ALLOC 2 /* SK_MEMINFO_WMEM_ALLOC */ |
| 90 |
#define IDIAG_SK_MEMINFO_SNDBUF 3 /* SK_MEMINFO_SNDBUF */ |
| 91 |
#define IDIAG_SK_MEMINFO_FWD_ALLOC 4 /* SK_MEMINFO_FWD_ALLOC */ |
| 92 |
#define IDIAG_SK_MEMINFO_WMEM_QUEUED 5 /* SK_MEMINFO_WMEM_QUEUED */ |
| 93 |
#define IDIAG_SK_MEMINFO_OPTMEM 6 /* SK_MEMINFO_OPTMEM */ |
| 94 |
#define IDIAG_SK_MEMINFO_BACKLOG 7 /* SK_MEMINFO_BACKLOG */ |
| 95 |
#define IDIAG_SK_MEMINFO_VARS SK_MEMINFO_VARS |
| 96 |
|
| 97 |
/* deprecated names. */ |
| 98 |
#define IDIAG_TIMER_OFF IDIAGNL_TIMER_OFF |
| 99 |
#define IDIAG_TIMER_ON IDIAGNL_TIMER_ON |
| 100 |
#define IDIAG_TIMER_KEEPALIVE IDIAGNL_TIMER_KEEPALIVE |
| 101 |
#define IDIAG_TIMER_TIMEWAIT IDIAGNL_TIMER_TIMEWAIT |
| 102 |
#define IDIAG_TIMER_PERSIST IDIAGNL_TIMER_PERSIST |
| 103 |
#define IDIAG_TIMER_UNKNOWN IDIAGNL_TIMER_UNKNOWN |
| 104 |
|
| 105 |
/*************************************************************/ |
| 106 |
|
| 107 |
/** |
| 108 |
* Macro to represent all socket states. |
| 109 |
* @ingroup idiag |
| 110 |
*/ |
| 111 |
#define IDIAGNL_SS_ALL (((1<<12)-1)) |
| 112 |
|
| 113 |
/** |
| 114 |
* Socket timer indentifiers |
| 115 |
* @ingroupd idiag |
| 116 |
*/ |
| 117 |
enum { |
| 118 |
IDIAGNL_TIMER_OFF = 0, |
| 119 |
IDIAGNL_TIMER_ON = 1, |
| 120 |
IDIAGNL_TIMER_KEEPALIVE = 2, |
| 121 |
IDIAGNL_TIMER_TIMEWAIT = 3, |
| 122 |
IDIAGNL_TIMER_PERSIST = 4, |
| 123 |
IDIAGNL_TIMER_UNKNOWN = 5, |
| 124 |
}; |
| 125 |
|
| 126 |
extern char * idiagnl_state2str(int, char *, size_t); |
| 127 |
extern int idiagnl_str2state(const char *); |
| 128 |
|
| 129 |
extern int idiagnl_connect(struct nl_sock *); |
| 130 |
extern int idiagnl_send_simple(struct nl_sock *, int, uint8_t, uint16_t, |
| 131 |
uint16_t); |
| 132 |
|
| 133 |
extern char * idiagnl_timer2str(int, char *, size_t); |
| 134 |
extern int idiagnl_str2timer(const char *); |
| 135 |
extern char * idiagnl_attrs2str(int, char *, size_t); |
| 136 |
extern char * idiagnl_tcpstate2str(uint8_t, char *, size_t); |
| 137 |
extern char * idiagnl_tcpopts2str(uint8_t, char *, size_t); |
| 138 |
extern char * idiagnl_shutdown2str(uint8_t, char *, size_t); |
| 139 |
extern char * idiagnl_exts2str(uint8_t, char *, size_t); |
| 140 |
|
| 141 |
#ifdef __cplusplus |
| 142 |
} |
| 143 |
#endif /* __cplusplus */ |
| 144 |
|
| 145 |
#endif /* NETLINK_IDIAGNL_H_ */ |