Esempio n. 1
0
/**
 * @brief matches two database records based on their MAC addresses
 * and VLAN IDs
 *
 * @param untypedReference record to match against
 * @param untypedEntry record to match
 *
 * @return TRUE if the match is successful or FALSE otherwise
 *
 * @internal
 */
IX_ETH_DB_PUBLIC
BOOL ixEthDBVlanRecordMatch(void *untypedReference, void *untypedEntry)
{
    MacDescriptor *entry     = (MacDescriptor *) untypedEntry;
    MacDescriptor *reference = (MacDescriptor *) untypedReference;
    
    /* check accepted record types */
    if ((entry->type & reference->type) == 0) return FALSE;
    
    return (IX_ETH_DB_GET_VLAN_ID(entry->recordData.filteringVlanData.ieee802_1qTag) ==
        IX_ETH_DB_GET_VLAN_ID(reference->recordData.filteringVlanData.ieee802_1qTag)) &&
        (ixEthDBAddressCompare(entry->macAddress, reference->macAddress) == 0);
}
/**
 * @brief displays one record in a format depending on the record filter
 *
 * @param descriptor pointer to the record
 * @param recordFilter format filter
 *
 * This function will display the fields in a record depending on the
 * selected record filter.
 *
 * @internal
 */
IX_ETH_DB_PRIVATE
void ixEthDBRecordShow(MacDescriptor *descriptor, IxEthDBRecordType recordFilter)
{
    if (recordFilter == IX_ETH_DB_FILTERING_VLAN_RECORD
        || recordFilter == (IX_ETH_DB_FILTERING_RECORD | IX_ETH_DB_FILTERING_VLAN_RECORD))
    {
        /* display VLAN record header - leave this commented code in place, its purpose is to align the print format with the header
        printf("    MAC address    |   Age  |   Type   | VLAN ID | CFI | QoS class \n");
        printf("___________________________________________________________________\n"); */

        if (descriptor->type == IX_ETH_DB_FILTERING_VLAN_RECORD)
        {
            printf("%02X:%02X:%02X:%02X:%02X:%02X | %3d | %s | %d | %d | %d\n",
                descriptor->macAddress[0],
                descriptor->macAddress[1],
                descriptor->macAddress[2],
                descriptor->macAddress[3],
                descriptor->macAddress[4],
                descriptor->macAddress[5],
                descriptor->recordData.filteringVlanData.age,
                descriptor->recordData.filteringVlanData.staticEntry ? "static" : "dynamic",
                IX_ETH_DB_GET_VLAN_ID(descriptor->recordData.filteringVlanData.ieee802_1qTag),
                (descriptor->recordData.filteringVlanData.ieee802_1qTag & 0x1000) >> 12,
                IX_ETH_DB_GET_QOS_PRIORITY(descriptor->recordData.filteringVlanData.ieee802_1qTag));
         }
         else if (descriptor->type == IX_ETH_DB_FILTERING_RECORD)