IxEthDBReports.c 22 KB

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