inet_diag.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 INET_DIAG_GETSOCK_MAX 24
  8. /* Socket identity */
  9. struct inet_diag_sockid {
  10. __be16 idiag_sport;
  11. __be16 idiag_dport;
  12. __be32 idiag_src[4];
  13. __be32 idiag_dst[4];
  14. __u32 idiag_if;
  15. __u32 idiag_cookie[2];
  16. #define INET_DIAG_NOCOOKIE (~0U)
  17. };
  18. /* Request structure */
  19. struct inet_diag_req {
  20. __u8 idiag_family; /* Family of addresses. */
  21. __u8 idiag_src_len;
  22. __u8 idiag_dst_len;
  23. __u8 idiag_ext; /* Query extended information */
  24. struct inet_diag_sockid id;
  25. __u32 idiag_states; /* States to dump */
  26. __u32 idiag_dbs; /* Tables to dump (NI) */
  27. };
  28. struct inet_diag_req_v2 {
  29. __u8 sdiag_family;
  30. __u8 sdiag_protocol;
  31. __u8 idiag_ext;
  32. __u8 pad;
  33. __u32 idiag_states;
  34. struct inet_diag_sockid id;
  35. };
  36. enum {
  37. INET_DIAG_REQ_NONE,
  38. INET_DIAG_REQ_BYTECODE,
  39. };
  40. #define INET_DIAG_REQ_MAX INET_DIAG_REQ_BYTECODE
  41. /* Bytecode is sequence of 4 byte commands followed by variable arguments.
  42. * All the commands identified by "code" are conditional jumps forward:
  43. * to offset cc+"yes" or to offset cc+"no". "yes" is supposed to be
  44. * length of the command and its arguments.
  45. */
  46. struct inet_diag_bc_op {
  47. unsigned char code;
  48. unsigned char yes;
  49. unsigned short no;
  50. };
  51. enum {
  52. INET_DIAG_BC_NOP,
  53. INET_DIAG_BC_JMP,
  54. INET_DIAG_BC_S_GE,
  55. INET_DIAG_BC_S_LE,
  56. INET_DIAG_BC_D_GE,
  57. INET_DIAG_BC_D_LE,
  58. INET_DIAG_BC_AUTO,
  59. INET_DIAG_BC_S_COND,
  60. INET_DIAG_BC_D_COND,
  61. };
  62. struct inet_diag_hostcond {
  63. __u8 family;
  64. __u8 prefix_len;
  65. int port;
  66. __be32 addr[0];
  67. };
  68. /* Base info structure. It contains socket identity (addrs/ports/cookie)
  69. * and, alas, the information shown by netstat. */
  70. struct inet_diag_msg {
  71. __u8 idiag_family;
  72. __u8 idiag_state;
  73. __u8 idiag_timer;
  74. __u8 idiag_retrans;
  75. struct inet_diag_sockid id;
  76. __u32 idiag_expires;
  77. __u32 idiag_rqueue;
  78. __u32 idiag_wqueue;
  79. __u32 idiag_uid;
  80. __u32 idiag_inode;
  81. };
  82. /* Extensions */
  83. enum {
  84. INET_DIAG_NONE,
  85. INET_DIAG_MEMINFO,
  86. INET_DIAG_INFO,
  87. INET_DIAG_VEGASINFO,
  88. INET_DIAG_CONG,
  89. INET_DIAG_TOS,
  90. INET_DIAG_TCLASS,
  91. INET_DIAG_SKMEMINFO,
  92. INET_DIAG_SHUTDOWN,
  93. };
  94. #define INET_DIAG_MAX INET_DIAG_SHUTDOWN
  95. /* INET_DIAG_MEM */
  96. struct inet_diag_meminfo {
  97. __u32 idiag_rmem;
  98. __u32 idiag_wmem;
  99. __u32 idiag_fmem;
  100. __u32 idiag_tmem;
  101. };
  102. /* INET_DIAG_VEGASINFO */
  103. struct tcpvegas_info {
  104. __u32 tcpv_enabled;
  105. __u32 tcpv_rttcnt;
  106. __u32 tcpv_rtt;
  107. __u32 tcpv_minrtt;
  108. };
  109. #ifdef __KERNEL__
  110. struct net;
  111. struct sock;
  112. struct inet_hashinfo;
  113. struct nlattr;
  114. struct nlmsghdr;
  115. struct sk_buff;
  116. struct netlink_callback;
  117. struct inet_diag_handler {
  118. void (*dump)(struct sk_buff *skb,
  119. struct netlink_callback *cb,
  120. struct inet_diag_req_v2 *r,
  121. struct nlattr *bc);
  122. int (*dump_one)(struct sk_buff *in_skb,
  123. const struct nlmsghdr *nlh,
  124. struct inet_diag_req_v2 *req);
  125. void (*idiag_get_info)(struct sock *sk,
  126. struct inet_diag_msg *r,
  127. void *info);
  128. int (*destroy)(struct sk_buff *in_skb,
  129. struct inet_diag_req_v2 *req);
  130. __u16 idiag_type;
  131. };
  132. struct inet_connection_sock;
  133. int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
  134. struct sk_buff *skb, struct inet_diag_req_v2 *req,
  135. u32 pid, u32 seq, u16 nlmsg_flags,
  136. const struct nlmsghdr *unlh);
  137. void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
  138. struct netlink_callback *cb, struct inet_diag_req_v2 *r,
  139. struct nlattr *bc);
  140. int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
  141. struct sk_buff *in_skb, const struct nlmsghdr *nlh,
  142. struct inet_diag_req_v2 *req);
  143. struct sock *inet_diag_find_one_icsk(struct net *net,
  144. struct inet_hashinfo *hashinfo,
  145. struct inet_diag_req_v2 *req);
  146. int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
  147. extern int inet_diag_register(const struct inet_diag_handler *handler);
  148. extern void inet_diag_unregister(const struct inet_diag_handler *handler);
  149. #endif /* __KERNEL__ */
  150. #endif /* _INET_DIAG_H_ */