Leaked source code of windows server 2003
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.

166 lines
7.4 KiB

  1. /*++
  2. Copyright(c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. brdgpkt.h
  5. Abstract:
  6. Ethernet MAC level bridge.
  7. Packet structure definitions
  8. Author:
  9. Mark Aiken
  10. (original bridge by Jameel Hyder)
  11. Environment:
  12. Kernel mode driver
  13. Revision History:
  14. Feb 2000 - Original version
  15. --*/
  16. // ===========================================================================
  17. //
  18. // DECLARATIONS
  19. //
  20. // ===========================================================================
  21. typedef enum
  22. {
  23. BrdgPacketImpossible = 0, // We zero PACKET_INFO structures on free so make zero invalid
  24. BrdgPacketInbound,
  25. BrdgPacketOutbound,
  26. BrdgPacketCreatedInBridge
  27. } PACKET_DIRECTION;
  28. // Special pointer value to indicate local miniport
  29. #define LOCAL_MINIPORT ((PADAPT)-1)
  30. //
  31. // This is the structure of the ProtocolReserved area of a packet queued for inbound processing
  32. //
  33. // This structure MUST be less than PROTOCOL_RESERVED_SIZE_IN_PACKET in size (currently 4*sizeof(PVOID))
  34. // since we store this structure in the ProtocolReserved section of NDIS_PACKET.
  35. //
  36. typedef struct _PACKET_Q_INFO
  37. {
  38. BSINGLE_LIST_ENTRY List; // Used to queue up the packets
  39. union
  40. {
  41. // If bFastTrackReceive == FALSE
  42. PADAPT pTargetAdapt; // The target adapter if one was found in the
  43. // forwarding table. Its refcount is bumped when it
  44. // is looked up, and is decremented after processing
  45. // completes in the queue-draining thread
  46. // If bFastTrackReceive == TRUE
  47. PADAPT pOriginalAdapt; // The adapter on which this packet was originally
  48. // received.
  49. } u;
  50. struct _PACKET_INFO *pInfo; // NULL if this is a NIC's packet descriptor on loan
  51. // != NULL if we got the packet on the copy path and
  52. // had to wrap it with our own descriptor
  53. struct
  54. {
  55. BOOLEAN bIsUnicastToBridge : 1; // This packet is unicast to the bridge and should be
  56. // indicated straight up when dequeued. The packet can
  57. // be a retained NIC packet or a wrapped packet.
  58. BOOLEAN bFastTrackReceive : 1; // Only used when bIsUnicastToBridge == TRUE. Signals that
  59. // this packet should be fast-track indicated. When FALSE,
  60. // the packet is a base packet and can be indicated normally.
  61. BOOLEAN bShouldIndicate : 1; // Whether this packet should be indicated up to the local
  62. // machine (used when bIsUnicastToBridge == FALSE)
  63. BOOLEAN bIsSTAPacket : 1; // This packet was sent to the Spanning Tree Algorithm
  64. // reserved multicast address. It should be indicated
  65. // to user mode and NOT forwarded.
  66. BOOLEAN bRequiresCompatWork : 1; // This packet will require compatibility-mode processing
  67. // when it gets dequeued. This IMPLIES bFastTrackReceive == FALSE,
  68. // since the fact that a packet requires compatibility-mode
  69. // processing should have forced us to copy the packet data
  70. // to our own data buffer. The compatibility-mode code
  71. // expects to receive a flat, EDITABLE packet.
  72. } Flags;
  73. } PACKET_Q_INFO, *PPACKET_Q_INFO;
  74. //
  75. // This is the structure of the info block associated with every
  76. // packet that we allocate.
  77. //
  78. typedef struct _PACKET_INFO
  79. {
  80. //
  81. // List and pOwnerPacket are maintained by the buffering code. They should not be modified
  82. // during processing and transmission.
  83. //
  84. BSINGLE_LIST_ENTRY List; // Used to keep queues of packets
  85. PNDIS_PACKET pOwnerPacket; // Backpointer to the packet associated with this block
  86. //
  87. // All following fields are used by the forwarding code for packet processing.
  88. //
  89. struct
  90. {
  91. UINT bIsBasePacket : 1; // Whether this packet is a base packet
  92. // (Controls which variant of the union below to use)
  93. UINT OriginalDirection:2;// Actually of type PACKET_DIRECTION but force to unsigned
  94. // otherwise Bad Things occur
  95. //
  96. // Whether this packet was originally received from a
  97. // lower-layer NIC, from a higher-layer protocol, or
  98. // created as a wrapper inside the bridge
  99. } Flags;
  100. union
  101. {
  102. //
  103. // This part of the union is valid if the bIsBasePacket field is NOT set
  104. //
  105. struct _PACKET_INFO *pBasePacketInfo; // If != NULL, this packet is using buffers refcounted by
  106. // another packet, whose info block is indicated.
  107. struct
  108. {
  109. //
  110. // This part of the union is valid if the bIsBasePacket field IS set
  111. //
  112. PNDIS_PACKET pOriginalPacket; // If != NULL, pOriginalPacket == a packet from a miniport
  113. // or protocol that needs to be returned when we're done
  114. PADAPT pOwnerAdapter; // The adapter that owns pOriginalPacket. If != NULL, we
  115. // got this packet from an underlying NIC and bumped up
  116. // its refcount when we first received the packet. This
  117. // ensures that a NIC is not unbound while we are still
  118. // holding some of its packets. pOwnerAdapter's refcount
  119. // is decremented after returning the original packet.
  120. LONG RefCount; // Refcount for this packet's buffers (decremented by all
  121. // dependent packets)
  122. NDIS_STATUS CompositeStatus; // Overall status of the packet. For packets sent to multiple
  123. // adapters, this is initialized to NDIS_STATUS_FAILURE
  124. // and any successful send sets it to NDIS_STATUS_SUCCESS.
  125. // Thus, it is SUCCESS if at least one send succeeded.
  126. } BasePacketInfo;
  127. } u;
  128. } PACKET_INFO, *PPACKET_INFO;