Moved the frame header formatting from the prism2 driver up into p80211.

Had to change the declaration and usage of the wlandev->macmode variable
in the process.
This commit is contained in:
mark 2000-02-03 04:37:55 +00:00
parent cf10e2c98d
commit 865125e0ba
6 changed files with 73 additions and 27 deletions

View File

@ -7,7 +7,7 @@ all:
clean:
set -e; for d in $(DIRS); do $(MAKE) -C $$d clean ; done
rm -f core core.* *.o .*.o *.s *.a .depend tmp_make *~ tags
for i in *_obj; do if [ -d $i ]; then rm -fr $i; fi; done
set -e; for i in *_obj; do if [ -d $i ]; then rm -fr $i; fi; done
install:
set -e; for d in $(DIRS); do $(MAKE) -C $$d install ; done

View File

@ -238,14 +238,19 @@ typedef struct wlan_pb
UINT32 wep_icv;
} wlan_pb_t;
/* Circular include trick */
struct wlandevice;
/*================================================================*/
/* Externs */
/*================================================================*/
/*Function Declarations */
int p80211pb_ether_to_p80211( UINT32 ethconv, wlan_pb_t *pb);
int p80211pb_p80211_to_ether( UINT32 ethconv, wlan_pb_t *pb);
int p80211pb_ether_to_p80211( struct wlandevice *wlandev,
UINT32 ethconv, wlan_pb_t *pb);
int p80211pb_p80211_to_ether( struct wlandevice *wlandev,
UINT32 ethconv, wlan_pb_t *pb);
void p80211pb_freeskb( void *buf, int size);
void p80211pb_kfree_s( void *buf, int size);
wlan_pb_t* p80211pb_alloc(void);

View File

@ -39,10 +39,10 @@
#define WLAN_DEVICE_CLOSED 0
#define WLAN_DEVICE_OPEN 1
#define WLAN_MODE_NONE 0
#define WLAN_MODE_IBSS_STA 1
#define WLAN_MODE_ESS_STA 2
#define WLAN_MODE_ESS_AP 3
#define WLAN_MACMODE_NONE 0
#define WLAN_MACMODE_IBSS_STA 1
#define WLAN_MACMODE_ESS_STA 2
#define WLAN_MACMODE_ESS_AP 3
/*================================================================*/
/* Macros */
@ -76,7 +76,7 @@ typedef struct wlandevice
/* 802.11 State */
UINT8 bssid[WLAN_BSSID_LEN];
UINT32 wlanmode;
UINT32 macmode;
/* Request/Confirm i/f state (used by p80211) */
UINT32 request_pending; /* flag, access atomically */

View File

