inet_diag.h 2.7 KB

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