core.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Wireless configuration interface internals.
  3. *
  4. * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
  5. */
  6. #ifndef __NET_WIRELESS_CORE_H
  7. #define __NET_WIRELESS_CORE_H
  8. #include <linux/mutex.h>
  9. #include <linux/list.h>
  10. #include <linux/netdevice.h>
  11. #include <linux/kref.h>
  12. #include <linux/rbtree.h>
  13. #include <net/genetlink.h>
  14. #include <net/wireless.h>
  15. #include <net/cfg80211.h>
  16. #include "reg.h"
  17. struct cfg80211_registered_device {
  18. struct cfg80211_ops *ops;
  19. struct list_head list;
  20. /* we hold this mutex during any call so that
  21. * we cannot do multiple calls at once, and also
  22. * to avoid the deregister call to proceed while
  23. * any call is in progress */
  24. struct mutex mtx;
  25. /* ISO / IEC 3166 alpha2 for which this device is receiving
  26. * country IEs on, this can help disregard country IEs from APs
  27. * on the same alpha2 quickly. The alpha2 may differ from
  28. * cfg80211_regdomain's alpha2 when an intersection has occurred.
  29. * If the AP is reconfigured this can also be used to tell us if
  30. * the country on the country IE changed. */
  31. char country_ie_alpha2[2];
  32. /* If a Country IE has been received this tells us the environment
  33. * which its telling us its in. This defaults to ENVIRON_ANY */
  34. enum environment_cap env;
  35. /* wiphy index, internal only */
  36. int wiphy_idx;
  37. /* associate netdev list */
  38. struct mutex devlist_mtx;
  39. struct list_head netdev_list;
  40. /* BSSes/scanning */
  41. spinlock_t bss_lock;
  42. struct list_head bss_list;
  43. struct rb_root bss_tree;
  44. u32 bss_generation;
  45. struct cfg80211_scan_request *scan_req; /* protected by RTNL */
  46. unsigned long suspend_at;
  47. /* must be last because of the way we do wiphy_priv(),
  48. * and it should at least be aligned to NETDEV_ALIGN */
  49. struct wiphy wiphy __attribute__((__aligned__(NETDEV_ALIGN)));
  50. };
  51. static inline
  52. struct cfg80211_registered_device *wiphy_to_dev(struct wiphy *wiphy)
  53. {
  54. BUG_ON(!wiphy);
  55. return container_of(wiphy, struct cfg80211_registered_device, wiphy);
  56. }
  57. extern struct mutex cfg80211_drv_mutex;
  58. extern struct list_head cfg80211_drv_list;
  59. struct cfg80211_internal_bss {
  60. struct list_head list;
  61. struct rb_node rbn;
  62. unsigned long ts;
  63. struct kref ref;
  64. /* must be last because of priv member */
  65. struct cfg80211_bss pub;
  66. };
  67. /*
  68. * This function returns a pointer to the driver
  69. * that the genl_info item that is passed refers to.
  70. * If successful, it returns non-NULL and also locks
  71. * the driver's mutex!
  72. *
  73. * This means that you need to call cfg80211_put_dev()
  74. * before being allowed to acquire &cfg80211_drv_mutex!
  75. *
  76. * This is necessary because we need to lock the global
  77. * mutex to get an item off the list safely, and then
  78. * we lock the drv mutex so it doesn't go away under us.
  79. *
  80. * We don't want to keep cfg80211_drv_mutex locked
  81. * for all the time in order to allow requests on
  82. * other interfaces to go through at the same time.
  83. *
  84. * The result of this can be a PTR_ERR and hence must
  85. * be checked with IS_ERR() for errors.
  86. */
  87. extern struct cfg80211_registered_device *
  88. cfg80211_get_dev_from_info(struct genl_info *info);
  89. /* identical to cfg80211_get_dev_from_info but only operate on ifindex */
  90. extern struct cfg80211_registered_device *
  91. cfg80211_get_dev_from_ifindex(int ifindex);
  92. extern void cfg80211_put_dev(struct cfg80211_registered_device *drv);
  93. /* free object */
  94. extern void cfg80211_dev_free(struct cfg80211_registered_device *drv);
  95. extern int cfg80211_dev_rename(struct cfg80211_registered_device *drv,
  96. char *newname);
  97. void ieee80211_set_bitrate_flags(struct wiphy *wiphy);
  98. void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby);
  99. void cfg80211_bss_expire(struct cfg80211_registered_device *dev);
  100. void cfg80211_bss_age(struct cfg80211_registered_device *dev,
  101. unsigned long age_secs);
  102. #endif /* __NET_WIRELESS_CORE_H */