summaryrefslogtreecommitdiff
path: root/drivers/net/npe/IxEthDBReports.c
blob: 912e60861341fa3db1869af7b9456341d6d9e676 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
/**
 * @file IxEthDBAPI.c
 *
 * @brief Implementation of the public API
 * 
 * @par
 * IXP400 SW Release version 2.0
 * 
 * -- Copyright Notice --
 * 
 * @par
 * Copyright 2001-2005, Intel Corporation.
 * All rights reserved.
 * 
 * @par
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the Intel Corporation nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 * 
 * @par
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * 
 * @par
 * -- End of Copyright Notice --
 */

#include "IxEthDB_p.h"

extern HashTable dbHashtable;
IX_ETH_DB_PRIVATE void ixEthDBPortInfoShow(IxEthDBPortId portID, IxEthDBRecordType recordFilter);
IX_ETH_DB_PRIVATE IxEthDBStatus ixEthDBHeaderShow(IxEthDBRecordType recordFilter);
IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBDependencyPortMapShow(IxEthDBPortId portID, IxEthDBPortMap map);

/**
 * @brief displays a port dependency map
 *
 * @param portID ID of the port
 * @param map port map to display
 *
 * @return IX_ETH_DB_SUCCESS if the operation completed
 * successfully
 */ 
IX_ETH_DB_PUBLIC
IxEthDBStatus ixEthDBDependencyPortMapShow(IxEthDBPortId portID, IxEthDBPortMap map)
{
    UINT32 portIndex;
    BOOL mapSelf = true, mapNone = true, firstPort = true;
    
    /* dependency port maps */
    printf("Dependency port map: ");
    
    /* browse the port map */
    for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++)
    {
        if (IS_PORT_INCLUDED(portIndex, map))
        {
            mapNone   = false;
            
            if (portIndex != portID)
            {
                mapSelf = false;
            }
            
            printf("%s%d", firstPort ? "{" : ", ", portIndex);
            
            firstPort = false;
        }
    }
    
    if (mapNone)
    {
        mapSelf = false;
    }
    
    printf("%s (%s)\n", firstPort ? "" : "}", mapSelf ? "self" : mapNone ? "none" : "group");
    
    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;
}

/**
 * @brief displays all the filtering records belonging to all the ports
 *
 * 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(IX_ETH_DB_ALL_PORTS, IX_ETH_DB_FILTERING_RECORD)
 */
IX_ETH_DB_PUBLIC
void ixEthDBFilteringDatabaseShowAll()
{
    IxEthDBPortId portIndex;

    printf("\nEthernet learning/filtering database: listing %d ports\n\n", (UINT32) IX_ETH_DB_NUMBER_OF_PORTS);

    for (portIndex = 0 ; portIndex < IX_ETH_DB_NUMBER_OF_PORTS ; portIndex++)
    {
        ixEthDBFilteringDatabaseShow(portIndex);

        if (portIndex < IX_ETH_DB_NUMBER_OF_PORTS - 1)
        {
            printf("\n");
        }
    }
}

