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.

202 lines
4.3 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. // This file contain init code for the TCP/UDP driver.
  14. // Some things here are ifdef'ed for building a UDP only version.
  15. //
  16. #include "oscfg.h"
  17. #include "ndis.h"
  18. #include "ip6imp.h"
  19. #include "ip6def.h"
  20. #include "tdi.h"
  21. #include <tdikrnl.h>
  22. #include "tdint.h"
  23. #include "tdistat.h"
  24. #include "queue.h"
  25. #include "transprt.h"
  26. #include "addr.h"
  27. #include "udp.h"
  28. #include "raw.h"
  29. #include "info.h"
  30. #ifndef UDP_ONLY
  31. #include "tcp.h"
  32. #include "tcpsend.h"
  33. #include "tcb.h"
  34. #include "tcpconn.h"
  35. #include "tcpdeliv.h"
  36. extern int TCPInit(void);
  37. extern void TCPUnload(void);
  38. #endif // UDP_ONLY
  39. #include "tdiinfo.h"
  40. #include "tcpcfg.h"
  41. extern int UDPInit(void);
  42. extern void UDPUnload(void);
  43. //
  44. // Definitions of global variables.
  45. //
  46. uint MaxUserPort;
  47. HANDLE AddressChangeHandle;
  48. LARGE_INTEGER StartTime;
  49. extern void *UDPProtInfo;
  50. extern void *RawProtInfo;
  51. //
  52. // All of the init code can be discarded.
  53. //
  54. #ifdef ALLOC_PRAGMA
  55. int TransportLayerInit();
  56. #pragma alloc_text(INIT, TransportLayerInit)
  57. #endif // ALLOC_PRAGMA
  58. #ifdef UDP_ONLY
  59. //
  60. // Dummy routines for UDP only version.
  61. // All of these routines return 'Invalid Request'.
  62. //
  63. TDI_STATUS
  64. TdiOpenConnection(PTDI_REQUEST Request, PVOID Context)
  65. {
  66. return TDI_INVALID_REQUEST;
  67. }
  68. TDI_STATUS
  69. TdiCloseConnection(PTDI_REQUEST Request)
  70. {
  71. return TDI_INVALID_REQUEST;
  72. }
  73. TDI_STATUS
  74. TdiAssociateAddress(PTDI_REQUEST Request, HANDLE AddrHandle)
  75. {
  76. return TDI_INVALID_REQUEST;
  77. }
  78. TDI_STATUS
  79. TdiDisAssociateAddress(PTDI_REQUEST Request)
  80. {
  81. return TDI_INVALID_REQUEST;
  82. }
  83. TDI_STATUS
  84. TdiConnect(PTDI_REQUEST Request, void *Timeout,
  85. PTDI_CONNECTION_INFORMATION RequestAddr,
  86. PTDI_CONNECTION_INFORMATION ReturnAddr)
  87. {
  88. return TDI_INVALID_REQUEST;
  89. }
  90. TDI_STATUS
  91. TdiListen(PTDI_REQUEST Request, ushort Flags,
  92. PTDI_CONNECTION_INFORMATION AcceptableAddr,
  93. PTDI_CONNECTION_INFORMATION ConnectedAddr)
  94. {
  95. return TDI_INVALID_REQUEST;
  96. }
  97. TDI_STATUS
  98. TdiAccept(PTDI_REQUEST Request, PTDI_CONNECTION_INFORMATION AcceptInfo,
  99. PTDI_CONNECTION_INFORMATION ConnectedInfo)
  100. {
  101. return TDI_INVALID_REQUEST;
  102. }
  103. TDI_STATUS
  104. TdiReceive(PTDI_REQUEST Request, ushort *Flags, uint *RcvLength,
  105. PNDIS_BUFFER Buffer)
  106. {
  107. return TDI_INVALID_REQUEST;
  108. }
  109. TDI_STATUS
  110. TdiSend(PTDI_REQUEST Request, ushort Flags, uint SendLength,
  111. PNDIS_BUFFER Buffer)
  112. {
  113. return TDI_INVALID_REQUEST;
  114. }
  115. TDI_STATUS
  116. TdiDisconnect(PTDI_REQUEST Request, PVOID Timeout, ushort Flags,
  117. PTDI_CONNECTION_INFORMATION DisconnectInfo,
  118. PTDI_CONNECTION_INFORMATION ReturnInfo)
  119. {
  120. return TDI_INVALID_REQUEST;
  121. }
  122. #endif // UDP_ONLY
  123. #pragma BEGIN_INIT
  124. //* TransportLayerInit - Initialize the transport layer.
  125. //
  126. // The main transport layer initialize routine. We get whatever config
  127. // info we need, initialize some data structures, get information
  128. // from IP, do some more initialization, and finally register our
  129. // protocol values with IP.
  130. //
  131. int // Returns: True is we succeeded, False if we fail to initialize.
  132. TransportLayerInit(
  133. void) // No arguments.
  134. {
  135. //
  136. // Remember when we started for TdiQueryInformation.
  137. //
  138. KeQuerySystemTime(&StartTime);
  139. //
  140. // Initialize common address object management code.
  141. //
  142. if (!InitAddr())
  143. return FALSE;
  144. //
  145. // Initialize the individual protocols.
  146. //
  147. if (!UDPInit())
  148. return FALSE;
  149. #ifndef UDP_ONLY
  150. if (!TCPInit())
  151. return FALSE;
  152. #endif
  153. return TRUE;
  154. }
  155. #pragma END_INIT
  156. //* TransportLayerUnload
  157. //
  158. // Cleanup and prepare the transport layer for stack unload.
  159. //
  160. void
  161. TransportLayerUnload(void)
  162. {
  163. #ifndef UDP_ONLY
  164. TCPUnload();
  165. #endif
  166. UDPUnload();
  167. AddrUnload();
  168. }