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.

134 lines
2.9 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 DeadGWDetect;
  47. uint PMTUDiscovery;
  48. uint PMTUBHDetect;
  49. uint KeepAliveTime;
  50. uint KAInterval;
  51. uint DefaultRcvWin;
  52. uint MaxConnections;
  53. uint MaxConnBlocks;
  54. uint TcbTableSize;
  55. uint MaxConnectRexmitCount;
  56. uint MaxDataRexmitCount;
  57. uint BSDUrgent;
  58. uint FinWait2TO;
  59. uint NTWMaxConnectCount;
  60. uint NTWMaxConnectTime;
  61. uint SynAttackProtect = 0;
  62. //* TCPInit - Initialize the Transport Control Protocol.
  63. //
  64. // The main TCP initialize routine. We get whatever config
  65. // info we need, initialize some data structures, etc.
  66. //
  67. int // Returns: True is we succeeded, False if we fail to initialize.
  68. TCPInit(void)
  69. {
  70. if (!TCPGetConfigInfo())
  71. return FALSE;
  72. KeepAliveTime = MS_TO_TICKS(KeepAliveTime);
  73. KAInterval = MS_TO_TICKS(KAInterval);
  74. MaxConnections = MIN(MaxConnections, INVALID_CONN_INDEX - 1);
  75. if (!InitISNGenerator())
  76. return FALSE;
  77. if (!InitTCPConn())
  78. return FALSE;
  79. if (!InitTCB())
  80. return FALSE;
  81. if (!InitTCPRcv())
  82. return FALSE;
  83. if (!InitTCPSend())
  84. return FALSE;
  85. //
  86. // Initialize statistics.
  87. //
  88. RtlZeroMemory(&TStats, sizeof(TCPStats));
  89. TStats.ts_rtoalgorithm = TCP_RTO_VANJ;
  90. TStats.ts_rtomin = MIN_RETRAN_TICKS * MS_PER_TICK;
  91. TStats.ts_rtomax = MAX_REXMIT_TO * MS_PER_TICK;
  92. TStats.ts_maxconn = (ulong) TCP_MAXCONN_DYNAMIC;
  93. return TRUE;
  94. }
  95. #pragma END_INIT
  96. //* TCPUnload
  97. //
  98. // Called to cleanup TCP in preparation for unloading the stack.
  99. //
  100. void
  101. TCPUnload(void)
  102. {
  103. //
  104. // After UnloadTCPSend, we will stop receiving packets
  105. // from the IPv6 layer.
  106. //
  107. UnloadTCPSend();
  108. UnloadTCPRcv();
  109. UnloadTCB();
  110. UnloadTCPConn();
  111. UnloadISNGenerator();
  112. }