@ -48,12 +48,21 @@
#include <linux/types.h>
#include <linux/skbuff.h>
#include <linux/malloc.h>
#include <linux/netdevice.h>
/*================================================================*/
/* Project Includes */
#include <wlan/version.h>
#include <wlan/p80211types.h>
#include <wlan/p80211hdr.h>
#include <wlan/p80211conv.h>
#include <wlan/p80211mgmt.h>
#include <wlan/p80211msg.h>
#include <wlan/p80211netdev.h>
#include <wlan/p80211ioctl.h>
#include <wlan/p80211req.h>
/*================================================================*/
/* Local Constants */
@ -108,9 +117,14 @@ static UINT8 oui_8021h[] = {0x00, 0x00, 0xf8};
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
int p80211pb_ether_to_p80211( UINT32 ethconv, wlan_pb_t *pb)
int p80211pb_ether_to_p80211( wlandevice_t *wlandev, UINT32 ethconv, wlan_pb_t *pb)
{
UINT16 proto;
UINT16 fc;
UINT8 *a1 = NULL;
UINT8 *a2 = NULL;
UINT8 *a3 = NULL;
DBFENTER;
if ( ethconv == WLAN_ETHCONV_ENCAP ) { /* simplest case */
@ -177,6 +191,43 @@ int p80211pb_ether_to_p80211( UINT32 ethconv, wlan_pb_t *pb)
}
}
/* Set up the 802.11 header */
/* It's a data frame */
fc = host2ieee16( WLAN_SET_FC_FTYPE(WLAN_FTYPE_DATA) |
WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DATAONLY));
pb->p80211_hdr->a3.dur = 0;
pb->p80211_hdr->a3.seq = 0;
switch ( wlandev->macmode ) {
case WLAN_MACMODE_IBSS_STA:
a1 = pb->eth_hdr->daddr;
a2 = wlandev->netdev->dev_addr;
a3 = wlandev->bssid;
break;
case WLAN_MACMODE_ESS_STA:
fc |= host2ieee16(WLAN_SET_FC_TODS(1));
a1 = wlandev->bssid;
a2 = wlandev->netdev->dev_addr;
a3 = pb->eth_hdr->daddr;
break;
case WLAN_MACMODE_ESS_AP:
fc |= host2ieee16(WLAN_SET_FC_FROMDS(1));
a1 = pb->eth_hdr->daddr;
a2 = wlandev->bssid;
a3 = wlandev->netdev->dev_addr;
break;
default:
WLAN_LOG_ERROR0("Error: Converting eth to wlan in unknown mode.\n");
return 1;
break;
}
memcpy( pb->p80211_hdr->a3.a1, a1, WLAN_ADDR_LEN);
memcpy( pb->p80211_hdr->a3.a2, a2, WLAN_ADDR_LEN);
memcpy( pb->p80211_hdr->a3.a3, a3, WLAN_ADDR_LEN);
/* Note that lower layers may set more bits in the fc field */
DBFEXIT;
return 0;
}
@ -214,7 +265,7 @@ int p80211pb_ether_to_p80211( UINT32 ethconv, wlan_pb_t *pb)
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
int p80211pb_p80211_to_ether( UINT32 ethconv, wlan_pb_t *pb)
int p80211pb_p80211_to_ether( wlandevice_t *wlandev, UINT32 ethconv, wlan_pb_t *pb)
{
UINT8 *daddr = NULL;
UINT8 *saddr = NULL;

View File

@ -58,8 +58,8 @@
#include <wlan/version.h>
#include <wlan/p80211types.h>
#include <wlan/p80211hdr.h>
#include <wlan/p80211mgmt.h>
#include <wlan/p80211conv.h>
#include <wlan/p80211mgmt.h>
#include <wlan/p80211msg.h>
#include <wlan/p80211netdev.h>
#include <wlan/p80211ioctl.h>
@ -272,7 +272,7 @@ void p80211netdev_rx(wlandevice_t *wlandev, wlan_pb_t *pb)
dev->interrupt = 1;
if (dev->start) {
if ( p80211pb_p80211_to_ether(wlandev->ethconv, pb) == 0 ) {
if ( p80211pb_p80211_to_ether(wlandev, wlandev->ethconv, pb) == 0 ) {
/* Mark last reception */
dev->last_rx = jiffies;
/* take ownership of skb from pb */
@ -346,7 +346,7 @@ int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netdev)
pb->ethfrmlen = skb->len;
pb->eth_hdr = (wlan_ethhdr_t*)pb->ethbuf;
if ( p80211pb_ether_to_p80211( wlandev->ethconv, pb) != 0 ) {
if ( p80211pb_ether_to_p80211(wlandev, wlandev->ethconv, pb) != 0 ) {
/* convert failed */
WLAN_LOG_DEBUG1(1,
"ether_to_80211(%d) failed.\n",
@ -524,6 +524,7 @@ int wlan_setup(wlandevice_t *wlandev)
/* Set up the wlandev */
wlandev->state = WLAN_DEVICE_CLOSED;
wlandev->ethconv = WLAN_ETHCONV_RFC1042;
wlandev->macmode = WLAN_MACMODE_NONE;
/* Allocate and initialize the struct device */
dev = kmalloc(sizeof(netdevice_t), GFP_ATOMIC);

View File

@ -334,7 +334,6 @@ void prism2sta_reset(wlandevice_t *wlandev )
* Call context:
* process thread
----------------------------------------------------------------*/
int prism2sta_txframe(wlandevice_t *wlandev, wlan_pb_t *pb )
{
prism2sta_priv_t *priv = (prism2sta_priv_t*)wlandev->priv;
@ -347,17 +346,6 @@ int prism2sta_txframe(wlandevice_t *wlandev, wlan_pb_t *pb )
printk(KERN_DEBUG"ethfrm[x] - [%d]:\n", pb->ethbuflen);
dmpmem(pb->ethbuf, pb->ethbuflen);
#endif
/* Set up the 802.11 header */
/* TODO: Move this up to wlandev */
pb->p80211_hdr->a3.fc = host2ieee16(
WLAN_SET_FC_FTYPE(WLAN_FTYPE_DATA) |
WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DATAONLY) |
WLAN_SET_FC_TODS(1) );
pb->p80211_hdr->a3.dur = 0;
pb->p80211_hdr->a3.seq = 0;
memcpy( pb->p80211_hdr->a3.a1, wlandev->bssid, WLAN_BSSID_LEN);
memcpy( pb->p80211_hdr->a3.a2, wlandev->netdev->dev_addr, WLAN_ADDR_LEN);
memcpy( pb->p80211_hdr->a3.a3, pb->eth_hdr->daddr, WLAN_ADDR_LEN);
/* Build Tx frame structure */
/* Set up the control field */
@ -368,6 +356,7 @@ dmpmem(pb->ethbuf, pb->ethbuflen);
HFA384x_TX_TXEX_SET(1) |
HFA384x_TX_TXOK_SET(1);
txdesc.tx_control = host2hfa384x_16(txdesc.tx_control);
/* Set up the 802.11 header */
memcpy(&(txdesc.frame_control), pb->p80211_hdr, WLAN_HDR_A3_LEN);
@ -1074,9 +1063,9 @@ void prism2sta_inf_linkstatus(wlandevice_t *wlandev, void *buf)
goto failed;
}
portstatus = hfa384x2host_16(portstatus);
wlandev->wlanmode =
wlandev->macmode =
portstatus == HFA384x_PSTATUS_CONN_IBSS ?
WLAN_MODE_IBSS_STA : WLAN_MODE_ESS_STA;
WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA;
break;
case HFA384x_LINK_DISCONNECTED:
WLAN_LOG_DEBUG0(1,"LinkStatus=DISCONNECTED (unhandled)\n");