inet_diag.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _INET_DIAG_H_
  3. #define _INET_DIAG_H_ 1
  4. #include <net/netlink.h>
  5. #include <uapi/linux/inet_diag.h>
  6. struct inet_hashinfo;
  7. struct inet_diag_handler {
  8. void (*dump)(struct sk_buff *skb,
  9. struct netlink_callback *cb,
  10. const struct inet_diag_req_v2 *r,
  11. struct nlattr *bc);
  12. int (*dump_one)(struct sk_buff *in_skb,
  13. const struct nlmsghdr *nlh,
  14. const struct inet_diag_req_v2 *req);
  15. void (*idiag_get_info)(struct sock *sk,
  16. struct inet_diag_msg *r,
  17. void *info);
  18. int (*idiag_get_aux)(struct sock *sk,
  19. bool net_admin,
  20. struct sk_buff *skb);
  21. size_t (*idiag_get_aux_size)(struct sock *sk,
  22. bool net_admin);
  23. int (*destroy)(struct sk_buff *in_skb,
  24. const struct inet_diag_req_v2 *req);
  25. __u16 idiag_type;
  26. __u16 idiag_info_size;
  27. };
  28. struct inet_connection_sock;
  29. int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
  30. struct sk_buff *skb, const struct inet_diag_req_v2 *req,
  31. struct user_namespace *user_ns,
  32. u32 pid, u32 seq, u16 nlmsg_flags,
  33. const struct nlmsghdr *unlh, bool net_admin);
  34. void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
  35. struct netlink_callback *cb,
  36. const struct inet_diag_req_v2 *r,
  37. struct nlattr *bc);
  38. int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
  39. struct sk_buff *in_skb, const struct nlmsghdr *nlh,
  40. const struct inet_diag_req_v2 *req);
  41. struct sock *inet_diag_find_one_icsk(struct net *net,
  42. struct inet_hashinfo *hashinfo,
  43. const struct inet_diag_req_v2 *req);
  44. int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
  45. void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
  46. static inline size_t inet_diag_msg_attrs_size(void)
  47. {
  48. return nla_total_size(1) /* INET_DIAG_SHUTDOWN */
  49. + nla_total_size(1) /* INET_DIAG_TOS */
  50. #if IS_ENABLED(CONFIG_IPV6)
  51. + nla_total_size(1) /* INET_DIAG_TCLASS */
  52. + nla_total_size(1) /* INET_DIAG_SKV6ONLY */
  53. #endif
  54. + nla_total_size(4) /* INET_DIAG_MARK */
  55. + nla_total_size(4); /* INET_DIAG_CLASS_ID */
  56. }
  57. int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
  58. struct inet_diag_msg *r, int ext,
  59. struct user_namespace *user_ns, bool net_admin);
  60. extern int inet_diag_register(const struct inet_diag_handler *handler);
  61. extern void inet_diag_unregister(const struct inet_diag_handler *handler);
  62. #endif /* _INET_DIAG_H_ */