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.

401 lines
11 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1998-2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: Locals.h
  6. * Content: Global information for the DNWSock service provider
  7. *
  8. *
  9. * History:
  10. * Date By Reason
  11. * ==== == ======
  12. * 11/25/98 jtk Created
  13. ***************************************************************************/
  14. #ifndef __LOCALS_H__
  15. #define __LOCALS_H__
  16. //**********************************************************************
  17. // Constant definitions
  18. //**********************************************************************
  19. //
  20. // Smallest and largest reasonable values for the Maximum Transmission Unit.
  21. //
  22. #define MIN_MTU 128
  23. #define MAX_MTU 1500
  24. //
  25. // Header sizes
  26. //
  27. #define IP_HEADER_SIZE 20
  28. #define UDP_HEADER_SIZE 8
  29. #define IP_UDP_HEADER_SIZE (IP_HEADER_SIZE + UDP_HEADER_SIZE)
  30. #define ESP_HEADER_SIZE 8
  31. #define ENCRYPTIONIV_HEADER_SIZE 8
  32. #define PADDING_FOR_MAX_PACKET 4
  33. #define ICV_AUTHENTICATION_SIZE 12
  34. #define MAX_ENCAPSULATION_SIZE (ESP_HEADER_SIZE + ENCRYPTIONIV_HEADER_SIZE + UDP_HEADER_SIZE + PADDING_FOR_MAX_PACKET + ICV_AUTHENTICATION_SIZE)
  35. // This should equal 1430 bytes, the Xbox secure networking UDP payload limit.
  36. #define NONDPLAY_HEADER_SIZE (IP_UDP_HEADER_SIZE + MAX_ENCAPSULATION_SIZE)
  37. #define ENUM_PAYLOAD_HEADER_SIZE (sizeof(PREPEND_BUFFER))
  38. //
  39. // Smallest and largest reasonable values for the maximum amount of data in
  40. // a frame that we send.
  41. //
  42. #define MIN_SEND_FRAME_SIZE (MIN_MTU - NONDPLAY_HEADER_SIZE)
  43. #define MAX_SEND_FRAME_SIZE (MAX_MTU - NONDPLAY_HEADER_SIZE)
  44. //
  45. // Default maximum user payload size in bytes. We don't use just
  46. // MAX_SEND_FRAME_SIZE because some broken routers can't handle IP
  47. // fragmentation properly in cases where the MTU is actually less than 1500.
  48. // The actual value used can be overridden (between MIN_SEND_FRAME_SIZE
  49. // and MAX_SEND_FRAME_SIZE) via the registry.
  50. //
  51. #define DEFAULT_MAX_USER_DATA_SIZE (MAX_SEND_FRAME_SIZE - 48)
  52. //
  53. // Default maximume enum payload size in bytes. We use something less than
  54. // DEFAULT_MAX_USER_DATA_SIZE to give us room to expand our enum
  55. // information. The actual value used can be overridden (between
  56. // MIN_SEND_FRAME_SIZE and MAX_SEND_FRAME_SIZE) via the registry.
  57. //
  58. #define DEFAULT_MAX_ENUM_DATA_SIZE 1000
  59. //
  60. // Older versions of DPlay (or new ones with modified registry settings) may
  61. // send us larger packets, so expect to handle that.
  62. //
  63. #define MAX_RECEIVE_FRAME_SIZE (MAX_MTU - IP_UDP_HEADER_SIZE)
  64. //
  65. // maximum value of a 32-bit unsigned variable
  66. //
  67. #define UINT32_MAX ((DWORD) 0xFFFFFFFF)
  68. #define WORD_MAX ((WORD) 0xFFFF)
  69. //
  70. // default enum retries for Winsock SP and retry time (milliseconds)
  71. //
  72. #ifdef _XBOX
  73. // Xbox design TCR 3-59 Session Discovery Time for System Link Play
  74. // The game must discover sessions for system link play in no more than three seconds
  75. #define DEFAULT_ENUM_RETRY_COUNT 3
  76. #define DEFAULT_ENUM_RETRY_INTERVAL 750
  77. #define DEFAULT_ENUM_TIMEOUT 750
  78. #else // ! _XBOX
  79. #define DEFAULT_ENUM_RETRY_COUNT 5
  80. #define DEFAULT_ENUM_RETRY_INTERVAL 1500
  81. #define DEFAULT_ENUM_TIMEOUT 1500
  82. #endif // ! _XBOX
  83. #define ENUM_RTT_ARRAY_SIZE 16 // also see ENUM_RTT_MASK
  84. #ifndef DPNBUILD_ONLYONEADAPTER
  85. //
  86. // Private address key that allows for friendlier multi-device commands issued
  87. // using xxxADDRESSINFO indications; specifically, this allows us to detect
  88. // responses sent to the "wrong" adapter when the core multiplexes an
  89. // enum or connect into multiple adapters.
  90. //
  91. #define DPNA_PRIVATEKEY_MULTIPLEXED_ADAPTER_ASSOCIATION L"pk_ipsp_maa"
  92. //
  93. // Private address key that allows for friendlier multi-device commands issued
  94. // using xxxADDRESSINFO indications; specifically, this allows us to distinguish
  95. // between the user specifying a fixed port and the core handing us back the
  96. // port we chose for a previous adapter when it multiplexes an enum, connect,
  97. // or listen into multiple adapters.
  98. //
  99. #define DPNA_PRIVATEKEY_PORT_NOT_SPECIFIC L"pk_ipsp_pns"
  100. #endif // ! DPNBUILD_ONLYONEADAPTER
  101. #if ((! defined(DPNBUILD_NOWINSOCK2)) || (! defined(DPNBUILD_NOREGISTRY)))
  102. //
  103. // Private address key designed to improve support for MS Proxy/ISA Firewall
  104. // client software. This key tracks the original target address for enums so
  105. // that if the application closes the socketport before trying to connect to
  106. // the responding address, the connect attempts will go to the real target
  107. // instead of the old proxy address.
  108. //
  109. #define DPNA_PRIVATEKEY_PROXIED_RESPONSE_ORIGINAL_ADDRESS L"pk_ipsp_proa"
  110. #endif // ! DPNBUILD_NOWINSOCK2 or ! DPNBUILD_NOREGISTRY
  111. //
  112. // 192.168.0.1 in network byte order
  113. //
  114. #define IP_PRIVATEICS_ADDRESS 0x0100A8C0
  115. //
  116. // 127.0.0.1 in network byte order
  117. //
  118. #define IP_LOOPBACK_ADDRESS 0x0100007F
  119. //
  120. // 1110 high bits or 224.0.0.0 - 239.255.255.255 multicast address, in network byte order
  121. //
  122. #define IS_CLASSD_IPV4_ADDRESS(dwAddr) (( (*((BYTE*) &(dwAddr))) & 0xF0) == 0xE0)
  123. #define NTOHS(x) ( (((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00) )
  124. #define HTONS(x) NTOHS(x)
  125. #ifndef DPNBUILD_NOMULTICAST
  126. #define MULTICAST_TTL_PRIVATE 1
  127. #define MULTICAST_TTL_PRIVATE_AS_STRING L"1"
  128. #define MULTICAST_TTL_LOCAL 16
  129. #define MULTICAST_TTL_LOCAL_AS_STRING L"16"
  130. #define MULTICAST_TTL_GLOBAL 255
  131. #define MULTICAST_TTL_GLOBAL_AS_STRING L"255"
  132. #endif // ! DPNBUILD_NOMULTICAST
  133. //**********************************************************************
  134. // Macro definitions
  135. //**********************************************************************
  136. //**********************************************************************
  137. // Structure definitions
  138. //**********************************************************************
  139. //
  140. // forward structure and class references
  141. //
  142. typedef struct IDP8ServiceProvider IDP8ServiceProvider;
  143. //**********************************************************************
  144. // Variable definitions
  145. //**********************************************************************
  146. #if ((! defined(WINCE)) && (! defined(_XBOX)))
  147. //
  148. // DLL instance
  149. //
  150. extern HINSTANCE g_hDLLInstance;
  151. #endif // ! WINCE and ! _XBOX
  152. #ifdef _XBOX
  153. extern BOOL g_fStartedXNet;
  154. #endif // _XBOX
  155. #ifndef DPNBUILD_LIBINTERFACE
  156. //
  157. // count of outstanding COM interfaces
  158. //
  159. extern volatile LONG g_lOutstandingInterfaceCount;
  160. #endif // ! DPNBUILD_LIBINTERFACE
  161. #ifndef DPNBUILD_ONLYONETHREAD
  162. //
  163. // thread count
  164. //
  165. extern LONG g_iThreadCount;
  166. #endif // ! DPNBUILD_ONLYONETHREAD
  167. #ifndef DPNBUILD_NOREGISTRY
  168. #if ((! defined(DPNBUILD_NOWINSOCK2)) && (! defined(DPNBUILD_ONLYWINSOCK2)))
  169. extern DWORD g_dwWinsockVersion;
  170. #endif // ! DPNBUILD_NOWINSOCK2 and ! DPNBUILD_ONLYWINSOCK2
  171. #endif // ! DPNBUILD_NOREGISTRY
  172. //
  173. // Winsock receive buffer size
  174. //
  175. extern BOOL g_fWinsockReceiveBufferSizeOverridden;
  176. extern INT g_iWinsockReceiveBufferSize;
  177. //
  178. // GUIDs for munging device and scope IDs
  179. //
  180. extern GUID g_IPSPEncryptionGuid;
  181. #ifndef DPNBUILD_NOIPX
  182. extern GUID g_IPXSPEncryptionGuid;
  183. #endif // ! DPNBUILD_NOIPX
  184. #ifndef DPNBUILD_NOIPV6
  185. //
  186. // IPv6 link-local multicast address for enumerating DirectPlay sessions
  187. //
  188. extern const IN6_ADDR c_in6addrEnumMulticast;
  189. #endif // ! DPNBUILD_NOIPV6
  190. #ifndef DPNBUILD_NONATHELP
  191. //
  192. // global NAT/firewall traversal information
  193. //
  194. #ifdef DPNBUILD_ONLYONENATHELP
  195. #define MAX_NUM_DIRECTPLAYNATHELPERS 1
  196. #else // ! DPNBUILD_ONLYONENATHELP
  197. #define MAX_NUM_DIRECTPLAYNATHELPERS 5
  198. #endif // ! DPNBUILD_ONLYONENATHELP
  199. #define FORCE_TRAVERSALMODE_BIT 0x80000000 // make the default mode override any app specific settings
  200. #ifndef DPNBUILD_NOREGISTRY
  201. extern BOOL g_fDisableDPNHGatewaySupport;
  202. extern BOOL g_fDisableDPNHFirewallSupport;
  203. extern DWORD g_dwDefaultTraversalMode;
  204. #endif // ! DPNBUILD_NOREGISTRY
  205. extern IDirectPlayNATHelp ** g_papNATHelpObjects;
  206. #ifndef DPNBUILD_NOLOCALNAT
  207. extern BOOL g_fLocalNATDetectedAtStartup;
  208. #endif // ! DPNBUILD_NOLOCALNAT
  209. #endif // DPNBUILD_NONATHELP
  210. #ifndef DPNBUILD_NOREGISTRY
  211. #if ((defined(WINNT)) && (! defined(DPNBUILD_NOMULTICAST)))
  212. extern BOOL g_fDisableMadcapSupport;
  213. extern MCAST_CLIENT_UID g_mcClientUid;
  214. #endif // WINNT and not DPNBUILD_NOMULTICAST
  215. //
  216. // ignore enums performance option
  217. //
  218. extern BOOL g_fIgnoreEnums;
  219. //
  220. // disconnect upon reception of ICMP port not reachable option
  221. //
  222. extern BOOL g_fDisconnectOnICMP;
  223. #ifndef DPNBUILD_NOIPV6
  224. //
  225. // IPv4 only/IPv6 only/hybrid setting
  226. //
  227. extern int g_iIPAddressFamily;
  228. #endif // ! DPNBUILD_NOIPV6
  229. //
  230. // IP banning globals
  231. //
  232. extern CHashTable * g_pHashBannedIPv4Addresses;
  233. extern DWORD g_dwBannedIPv4Masks;
  234. //
  235. // proxy support options
  236. //
  237. #ifndef DPNBUILD_NOWINSOCK2
  238. extern BOOL g_fDontAutoDetectProxyLSP;
  239. #endif // !DPNBUILD_NOWINSOCK2
  240. extern BOOL g_fTreatAllResponsesAsProxied;
  241. //
  242. // settings for overriding MTU
  243. //
  244. extern DWORD g_dwMaxUserDataSize;
  245. extern DWORD g_dwMaxEnumDataSize;
  246. //
  247. // default port range
  248. //
  249. extern WORD g_wBaseDPlayPort;
  250. extern WORD g_wMaxDPlayPort;
  251. #endif // ! DPNBUILD_NOREGISTRY
  252. //
  253. // ID of most recent endpoint generated
  254. //
  255. extern DWORD g_dwCurrentEndpointID;
  256. #ifdef DBG
  257. //
  258. // Bilink for tracking DPNWSock critical sections
  259. //
  260. extern CBilink g_blDPNWSockCritSecsHeld;
  261. #endif // DBG
  262. #ifdef DPNBUILD_WINSOCKSTATISTICS
  263. //
  264. // Winsock debugging/tuning stats
  265. //
  266. extern DWORD g_dwWinsockStatNumSends;
  267. extern DWORD g_dwWinsockStatSendCallTime;
  268. #endif // DPNBUILD_WINSOCKSTATISTICS
  269. #ifndef DPNBUILD_NOREGISTRY
  270. //
  271. // Registry strings
  272. //
  273. extern const WCHAR g_RegistryBase[];
  274. extern const WCHAR g_RegistryKeyReceiveBufferSize[];
  275. #ifndef DPNBUILD_ONLYONETHREAD
  276. extern const WCHAR g_RegistryKeyThreadCount[];
  277. #endif // ! DPNBUILD_ONLYONETHREAD
  278. #if ((! defined(DPNBUILD_NOWINSOCK2)) && (! defined(DPNBUILD_ONLYWINSOCK2)))
  279. extern const WCHAR g_RegistryKeyWinsockVersion[];
  280. #endif // ! DPNBUILD_NOWINSOCK2 and ! DPNBUILD_ONLYWINSOCK2
  281. #ifndef DPNBUILD_NONATHELP
  282. extern const WCHAR g_RegistryKeyDisableDPNHGatewaySupport[];
  283. extern const WCHAR g_RegistryKeyDisableDPNHFirewallSupport[];
  284. extern const WCHAR g_RegistryKeyTraversalModeSettings[];
  285. extern const WCHAR g_RegistryKeyDefaultTraversalMode[];
  286. #endif // ! DPNBUILD_NONATHELP
  287. extern const WCHAR g_RegistryKeyAppsToIgnoreEnums[];
  288. extern const WCHAR g_RegistryKeyAppsToDisconnectOnICMP[];
  289. #ifndef DPNBUILD_NOIPV6
  290. extern const WCHAR g_RegistryKeyIPAddressFamilySettings[];
  291. extern const WCHAR g_RegistryKeyDefaultIPAddressFamily[];
  292. #endif // ! DPNBUILD_NOIPV6
  293. #ifndef DPNBUILD_NOWINSOCK2
  294. extern const WCHAR g_RegistryKeyDontAutoDetectProxyLSP[];
  295. #endif // ! DPNBUILD_NOWINSOCK2
  296. extern const WCHAR g_RegistryKeyTreatAllResponsesAsProxied[];
  297. #if ((defined(WINNT)) && (! defined(DPNBUILD_NOMULTICAST)))
  298. extern const WCHAR g_RegistryKeyDisableMadcapSupport[];
  299. #endif // WINNT and not DPNBUILD_NOMULTICAST
  300. extern const WCHAR g_RegistryKeyMaxUserDataSize[];
  301. extern const WCHAR g_RegistryKeyMaxEnumDataSize[];
  302. extern const WCHAR g_RegistryKeyBaseDPlayPort[];
  303. extern const WCHAR g_RegistryKeyMaxDPlayPort[];
  304. extern const WCHAR g_RegistryKeyBannedIPv4Addresses[];
  305. #endif // ! DPNBUILD_NOREGISTRY
  306. #endif // __LOCALS_H__