tcp_diag.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef _TCP_DIAG_H_
  2. #define _TCP_DIAG_H_ 1
  3. /* Just some random number */
  4. #define TCPDIAG_GETSOCK 18
  5. #define DCCPDIAG_GETSOCK 19
  6. #define INET_DIAG_GETSOCK_MAX 24
  7. /* Socket identity */
  8. struct tcpdiag_sockid
  9. {
  10. __u16 tcpdiag_sport;
  11. __u16 tcpdiag_dport;
  12. __u32 tcpdiag_src[4];
  13. __u32 tcpdiag_dst[4];
  14. __u32 tcpdiag_if;
  15. __u32 tcpdiag_cookie[2];
  16. #define TCPDIAG_NOCOOKIE (~0U)
  17. };
  18. /* Request structure */
  19. struct tcpdiagreq
  20. {
  21. __u8 tcpdiag_family; /* Family of addresses. */
  22. __u8 tcpdiag_src_len;
  23. __u8 tcpdiag_dst_len;
  24. __u8 tcpdiag_ext; /* Query extended information */
  25. struct tcpdiag_sockid id;
  26. __u32 tcpdiag_states; /* States to dump */
  27. __u32 tcpdiag_dbs; /* Tables to dump (NI) */
  28. };
  29. enum
  30. {
  31. TCPDIAG_REQ_NONE,
  32. TCPDIAG_REQ_BYTECODE,
  33. };
  34. #define TCPDIAG_REQ_MAX TCPDIAG_REQ_BYTECODE
  35. /* Bytecode is sequence of 4 byte commands followed by variable arguments.
  36. * All the commands identified by "code" are conditional jumps forward:
  37. * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be
  38. * length of the command and its arguments.
  39. */
  40. struct tcpdiag_bc_op
  41. {
  42. unsigned char code;
  43. unsigned char yes;
  44. unsigned short no;
  45. };
  46. enum
  47. {
  48. TCPDIAG_BC_NOP,
  49. TCPDIAG_BC_JMP,
  50. TCPDIAG_BC_S_GE,
  51. TCPDIAG_BC_S_LE,
  52. TCPDIAG_BC_D_GE,
  53. TCPDIAG_BC_D_LE,
  54. TCPDIAG_BC_AUTO,
  55. TCPDIAG_BC_S_COND,
  56. TCPDIAG_BC_D_COND,
  57. };
  58. struct tcpdiag_hostcond
  59. {
  60. __u8 family;
  61. __u8 prefix_len;
  62. int port;
  63. __u32 addr[0];
  64. };
  65. /* Base info structure. It contains socket identity (addrs/ports/cookie)
  66. * and, alas, the information shown by netstat. */
  67. struct tcpdiagmsg
  68. {
  69. __u8 tcpdiag_family;
  70. __u8 tcpdiag_state;
  71. __u8 tcpdiag_timer;
  72. __u8 tcpdiag_retrans;
  73. struct tcpdiag_sockid id;
  74. __u32 tcpdiag_expires;
  75. __u32 tcpdiag_rqueue;
  76. __u32 tcpdiag_wqueue;
  77. __u32 tcpdiag_uid;
  78. __u32 tcpdiag_inode;
  79. };
  80. /* Extensions */
  81. enum
  82. {
  83. TCPDIAG_NONE,
  84. TCPDIAG_MEMINFO,
  85. TCPDIAG_INFO,
  86. TCPDIAG_VEGASINFO,
  87. TCPDIAG_CONG,
  88. };
  89. #define TCPDIAG_MAX TCPDIAG_CONG
  90. /* TCPDIAG_MEM */
  91. struct tcpdiag_meminfo
  92. {
  93. __u32 tcpdiag_rmem;
  94. __u32 tcpdiag_wmem;
  95. __u32 tcpdiag_fmem;
  96. __u32 tcpdiag_tmem;
  97. };
  98. /* TCPDIAG_VEGASINFO */
  99. struct tcpvegas_info {
  100. __u32 tcpv_enabled;
  101. __u32 tcpv_rttcnt;
  102. __u32 tcpv_rtt;
  103. __u32 tcpv_minrtt;
  104. };
  105. #ifdef __KERNEL__
  106. struct sock;
  107. struct inet_hashinfo;
  108. struct inet_diag_handler {
  109. struct inet_hashinfo *idiag_hashinfo;
  110. void (*idiag_get_info)(struct sock *sk,
  111. struct tcpdiagmsg *r,
  112. void *info);
  113. __u16 idiag_info_size;
  114. __u16 idiag_type;
  115. };
  116. extern int inet_diag_register(const struct inet_diag_handler *handler);
  117. extern void inet_diag_unregister(const struct inet_diag_handler *handler);
  118. #endif /* __KERNEL__ */
  119. #endif /* _TCP_DIAG_H_ */