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.

170 lines
7.7 KiB

  1. /*
  2. * this is the arasock header
  3. */
  4. #ifndef _ARASOCK_
  5. #define _ARASOCK_
  6. #include <windows.h>
  7. #include <socket.h>
  8. #define PSI_SUCCESS 0
  9. #define AS_PROTFAMILY_NOT_FOUND (WSABASEERR+94)
  10. #define AS_PF_OUT_OF_RANGE (WSABASEERR+95)
  11. #define AS_MAX_TASK 10
  12. #define AS_MAX_SOCK_PER_TASK 5
  13. #define AS_MAX_SOCKET AS_MAX_TASK*AS_MAX_SOCK_PER_TASK
  14. #define AS_STATE_INUSE 0x01 // socket has been reserved, but not bound
  15. #define AS_STATE_AVAILABLE 0x00 // the socket is bound to an address
  16. typedef struct PROTPARAMtag
  17. {
  18. WORD wTypes; // the protocol styles supported, SOCK_DGRAM, SOCK_STREAM, etc
  19. DWORD dwFamilies; // the families we support. usually ours + PF_UNSPEC
  20. #ifndef SHIP_BUILD
  21. WORD wMaxDataSize; // Maximum data size supported by this transport
  22. #endif
  23. } PROTPARAM, *PPROTPARAM, FAR *LPPROTPARAM;
  24. ///////// PSI CALLBACKS to Arador Sockets ////////////////////
  25. int CALLBACK ASclosedProc(SOCKET sock, WORD wResult);
  26. typedef int (CALLBACK *LPFN_CLOSED)(SOCKET sock, WORD wResult);
  27. //////// PSI entry point Prototypes ///////////
  28. int WINAPI PSIinit(LPPROTPARAM lpProtParam, LPFN_CLOSED lpfnLink);
  29. typedef int (WINAPI *LPFN_PSIINIT)(LPPROTPARAM lpProtParam, LPFN_CLOSED lpfnLink);
  30. int WINAPI PSIdeinit(void);
  31. typedef int (WINAPI *LPFN_PSIDEINIT)(void);
  32. int WINAPI PSIopen(SOCKET sock, int nStyle, int nMac, LPFN_CLOSED lpfnClosed);
  33. typedef int (WINAPI *LPFN_PSIOPEN)(SOCKET sock, int nStyle, int nMac, LPFN_CLOSED lpfnClosed);
  34. int WINAPI PSIclose(SOCKET sock);
  35. typedef int (WINAPI *LPFN_PSICLOSE)(SOCKET sock);
  36. int WINAPI PSIbindAddress(SOCKET sock, LPSOCKADDR lpSockAddr, WORD wAddrLen);
  37. typedef int (WINAPI *LPFN_PSIBINDADDRESS)(SOCKET sock, LPSOCKADDR lpSockAddr, WORD wAddrLen);
  38. int WINAPI PSIconnect(SOCKET sock, LPSOCKADDR lpSockAddr, WORD wAddrLen);
  39. typedef int (WINAPI *LPFN_PSICONNECT)(SOCKET sock, LPSOCKADDR lpSockAddr, WORD wAddrLen);
  40. int WINAPI PSIassociate(SOCKET sock, LPSOCKADDR lpSockAddr, WORD wAddrLen);
  41. typedef int (WINAPI *LPFN_PSIASSOCIATE)(SOCKET sock, LPSOCKADDR lpSockAddr, WORD wAddrLen);
  42. int WINAPI PSIlisten(SOCKET sock, int nBacklog);
  43. typedef int (WINAPI *LPFN_PSILISTEN)(SOCKET sock, int nBacklog);
  44. int WINAPI PSIaccept(SOCKET sock, SOCKET sockNew);
  45. typedef int (WINAPI *LPFN_PSIACCEPT)(SOCKET sock, SOCKET sockNew);
  46. int WINAPI PSIsendConnection(SOCKET sock, LPBYTE lpbData, LPWORD lpwDataLen, WORD wFlags);
  47. typedef int (WINAPI *LPFN_PSISENDCONNECTION)(SOCKET sock, LPBYTE lpbData, LPWORD lpwDataLen, WORD wFlags);
  48. int WINAPI PSIrecvConnection(SOCKET sock, LPBYTE lpbData, LPWORD lpwDataLen, WORD wFlags);
  49. typedef int (WINAPI *LPFN_PSIRECVCONNECTION)(SOCKET sock, LPBYTE lpbData, LPWORD lpwDataLen, WORD wFlags);
  50. int WINAPI PSIsendConnectionless(SOCKET sock, LPBYTE lpbData, LPWORD lpwDataLen, WORD wFlags, LPSOCKADDR lpSockAddr, WORD wAddrLen);
  51. typedef int (WINAPI *LPFN_PSISENDCONNECTIONLESS)(SOCKET sock, LPBYTE lpbData, LPWORD lpwDataLen, WORD wFlags, LPSOCKADDR lpSockAddr, WORD wAddrLen);
  52. int WINAPI PSIrecvConnectionless(SOCKET sock, LPBYTE lpbData, LPWORD lpwDataLen, WORD wFlags, LPSOCKADDR lpSockAddr, LPWORD lpwAddrLen);
  53. typedef int (WINAPI *LPFN_PSIRECVCONNECTIONLESS)(SOCKET sock, LPBYTE lpbData, LPWORD lpwDataLen, WORD wFlags, LPSOCKADDR lpSockAddr, LPWORD lpwAddrLen);
  54. int WINAPI PSIgetRemoteName(SOCKET sock, LPSOCKADDR lpSockAddr, LPWORD pwAddrLen);
  55. typedef int (WINAPI *LPFN_PSIGETREMOTENAME)(SOCKET sock, LPSOCKADDR lpSockAddr, LPWORD pwAddrLen);
  56. int WINAPI PSIgetLocalName(SOCKET sock, LPSOCKADDR lpSockAddr, LPWORD pwAddrLen);
  57. typedef int (WINAPI *LPFN_PSIGETLOCALNAME)(SOCKET sock, LPSOCKADDR lpSockAddr, LPWORD pwAddrLen);
  58. int WINAPI PSIregEvent(SOCKET sock, HWND hWnd, WORD wMsg, DWORD dwEvent);
  59. typedef int (WINAPI *LPFN_PSIREGEVENT)(SOCKET sock, HWND hWnd, WORD wMsg, DWORD dwEvent);
  60. int WINAPI PSIsetOption(SOCKET sock, WORD wOptName, LPBYTE lpOptVal, WORD wOptLen);
  61. typedef int (WINAPI *LPFN_PSISETOPTION)(SOCKET sock, WORD wOptName, LPBYTE lpOptVal, WORD wOptLen);
  62. int WINAPI PSIgetOption(SOCKET sock, WORD wOptName, LPBYTE lpOptVal, LPWORD lpwOptLen);
  63. typedef int (WINAPI *LPFN_PSIGETOPTION)(SOCKET sock, WORD wOptName, LPBYTE lpOptVal, LPWORD lpwOptLen);
  64. int WINAPI PSIStartAdvertisement(SOCKET sock, WORD wServerType, LPSTR lpServerName );
  65. typedef int (WINAPI *LPFN_PSISTARTADVT)( SOCKET sock, WORD wServerType, LPSTR lpServerName );
  66. int WINAPI PSIStopAdvertisement(SOCKET sock, WORD wServerType );
  67. typedef int (WINAPI *LPFN_PSISTOPADVT)( SOCKET sock, WORD wServerType);
  68. typedef void (WINAPI *LPFN_PSIFINDSERVERCLOSE)( AWHANDLE hTransaction );
  69. void WINAPI PSIFindServerClose( AWHANDLE hTransaction );
  70. struct hostent FAR * WINAPI PSIFindFirstServer( WORD wServerType, LPSTR lpServerName,
  71. LPAWHANDLE lphTransaction );
  72. typedef struct hostent FAR *(WINAPI *LPFN_PSIFINDFIRSTSERVER)( WORD wServerType,
  73. LPSTR lpServerName, LPAWHANDLE lphTransaction );
  74. struct hostent FAR * WINAPI PSIFindNextServer
  75. ( WORD wServerType,LPSTR lpServerName, AWHANDLE hTransaction );
  76. typedef struct hostent FAR *(WINAPI *LPFN_PSIFINDNEXTSERVER)
  77. ( WORD wServerType, LPSTR lpServerName, AWHANDLE hTransaction );
  78. int WINAPI PSIGetHostByName(LPSTR lpServerName, LPSOCKADDR lpAddr, WORD wBufLen );
  79. typedef int (WINAPI *LPFN_PSIGETHOSTBYNAME)( LPSTR ServerName, LPSOCKADDR lpAddr, WORD wBufLen );
  80. int WINAPI PSIGetLastSocketError ( SOCKET sockParm );
  81. typedef int (WINAPI *LPFN_PSIGETLASTSOCKETERROR)( SOCKET sockParm);
  82. typedef struct PROTFAMILYtag
  83. {
  84. BOOL fInUse;
  85. char lpszProtocol[20];
  86. PROTPARAM ProtParam;
  87. HINSTANCE hinstDll;
  88. LPFN_PSIOPEN PSIopen;
  89. LPFN_PSICLOSE PSIclose;
  90. LPFN_PSIBINDADDRESS PSIbindAddress;
  91. LPFN_PSICONNECT PSIconnect;
  92. LPFN_PSIASSOCIATE PSIassociate;
  93. LPFN_PSILISTEN PSIlisten;
  94. LPFN_PSIACCEPT PSIaccept;
  95. LPFN_PSISENDCONNECTION PSIsendConnection;
  96. LPFN_PSIRECVCONNECTION PSIrecvConnection;
  97. LPFN_PSISENDCONNECTIONLESS PSIsendConnectionless;
  98. LPFN_PSIRECVCONNECTIONLESS PSIrecvConnectionless;
  99. LPFN_PSIGETREMOTENAME PSIgetRemoteName;
  100. LPFN_PSIGETLOCALNAME PSIgetLocalName;
  101. LPFN_PSIREGEVENT PSIregEvent;
  102. LPFN_PSISETOPTION PSIsetOption;
  103. LPFN_PSIGETOPTION PSIgetOption;
  104. LPFN_PSISTARTADVT PSIStartAdvertisement;
  105. LPFN_PSISTOPADVT PSIStopAdvertisement;
  106. LPFN_PSIFINDFIRSTSERVER PSIFindFirstServer;
  107. LPFN_PSIFINDNEXTSERVER PSIFindNextServer;
  108. LPFN_PSIFINDSERVERCLOSE PSIFindServerClose;
  109. LPFN_PSIGETHOSTBYNAME PSIGetHostByName;
  110. } PROTFAMILY, *PPROTFAMILY;
  111. typedef struct AWSOCKHANDLEtag
  112. {
  113. AWHANDLE hProtAwHandle; // handle returned by the transport
  114. WORD wCurrentFamily;
  115. HGLOBAL hMem; // Handle returned by GlobalAlloc
  116. BYTE ServerName[48]; // To store server Name
  117. WORD wServerType; // Cache ServerType
  118. }AWSOCKHANDLE;
  119. typedef AWSOCKHANDLE FAR *LPAWSOCKHANDLE;
  120. typedef struct PERTASKtag
  121. {
  122. BOOL fInUse;
  123. HTASK hTaskId;
  124. WORD wReferenceCount;
  125. WORD wUsedSockets;
  126. WORD wLastError;
  127. struct hostent hent;
  128. #ifdef ATWORK
  129. struct sockaddr sa_list[8];
  130. char FAR * addrlist[16]; // Assume that we will never support more than 8 transports at the
  131. // same time
  132. #endif
  133. } PERTASK, *PPERTASK;
  134. typedef struct SOCKETtag
  135. {
  136. WORD wState; // OR'd list of AS_STATES
  137. WORD wType;
  138. WORD wMac;
  139. int nProtFamily; // we need this array index twice because we do funky poniter stuff
  140. PPROTFAMILY pProtFamily;
  141. PPERTASK pPerTask;
  142. } SOCK, *PSOCK;
  143. int ASinstallProtocolStack(WORD wProtFamily, LPSTR lpszProtocol, LPSTR lpszDllName);
  144. int ASinstallProtocolStacks();
  145. int ASremoveProtocolStack(WORD wProtFamily);
  146. #ifdef IFAX
  147. void ASRemoveProtocolStacks();
  148. #endif
  149. int CALLBACK ASclosedProc(SOCKET sock, WORD wResult);
  150. #ifdef ATWORK
  151. LPVOID myGlobalAlloc( UINT flags, DWORD dwMemSize , HGLOBAL FAR *lpHandle );
  152. HGLOBAL myGlobalFree( HGLOBAL hMem, LPVOID lpMem );
  153. #endif
  154. #endif