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