/**
 * @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)
         {
            printf("%02X:%02X:%02X:%02X:%02X:%02X | %3d | %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");
         }
    }
    else if (recordFilter == IX_ETH_DB_FILTERING_RECORD)
    {
        /* display filtering record header - leave this commented code in place, its purpose is to align the print format with the header
        printf("    MAC address    |   Age  |   Type   \n");
        printf("_______________________________________\n");  */

        if (descriptor->type == IX_ETH_DB_FILTERING_RECORD)
        {
         printf("%02X:%02X:%02X:%02X:%02X:%02X | %3d | %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");
        }
    }
    else if (recordFilter == IX_ETH_DB_WIFI_RECORD)
    {
        /* display WiFi record header - leave this commented code in place, its purpose is to align the print format with the header 
        printf("    MAC address    |   GW MAC address  \n");
        printf("_______________________________________\n"); */

        if (descriptor->type == IX_ETH_DB_WIFI_RECORD)
        {
            if (descriptor->recordData.wifiData.type == IX_ETH_DB_WIFI_AP_TO_AP)
            {
                /* gateway address present */
                printf("%02X:%02X:%02X:%02X:%02X:%02X | %02X:%02X:%02X:%02X:%02X:%02X \n",
                    descriptor->macAddress[0],
                    descriptor->macAddress[1],
                    descriptor->macAddress[2],
                    descriptor->macAddress[3],
                    descriptor->macAddress[4],
                    descriptor->macAddress[5],
                    descriptor->recordData.wifiData.gwMacAddress[0],
                    descriptor->recordData.wifiData.gwMacAddress[1],
                    descriptor->recordData.wifiData.gwMacAddress[2],
                    descriptor->recordData.wifiData.gwMacAddress[3],
                    descriptor->recordData.wifiData.gwMacAddress[4],
                    descriptor->recordData.wifiData.gwMacAddress[5]);
            }
            else
            {
                /* no gateway */
                printf("%02X:%02X:%02X:%02X:%02X:%02X | ----no gateway----- \n",
                    descriptor->macAddress[0],
                    descriptor->macAddress[1],
                    descriptor->macAddress[2],
                    descriptor->macAddress[3],
                    descriptor->macAddress[4],
                    descriptor->macAddress[5]);
            }
        }
    }
    else if (recordFilter == IX_ETH_DB_FIREWALL_RECORD)
    {
        /* display Firewall record header - leave this commented code in place, its purpose is to align the print format with the header 
        printf("    MAC address   \n");
        printf("__________________\n"); */

        if (descriptor->type == IX_ETH_DB_FIREWALL_RECORD)
        {
            printf("%02X:%02X:%02X:%02X:%02X:%02X \n",
                descriptor->macAddress[0],
                descriptor->macAddress[1],
                descriptor->macAddress[2],
                descriptor->macAddress[3],
                descriptor->macAddress[4],
                descriptor->macAddress[5]);
        }
    }
    else if (recordFilter == IX_ETH_DB_ALL_RECORD_TYPES)
    {
        /* display composite record header - leave this commented code in place, its purpose is to align the print format with the header 
        printf("    MAC address   | Record | Age|  Type   | VLAN |CFI| QoS |  GW MAC address   \n");
        printf("_______________________________________________________________________________\n"); */

        if (descriptor->type == IX_ETH_DB_FILTERING_VLAN_RECORD)
        {
            printf("%02X:%02X:%02X:%02X:%02X:%02X |  VLAN  | %2d | %s | %4d | %1d |  %1d  | -----------------\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)
         {
            printf("%02X:%02X:%02X:%02X:%02X:%02X | Filter | %2d | %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");
         }
        else if (descriptor->type == IX_ETH_DB_WIFI_RECORD)
        {
            if (descriptor->recordData.wifiData.type == IX_ETH_DB_WIFI_AP_TO_AP)
            {
                /* gateway address present */
                printf("%02X:%02X:%02X:%02X:%02X:%02X |  WiFi  | -- | AP=>AP  | ---- | - | --- | %02X:%02X:%02X:%02X:%02X:%02X\n",
                    descriptor->macAddress[0],
                    descriptor->macAddress[1],
                    descriptor->macAddress[2],
                    descriptor->macAddress[3],
                    descriptor->macAddress[4],
                    descriptor->macAddress[5],
                    descriptor->recordData.wifiData.gwMacAddress[0],
                    descriptor->recordData.wifiData.gwMacAddress[1],
                    descriptor->recordData.wifiData.gwMacAddress[2],
                    descriptor->recordData.wifiData.gwMacAddress[3],
                    descriptor->recordData.wifiData.gwMacAddress[4],
                    descriptor->recordData.wifiData.gwMacAddress[5]);
            }
            else
            {
                /* no gateway */
                printf("%02X:%02X:%02X:%02X:%02X:%02X |  WiFi  | -- | AP=>ST  | ---- | - | --- | -- no gateway -- \n",
                    descriptor->macAddress[0],
                    descriptor->macAddress[1],
                    descriptor->macAddress[2],
                    descriptor->macAddress[3],
                    descriptor->macAddress[4],
                    descriptor->macAddress[5]);
            }
        }
        else if (descriptor->type == IX_ETH_DB_FIREWALL_RECORD)
        {
            printf("%02X:%02X:%02X:%02X:%02X:%02X |   FW   | -- | ------- | ---- | - | --- | -----------------\n",
                descriptor->macAddress[0],
                descriptor->macAddress[1],
                descriptor->macAddress[2],
                descriptor->macAddress[3],
                descriptor->macAddress[4],
                descriptor->macAddress[5]);
        }
    }
    else
    {
        printf("invalid record filter\n");
    }
}

/**
 * @brief displays the status, records and configuration information of a port
 *
 * @param portID ID of the port
 * @param recordFilter record filter to display
 *
 * @internal
 */
IX_ETH_DB_PRIVATE
void ixEthDBPortInfoShow(IxEthDBPortId portID, IxEthDBRecordType recordFilter)
{
    PortInfo *portInfo = &ixEthDBPortInfo[portID];
    UINT32 recordCount = 0;
    HashIterator iterator;
    IxEthDBStatus local_result;

    /* display port status */
    printf("== Port ID %d ==\n", portID);

    /* display capabilities */
    printf("- Capabilities: ");

    if ((portInfo->featureCapability & IX_ETH_DB_LEARNING) != 0)
    {
        printf("Learning (%s) ", ((portInfo->featureStatus & IX_ETH_DB_LEARNING) != 0) ? "on" : "off");
    }

    if ((portInfo->featureCapability & IX_ETH_DB_VLAN_QOS) != 0)
    {
        printf("VLAN/QoS (%s) ", ((portInfo->featureStatus & IX_ETH_DB_VLAN_QOS) != 0) ? "on" : "off");
    }

    if ((portInfo->featureCapability & IX_ETH_DB_FIREWALL) != 0)
    {
        printf("Firewall (%s) ", ((portInfo->featureStatus & IX_ETH_DB_FIREWALL) != 0) ? "on" : "off");
    }

    if ((portInfo->featureCapability & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0)
    {
        printf("WiFi (%s) ", ((portInfo->featureStatus & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0) ? "on" : "off");
    }

    if ((portInfo->featureCapability & IX_ETH_DB_SPANNING_TREE_PROTOCOL) != 0)
    {
        printf("STP (%s) ", ((portInfo->featureStatus & IX_ETH_DB_SPANNING_TREE_PROTOCOL) != 0) ? "on" : "off");
    }

    printf("\n");

    /* dependency map */
    ixEthDBDependencyPortMapShow(portID, portInfo->dependencyPortMap);

    /* NPE dynamic updates */
    if (ixEthDBPortDefinitions[portID].type == IX_ETH_NPE) 
    {
        printf(" - NPE dynamic update is %s\n", portInfo->updateMethod.updateEnabled ? "enabled" : "disabled");
    }
    else
    {
        printf(" - dynamic update disabled (not an NPE)\n");
    }

    if ((portInfo->featureCapability & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0)
    {
        if ((portInfo->featureStatus & IX_ETH_DB_WIFI_HEADER_CONVERSION) != 0)
        {
            /* WiFi header conversion */
            if ((portInfo->frameControlDurationID 
                + portInfo->bbsid[0] 
                + portInfo->bbsid[1] 
                + portInfo->bbsid[2] 
                + portInfo->bbsid[3] 
                + portInfo->bbsid[4] 
                + portInfo->bbsid[5]) == 0)
            {
                printf(" - WiFi header conversion not configured\n");
            }
            else
            {  
                printf(" - WiFi header conversion: BBSID [%02X:%02X:%02X:%02X:%02X:%02X], Frame Control 0x%X, Duration/ID 0x%X\n", 
                    portInfo->bbsid[0],
                    portInfo->bbsid[1],
                    portInfo->bbsid[2],
                    portInfo->bbsid[3],
                    portInfo->bbsid[4],
                    portInfo->bbsid[5],
                    portInfo->frameControlDurationID >> 16,
                    portInfo->frameControlDurationID & 0xFFFF);
            }
        }
        else
        {
            printf(" - WiFi header conversion not enabled\n");
        }
    }

    /* Firewall */
    if ((portInfo->featureCapability & IX_ETH_DB_FIREWALL) != 0)
    {
        if ((portInfo->featureStatus & IX_ETH_DB_FIREWALL) != 0)
        {
            printf(" - Firewall is in %s-list mode\n", portInfo->firewallMode == IX_ETH_DB_FIREWALL_BLACK_LIST ? "black" : "white");
            printf(" - Invalid source MAC address filtering is %s\n", portInfo->srcAddressFilterEnabled ? "enabled" : "disabled");
        }
        else
        {
            printf(" - Firewall not enabled\n");
        }
    }
  
    /* browse database if asked to display records */
    if (recordFilter != IX_ETH_DB_NO_RECORD_TYPE)
    {
        printf("\n");
        ixEthDBHeaderShow(recordFilter);

        BUSY_RETRY(ixEthDBInitHashIterator(&dbHashtable, &iterator));

        while (IS_ITERATOR_VALID(&iterator))
        {
            MacDescriptor *descriptor = (MacDescriptor *) iterator.node->data;

            if (descriptor->portID == portID && (descriptor->type & recordFilter) != 0)
            {
                recordCount++;

                /* display entry */
                ixEthDBRecordShow(descriptor, recordFilter);
            }

            /* move to the next record */
            BUSY_RETRY_WITH_RESULT(ixEthDBIncrementHashIterator(&dbHashtable, &iterator), local_result);

            /* debug */
            if (local_result == IX_ETH_DB_BUSY)
            {
                printf("EthDB (API): Error, database browser failed (no access), giving up\n");
            }
        }
        
        printf("\nFound %d records\n\n", recordCount);
    }
}

/**
 * @brief displays a record header
 *
 * @param recordFilter record type filter
 *
 * This function displays a record header, depending on
 * the given record type filter. It is useful when used
 * in conjunction with ixEthDBRecordShow which will display
 * record fields formatted for the header, provided the same
 * record filter is used.
 *
 * @return IX_ETH_DB_SUCCESS if the operation completed
 * successfully or IX_ETH_DB_INVALID_ARG if the recordFilter
 * parameter is invalid or not supported
 *
 * @internal
 */
IX_ETH_DB_PRIVATE
IxEthDBStatus ixEthDBHeaderShow(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 */
    printf("    MAC address    |   Age  |   Type   | VLAN ID | CFI | QoS class \n");
    printf("___________________________________________________________________\n");
  }
  else if (recordFilter == IX_ETH_DB_FILTERING_RECORD)
  {
    /* display filtering record header */
    printf("    MAC address    |   Age  |   Type   \n");
    printf("_______________________________________\n");
  }
  else if (recordFilter == IX_ETH_DB_WIFI_RECORD)
  {
    /* display WiFi record header */
    printf("    MAC address    |   GW MAC address  \n");
    printf("_______________________________________\n");
  }
  else if (recordFilter == IX_ETH_DB_FIREWALL_RECORD)
  {
    /* display Firewall record header */
    printf("    MAC address   \n");
    printf("__________________\n");
  }
  else if (recordFilter == IX_ETH_DB_ALL_RECORD_TYPES)
  {
    /* display composite record header */
    printf("    MAC address   | Record | Age|  Type   | VLAN |CFI| QoS |  GW MAC address   \n");
    printf("_______________________________________________________________________________\n");
  }
  else
  {
    return IX_ETH_DB_INVALID_ARG;
  }
  
  return IX_ETH_DB_SUCCESS;
}

/**
 * @brief displays database information (records and port information)
 *
 * @param portID ID of the port to display (or IX_ETH_DB_ALL_PORTS for all the ports)
 * @param recordFilter record filter (use IX_ETH_DB_NO_RECORD_TYPE to display only
 * port information)
 * 
 * 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 code otherwise
 * 
 */
IX_ETH_DB_PUBLIC
IxEthDBStatus ixEthDBFilteringDatabaseShowRecords(IxEthDBPortId portID, IxEthDBRecordType recordFilter)
{
  IxEthDBPortId currentPort;
  BOOL showAllPorts = (portID == IX_ETH_DB_ALL_PORTS);
  
  IX_ETH_DB_CHECK_PORT_ALL(portID);

  printf("\nEthernet learning/filtering database: listing %d port(s)\n\n", showAllPorts ? (UINT32) IX_ETH_DB_NUMBER_OF_PORTS : 1);
  
  currentPort = showAllPorts ? 0 : portID;
  
  while (currentPort != IX_ETH_DB_NUMBER_OF_PORTS)
  {
    /* display port info */
    ixEthDBPortInfoShow(currentPort, recordFilter);
    
    /* next port */
    currentPort = showAllPorts ? currentPort + 1 : IX_ETH_DB_NUMBER_OF_PORTS;
  }
  
  return IX_ETH_DB_SUCCESS;
}