aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/main.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-09-10 18:01:58 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-09-15 16:48:23 -0400
commit05c914fe330fa8e1cc67870dc0d3809dfd96c107 (patch)
treedf53bcab47335f3361c09478d6b1447b7d298536 /net/mac80211/main.c
parent96dd22ac06b0dbfb069fdf530c72046a941e9694 (diff)
mac80211: use nl80211 interface types
There's really no reason for mac80211 to be using its own interface type defines. Use the nl80211 types and simplify the configuration code a bit: there's no need to translate them any more now. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/main.c')
-rw-r--r--net/mac80211/main.c89
1 files changed, 44 insertions, 45 deletions
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 4c424acc01a4..584a75bd6cfe 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -146,7 +146,7 @@ static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
146 int meshhdrlen; 146 int meshhdrlen;
147 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 147 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
148 148
149 meshhdrlen = (sdata->vif.type == IEEE80211_IF_TYPE_MESH_POINT) ? 5 : 0; 149 meshhdrlen = (sdata->vif.type == NL80211_IFTYPE_MESH_POINT) ? 5 : 0;
150 150
151 /* FIX: what would be proper limits for MTU? 151 /* FIX: what would be proper limits for MTU?
152 * This interface uses 802.3 frames. */ 152 * This interface uses 802.3 frames. */
@@ -164,18 +164,16 @@ static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
164 164
165static inline int identical_mac_addr_allowed(int type1, int type2) 165static inline int identical_mac_addr_allowed(int type1, int type2)
166{ 166{
167 return (type1 == IEEE80211_IF_TYPE_MNTR || 167 return type1 == NL80211_IFTYPE_MONITOR ||
168 type2 == IEEE80211_IF_TYPE_MNTR || 168 type2 == NL80211_IFTYPE_MONITOR ||
169 (type1 == IEEE80211_IF_TYPE_AP && 169 (type1 == NL80211_IFTYPE_AP && type2 == NL80211_IFTYPE_WDS) ||
170 type2 == IEEE80211_IF_TYPE_WDS) || 170 (type1 == NL80211_IFTYPE_WDS &&
171 (type1 == IEEE80211_IF_TYPE_WDS && 171 (type2 == NL80211_IFTYPE_WDS ||
172 (type2 == IEEE80211_IF_TYPE_WDS || 172 type2 == NL80211_IFTYPE_AP)) ||
173 type2 == IEEE80211_IF_TYPE_AP)) || 173 (type1 == NL80211_IFTYPE_AP && type2 == NL80211_IFTYPE_AP_VLAN) ||
174 (type1 == IEEE80211_IF_TYPE_AP && 174 (type1 == NL80211_IFTYPE_AP_VLAN &&
175 type2 == IEEE80211_IF_TYPE_VLAN) || 175 (type2 == NL80211_IFTYPE_AP ||
176 (type1 == IEEE80211_IF_TYPE_VLAN && 176 type2 == NL80211_IFTYPE_AP_VLAN));
177 (type2 == IEEE80211_IF_TYPE_AP ||
178 type2 == IEEE80211_IF_TYPE_VLAN)));
179} 177}
180 178
181static int ieee80211_open(struct net_device *dev) 179static int ieee80211_open(struct net_device *dev)
@@ -211,8 +209,8 @@ static int ieee80211_open(struct net_device *dev)
211 * belonging to the same hardware. Then, however, we're 209 * belonging to the same hardware. Then, however, we're
212 * faced with having to adopt two different TSF timers... 210 * faced with having to adopt two different TSF timers...
213 */ 211 */
214 if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && 212 if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
215 nsdata->vif.type == IEEE80211_IF_TYPE_IBSS) 213 nsdata->vif.type == NL80211_IFTYPE_ADHOC)
216 return -EBUSY; 214 return -EBUSY;
217 215
218 /* 216 /*
@@ -232,37 +230,38 @@ static int ieee80211_open(struct net_device *dev)
232 /* 230 /*
233 * can only add VLANs to enabled APs 231 * can only add VLANs to enabled APs
234 */ 232 */
235 if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN && 233 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
236 nsdata->vif.type == IEEE80211_IF_TYPE_AP) 234 nsdata->vif.type == NL80211_IFTYPE_AP)
237 sdata->bss = &nsdata->u.ap; 235 sdata->bss = &nsdata->u.ap;
238 } 236 }
239 } 237 }
240 238
241 switch (sdata->vif.type) { 239 switch (sdata->vif.type) {
242 case IEEE80211_IF_TYPE_WDS: 240 case NL80211_IFTYPE_WDS:
243 if (!is_valid_ether_addr(sdata->u.wds.remote_addr)) 241 if (!is_valid_ether_addr(sdata->u.wds.remote_addr))
244 return -ENOLINK; 242 return -ENOLINK;
245 break; 243 break;
246 case IEEE80211_IF_TYPE_VLAN: 244 case NL80211_IFTYPE_AP_VLAN:
247 if (!sdata->bss) 245 if (!sdata->bss)
248 return -ENOLINK; 246 return -ENOLINK;
249 list_add(&sdata->u.vlan.list, &sdata->bss->vlans); 247 list_add(&sdata->u.vlan.list, &sdata->bss->vlans);
250 break; 248 break;
251 case IEEE80211_IF_TYPE_AP: 249 case NL80211_IFTYPE_AP:
252 sdata->bss = &sdata->u.ap; 250 sdata->bss = &sdata->u.ap;
253 break; 251 break;
254 case IEEE80211_IF_TYPE_MESH_POINT: 252 case NL80211_IFTYPE_MESH_POINT:
255 if (!ieee80211_vif_is_mesh(&sdata->vif)) 253 if (!ieee80211_vif_is_mesh(&sdata->vif))
256 break; 254 break;
257 /* mesh ifaces must set allmulti to forward mcast traffic */ 255 /* mesh ifaces must set allmulti to forward mcast traffic */
258 atomic_inc(&local->iff_allmultis); 256 atomic_inc(&local->iff_allmultis);
259 break; 257 break;
260 case IEEE80211_IF_TYPE_STA: 258 case NL80211_IFTYPE_STATION:
261 case IEEE80211_IF_TYPE_MNTR: 259 case NL80211_IFTYPE_MONITOR:
262 case IEEE80211_IF_TYPE_IBSS: 260 case NL80211_IFTYPE_ADHOC:
263 /* no special treatment */ 261 /* no special treatment */
264 break; 262 break;
265 case IEEE80211_IF_TYPE_INVALID: 263 case NL80211_IFTYPE_UNSPECIFIED:
264 case __NL80211_IFTYPE_AFTER_LAST:
266 /* cannot happen */ 265 /* cannot happen */
267 WARN_ON(1); 266 WARN_ON(1);
268 break; 267 break;
@@ -309,10 +308,10 @@ static int ieee80211_open(struct net_device *dev)
309 } 308 }
310 309
311 switch (sdata->vif.type) { 310 switch (sdata->vif.type) {
312 case IEEE80211_IF_TYPE_VLAN: 311 case NL80211_IFTYPE_AP_VLAN:
313 /* no need to tell driver */ 312 /* no need to tell driver */
314 break; 313 break;
315 case IEEE80211_IF_TYPE_MNTR: 314 case NL80211_IFTYPE_MONITOR:
316 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) { 315 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
317 local->cooked_mntrs++; 316 local->cooked_mntrs++;
318 break; 317 break;
@@ -336,8 +335,8 @@ static int ieee80211_open(struct net_device *dev)
336 ieee80211_configure_filter(local); 335 ieee80211_configure_filter(local);
337 netif_addr_unlock_bh(local->mdev); 336 netif_addr_unlock_bh(local->mdev);
338 break; 337 break;
339 case IEEE80211_IF_TYPE_STA: 338 case NL80211_IFTYPE_STATION:
340 case IEEE80211_IF_TYPE_IBSS: 339 case NL80211_IFTYPE_ADHOC:
341 sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET; 340 sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET;
342 /* fall through */ 341 /* fall through */
343 default: 342 default:
@@ -354,14 +353,14 @@ static int ieee80211_open(struct net_device *dev)
354 ieee80211_bss_info_change_notify(sdata, changed); 353 ieee80211_bss_info_change_notify(sdata, changed);
355 ieee80211_enable_keys(sdata); 354 ieee80211_enable_keys(sdata);
356 355
357 if (sdata->vif.type == IEEE80211_IF_TYPE_STA && 356 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
358 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME)) 357 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
359 netif_carrier_off(dev); 358 netif_carrier_off(dev);
360 else 359 else
361 netif_carrier_on(dev); 360 netif_carrier_on(dev);
362 } 361 }
363 362
364 if (sdata->vif.type == IEEE80211_IF_TYPE_WDS) { 363 if (sdata->vif.type == NL80211_IFTYPE_WDS) {
365 /* Create STA entry for the WDS peer */ 364 /* Create STA entry for the WDS peer */
366 sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr, 365 sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
367 GFP_KERNEL); 366 GFP_KERNEL);
@@ -417,8 +416,8 @@ static int ieee80211_open(struct net_device *dev)
417 * yet be effective. Trigger execution of ieee80211_sta_work 416 * yet be effective. Trigger execution of ieee80211_sta_work
418 * to fix this. 417 * to fix this.
419 */ 418 */
420 if (sdata->vif.type == IEEE80211_IF_TYPE_STA || 419 if (sdata->vif.type == NL80211_IFTYPE_STATION ||
421 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { 420 sdata->vif.type == NL80211_IFTYPE_ADHOC) {
422 struct ieee80211_if_sta *ifsta = &sdata->u.sta; 421 struct ieee80211_if_sta *ifsta = &sdata->u.sta;
423 queue_work(local->hw.workqueue, &ifsta->work); 422 queue_work(local->hw.workqueue, &ifsta->work);
424 } 423 }
@@ -433,7 +432,7 @@ static int ieee80211_open(struct net_device *dev)
433 local->ops->stop(local_to_hw(local)); 432 local->ops->stop(local_to_hw(local));
434 err_del_bss: 433 err_del_bss:
435 sdata->bss = NULL; 434 sdata->bss = NULL;
436 if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN) 435 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
437 list_del(&sdata->u.vlan.list); 436 list_del(&sdata->u.vlan.list);
438 return res; 437 return res;
439} 438}
@@ -496,7 +495,7 @@ static int ieee80211_stop(struct net_device *dev)
496 dev_mc_unsync(local->mdev, dev); 495 dev_mc_unsync(local->mdev, dev);
497 496
498 /* APs need special treatment */ 497 /* APs need special treatment */
499 if (sdata->vif.type == IEEE80211_IF_TYPE_AP) { 498 if (sdata->vif.type == NL80211_IFTYPE_AP) {
500 struct ieee80211_sub_if_data *vlan, *tmp; 499 struct ieee80211_sub_if_data *vlan, *tmp;
501 struct beacon_data *old_beacon = sdata->u.ap.beacon; 500 struct beacon_data *old_beacon = sdata->u.ap.beacon;
502 501
@@ -515,11 +514,11 @@ static int ieee80211_stop(struct net_device *dev)
515 local->open_count--; 514 local->open_count--;
516 515
517 switch (sdata->vif.type) { 516 switch (sdata->vif.type) {
518 case IEEE80211_IF_TYPE_VLAN: 517 case NL80211_IFTYPE_AP_VLAN:
519 list_del(&sdata->u.vlan.list); 518 list_del(&sdata->u.vlan.list);
520 /* no need to tell driver */ 519 /* no need to tell driver */
521 break; 520 break;
522 case IEEE80211_IF_TYPE_MNTR: 521 case NL80211_IFTYPE_MONITOR:
523 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) { 522 if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
524 local->cooked_mntrs--; 523 local->cooked_mntrs--;
525 break; 524 break;
@@ -542,8 +541,8 @@ static int ieee80211_stop(struct net_device *dev)
542 ieee80211_configure_filter(local); 541 ieee80211_configure_filter(local);
543 netif_addr_unlock_bh(local->mdev); 542 netif_addr_unlock_bh(local->mdev);
544 break; 543 break;
545 case IEEE80211_IF_TYPE_STA: 544 case NL80211_IFTYPE_STATION:
546 case IEEE80211_IF_TYPE_IBSS: 545 case NL80211_IFTYPE_ADHOC:
547 sdata->u.sta.state = IEEE80211_STA_MLME_DISABLED; 546 sdata->u.sta.state = IEEE80211_STA_MLME_DISABLED;
548 memset(sdata->u.sta.bssid, 0, ETH_ALEN); 547 memset(sdata->u.sta.bssid, 0, ETH_ALEN);
549 del_timer_sync(&sdata->u.sta.timer); 548 del_timer_sync(&sdata->u.sta.timer);
@@ -569,7 +568,7 @@ static int ieee80211_stop(struct net_device *dev)
569 sdata->u.sta.extra_ie = NULL; 568 sdata->u.sta.extra_ie = NULL;
570 sdata->u.sta.extra_ie_len = 0; 569 sdata->u.sta.extra_ie_len = 0;
571 /* fall through */ 570 /* fall through */
572 case IEEE80211_IF_TYPE_MESH_POINT: 571 case NL80211_IFTYPE_MESH_POINT:
573 if (ieee80211_vif_is_mesh(&sdata->vif)) { 572 if (ieee80211_vif_is_mesh(&sdata->vif)) {
574 /* allmulti is always set on mesh ifaces */ 573 /* allmulti is always set on mesh ifaces */
575 atomic_dec(&local->iff_allmultis); 574 atomic_dec(&local->iff_allmultis);
@@ -698,12 +697,12 @@ int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed)
698 memset(&conf, 0, sizeof(conf)); 697 memset(&conf, 0, sizeof(conf));
699 conf.changed = changed; 698 conf.changed = changed;
700 699
701 if (sdata->vif.type == IEEE80211_IF_TYPE_STA || 700 if (sdata->vif.type == NL80211_IFTYPE_STATION ||
702 sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { 701 sdata->vif.type == NL80211_IFTYPE_ADHOC) {
703 conf.bssid = sdata->u.sta.bssid; 702 conf.bssid = sdata->u.sta.bssid;
704 conf.ssid = sdata->u.sta.ssid; 703 conf.ssid = sdata->u.sta.ssid;
705 conf.ssid_len = sdata->u.sta.ssid_len; 704 conf.ssid_len = sdata->u.sta.ssid_len;
706 } else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) { 705 } else if (sdata->vif.type == NL80211_IFTYPE_AP) {
707 conf.bssid = sdata->dev->dev_addr; 706 conf.bssid = sdata->dev->dev_addr;
708 conf.ssid = sdata->u.ap.ssid; 707 conf.ssid = sdata->u.ap.ssid;
709 conf.ssid_len = sdata->u.ap.ssid_len; 708 conf.ssid_len = sdata->u.ap.ssid_len;
@@ -1204,7 +1203,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
1204 1203
1205 rcu_read_lock(); 1204 rcu_read_lock();
1206 list_for_each_entry_rcu(sdata, &local->interfaces, list) { 1205 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
1207 if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) { 1206 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
1208 if (!netif_running(sdata->dev)) 1207 if (!netif_running(sdata->dev))
1209 continue; 1208 continue;
1210 1209
@@ -1450,7 +1449,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
1450 1449
1451 /* add one default STA interface */ 1450 /* add one default STA interface */
1452 result = ieee80211_if_add(local, "wlan%d", NULL, 1451 result = ieee80211_if_add(local, "wlan%d", NULL,
1453 IEEE80211_IF_TYPE_STA, NULL); 1452 NL80211_IFTYPE_STATION, NULL);
1454 if (result) 1453 if (result)
1455 printk(KERN_WARNING "%s: Failed to add default virtual iface\n", 1454 printk(KERN_WARNING "%s: Failed to add default virtual iface\n",
1456 wiphy_name(local->hw.wiphy)); 1455 wiphy_name(local->hw.wiphy));