core.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 <net/genetlink.h>
  12. #include <net/wireless.h>
  13. #include <net/cfg80211.h>
  14. #include "reg.h"
  15. struct cfg80211_registered_device {
  16. struct cfg80211_ops *ops;
  17. struct list_head list;
  18. /* we hold this mutex during any call so that
  19. * we cannot do multiple calls at once, and also
  20. * to avoid the deregister call to proceed while
  21. * any call is in progress */
  22. struct mutex mtx;
  23. /* ISO / IEC 3166 alpha2 for which this device is receiving
  24. * country IEs on, this can help disregard country IEs from APs
  25. * on the same alpha2 quickly. The alpha2 may differ from
  26. * cfg80211_regdomain's alpha2 when an intersection has occurred.
  27. * If the AP is reconfigured this can also be used to tell us if
  28. * the country on the country IE changed. */
  29. char country_ie_alpha2[2];
  30. /* If a Country IE has been received this tells us the environment
  31. * which its telling us its in. This defaults to ENVIRON_ANY */
  32. enum environment_cap env;
  33. /* wiphy index, internal only */
  34. int idx;
  35. /* associate netdev list */
  36. struct mutex devlist_mtx;
  37. struct list_head netdev_list;
  38. /* must be last because of the way we do wiphy_priv(),
  39. * and it should at least be aligned to NETDEV_ALIGN */
  40. struct wiphy wiphy __attribute__((__aligned__(NETDEV_ALIGN)));
  41. };
  42. static inline
  43. struct cfg80211_registered_device *wiphy_to_dev(struct wiphy *wiphy)
  44. {
  45. BUG_ON(!wiphy);
  46. return container_of(wiphy, struct cfg80211_registered_device, wiphy);
  47. }
  48. extern struct mutex cfg80211_drv_mutex;
  49. extern struct list_head cfg80211_drv_list;
  50. /*
  51. * This function returns a pointer to the driver
  52. * that the genl_info item that is passed refers to.
  53. * If successful, it returns non-NULL and also locks
  54. * the driver's mutex!
  55. *
  56. * This means that you need to call cfg80211_put_dev()
  57. * before being allowed to acquire &cfg80211_drv_mutex!
  58. *
  59. * This is necessary because we need to lock the global
  60. * mutex to get an item off the list safely, and then
  61. * we lock the drv mutex so it doesn't go away under us.
  62. *
  63. * We don't want to keep cfg80211_drv_mutex locked
  64. * for all the time in order to allow requests on
  65. * other interfaces to go through at the same time.
  66. *
  67. * The result of this can be a PTR_ERR and hence must
  68. * be checked with IS_ERR() for errors.
  69. */
  70. extern struct cfg80211_registered_device *
  71. cfg80211_get_dev_from_info(struct genl_info *info);
  72. /* identical to cfg80211_get_dev_from_info but only operate on ifindex */
  73. extern struct cfg80211_registered_device *
  74. cfg80211_get_dev_from_ifindex(int ifindex);
  75. extern void cfg80211_put_dev(struct cfg80211_registered_device *drv);
  76. /* free object */
  77. extern void cfg80211_dev_free(struct cfg80211_registered_device *drv);
  78. extern int cfg80211_dev_rename(struct cfg80211_registered_device *drv,
  79. char *newname);
  80. void ieee80211_set_bitrate_flags(struct wiphy *wiphy);
  81. void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby);
  82. #endif /* __NET_WIRELESS_CORE_H */