Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file IxEthDBAPI.c |
| 3 | * |
| 4 | * @brief Implementation of the public API |
| 5 | * |
| 6 | * @par |
| 7 | * IXP400 SW Release version 2.0 |
| 8 | * |
| 9 | * -- Copyright Notice -- |
| 10 | * |
| 11 | * @par |
| 12 | * Copyright 2001-2005, Intel Corporation. |
| 13 | * All rights reserved. |
| 14 | * |
| 15 | * @par |
Wolfgang Denk | cb3761e | 2013-07-28 22:12:47 +0200 | [diff] [blame^] | 16 | * SPDX-License-Identifier: BSD-3-Clause |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 17 | * @par |
| 18 | * -- End of Copyright Notice -- |
| 19 | */ |
| 20 | |
| 21 | #include "IxEthDB_p.h" |
| 22 | |
| 23 | extern HashTable dbHashtable; |
| 24 | IX_ETH_DB_PRIVATE void ixEthDBPortInfoShow(IxEthDBPortId portID, IxEthDBRecordType recordFilter); |
| 25 | IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBHeaderShow(IxEthDBRecordType recordFilter); |
| 26 | IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBDependencyPortMapShow(IxEthDBPortId portID, IxEthDBPortMap map); |
| 27 | |
| 28 | /** |
| 29 | * @brief displays a port dependency map |
| 30 | * |
| 31 | * @param portID ID of the port |
| 32 | * @param map port map to display |
| 33 | * |
| 34 | * @return IX_ETH_DB_SUCCESS if the operation completed |
| 35 | * successfully |
| 36 | */ |
| 37 | IX_ETH_DB_PUBLIC |
| 38 | IxEthDBStatus ixEthDBDependencyPortMapShow(IxEthDBPortId portID, IxEthDBPortMap map) |
| 39 | { |
| 40 | UINT32 portIndex; |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 41 | BOOL mapSelf = true, mapNone = true, firstPort = true; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 42 | |
| 43 | /* dependency port maps */ |
| 44 | printf("Dependency port map: "); |
| 45 | |
| 46 | /* browse the port map */ |
| 47 | for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++) |
| 48 | { |
| 49 | if (IS_PORT_INCLUDED(portIndex, map)) |
| 50 | { |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 51 | mapNone = false; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 52 | |
| 53 | if (portIndex != portID) |
| 54 | { |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 55 | mapSelf = false; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | printf("%s%d", firstPort ? "{" : ", ", portIndex); |
| 59 | |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 60 | firstPort = false; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 61 | } |
| 62 | } |
| 63 | |
| 64 | if (mapNone) |
| 65 | { |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 66 | mapSelf = false; |
Wolfgang Denk | ba94a1b | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | printf("%s (%s)\n", firstPort ? "" : "}", mapSelf ? "self" : mapNone ? "none" : "group"); |
| 70 | |
| 71 | return IX_ETH_DB_SUCCESS; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * @brief displays all the filtering records belonging to a port |
| 76 | * |
| 77 | * @param portID ID of the port to display |
| 78 | * |
| 79 | * Note that this function is documented in the main component |
| 80 | * header file, IxEthDB.h. |
| 81 | * |
| 82 | * @warning deprecated, use @ref ixEthDBFilteringDatabaseShowRecords() |
| 83 | * instead. Calling this function is equivalent to calling |
| 84 | * ixEthDBFilteringDatabaseShowRecords(portID, IX_ETH_DB_FILTERING_RECORD) |
| 85 | */ |
| 86 | IX_ETH_DB_PUBLIC |
| 87 | IxEthDBStatus ixEthDBFilteringDatabaseShow(IxEthDBPortId portID) |
| 88 | { |
| 89 | IxEthDBStatus local_result; |
| 90 | HashIterator iterator; |
| 91 | PortInfo *portInfo; |
| 92 | UINT32 recordCount = 0; |
| 93 | |
| 94 | IX_ETH_DB_CHECK_PORT(portID); |
| 95 | |
| 96 | IX_ETH_DB_CHECK_SINGLE_NPE(portID); |
| 97 | |
| 98 | portInfo = &ixEthDBPortInfo[portID]; |
| 99 | |
| 100 | /* display table header */ |
| 101 | printf("Ethernet database records for port ID [%d]\n", portID); |
| 102 | |
| 103 | ixEthDBDependencyPortMapShow(portID, portInfo->dependencyPortMap); |
| 104 | |
| 105 | if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) |
| 106 | { |
| 107 | printf("NPE updates are %s\n\n", portInfo->updateMethod.updateEnabled ? "enabled" : "disabled"); |
| 108 | } |
| 109 | else |
| 110 | { |
| 111 | printf("updates disabled (not an NPE)\n\n"); |
| 112 | } |
| 113 | |
| 114 | printf(" MAC address | Age | Type \n"); |
| 115 | printf("___________________________________\n"); |
| 116 | |
| 117 | /* browse database */ |
| 118 | BUSY_RETRY(ixEthDBInitHashIterator(&dbHashtable, &iterator)); |
| 119 | |
| 120 | while (IS_ITERATOR_VALID(&iterator)) |
| 121 | { |
| 122 | MacDescriptor *descriptor = (MacDescriptor *) iterator.node->data; |
| 123 | |
| 124 | if (descriptor->portID == portID && descriptor->type == IX_ETH_DB_FILTERING_RECORD) |
| 125 | { |
| 126 | recordCount++; |
| 127 | |
| 128 | /* display entry */ |
| 129 | printf(" %02X:%02X:%02X:%02X:%02X:%02X | %5d | %s\n", |
| 130 | descriptor->macAddress[0], |
| 131 | descriptor->macAddress[1], |
| 132 | descriptor->macAddress[2], |
| 133 | descriptor->macAddress[3], |
| 134 | descriptor->macAddress[4], |
| 135 | descriptor->macAddress[5], |
| 136 | descriptor->recordData.filteringData.age, |
| 137 | descriptor->recordData.filteringData.staticEntry ? "static" : "dynamic"); |
| 138 | } |
| 139 | |
| 140 | /* move to the next record */ |
| 141 | BUSY_RETRY_WITH_RESULT(ixEthDBIncrementHashIterator(&dbHashtable, &iterator), local_result); |
| 142 | |
| 143 | /* debug */ |
| 144 | if (local_result == IX_ETH_DB_BUSY) |
| 145 | { |
| 146 | return IX_ETH_DB_FAIL; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | /* display number of records */ |
| 151 | printf("\nFound %d records\n", recordCount); |
| 152 | |
| 153 | return IX_ETH_DB_SUCCESS; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * @brief displays all the filtering records belonging to all the ports |
| 158 | * |
| 159 | * Note that this function is documented in the main component |
| 160 | * header file, IxEthDB.h. |
| 161 | * |
| 162 | * @warning deprecated, use @ref ixEthDBFilteringDatabaseShowRecords() |
| 163 | * instead. Calling this function is equivalent to calling |
| 164 | * ixEthDBFilteringDatabaseShowRecords(IX_ETH_DB_ALL_PORTS, IX_ETH_DB_FILTERING_RECORD) |
| 165 | */ |
| 166 | IX_ETH_DB_PUBLIC |
| 167 | void ixEthDBFilteringDatabaseShowAll() |
| 168 | { |
| 169 | IxEthDBPortId portIndex; |
| 170 | |
| 171 | printf("\nEthernet learning/filtering database: listing %d ports\n\n", (UINT32) IX_ETH_DB_NUMBER_OF_PORTS); |
| 172 | |
| 173 | for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++) |
| 174 | { |
| 175 | ixEthDBFilteringDatabaseShow(portIndex); |
| 176 | |
| 177 | if (portIndex < IX_ETH_DB_NUMBER_OF_PORTS - 1) |
| 178 | { |
| 179 | printf("\n"); |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * @brief displays one record in a format depending on the record filter |
| 186 | * |
| 187 | * @param descriptor pointer to the record |
| 188 | * @param recordFilter format filter |
| 189 | * |
| 190 | * This function will display the fields in a record depending on the |
| 191 | * selected record filter. |
| 192 | * |
| 193 | * @internal |
| 194 | */ |
| 195 | IX_ETH_DB_PRIVATE |
| 196 | void ixEthDBRecordShow(MacDescriptor *descriptor, IxEthDBRecordType recordFilter) |
| 197 | { |
| 198 | if (recordFilter == IX_ETH_DB_FILTERING_VLAN_RECORD |
| 199 | || recordFilter == (IX_ETH_DB_FILTERING_RECORD | IX_ETH_DB_FILTERING_VLAN_RECORD)) |
| 200 | { |
| 201 | /* display VLAN record header - leave this commented code in place, its purpose is to align the print format with the header |
| 202 | printf(" MAC address | Age | Type | VLAN ID | CFI | QoS class \n"); |
| 203 | printf("___________________________________________________________________\n"); */ |
| 204 | |
| 205 | if (descriptor->type == IX_ETH_DB_FILTERING_VLAN_RECORD) |
| 206 | { |
| 207 | printf("%02X:%02X:%02X:%02X:%02X:%02X | %3d | %s | %d | %d | %d\n", |
| 208 | descriptor->macAddress[0], |
| 209 | descriptor->macAddress[1], |
| 210 | descriptor->macAddress[2], |
| 211 | descriptor->macAddress[3], |
| 212 | descriptor->macAddress[4], |
| 213 | descriptor->macAddress[5], |
| 214 | descriptor->recordData.filteringVlanData.age, |
| 215 | descriptor->recordData.filteringVlanData.staticEntry ? "static" : "dynamic", |
| 216 | IX_ETH_DB_GET_VLAN_ID(descriptor->recordData.filteringVlanData.ieee802_1qTag), |
| 217 | (descriptor->recordData.filteringVlanData.ieee802_1qTag & 0x1000) >> 12, |
| 218 | IX_ETH_DB_GET_QOS_PRIORITY(descriptor->recordData.filteringVlanData.ieee802_1qTag)); |
| 219 | } |
| 220 | else if (descriptor->type == IX_ETH_DB_FILTERING_RECORD) |
| 221 | { |
| 222 | printf("%02X:%02X:%02X:%02X:%02X:%02X | %3d | %s | - | - | -\n", |
| 223 | descriptor->macAddress[0], |
| 224 | descriptor->macAddress[1], |
| 225 | descriptor->macAddress[2], |
| 226 | descriptor->macAddress[3], |
| 227 | descriptor->macAddress[4], |
| 228 | descriptor->macAddress[5], |
| 229 | descriptor->recordData.filteringData.age, |
| 230 | descriptor->recordData.filteringData.staticEntry ? "static" : "dynamic"); |
| 231 | } |
| 232 | } |
| 233 | else if (recordFilter == IX_ETH_DB_FILTERING_RECORD) |
| 234 | { |
| 235 | /* display filtering record header - leave this commented code in place, its purpose is to align the print format with the header |
| 236 | printf(" MAC address | Age | Type \n"); |
| 237 | printf("_______________________________________\n"); */ |
| 238 | |
| 239 | if (descriptor->type == IX_ETH_DB_FILTERING_RECORD) |
| 240 | { |
| 241 | printf("%02X:%02X:%02X:%02X:%02X:%02X | %3d | %s \n", |
| 242 | descriptor->macAddress[0], |
| 243 | descriptor->macAddress[1], |
| 244 | descriptor->macAddress[2], |
| 245 | descriptor->macAddress[3], |
| 246 | descriptor->macAddress[4], |
| 247 | descriptor->macAddress[5], |
| 248 | descriptor->recordData.filteringData.age, |
| 249 | descriptor->recordData.filteringData.staticEntry ? "static" : "dynamic"); |
| 250 | } |
| 251 | } |
| 252 | else if (recordFilter == IX_ETH_DB_WIFI_RECORD) |
| 253 | { |
| 254 | /* display WiFi record header - leave this commented code in place, its purpose is to align the print format with the header |
| 255 | printf(" MAC address | GW MAC address \n"); |
| 256 | printf("_______________________________________\n"); */ |
| 257 | |
| 258 | if (descriptor->type == IX_ETH_DB_WIFI_RECORD) |
| 259 | { |
| 260 | if (descriptor->recordData.wifiData.type == IX_ETH_DB_WIFI_AP_TO_AP) |
| 261 | { |
| 262 | /* gateway address present */ |
| 263 | printf("%02X:%02X:%02X:%02X:%02X:%02X | %02X:%02X:%02X:%02X:%02X:%02X \n", |
| 264 | descriptor->macAddress[0], |
| 265 | descriptor->macAddress[1], |
| 266 | descriptor->macAddress[2], |
| 267 | descriptor->macAddress[3], |
| 268 | descriptor->macAddress[4], |
| 269 | descriptor->macAddress[5], |
| 270 | descriptor->recordData.wifiData.gwMacAddress[0], |
| 271 | descriptor->recordData.wifiData.gwMacAddress[1], |
| 272 | descriptor->recordData.wifiData.gwMacAddress[2], |
| 273 | descriptor->recordData.wifiData.gwMacAddress[3], |
| 274 | descriptor->recordData.wifiData.gwMacAddress[4], |
| 275 | descriptor->recordData.wifiData.gwMacAddress[5]); |
| 276 | } |
| 277 | else |
| 278 | { |
| 279 | /* no gateway */ |
| 280 | printf("%02X:%02X:%02X:%02X:%02X:%02X | ----no gateway----- \n", |
| 281 | descriptor->macAddress[0], |
| 282 | descriptor->macAddress[1], |
| 283 | descriptor->macAddress[2], |
| 284 | descriptor->macAddress[3], |
| 285 | descriptor->macAddress[4], |
| 286 | descriptor->macAddress[5]); |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | else if (recordFilter == IX_ETH_DB_FIREWALL_RECORD) |
| 291 | { |
| 292 | /* display Firewall record header - leave this commented code in place, its purpose is to align the print format with the header |
| 293 | printf(" MAC address \n"); |
| 294 | printf("__________________\n"); */ |
| 295 | |
| 296 | if (descriptor->type == IX_ETH_DB_FIREWALL_RECORD) |
| 297 | { |
| 298 | printf("%02X:%02X:%02X:%02X:%02X:%02X \n", |
| 299 | descriptor->macAddress[0], |
| 300 | descriptor->macAddress[1], |
| 301 | descriptor->macAddress[2], |
| 302 | descriptor->macAddress[3], |
| 303 | descriptor->macAddress[4], |
| 304 | descriptor->macAddress[5]); |
| 305 | } |
| 306 | } |
| 307 | else if (recordFilter == IX_ETH_DB_ALL_RECORD_TYPES) |
| 308 | { |
| 309 | /* display composite record header - leave this commented code in place, its purpose is to align the print format with the header |
| 310 | printf(" MAC address | Record | Age| Type | VLAN |CFI| QoS | GW MAC address \n"); |
| 311 | printf("_______________________________________________________________________________\n"); */ |
| 312 | |
| 313 | if (descriptor->type == IX_ETH_DB_FILTERING_VLAN_RECORD) |
| 314 | { |
| 315 | printf("%02X:%02X:%02X:%02X:%02X:%02X | VLAN | %2d | %s | %4d | %1d | %1d | -----------------\n", |
| 316 | descriptor->macAddress[0], |
| 317 | descriptor->macAddress[1], |
| 318 | descriptor->macAddress[2], |
| 319 | descriptor->macAddress[3], |
| 320 | descriptor->macAddress[4], |
| 321 | descriptor->macAddress[5], |
| 322 | descriptor->recordData.filteringVlanData.age, |
| 323 | descriptor->recordData.filteringVlanData.staticEntry ? "static " : "dynamic", |
| 324 | IX_ETH_DB_GET_VLAN_ID(descriptor->recordData.filteringVlanData.ieee802_1qTag), |
| 325 | (descriptor->recordData.filteringVlanData.ieee802_1qTag & 0x1000) >> 12, |
| 326 | IX_ETH_DB_GET_QOS_PRIORITY(descriptor->recordData.filteringVlanData.ieee802_1qTag)); |
| 327 | } |
| 328 | else if (descriptor->type == IX_ETH_DB_FILTERING_RECORD) |
| 329 | { |
| 330 | printf("%02X:%02X:%02X:%02X:%02X:%02X | Filter | %2d | %s | ---- | - | --- | -----------------\n", |
| 331 | descriptor->macAddress[0], |
| 332 | descriptor->macAddress[1], |
| 333 | descriptor->macAddress[2], |
| 334 | descriptor->macAddress[3], |
| 335 | descriptor->macAddress[4], |
| 336 | descriptor->macAddress[5], |
| 337 | descriptor->recordData.filteringData.age, |
| 338 | descriptor->recordData.filteringData.staticEntry ? "static " : "dynamic"); |
| 339 | } |
| 340 | else if (descriptor->type == IX_ETH_DB_WIFI_RECORD) |
| 341 | { |
| 342 | if (descriptor->recordData.wifiData.type == IX_ETH_DB_WIFI_AP_TO_AP) |
| 343 | { |
| 344 | /* gateway address present */ |
| 345 | printf("%02X:%02X:%02X:%02X:%02X:%02X | WiFi | -- | AP=>AP | ---- | - | --- | %02X:%02X:%02X:%02X:%02X:%02X\n", |
| 346 | descriptor->macAddress[0], |
| 347 | descriptor->macAddress[1], |
| 348 | descriptor->macAddress[2], |
| 349 | descriptor->macAddress[3], |
| 350 | descriptor->macAddress[4], |
| 351 | descriptor->macAddress[5], |
| 352 | descriptor->recordData.wifiData.gwMacAddress[0], |
| 353 | descriptor->recordData.wifiData.gwMacAddress[1], |
| 354 | descriptor->recordData.wifiData.gwMacAddress[2], |
| 355 | descriptor->recordData.wifiData.gwMacAddress[3], |
| 356 | descriptor->recordData.wifiData.gwMacAddress[4], |
| 357 | descriptor->recordData.wifiData.gwMacAddress[5]); |
| 358 | } |
| 359 | else |
| 360 | { |
| 361 | /* no gateway */ |
| 362 | printf("%02X:%02X:%02X:%02X:%02X:%02X | WiFi | -- | AP=>ST | ---- | - | --- | -- no gateway -- \n", |
| 363 | descriptor->macAddress[0], |
| 364 | descriptor->macAddress[1], |
| 365 | descriptor->macAddress[2], |
| 366 | descriptor->macAddress[3], |
| 367 | descriptor->macAddress[4], |
| 368 | descriptor->macAddress[5]); |
| 369 | } |
| 370 | } |
| 371 | else if (descriptor->type == IX_ETH_DB_FIREWALL_RECORD) |
| 372 | { |
| 373 | printf("%02X:%02X:%02X:%02X:%02X:%02X | FW | -- | ------- | ---- | - | --- | -----------------\n", |
| 374 | descriptor->macAddress[0], |
| 375 | descriptor->macAddress[1], |
| 376 | descriptor->macAddress[2], |
| 377 | descriptor->macAddress[3], |
| 378 | descriptor->macAddress[4], |
| 379 | descriptor->macAddress[5]); |
| 380 | } |
| 381 | } |
| 382 | else |
| 383 | { |
| 384 | printf("invalid record filter\n"); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * @brief displays the status, records and configuration information of a port |
| 390 | * |
| 391 | * @param portID ID of the port |
| 392 | * @param recordFilter record filter to display |
| 393 | * |
| 394 | * @internal |
| 395 | */ |
| 396 | IX_ETH_DB_PRIVATE |
| 397 | void ixEthDBPortInfoShow(IxEthDBPortId portID, IxEthDBRecordType recordFilter) |
| 398 | { |
| 399 | PortInfo *portInfo = &ixEthDBPortInfo[portID]; |
| 400 | UINT32 recordCount = 0; |
| 401 | HashIterator iterator; |
| 402 | IxEthDBStatus local_result; |
| 403 | |
| 404 | /* display port status */ |
| 405 | printf("== Port ID %d ==\n", portID); |
| 406 | |
| 407 | /* display capabilities */ |
| 408 | printf("- Capabilities: "); |
| 409 | |
| 410 | if ((portInfo->featureCapability & IX_ETH_DB_LEARNING) != 0) |
| 411 | { |
| 412 | printf("Learning (%s) ", ((portInfo->featureStatus & IX_ETH_DB_LEARNING) != 0) ? "on" : "off"); |
| 413 | } |
| 414 | |
| 415 | if ((portInfo->featureCapability & IX_ETH_DB_VLAN_QOS) != 0) |
| 416 | { |
| 417 | printf("VLAN/QoS (%s) ", ((portInfo->featureStatus & IX_ETH_DB_VLAN_QOS) != 0) ? "on" : "off"); |
| 418 | } |
| 419 | |
| 420 | if ((portInfo->featureCapability & IX_ETH_DB_FIREWALL) != 0) |
| 421 | { |
| 422 | printf("Firewall (%s) ", ((portInfo->featureStatus & IX_ETH_DB_FIREWALL) != 0) ? "on" : "off"); |
| 423 | } |
| 424 | |
| 425 | if ((portInfo->featureCapability & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0) |
| 426 | { |
| 427 | printf("WiFi (%s) ", ((portInfo->featureStatus & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0) ? "on" : "off"); |
| 428 | } |
| 429 | |
| 430 | if ((portInfo->featureCapability & IX_ETH_DB_SPANNING_TREE_PROTOCOL) != 0) |
| 431 | { |
| 432 | printf("STP (%s) ", ((portInfo->featureStatus & IX_ETH_DB_SPANNING_TREE_PROTOCOL) != 0) ? "on" : "off"); |
| 433 | } |
| 434 | |
| 435 | printf("\n"); |
| 436 | |
| 437 | /* dependency map */ |
| 438 | ixEthDBDependencyPortMapShow(portID, portInfo->dependencyPortMap); |
| 439 | |
| 440 | /* NPE dynamic updates */ |
| 441 | if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) |
| 442 | { |
| 443 | printf(" - NPE dynamic update is %s\n", portInfo->updateMethod.updateEnabled ? "enabled" : "disabled"); |
| 444 | } |
| 445 | else |
| 446 | { |
| 447 | printf(" - dynamic update disabled (not an NPE)\n"); |
| 448 | } |
| 449 | |
| 450 | if ((portInfo->featureCapability & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0) |
| 451 | { |
| 452 | if ((portInfo->featureStatus & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0) |
| 453 | { |
| 454 | /* WiFi header conversion */ |
| 455 | if ((portInfo->frameControlDurationID |
| 456 | + portInfo->bbsid[0] |
| 457 | + portInfo->bbsid[1] |
| 458 | + portInfo->bbsid[2] |
| 459 | + portInfo->bbsid[3] |
| 460 | + portInfo->bbsid[4] |
| 461 | + portInfo->bbsid[5]) == 0) |
| 462 | { |
| 463 | printf(" - WiFi header conversion not configured\n"); |
| 464 | } |
| 465 | else |
| 466 | { |
| 467 | printf(" - WiFi header conversion: BBSID [%02X:%02X:%02X:%02X:%02X:%02X], Frame Control 0x%X, Duration/ID 0x%X\n", |
| 468 | portInfo->bbsid[0], |
| 469 | portInfo->bbsid[1], |
| 470 | portInfo->bbsid[2], |
| 471 | portInfo->bbsid[3], |
| 472 | portInfo->bbsid[4], |
| 473 | portInfo->bbsid[5], |
| 474 | portInfo->frameControlDurationID >> 16, |
| 475 | portInfo->frameControlDurationID & 0xFFFF); |
| 476 | } |
| 477 | } |
| 478 | else |
| 479 | { |
| 480 | printf(" - WiFi header conversion not enabled\n"); |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | /* Firewall */ |
| 485 | if ((portInfo->featureCapability & IX_ETH_DB_FIREWALL) != 0) |
| 486 | { |
| 487 | if ((portInfo->featureStatus & IX_ETH_DB_FIREWALL) != 0) |
| 488 | { |
| 489 | printf(" - Firewall is in %s-list mode\n", portInfo->firewallMode == IX_ETH_DB_FIREWALL_BLACK_LIST ? "black" : "white"); |
| 490 | printf(" - Invalid source MAC address filtering is %s\n", portInfo->srcAddressFilterEnabled ? "enabled" : "disabled"); |
| 491 | } |
| 492 | else |
| 493 | { |
| 494 | printf(" - Firewall not enabled\n"); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | /* browse database if asked to display records */ |
| 499 | if (recordFilter != IX_ETH_DB_NO_RECORD_TYPE) |
| 500 | { |
| 501 | printf("\n"); |
| 502 | ixEthDBHeaderShow(recordFilter); |
| 503 | |
| 504 | BUSY_RETRY(ixEthDBInitHashIterator(&dbHashtable, &iterator)); |
| 505 | |
| 506 | while (IS_ITERATOR_VALID(&iterator)) |
| 507 | { |
| 508 | MacDescriptor *descriptor = (MacDescriptor *) iterator.node->data; |
| 509 | |
| 510 | if (descriptor->portID == portID && (descriptor->type & recordFilter) != 0) |
| 511 | { |
| 512 | recordCount++; |
| 513 | |
| 514 | /* display entry */ |
| 515 | ixEthDBRecordShow(descriptor, recordFilter); |
| 516 | } |
| 517 | |
| 518 | /* move to the next record */ |
| 519 | BUSY_RETRY_WITH_RESULT(ixEthDBIncrementHashIterator(&dbHashtable, &iterator), local_result); |
| 520 | |
| 521 | /* debug */ |
| 522 | if (local_result == IX_ETH_DB_BUSY) |
| 523 | { |
| 524 | printf("EthDB (API): Error, database browser failed (no access), giving up\n"); |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | printf("\nFound %d records\n\n", recordCount); |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * @brief displays a record header |
| 534 | * |
| 535 | * @param recordFilter record type filter |
| 536 | * |
| 537 | * This function displays a record header, depending on |
| 538 | * the given record type filter. It is useful when used |
| 539 | * in conjunction with ixEthDBRecordShow which will display |
| 540 | * record fields formatted for the header, provided the same |
| 541 | * record filter is used. |
| 542 | * |
| 543 | * @return IX_ETH_DB_SUCCESS if the operation completed |
| 544 | * successfully or IX_ETH_DB_INVALID_ARG if the recordFilter |
| 545 | * parameter is invalid or not supported |
| 546 | * |
| 547 | * @internal |
| 548 | */ |
| 549 | IX_ETH_DB_PRIVATE |
| 550 | IxEthDBStatus ixEthDBHeaderShow(IxEthDBRecordType recordFilter) |
| 551 | { |
| 552 | if (recordFilter == IX_ETH_DB_FILTERING_VLAN_RECORD |
| 553 | || recordFilter == (IX_ETH_DB_FILTERING_RECORD | IX_ETH_DB_FILTERING_VLAN_RECORD)) |
| 554 | { |
| 555 | /* display VLAN record header */ |
| 556 | printf(" MAC address | Age | Type | VLAN ID | CFI | QoS class \n"); |
| 557 | printf("___________________________________________________________________\n"); |
| 558 | } |
| 559 | else if (recordFilter == IX_ETH_DB_FILTERING_RECORD) |
| 560 | { |
| 561 | /* display filtering record header */ |
| 562 | printf(" MAC address | Age | Type \n"); |
| 563 | printf("_______________________________________\n"); |
| 564 | } |
| 565 | else if (recordFilter == IX_ETH_DB_WIFI_RECORD) |
| 566 | { |
| 567 | /* display WiFi record header */ |
| 568 | printf(" MAC address | GW MAC address \n"); |
| 569 | printf("_______________________________________\n"); |
| 570 | } |
| 571 | else if (recordFilter == IX_ETH_DB_FIREWALL_RECORD) |
| 572 | { |
| 573 | /* display Firewall record header */ |
| 574 | printf(" MAC address \n"); |
| 575 | printf("__________________\n"); |
| 576 | } |
| 577 | else if (recordFilter == IX_ETH_DB_ALL_RECORD_TYPES) |
| 578 | { |
| 579 | /* display composite record header */ |
| 580 | printf(" MAC address | Record | Age| Type | VLAN |CFI| QoS | GW MAC address \n"); |
| 581 | printf("_______________________________________________________________________________\n"); |
| 582 | } |
| 583 | else |
| 584 | { |
| 585 | return IX_ETH_DB_INVALID_ARG; |
| 586 | } |
| 587 | |
| 588 | return IX_ETH_DB_SUCCESS; |
| 589 | } |
| 590 | |
| 591 | /** |
| 592 | * @brief displays database information (records and port information) |
| 593 | * |
| 594 | * @param portID ID of the port to display (or IX_ETH_DB_ALL_PORTS for all the ports) |
| 595 | * @param recordFilter record filter (use IX_ETH_DB_NO_RECORD_TYPE to display only |
| 596 | * port information) |
| 597 | * |
| 598 | * Note that this function is documented in the main component header |
| 599 | * file, IxEthDB.h. |
| 600 | * |
| 601 | * @return IX_ETH_DB_SUCCESS if the operation completed successfully or |
| 602 | * an appropriate error code otherwise |
| 603 | * |
| 604 | */ |
| 605 | IX_ETH_DB_PUBLIC |
| 606 | IxEthDBStatus ixEthDBFilteringDatabaseShowRecords(IxEthDBPortId portID, IxEthDBRecordType recordFilter) |
| 607 | { |
| 608 | IxEthDBPortId currentPort; |
| 609 | BOOL showAllPorts = (portID == IX_ETH_DB_ALL_PORTS); |
| 610 | |
| 611 | IX_ETH_DB_CHECK_PORT_ALL(portID); |
| 612 | |
| 613 | printf("\nEthernet learning/filtering database: listing %d port(s)\n\n", showAllPorts ? (UINT32) IX_ETH_DB_NUMBER_OF_PORTS : 1); |
| 614 | |
| 615 | currentPort = showAllPorts ? 0 : portID; |
| 616 | |
| 617 | while (currentPort != IX_ETH_DB_NUMBER_OF_PORTS) |
| 618 | { |
| 619 | /* display port info */ |
| 620 | ixEthDBPortInfoShow(currentPort, recordFilter); |
| 621 | |
| 622 | /* next port */ |
| 623 | currentPort = showAllPorts ? currentPort + 1 : IX_ETH_DB_NUMBER_OF_PORTS; |
| 624 | } |
| 625 | |
| 626 | return IX_ETH_DB_SUCCESS; |
| 627 | } |
| 628 | |