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.

133 lines
3.0 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 contains init code for TCP.
  14. //
  15. #include "oscfg.h"
  16. #include "ndis.h"
  17. #include "ip6imp.h"
  18. #include "ip6def.h"
  19. #include "tdi.h"
  20. #include <tdikrnl.h>
  21. #include "tdint.h"
  22. #include "tdistat.h"
  23. #include "queue.h"
  24. #include "transprt.h"
  25. #include "addr.h"
  26. #include "info.h"
  27. #include "tcp.h"
  28. #include "tcpsend.h"
  29. #include "tcb.h"
  30. #include "tcpconn.h"
  31. #include "tcpdeliv.h"
  32. #include "tdiinfo.h"
  33. #include "tcpcfg.h"
  34. #pragma BEGIN_INIT
  35. extern uchar TCPGetConfigInfo(void);
  36. extern int InitTCPConn(void);
  37. extern void UnloadTCPConn(void);
  38. extern int InitTCPRcv(void);
  39. extern void UnloadTCPRcv(void);
  40. extern int InitISNGenerator(void);
  41. extern void UnloadISNGenerator(void);
  42. //
  43. // Definitions of TCP specific global variables.
  44. //
  45. uint AllowUserRawAccess;
  46. uint PMTUDiscovery;
  47. uint PMTUBHDetect;
  48. uint KeepAliveTime;
  49. uint KAInterval;
  50. uint DefaultRcvWin;
  51. uint MaxConnections;
  52. uint MaxConnBlocks;
  53. uint TcbTableSize;
  54. uint MaxConnectRexmitCount;
  55. uint MaxDataRexmitCount;
  56. uint BSDUrgent;
  57. uint FinWait2TO;
  58. uint NTWMaxConnectCount;
  59. uint NTWMaxConnectTime;
  60. uint SynAttackProtect = 0;
  61. //* TCPInit - Initialize the Transport Control Protocol.
  62. //
  63. // The main TCP initialize routine. We get whatever config
  64. // info we need, initialize some data structures, etc.
  65. //
  66. int // Returns: True is we succeeded, False if we fail to initialize.
  67. TCPInit(void)
  68. {
  69. if (!TCPGetConfigInfo())
  70. return FALSE;
  71. KeepAliveTime = MS_TO_TICKS(KeepAliveTime);
  72. KAInterval = MS_TO_TICKS(KAInterval);
  73. MaxConnections = MIN(MaxConnections, INVALID_CONN_INDEX - 1);
  74. if (!InitISNGenerator())
  75. return FALSE;
  76. if (!InitTCPConn())
  77. return FALSE;
  78. if (!InitTCB())
  79. return FALSE;
  80. if (!InitTCPRcv())
  81. return FALSE;
  82. if (!InitTCPSend())
  83. return FALSE;
  84. //
  85. // Initialize statistics.
  86. //
  87. RtlZeroMemory(&TStats, sizeof(TCPStats));
  88. TStats.ts_rtoalgorithm = TCP_RTO_VANJ;
  89. TStats.ts_rtomin = MIN_RETRAN_TICKS * MS_PER_TICK;
  90. TStats.ts_rtomax = MAX_REXMIT_TO * MS_PER_TICK;
  91. TStats.ts_maxconn = (ulong) TCP_MAXCONN_DYNAMIC;
  92. return TRUE;
  93. }
  94. #pragma END_INIT
  95. //* TCPUnload
  96. //
  97. // Called to cleanup TCP in preparation for unloading the stack.
  98. //
  99. void
  100. TCPUnload(void)
  101. {
  102. //
  103. // After UnloadTCPSend, we will stop receiving packets
  104. // from the IPv6 layer.
  105. //
  106. UnloadTCPSend();
  107. UnloadTCPRcv();
  108. UnloadTCB();
  109. UnloadTCPConn();
  110. UnloadISNGenerator();
  111. }