idiagnl.h 4.8 KB

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