inet_diag.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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_compat {
  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. struct inet_diag_req {
  30. __u8 sdiag_family;
  31. __u8 sdiag_protocol;
  32. __u8 idiag_ext;
  33. __u8 pad;
  34. __u32 idiag_states;
  35. struct inet_diag_sockid id;
  36. };
  37. enum {
  38. INET_DIAG_REQ_NONE,
  39. INET_DIAG_REQ_BYTECODE,
  40. };
  41. #define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE
  42. /* Bytecode is sequence of 4 byte commands followed by variable arguments.
  43. * All the commands identified by "code" are conditional jumps forward:
  44. * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be
  45. * length of the command and its arguments.
  46. */
  47. struct inet_diag_bc_op {
  48. unsigned char code;
  49. unsigned char yes;
  50. unsigned short no;
  51. };
  52. enum {
  53. INET_DIAG_BC_NOP,
  54. INET_DIAG_BC_JMP,
  55. INET_DIAG_BC_S_GE,
  56. INET_DIAG_BC_S_LE,
  57. INET_DIAG_BC_D_GE,
  58. INET_DIAG_BC_D_LE,
  59. INET_DIAG_BC_AUTO,
  60. INET_DIAG_BC_S_COND,
  61. INET_DIAG_BC_D_COND,
  62. };
  63. struct inet_diag_hostcond {
  64. __u8 family;
  65. __u8 prefix_len;
  66. int port;
  67. __be32 addr[0];
  68. };
  69. /* Base info structure. It contains socket identity (addrs/ports/cookie)
  70. * and, alas, the information shown by netstat. */
  71. struct inet_diag_msg {
  72. __u8 idiag_family;
  73. __u8 idiag_state;
  74. __u8 idiag_timer;
  75. __u8 idiag_retrans;
  76. struct inet_diag_sockid id;
  77. __u32 idiag_expires;
  78. __u32 idiag_rqueue;
  79. __u32 idiag_wqueue;
  80. __u32 idiag_uid;
  81. __u32 idiag_inode;
  82. };
  83. /* Extensions */
  84. enum {
  85. INET_DIAG_NONE,
  86. INET_DIAG_MEMINFO,
  87. INET_DIAG_INFO,
  88. INET_DIAG_VEGASINFO,
  89. INET_DIAG_CONG,
  90. INET_DIAG_TOS,
  91. INET_DIAG_TCLASS,
  92. };
  93. #define INET_DIAG_MAX INET_DIAG_TCLASS
  94. /* INET_DIAG_MEM */
  95. struct inet_diag_meminfo {
  96. __u32 idiag_rmem;
  97. __u32 idiag_wmem;
  98. __u32 idiag_fmem;
  99. __u32 idiag_tmem;
  100. };
  101. /* INET_DIAG_VEGASINFO */
  102. struct tcpvegas_info {
  103. __u32 tcpv_enabled;
  104. __u32 tcpv_rttcnt;
  105. __u32 tcpv_rtt;
  106. __u32 tcpv_minrtt;
  107. };
  108. #ifdef __KERNEL__
  109. struct sock;
  110. struct inet_hashinfo;
  111. struct nlattr;
  112. struct nlmsghdr;
  113. struct sk_buff;
  114. struct inet_diag_handler {
  115. struct inet_hashinfo *idiag_hashinfo;
  116. void (*idiag_get_info)(struct sock *sk,
  117. struct inet_diag_msg *r,
  118. void *info);
  119. __u16 idiag_type;
  120. };
  121. struct inet_connection_sock;
  122. int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
  123. struct sk_buff *skb, struct inet_diag_req *req,
  124. u32 pid, u32 seq, u16 nlmsg_flags,
  125. const struct nlmsghdr *unlh);
  126. int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
  127. int inet_diag_check_cookie(struct sock *sk, struct inet_diag_req *req);
  128. extern int inet_diag_register(const struct inet_diag_handler *handler);
  129. extern void inet_diag_unregister(const struct inet_diag_handler *handler);
  130. #endif /* __KERNEL__ */
  131. #endif /* _INET_DIAG_H_ */