constants.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * TAP-Windows -- A kernel driver to provide virtual tap
  3. * device functionality on Windows.
  4. *
  5. * This code was inspired by the CIPE-Win32 driver by Damion K. Wilson.
  6. *
  7. * This source code is Copyright (C) 2002-2014 OpenVPN Technologies, Inc.,
  8. * and is released under the GPL version 2 (see below).
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program (see the file COPYING included with this
  21. * distribution); if not, write to the Free Software Foundation, Inc.,
  22. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. //====================================================================
  25. // Product and Version public settings
  26. //====================================================================
  27. #define PRODUCT_STRING PRODUCT_TAP_DEVICE_DESCRIPTION
  28. //
  29. // Update the driver version number every time you release a new driver
  30. // The high word is the major version. The low word is the minor version.
  31. // Also make sure that VER_FILEVERSION specified in the .RC file also
  32. // matches with the driver version because NDISTESTER checks for that.
  33. //
  34. #ifndef TAP_DRIVER_MAJOR_VERSION
  35. #define TAP_DRIVER_MAJOR_VERSION 0x04
  36. #define TAP_DRIVER_MINOR_VERSION 0x02
  37. #endif
  38. #define TAP_DRIVER_VENDOR_VERSION ((TAP_DRIVER_MAJOR_VERSION << 16) | TAP_DRIVER_MINOR_VERSION)
  39. //
  40. // Define the NDIS miniport interface version that this driver targets.
  41. //
  42. #if defined(NDIS60_MINIPORT)
  43. # define TAP_NDIS_MAJOR_VERSION 6
  44. # define TAP_NDIS_MINOR_VERSION 0
  45. #elif defined(NDIS61_MINIPORT)
  46. # define TAP_NDIS_MAJOR_VERSION 6
  47. # define TAP_NDIS_MINOR_VERSION 1
  48. #elif defined(NDIS620_MINIPORT)
  49. # define TAP_NDIS_MAJOR_VERSION 6
  50. # define TAP_NDIS_MINOR_VERSION 20
  51. #elif defined(NDIS630_MINIPORT)
  52. # define TAP_NDIS_MAJOR_VERSION 6
  53. # define TAP_NDIS_MINOR_VERSION 30
  54. #else
  55. #define TAP_NDIS_MAJOR_VERSION 5
  56. #define TAP_NDIS_MINOR_VERSION 0
  57. #endif
  58. //===========================================================
  59. // Driver constants
  60. //===========================================================
  61. #define ETHERNET_HEADER_SIZE (sizeof (ETH_HEADER))
  62. //#define ETHERNET_MTU 1500
  63. #define ETHERNET_MTU 2800
  64. #define ETHERNET_PACKET_SIZE (ETHERNET_MTU + ETHERNET_HEADER_SIZE)
  65. #define DEFAULT_PACKET_LOOKAHEAD (ETHERNET_PACKET_SIZE)
  66. #define VLAN_TAG_SIZE 4
  67. //===========================================================
  68. // Medium properties
  69. //===========================================================
  70. #define TAP_FRAME_HEADER_SIZE ETHERNET_HEADER_SIZE
  71. #define TAP_FRAME_MAX_DATA_SIZE ETHERNET_MTU
  72. #define TAP_MAX_FRAME_SIZE (TAP_FRAME_HEADER_SIZE + TAP_FRAME_MAX_DATA_SIZE)
  73. #define TAP_MIN_FRAME_SIZE 60
  74. #define TAP_MEDIUM_TYPE NdisMedium802_3
  75. //===========================================================
  76. // Physical adapter properties
  77. //===========================================================
  78. // The bus that connects the adapter to the PC.
  79. // (Example: PCI adapters should use NdisInterfacePci).
  80. #define TAP_INTERFACE_TYPE NdisInterfaceInternal
  81. #define TAP_VENDOR_DESC PRODUCT_TAP_WIN_DEVICE_DESCRIPTION
  82. // Highest byte is the NIC byte plus three vendor bytes. This is normally
  83. // obtained from the NIC.
  84. #define TAP_VENDOR_ID 0x00FFFFFF
  85. // If you have physical hardware on 802.3, use NdisPhysicalMedium802_3.
  86. #define TAP_PHYSICAL_MEDIUM NdisPhysicalMediumUnspecified
  87. // Claim to be 100mbps duplex
  88. #define MEGABITS_PER_SECOND 1000000ULL
  89. #define TAP_XMIT_SPEED (100ULL*MEGABITS_PER_SECOND)
  90. #define TAP_RECV_SPEED (100ULL*MEGABITS_PER_SECOND)
  91. // Max number of multicast addresses supported in hardware
  92. #define TAP_MAX_MCAST_LIST 128
  93. #define TAP_MAX_LOOKAHEAD TAP_FRAME_MAX_DATA_SIZE
  94. #define TAP_BUFFER_SIZE TAP_MAX_FRAME_SIZE
  95. // Set this value to TRUE if there is a physical adapter.
  96. #define TAP_HAS_PHYSICAL_CONNECTOR FALSE
  97. #define TAP_ACCESS_TYPE NET_IF_ACCESS_BROADCAST
  98. #define TAP_DIRECTION_TYPE NET_IF_DIRECTION_SENDRECEIVE
  99. #define TAP_CONNECTION_TYPE NET_IF_CONNECTION_DEDICATED
  100. // This value must match the *IfType in the driver .inf file
  101. #define TAP_IFTYPE IF_TYPE_ETHERNET_CSMACD
  102. //
  103. // This is a virtual device, so it can tolerate surprise removal and
  104. // suspend. Ensure the correct flags are set for your hardware.
  105. //
  106. #define TAP_ADAPTER_ATTRIBUTES_FLAGS (\
  107. NDIS_MINIPORT_ATTRIBUTES_SURPRISE_REMOVE_OK | NDIS_MINIPORT_ATTRIBUTES_NDIS_WDM)
  108. #define TAP_SUPPORTED_FILTERS ( \
  109. NDIS_PACKET_TYPE_DIRECTED | \
  110. NDIS_PACKET_TYPE_MULTICAST | \
  111. NDIS_PACKET_TYPE_BROADCAST | \
  112. NDIS_PACKET_TYPE_ALL_LOCAL | \
  113. NDIS_PACKET_TYPE_PROMISCUOUS | \
  114. NDIS_PACKET_TYPE_ALL_MULTICAST)
  115. //#define TAP_MAX_MCAST_LIST 128 // Max length of multicast address list
  116. //
  117. // Specify a bitmask that defines optional properties of the NIC.
  118. // This miniport indicates receive with NdisMIndicateReceiveNetBufferLists
  119. // function. Such a driver should set this NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
  120. // flag.
  121. //
  122. // NDIS_MAC_OPTION_NO_LOOPBACK tells NDIS that NIC has no internal
  123. // loopback support so NDIS will manage loopbacks on behalf of
  124. // this driver.
  125. //
  126. // NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA tells the protocol that
  127. // our receive buffer is not on a device-specific card. If
  128. // NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA is not set, multi-buffer
  129. // indications are copied to a single flat buffer.
  130. //
  131. #define TAP_MAC_OPTIONS (\
  132. NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA | \
  133. NDIS_MAC_OPTION_TRANSFERS_NOT_PEND | \
  134. NDIS_MAC_OPTION_NO_LOOPBACK)
  135. #define TAP_ADAPTER_CHECK_FOR_HANG_TIME_IN_SECONDS 4
  136. // NDIS 6.x miniports must support all counters in OID_GEN_STATISTICS.
  137. #define TAP_SUPPORTED_STATISTICS (\
  138. NDIS_STATISTICS_FLAGS_VALID_DIRECTED_FRAMES_RCV | \
  139. NDIS_STATISTICS_FLAGS_VALID_MULTICAST_FRAMES_RCV | \
  140. NDIS_STATISTICS_FLAGS_VALID_BROADCAST_FRAMES_RCV | \
  141. NDIS_STATISTICS_FLAGS_VALID_BYTES_RCV | \
  142. NDIS_STATISTICS_FLAGS_VALID_RCV_DISCARDS | \
  143. NDIS_STATISTICS_FLAGS_VALID_RCV_ERROR | \
  144. NDIS_STATISTICS_FLAGS_VALID_DIRECTED_FRAMES_XMIT | \
  145. NDIS_STATISTICS_FLAGS_VALID_MULTICAST_FRAMES_XMIT | \
  146. NDIS_STATISTICS_FLAGS_VALID_BROADCAST_FRAMES_XMIT | \
  147. NDIS_STATISTICS_FLAGS_VALID_BYTES_XMIT | \
  148. NDIS_STATISTICS_FLAGS_VALID_XMIT_ERROR | \
  149. NDIS_STATISTICS_FLAGS_VALID_XMIT_DISCARDS | \
  150. NDIS_STATISTICS_FLAGS_VALID_DIRECTED_BYTES_RCV | \
  151. NDIS_STATISTICS_FLAGS_VALID_MULTICAST_BYTES_RCV | \
  152. NDIS_STATISTICS_FLAGS_VALID_BROADCAST_BYTES_RCV | \
  153. NDIS_STATISTICS_FLAGS_VALID_DIRECTED_BYTES_XMIT | \
  154. NDIS_STATISTICS_FLAGS_VALID_MULTICAST_BYTES_XMIT | \
  155. NDIS_STATISTICS_FLAGS_VALID_BROADCAST_BYTES_XMIT)
  156. #define MINIMUM_MTU 576 // USE TCP Minimum MTU
  157. #define MAXIMUM_MTU 65536 // IP maximum MTU
  158. #define PACKET_QUEUE_SIZE 64 // tap -> userspace queue size
  159. #define IRP_QUEUE_SIZE 16 // max number of simultaneous i/o operations from userspace
  160. #define INJECT_QUEUE_SIZE 16 // DHCP/ARP -> tap injection queue
  161. #define TAP_LITTLE_ENDIAN // affects ntohs, htonl, etc. functions