added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / net / wireless / wext-compat.c
blob58e489fd4aedf0527241c4c39aa5d20482a6dea2
1 /*
2 * cfg80211 - wext compat code
4 * This is temporary code until all wireless functionality is migrated
5 * into cfg80211, when that happens all the exports here go away and
6 * we directly assign the wireless handlers of wireless interfaces.
8 * Copyright 2008 Johannes Berg <johannes@sipsolutions.net>
9 */
11 #include <linux/wireless.h>
12 #include <linux/nl80211.h>
13 #include <net/iw_handler.h>
14 #include <net/wireless.h>
15 #include <net/cfg80211.h>
16 #include "core.h"
18 int cfg80211_wext_giwname(struct net_device *dev,
19 struct iw_request_info *info,
20 char *name, char *extra)
22 struct wireless_dev *wdev = dev->ieee80211_ptr;
23 struct ieee80211_supported_band *sband;
24 bool is_ht = false, is_a = false, is_b = false, is_g = false;
26 if (!wdev)
27 return -EOPNOTSUPP;
29 sband = wdev->wiphy->bands[IEEE80211_BAND_5GHZ];
30 if (sband) {
31 is_a = true;
32 is_ht |= sband->ht_cap.ht_supported;
35 sband = wdev->wiphy->bands[IEEE80211_BAND_2GHZ];
36 if (sband) {
37 int i;
38 /* Check for mandatory rates */
39 for (i = 0; i < sband->n_bitrates; i++) {
40 if (sband->bitrates[i].bitrate == 10)
41 is_b = true;
42 if (sband->bitrates[i].bitrate == 60)
43 is_g = true;
45 is_ht |= sband->ht_cap.ht_supported;
48 strcpy(name, "IEEE 802.11");
49 if (is_a)
50 strcat(name, "a");
51 if (is_b)
52 strcat(name, "b");
53 if (is_g)
54 strcat(name, "g");
55 if (is_ht)
56 strcat(name, "n");
58 return 0;
60 EXPORT_SYMBOL(cfg80211_wext_giwname);
62 int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
63 u32 *mode, char *extra)
65 struct wireless_dev *wdev = dev->ieee80211_ptr;
66 struct cfg80211_registered_device *rdev;
67 struct vif_params vifparams;
68 enum nl80211_iftype type;
70 if (!wdev)
71 return -EOPNOTSUPP;
73 rdev = wiphy_to_dev(wdev->wiphy);
75 if (!rdev->ops->change_virtual_intf)
76 return -EOPNOTSUPP;
78 /* don't support changing VLANs, you just re-create them */
79 if (wdev->iftype == NL80211_IFTYPE_AP_VLAN)
80 return -EOPNOTSUPP;
82 switch (*mode) {
83 case IW_MODE_INFRA:
84 type = NL80211_IFTYPE_STATION;
85 break;
86 case IW_MODE_ADHOC:
87 type = NL80211_IFTYPE_ADHOC;
88 break;
89 case IW_MODE_REPEAT:
90 type = NL80211_IFTYPE_WDS;
91 break;
92 case IW_MODE_MONITOR:
93 type = NL80211_IFTYPE_MONITOR;
94 break;
95 default:
96 return -EINVAL;
99 memset(&vifparams, 0, sizeof(vifparams));
101 return rdev->ops->change_virtual_intf(wdev->wiphy, dev->ifindex, type,
102 NULL, &vifparams);
104 EXPORT_SYMBOL(cfg80211_wext_siwmode);
106 int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info,
107 u32 *mode, char *extra)
109 struct wireless_dev *wdev = dev->ieee80211_ptr;
111 if (!wdev)
112 return -EOPNOTSUPP;
114 switch (wdev->iftype) {
115 case NL80211_IFTYPE_AP:
116 *mode = IW_MODE_MASTER;
117 break;
118 case NL80211_IFTYPE_STATION:
119 *mode = IW_MODE_INFRA;
120 break;
121 case NL80211_IFTYPE_ADHOC:
122 *mode = IW_MODE_ADHOC;
123 break;
124 case NL80211_IFTYPE_MONITOR:
125 *mode = IW_MODE_MONITOR;
126 break;
127 case NL80211_IFTYPE_WDS:
128 *mode = IW_MODE_REPEAT;
129 break;
130 case NL80211_IFTYPE_AP_VLAN:
131 *mode = IW_MODE_SECOND; /* FIXME */
132 break;
133 default:
134 *mode = IW_MODE_AUTO;
135 break;
137 return 0;
139 EXPORT_SYMBOL(cfg80211_wext_giwmode);