📄 intprismtertap.c
字号:
} } pWlanDev->txPool[j].fid = WLAN_IN_16(WLAN_BASE_ADDR + WLAN_ALLOC_FID); /* ACK the alloc event */ WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_EVENT_ACK, WLAN_EV_ALLOC); } /* END: lifted from intPrismInit */ /* * when more cards are supported in the future, this may have to be * specific for each card */ if ((apConfig.apCardType == WLAN_CARDTYPE_INTERSIL_2) || (apConfig.apCardType == WLAN_CARDTYPE_INTERSIL_2_5) || (apConfig.apCardType == WLAN_CARDTYPE_INTERSIL_3)) { /* Set the SSID name */ intPrismRIDStringWrite(pWlanDev, WLAN_RID_OWN_SSID, apConfig.apName); /* Set the Comm channel */ intPrismRIDWordWrite(pWlanDev, WLAN_RID_OWN_CHANNEL, apConfig.apChannel); /* Set the Basic Data Rate to 11 Mbps */ intPrismRIDWordWrite(pWlanDev, INTERSIL_RID_BASIC_RATES, WLAN_11_MBIT); /* Set Supported Data Rate to 11 Mbps */ intPrismRIDWordWrite(pWlanDev, INTERSIL_RID_SUPPORTED_RATES, WLAN_11_MBIT); /* Set Tx Rate Control */ intPrismRIDWordWrite(pWlanDev, WLAN_RID_TX_RATE0, WLAN_11_MBIT); /* Turn on Host based authentication */ intPrismRIDWordWrite(pWlanDev, WLAN_RID_HOST_AUTH, 1); } /* * Make sure all card interrupts are clear and all events acknowledged * before we enable system interrupts */ WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_INT_EN, 0x0000); WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_EVENT_ACK, 0xffff); WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_INT_EN, pWlanDev->intMask); intPrismCommand (pWlanDev, WLAN_CMD_ENABLE,0,0,0); /* can now set the cardMode as Tertiary AP */ pWlanDev->cardMode = WLAN_CARDMODE_TERT_AP; pWlanDev->cardStatus = WLAN_STATUS_UP; if (pWiredDev != NULL) { /* * turn packet bridging on: packets received on one interface * (wired/wireless) are also sent to the other interface */ if (intPrismBridgeOn(WLAN_IFNAME,apConfig.apInterfaceNum, apConfig.wiredDevName, apConfig.wiredDevNum) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR,("intPrismTertApStart: Could not start " "bridging\n")); goto ERR; } else { goto SUCCESS; } } else { /* this is not really a FATAL message, but it's nice to see this message always */ WLANDL_DEBUG(DEBUG_FATAL, ("intPrismTertApStart: simple bridge not initialized.\n")); goto SUCCESS; } ERR: status = ERROR; SUCCESS: /* resume suspended keep-alive thread running on StormPad */#if (CPU==STRONGARM) || (CPU==XSCALE) || (CPU==ARMARCH4) if (taskResume (taskNameToId("tWlanPoll")) == ERROR) { WLANDL_DEBUG(DEBUG_INFO, ("intPrismTertApStart: could not resume task tWlanPoll\n")); } #endif if (status == ERROR) { return ERROR; } else { WLANDL_DEBUG(DEBUG_INFO, ("intPrismTertApStart: successfully created AP with" " SSID = %s, channel = %i\n", apConfig.apName, apConfig.apChannel)); return OK; } }/******************************************************************************* intPrismTertApStaAdd - Adds a Station to the access control list** A station identifier (represented by the MAC address and authentication type * passed to this routine) is added to the list of Stations that* will be successfully authenticated by the TAP, should they request it. * Duplicate stations will not be added to the list.** RETURNS: OK if the station ID was created and added to the list, ERROR if* the station could not be added to the list* ERRNO: N/A*/ STATUS intPrismTertApStaAdd ( UINT16 mac1, /* MAC address (field 1) of STA */ UINT16 mac2, /* MAC address (field 2) of STA */ UINT16 mac3, /* MAC address (field 3) of STA */ UINT8 authType /* type of authentication STA will use: 0 = open system, 1 = shared key */ ) { STA_ID * pStationCurrent; STA_ID * pStationPrev; if (pStations == NULL) { /* create the first element in the list */ pStations = (STA_ID *) malloc(sizeof(STA_ID)); if (pStations == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertApStaAdd: Error - could not malloc" " space for additional station id %i bytes\n", (int) sizeof(STA_ID))); return ERROR; } else { pStations->mac1 = mac1; pStations->mac2 = mac2; pStations->mac3 = mac3; pStations->authType = authType; pStations->pNext = NULL; return OK; } } else { pStationCurrent = pStations; pStationPrev = NULL; /* find the end of the list */ do { /* make sure there isnt a duplicate */ if ( (pStationCurrent->mac1 == mac1) && (pStationCurrent->mac2 == mac2) && (pStationCurrent->mac3 == mac3) && (pStationCurrent->authType == authType) ) { WLANDL_DEBUG(DEBUG_INFO, ("intPrismTertApStaAdd: cannot add " " duplicate station\n")); return ERROR; } else { pStationPrev = pStationCurrent; pStationCurrent = pStationCurrent->pNext; } } while (pStationCurrent != NULL); /* add to the end of the list */ pStationPrev->pNext = (STA_ID *) malloc(sizeof(STA_ID)); if (pStationPrev->pNext == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertApStaAdd: Error - could not malloc" " space for additional station id %i bytes\n", (int) sizeof(STA_ID))); return ERROR; } else { pStationCurrent = pStationPrev->pNext; pStationCurrent->mac1 = mac1; pStationCurrent->mac2 = mac2; pStationCurrent->mac3 = mac3; pStationCurrent->authType = authType; pStationCurrent->pNext = NULL; } } return OK; }/******************************************************************************* intPrismTertApStaRemove - Removes a station from the Access Control List** Removes a station identifier (represented by the MAC address and * authentication type passed to this routine) from the list of stations that* are to be successfully authenticated by the TAP. ** RETURNS: OK if the station ID was removed from the station list, ERROR if* the station could not be found in the list* ERRNO: N/A*/ STATUS intPrismTertApStaRemove ( UINT16 mac1, /* MAC address (field 1) of STA */ UINT16 mac2, /* MAC address (field 2) of STA */ UINT16 mac3, /* MAC address (field 3) of STA */ UINT8 authType /* type of authentication STA will use: 0 = open system and 1 = shared key system */ ) { STA_ID * pStationPrev; STA_ID * pStationCurrent; if (pStations == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismTertApStaRemove: no stations\n")); return ERROR; } else { pStationCurrent = pStations; pStationPrev = NULL; do { if ( (pStationCurrent->mac1 == mac1) && (pStationCurrent->mac2 == mac2) && (pStationCurrent->mac3 == mac3) && (pStationCurrent->authType == authType) ) { if (pStationPrev != NULL) { pStationPrev->pNext = pStationCurrent->pNext; } else { pStations = pStationCurrent->pNext; } /* free the memory and return */ free(pStationCurrent); return OK; } else { /* move to the next item in the list */ pStationPrev = pStationCurrent; pStationCurrent = pStationCurrent->pNext; } } while (pStationCurrent != NULL); } /* station to remove was not found */ return ERROR; } /******************************************************************************* intPrismTertApStaListShow - Displays the Access Control List** Displays a list of STA's that have been added to the Access Control List * A STA is added by a call to intPrismTertApStaAdd()** RETURNS: N/A* ERRNO: N/A*/ void intPrismTertApStaListShow(void) { STA_ID * pStationTemp; if (pStations == NULL) { /* not really a DEBUG_FATAL error, but DEBUG_FATAL is guaranteed to be turned on */ WLANDL_DEBUG(DEBUG_FATAL, ("intPrismTertApStaListShow: no stations" " in access control list\n")); } else { pStationTemp = pStations; do { WLANDL_DEBUG(DEBUG_FATAL, ("intPrismTertApStaListShow: MAC Addr = %x:%x:%x, " "auth type = %i\n", pStationTemp->mac1, pStationTemp->mac2, pStationTemp->mac3, pStationTemp->authType)); pStationTemp = pStationTemp->pNext; } while (pStationTemp != NULL); } }/****************************************************************************** NOMANUAL* intPrismApStationAuthenticate - Authenticates a station for communication * with the AP** If the STA exists in the Access control list, it is authenticated by * setting the authenticateStation RID. If no Access control list exists, ALL * requests for authentication are granted. ** NOTE: it is expected this routine will be used with parameters taken directly* from a packet received from the intPrism card, hence network byte order* is expected for the MAC addr parameters.** RETURNS: TRUE if the STA is authenticated, else FALSE* ERRNO: N/A*/ BOOL intPrismTertApStaAuthenticate ( UINT16 mac1, /* MAC address (field 1) of STA */ UINT16 mac2, /* MAC address (field 2) of STA */ UINT16 mac3, /* MAC address (field 3) of STA */ UINT8 authType /* type of authentication STA will use: 0 = open system and 1 = shared key system */ ) { UINT16 mac1HostOrder; UINT16 mac2HostOrder; UINT16 mac3HostOrder; LTV_RECORD ltv; STA_ID * pStationTemp; /* convert the mac fields to host byte order */ mac1HostOrder = L_TO_B_ENDIAN_16(mac1); mac2HostOrder = L_TO_B_ENDIAN_16(mac2); mac3HostOrder = L_TO_B_ENDIAN_16(mac3); WLANDL_DEBUG(DEBUG_INFO,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -