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.

167 lines
5.4 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 LOOKAHEAD_SIZE 128 // A reasonable lookahead size.
  21. #define IEEE_802_ADDR_LENGTH 6 // Length of an IEEE 802 address.
  22. //
  23. // Structure of an Ethernet header.
  24. //
  25. typedef struct EtherHeader {
  26. uchar eh_daddr[IEEE_802_ADDR_LENGTH];
  27. uchar eh_saddr[IEEE_802_ADDR_LENGTH];
  28. ushort eh_type;
  29. } EtherHeader;
  30. //
  31. // Structure of a token ring header.
  32. //
  33. typedef struct TRHeader {
  34. uchar tr_ac;
  35. uchar tr_fc;
  36. uchar tr_daddr[IEEE_802_ADDR_LENGTH];
  37. uchar tr_saddr[IEEE_802_ADDR_LENGTH];
  38. } TRHeader;
  39. #define ARP_AC 0x10
  40. #define ARP_FC 0x40
  41. #define TR_RII 0x80
  42. typedef struct RC {
  43. uchar rc_blen; // Broadcast indicator and length.
  44. uchar rc_dlf; // Direction and largest frame.
  45. } RC;
  46. #define RC_DIR 0x80
  47. #define RC_LENMASK 0x1f
  48. #define RC_SRBCST 0xc2 // Single route broadcast RC.
  49. #define RC_BCST_LEN 0x70 // Length for a broadcast.
  50. #define RC_LF_MASK 0x70 // Mask for length bits.
  51. // Structure of source routing information.
  52. typedef struct SRInfo {
  53. RC sri_rc; // Routing control info.
  54. ushort sri_rd[1]; // Routing designators.
  55. } SRInfo;
  56. #define MAX_RD 8
  57. //
  58. // Structure of an FDDI header.
  59. //
  60. typedef struct FDDIHeader {
  61. uchar fh_pri;
  62. uchar fh_daddr[IEEE_802_ADDR_LENGTH];
  63. uchar fh_saddr[IEEE_802_ADDR_LENGTH];
  64. } FDDIHeader;
  65. #define FDDI_PRI 0x57
  66. #define FDDI_MSS 4352
  67. //
  68. // Structure of a SNAP header.
  69. //
  70. typedef struct SNAPHeader {
  71. uchar sh_dsap;
  72. uchar sh_ssap;
  73. uchar sh_ctl;
  74. uchar sh_protid[3];
  75. ushort sh_etype;
  76. } SNAPHeader;
  77. #define SNAP_SAP 170
  78. #define SNAP_UI 3
  79. #define MAX_MEDIA_ETHER sizeof(EtherHeader)
  80. #define MAX_MEDIA_TR (sizeof(TRHeader)+sizeof(RC)+(MAX_RD*sizeof(ushort))+sizeof(SNAPHeader))
  81. #define MAX_MEDIA_FDDI (sizeof(FDDIHeader)+sizeof(SNAPHeader))
  82. #define ETHER_BCAST_MASK 0x01
  83. #define TR_BCAST_MASK 0x80
  84. #define FDDI_BCAST_MASK 0x01
  85. #define ETHER_BCAST_VAL 0x01
  86. #define TR_BCAST_VAL 0x80
  87. #define FDDI_BCAST_VAL 0x01
  88. #define ETHER_BCAST_OFF 0x00
  89. #define TR_BCAST_OFF FIELD_OFFSET(struct TRHeader, tr_daddr)
  90. #define FDDI_BCAST_OFF FIELD_OFFSET(struct FDDIHeader, fh_daddr)
  91. //
  92. // Lan driver specific information we keep on a per-interface basis.
  93. //
  94. typedef struct LanInterface {
  95. void *ai_context; // Upper layer context info.
  96. NDIS_HANDLE ai_handle; // NDIS binding handle.
  97. NDIS_HANDLE ai_unbind; // NDIS unbinding handle.
  98. KSPIN_LOCK ai_lock; // Lock for this structure.
  99. PNDIS_PACKET ai_tdpacket; // Transfer Data packet.
  100. uchar ai_state; // State of the interface.
  101. int ai_resetting; // Is the interface resetting?
  102. uint ai_pfilter; // Packet filter for this I/F.
  103. //
  104. // Used for calling NdisOpenAdapter and NdisCloseAdapter.
  105. //
  106. KEVENT ai_event;
  107. NDIS_STATUS ai_status;
  108. NDIS_MEDIUM ai_media; // Media type.
  109. uchar ai_addr[IEEE_802_ADDR_LENGTH]; // Local HW address.
  110. uchar ai_addrlen; // Length of ai_addr.
  111. uchar ai_bcastmask; // Mask for checking unicast.
  112. uchar ai_bcastval; // Value to check against.
  113. uchar ai_bcastoff; // Offset in frame to check against.
  114. uchar ai_hdrsize; // Size of link-level header.
  115. ushort ai_mtu; // MTU for this interface.
  116. uint ai_speed; // Speed.
  117. uint ai_qlen; // Output queue length.
  118. uint ai_uknprotos; // Unknown protocols received.
  119. uint ai_inoctets; // Input octets.
  120. uint ai_inpcount[2]; // Count of packets received.
  121. uint ai_indiscards; // Input packets discarded.
  122. uint ai_inerrors; // Input errors.
  123. uint ai_outoctets; // Output octets.
  124. uint ai_outpcount[2]; // Count of packets sent.
  125. uint ai_outdiscards; // Output packets discarded.
  126. uint ai_outerrors; // Output errors.
  127. } LanInterface;
  128. //
  129. // NOTE: These two values MUST stay at 0 and 1.
  130. //
  131. #define AI_UCAST_INDEX 0
  132. #define AI_NONUCAST_INDEX 1
  133. // Ether Types
  134. //
  135. // Note that the Ether-Type field from classic Ethernet frames coincides
  136. // in the header with the Length field in IEEE 802.3 frames. This field
  137. // can be used to distinguish between frame types as valid values for the
  138. // 802.3 Length field are from 0x0000 to 0x05dc. All valid Ether Types
  139. // are greater than this. See discussion on p.25 of RFC 1122.
  140. //
  141. #define ETYPE_MIN 0x05dd
  142. #define ETYPE_IPv6 0x86dd
  143. #endif // LAN_INCLUDED