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.

141 lines
2.9 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. // LAURABU SALEM BUGBUG
  39. // THIS IS A DUP OF \h\imsconf3.idl value
  40. //
  41. #define DEFAULT_LISTEN_PORT 522
  42. typedef enum {
  43. READ_HEADER,
  44. READ_DATA,
  45. DISCONNECT_REQUEST, /* There are dependencies on this order */
  46. CONNECTION_CONFIRM,
  47. CONNECTION_REQUEST,
  48. DATA_READY
  49. } ReadState;
  50. #define WM_SOCKET_NOTIFICATION (WM_APP)
  51. #define WM_SECURE_SOCKET_NOTIFICATION (WM_APP+1)
  52. #define WM_PLUGGABLE_X224 (WM_APP+2)
  53. #define WM_PLUGGABLE_PSTN (WM_APP+3)
  54. typedef struct _Security_Buffer_Info {
  55. LPBYTE lpBuffer;
  56. UINT uiLength;
  57. } Security_Buffer_Info;
  58. class CSocket : public CRefCount
  59. {
  60. public:
  61. CSocket(BOOL *, TransportConnection, PSecurityContext);
  62. ~CSocket(void);
  63. void FreeTransportBuffer(void);
  64. public:
  65. X224_DATA_PACKET X224_Header;
  66. /* global variables */
  67. // SOCKET Socket_Number;
  68. SocketState State;
  69. SecurityState SecState;
  70. PSecurityContext pSC;
  71. UINT Max_Packet_Length;
  72. Char Remote_Address[MAXIMUM_IP_ADDRESS_SIZE];
  73. /* recv state variables */
  74. UINT Current_Length;
  75. PUChar Data_Indication_Buffer;
  76. UINT Data_Indication_Length;
  77. ReadState Read_State;
  78. UINT X224_Length;
  79. BOOL bSpaceAllocated;
  80. PMemory Data_Memory;
  81. /* send state variables */
  82. union {
  83. PDataPacket pUnfinishedPacket;
  84. Security_Buffer_Info sbiBufferInfo;
  85. } Retry_Info;
  86. BOOL fExtendedX224;
  87. BOOL fIncomingSecure;
  88. // plugable transport
  89. TransportConnection XprtConn;
  90. };
  91. typedef CSocket *PSocket;
  92. class CSocketList : public CList
  93. {
  94. DEFINE_CLIST(CSocketList, PSocket)
  95. void SafeAppend(PSocket);
  96. BOOL SafeRemove(PSocket);
  97. PSocket FindByTransportConnection(TransportConnection, BOOL fNoAddRef = FALSE);
  98. PSocket RemoveByTransportConnection(TransportConnection);
  99. };
  100. extern CSocketList *g_pSocketList;
  101. /* Function prototypes */
  102. PSocket newSocket(TransportConnection, PSecurityContext);
  103. PSocket newPluggableSocket(TransportConnection);
  104. PSocket newSocketEx(TransportConnection, PSecurityContext);
  105. void freeSocket(PSocket, TransportConnection);
  106. void freeListenSocket(TransportConnection);
  107. void freePluggableSocket(PSocket);
  108. void freeSocketEx(PSocket, TransportConnection /* listen_socket_number */);
  109. SOCKET CreateAndConfigureListenSocket (VOID);
  110. #endif /* _SOCKET_ */