af_netlink.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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_ring {
  7. void **pg_vec;
  8. unsigned int head;
  9. unsigned int frames_per_block;
  10. unsigned int frame_size;
  11. unsigned int frame_max;
  12. unsigned int pg_vec_order;
  13. unsigned int pg_vec_pages;
  14. unsigned int pg_vec_len;
  15. atomic_t pending;
  16. };
  17. struct netlink_sock {
  18. /* struct sock has to be the first member of netlink_sock */
  19. struct sock sk;
  20. u32 portid;
  21. u32 dst_portid;
  22. u32 dst_group;
  23. u32 flags;
  24. u32 subscriptions;
  25. u32 ngroups;
  26. unsigned long *groups;
  27. unsigned long state;
  28. wait_queue_head_t wait;
  29. struct netlink_callback *cb;
  30. struct mutex *cb_mutex;
  31. struct mutex cb_def_mutex;
  32. void (*netlink_rcv)(struct sk_buff *skb);
  33. void (*netlink_bind)(int group);
  34. struct module *module;
  35. #ifdef CONFIG_NETLINK_MMAP
  36. struct mutex pg_vec_lock;
  37. struct netlink_ring rx_ring;
  38. struct netlink_ring tx_ring;
  39. atomic_t mapped;
  40. #endif /* CONFIG_NETLINK_MMAP */
  41. };
  42. static inline struct netlink_sock *nlk_sk(struct sock *sk)
  43. {
  44. return container_of(sk, struct netlink_sock, sk);
  45. }
  46. struct nl_portid_hash {
  47. struct hlist_head *table;
  48. unsigned long rehash_time;
  49. unsigned int mask;
  50. unsigned int shift;
  51. unsigned int entries;
  52. unsigned int max_shift;
  53. u32 rnd;
  54. };
  55. struct netlink_table {
  56. struct nl_portid_hash hash;
  57. struct hlist_head mc_list;
  58. struct listeners __rcu *listeners;
  59. unsigned int flags;
  60. unsigned int groups;
  61. struct mutex *cb_mutex;
  62. struct module *module;
  63. void (*bind)(int group);
  64. int registered;
  65. };
  66. extern struct netlink_table *nl_table;
  67. extern rwlock_t nl_table_lock;
  68. #endif