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.

138 lines
3.0 KiB

  1. /* Socket.h
  2. *
  3. * Copyright (c) 1996 by Microsoft Corporation
  4. *
  5. * Abstract:
  6. * This is the WinSock interface to a socket. It can create a
  7. * connection with another machine, transmit and receive data, and shut
  8. * down the socket when it is finished.
  9. *
  10. */
  11. #ifndef _SOCKET_
  12. #define _SOCKET_
  13. #include "databeam.h"
  14. extern "C"
  15. {
  16. #include "t120.h"
  17. #include "winsock2.h"
  18. }
  19. #include "tprtsec.h"
  20. /* States that the socket can be in */
  21. typedef enum
  22. {
  23. NOT_CONNECTED,
  24. WAITING_FOR_CONNECTION,
  25. SOCKET_CONNECTED,
  26. X224_CONNECTED,
  27. WAITING_FOR_DISCONNECT
  28. } SocketState;
  29. /* Security states that the socket can be in */
  30. typedef enum
  31. {
  32. SC_UNDETERMINED,
  33. SC_SECURE,
  34. SC_NONSECURE
  35. } SecurityState;
  36. #define MAXIMUM_IP_ADDRESS_SIZE 32
  37. /*
  38. ** This is the port number specified by IMTC
  39. */
  40. #define TCP_PORT_NUMBER 1503
  41. typedef enum {
  42. READ_HEADER,
  43. READ_DATA,
  44. DISCONNECT_REQUEST, /* There are dependencies on this order */
  45. CONNECTION_CONFIRM,
  46. CONNECTION_REQUEST,
  47. DATA_READY
  48. } ReadState;
  49. #define WM_SOCKET_NOTIFICATION (WM_APP)
  50. #define WM_SECURE_SOCKET_NOTIFICATION (WM_APP+1)
  51. #define WM_PLUGGABLE_X224 (WM_APP+2)
  52. #define WM_PLUGGABLE_PSTN (WM_APP+3)
  53. typedef struct _Security_Buffer_Info {
  54. LPBYTE lpBuffer;
  55. UINT uiLength;
  56. } Security_Buffer_Info;
  57. class CSocket : public CRefCount
  58. {
  59. public:
  60. CSocket(BOOL *, TransportConnection, PSecurityContext);
  61. ~CSocket(void);
  62. void FreeTransportBuffer(void);
  63. public:
  64. X224_DATA_PACKET X224_Header;
  65. /* global variables */
  66. // SOCKET Socket_Number;
  67. SocketState State;
  68. SecurityState SecState;
  69. PSecurityContext pSC;
  70. UINT Max_Packet_Length;
  71. Char Remote_Address[MAXIMUM_IP_ADDRESS_SIZE];
  72. /* recv state variables */
  73. UINT Current_Length;
  74. PUChar Data_Indication_Buffer;
  75. UINT Data_Indication_Length;
  76. ReadState Read_State;
  77. UINT X224_Length;
  78. BOOL bSpaceAllocated;
  79. PMemory Data_Memory;
  80. /* send state variables */
  81. union {
  82. PDataPacket pUnfinishedPacket;
  83. Security_Buffer_Info sbiBufferInfo;
  84. } Retry_Info;
  85. BOOL fExtendedX224;
  86. BOOL fIncomingSecure;
  87. // plugable transport
  88. TransportConnection XprtConn;
  89. };
  90. typedef CSocket *PSocket;
  91. class CSocketList : public CList
  92. {
  93. DEFINE_CLIST(CSocketList, PSocket)
  94. void SafeAppend(PSocket);
  95. BOOL SafeRemove(PSocket);
  96. PSocket FindByTransportConnection(TransportConnection, BOOL fNoAddRef = FALSE);
  97. PSocket RemoveByTransportConnection(TransportConnection);
  98. };
  99. extern CSocketList *g_pSocketList;
  100. /* Function prototypes */
  101. PSocket newSocket(TransportConnection, PSecurityContext);
  102. PSocket newPluggableSocket(TransportConnection);
  103. PSocket newSocketEx(TransportConnection, PSecurityContext);
  104. void freeSocket(PSocket, TransportConnection);
  105. void freeListenSocket(TransportConnection);
  106. void freePluggableSocket(PSocket);
  107. void freeSocketEx(PSocket, TransportConnection /* listen_socket_number */);
  108. SOCKET CreateAndConfigureListenSocket (VOID);
  109. #endif /* _SOCKET_ */