Andrey Vagin | 0f29c76 | 2013-03-21 20:33:47 +0400 | [diff] [blame^] | 1 | #ifndef _AF_NETLINK_H |
| 2 | #define _AF_NETLINK_H |
| 3 | |
| 4 | #include <net/sock.h> |
| 5 | |
| 6 | #define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8) |
| 7 | #define NLGRPLONGS(x) (NLGRPSZ(x)/sizeof(unsigned long)) |
| 8 | |
| 9 | struct netlink_sock { |
| 10 | /* struct sock has to be the first member of netlink_sock */ |
| 11 | struct sock sk; |
| 12 | u32 portid; |
| 13 | u32 dst_portid; |
| 14 | u32 dst_group; |
| 15 | u32 flags; |
| 16 | u32 subscriptions; |
| 17 | u32 ngroups; |
| 18 | unsigned long *groups; |
| 19 | unsigned long state; |
| 20 | wait_queue_head_t wait; |
| 21 | struct netlink_callback *cb; |
| 22 | struct mutex *cb_mutex; |
| 23 | struct mutex cb_def_mutex; |
| 24 | void (*netlink_rcv)(struct sk_buff *skb); |
| 25 | void (*netlink_bind)(int group); |
| 26 | struct module *module; |
| 27 | }; |
| 28 | |
| 29 | static inline struct netlink_sock *nlk_sk(struct sock *sk) |
| 30 | { |
| 31 | return container_of(sk, struct netlink_sock, sk); |
| 32 | } |
| 33 | |
| 34 | struct nl_portid_hash { |
| 35 | struct hlist_head *table; |
| 36 | unsigned long rehash_time; |
| 37 | |
| 38 | unsigned int mask; |
| 39 | unsigned int shift; |
| 40 | |
| 41 | unsigned int entries; |
| 42 | unsigned int max_shift; |
| 43 | |
| 44 | u32 rnd; |
| 45 | }; |
| 46 | |
| 47 | struct netlink_table { |
| 48 | struct nl_portid_hash hash; |
| 49 | struct hlist_head mc_list; |
| 50 | struct listeners __rcu *listeners; |
| 51 | unsigned int flags; |
| 52 | unsigned int groups; |
| 53 | struct mutex *cb_mutex; |
| 54 | struct module *module; |
| 55 | void (*bind)(int group); |
| 56 | int registered; |
| 57 | }; |
| 58 | |
| 59 | extern struct netlink_table *nl_table; |
| 60 | extern rwlock_t nl_table_lock; |
| 61 | |
| 62 | #endif |