IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFilteringPortSearch(IxEthDBPortId portID, IxEthDBMacAddr *macAddr) { HashNode *searchResult; IxEthDBStatus result = IX_ETH_DB_NO_SUCH_ADDR; 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_LEARNING); searchResult = ixEthDBSearch(macAddr, IX_ETH_DB_ALL_FILTERING_RECORDS); if (searchResult == NULL) { return IX_ETH_DB_NO_SUCH_ADDR; /* not found */ } if (((MacDescriptor *) (searchResult->data))->portID == portID) { result = IX_ETH_DB_SUCCESS; /* address and port match */ } ixEthDBReleaseHashNode(searchResult); return result; }
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFilteringDynamicEntryProvision(IxEthDBPortId portID, IxEthDBMacAddr *macAddr) { 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_LEARNING); return ixEthDBTriggerAddPortUpdate(macAddr, portID, FALSE); }
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortAgingEnable(IxEthDBPortId portID) { IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_LEARNING); ixEthDBPortInfo[portID].agingEnabled = TRUE; return IX_ETH_DB_SUCCESS; }
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortUpdateEnableSet(IxEthDBPortId portID, BOOL enableUpdate) { IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_FILTERING); ixEthDBPortInfo[portID].updateMethod.updateEnabled = enableUpdate; ixEthDBPortInfo[portID].updateMethod.userControlled = TRUE; return IX_ETH_DB_SUCCESS; }
/** * @brief retrieves the STP blocking state of a port * * @param portID ID of the port * @param blocked address to write the blocked status into * * 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_PUBLIC IxEthDBStatus ixEthDBSpanningTreeBlockingStateGet(IxEthDBPortId portID, BOOL *blocked) { IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_SPANNING_TREE_PROTOCOL); IX_ETH_DB_CHECK_REFERENCE(blocked); *blocked = ixEthDBPortInfo[portID].stpBlocked; return IX_ETH_DB_SUCCESS; }
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortDependencyMapGet(IxEthDBPortId portID, IxEthDBPortMap dependencyPortMap) { IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_REFERENCE(dependencyPortMap); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_FILTERING); COPY_DEPENDENCY_MAP(dependencyPortMap, ixEthDBPortInfo[portID].dependencyPortMap); return IX_ETH_DB_SUCCESS; }
/** * @brief returns the status of a feature * * @param portID port ID * @param present location to store a boolean value indicating * if the feature is present (TRUE) or not (FALSE) * @param enabled location to store a booleam value indicating * if the feature is present (TRUE) or not (FALSE) * * 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_PUBLIC IxEthDBStatus ixEthDBFeatureStatusGet(IxEthDBPortId portID, IxEthDBFeature feature, BOOL *present, BOOL *enabled) { PortInfo *portInfo; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_REFERENCE(present); IX_ETH_DB_CHECK_REFERENCE(enabled); portInfo = &ixEthDBPortInfo[portID]; *present = (portInfo->featureCapability & feature) != 0; *enabled = (portInfo->featureStatus & feature) != 0; return IX_ETH_DB_SUCCESS; }
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortDependencyMapSet(IxEthDBPortId portID, IxEthDBPortMap dependencyPortMap) { IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_REFERENCE(dependencyPortMap); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_FILTERING); /* force bit at offset 255 to 0 (reserved) */ dependencyPortMap[31] &= 0xFE; COPY_DEPENDENCY_MAP(ixEthDBPortInfo[portID].dependencyPortMap, dependencyPortMap); return IX_ETH_DB_SUCCESS; }
/** * @brief sets the STP blocking state of a port * * @param portID ID of the port * @param blocked TRUE to block the port or FALSE to unblock it * * 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_PUBLIC IxEthDBStatus ixEthDBSpanningTreeBlockingStateSet(IxEthDBPortId portID, BOOL blocked) { IxNpeMhMessage message; IX_STATUS result; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); IX_ETH_DB_CHECK_FEATURE(portID, IX_ETH_DB_SPANNING_TREE_PROTOCOL); ixEthDBPortInfo[portID].stpBlocked = blocked; FILL_SETBLOCKINGSTATE_MSG(message, portID, blocked); IX_ETHDB_SEND_NPE_MSG(IX_ETHNPE_PHYSICAL_ID_TO_NODE(portID), message, result); return result; }
/** * @brief Restore the states of EthDB Features * * @param portID ID of the port * * See IxEthDB.h for more details. */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFeatureStatesRestore(IxEthDBPortId portID) { PortInfo *portInfo = &ixEthDBPortInfo[portID]; /* Check whether port if enabled */ IX_ETH_DB_CHECK_PORT_INITIALIZED(portID); IX_ETH_DB_CHECK_PORT(portID); /* ======================== Basic ========================== * Set up Port MAC Address */ if (ixEthDBPortAddressSet(portID, &(portInfo->macAddr)) != IX_SUCCESS) { return IX_ETH_DB_FAIL; } /* * Set up Port Max Rx/Tx frame lengths */ if(ixEthDBPortFrameLengthsUpdate(portID) != IX_SUCCESS) { return IX_ETH_DB_FAIL; } /* ======================== VLAN/QoS ========================== * Only performs VLAN feature update if it is enabled before */ if ((portInfo->featureStatus & IX_ETH_DB_VLAN_QOS) != 0) { /* Set VLAN Rx tag mode */ if (ixEthDBIngressVlanModeUpdate(portID) != IX_SUCCESS) { return IX_ETH_DB_FAIL; } /* Set Default Rx VID */ if (ixEthDBPortVlanTagSet(portID, portInfo->vlanTag) != IX_SUCCESS) { return IX_ETH_DB_FAIL; } /* Set PortID extraction mode */ if (ixEthDBVlanPortExtractionEnable(portID, portInfo->portIdExtractionEnable) != IX_SUCCESS) { return IX_ETH_DB_FAIL; } /* Set VLAN Table */ if (ixEthDBVlanTableRangeUpdate(portID) != IX_SUCCESS) { return IX_ETH_DB_FAIL; } } /* VLAN/QoS */ /* ======================== Firewall ========================== * Only performs Firewall feature update if it is enabled before */ if ((portInfo->featureStatus & IX_ETH_DB_FIREWALL) != 0) { if(ixEthDBFirewallTableDownload(portID) != IX_SUCCESS) { return IX_ETH_DB_FAIL; } } /* Firewall */ /* ===================== Header Conversion ========================== * Only performs Header Conversion feature update if it is enabled before */ if ((portInfo->featureStatus & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0) { /* Update WiFi FC & DID */ if (ixEthDBWiFiFrameControlDurationIDUpdate(portID) != IX_SUCCESS) { return IX_ETH_DB_FAIL; } /* Update BSSID */ if (ixEthDBWiFiBSSIDSet(portID, (IxEthDBMacAddr *) portInfo->bssid) != IX_SUCCESS) { return IX_ETH_DB_FAIL; } /* Update Header Conversion Table & AP MAC Table */ if (ixEthDBWiFiConversionTableDownload(portID) != IX_ETH_DB_SUCCESS) { return IX_ETH_DB_FAIL; } } /* Header Conversion */ /* ====================== Learning & Filtering ========================== * Learning & Filtering feature update is not neccessary as we can rely * on EthNPE to learn the src address again. As for the entry added by client * earlier, it will be lost. This is the constraint as the mechanism to retrieve * the entry that has been added by client from NPE is not trivial. */ /* ============================== STP =================================== * Only performs STP feature update if it is enabled before */ if ((portInfo->featureStatus & IX_ETH_DB_SPANNING_TREE_PROTOCOL) != 0) { if (ixEthDBSpanningTreeBlockingStateSet(portID, portInfo->stpBlocked) != IX_SUCCESS) { return IX_ETH_DB_FAIL; } } return IX_ETH_DB_SUCCESS; }
/** * @brief displays all the filtering records belonging to a port * * @param portID ID of the port to display * * Note that this function is documented in the main component * header file, IxEthDB.h. * * @warning deprecated, use @ref ixEthDBFilteringDatabaseShowRecords() * instead. Calling this function is equivalent to calling * ixEthDBFilteringDatabaseShowRecords(portID, IX_ETH_DB_FILTERING_RECORD) */ IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFilteringDatabaseShow(IxEthDBPortId portID) { IxEthDBStatus local_result; HashIterator iterator; PortInfo *portInfo; UINT32 recordCount = 0; IX_ETH_DB_CHECK_PORT(portID); IX_ETH_DB_CHECK_SINGLE_NPE(portID); portInfo = &ixEthDBPortInfo[portID]; /* display table header */ printf("Ethernet database records for port ID [%d]\n", portID); ixEthDBDependencyPortMapShow(portID, portInfo->dependencyPortMap); if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) { printf("NPE updates are %s\n\n", portInfo->updateMethod.updateEnabled ? "enabled" : "disabled"); } else { printf("updates disabled (not an NPE)\n\n"); } printf(" MAC address | Age | Type \n"); printf("___________________________________\n"); /* browse database */ BUSY_RETRY(ixEthDBInitHashIterator(&dbHashtable, &iterator)); while (IS_ITERATOR_VALID(&iterator)) { MacDescriptor *descriptor = (MacDescriptor *) iterator.node->data; if (descriptor->portID == portID && descriptor->type == IX_ETH_DB_FILTERING_RECORD) { recordCount++; /* display entry */ printf(" %02X:%02X:%02X:%02X:%02X:%02X | %5d | %s\n", descriptor->macAddress[0], descriptor->macAddress[1], descriptor->macAddress[2], descriptor->macAddress[3], descriptor->macAddress[4], descriptor->macAddress[5], descriptor->recordData.filteringData.age, descriptor->recordData.filteringData.staticEntry ? "static" : "dynamic"); } /* move to the next record */ BUSY_RETRY_WITH_RESULT(ixEthDBIncrementHashIterator(&dbHashtable, &iterator), local_result); /* debug */ if (local_result == IX_ETH_DB_BUSY) { return IX_ETH_DB_FAIL; } } /* display number of records */ printf("\nFound %d records\n", recordCount); return IX_ETH_DB_SUCCESS; }