aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-06-08 15:48:25 -0400
committerJeff Garzik <jeff@garzik.org>2006-06-08 15:48:25 -0400
commitba9b28d19a3251bb1dfe6a6f8cc89b96fb85f683 (patch)
treed770bd8c536771cb3804abb51ed029d7dd9d30d2 /net
parent862fc81b62c2d41a7e0b97b90844c80e59c7b0f1 (diff)
parent5c601d0c942f5aaf7f3cff7e08f61047d70a964e (diff)
Merge branch 'upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6 into upstream
Diffstat (limited to 'net')
-rw-r--r--net/ieee80211/ieee80211_tx.c25
-rw-r--r--net/ieee80211/softmac/Kconfig1
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_assoc.c22
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_auth.c12
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_event.c5
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_io.c169
6 files changed, 125 insertions, 109 deletions
diff --git a/net/ieee80211/ieee80211_tx.c b/net/ieee80211/ieee80211_tx.c
index 233d527c6953..6a5de1b84459 100644
--- a/net/ieee80211/ieee80211_tx.c
+++ b/net/ieee80211/ieee80211_tx.c
@@ -555,7 +555,8 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
555/* Incoming 802.11 strucure is converted to a TXB 555/* Incoming 802.11 strucure is converted to a TXB
556 * a block of 802.11 fragment packets (stored as skbs) */ 556 * a block of 802.11 fragment packets (stored as skbs) */
557int ieee80211_tx_frame(struct ieee80211_device *ieee, 557int ieee80211_tx_frame(struct ieee80211_device *ieee,
558 struct ieee80211_hdr *frame, int len) 558 struct ieee80211_hdr *frame, int hdr_len, int total_len,
559 int encrypt_mpdu)
559{ 560{
560 struct ieee80211_txb *txb = NULL; 561 struct ieee80211_txb *txb = NULL;
561 unsigned long flags; 562 unsigned long flags;
@@ -565,6 +566,9 @@ int ieee80211_tx_frame(struct ieee80211_device *ieee,
565 566
566 spin_lock_irqsave(&ieee->lock, flags); 567 spin_lock_irqsave(&ieee->lock, flags);
567 568
569 if (encrypt_mpdu && !ieee->sec.encrypt)
570 encrypt_mpdu = 0;
571
568 /* If there is no driver handler to take the TXB, dont' bother 572 /* If there is no driver handler to take the TXB, dont' bother
569 * creating it... */ 573 * creating it... */
570 if (!ieee->hard_start_xmit) { 574 if (!ieee->hard_start_xmit) {
@@ -572,32 +576,41 @@ int ieee80211_tx_frame(struct ieee80211_device *ieee,
572 goto success; 576 goto success;
573 } 577 }
574 578
575 if (unlikely(len < 24)) { 579 if (unlikely(total_len < 24)) {
576 printk(KERN_WARNING "%s: skb too small (%d).\n", 580 printk(KERN_WARNING "%s: skb too small (%d).\n",
577 ieee->dev->name, len); 581 ieee->dev->name, total_len);
578 goto success; 582 goto success;
579 } 583 }
580 584
585 if (encrypt_mpdu)
586 frame->frame_ctl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
587
581 /* When we allocate the TXB we allocate enough space for the reserve 588 /* When we allocate the TXB we allocate enough space for the reserve
582 * and full fragment bytes (bytes_per_frag doesn't include prefix, 589 * and full fragment bytes (bytes_per_frag doesn't include prefix,
583 * postfix, header, FCS, etc.) */ 590 * postfix, header, FCS, etc.) */
584 txb = ieee80211_alloc_txb(1, len, ieee->tx_headroom, GFP_ATOMIC); 591 txb = ieee80211_alloc_txb(1, total_len, ieee->tx_headroom, GFP_ATOMIC);
585 if (unlikely(!txb)) { 592 if (unlikely(!txb)) {
586 printk(KERN_WARNING "%s: Could not allocate TXB\n", 593 printk(KERN_WARNING "%s: Could not allocate TXB\n",
587 ieee->dev->name); 594 ieee->dev->name);
588 goto failed; 595 goto failed;
589 } 596 }
590 txb->encrypted = 0; 597 txb->encrypted = 0;
591 txb->payload_size = len; 598 txb->payload_size = total_len;
592 599
593 skb_frag = txb->fragments[0]; 600 skb_frag = txb->fragments[0];
594 601
595 memcpy(skb_put(skb_frag, len), frame, len); 602 memcpy(skb_put(skb_frag, total_len), frame, total_len);
596 603
597 if (ieee->config & 604 if (ieee->config &
598 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) 605 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
599 skb_put(skb_frag, 4); 606 skb_put(skb_frag, 4);
600 607
608 /* To avoid overcomplicating things, we do the corner-case frame
609 * encryption in software. The only real situation where encryption is
610 * needed here is during software-based shared key authentication. */
611 if (encrypt_mpdu)
612 ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
613
601 success: 614 success:
602 spin_unlock_irqrestore(&ieee->lock, flags); 615 spin_unlock_irqrestore(&ieee->lock, flags);
603 616
diff --git a/net/ieee80211/softmac/Kconfig b/net/ieee80211/softmac/Kconfig
index f2a27cc6ecb1..2811651cb134 100644
--- a/net/ieee80211/softmac/Kconfig
+++ b/net/ieee80211/softmac/Kconfig
@@ -2,6 +2,7 @@ config IEEE80211_SOFTMAC
2 tristate "Software MAC add-on to the IEEE 802.11 networking stack" 2 tristate "Software MAC add-on to the IEEE 802.11 networking stack"
3 depends on IEEE80211 && EXPERIMENTAL 3 depends on IEEE80211 && EXPERIMENTAL
4 select WIRELESS_EXT 4 select WIRELESS_EXT
5 select IEEE80211_CRYPT_WEP
5 ---help--- 6 ---help---
6 This option enables the hardware independent software MAC addon 7 This option enables the hardware independent software MAC addon
7 for the IEEE 802.11 networking stack. 8 for the IEEE 802.11 networking stack.
diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
index 5d90b9a6ee50..5e9a90651d04 100644
--- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
+++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -164,12 +164,28 @@ network_matches_request(struct ieee80211softmac_device *mac, struct ieee80211_ne
164} 164}
165 165
166static void 166static void
167ieee80211softmac_assoc_notify(struct net_device *dev, void *context) 167ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
168{ 168{
169 struct ieee80211softmac_device *mac = ieee80211_priv(dev); 169 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
170 ieee80211softmac_assoc_work((void*)mac); 170 ieee80211softmac_assoc_work((void*)mac);
171} 171}
172 172
173static void
174ieee80211softmac_assoc_notify_auth(struct net_device *dev, int event_type, void *context)
175{
176 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
177
178 switch (event_type) {
179 case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
180 ieee80211softmac_assoc_work((void*)mac);
181 break;
182 case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
183 case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:
184 ieee80211softmac_disassoc(mac);
185 break;
186 }
187}
188
173/* This function is called to handle userspace requests (asynchronously) */ 189/* This function is called to handle userspace requests (asynchronously) */
174void 190void
175ieee80211softmac_assoc_work(void *d) 191ieee80211softmac_assoc_work(void *d)
@@ -249,7 +265,7 @@ ieee80211softmac_assoc_work(void *d)
249 * Maybe we can hope to have more memory after scanning finishes ;) 265 * Maybe we can hope to have more memory after scanning finishes ;)
250 */ 266 */
251 dprintk(KERN_INFO PFX "Associate: Scanning for networks first.\n"); 267 dprintk(KERN_INFO PFX "Associate: Scanning for networks first.\n");
252 ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify, NULL); 268 ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify_scan, NULL);
253 if (ieee80211softmac_start_scan(mac)) 269 if (ieee80211softmac_start_scan(mac))
254 dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n"); 270 dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n");
255 return; 271 return;
@@ -284,7 +300,7 @@ ieee80211softmac_assoc_work(void *d)
284 * otherwise adding the notification would be racy. */ 300 * otherwise adding the notification would be racy. */
285 if (!ieee80211softmac_auth_req(mac, found)) { 301 if (!ieee80211softmac_auth_req(mac, found)) {
286 dprintk(KERN_INFO PFX "cannot associate without being authenticated, requested authentication\n"); 302 dprintk(KERN_INFO PFX "cannot associate without being authenticated, requested authentication\n");
287 ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify, NULL, GFP_KERNEL); 303 ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL);
288 } else { 304 } else {
289 printkl(KERN_WARNING PFX "Not authenticated, but requesting authentication failed. Giving up to associate\n"); 305 printkl(KERN_WARNING PFX "Not authenticated, but requesting authentication failed. Giving up to associate\n");
290 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found); 306 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found);
diff --git a/net/ieee80211/softmac/ieee80211softmac_auth.c b/net/ieee80211/softmac/ieee80211softmac_auth.c
index 084b6211f293..90b8484e509b 100644
--- a/net/ieee80211/softmac/ieee80211softmac_auth.c
+++ b/net/ieee80211/softmac/ieee80211softmac_auth.c
@@ -107,6 +107,7 @@ ieee80211softmac_auth_queue(void *data)
107 printkl(KERN_WARNING PFX "Authentication timed out with "MAC_FMT"\n", MAC_ARG(net->bssid)); 107 printkl(KERN_WARNING PFX "Authentication timed out with "MAC_FMT"\n", MAC_ARG(net->bssid));
108 /* Remove this item from the queue */ 108 /* Remove this item from the queue */
109 spin_lock_irqsave(&mac->lock, flags); 109 spin_lock_irqsave(&mac->lock, flags);
110 net->authenticating = 0;
110 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT, net); 111 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT, net);
111 cancel_delayed_work(&auth->work); /* just to make sure... */ 112 cancel_delayed_work(&auth->work); /* just to make sure... */
112 list_del(&auth->list); 113 list_del(&auth->list);
@@ -212,13 +213,13 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
212 aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE; 213 aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE;
213 spin_unlock_irqrestore(&mac->lock, flags); 214 spin_unlock_irqrestore(&mac->lock, flags);
214 215
215 /* Switch to correct channel for this network */ 216 /* Send our response */
216 mac->set_channel(mac->dev, net->channel);
217
218 /* Send our response (How to encrypt?) */
219 ieee80211softmac_send_mgt_frame(mac, aq->net, IEEE80211_STYPE_AUTH, aq->state); 217 ieee80211softmac_send_mgt_frame(mac, aq->net, IEEE80211_STYPE_AUTH, aq->state);
220 break; 218 return 0;
221 case IEEE80211SOFTMAC_AUTH_SHARED_PASS: 219 case IEEE80211SOFTMAC_AUTH_SHARED_PASS:
220 kfree(net->challenge);
221 net->challenge = NULL;
222 net->challenge_len = 0;
222 /* Check the status code of the response */ 223 /* Check the status code of the response */
223 switch(auth->status) { 224 switch(auth->status) {
224 case WLAN_STATUS_SUCCESS: 225 case WLAN_STATUS_SUCCESS:
@@ -229,6 +230,7 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
229 spin_unlock_irqrestore(&mac->lock, flags); 230 spin_unlock_irqrestore(&mac->lock, flags);
230 printkl(KERN_NOTICE PFX "Shared Key Authentication completed with "MAC_FMT"\n", 231 printkl(KERN_NOTICE PFX "Shared Key Authentication completed with "MAC_FMT"\n",
231 MAC_ARG(net->bssid)); 232 MAC_ARG(net->bssid));
233 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_AUTHENTICATED, net);
232 break; 234 break;
233 default: 235 default:
234 printkl(KERN_NOTICE PFX "Shared Key Authentication with "MAC_FMT" failed, error code: %i\n", 236 printkl(KERN_NOTICE PFX "Shared Key Authentication with "MAC_FMT" failed, error code: %i\n",
diff --git a/net/ieee80211/softmac/ieee80211softmac_event.c b/net/ieee80211/softmac/ieee80211softmac_event.c
index 4b153f7cc96c..f34fa2ef666b 100644
--- a/net/ieee80211/softmac/ieee80211softmac_event.c
+++ b/net/ieee80211/softmac/ieee80211softmac_event.c
@@ -78,7 +78,7 @@ ieee80211softmac_notify_callback(void *d)
78 struct ieee80211softmac_event event = *(struct ieee80211softmac_event*) d; 78 struct ieee80211softmac_event event = *(struct ieee80211softmac_event*) d;
79 kfree(d); 79 kfree(d);
80 80
81 event.fun(event.mac->dev, event.context); 81 event.fun(event.mac->dev, event.event_type, event.context);
82} 82}
83 83
84int 84int
@@ -167,6 +167,9 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve
167 if ((eventptr->event_type == event || eventptr->event_type == -1) 167 if ((eventptr->event_type == event || eventptr->event_type == -1)
168 && (eventptr->event_context == NULL || eventptr->event_context == event_ctx)) { 168 && (eventptr->event_context == NULL || eventptr->event_context == event_ctx)) {
169 list_del(&eventptr->list); 169 list_del(&eventptr->list);
170 /* User may have subscribed to ANY event, so
171 * we tell them which event triggered it. */
172 eventptr->event_type = event;
170 schedule_work(&eventptr->work); 173 schedule_work(&eventptr->work);
171 } 174 }
172 } 175 }
diff --git a/net/ieee80211/softmac/ieee80211softmac_io.c b/net/ieee80211/softmac/ieee80211softmac_io.c
index cc6cd56c85b1..09541611e48c 100644
--- a/net/ieee80211/softmac/ieee80211softmac_io.c
+++ b/net/ieee80211/softmac/ieee80211softmac_io.c
@@ -149,6 +149,56 @@ ieee80211softmac_hdr_3addr(struct ieee80211softmac_device *mac,
149 * shouldn't the sequence number be in ieee80211? */ 149 * shouldn't the sequence number be in ieee80211? */
150} 150}
151 151
152static u16
153ieee80211softmac_capabilities(struct ieee80211softmac_device *mac,
154 struct ieee80211softmac_network *net)
155{
156 u16 capability = 0;
157
158 /* ESS and IBSS bits are set according to the current mode */
159 switch (mac->ieee->iw_mode) {
160 case IW_MODE_INFRA:
161 capability = cpu_to_le16(WLAN_CAPABILITY_ESS);
162 break;
163 case IW_MODE_ADHOC:
164 capability = cpu_to_le16(WLAN_CAPABILITY_IBSS);
165 break;
166 case IW_MODE_AUTO:
167 capability = net->capabilities &
168 (WLAN_CAPABILITY_ESS|WLAN_CAPABILITY_IBSS);
169 break;
170 default:
171 /* bleh. we don't ever go to these modes */
172 printk(KERN_ERR PFX "invalid iw_mode!\n");
173 break;
174 }
175
176 /* CF Pollable / CF Poll Request */
177 /* Needs to be implemented, for now, the 0's == not supported */
178
179 /* Privacy Bit */
180 capability |= mac->ieee->sec.level ?
181 cpu_to_le16(WLAN_CAPABILITY_PRIVACY) : 0;
182
183 /* Short Preamble */
184 /* Always supported: we probably won't ever be powering devices which
185 * dont support this... */
186 capability |= WLAN_CAPABILITY_SHORT_PREAMBLE;
187
188 /* PBCC */
189 /* Not widely used */
190
191 /* Channel Agility */
192 /* Not widely used */
193
194 /* Short Slot */
195 /* Will be implemented later */
196
197 /* DSSS-OFDM */
198 /* Not widely used */
199
200 return capability;
201}
152 202
153/***************************************************************************** 203/*****************************************************************************
154 * Create Management packets 204 * Create Management packets
@@ -179,27 +229,6 @@ ieee80211softmac_assoc_req(struct ieee80211_assoc_request **pkt,
179 return 0; 229 return 0;
180 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_ASSOC_REQ, net->bssid, net->bssid); 230 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_ASSOC_REQ, net->bssid, net->bssid);
181 231
182 /* Fill in capability Info */
183 switch (mac->ieee->iw_mode) {
184 case IW_MODE_INFRA:
185 (*pkt)->capability = cpu_to_le16(WLAN_CAPABILITY_ESS);
186 break;
187 case IW_MODE_ADHOC:
188 (*pkt)->capability = cpu_to_le16(WLAN_CAPABILITY_IBSS);
189 break;
190 case IW_MODE_AUTO:
191 (*pkt)->capability = net->capabilities & (WLAN_CAPABILITY_ESS|WLAN_CAPABILITY_IBSS);
192 break;
193 default:
194 /* bleh. we don't ever go to these modes */
195 printk(KERN_ERR PFX "invalid iw_mode!\n");
196 break;
197 }
198 /* Need to add this
199 (*pkt)->capability |= mac->ieee->short_slot ?
200 cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME) : 0;
201 */
202 (*pkt)->capability |= mac->ieee->sec.level ? cpu_to_le16(WLAN_CAPABILITY_PRIVACY) : 0;
203 /* Fill in Listen Interval (?) */ 232 /* Fill in Listen Interval (?) */
204 (*pkt)->listen_interval = cpu_to_le16(10); 233 (*pkt)->listen_interval = cpu_to_le16(10);
205 234
@@ -239,17 +268,9 @@ ieee80211softmac_reassoc_req(struct ieee80211_reassoc_request **pkt,
239 return 0; 268 return 0;
240 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_REASSOC_REQ, net->bssid, net->bssid); 269 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_REASSOC_REQ, net->bssid, net->bssid);
241 270
242 /* Fill in capability Info */ 271 /* Fill in the capabilities */
243 (*pkt)->capability = mac->ieee->iw_mode == IW_MODE_MASTER ? 272 (*pkt)->capability = ieee80211softmac_capabilities(mac, net);
244 cpu_to_le16(WLAN_CAPABILITY_ESS) : 273
245 cpu_to_le16(WLAN_CAPABILITY_IBSS);
246 /*
247 (*pkt)->capability |= mac->ieee->short_slot ?
248 cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME) : 0;
249 */
250 (*pkt)->capability |= mac->ieee->sec.level ?
251 cpu_to_le16(WLAN_CAPABILITY_PRIVACY) : 0;
252
253 /* Fill in Listen Interval (?) */ 274 /* Fill in Listen Interval (?) */
254 (*pkt)->listen_interval = cpu_to_le16(10); 275 (*pkt)->listen_interval = cpu_to_le16(10);
255 /* Fill in the current AP MAC */ 276 /* Fill in the current AP MAC */
@@ -268,26 +289,27 @@ ieee80211softmac_reassoc_req(struct ieee80211_reassoc_request **pkt,
268static u32 289static u32
269ieee80211softmac_auth(struct ieee80211_auth **pkt, 290ieee80211softmac_auth(struct ieee80211_auth **pkt,
270 struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net, 291 struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net,
271 u16 transaction, u16 status) 292 u16 transaction, u16 status, int *encrypt_mpdu)
272{ 293{
273 u8 *data; 294 u8 *data;
295 int auth_mode = mac->ieee->sec.auth_mode;
296 int is_shared_response = (auth_mode == WLAN_AUTH_SHARED_KEY
297 && transaction == IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE);
298
274 /* Allocate Packet */ 299 /* Allocate Packet */
275 (*pkt) = (struct ieee80211_auth *)ieee80211softmac_alloc_mgt( 300 (*pkt) = (struct ieee80211_auth *)ieee80211softmac_alloc_mgt(
276 2 + /* Auth Algorithm */ 301 2 + /* Auth Algorithm */
277 2 + /* Auth Transaction Seq */ 302 2 + /* Auth Transaction Seq */
278 2 + /* Status Code */ 303 2 + /* Status Code */
279 /* Challenge Text IE */ 304 /* Challenge Text IE */
280 mac->ieee->open_wep ? 0 : 305 is_shared_response ? 0 : 1 + 1 + net->challenge_len
281 1 + 1 + WLAN_AUTH_CHALLENGE_LEN 306 );
282 );
283 if (unlikely((*pkt) == NULL)) 307 if (unlikely((*pkt) == NULL))
284 return 0; 308 return 0;
285 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_AUTH, net->bssid, net->bssid); 309 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_AUTH, net->bssid, net->bssid);
286 310
287 /* Algorithm */ 311 /* Algorithm */
288 (*pkt)->algorithm = mac->ieee->open_wep ? 312 (*pkt)->algorithm = cpu_to_le16(auth_mode);
289 cpu_to_le16(WLAN_AUTH_OPEN) :
290 cpu_to_le16(WLAN_AUTH_SHARED_KEY);
291 /* Transaction */ 313 /* Transaction */
292 (*pkt)->transaction = cpu_to_le16(transaction); 314 (*pkt)->transaction = cpu_to_le16(transaction);
293 /* Status */ 315 /* Status */
@@ -295,18 +317,20 @@ ieee80211softmac_auth(struct ieee80211_auth **pkt,
295 317
296 data = (u8 *)(*pkt)->info_element; 318 data = (u8 *)(*pkt)->info_element;
297 /* Challenge Text */ 319 /* Challenge Text */
298 if(!mac->ieee->open_wep){ 320 if (is_shared_response) {
299 *data = MFIE_TYPE_CHALLENGE; 321 *data = MFIE_TYPE_CHALLENGE;
300 data++; 322 data++;
301 323
302 /* Copy the challenge in */ 324 /* Copy the challenge in */
303 // *data = challenge length 325 *data = net->challenge_len;
304 // data += sizeof(u16); 326 data++;
305 // memcpy(data, challenge, challenge length); 327 memcpy(data, net->challenge, net->challenge_len);
306 // data += challenge length; 328 data += net->challenge_len;
307 329
308 /* Add the full size to the packet length */ 330 /* Make sure this frame gets encrypted with the shared key */
309 } 331 *encrypt_mpdu = 1;
332 } else
333 *encrypt_mpdu = 0;
310 334
311 /* Return the packet size */ 335 /* Return the packet size */
312 return (data - (u8 *)(*pkt)); 336 return (data - (u8 *)(*pkt));
@@ -396,6 +420,7 @@ ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
396{ 420{
397 void *pkt = NULL; 421 void *pkt = NULL;
398 u32 pkt_size = 0; 422 u32 pkt_size = 0;
423 int encrypt_mpdu = 0;
399 424
400 switch(type) { 425 switch(type) {
401 case IEEE80211_STYPE_ASSOC_REQ: 426 case IEEE80211_STYPE_ASSOC_REQ:
@@ -405,7 +430,7 @@ ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
405 pkt_size = ieee80211softmac_reassoc_req((struct ieee80211_reassoc_request **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg); 430 pkt_size = ieee80211softmac_reassoc_req((struct ieee80211_reassoc_request **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg);
406 break; 431 break;
407 case IEEE80211_STYPE_AUTH: 432 case IEEE80211_STYPE_AUTH:
408 pkt_size = ieee80211softmac_auth((struct ieee80211_auth **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg, (u16)(arg & 0xFFFF), (u16) (arg >> 16)); 433 pkt_size = ieee80211softmac_auth((struct ieee80211_auth **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg, (u16)(arg & 0xFFFF), (u16) (arg >> 16), &encrypt_mpdu);
409 break; 434 break;
410 case IEEE80211_STYPE_DISASSOC: 435 case IEEE80211_STYPE_DISASSOC:
411 case IEEE80211_STYPE_DEAUTH: 436 case IEEE80211_STYPE_DEAUTH:
@@ -434,52 +459,8 @@ ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
434 * or get rid of it alltogether? 459 * or get rid of it alltogether?
435 * Does this work for you now? 460 * Does this work for you now?
436 */ 461 */
437 ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *)pkt, pkt_size); 462 ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *)pkt,
438 463 IEEE80211_3ADDR_LEN, pkt_size, encrypt_mpdu);
439 kfree(pkt);
440 return 0;
441}
442
443
444/* Create an rts/cts frame */
445static u32
446ieee80211softmac_rts_cts(struct ieee80211_hdr_2addr **pkt,
447 struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net,
448 u32 type)
449{
450 /* Allocate Packet */
451 (*pkt) = kmalloc(IEEE80211_2ADDR_LEN, GFP_ATOMIC);
452 memset(*pkt, 0, IEEE80211_2ADDR_LEN);
453 if((*pkt) == NULL)
454 return 0;
455 ieee80211softmac_hdr_2addr(mac, (*pkt), type, net->bssid);
456 return IEEE80211_2ADDR_LEN;
457}
458
459
460/* Sends a control packet */
461static int
462ieee80211softmac_send_ctl_frame(struct ieee80211softmac_device *mac,
463 struct ieee80211softmac_network *net, u32 type, u32 arg)
464{
465 void *pkt = NULL;
466 u32 pkt_size = 0;
467
468 switch(type) {
469 case IEEE80211_STYPE_RTS:
470 case IEEE80211_STYPE_CTS:
471 pkt_size = ieee80211softmac_rts_cts((struct ieee80211_hdr_2addr **)(&pkt), mac, net, type);
472 break;
473 default:
474 printkl(KERN_DEBUG PFX "Unsupported Control Frame type: %i\n", type);
475 return -EINVAL;
476 }
477
478 if(pkt_size == 0)
479 return -ENOMEM;
480
481 /* Send the packet to the ieee80211 layer for tx */
482 ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *) pkt, pkt_size);
483 464
484 kfree(pkt); 465 kfree(pkt);
485 return 0; 466 return 0;