1 /* 2 * netlink/idiag/idiagnl.h Inetdiag Netlink 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation version 2.1 7 * of the License. 8 * 9 * Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com> 10 */ 11 12 #ifndef NETLINK_IDIAGNL_H_ 13 #define NETLINK_IDIAGNL_H_ 14 15 #include <netlink/netlink.h> 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /** 22 * Inet Diag message types 23 */ 24 #define IDIAG_TCPDIAG_GETSOCK 18 25 #define IDIAG_DCCPDIAG_GETSOCK 19 26 #define IDIAG_GETSOCK_MAX 24 27 28 /** 29 * Socket state identifiers 30 * @ingroup idiag 31 */ 32 enum { 33 IDIAG_SS_UNKNOWN, 34 IDIAG_SS_ESTABLISHED, 35 IDIAG_SS_SYN_SENT, 36 IDIAG_SS_SYN_RECV, 37 IDIAG_SS_FIN_WAIT1, 38 IDIAG_SS_FIN_WAIT2, 39 IDIAG_SS_TIME_WAIT, 40 IDIAG_SS_CLOSE, 41 IDIAG_SS_CLOSE_WAIT, 42 IDIAG_SS_LAST_ACK, 43 IDIAG_SS_LISTEN, 44 IDIAG_SS_CLOSING, 45 IDIAG_SS_MAX 46 }; 47 48 /** 49 * Macro to represent all socket states. 50 * @ingroup idiag 51 */ 52 #define IDIAG_SS_ALL ((1<<IDIAG_SS_MAX)-1) 53 54 /** 55 * Inet Diag extended attributes 56 * @ingroup idiag 57 */ 58 enum { 59 IDIAG_ATTR_NONE, 60 IDIAG_ATTR_MEMINFO, 61 IDIAG_ATTR_INFO, 62 IDIAG_ATTR_VEGASINFO, 63 IDIAG_ATTR_CONG, 64 IDIAG_ATTR_TOS, 65 IDIAG_ATTR_TCLASS, 66 IDIAG_ATTR_SKMEMINFO, 67 IDIAG_ATTR_SHUTDOWN, 68 IDIAG_ATTR_MAX, 69 }; 70 71 /** 72 * Macro to represent all socket attributes. 73 * @ingroup idiag 74 */ 75 #define IDIAG_ATTR_ALL ((1<<IDIAG_ATTR_MAX)-1) 76 77 /** 78 * Socket memory info identifiers 79 * @ingroup idiag 80 */ 81 enum { 82 IDIAG_SK_MEMINFO_RMEM_ALLOC, 83 IDIAG_SK_MEMINFO_RCVBUF, 84 IDIAG_SK_MEMINFO_WMEM_ALLOC, 85 IDIAG_SK_MEMINFO_SNDBUF, 86 IDIAG_SK_MEMINFO_FWD_ALLOC, 87 IDIAG_SK_MEMINFO_WMEM_QUEUED, 88 IDIAG_SK_MEMINFO_OPTMEM, 89 IDIAG_SK_MEMINFO_BACKLOG, 90 91 IDIAG_SK_MEMINFO_VARS, 92 }; 93 94 /** 95 * Socket timer indentifiers 96 * @ingroupd idiag 97 */ 98 enum { 99 IDIAG_TIMER_OFF, 100 IDIAG_TIMER_ON, 101 IDIAG_TIMER_KEEPALIVE, 102 IDIAG_TIMER_TIMEWAIT, 103 IDIAG_TIMER_PERSIST, 104 IDIAG_TIMER_UNKNOWN, 105 }; 106 107 extern char * idiagnl_state2str(int, char *, size_t); 108 extern int idiagnl_str2state(const char *); 109 110 extern int idiagnl_connect(struct nl_sock *); 111 extern int idiagnl_send_simple(struct nl_sock *, int, uint8_t, uint16_t, 112 uint16_t); 113 114 extern char * idiagnl_timer2str(int, char *, size_t); 115 extern int idiagnl_str2timer(const char *); 116 extern char * idiagnl_attrs2str(int, char *, size_t); 117 extern char * idiagnl_tcpstate2str(uint8_t, char *, size_t); 118 extern char * idiagnl_tcpopts2str(uint8_t, char *, size_t); 119 extern char * idiagnl_shutdown2str(uint8_t, char *, size_t); 120 extern char * idiagnl_exts2str(uint8_t, char *, size_t); 121 122 #ifdef __cplusplus 123 } 124 #endif /* __cplusplus */ 125 126 #endif /* NETLINK_IDIAGNL_H_ */ 127