blob: ee251c585854ca09978bba226dca23fd31534b9e [file] [log] [blame]
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -03001#ifndef _INET_DIAG_H_
2#define _INET_DIAG_H_ 1
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
David Howells607ca462012-10-13 10:46:48 +01004#include <uapi/linux/inet_diag.h>
Jaswinder Singh Rajput2df005b2009-01-30 21:42:47 +05305
Lorenzo Colittib613f562015-12-16 12:30:02 +09006struct net;
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -03007struct sock;
8struct inet_hashinfo;
Pavel Emelyanov8d07d152011-12-09 06:22:44 +00009struct nlattr;
Pavel Emelyanov3c4d05c2011-12-09 06:23:00 +000010struct nlmsghdr;
11struct sk_buff;
Pavel Emelyanov1942c512011-12-09 06:23:18 +000012struct netlink_callback;
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -030013
14struct inet_diag_handler {
Eric Dumazet34160ea2015-03-10 07:15:54 -070015 void (*dump)(struct sk_buff *skb,
16 struct netlink_callback *cb,
17 const struct inet_diag_req_v2 *r,
18 struct nlattr *bc);
Pavel Emelyanov1942c512011-12-09 06:23:18 +000019
Eric Dumazet34160ea2015-03-10 07:15:54 -070020 int (*dump_one)(struct sk_buff *in_skb,
21 const struct nlmsghdr *nlh,
22 const struct inet_diag_req_v2 *req);
Pavel Emelyanov1942c512011-12-09 06:23:18 +000023
Eric Dumazet34160ea2015-03-10 07:15:54 -070024 void (*idiag_get_info)(struct sock *sk,
25 struct inet_diag_msg *r,
26 void *info);
Lorenzo Colitti6eb5d2e2015-12-16 12:30:04 +090027
Ivan Delalandeb37e8842017-08-31 09:59:38 -070028 int (*idiag_get_aux)(struct sock *sk,
29 bool net_admin,
30 struct sk_buff *skb);
31
32 size_t (*idiag_get_aux_size)(struct sock *sk,
33 bool net_admin);
34
Lorenzo Colitti6eb5d2e2015-12-16 12:30:04 +090035 int (*destroy)(struct sk_buff *in_skb,
36 const struct inet_diag_req_v2 *req);
37
Eric Dumazet34160ea2015-03-10 07:15:54 -070038 __u16 idiag_type;
Craig Gallek3fd22af2015-06-15 11:26:19 -040039 __u16 idiag_info_size;
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -030040};
41
Pavel Emelyanov3c4d05c2011-12-09 06:23:00 +000042struct inet_connection_sock;
43int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
Eric Dumazet34160ea2015-03-10 07:15:54 -070044 struct sk_buff *skb, const struct inet_diag_req_v2 *req,
45 struct user_namespace *user_ns,
46 u32 pid, u32 seq, u16 nlmsg_flags,
Lorenzo Colittid545cac2016-09-08 00:42:25 +090047 const struct nlmsghdr *unlh, bool net_admin);
Pavel Emelyanov1942c512011-12-09 06:23:18 +000048void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
Eric Dumazet34160ea2015-03-10 07:15:54 -070049 struct netlink_callback *cb,
50 const struct inet_diag_req_v2 *r,
51 struct nlattr *bc);
Pavel Emelyanov1942c512011-12-09 06:23:18 +000052int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
Eric Dumazet34160ea2015-03-10 07:15:54 -070053 struct sk_buff *in_skb, const struct nlmsghdr *nlh,
54 const struct inet_diag_req_v2 *req);
Pavel Emelyanov1942c512011-12-09 06:23:18 +000055
Lorenzo Colittib613f562015-12-16 12:30:02 +090056struct sock *inet_diag_find_one_icsk(struct net *net,
57 struct inet_hashinfo *hashinfo,
58 const struct inet_diag_req_v2 *req);
59
Pavel Emelyanov8d07d152011-12-09 06:22:44 +000060int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
Pavel Emelyanovb005ab42011-12-09 06:21:53 +000061
Ben Dooksc3ec5e52016-06-09 18:05:09 +010062void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
63
64int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
65 struct inet_diag_msg *r, int ext,
Lorenzo Colittid545cac2016-09-08 00:42:25 +090066 struct user_namespace *user_ns, bool net_admin);
Ben Dooksc3ec5e52016-06-09 18:05:09 +010067
Arnaldo Carvalho de Melo4f5736c2005-08-12 09:27:49 -030068extern int inet_diag_register(const struct inet_diag_handler *handler);
69extern void inet_diag_unregister(const struct inet_diag_handler *handler);
Arnaldo Carvalho de Melo73c1f4a2005-08-12 12:51:49 -030070#endif /* _INET_DIAG_H_ */