📄 dot11test.c
字号:
** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11ShortRetrySet ( int ifNum, /* Interface number, ie. the '0' in wls0 */ int retry ) { return dot11TestIoctl(ifNum, WIOCSSHORTRETRY, (caddr_t)retry); }/****************************************************************************** dot11LongRetryGet - Gets the maximum number of long retries** This routine gets the number of times a "long" packet will be retried and * prints it to the console.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11LongRetryGet ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { int retry; STATUS status; status = dot11TestIoctl(ifNum, WIOCGLONGRETRY, (caddr_t)&retry); if (status == OK) { printf("Number of long retries: %d\n", retry); } return status; }/****************************************************************************** dot11ShortRetryGet - Gets the maximum number of short retries** This routine gets the number of times a "short" packet will be retried and * prints it to the console.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11ShortRetryGet ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { int retry; STATUS status; status = dot11TestIoctl(ifNum, WIOCGSHORTRETRY, (caddr_t)&retry); if (status == OK) { printf("Number of long retries: %d\n", retry); } return status; }/****************************************************************************** dot11CountryCodeSet - Sets the current operating country code** This routine sets the country code for the card. This controls the range of * channels and radio modes available to the driver. This is also the country * code that is advertised in AP mode if 802.11d is enabled. In ESS mode, the* station will not associate to (or even communicator with) an AP that does* not advertise this country code. <data> is a UINT32 that contains the * country code as specified in ISO 3166, or specified in dot11UsrLib.h by the* macros DOT11_COUNTRY_xxx. ** If the current channel is no longer supported in the new country code, then* the channel will be changed to the lowest supported channel in the same * radio mode as the old channel, if that radio mode is still supported. If* not, the channel will be changed to the lowest supported channel in any * radio mode.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11CountryCodeSet ( int ifNum, /* Interface number, ie. the '0' in wls0 */ int cc /* Country code to change to */ ) { return dot11TestIoctl(ifNum, WIOCSCOUNTRYCODE, (caddr_t)cc); }/****************************************************************************** dot11SuppRateGet - Prints current supported rates to console** This routine retrieves the current supported rates from the driver and * prints them to the console. These are the rates that the driver is allowed* to transmit in, and are further restricted to only those rates that are* also set in dot11RateSet(), if dot11RateSet() was used.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11SuppRateGet ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { STATUS status; DOT11_RATES rate; int i; rate.length = 0; status = dot11TestIoctl(ifNum, WIOCGSUPPRXRATE, (caddr_t)&rate); printf("Supp RX: "); for (i=0; i<rate.length; i++) { printf("%s%d%s ",DOT11_IS_BRATE(rate.rates[i])?"[":"", DOT11_RATE(rate.rates[i]), DOT11_IS_BRATE(rate.rates[i])?"]":""); } printf("\n"); rate.length = 0; status |= dot11TestIoctl(ifNum, WIOCGSUPPTXRATE, (caddr_t)&rate); printf("Supp TX: "); for (i=0; i<rate.length; i++) { printf("%s%d%s ",DOT11_IS_BRATE(rate.rates[i])?"[":"", DOT11_RATE(rate.rates[i]), DOT11_IS_BRATE(rate.rates[i])?"]":""); } printf("\n"); return status; }/****************************************************************************** dot11ChannelGet - Prints the currently connected channel to console** This routine prints the channel the radio is currently on to the console.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot111ChannelGet ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { STATUS status; UINT32 channel; status = dot11TestIoctl(ifNum, WIOCGCHANNEL, (caddr_t)&channel); printf("Current channel = %d\n", channel); return status; }/****************************************************************************** dot11AuthtypeSet - Sets the current authentication type** This routine sets the current authentication type for legacy WEP stations.* In WPA/RSN mode, this must always be set to Open System Authentication. For* legacy WEP or non-WEP operation, the available choices are:* DOT11_AUTHTYPE_OPEN 1 Open system authentication * DOT11_AUTHTYPE_SKA 2 Shared key authentication * DOT11_AUTHTYPE_ALL 3 Allow all available authentication type ** Note: DOT11_AUTHTYPE_ALL is only allowed on an AP. DOT11_AUTHTYPE_SKA is * only allowed when WEP is enabled.** RETURNS: the results of the IOCTL call, typically OK, ERROR, EINVAL** ERRNO: N/A*/STATUS dot11AuthTypeSet ( int ifNum, /* Interface number, ie. the '0' in wls0 */ int authType /* 802.11 authentication type to use */ ) { return dot11TestIoctl(ifNum, WIOCSAUTHTYPE, (caddr_t)authType); }/****************************************************************************** dot11Stats - prints device statistics** This routine prints all the device statistics available through WIOCGSTATS.* This routine give the same information as dot11Show() for device statistics,* but is provided as an example of how to use WIOCGSTATS.** RETURNS: results of IOCTL** ERRNO: N/A*/STATUS dot11Stats ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { DOT11_STATS stats; STATUS status; bzero((char *)&stats, sizeof(DOT11_STATS)); if ((status = dot11TestIoctl(ifNum, WIOCGSTATS, (caddr_t)&stats)) != OK) { printf("Error %d calling WIOCGSTATS. Errno = 0x%x\n", status, errnoGet()); } else { printf(" RX Frames %d\n", stats.rxFrames); printf(" RX Fragments %d\n", stats.rxFragments); printf(" RX Mcast Fragments %d\n", stats.rxMcastFragments); printf(" RX Total Bytes %lld kB\n", stats.rxTotalBytes / 1024); printf(" RX Duplicates %d\n", stats.rxDuplicates); printf(" RX FCS Errors %d\n", stats.rxFCSError); printf(" RX HW Errors %d\n", stats.rxHardwareError); printf(" RX Decrypt Errors %d\n", stats.rxDecryptError); printf(" RX MIC Failures %d\n", stats.rxMicFailure); printf(" RX Unencrypted excluded %d\n", stats.rxExcludeUnencrypted); printf(" RX 802.1X disallowed %d\n", stats.rxDot1xDropped); printf(" RX Can't reassemble %d\n", stats.rxCantReassemble); printf(" RX kBytes/sec %d\n", stats.rxBytesPerSec / 1024); printf(" RX kBytes/sec (16 s avg) %d\n", stats.rxBytesPer16Sec / 1024); printf("\n"); printf(" TX Frames %d\n", stats.txFrames); printf(" TX Fragments %d\n", stats.txFragments); printf(" TX McastFragments %d\n", stats.txMcastFragments); printf(" TX Total Bytes OK %lld kB\n", stats.txTotalBytes / 1024); printf(" TX Retry Success %d\n", stats.txRetry); printf(" TX Retry Mult. Success %d\n", stats.txRetryMultiple); printf(" TX Retry Fail %d\n", stats.txRetryFailure); printf(" TX ACK Fail %d\n", stats.txAckFailure); printf(" TX RTS Fail %d\n", stats.txRTSFailure); printf(" TX RTS Success %d\n", stats.txRTSSuccess); printf(" TX HW Errors %d\n", stats.txHardwareError); printf(" TX 802.1X disallowed %d\n", stats.txDot1xDropped); printf(" TX kBytes/sec %d\n", stats.txBytesPerSec / 1024); printf(" TX kBytes/sec (16s avg) %d\n", stats.txBytesPer16Sec / 1024); printf(" TX 4Way Hndshake Success %d\n", stats.fourWaySuccess); printf(" TX 4Way Hndshake Failure %d\n", stats.fourWayFailure); printf(" TX Group Handshake Suc. %d\n", stats.groupExchangeSuccess); printf(" TX Group Handshake Fail %d\n", stats.groupExchangeFailure); } return status; }/****************************************************************************** dot11Scan - Scans all available channels for the requested SSID** This routine executes a BSS scan, to search for all BSS matching the* search criteria. A SSID of NULL or "" will search for all BSSs. The* results of the search will be printed to the console.** RETURNS: OK or ERROR** ERRNO: N/A*/STATUS dot11Scan ( int ifNum, /* Interface number, ie. the '0' in wls0 */ char * ssid /* SSID to search for, or "" to search for any */ ) { STATUS status; DOT11_SCAN_REQ req; DOT11_SCAN_RESULTS res[50]; int i; if (ssid == NULL) { strcpy(req.ssid, ""); } else { strcpy(req.ssid, ssid); } req.maxResults = 50; req.pResults = &res[0]; if ((status = dot11TestIoctl(ifNum, WIOCBSSSCAN, (caddr_t)&req)) != OK) { printf("Error %d calling WIOCBSSSCAN. Errno = 0x%x\n", status, errnoGet()); } else { printf("%d wireless networks found\n", (int)req.numResults); for (i=0; i< req.numResults; i++) { printf("\"%s\" chan=%d ssi=%d\n", req.pResults[i].ssid, req.pResults[i].channel, req.pResults[i].ssi); } } return status; }/****************************************************************************** dot11ChannelListGet - Displays a list of all available channels** This routine executes WIOCGCHANNELLIST to retrieve a list of all channels * allowed in the current country code, and then prints it to STDOUT.** RETURNS: OK or ERROR** ERRNO: N/A*/STATUS dot11ChannelListGet ( int ifNum /* Interface number, ie. the '0' in wls0 */ ) { STATUS status; DOT11_CHANNEL_LIST chanList; int i; chanList.numChannels = 0; if ((status = dot11TestIoctl(ifNum, WIOCGCHANNELLIST, (caddr_t)&chanList)) != OK) { printf("Error %d calling WIOCGCHANNELLIST. " "Errno = 0x%x\n", status, errnoGet()); return ERROR; } if (chanList.numChannels == 0) { printf("dot11ChannelListGet: ERROR - no channels found\n"); return ERROR; } printf("Channel Freq (Mhz) Mode\n"); for (i=0; i< chanList.numChannels; i++) { printf("%3d %4d %10s %d %s\n", chanList.channels[i].channel, chanList.channels[i].freq, dot11ModeString[chanList.channels[i].mode], chanList.channels[i].mode, chanList.channels[i].activeScanAllowed?"":"PASSIVE" ); } return OK; }/****************************************************************************** dot11BeaconSet - Sets the current beacon interval** This routine sets the amount of time between each beacon. <beaconInterval> * is expressed in 802.11 time units, which are 1.024 microseconds each. This* only takes effect in IBSS and AP modes.** RETURNS: OK or ERROR** ERRNO: N/A*/STATUS dot11BeaconSet ( int ifNum, /* Interface number, ie. the '0' in wls0 */ int beaconInterval /* Time between beacons, in 802.11 time units */ ) { return dot11TestIoctl(ifNum, WIOCSBEACONRATE, (caddr_t)beaconInterval); }/****************************************************************************** dot11MultiDomainSet - Enables or disables 802.11d multidomain operation** In 802.11d mode, an AP will advertise it's current country code in beacons* and probe responses. A station in 802.11d mode will search to determine the* country advertised by APs in the area. Passive scans only will be performed* until a country is decided upon, lengthening association times. <enable> is a* boolean indicating the new status of 802.11d mode.** RETURNS: OK or ERROR** ERRNO: N/A*/STATUS dot11MultiDomainSet ( int ifNum, /* Interface number, ie. the '0' in wls0 */ BOOL enable ) { return dot11TestIoctl(ifNum, WIOCS80211D, (caddr_t)enable); }/****************************************************************************** dot11SSIDHide - Sets SSID hiding and other pseudo-security parameters** The available options are the logical OR of:* #define DOT11_ADVSEC_HIDE_SSID 1* #define DOT11_ADVSEC_BLOCK_BCAST_SSID 2* 0 should be passed to <ssidFeatures> to disable all pseudo-security features** RETURNS: OK or ERROR*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -