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