inet_diag.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #ifndef _INET_DIAG_H_
  2. #define _INET_DIAG_H_ 1
  3. #include <linux/types.h>
  4. /* Just some random number */
  5. #define TCPDIAG_GETSOCK 18
  6. #define DCCPDIAG_GETSOCK 19
  7. #define SOCK_DIAG_BY_FAMILY 20
  8. #define INET_DIAG_GETSOCK_MAX 24
  9. /* Socket identity */
  10. struct inet_diag_sockid {
  11. __be16 idiag_sport;
  12. __be16 idiag_dport;
  13. __be32 idiag_src[4];
  14. __be32 idiag_dst[4];
  15. __u32 idiag_if;
  16. __u32 idiag_cookie[2];
  17. #define INET_DIAG_NOCOOKIE (~0U)
  18. };
  19. /* Request structure */
  20. struct inet_diag_req {
  21. __u8 idiag_family; /* Family of addresses. */
  22. __u8 idiag_src_len;
  23. __u8 idiag_dst_len;
  24. __u8 idiag_ext; /* Query extended information */
  25. struct inet_diag_sockid id;
  26. __u32 idiag_states; /* States to dump */
  27. __u32 idiag_dbs; /* Tables to dump (NI) */
  28. };
  29. enum {
  30. INET_DIAG_REQ_NONE,
  31. INET_DIAG_REQ_BYTECODE,
  32. };
  33. #define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE
  34. /* Bytecode is sequence of 4 byte commands followed by variable arguments.
  35. * All the commands identified by "code" are conditional jumps forward:
  36. * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be
  37. * length of the command and its arguments.
  38. */
  39. struct inet_diag_bc_op {
  40. unsigned char code;
  41. unsigned char yes;
  42. unsigned short no;
  43. };
  44. enum {
  45. INET_DIAG_BC_NOP,
  46. INET_DIAG_BC_JMP,
  47. INET_DIAG_BC_S_GE,
  48. INET_DIAG_BC_S_LE,
  49. INET_DIAG_BC_D_GE,
  50. INET_DIAG_BC_D_LE,
  51. INET_DIAG_BC_AUTO,
  52. INET_DIAG_BC_S_COND,
  53. INET_DIAG_BC_D_COND,
  54. };
  55. struct inet_diag_hostcond {
  56. __u8 family;
  57. __u8 prefix_len;
  58. int port;
  59. __be32 addr[0];
  60. };
  61. /* Base info structure. It contains socket identity (addrs/ports/cookie)
  62. * and, alas, the information shown by netstat. */
  63. struct inet_diag_msg {
  64. __u8 idiag_family;
  65. __u8 idiag_state;
  66. __u8 idiag_timer;
  67. __u8 idiag_retrans;
  68. struct inet_diag_sockid id;
  69. __u32 idiag_expires;
  70. __u32 idiag_rqueue;
  71. __u32 idiag_wqueue;
  72. __u32 idiag_uid;
  73. __u32 idiag_inode;
  74. };
  75. /* Extensions */
  76. enum {
  77. INET_DIAG_NONE,
  78. INET_DIAG_MEMINFO,
  79. INET_DIAG_INFO,
  80. INET_DIAG_VEGASINFO,
  81. INET_DIAG_CONG,
  82. INET_DIAG_TOS,
  83. INET_DIAG_TCLASS,
  84. };
  85. #define INET_DIAG_MAX INET_DIAG_TCLASS
  86. /* INET_DIAG_MEM */
  87. struct inet_diag_meminfo {
  88. __u32 idiag_rmem;
  89. __u32 idiag_wmem;
  90. __u32 idiag_fmem;
  91. __u32 idiag_tmem;
  92. };
  93. /* INET_DIAG_VEGASINFO */
  94. struct tcpvegas_info {
  95. __u32 tcpv_enabled;
  96. __u32 tcpv_rttcnt;
  97. __u32 tcpv_rtt;
  98. __u32 tcpv_minrtt;
  99. };
  100. #ifdef __KERNEL__
  101. struct sock;
  102. struct inet_hashinfo;
  103. struct inet_diag_handler {
  104. struct inet_hashinfo *idiag_hashinfo;
  105. void (*idiag_get_info)(struct sock *sk,
  106. struct inet_diag_msg *r,
  107. void *info);
  108. __u16 idiag_info_size;
  109. __u16 idiag_type;
  110. };
  111. extern int inet_diag_register(const struct inet_diag_handler *handler);
  112. extern void inet_diag_unregister(const struct inet_diag_handler *handler);
  113. #endif /* __KERNEL__ */
  114. #endif /* _INET_DIAG_H_ */