Commit | Line | Data |
---|---|---|
0f29c768 AV |
1 | #ifndef _AF_NETLINK_H |
2 | #define _AF_NETLINK_H | |
3 | ||
e341694e | 4 | #include <linux/rhashtable.h> |
ee1c2442 | 5 | #include <linux/atomic.h> |
0f29c768 AV |
6 | #include <net/sock.h> |
7 | ||
8 | #define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8) | |
9 | #define NLGRPLONGS(x) (NLGRPSZ(x)/sizeof(unsigned long)) | |
10 | ||
11 | struct netlink_sock { | |
12 | /* struct sock has to be the first member of netlink_sock */ | |
13 | struct sock sk; | |
14 | u32 portid; | |
15 | u32 dst_portid; | |
16 | u32 dst_group; | |
17 | u32 flags; | |
18 | u32 subscriptions; | |
19 | u32 ngroups; | |
20 | unsigned long *groups; | |
21 | unsigned long state; | |
9063e21f | 22 | size_t max_recvmsg_len; |
0f29c768 | 23 | wait_queue_head_t wait; |
da314c99 | 24 | bool bound; |
16b304f3 PS |
25 | bool cb_running; |
26 | struct netlink_callback cb; | |
0f29c768 AV |
27 | struct mutex *cb_mutex; |
28 | struct mutex cb_def_mutex; | |
29 | void (*netlink_rcv)(struct sk_buff *skb); | |
023e2cfa JB |
30 | int (*netlink_bind)(struct net *net, int group); |
31 | void (*netlink_unbind)(struct net *net, int group); | |
0f29c768 | 32 | struct module *module; |
e341694e TG |
33 | |
34 | struct rhash_head node; | |
21e4902a | 35 | struct rcu_head rcu; |
0f29c768 AV |
36 | }; |
37 | ||
38 | static inline struct netlink_sock *nlk_sk(struct sock *sk) | |
39 | { | |
40 | return container_of(sk, struct netlink_sock, sk); | |
41 | } | |
42 | ||
0f29c768 | 43 | struct netlink_table { |
e341694e | 44 | struct rhashtable hash; |
0f29c768 AV |
45 | struct hlist_head mc_list; |
46 | struct listeners __rcu *listeners; | |
47 | unsigned int flags; | |
48 | unsigned int groups; | |
49 | struct mutex *cb_mutex; | |
50 | struct module *module; | |
023e2cfa JB |
51 | int (*bind)(struct net *net, int group); |
52 | void (*unbind)(struct net *net, int group); | |
da12c90e | 53 | bool (*compare)(struct net *net, struct sock *sock); |
0f29c768 AV |
54 | int registered; |
55 | }; | |
56 | ||
57 | extern struct netlink_table *nl_table; | |
58 | extern rwlock_t nl_table_lock; | |
59 | ||
60 | #endif |