crypto: atmel-sha - remove unnecessary static in atmel_sha_remove()
[linux-stable.git] / include / linux / sock_diag.h
bloba2f8109bb215751427e99b3c026badfe7113b875
1 #ifndef __SOCK_DIAG_H__
2 #define __SOCK_DIAG_H__
4 #include <linux/netlink.h>
5 #include <linux/user_namespace.h>
6 #include <net/net_namespace.h>
7 #include <net/sock.h>
8 #include <uapi/linux/sock_diag.h>
10 struct sk_buff;
11 struct nlmsghdr;
12 struct sock;
14 struct sock_diag_handler {
15 __u8 family;
16 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
17 int (*get_info)(struct sk_buff *skb, struct sock *sk);
18 int (*destroy)(struct sk_buff *skb, struct nlmsghdr *nlh);
21 int sock_diag_register(const struct sock_diag_handler *h);
22 void sock_diag_unregister(const struct sock_diag_handler *h);
24 void sock_diag_register_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh));
25 void sock_diag_unregister_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh));
27 u64 sock_gen_cookie(struct sock *sk);
28 int sock_diag_check_cookie(struct sock *sk, const __u32 *cookie);
29 void sock_diag_save_cookie(struct sock *sk, __u32 *cookie);
31 int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attr);
32 int sock_diag_put_filterinfo(bool may_report_filterinfo, struct sock *sk,
33 struct sk_buff *skb, int attrtype);
35 static inline
36 enum sknetlink_groups sock_diag_destroy_group(const struct sock *sk)
38 switch (sk->sk_family) {
39 case AF_INET:
40 if (sk->sk_type == SOCK_RAW)
41 return SKNLGRP_NONE;
43 switch (sk->sk_protocol) {
44 case IPPROTO_TCP:
45 return SKNLGRP_INET_TCP_DESTROY;
46 case IPPROTO_UDP:
47 return SKNLGRP_INET_UDP_DESTROY;
48 default:
49 return SKNLGRP_NONE;
51 case AF_INET6:
52 if (sk->sk_type == SOCK_RAW)
53 return SKNLGRP_NONE;
55 switch (sk->sk_protocol) {
56 case IPPROTO_TCP:
57 return SKNLGRP_INET6_TCP_DESTROY;
58 case IPPROTO_UDP:
59 return SKNLGRP_INET6_UDP_DESTROY;
60 default:
61 return SKNLGRP_NONE;
63 default:
64 return SKNLGRP_NONE;
68 static inline
69 bool sock_diag_has_destroy_listeners(const struct sock *sk)
71 const struct net *n = sock_net(sk);
72 const enum sknetlink_groups group = sock_diag_destroy_group(sk);
74 return group != SKNLGRP_NONE && n->diag_nlsk &&
75 netlink_has_listeners(n->diag_nlsk, group);
77 void sock_diag_broadcast_destroy(struct sock *sk);
79 int sock_diag_destroy(struct sock *sk, int err);
80 #endif