# HG changeset patch # User Joseph Jezak # Node ID d80ae859b8cd448f3e45befc121d9449de4dbbfe # Parent c5209368fcd8aa504ed41ee3b285dc1f2780bf9f Added CTS/RTS frames. diff -r c5209368fcd8 -r d80ae859b8cd ieee80211softmac_io.c --- a/ieee80211softmac_io.c Wed Nov 30 11:55:33 2005 +++ b/ieee80211softmac_io.c Wed Nov 30 13:55:27 2005 @@ -95,15 +95,17 @@ } /* - * Add a 3 Address Header + * Add a 2 Address Header */ void -ieee80211softmac_hdr_3addr(struct ieee80211softmac_device *mac, - struct ieee80211_hdr_3addr *header, u32 type, u8 *dest, u8 *bssid) +ieee80211softmac_hdr_2addr(struct ieee80211softmac_device *mac, + struct ieee80211_hdr_3addr *header, u32 type, u8 *dest) { /* Fill in the frame control flags */ header->frame_ctl = type; - header->frame_ctl |= mac->ieee->sec.level ? IEEE80211_FCTL_PROTECTED : 0; + /* Control packets always have WEP turned off */ + if(type > IEEE80211_STYPE_CFENDACK && type < IEEE80211_STYPE_PSPOLL) + header->frame_ctl |= mac->ieee->sec.level ? IEEE80211_FCTL_PROTECTED : 0; /* Fill in the duration */ header->duration_id = 0; @@ -117,6 +119,18 @@ memcpy(header->addr1, dest, ETH_ALEN); /* Fill in the Source Address */ memcpy(header->addr2, mac->ieee->dev->dev_addr, ETH_ALEN); + +} + + +/* Add a 3 Address Header */ +void +ieee80211softmac_hdr_3addr(struct ieee80211softmac_device *mac, + struct ieee80211_hdr_3addr *header, u32 type, u8 *dest, u8 *bssid) +{ + /* This is common with 2addr, so use that instead */ + ieee80211softmac_add_hdr_2addr(mac, (struct ieee80211_hdr_2addr *)header, type, dest); + /* Fill in the BSS ID */ if(bssid == NULL) memset(header->addr3, 0xFF, ETH_ALEN); @@ -365,6 +379,7 @@ pkt_size = data - pkt; break; default: + printk(PFX "Unsupported Management Frame type: %i\n", type); return -EINVAL; break; }; @@ -382,3 +397,33 @@ return 0; } + +int +ieee80211softmac_send_ctl_frame(struct ieee80211softmac_device *mac, + struct ieee80211_network *net, u32 type, u32 arg) +{ + u8 *pkt; + struct ieee80211_hdr_2addr *header_2addr; + int pkt_size = 0; + + switch(type) { + case IEEE80211_STYPE_RTS: + case IEEE80211_STYPE_CTS: + /* Allocate Packet */ + pkt = kmalloc(IEEE80211_2ADDR_LEN, GFP_ATOMIC); + header_2addr = (struct ieee80211_hdr_2addr *)pkt; + ieee80211softmac_add_hdr_2addr(mac, header_2addr, type, net->bssid); + pkt_size = IEEE80211_2ADDR_LEN; + break; + default: + printk(PFX "Unsupported Control Frame type: %i\n", type); + return -EINVAL; + break; + } + + /* Send the packet to the ieee80211 layer for tx */ + ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *) pkt, pkt_size); + + kfree(pkt); + return 0; +}