📄 ixethdbwifi.c
字号:
/** * @file IxEthDBAPI.c * * @brief Implementation of the public API * * @par * IXP400 SW Release version 2.1 * * -- Copyright Notice -- * * @par * Copyright (c) 2001-2005, Intel Corporation. * All rights reserved. * * @par * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Intel Corporation nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * * @par * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * * @par * -- End of Copyright Notice -- */#include "IxEthDB_p.h"/* forward prototypes */IX_ETH_DB_PRIVATE MacTreeNode *ixEthDBGatewaySelect(MacTreeNode *stations, UINT32 *gwCount);IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBWiFiEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr, IxEthDBWiFiRecData *wifiRecData);IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBDownloadGatewayTable (IxEthDBPortId portID, MacTreeNode *gateways);IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBDownloadBssidTable (IxEthDBPortId portID, MacTreeNode *bssids);IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBDuplicateAddressCheck(MacTreeNode *rootNode, MacTreeNode *currentNode, UINT32 *dgwIndexAddr);IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBWiFiFrameControlDurationIDUpdate(IxEthDBPortId portID);/* forward prototypes */IX_ETH_DB_PUBLIC MacTreeNode *ixEthDBGatewaySelect(MacTreeNode *stations, UINT32 *gwCount);/** * @brief sets the BSSID value for the WiFi header conversion feature * * @param portID ID of the port * @param bssid pointer to the 6-byte BSSID value * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBWiFiBSSIDSet(IxEthDBPortId portID, IxEthDBMacAddr *bssid){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION); IX_ETH_DB_CHECK_REFERENCE(bssid); if (memcpy(ixEthDBPortInfo[portID].bssid, bssid, IX_IEEE803_MAC_ADDRESS_SIZE) == NULL) { return IX_ETH_DB_FAIL; } return IX_ETH_DB_SUCCESS;}/** * @brief updates the Frame Control and Duration/ID WiFi header * conversion parameters in an NPE * * @param portID ID of the port * * This function will send a message to the NPE updating the * frame conversion parameters for 802.3 => 802.11 header conversion. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or IX_ETH_DB_FAIL otherwise * * @internal */IX_ETH_DB_PRIVATEIxEthDBStatus ixEthDBWiFiFrameControlDurationIDUpdate(IxEthDBPortId portID){ IxNpeMhMessage message; IX_STATUS result; FILL_SETFRAMECONTROLDURATIONID(message, portID, ixEthDBPortInfo[portID].frameControlDurationID); IX_ETHDB_SEND_NPE_MSG(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portID), message, result); return result;}/** * @brief sets the Duration/ID WiFi frame header conversion parameter * * @param portID ID of the port * @param durationID 16-bit value containing the new Duration/ID parameter * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBWiFiDurationIDSet(IxEthDBPortId portID, UINT16 durationID){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION); ixEthDBPortInfo[portID].frameControlDurationID = (ixEthDBPortInfo[portID].frameControlDurationID & 0xFFFF0000) | durationID; return ixEthDBWiFiFrameControlDurationIDUpdate(portID);}/** * @brief sets the Frame Control WiFi frame header conversion parameter * * @param portID ID of the port * @param durationID 16-bit value containing the new Frame Control parameter * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBWiFiFrameControlSet(IxEthDBPortId portID, UINT16 frameControl){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION); ixEthDBPortInfo[portID].frameControlDurationID = (ixEthDBPortInfo[portID].frameControlDurationID & 0xFFFF) | (frameControl << 16); return ixEthDBWiFiFrameControlDurationIDUpdate(portID);}/** * @brief removes a WiFi header conversion record * * @param portID ID of the port * @param macAddr MAC address of the record to remove * * Note that this function is documented in the main * component header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed * successfully or an appropriate error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBWiFiEntryRemove(IxEthDBPortId portID, IxEthDBMacAddr *macAddr){ MacDescriptor recordTemplate; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_REFERENCE(macAddr); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION); memcpy(recordTemplate.macAddress, macAddr, IX_IEEE803_MAC_ADDRESS_SIZE); recordTemplate.type = IX_ETH_DB_WIFI_RECORD; recordTemplate.portID = portID; return ixEthDBRemove(&recordTemplate, NULL);}/** * @brief adds a WiFi header conversion record * * @param portID ID of the port * @param macAddr MAC address of the record to add * @param wifiRecData pointer to the wifi specific data (flags, gw etc.) * (GW address is NULL if this is a station record) * * This function adds a record of type AP_TO_AP (gateway is not NULL) * or AP_TO_STA (gateway is NULL) in the main database as a * WiFi header conversion record. * * @return IX_ETH_DB_SUCCESS if the operation completed * successfully or an appropriate error message otherwise * * @internal */IX_ETH_DB_PRIVATEIxEthDBStatus ixEthDBWiFiEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr, IxEthDBWiFiRecData *wifiRecData){ MacDescriptor recordTemplate; IxEthDBPortMap query; MacTreeNode *stations = NULL; MacTreeNode *gateways = NULL; PortInfo *portInfo; UINT32 gatewayCount = 1; IX_ETH_DB_CHECK_REFERENCE(wifiRecData); IX_ETH_DB_CHECK_REC_TYPE(wifiRecData->recType); IX_ETH_DB_CHECK_ODD_PAD(wifiRecData->padLength); IX_ETH_DB_CHECK_PAD_LENGTH(wifiRecData->padLength); IX_ETH_DB_CHECK_LOG_PORT(wifiRecData->logicalPortID); IX_ETH_DB_CHECK_WIFI_VLAN_TAG(wifiRecData->vlanTagFlag); if (wifiRecData->recType != IX_ETH_DB_WIFI_TO_ETHER && wifiRecData->recType != IX_ETH_DB_WIFI_TO_LOCAL) { IX_ETH_DB_CHECK_ADDR(wifiRecData->bssid); if (wifiRecData->recType == IX_ETH_DB_WIFI_AP_TO_AP) { IX_ETH_DB_CHECK_ADDR(wifiRecData->gatewayMacAddr); } } portInfo = &ixEthDBPortInfo[portID]; if (portInfo->wifiRecordsCount >= MAX_ELT_SIZE) { ERROR_LOG("DB: In ixEthDBWiFiEntryAdd(): Exceeded the maximum limit of wi-fi records\n"); return IX_ETH_DB_FAIL; } if (wifiRecData->recType == IX_ETH_DB_WIFI_AP_TO_STA || wifiRecData->recType == IX_ETH_DB_WIFI_AP_TO_AP) { /* Check that the number of Wifi records do not exceed the maximum capacity */ SET_DEPENDENCY_MAP(query, portID); stations = ixEthDBQuery(NULL, query, IX_ETH_DB_WIFI_RECORD, MAX_ELT_SIZE); gateways = ixEthDBGatewaySelect(stations, &gatewayCount); if (stations != NULL) ixEthDBFreeMacTreeNode(stations); if (gateways != NULL) ixEthDBFreeMacTreeNode(gateways); if (gatewayCount >= MAX_GW_SIZE) { ERROR_LOG("DB: In ixEthDBWiFiEntryAdd(): Exceeded maximum limit of gateway entries\n"); return IX_ETH_DB_FAIL; } if (wifiRecData->recType == IX_ETH_DB_WIFI_AP_TO_AP) { memcpy(recordTemplate.recordData.wifiData.gwMacAddress, wifiRecData->gatewayMacAddr, IX_IEEE803_MAC_ADDRESS_SIZE); } else { memset(recordTemplate.recordData.wifiData.gwMacAddress, 0, IX_IEEE803_MAC_ADDRESS_SIZE); } memcpy(recordTemplate.recordData.wifiData.bssid, wifiRecData->bssid, IX_IEEE803_MAC_ADDRESS_SIZE); recordTemplate.recordData.wifiData.recType = (wifiRecData->recType | (wifiRecData->vlanTagFlag <<2)); } else { memset(recordTemplate.recordData.wifiData.gwMacAddress, 0, IX_IEEE803_MAC_ADDRESS_SIZE); memset(recordTemplate.recordData.wifiData.bssid, 0, IX_IEEE803_MAC_ADDRESS_SIZE); recordTemplate.recordData.wifiData.recType = (wifiRecData->recType | (0 <<2)); } memcpy(recordTemplate.macAddress, macAddr, IX_IEEE803_MAC_ADDRESS_SIZE); recordTemplate.type = IX_ETH_DB_WIFI_RECORD; recordTemplate.portID = portID; /* This value will be overwritten for AP and STA cases later */ recordTemplate.recordData.wifiData.recIndex = portID; /* Divide pad length by 2 because we have only 4 bits to store the value 16 */ recordTemplate.recordData.wifiData.padLength = (wifiRecData->padLength)/2; recordTemplate.recordData.wifiData.logicalPortID = wifiRecData->logicalPortID; return ixEthDBAdd(&recordTemplate, NULL);}/** * @brief sets the BSSID/GW/Flag values in the WiFi header conversion table * * @param portID ID of the port * @param macAddr MAC address of the record to add * @param wifiRecData pointer to the wifi specific data (flags, gw, bssid etc.) * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed successfully * or an appropriate error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBWiFiRecordEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr, IxEthDBWiFiRecData *wifiRecData){ IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION); IX_ETH_DB_CHECK_REFERENCE(macAddr); return ixEthDBWiFiEntryAdd(portID, macAddr, wifiRecData);}/** * @brief adds a WiFi header conversion record * * @param portID ID of the port * @param macAddr MAC address of the record to add * @param gatewayMacAddr address of the gateway * * This function adds a record of type AP_TO_AP * in the main database as a WiFi header conversion record. * * This is simply a wrapper over @ref ixEthDBWiFiEntryAdd(). * * Note that this function is documented in the main * component header file, IxEthDB.h. * * @return IX_ETH_DB_SUCCESS if the operation completed * successfully or an appropriate error message otherwise */IX_ETH_DB_PUBLICIxEthDBStatus ixEthDBWiFiAccessPointEntryAdd(IxEthDBPortId portID, IxEthDBMacAddr *macAddr, IxEthDBMacAddr *gatewayMacAddr){ IxEthDBWiFiRecData wifiRecData; PortInfo *portInfo; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_WIFI_HEADER_CONVERSION); IX_ETH_DB_CHECK_REFERENCE(macAddr); IX_ETH_DB_CHECK_REFERENCE(gatewayMacAddr); portInfo = &ixEthDBPortInfo[portID]; IX_ETH_DB_CHECK_ADDR(portInfo->bssid); memcpy(wifiRecData.bssid, portInfo->bssid, IX_IEEE803_MAC_ADDRESS_SIZE); memcpy(wifiRecData.gatewayMacAddr, gatewayMacAddr, IX_IEEE803_MAC_ADDRESS_SIZE); wifiRecData.recType = IX_ETH_DB_WIFI_AP_TO_AP; wifiRecData.vlanTagFlag = IX_ETH_DB_WIFI_VLAN_NOTAG; wifiRecData.padLength = IX_ETH_DB_WIFI_MIN_PAD_SIZE; wifiRecData.logicalPortID = 0xFF; return ixEthDBWiFiEntryAdd(portID, macAddr, &wifiRecData);}/** * @brief adds a WiFi header conversion record * * @param portID ID of the port
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -