# HG changeset patch # User Joseph Jezak # Node ID ec3ea487a296aca84ed627a371ba89bc24d41d28 # Parent b1dfc97ab7a724f6b03d7f8d29225ac7519b10c7 Added ieee80211softmac_io, ieee80211_assoc and ieee80211_auth diff -r b1dfc97ab7a7 -r ec3ea487a296 ieee80211softmac_assoc.c --- /dev/null Wed Nov 23 11:59:04 2005 +++ b/ieee80211softmac_assoc.c Fri Nov 25 16:27:40 2005 @@ -0,0 +1,24 @@ +/* Sends out an association request to the desired AP */ +ieee80211softmac_assoc( ) +{ + /* Send association request */ + + /* Change the state to associating */ + + /* Set a timer for timeout (?) */ +} + +ieee80211softmac_reassoc( ) +{ + +} + + +/* Sends out a deassociation request to the desired AP */ +ieee80211softmac_deassoc() +{ + /* Send a deaassociation request */ + + /* Change our state */ + +} diff -r b1dfc97ab7a7 -r ec3ea487a296 ieee80211softmac_auth.c --- /dev/null Wed Nov 23 11:59:04 2005 +++ b/ieee80211softmac_auth.c Fri Nov 25 16:27:40 2005 @@ -0,0 +1,18 @@ + +/* Sends an auth request to the desired AP */ +ieee80211softmac_auth( ) +{ + /* Send the auth packet */ + + /* Put the softmac into AUTHORIZING state */ + + /* Set a timer for auth timeout (to leave AUTHORIZING state if the AP doesn't respond) */ +} + +/* Sends a deauth request to the desired AP */ +ieee80211softmac_deauth( ) +{ + /* Send the deauth packet */ + + /* Update the status (?) */ +} diff -r b1dfc97ab7a7 -r ec3ea487a296 ieee80211softmac_io.c --- /dev/null Wed Nov 23 11:59:04 2005 +++ b/ieee80211softmac_io.c Fri Nov 25 16:27:40 2005 @@ -0,0 +1,176 @@ +/* + * Some parts based on code from net80211 + * Copyright (c) 2001 Atsushi Onoe + * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "ieee80211softmac.h" + +/* Helper functions for inserting data into the frames */ + +/* + * Adds an SSID element to the frame + * + */ +static u8 * +ieee80211softmac_add_ssid(u8 *dst, const u8 *ssid, u32 len) +{ + *dst++ = MFIE_TYPE_SSID; + *dst++ = len; + memcpy(dst, ssid, len); + return dst + len; +} + +/* + * Adds a Supported Rates Information Element to the frame + * + */ +static u8 * +ieee80211softmac_add_rates(u8 *dst, const u8 *rates, u32 rates_count) +{ + *dst++ = MFIE_TYPE_RATES; + if(rates_count > MAX_RATES_LENGTH) + rates_count = MAX_RATES_LENGTH; + *dst++ = rates_count; + memcpy(dst, rates, rates_count); + return dst + rates_count; +} + + +/* Allocate a management frame */ +static sk_buff * +ieee80211softmac_alloc_mgt(uint32 size) +{ + struct sk_buff *skb; + /* Add the header and FCS to the size */ + size = size + IEEE80211_3ADDR_LEN; + if(size > IEEE80211_DATA_LEN) + return NULL; + + /* Allocate the skb */ + skb = skb_alloc(size, GPF_ATOMIC); + return skb; +} + +/* Add a header to a management frame */ +static u8 * ieee80211softmac_add_3addr(struct ieee80211softmac_device* mac, + u8 * dst, struct ieee80211softmac_network *net, u32 type) +{ + struct ieee80211_hdr_3addr *header = (iee80211_hdr_3addr *)dst; + /* Setup the FC */ + + /* DA */ + + /* BA */ + + /* BSSID */ + + /* Note dur_id and seq_ctl are set by the tx'r (IS HEADER?) */ +} + +/* + * Send a management frame. + * + * mac - ieee80211softmac_device reference + * net - Network info to send the packet on + * type - Type of frame to generate + * arg - Optional args for the frame + * + */ + +ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac, + struct ieee80211softmac_network *net, u32 type, u32 arg) +{ + struct sk_buff *skb; + struct ieee80211_device *ieee = mac->ieee; + int pkt_size = 0; + + switch (type) { + case IEEE80211_STYPE_ASSOC_REQ: + case IEEE80211_STYPE_REASSOC_REQ: + break; + case IEEE80211_STYPE_AUTH: + u16 status = (arg >> 16) & 0xFFFF; /* Status field */ + u16 seq = (arg & 0xFFFF); /* Seq Number */ + struct ieee80211_auth *auth; + pkt_size = ( + 2 + /* Auth Algorithm */ + 2 + /* Auth Transaction Seq */ + 2 /* Status Code */ + /*FIXME*/ /* Challenge Text */ + + ); + /* Allocate Packet */ + skb = ieee80211softmac_alloc_mgt(pkt_size, GPF_ATOMIC); + if(skb == NULL) + return -ENOMEM; + auth = (ieee80211_auth *) skb->data; + + auth->algorithm = cpu_to_le16(0); /* FIXME Open, for now */ + auth->transaction = cpu_to_le16(seq); + auth->status = cpu_to_le16(status); + /* FIXME Challenge Text */ + break; + /* These have the same format */ + case IEEE80211_STYPE_DISASSOC: + case IEEE80211_STYPE_DEAUTH: + struct ieee80211_disassoc *disassoc; + int reason = arg & 0xFFFF; + pkt_size = 2; /* Reason Code */ + /* Allocate Packet */ + skb = ieee80211softmac_alloc_mgt(pkt_size, GPF_ATOMIC); + if(skb == NULL) + return -ENOMEM; + disassoc = (ieee80211_disassoc *)skb->data; + disassoc->reason = cpu_to_le16(reason); + break; + default: + return = -EINVAL; + break; + }; + + /* Add the header */ + ieee80211softmac_add_3addr(mac, skb->head, net, type); + + /* Send the packet to the ieee80211 layer for tx */ + ieee80211_xmit(skb, ieee->dev); + + /* FIXME check if the xmit free's the skb and if not, + * is it safe to do so here? */ + return 0; +} + + +/* Sends a beacon frame */ +ieee80211softmac_send_bcn_frame( ) +{ + +}