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 16 struct cfg80211_registered_device { 17 struct cfg80211_ops *ops; 18 struct list_head list; 19 /* we hold this mutex during any call so that 20 * we cannot do multiple calls at once, and also 21 * to avoid the deregister call to proceed while 22 * any call is in progress */ 23 struct mutex mtx; 24 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 33 /* If a Country IE has been received this tells us the environment 34 * which its telling us its in. This defaults to ENVIRON_ANY */ 35 enum environment_cap env; 36 37 /* wiphy index, internal only */ 38 int idx; 39 40 /* associate netdev list */ 41 struct mutex devlist_mtx; 42 struct list_head netdev_list; 43 44 /* must be last because of the way we do wiphy_priv(), 45 * and it should at least be aligned to NETDEV_ALIGN */ 46 struct wiphy wiphy __attribute__((__aligned__(NETDEV_ALIGN))); 47 }; 48 49 static inline 50 struct cfg80211_registered_device *wiphy_to_dev(struct wiphy *wiphy) 51 { 52 BUG_ON(!wiphy); 53 return container_of(wiphy, struct cfg80211_registered_device, wiphy); 54 } 55 56 extern struct mutex cfg80211_drv_mutex; 57 extern struct list_head cfg80211_drv_list; 58 59 /* 60 * This function returns a pointer to the driver 61 * that the genl_info item that is passed refers to. 62 * If successful, it returns non-NULL and also locks 63 * the driver's mutex! 64 * 65 * This means that you need to call cfg80211_put_dev() 66 * before being allowed to acquire &cfg80211_drv_mutex! 67 * 68 * This is necessary because we need to lock the global 69 * mutex to get an item off the list safely, and then 70 * we lock the drv mutex so it doesn't go away under us. 71 * 72 * We don't want to keep cfg80211_drv_mutex locked 73 * for all the time in order to allow requests on 74 * other interfaces to go through at the same time. 75 * 76 * The result of this can be a PTR_ERR and hence must 77 * be checked with IS_ERR() for errors. 78 */ 79 extern struct cfg80211_registered_device * 80 cfg80211_get_dev_from_info(struct genl_info *info); 81 82 /* identical to cfg80211_get_dev_from_info but only operate on ifindex */ 83 extern struct cfg80211_registered_device * 84 cfg80211_get_dev_from_ifindex(int ifindex); 85 86 extern void cfg80211_put_dev(struct cfg80211_registered_device *drv); 87 88 /* free object */ 89 extern void cfg80211_dev_free(struct cfg80211_registered_device *drv); 90 91 extern int cfg80211_dev_rename(struct cfg80211_registered_device *drv, 92 char *newname); 93 94 void ieee80211_set_bitrate_flags(struct wiphy *wiphy); 95 void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby); 96 97 #endif /* __NET_WIRELESS_CORE_H */ 98