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.

236 lines
7.2 KiB

  1. /***************************************************************************
  2. *
  3. * File: h245ws.h
  4. *
  5. * INTEL Corporation Proprietary Information
  6. * Copyright (c) 1996 Intel Corporation.
  7. *
  8. * This listing is supplied under the terms of a license agreement
  9. * with INTEL Corporation and may not be used, copied, nor disclosed
  10. * except in accordance with the terms of that agreement.
  11. *
  12. ***************************************************************************
  13. *
  14. * $Workfile: h245ws.h $
  15. * $Revision: 1.19 $
  16. * $Modtime: 31 Jan 1997 15:56:32 $
  17. * $Log: S:\sturgeon\src\h245ws\vcs\h245ws.h_v $
  18. *
  19. * Rev 1.19 31 Jan 1997 16:23:34 SBELL1
  20. * Got rid of unused next pointer and put in definition of SocketTOPhysicalID
  21. *
  22. * Rev 1.18 13 Dec 1996 12:13:06 SBELL1
  23. * moved ifdef _cplusplus to after includes
  24. *
  25. * Rev 1.17 11 Dec 1996 13:45:36 SBELL1
  26. * Changed table/locks to use tstable.h stuff.
  27. *
  28. * Rev 1.16 21 Jun 1996 18:51:44 unknown
  29. * Fixed yet another shutdown bug - linkLayerShutdown re-entrancy check.
  30. *
  31. * Rev 1.15 May 28 1996 10:36:50 plantz
  32. * Change HWSMALLOC and HWSFREE to use GlobalAlloc and GlobalFree (in release
  33. * build only). Remove HWSREALLOC; it was not used.
  34. * .
  35. *
  36. * Rev 1.14 17 May 1996 16:49:36 EHOWARDX
  37. * Shutdown fix.
  38. *
  39. * Rev 1.13 16 May 1996 13:09:50 EHOWARDX
  40. * Made reporting of IP Addres and port consistent between linkLayerListen
  41. * and LinkLayerConnect.
  42. *
  43. * Rev 1.12 09 May 1996 18:33:06 EHOWARDX
  44. *
  45. * Changes to build with new LINKAPI.H.
  46. *
  47. * Rev 1.11 Apr 29 1996 14:02:28 plantz
  48. * Delete unused or private functions.
  49. *
  50. * Rev 1.10 Apr 29 1996 12:15:38 plantz
  51. * Remove unused members of HWSINST structure.
  52. *
  53. * Rev 1.9 Apr 24 1996 20:46:58 plantz
  54. * Changed ListenCallback to ConnectCallback in HWSINST structure.
  55. *
  56. * Rev 1.8 Apr 24 1996 16:24:14 plantz
  57. * Change to use winsock 1 and not use overlapped I/O.
  58. *
  59. * Rev 1.7 01 Apr 1996 14:20:38 unknown
  60. * Shutdown redesign.
  61. *
  62. * Rev 1.6 27 Mar 1996 13:01:28 EHOWARDX
  63. * Added dwThreadId to H245WS instance structure.
  64. *
  65. * Rev 1.5 19 Mar 1996 20:21:46 EHOWARDX
  66. * Redesigned shutdown.
  67. *
  68. * Rev 1.3 18 Mar 1996 19:07:10 EHOWARDX
  69. * Fixed shutdown; eliminated TPKT/WSCB dependencies.
  70. * Define TPKT to put TPKT/WSCB dependencies back in.
  71. *
  72. * Rev 1.2 14 Mar 1996 17:01:50 EHOWARDX
  73. *
  74. * NT4.0 testing; got rid of HwsAssert(); got rid of TPKT/WSCB.
  75. *
  76. * Rev 1.1 09 Mar 1996 21:12:58 EHOWARDX
  77. * Fixes as result of testing.
  78. *
  79. * Rev 1.0 08 Mar 1996 20:17:56 unknown
  80. * Initial revision.
  81. *
  82. ***************************************************************************/
  83. #ifndef H245WS_H
  84. #define H245WS_H
  85. #ifndef STRICT
  86. #define STRICT
  87. #endif
  88. #include <malloc.h>
  89. #include <incommon.h>
  90. #ifdef __cplusplus
  91. extern "C"
  92. {
  93. #endif // __cplusplus
  94. /*
  95. * Constants
  96. */
  97. #define SUCCESS 0
  98. #define TPKT_VERSION 3
  99. #define TPKT_HEADER_SIZE 4
  100. // Indexes of permanent events in Events[]
  101. #define EVENT_SOCKET 0
  102. #define EVENT_RECV 1
  103. #define EVENT_SEND 2
  104. #define EVENT_FIRST 3
  105. // Values for byLevel
  106. #define HWS_CRITICAL 0x01
  107. #define HWS_ERROR 0x02
  108. #define HWS_WARNING 0x04
  109. #define HWS_NOTIFY 0x08
  110. #define HWS_TRACE 0x10
  111. #define HWS_TEMP 0x20
  112. #define HWSMALLOC(x) malloc(x)
  113. #define HWSFREE(x) free(x)
  114. #if defined(DBG)
  115. void HwsTrace (DWORD dwInst, BYTE byLevel, LPSTR pszFormat, ...);
  116. #define HWSASSERT(exp) ASSERT(exp)
  117. #define HWSTRACE0(dwH245Instance,byLevel,a) HwsTrace(dwH245Instance,byLevel,a)
  118. #define HWSTRACE1(dwH245Instance,byLevel,a,b) HwsTrace(dwH245Instance,byLevel,a,b)
  119. #define HWSTRACE2(dwH245Instance,byLevel,a,b,c) HwsTrace(dwH245Instance,byLevel,a,b,c)
  120. #define HWSTRACE3(dwH245Instance,byLevel,a,b,c,d) HwsTrace(dwH245Instance,byLevel,a,b,c,d)
  121. #define HWSTRACE4(dwH245Instance,byLevel,a,b,c,d,e) HwsTrace(dwH245Instance,byLevel,a,b,c,d,e)
  122. #define HWSTRACE5(dwH245Instance,byLevel,a,b,c,d,e,f) HwsTrace(dwH245Instance,byLevel,a,b,c,d,e,f)
  123. #else // (DBG)
  124. #define HWSASSERT(exp)
  125. #define HWSTRACE0(dwH245Instance,byLevel,a)
  126. #define HWSTRACE1(dwH245Instance,byLevel,a,b)
  127. #define HWSTRACE2(dwH245Instance,byLevel,a,b,c)
  128. #define HWSTRACE3(dwH245Instance,byLevel,a,b,c,d)
  129. #define HWSTRACE4(dwH245Instance,byLevel,a,b,c,d,e)
  130. #define HWSTRACE5(dwH245Instance,byLevel,a,b,c,d,e,f)
  131. #endif // (DBG)
  132. // This structure is used for overlapped sends and receives
  133. typedef struct _IO_REQUEST
  134. {
  135. struct _HWSINST * req_pHws; // Pointer back to socket data
  136. BYTE req_TpktHeader[TPKT_HEADER_SIZE];
  137. int req_header_bytes_done;
  138. BYTE * req_client_data;
  139. int req_client_length;
  140. int req_client_bytes_done;
  141. DWORD req_dwMagic; // Request type (send or receive)
  142. #define RECV_REQUEST_MAGIC 0x91827364
  143. #define SEND_REQUEST_MAGIC 0x19283746
  144. } REQUEST, *PREQUEST;
  145. typedef struct _HWSINST
  146. {
  147. UINT hws_uState;
  148. #define HWS_START 0
  149. #define HWS_LISTENING 1 /* Waiting for FD_ACCEPT */
  150. #define HWS_CONNECTING 2 /* Waiting for FD_CONNECT */
  151. #define HWS_CONNECTED 3 /* Data transfer state */
  152. #define HWS_CLOSING 4 /* Waiting for FD_CLOSE */
  153. #define HWS_CLOSED 5 /* Waiting for linkLayerShutdown() */
  154. #define HWS_SHUTDOWN 6 /* linkLayerShutdown() called from callback */
  155. DWORD hws_dwPhysicalId;
  156. DWORD hws_dwH245Instance;
  157. H245CONNECTCALLBACK hws_h245ConnectCallback;
  158. H245SRCALLBACK hws_h245RecvCallback;
  159. H245SRCALLBACK hws_h245SendCallback;
  160. SOCKET hws_Socket;
  161. SOCKADDR_IN hws_SockAddr;
  162. UINT hws_uSockAddrLen;
  163. // points to a queue used to hold send buffers
  164. PQUEUE hws_pSendQueue;
  165. // points to a queue used to hold receive buffers
  166. PQUEUE hws_pRecvQueue;
  167. // The maximum message size we can send on this socket.
  168. // This value is either an integer or the manifest constant NO_MAX_MSG_SIZE.
  169. UINT hws_uMaxMsgSize;
  170. BOOL hws_bCloseFlag;
  171. #if defined(DBG)
  172. DWORD hws_dwMagic; // Request type (send or receive)
  173. #define HWSINST_MAGIC 0x12345678
  174. #endif // (DBG)
  175. } HWSINST, *PHWSINST;
  176. typedef struct _SOCKET_TO_INSTANCE
  177. {
  178. SOCKET socket;
  179. DWORD dwPhysicalId;
  180. struct _SOCKET_TO_INSTANCE *next;
  181. } SOCKET_TO_INSTANCE, *PSOCKET_TO_INSTANCE;
  182. #define SOCK_TO_PHYSID_TABLE_SIZE 251
  183. ////////////////////////////////////////////////////////////////////////////
  184. //
  185. // Function Prototypes
  186. //
  187. ////////////////////////////////////////////////////////////////////////////
  188. #ifdef UNICODE_TRACE
  189. LPCTSTR
  190. #else
  191. const char *
  192. #endif
  193. SocketErrorText(void);
  194. //PHWSINST FindPhysicalId(DWORD dwPhysicalId);
  195. void NotifyRead (PHWSINST pHws);
  196. void NotifyWrite (PHWSINST pHws);
  197. void ProcessQueuedRecvs(PHWSINST pHws);
  198. void ProcessQueuedSends(PHWSINST pHws);
  199. void SocketCloseEvent (PHWSINST pHws);
  200. DWORD SocketToPhysicalId (SOCKET socket);
  201. BOOL CreateSocketToPhysicalIdMapping(SOCKET socket, DWORD dwPhysicalId);
  202. BOOL RemoveSocketToPhysicalIdMapping(SOCKET socket);
  203. #if defined(__cplusplus)
  204. }
  205. #endif // (__cplusplus)
  206. #endif // H245WS_H