af_netlink.h 1.3 KB

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