Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
3.6 KiB

  1. /*++
  2. Copyright(c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. brdgtbl.h
  5. Abstract:
  6. Ethernet MAC level bridge.
  7. MAC Table section
  8. PUBLIC header
  9. Author:
  10. Mark Aiken
  11. (original bridge by Jameel Hyder)
  12. Environment:
  13. Kernel mode driver
  14. Revision History:
  15. Feb 2000 - Original version
  16. --*/
  17. // ===========================================================================
  18. //
  19. // GLOBALS
  20. //
  21. // ===========================================================================
  22. // The MAC forwarding table
  23. extern PHASH_TABLE gMACForwardingTable;
  24. // Default age at which entries are removed from table
  25. #define DEFAULT_MAX_TBL_AGE (300 * 1000) // 5 minutes in milliseconds
  26. // ===========================================================================
  27. //
  28. // PRIVATE PROTOTYPES
  29. //
  30. // ===========================================================================
  31. //
  32. // These need to be exposed here to make the inlines below work.
  33. // Pretend they're not here.
  34. //
  35. VOID
  36. BrdgTableRefreshInsertEntry(
  37. IN PHASH_TABLE_ENTRY pEntry,
  38. IN PVOID pData
  39. );
  40. BOOLEAN
  41. BrdgTblEntriesMatch(
  42. IN PHASH_TABLE_ENTRY pEntry,
  43. IN PVOID pAdapt
  44. );
  45. VOID
  46. BrdgTblCopyEntries(
  47. PHASH_TABLE_ENTRY pEntry,
  48. PUCHAR pDest
  49. );
  50. VOID
  51. BrdgTblNoteAddress(
  52. IN PUCHAR pAddr,
  53. IN PADAPT pAdapt
  54. );
  55. // ===========================================================================
  56. //
  57. // INLINES
  58. //
  59. // ===========================================================================
  60. //
  61. // Changes the forwarding table timeout value.
  62. //
  63. __forceinline
  64. VOID
  65. BrdgTblSetTimeout(
  66. IN ULONG Timeout
  67. )
  68. {
  69. DBGPRINT(FWD, ("Adopting a shorter table timeout value of %ims\n", Timeout));
  70. SAFEASSERT( gMACForwardingTable != NULL );
  71. BrdgHashChangeTableTimeout( gMACForwardingTable, Timeout );
  72. }
  73. //
  74. // Sets the table timeout value back to its default
  75. //
  76. __forceinline
  77. VOID
  78. BrdgTblRevertTimeout()
  79. {
  80. DBGPRINT(FWD, ("Reverting to default timeout value of %ims\n", DEFAULT_MAX_TBL_AGE));
  81. SAFEASSERT( gMACForwardingTable != NULL );
  82. BrdgHashChangeTableTimeout( gMACForwardingTable, DEFAULT_MAX_TBL_AGE );
  83. }
  84. //
  85. // Removes all entries that reference the given adapter
  86. //
  87. __forceinline
  88. VOID
  89. BrdgTblScrubAdapter(
  90. IN PADAPT pAdapt
  91. )
  92. {
  93. DBGPRINT(FWD, ("Scrubbing adapter %p from the MAC table...\n", pAdapt));
  94. BrdgHashRemoveMatching( gMACForwardingTable, BrdgTblEntriesMatch, pAdapt );
  95. }
  96. //
  97. // Copies all the MAC addresses that appear in the forwarding table that
  98. // are associated with the given adapter to the given data buffer.
  99. //
  100. // The return value is the room necessary to hold all the data. If the
  101. // return value is <= BufferLength, the buffer was sufficiently large
  102. // to hold the data and it was all copied.
  103. //
  104. __forceinline
  105. ULONG
  106. BrdgTblReadTable(
  107. IN PADAPT pAdapt,
  108. IN PUCHAR pBuffer,
  109. IN ULONG BufferLength
  110. )
  111. {
  112. return BrdgHashCopyMatching( gMACForwardingTable, BrdgTblEntriesMatch, BrdgTblCopyEntries,
  113. ETH_LENGTH_OF_ADDRESS, pAdapt, pBuffer, BufferLength );
  114. }
  115. // ===========================================================================
  116. //
  117. // PROTOTYPES
  118. //
  119. // ===========================================================================
  120. NTSTATUS
  121. BrdgTblDriverInit();
  122. PADAPT
  123. BrdgTblFindTargetAdapter(
  124. IN PUCHAR pAddr
  125. );
  126. VOID
  127. BrdgTblCleanup();
  128. VOID
  129. BrdgTblScrubAllAdapters();