?? dot11test.c
字號:
/* dot11Test.c - Routines for managing driver from target/host shell *//* * Copyright (c) 2004-2006 Wind River Systems, Inc. * * The right to copy, distribute, modify or otherwise make use * of this software may be licensed only pursuant to the terms * of an applicable Wind River license agreement. *//* Modification History--------------------02d,15mar06,rb Added test routines for ACL and WEP key mapping02c,27feb06,rb Changes from code inspection02b,14feb06,rb Add VLAN routines02a,11nov05,rb Added mSSID feature01z,31oct05,rb Fix to SPR 114576 - dot11Scan() does not recognise specific SSIDs01y,28sep05,rb Remove warnings01x,28sep05,rb Fix APIGEN Errors01w,23sep05,rb Fixed up header01v,22sep05,rb Improve descriptions for APIGEN01u,22sep05,rb Removed warning on RTP Ioctl access01t,12sep05,rb Added dot11ScanTypeSet/Get01s,09sep05,rb Added init routine for project facility inclusion01r,25aug05,rb Added API to enable 11d01q,09aug05,rb Added dot11BeaconSet()01p,04aug05,rb Added dot11ChannelListGet()01o,30jun05,rb Added dot11Scan() routine01n,20may05,rb Added get routines for short/long retry01m,17may05,rb Added new calls to set security IOCTLs01l,03may05,??? added CTS/RTS and Fragmentation calls01k,29apr05,rb Added wep key call01j,26apr05,rb Added rate setting call01i,14apr05,rb Added support for Transmit Power Scaling (WIOCSTXPOWERSCALE)01h,11apr05,rjh fix capitalization on stdlib.h01g,11apr05,rjh fix capitalization of ioLib.h01f,22mar05,rjh Added more routines01e,24mar05,rb Oops - minor 5.5 compilation problem01d,24mar05,rb Added Base 6 RTP capability01c,21mar05,rb Even more routines01b,08mar05,rb Added more routines01a,25feb05,rb created*//*DESCRIPTIONThis file provides a series of APIs for managing the 802.11 driver. These canbe called programatically or through the shell (to aid in automated testing, for example). They also serve as a demonstration of the preferred usage ofthe management API to this driver.This library is meant to be used in vxWorks 5.5.x and 6.x, and should work with both network stacks. Note that these calls can only be used in an RTP invxWorks 6.1 and higher, since operating system support for the MUX IOCTL passthrough was not added until vxWorks 6.1. Kernel mode management is supported in all versions of vxWorks 6.xSEE ALSOWind River Wireless Ethernet Driver 2.2 for vxWorks 5 User's Guide Wind River Wireless Ethernet Driver 2.2 for vxWorks 6 User's Guide INCLUDE FILES: drv/wlan/dot11UsrLib.h*//* includes */#include <vxWorks.h>#include <stdio.h>#include <muxLib.h>#ifdef _WRS_KERNEL #include <muxTkLib.h>#include <endLib.h>#endif /* _WRS_KERNEL */#include <ioLib.h>#include <errnoLib.h>#include <string.h>#include <stdlib.h>#include <stdio.h>#include <stdarg.h>#include <net/inet.h>#include <errno.h>/* This is the only include file that should be necessary to manage the device.The header file dot11Lib.h is for internal use only. */#include <drv/wlan/dot11UsrLib.h>#include <drv/wlan/dot11Test.h>/* This is the name of the wireless interface. It is defined in dot11Lib.h,but to avoid pulling it in, */#define DOT11_IFNAME "wls"/* Local Prototypes */#ifndef _WRS_KERNELLOCAL STATUS dot11TestIoctlRtp(int ifNum, int cmd, caddr_t data);#endif /* _WRS_KERNEL *//* This is a duplicate of he structure in dot11Lib.c, but the structure in dot11Lib.c is not accessable from an RTP */const char * dot11ModeString[] = {"NONE", /* 00000b */ "802.11a", /* 00001b */ "802.11b", /* 00010b */ "802.11a/b", /* 00011b */ "802.11g", /* 00100b */ "802.11a/g", /* 00101b */ "802.11b/g", /* 00110b */ "802.11a/b/g", /* 00111b */ "turboG", /* 01000b */ "802.11a+tG", /* 01001b */ "802.11b+tG", /* 01010b */ "802.11a/b+tG", /* 01011b */ "802.11g+tG", /* 01100b */ "802.11a/g+tG", /* 01101b */ "802.11b/g+tG", /* 01110b */ "802.11a/b/g+tG", /* 01111b */ "turboA", /* 10000b */ "802.11a+tA", /* 10001b */ "802.11b+tA", /* 10010b */ "802.11a/b+tA", /* 10011b */ "802.11g+tA", /* 10100b */ "802.11a/g+tA", /* 10101b */ "802.11b/g+tA", /* 10110b */ "802.11a/b/g+tA", /* 10111b */ "turboG + turboA", /* 11000b */ "802.11a+tG+tA", /* 11001b */ "802.11b+tG+tA", /* 11010b */ "802.11a/b+tG+tA", /* 11011b */ "802.11g+tG+tA", /* 11100b */ "802.11a/g+tG+tA", /* 11101b */ "802.11b/g+tG+tA", /* 11110b */ "ANY"}; /* 11111b *//****************************************************************************** dot11TestInit - Empty stub function to force inclusion of the module*** RETURNS: void** ERRNO: N/A** \NOMANUAL**/VOID dot11TestInit(void) { return; }/****************************************************************************** dot11TestIoctl - Calls the IOCTL for the wireless device** This routine is a wrapper function that will call the wireless IOCTL * regardless of the operating system and mode.** RETURNS: the results of the IOCTL call, typically OK, ERROR, or EINVAL** ERRNO: N/A*/STATUS dot11TestIoctl ( int ifNum, /* Interface number, ie. the '0' in wls0 */ int cmd, /* IOCTL command from dot11UsrLib.h */ caddr_t data /* Data to pass to IOCTL */ ) { STATUS status; void * pCookie;#ifdef _WRS_KERNEL /* This is the code to call the IOCTL in vxWorks 5.5.x */ if ((pCookie = muxTkCookieGet(DOT11_IFNAME, ifNum)) == NULL) { return ERROR; } status = muxIoctl(pCookie, cmd, data);#else /* _WRS_KERNEL */ /* This is the call to get to the IOCTLs from an RTP in vxWorks 6.x */ status = dot11TestIoctlRtp(ifNum, cmd, data);#endif /* _WRS_KERNEL */ return status; }#ifndef _WRS_KERNEL/****************************************************************************** dot11TestIoctlRtp - Calls the IOCTL for the wireless device from an RTP** This routine is a wrapper function that calls the wireless IOCTL through the* newly added SIOCMUXPASSTHRU** RETURNS: the results of the IOCTL call, typically OK, ERROR, or EINVAL** ERRNO: N/A*/LOCAL STATUS dot11TestIoctlRtp ( int ifNum, /* Interface number, ie. the '0' in wls0 */ int cmd, /* IOCTL command from dot11UsrLib.h */ caddr_t data /* Data to pass to IOCTL */ ) { DOT11_STATS stats; int fd; int status; MUX_PASSTHRU passThru; strcpy(passThru.name, "wls"); passThru.unit = ifNum; passThru.cmd = cmd; passThru.pData = (void *)data; if ((fd = socket(AF_INET, SOCK_RAW, 0)) <= 0) { printf("dot11TestIoctl: socket() returned %d. Errno = 0x%x Exiting\n", fd, errnoGet()); exit(-1); } status = ioctl(fd, SIOCMUXPASSTHRU, (int)&passThru); close(fd); return status; }#endif/****************************************************************************** dot11SSIDSet - Sets the SSID of the indicated interface** This routine is a wrapper function that will call WIOCSSSID with the* specified parameter. <ssid> is a character string of at most 32 bytes, not* including the NULL-terminator.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11SSIDSet ( int ifNum, /* Interface number, ie. the '0' in wls0 */ char * ssid /* char buffer with SSID to set */ ) { return dot11TestIoctl(ifNum, WIOCSSSID, (caddr_t)ssid); }/****************************************************************************** dot11SSIDGet - Gets the connected and desired SSID of the indicated interface** This routine is a wrapper function that will call WIOCGSSID with the* specified parameter, and display the current CONNECTED and DESIRED SSIDs* to the console.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11SSIDGet ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { UINT8 ssid[DOT11_SSID_LEN + 1]; STATUS status; if ((status = dot11TestIoctl(ifNum, WIOCGDESIREDSSID, (caddr_t)ssid)) != OK) { printf("dot11SSIDGet: WIOCGDESIREDSSID failed with return code = %d\n", status); return status; } printf("dot11SSIDGet: Desired SSID = \"%s\"\n", ssid); if ((status = dot11TestIoctl(ifNum, WIOCGCONNECTEDSSID, (caddr_t)ssid)) != OK) { printf("dot11SSIDGet: WIOCGCONNECTEDSSID fail with return code = %d\n", status); return status; } printf("dot11SSIDGet: Connected SSID = \"%s\"\n", ssid); return OK; }/****************************************************************************** dot11ModeSet - Sets the SME Mode of the indicated interface** This routine is a wrapper function that will call WIOCSDOT11MODE with the* specified parameter. <mode> can be one of * DOT11_MODE_NONE 0* DOT11_MODE_ESS 1* DOT11_MODE_IBSS 2* DOT11_MODE_AP 3** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11ModeSet ( int ifNum, /* Interface number, ie. the '0' in wls0 */ int mode /* Mode to set: 0=none, 1=ess, 2=ibss, 3=ap */ ) { return dot11TestIoctl(ifNum, WIOCSDOT11MODE, (caddr_t)mode); }/****************************************************************************** dot11ModeNone - Sets the SME Mode of the indicated interface to NONE** This routine is a wrapper function that will call WIOCSDOT11MODE with the* DOT11_MODE_NONE parameter to place the SME into NONE mode. This will stop* device function completely and disable the radio.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11ModeNone ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { return dot11TestIoctl(ifNum, WIOCSDOT11MODE, (caddr_t)0); }/****************************************************************************** dot11ModeEss - Sets the SME Mode of the indicated interface to ESS** This routine is a wrapper function that will call WIOCSDOT11MODE to * place the device into ESS mode. The wireless interface should be attached* to the network stack for normal communications.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11ModeEss ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { return dot11TestIoctl(ifNum, WIOCSDOT11MODE, (caddr_t)1); }/****************************************************************************** dot11ModeIbss - Sets the SME Mode of the indicated interface to IBSS mode** This routine is a wrapper function that will call WIOCSDOT11MODE to place* the device into IBSS mode. The wireless interface should be attached* to the network stack for normal communications.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11ModeIbss ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { return dot11TestIoctl(ifNum, WIOCSDOT11MODE, (caddr_t)2); }/****************************************************************************** dot11ModeAp - Sets the SME Mode of the indicated interface to AP mode** This routine is a wrapper function that will call WIOCSDOT11MODE to place* the device into AP mode. Note that in order for AP mode to be functional,* the Learning Bridge should also be up, and have this wireless interface* configured as a bridge port.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11ModeAp ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { return dot11TestIoctl(ifNum, WIOCSDOT11MODE, (caddr_t)3); }/****************************************************************************** dot11PmSet - Sets the Power Management mode on or off** This routine is a wrapper function that will call WIOCSPWRMAN with the* specified parameter. <pmEnabled> will take the value TRUE or FALSE, with* TRUE enabling power management mode. This call is only meaningful in * ESS mode, and will not have any effect in other modes, although the state* of this flag will be maintained.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11PmSet ( int ifNum, /* Interface number, ie. the '0' in wls0 */ BOOL pmEnabled /* TRUE to turn PM on, FALSE for off */ ) { return dot11TestIoctl(ifNum, WIOCSPWRMAN, (caddr_t)pmEnabled); }/****************************************************************************** dot11ChannelSet - Sets the Channel of the indicated interface** This routine is a wrapper function that will call WIOCSCHANNEL with the* desired channel and change to that channel. The channel should be in* the set returned by dot11ChannelListGet(), or else ERROR will be returned* and no change effected.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11ChannelSet ( int ifNum, /* Interface number, ie. the '0' in wls0 */ int channel /* Channel number to change to */ )
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -