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.

172 lines
5.9 KiB

  1. // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil -*- (for GNU Emacs)
  2. //
  3. // Copyright (c) 1985-2000 Microsoft Corporation
  4. //
  5. // This file is part of the Microsoft Research IPv6 Network Protocol Stack.
  6. // You should have received a copy of the Microsoft End-User License Agreement
  7. // for this software along with this release; see the file "license.txt".
  8. // If not, please see http://www.research.microsoft.com/msripv6/license.htm,
  9. // or write to Microsoft Research, One Microsoft Way, Redmond, WA 98052-6399.
  10. //
  11. // Abstract:
  12. //
  13. // LAN driver definitions.
  14. //
  15. #ifndef LAN_INCLUDED
  16. #define LAN_INCLUDED 1
  17. #define INTERFACE_UP 0 // Interface is up.
  18. #define INTERFACE_INIT 1 // Interface is initializing.
  19. #define INTERFACE_DOWN 2 // Interface is down.
  20. #define MEDIA_CHECK_IDLE 0 // Not checking media connectivity.
  21. #define MEDIA_CHECK_QUERY 1 // Media check in progress.
  22. #define MEDIA_CHECK_CONFLICT 2 // Race occurred, must requery.
  23. #define LOOKAHEAD_SIZE 128 // A reasonable lookahead size.
  24. #define IEEE_802_ADDR_LENGTH 6 // Length of an IEEE 802 address.
  25. //
  26. // Structure of an Ethernet header.
  27. //
  28. typedef struct EtherHeader {
  29. uchar eh_daddr[IEEE_802_ADDR_LENGTH];
  30. uchar eh_saddr[IEEE_802_ADDR_LENGTH];
  31. ushort eh_type;
  32. } EtherHeader;
  33. //
  34. // Structure of a token ring header.
  35. //
  36. typedef struct TRHeader {
  37. uchar tr_ac;
  38. uchar tr_fc;
  39. uchar tr_daddr[IEEE_802_ADDR_LENGTH];
  40. uchar tr_saddr[IEEE_802_ADDR_LENGTH];
  41. } TRHeader;
  42. #define ARP_AC 0x10
  43. #define ARP_FC 0x40
  44. #define TR_RII 0x80
  45. typedef struct RC {
  46. uchar rc_blen; // Broadcast indicator and length.
  47. uchar rc_dlf; // Direction and largest frame.
  48. } RC;
  49. #define RC_DIR 0x80
  50. #define RC_LENMASK 0x1f
  51. #define RC_SRBCST 0xc2 // Single route broadcast RC.
  52. #define RC_BCST_LEN 0x70 // Length for a broadcast.
  53. #define RC_LF_MASK 0x70 // Mask for length bits.
  54. // Structure of source routing information.
  55. typedef struct SRInfo {
  56. RC sri_rc; // Routing control info.
  57. ushort sri_rd[1]; // Routing designators.
  58. } SRInfo;
  59. #define MAX_RD 8
  60. //
  61. // Structure of an FDDI header.
  62. //
  63. typedef struct FDDIHeader {
  64. uchar fh_pri;
  65. uchar fh_daddr[IEEE_802_ADDR_LENGTH];
  66. uchar fh_saddr[IEEE_802_ADDR_LENGTH];
  67. } FDDIHeader;
  68. #define FDDI_PRI 0x57
  69. #define FDDI_MSS 4352
  70. //
  71. // Structure of a SNAP header.
  72. //
  73. typedef struct SNAPHeader {
  74. uchar sh_dsap;
  75. uchar sh_ssap;
  76. uchar sh_ctl;
  77. uchar sh_protid[3];
  78. ushort sh_etype;
  79. } SNAPHeader;
  80. #define SNAP_SAP 170
  81. #define SNAP_UI 3
  82. #define MAX_MEDIA_ETHER sizeof(EtherHeader)
  83. #define MAX_MEDIA_TR (sizeof(TRHeader)+sizeof(RC)+(MAX_RD*sizeof(ushort))+sizeof(SNAPHeader))
  84. #define MAX_MEDIA_FDDI (sizeof(FDDIHeader)+sizeof(SNAPHeader))
  85. #define ETHER_BCAST_MASK 0x01
  86. #define TR_BCAST_MASK 0x80
  87. #define FDDI_BCAST_MASK 0x01
  88. #define ETHER_BCAST_VAL 0x01
  89. #define TR_BCAST_VAL 0x80
  90. #define FDDI_BCAST_VAL 0x01
  91. #define ETHER_BCAST_OFF 0x00
  92. #define TR_BCAST_OFF FIELD_OFFSET(struct TRHeader, tr_daddr)
  93. #define FDDI_BCAST_OFF FIELD_OFFSET(struct FDDIHeader, fh_daddr)
  94. //
  95. // Lan driver specific information we keep on a per-interface basis.
  96. //
  97. typedef struct LanInterface {
  98. void *ai_context; // Upper layer context info.
  99. NDIS_HANDLE ai_handle; // NDIS binding handle.
  100. NDIS_HANDLE ai_unbind; // NDIS unbinding handle.
  101. KSPIN_LOCK ai_lock; // Lock for this structure.
  102. PNDIS_PACKET ai_tdpacket; // Transfer Data packet.
  103. uchar ai_state; // State of the interface.
  104. uchar ai_media_check; // Used to query media connectivity.
  105. int ai_resetting; // Is the interface resetting?
  106. uint ai_pfilter; // Packet filter for this I/F.
  107. //
  108. // Used for calling NdisOpenAdapter and NdisCloseAdapter.
  109. //
  110. KEVENT ai_event;
  111. NDIS_STATUS ai_status;
  112. NDIS_MEDIUM ai_media; // Media type.
  113. uchar ai_addr[IEEE_802_ADDR_LENGTH]; // Local HW address.
  114. uchar ai_addrlen; // Length of ai_addr.
  115. uchar ai_bcastmask; // Mask for checking unicast.
  116. uchar ai_bcastval; // Value to check against.
  117. uchar ai_bcastoff; // Offset in frame to check against.
  118. uchar ai_hdrsize; // Size of link-level header.
  119. ushort ai_mtu; // MTU for this interface.
  120. uint ai_speed; // Speed.
  121. uint ai_qlen; // Output queue length.
  122. uint ai_uknprotos; // Unknown protocols received.
  123. uint ai_inoctets; // Input octets.
  124. uint ai_inpcount[2]; // Count of packets received.
  125. uint ai_indiscards; // Input packets discarded.
  126. uint ai_inerrors; // Input errors.
  127. uint ai_outoctets; // Output octets.
  128. uint ai_outpcount[2]; // Count of packets sent.
  129. uint ai_outdiscards; // Output packets discarded.
  130. uint ai_outerrors; // Output errors.
  131. } LanInterface;
  132. //
  133. // NOTE: These two values MUST stay at 0 and 1.
  134. //
  135. #define AI_UCAST_INDEX 0
  136. #define AI_NONUCAST_INDEX 1
  137. // Ether Types
  138. //
  139. // Note that the Ether-Type field from classic Ethernet frames coincides
  140. // in the header with the Length field in IEEE 802.3 frames. This field
  141. // can be used to distinguish between frame types as valid values for the
  142. // 802.3 Length field are from 0x0000 to 0x05dc. All valid Ether Types
  143. // are greater than this. See discussion on p.25 of RFC 1122.
  144. //
  145. #define ETYPE_MIN 0x05dd
  146. #define ETYPE_IPv6 0x86dd
  147. #endif // LAN_INCLUDED