📄 intprismtertap.c
字号:
("intPrismTertApStaAuthenticate trying to auth Mac " "%x:%x:%x, auth type %i\n", mac1HostOrder, mac2HostOrder, mac3HostOrder, authType)); ltv.type = WLAN_RID_AUTH_STA; ltv.length = 6; ltv.data[0] = mac1; ltv.data[1] = mac2; ltv.data[2] = mac3; ltv.data[3] = 0; ltv.data[4] = authType; /* * if there is no Access control list, then all stations requesting * authentication are granted */ if (pStations == NULL) { WLANDL_DEBUG(DEBUG_INFO, ("intPrismTertApStaAuthenticate: no Access " "control list exists\n")); /* grant authentication */ if (intPrismLTVWrite(pWlanDev, <v) == ERROR) { WLANDL_DEBUG(DEBUG_INFO, ("intPrismTertApStatAuthenticate: Error - " " authenticating\n")); return FALSE; } else { WLANDL_DEBUG(DEBUG_INFO, ("intPrismTertApStaAuthenticate: " "Authenticated\n")); return TRUE; } } else /* go through the station list trying to find a match */ { pStationTemp = pStations; do { if ( (pStationTemp->mac1 == mac1HostOrder) && (pStationTemp->mac2 == mac2HostOrder) && (pStationTemp->mac3 == mac3HostOrder) && (pStationTemp->authType == authType)) { /* match found, grant authentication */ if (intPrismLTVWrite(pWlanDev, <v) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertApStaAuthenticate: Error - " " authenticating\n")); return FALSE; } else { WLANDL_DEBUG(DEBUG_INFO, ("intPrismTertApStaAuthenticate: " " Authenticated\n")); return TRUE; } } pStationTemp = pStationTemp->pNext; } while (pStationTemp != NULL); /* no match found in station list, cannot grant authentication */ WLANDL_DEBUG(DEBUG_INFO,("intPrismTertApStaAuthenticate: no match found" " in station list\n")); return FALSE; } }/****************************************************************************** intPrismTertApChannelInfoShow - Gets channel statistics and outputs to stdio** This routine initiates a scan of each channel. The results of the scan * are received in the form of an Info Frame and the following values * (parsed from the frame) will be printed on stdio: Channel Id, Signal * Level(dBm), Peak Noise Level(dBm), and Activity (0 = no activity, 1 = active)** Note - it may take some time for the results to be displayed, depending on* the scan time specified** RETURNS: N/A* ERRNO: N/A*/ void intPrismTertApChannelInfoShow ( UINT16 scanTime /* num of mS each channel should be scanned for */ ) { LTV_RECORD ltv; ltv.type = WLAN_RID_CHANNEL_INFO; ltv.length = 3; ltv.data[0] = 0x3FFF; /* this corresponds to bits 0-13, ie. channels 1-14 */ ltv.data[1] = scanTime; if (intPrismLTVWrite(pWlanDev, <v) != OK) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertApChannelInfoShow: " "Error invoking channel scan")); } }/****************************************************************************** NOMANUAL* intPrismTertApChannelInfoOutput - logs channel statistics resulting from scan** This routine is meant to be called only by the intPrismEnd ISR, when the * result of a channel scan has been received. The results of a channel scan are* output to logMsg: Channel Id, Signal Level (dBm), Peak Noise Level (dBm) and* Activity (0 = no activity, 1 = active) ** RETURNS: N/A* ERRNO: N/A*/ void intPrismTertApChannelInfoOutput ( LTV_RECORD * pltv /* ptr. to the LTV record containing the scan results */ ) { int i = 0; int j = 1; for (i = 1; i <= (pltv->length - 2) / 4; i++) { logMsg("channel: %i\n", pltv->data[j], 0,0,0,0,0); logMsg("signal level/peak noise level/activity: %i/%i/%i\n", pltv->data[j+1], pltv->data[j+2], pltv->data[j+3],0,0,0); j = j + 4; } }/******************************************************************************* intPrismTertApFileDownload - Configures an intPrism Sta card to run as a TAP** This EXAMPLE routine demonstrates how the TAP is initiated using ioctl calls * and a local filesystem to read the Tertiary file. The wired dev name/num are* required for initializing simple packet bridging between the wired and * wireless network. If this simple bridge, as provided by this module, is not* required or desired, pass NULL as the wired dev name.** RETURNS: OK if the Access Point was successfully started, else ERROR* ERRNO: N/A*/STATUS intPrismTertApFileDownload ( char * tertiaryFilename, /* Tertiary file to be read from filesystem */ char * apName, /* Name to be given to the AP, the SSID */ int apChannel, /* Channel for the AP to use */ char * wiredDevName, /* Wired END device name */ int wiredDevNum, /* Wired END device number */ char * wirelessDevName, /* WLAN END device name */ int wirelessDevNum /* WLAN END device number */ ) { char * pBuffer; UINT16 mode; END_OBJ * pWlan; AP_PARAMS params; int fd; struct stat fileStat; UINT16 wepEnable = 0; UINT16 wepType = 0; UINT8 wepKey [WLAN_WEP_MAX_KEYSIZE]; UINT16 wepKeyNumber = 0; BOOL wepAvail = FALSE; int i = 0; /* uncomment if adding a STA to the access control list further down...*/ /* UINT16 station[4]; */ /* Get the encryption mode */ (void) sysWlanCfgParamGet (WLAN_WEP_ENABLE, (INT32) &wepEnable); /* Get the default 40 bit wep key */ (void) sysWlanCfgParamGet (WLAN_WEP_KEY0_64, (INT32) wepKey); /* Get the default wep key number */ (void) sysWlanCfgParamGet (WLAN_WEP_KEY_NUMBER, (INT32) &wepKeyNumber); /* open the Tertiary file */ fd = open(tertiaryFilename, O_RDONLY, 0444); if (fd == ERROR) { printf("intPrismTertApFileDownload: Error - could not open file %s\n", tertiaryFilename); return ERROR; } if (fstat(fd, &fileStat) == ERROR) { printf("intPrismTertApFileDownload: Error - getting filestat info\n"); close(fd); return ERROR; } /* read the file contents into a buffer */ pBuffer = (char *) malloc(fileStat.st_size); if (pBuffer == NULL) { printf("intPrismTertApFileDownload: Error - could not malloc %i bytes\n", (int) fileStat.st_size); close(fd); free(pBuffer); return ERROR; } if (read(fd, pBuffer, fileStat.st_size) != (int) fileStat.st_size) { printf("intPrismTertApFileDownload: Error - did not read entire file\n"); close(fd); free(pBuffer); return ERROR; } pWlan = endFindByName(wirelessDevName, wirelessDevNum); /* make sure it's an Intersil card */ if ( (pWlan != NULL) && ( (((WLAN_DEV *) pWlan)->cardType == WLAN_CARDTYPE_INTERSIL_2) || (((WLAN_DEV *) pWlan)->cardType == WLAN_CARDTYPE_INTERSIL_2_5) || (((WLAN_DEV *) pWlan)->cardType == WLAN_CARDTYPE_INTERSIL_3))) { /* Get the current mode of the card */ intPrismIoctl(pWlan, EIOCGMODE, (caddr_t) &mode); if (mode == WLAN_CARDMODE_STA) { params.cardType = ((WLAN_DEV *) pWlan)->cardType; params.apName = apName; params.apChannel = apChannel; params.apInterfaceNum = wirelessDevNum; params.wiredDevName = wiredDevName; params.wiredDevNum = wiredDevNum; params.pTertiaryBuffer = pBuffer; params.numBytes = fileStat.st_size; #if 0 /* this is how one would add a sta to the access control list */ station[0] = 0x60; /* MAC addr field 1 */ station[1] = 0x1DF0; /* MAC addr field 2 */ station[2] = 0xCEF8; /* MAC addr field 3 */ station[3] = 0; if (intPrismIoctl(pWlan, EIOCASTA, (caddr_t) &station) == ERROR) { printf("intPrismTertApFileDownload: could not add station to " "auth list\n"); }#endif /* set mode to AP */ if (intPrismIoctl(pWlan, EIOCSAPMODE, (caddr_t) ¶ms) != ERROR) { printf("intPrismTertApFileDownload: now in AP mode\n"); /* enable WEP security if so indicated by configWlan.h */ (void) sysWlanCfgParamGet (WLAN_WEP_ENABLE, (INT32) &wepEnable); if (wepEnable == TRUE) { /* Get the wep type (40/64 or 104/128 bit) encryption */ (void) sysWlanCfgParamGet(WLAN_WEP_TYPE, (INT32) &wepType); if (wepType == WLAN_WEP_TYPE_64) { for (i = 0; i < WLAN_WEP_NUM_KEYS; i++) { sysWlanCfgParamGet(WLAN_WEP_KEY0_64 + i, (INT32) wepKey); intPrismIoctl((END_OBJ *) pWlan, EIOCSWEPKEY0 + i, (caddr_t) wepKey); } } else if (wepType == WLAN_WEP_TYPE_128) { sysWlanCfgParamGet(WLAN_WEP_KEY0_128, (INT32)wepKey); intPrismIoctl((END_OBJ *)pWlan, EIOCSWEPKEY0, (caddr_t) wepKey); } /* Get the default wep key number */ (void) sysWlanCfgParamGet (WLAN_WEP_KEY_NUMBER, (INT32) &wepKeyNumber); intPrismIoctl((END_OBJ *) pWlan, EIOCSWEPDEFAULTKEY, (caddr_t)(INT32)wepKeyNumber); /* finally, turn on WEP */ intPrismIoctl((END_OBJ *) pWlan, EIOCSWEP, (caddr_t)1); /* Check to make sure that WEP was actually enabled */ intPrismIoctl(pWlan, EIOCGWEPSTATUS, (caddr_t) &wepAvail); if (wepAvail == FALSE) { printf("intPrismTertApFileDownload: Error - WEP was not" " enabled\n"); } else { printf("intPrismTertApFileDownload: WEP Enabled\n"); } } } else { printf("intPrismTertApFileDownload: Error enabling AP\n"); free(pBuffer); return ERROR; } } else { printf("intPrismTertApFileDownload: currently in AP mode\n"); } } else { printf("intPrismTertApFileDownload: Error - %s%i is not an " "Intersil/Prism based interface\n", wirelessDevName, wirelessDevNum); free(pBuffer); return ERROR; } /* don't forget to free the memory associated with the tert buffer */ if (pBuffer != NULL) { free(pBuffer); } return OK; }/******************************************************************************* intPrismTertApFtpDownload - Configures an intPrism STA card to run as an AP** This EXAMPLE routine demonstrates how the TAP is initiated using ioctl calls * and an FTP server to load the Tertiary file. The wired dev name/num are* required for initializing simple packet bridging between the wired and * wireless network. If this simple bridge, is not required or desired, pass* NULL as the wired dev name.** RETURNS: OK if the Tertiary Access Point was successfully started, else ERROR* ERRNO: N/A
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -