aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/ieee80211.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/ieee80211.c')
-rw-r--r--net/mac80211/ieee80211.c181
1 files changed, 1 insertions, 180 deletions
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c
index 373e8b728782..804da5e89bbf 100644
--- a/net/mac80211/ieee80211.c
+++ b/net/mac80211/ieee80211.c
@@ -24,7 +24,6 @@
24#include <net/net_namespace.h> 24#include <net/net_namespace.h>
25#include <net/cfg80211.h> 25#include <net/cfg80211.h>
26 26
27#include "ieee80211_common.h"
28#include "ieee80211_i.h" 27#include "ieee80211_i.h"
29#include "ieee80211_rate.h" 28#include "ieee80211_rate.h"
30#include "wep.h" 29#include "wep.h"
@@ -123,151 +122,6 @@ static void ieee80211_master_set_multicast_list(struct net_device *dev)
123 ieee80211_configure_filter(local); 122 ieee80211_configure_filter(local);
124} 123}
125 124
126/* management interface */
127
128static void
129ieee80211_fill_frame_info(struct ieee80211_local *local,
130 struct ieee80211_frame_info *fi,
131 struct ieee80211_rx_status *status)
132{
133 if (status) {
134 struct timespec ts;
135 struct ieee80211_rate *rate;
136
137 jiffies_to_timespec(jiffies, &ts);
138 fi->hosttime = cpu_to_be64((u64) ts.tv_sec * 1000000 +
139 ts.tv_nsec / 1000);
140 fi->mactime = cpu_to_be64(status->mactime);
141 switch (status->phymode) {
142 case MODE_IEEE80211A:
143 fi->phytype = htonl(ieee80211_phytype_ofdm_dot11_a);
144 break;
145 case MODE_IEEE80211B:
146 fi->phytype = htonl(ieee80211_phytype_dsss_dot11_b);
147 break;
148 case MODE_IEEE80211G:
149 fi->phytype = htonl(ieee80211_phytype_pbcc_dot11_g);
150 break;
151 default:
152 fi->phytype = htonl(0xAAAAAAAA);
153 break;
154 }
155 fi->channel = htonl(status->channel);
156 rate = ieee80211_get_rate(local, status->phymode,
157 status->rate);
158 if (rate) {
159 fi->datarate = htonl(rate->rate);
160 if (rate->flags & IEEE80211_RATE_PREAMBLE2) {
161 if (status->rate == rate->val)
162 fi->preamble = htonl(2); /* long */
163 else if (status->rate == rate->val2)
164 fi->preamble = htonl(1); /* short */
165 } else
166 fi->preamble = htonl(0);
167 } else {
168 fi->datarate = htonl(0);
169 fi->preamble = htonl(0);
170 }
171
172 fi->antenna = htonl(status->antenna);
173 fi->priority = htonl(0xffffffff); /* no clue */
174 fi->ssi_type = htonl(ieee80211_ssi_raw);
175 fi->ssi_signal = htonl(status->ssi);
176 fi->ssi_noise = 0x00000000;
177 fi->encoding = 0;
178 } else {
179 /* clear everything because we really don't know.
180 * the msg_type field isn't present on monitor frames
181 * so we don't know whether it will be present or not,
182 * but it's ok to not clear it since it'll be assigned
183 * anyway */
184 memset(fi, 0, sizeof(*fi) - sizeof(fi->msg_type));
185
186 fi->ssi_type = htonl(ieee80211_ssi_none);
187 }
188 fi->version = htonl(IEEE80211_FI_VERSION);
189 fi->length = cpu_to_be32(sizeof(*fi) - sizeof(fi->msg_type));
190}
191
192/* this routine is actually not just for this, but also
193 * for pushing fake 'management' frames into userspace.
194 * it shall be replaced by a netlink-based system. */
195void
196ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb,
197 struct ieee80211_rx_status *status, u32 msg_type)
198{
199 struct ieee80211_frame_info *fi;
200 const size_t hlen = sizeof(struct ieee80211_frame_info);
201 struct net_device *dev = local->apdev;
202
203 skb->dev = dev;
204
205 if (skb_headroom(skb) < hlen) {
206 I802_DEBUG_INC(local->rx_expand_skb_head);
207 if (pskb_expand_head(skb, hlen, 0, GFP_ATOMIC)) {
208 dev_kfree_skb(skb);
209 return;
210 }
211 }
212
213 fi = (struct ieee80211_frame_info *) skb_push(skb, hlen);
214
215 ieee80211_fill_frame_info(local, fi, status);
216 fi->msg_type = htonl(msg_type);
217
218 dev->stats.rx_packets++;
219 dev->stats.rx_bytes += skb->len;
220
221 skb_set_mac_header(skb, 0);
222 skb->ip_summed = CHECKSUM_UNNECESSARY;
223 skb->pkt_type = PACKET_OTHERHOST;
224 skb->protocol = htons(ETH_P_802_2);
225 memset(skb->cb, 0, sizeof(skb->cb));
226 netif_rx(skb);
227}
228
229static int ieee80211_mgmt_open(struct net_device *dev)
230{
231 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
232
233 if (!netif_running(local->mdev))
234 return -EOPNOTSUPP;
235 return 0;
236}
237
238static int ieee80211_mgmt_stop(struct net_device *dev)
239{
240 return 0;
241}
242
243static int ieee80211_change_mtu_apdev(struct net_device *dev, int new_mtu)
244{
245 /* FIX: what would be proper limits for MTU?
246 * This interface uses 802.11 frames. */
247 if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN) {
248 printk(KERN_WARNING "%s: invalid MTU %d\n",
249 dev->name, new_mtu);
250 return -EINVAL;
251 }
252
253#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
254 printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu);
255#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
256 dev->mtu = new_mtu;
257 return 0;
258}
259
260void ieee80211_if_mgmt_setup(struct net_device *dev)
261{
262 ether_setup(dev);
263 dev->hard_start_xmit = ieee80211_mgmt_start_xmit;
264 dev->change_mtu = ieee80211_change_mtu_apdev;
265 dev->open = ieee80211_mgmt_open;
266 dev->stop = ieee80211_mgmt_stop;
267 dev->type = ARPHRD_IEEE80211_PRISM;
268 dev->destructor = ieee80211_if_free;
269}
270
271/* regular interfaces */ 125/* regular interfaces */
272 126
273static int ieee80211_change_mtu(struct net_device *dev, int new_mtu) 127static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
@@ -345,7 +199,6 @@ static int ieee80211_open(struct net_device *dev)
345 return -ENOLINK; 199 return -ENOLINK;
346 break; 200 break;
347 case IEEE80211_IF_TYPE_AP: 201 case IEEE80211_IF_TYPE_AP:
348 case IEEE80211_IF_TYPE_MGMT:
349 case IEEE80211_IF_TYPE_STA: 202 case IEEE80211_IF_TYPE_STA:
350 case IEEE80211_IF_TYPE_MNTR: 203 case IEEE80211_IF_TYPE_MNTR:
351 case IEEE80211_IF_TYPE_IBSS: 204 case IEEE80211_IF_TYPE_IBSS:
@@ -410,10 +263,6 @@ static int ieee80211_open(struct net_device *dev)
410 if (local->open_count == 0) { 263 if (local->open_count == 0) {
411 res = dev_open(local->mdev); 264 res = dev_open(local->mdev);
412 WARN_ON(res); 265 WARN_ON(res);
413 if (local->apdev) {
414 res = dev_open(local->apdev);
415 WARN_ON(res);
416 }
417 tasklet_enable(&local->tx_pending_tasklet); 266 tasklet_enable(&local->tx_pending_tasklet);
418 tasklet_enable(&local->tasklet); 267 tasklet_enable(&local->tasklet);
419 } 268 }
@@ -499,9 +348,6 @@ static int ieee80211_stop(struct net_device *dev)
499 if (netif_running(local->mdev)) 348 if (netif_running(local->mdev))
500 dev_close(local->mdev); 349 dev_close(local->mdev);
501 350
502 if (local->apdev)
503 dev_close(local->apdev);
504
505 if (local->ops->stop) 351 if (local->ops->stop)
506 local->ops->stop(local_to_hw(local)); 352 local->ops->stop(local_to_hw(local));
507 353
@@ -550,7 +396,7 @@ static const struct header_ops ieee80211_header_ops = {
550 .cache_update = eth_header_cache_update, 396 .cache_update = eth_header_cache_update,
551}; 397};
552 398
553/* Must not be called for mdev and apdev */ 399/* Must not be called for mdev */
554void ieee80211_if_setup(struct net_device *dev) 400void ieee80211_if_setup(struct net_device *dev)
555{ 401{
556 ether_setup(dev); 402 ether_setup(dev);
@@ -806,8 +652,6 @@ static void ieee80211_remove_tx_extra(struct ieee80211_local *local,
806 pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT; 652 pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT;
807 if (control->flags & IEEE80211_TXCTL_REQUEUE) 653 if (control->flags & IEEE80211_TXCTL_REQUEUE)
808 pkt_data->flags |= IEEE80211_TXPD_REQUEUE; 654 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
809 if (control->type == IEEE80211_IF_TYPE_MGMT)
810 pkt_data->flags |= IEEE80211_TXPD_MGMT_IFACE;
811 pkt_data->queue = control->queue; 655 pkt_data->queue = control->queue;
812 656
813 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 657 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
@@ -860,7 +704,6 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
860 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 704 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
861 struct ieee80211_local *local = hw_to_local(hw); 705 struct ieee80211_local *local = hw_to_local(hw);
862 u16 frag, type; 706 u16 frag, type;
863 u32 msg_type;
864 struct ieee80211_tx_status_rtap_hdr *rthdr; 707 struct ieee80211_tx_status_rtap_hdr *rthdr;
865 struct ieee80211_sub_if_data *sdata; 708 struct ieee80211_sub_if_data *sdata;
866 int monitors; 709 int monitors;
@@ -975,29 +818,9 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
975 local->dot11FailedCount++; 818 local->dot11FailedCount++;
976 } 819 }
977 820
978 msg_type = (status->flags & IEEE80211_TX_STATUS_ACK) ?
979 ieee80211_msg_tx_callback_ack : ieee80211_msg_tx_callback_fail;
980
981 /* this was a transmitted frame, but now we want to reuse it */ 821 /* this was a transmitted frame, but now we want to reuse it */
982 skb_orphan(skb); 822 skb_orphan(skb);
983 823
984 if ((status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS) &&
985 local->apdev) {
986 if (local->monitors) {
987 skb2 = skb_clone(skb, GFP_ATOMIC);
988 } else {
989 skb2 = skb;
990 skb = NULL;
991 }
992
993 if (skb2)
994 /* Send frame to hostapd */
995 ieee80211_rx_mgmt(local, skb2, NULL, msg_type);
996
997 if (!skb)
998 return;
999 }
1000
1001 if (!local->monitors) { 824 if (!local->monitors) {
1002 dev_kfree_skb(skb); 825 dev_kfree_skb(skb);
1003 return; 826 return;
@@ -1344,8 +1167,6 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
1344 BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED); 1167 BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED);
1345 1168
1346 local->reg_state = IEEE80211_DEV_UNREGISTERED; 1169 local->reg_state = IEEE80211_DEV_UNREGISTERED;
1347 if (local->apdev)
1348 ieee80211_if_del_mgmt(local);
1349 1170
1350 /* 1171 /*
1351 * At this point, interface list manipulations are fine 1172 * At this point, interface list manipulations are fine