# HG changeset patch # User Joseph Jezak # Node ID 88d6e741e7589c0fad6238b9e7e9605eb65c7953 # Parent a7e8494deed411e6d48ce2b8d6c14739788fcee5 Made ieee80211softmac_io more functional. diff -r a7e8494deed4 -r 88d6e741e758 ieee80211softmac_auth.c --- a/ieee80211softmac_auth.c Sun Nov 27 15:02:27 2005 +++ b/ieee80211softmac_auth.c Mon Nov 28 05:54:12 2005 @@ -2,19 +2,54 @@ /* Sends an auth request to the desired AP */ -ieee80211softmac_auth( ) +int ieee80211softmac_auth_req( ) { + int ret; /* Send the auth packet */ - + if(ret = ieee80211softmac_send_mgt_frame(IEEE80211_STYPE_AUTH)) + return ret; + /* Put the softmac into AUTHORIZING state */ - /* Set a timer for auth timeout (to leave AUTHORIZING state if the AP doesn't respond) */ + /* Workqueue for timeout */ + queue_delayed_work( ); } -/* Sends a deauth request to the desired AP */ -ieee80211softmac_deauth( ) +/* + * Retry if we haven't gotten a response from the AP (?) + * Workqueue task for auth timeout + */ +void ieee80211softmac_auth_retry( ) { - /* Send the deauth packet */ + +} + +/* Handle the auth response from the AP + * This should be registered with ieee80211 as handle_auth + */ +int ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth) +{ + /* Update the status to Authenticated */ + + /* Cancel the timeout if required */ + +} + +/* + * Sends a deauth request to the desired AP + */ +int ieee80211softmac_deauth_req() { + /* Send the de-auth packet */ + + /* Put the softmac into (?) */ + +} + +/* + * This should be registered with ieee80211 as handle_deauth + */ +int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_auth *auth){ +{ /* Update the status (?) */ } diff -r a7e8494deed4 -r 88d6e741e758 ieee80211softmac_io.c --- a/ieee80211softmac_io.c Sun Nov 27 15:02:27 2005 +++ b/ieee80211softmac_io.c Mon Nov 28 05:54:12 2005 @@ -34,27 +34,26 @@ #include "ieee80211softmac_priv.h" - /* Helper functions for inserting data into the frames */ /* * Adds an SSID element to the frame * */ -static u8 * +u8 * ieee80211softmac_add_ssid(u8 *dst, const u8 *ssid, u32 len) { *dst++ = MFIE_TYPE_SSID; *dst++ = len; memcpy(dst, ssid, len); - return dst + len; + return dst + len; } /* * Adds a Supported Rates Information Element to the frame * */ -static u8 * +u8 * ieee80211softmac_add_rates(u8 *dst, const u8 *rates, u32 rates_count) { *dst++ = MFIE_TYPE_RATES; @@ -76,26 +75,39 @@ size = size + IEEE80211_3ADDR_LEN; if(size > IEEE80211_DATA_LEN) return NULL; - - /* Allocate the skb */ + /* Allocate the frame */ data = kmalloc(size, GFP_ATOMIC); return data; } -/* Add a header to a management frame */ -static u8 * ieee80211softmac_add_3addr(struct ieee80211softmac_device* mac, - u8 * dst, struct ieee80211_network *net, u32 type) -{ - struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *)dst; - /* Setup the FC */ - - /* Destination Address */ - - /* Source Address */ - - /* BSSID */ - - /* Note dur_id and seq_ctl are set by the tx'r (IS HEADER?) */ +/* + * Add a 3 Address Header + */ +void ieee80211softmac_hdr_3addr(struct ieee80211softmac_device *mac, + struct ieee80211_hdr_3addr *header, u32 type, u8 *dest, u8 *bssid) +{ + /* Fill in the frame control flags */ + header->frame_ctl = type; + header->frame_ctl |= mac->ieee->sec.level ? IEEE80211_FCTL_PROTECTED : 0; + + /* Fill in the duration */ + /* FIXME: How do I find this? */ + + /* Fill in the Destination Address */ + if(dest == NULL) + memset(header->addr1, 0xFF, ETH_ALEN); + else + memcpy(header->addr1, dest, ETH_ALEN); + /* Fill in the Source Address */ + memcpy(header->addr2, mac->ieee->dev->dev_addr, ETH_ALEN); + /* Fill in the BSS ID */ + if(bssid == NULL) + memset(header->addr3, 0xFF, ETH_ALEN); + else + memcpy(header->addr3, bssid, ETH_ALEN); + + /* Fill in the sequence # */ + /* FIXME: I need to add this to the softmac struct */ } /* @@ -111,25 +123,74 @@ ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac, struct ieee80211_network *net, u32 type, u32 arg) { + union { + struct ieee80211_assoc_request *assoc; + struct ieee80211_reassoc_request *reassoc; + struct ieee80211_auth *auth; + struct ieee80211_disassoc *disassoc; + struct ieee80211_probe_request *probe_req; + } p; + int pkt_size = 0; u16 status, seq, reason; u8 *data, *pkt; switch (type) { case IEEE80211_STYPE_ASSOC_REQ: + pkt_size = ( + 2 + /* Capability Info */ + 2 + /* Listen Interval */ + /* SSID IE */ + 2 + 2 + IW_ESSID_MAX_SIZE + + /* Rates IE */ + 2 + 2 + MAX_RATES_LENGTH + ); + pkt = ieee80211softmac_alloc_mgt(pkt_size); + if (pkt == NULL) + return -ENOMEM; + p.assoc = (struct ieee80211_assoc_request *)pkt; + ieee80211softmac_hdr_3addr(mac, &(p.assoc->header), type, net->bssid, net->bssid); + + /* Fill in capability Info */ + p.assoc->capability = 0; + /* Fill in Listen Interval */ + p.assoc->listen_interval = 0; + + data = (u8 *)p.assoc->info_element; + /* Add SSID */ + data = ieee80211softmac_add_ssid(data, net->ssid, net->ssid_len); + /* Add Rates */ + data = ieee80211softmac_add_rates(data, net->rates, net->rates_len); + break; case IEEE80211_STYPE_REASSOC_REQ: pkt_size = ( - 2 + /* Capability Info */ - 2 + /* Listen Interval */ - /* MAC of AP if REASSOC */ - (type == IEEE80211_STYPE_REASSOC_REQ ? - ETH_ALEN : 0) - /* SSID */ - /* Rates */ + 2 + /* Capability Info */ + 2 + /* Listen Interval */ + ETH_ALEN + /* AP MAC */ + /* SSID IE */ + 2 + 2 + IW_ESSID_MAX_SIZE + + /* Rates IE */ + 2 + 2 + MAX_RATES_LENGTH ); pkt = ieee80211softmac_alloc_mgt(pkt_size); if (pkt == NULL) return -ENOMEM; + p.reassoc = (struct ieee80211_reassoc_request *)pkt; + ieee80211softmac_hdr_3addr(mac, &(p.reassoc->header), type, net->bssid, net->bssid); + + /* Fill in capability Info */ + p.assoc->capability = 0; + /* Fill in Listen Interval */ + p.assoc->listen_interval = 0; + /* Fill in the current AP MAC */ + memcpy(p.reassoc->current_ap, mac->ieee->bssid, ETH_ALEN); + + data = (u8 *)p.reassoc->info_element; + /* Add SSID */ + data = ieee80211softmac_add_ssid(data, net->ssid, net->ssid_len); + /* Add Rates */ + data = ieee80211softmac_add_rates(data, net->rates, net->rates_len); + // data = ieee80211softmac_add_rates(data, rates, rate_count); break; case IEEE80211_STYPE_AUTH: status = (arg >> 16) & 0xFFFF; /* Status field */ @@ -137,28 +198,44 @@ pkt_size = ( 2 + /* Auth Algorithm */ 2 + /* Auth Transaction Seq */ - 2 /* Status Code */ - /*FIXME*/ /* Challenge Text */ - + 2 + /* Status Code */ + /* Challenge Text IE */ + mac->ieee->open_wep ? 0 : + 2 + 2 + WLAN_AUTH_CHALLENGE_LEN ); /* Allocate Packet */ pkt = ieee80211softmac_alloc_mgt(pkt_size); if(pkt == NULL) return -ENOMEM; - data = pkt + IEEE80211_3ADDR_LEN; + p.auth = (struct ieee80211_auth *)pkt; + ieee80211softmac_hdr_3addr(mac, &(p.auth->header), type, net->bssid, net->bssid); /* Algorithm */ - *data = cpu_to_le16(0); /* FIXME Open, for now */ - data += sizeof(u16); - + p.auth->algorithm = cpu_to_le16(mac->ieee->open_wep ? + WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY); /* Transaction */ - *data = cpu_to_le16(seq); - data += sizeof(u16); - + p.auth->transaction = cpu_to_le16(seq); /* Status */ - *data = cpu_to_le16(status); - data += sizeof(u16); - /* FIXME Challenge Text */ + p.auth->status = cpu_to_le16(status); + + data = (u8 *)p.auth->info_element; + /* Challenge Text */ + if(!mac->ieee->open_wep){ + *data = MFIE_TYPE_CHALLENGE; + data += 2; + + pkt_size -= WLAN_AUTH_CHALLENGE_LEN; + /* Find length of Challenge */ + + /* Copy it in */ + // *data = challenge length + // data += sizeof(u16); + // memcpy(data, challenge, challenge length); + // data += challenge length; + + /* Add the full size to the packet length */ + // pkt_size += challenge length; + } break; /* These have the same format */ case IEEE80211_STYPE_DISASSOC: @@ -169,20 +246,37 @@ pkt = ieee80211softmac_alloc_mgt(pkt_size); if(pkt == NULL) return -ENOMEM; - data = pkt + IEEE80211_3ADDR_LEN; + p.disassoc = (struct ieee80211_disassoc *)pkt; + ieee80211softmac_hdr_3addr(mac, &(p.disassoc->header), type, net->bssid, net->bssid); /* Reason */ - *data = cpu_to_le16(reason); - data += sizeof(u16); + p.disassoc->reason = cpu_to_le16(reason); + break; + case IEEE80211_STYPE_PROBE_REQ: + /* FIXME: Not complete */ + pkt_size = ( + 8 + /* Timestamp */ + 2 + /* Beacon Interval */ + 2 + /* Capability Info */ + /* SSID IE */ + 2 + 2 + IW_ESSID_MAX_SIZE + + 7 + /* FH Parameter Set */ + 2 + /* DS Parameter Set */ + 8 + /* CF Parameter Set */ + 4 /* IBSS Parameter Set */ + ); + /* Allocate Packet */ + pkt = ieee80211softmac_alloc_mgt(pkt_size); + if(pkt == NULL) + return -ENOMEM; + p.probe_req = (struct ieee80211_probe_request *)pkt; + ieee80211softmac_hdr_3addr(mac, &(p.probe_req->header), type, NULL, NULL); break; default: return -EINVAL; break; }; - /* Add the header */ - ieee80211softmac_add_3addr(mac, pkt, net, type); - /* Send the packet to the ieee80211 layer for tx */ ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *) pkt, pkt_size); @@ -191,11 +285,3 @@ return 0; } - - -/* Sends a beacon frame */ -int -ieee80211softmac_send_bcn_frame(void) -{ - return 0; -} # HG changeset patch # User Joseph Jezak # Node ID c3a7508e7560d0a425278c7483c52fa9ee3abcbc # Parent 88d6e741e7589c0fad6238b9e7e9605eb65c7953 Added some auth outlines. diff -r 88d6e741e758 -r c3a7508e7560 ieee80211softmac_auth.c --- a/ieee80211softmac_auth.c Mon Nov 28 05:54:12 2005 +++ b/ieee80211softmac_auth.c Mon Nov 28 05:54:19 2005 @@ -9,7 +9,8 @@ if(ret = ieee80211softmac_send_mgt_frame(IEEE80211_STYPE_AUTH)) return ret; - /* Put the softmac into AUTHORIZING state */ + /* Set the state to Authenticating (LOCK?) */ + sm->ieee->state = IEEE80211_AUTHENTICATING; /* Workqueue for timeout */ queue_delayed_work( ); @@ -21,7 +22,14 @@ */ void ieee80211softmac_auth_retry( ) { - + int ret; + /* Test the retry counter to see if we need to do an AUTH again */ + + /* Decrement the retry counter (?) */ + /* Send the auth packet */ + if(ret = ieee80211softmac_auth_req( )) + + /* Add a new workqueue */ } @@ -30,20 +38,32 @@ */ int ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth) { - /* Update the status to Authenticated */ - - /* Cancel the timeout if required */ + struct ieee80211softmac_device *sm = ieee80211_priv(dev); + if(auth->algorithm == WLAN_AUTH_OPEN) { + /* Check the status code of the response */ + if (auth->staus == WLAN_STATUS_SUCCESS) { + /* Update the status to Authenticated (LOCK?) */ + sm->ieee->state = IEEE80211_AUTHENTICATED; + /* Cancel the timeout if required */ + cancel_delayed_work( ); + + /* FIXME Do we fire off an associate req now? */ + } + /* FIXME deal with not authenticated reasons */ + } } /* * Sends a deauth request to the desired AP */ -int ieee80211softmac_deauth_req() { +int ieee80211softmac_deauth_req(int reason) { + int ret; /* Send the de-auth packet */ - - /* Put the softmac into (?) */ - + if(ret = ieee80211softmac_send_mgt_frame(IEEE80211_STYPE_DEAUTH)) + return ret; + + /* Put the softmac into which state(?) */ } /* @@ -51,5 +71,6 @@ */ int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_auth *auth){ { - /* Update the status (?) */ + + /* Update the state (?) */ } diff -r 88d6e741e758 -r c3a7508e7560 ieee80211softmac_io.c --- a/ieee80211softmac_io.c Mon Nov 28 05:54:12 2005 +++ b/ieee80211softmac_io.c Mon Nov 28 05:54:19 2005 @@ -40,7 +40,7 @@ * Adds an SSID element to the frame * */ -u8 * +static u8 * ieee80211softmac_add_ssid(u8 *dst, const u8 *ssid, u32 len) { *dst++ = MFIE_TYPE_SSID; @@ -53,7 +53,7 @@ * Adds a Supported Rates Information Element to the frame * */ -u8 * +static u8 * ieee80211softmac_add_rates(u8 *dst, const u8 *rates, u32 rates_count) { *dst++ = MFIE_TYPE_RATES; @@ -152,8 +152,16 @@ ieee80211softmac_hdr_3addr(mac, &(p.assoc->header), type, net->bssid, net->bssid); /* Fill in capability Info */ + p.assoc->capability = cpu_to_le16(mac->ieee->iw_mode == IW_MODE_MASTER ? + WLAN_CAPABILITY_ESS : WLAN_CAPABILITY_IBSS); + /* Need to add this + p.assoc->capability |= cpu_to_le16(mac->ieee->short_slot ? + WLAN_CAPABILITY_SHORT_SLOT_TIME : 0); + */ + p.assoc->capability |= cpu_to_le16(mac->ieee->sec.level ? + WLAN_CAPABILITY_PRIVACY : 0); p.assoc->capability = 0; - /* Fill in Listen Interval */ + /* Fill in Listen Interval (?) */ p.assoc->listen_interval = 0; data = (u8 *)p.assoc->info_element; @@ -179,8 +187,16 @@ ieee80211softmac_hdr_3addr(mac, &(p.reassoc->header), type, net->bssid, net->bssid); /* Fill in capability Info */ - p.assoc->capability = 0; - /* Fill in Listen Interval */ + p.reassoc->capability = cpu_to_le16(mac->ieee->iw_mode == IW_MODE_MASTER ? + WLAN_CAPABILITY_ESS : WLAN_CAPABILITY_IBSS); + /* + p.reassoc->capability |= cpu_to_le16(mac->ieee->short_slot ? + WLAN_CAPABILITY_SHORT_SLOT_TIME : 0); + */ + p.reassoc->capability |= cpu_to_le16(mac->ieee->sec.level ? + WLAN_CAPABILITY_PRIVACY : 0); + + /* Fill in Listen Interval (?) */ p.assoc->listen_interval = 0; /* Fill in the current AP MAC */ memcpy(p.reassoc->current_ap, mac->ieee->bssid, ETH_ALEN); @@ -190,7 +206,6 @@ data = ieee80211softmac_add_ssid(data, net->ssid, net->ssid_len); /* Add Rates */ data = ieee80211softmac_add_rates(data, net->rates, net->rates_len); - // data = ieee80211softmac_add_rates(data, rates, rate_count); break; case IEEE80211_STYPE_AUTH: status = (arg >> 16) & 0xFFFF; /* Status field */ # HG changeset patch # User Joseph Jezak # Node ID bb0ca81b925afdc8890ab50383bb7ae47715adc6 # Parent c3a7508e7560d0a425278c7483c52fa9ee3abcbc Added probe_req. diff -r c3a7508e7560 -r bb0ca81b925a ieee80211softmac_io.c --- a/ieee80211softmac_io.c Mon Nov 28 05:54:19 2005 +++ b/ieee80211softmac_io.c Mon Nov 28 06:47:51 2005 @@ -38,7 +38,7 @@ /* * Adds an SSID element to the frame - * + * */ static u8 * ieee80211softmac_add_ssid(u8 *dst, const u8 *ssid, u32 len) @@ -51,7 +51,7 @@ /* * Adds a Supported Rates Information Element to the frame - * + * This is wrong, as is the EX Rates (need to seperate them somehow) */ static u8 * ieee80211softmac_add_rates(u8 *dst, const u8 *rates, u32 rates_count) @@ -64,6 +64,20 @@ return dst + rates_count; } +/* + * Adds an Extended Supported Rates Information Element to the frame + * + */ +static u8 * +ieee80211softmac_add_ex_rates(u8 *dst, const u8 *rates, u32 rates_count) +{ + *dst++ = MFIE_TYPE_RATES_EX; + if(rates_count > MAX_RATES_EX_LENGTH) + rates_count = MAX_RATES_EX_LENGTH; + *dst++ = rates_count; + memcpy(dst, rates, rates_count); + return dst + rates_count; +} /* Allocate a management frame */ static u8 * @@ -83,7 +97,8 @@ /* * Add a 3 Address Header */ -void ieee80211softmac_hdr_3addr(struct ieee80211softmac_device *mac, +void +ieee80211softmac_hdr_3addr(struct ieee80211softmac_device *mac, struct ieee80211_hdr_3addr *header, u32 type, u8 *dest, u8 *bssid) { /* Fill in the frame control flags */ @@ -129,6 +144,7 @@ struct ieee80211_auth *auth; struct ieee80211_disassoc *disassoc; struct ieee80211_probe_request *probe_req; + struct ieee80211_probe_response *probe_resp; } p; int pkt_size = 0; @@ -143,7 +159,10 @@ /* SSID IE */ 2 + 2 + IW_ESSID_MAX_SIZE + /* Rates IE */ - 2 + 2 + MAX_RATES_LENGTH + 2 + 2 + MAX_RATES_LENGTH + + /* Extended Rates IE */ + 2 + 2 + MAX_RATES_EX_LENGTH + /* Other IE's? Optional? */ ); pkt = ieee80211softmac_alloc_mgt(pkt_size); if (pkt == NULL) @@ -169,6 +188,7 @@ data = ieee80211softmac_add_ssid(data, net->ssid, net->ssid_len); /* Add Rates */ data = ieee80211softmac_add_rates(data, net->rates, net->rates_len); + /* Add extended rates */ break; case IEEE80211_STYPE_REASSOC_REQ: pkt_size = ( @@ -206,6 +226,7 @@ data = ieee80211softmac_add_ssid(data, net->ssid, net->ssid_len); /* Add Rates */ data = ieee80211softmac_add_rates(data, net->rates, net->rates_len); + /* Add extended rates */ break; case IEEE80211_STYPE_AUTH: status = (arg >> 16) & 0xFFFF; /* Status field */ @@ -268,6 +289,35 @@ p.disassoc->reason = cpu_to_le16(reason); break; case IEEE80211_STYPE_PROBE_REQ: + /* + * FIXME: Probe request implies that we don't have a network + * setup yet? + */ + pkt_size = ( + /* SSID of requested network */ + 2 + 2 + IW_ESSID_MAX_SIZE + + /* Rates IE */ + 2 + 2 + MAX_RATES_LENGTH + + /* Extended Rates IE */ + 2 + 2 + MAX_RATES_EX_LENGTH + ); + /* Allocate Packet */ + pkt = ieee80211softmac_alloc_mgt(pkt_size); + if(pkt == NULL) + return -ENOMEM; + p.probe_req = (struct ieee80211_probe_request *)pkt; + ieee80211softmac_hdr_3addr(mac, &(p.probe_req->header), type, NULL, NULL); + + data = (u8 *)p.probe_req->info_element; + /* Add SSID */ + data = ieee80211softmac_add_ssid(data, net->ssid, net->ssid_len); + /* Add Rates */ + data = ieee80211softmac_add_rates(data, net->rates, net->rates_len); + /* Add Extended Rates */ + data = ieee80211softmac_add_ex_rates(data, net->rates, net->rates_len); + + break; + case IEEE80211_STYPE_PROBE_RESP: /* FIXME: Not complete */ pkt_size = ( 8 + /* Timestamp */ @@ -284,8 +334,7 @@ pkt = ieee80211softmac_alloc_mgt(pkt_size); if(pkt == NULL) return -ENOMEM; - p.probe_req = (struct ieee80211_probe_request *)pkt; - ieee80211softmac_hdr_3addr(mac, &(p.probe_req->header), type, NULL, NULL); + p.probe_resp = (struct ieee80211_probe_response *)pkt; break; default: return -EINVAL;