blob: f7fb9f413028a7f4783e2d7ae1616ebc1dcfe311 [file] [log] [blame]
Johannes Berg704232c2007-04-23 12:20:05 -07001/*
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>
Luis R. Rodriguez3f2355c2008-11-12 14:22:02 -080014#include "reg.h"
Johannes Berg704232c2007-04-23 12:20:05 -070015
16struct 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
Luis R. Rodriguez3f2355c2008-11-12 14:22:02 -080025 /* 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
Johannes Berg704232c2007-04-23 12:20:05 -070037 /* 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
49static inline
50struct 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
56extern struct mutex cfg80211_drv_mutex;
57extern struct list_head cfg80211_drv_list;
58
Johannes Berg55682962007-09-20 13:09:35 -040059/*
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 */
79extern struct cfg80211_registered_device *
80cfg80211_get_dev_from_info(struct genl_info *info);
81
82/* identical to cfg80211_get_dev_from_info but only operate on ifindex */
83extern struct cfg80211_registered_device *
84cfg80211_get_dev_from_ifindex(int ifindex);
85
86extern void cfg80211_put_dev(struct cfg80211_registered_device *drv);
87
Johannes Berg704232c2007-04-23 12:20:05 -070088/* free object */
89extern void cfg80211_dev_free(struct cfg80211_registered_device *drv);
90
Johannes Berg55682962007-09-20 13:09:35 -040091extern int cfg80211_dev_rename(struct cfg80211_registered_device *drv,
92 char *newname);
93
Johannes Berg8318d782008-01-24 19:38:38 +010094void ieee80211_set_bitrate_flags(struct wiphy *wiphy);
Luis R. Rodriguezb2e1b302008-09-09 23:19:48 -070095void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby);
Johannes Berg8318d782008-01-24 19:38:38 +010096
Johannes Berg704232c2007-04-23 12:20:05 -070097#endif /* __NET_WIRELESS_CORE_H */