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.

327 lines
6.7 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. or.hxx
  5. Abstract:
  6. C++ include for C++ OR modules.
  7. Author:
  8. Mario Goertzel [mariogo] Feb-10-95
  9. Revision History:
  10. --*/
  11. #ifndef __OR_HXX
  12. #define __OR_HXX
  13. #include <or.h>
  14. // Protcol defined timeouts
  15. const unsigned short BasePingInterval = 120;
  16. const unsigned short BaseNumberOfPings = 3;
  17. const unsigned short BaseTimeoutInterval = (BasePingInterval * BaseNumberOfPings);
  18. // Max number of OIDs to rundown in one call
  19. #define MAX_OID_RUNDOWNS_PER_CALL 21
  20. // Well known tower IDs
  21. const unsigned short ID_LPC = 0x10; // ncalrpc, IsLocal() == TRUE
  22. const unsigned short ID_NP = 0x0F; // ncacn_np, IsLocal() == FALSE
  23. const unsigned short ID_UDP = 0x08; // ncadg_ip_udp
  24. const unsigned short ID_TCP = 0x07; // ncacn_ip_tcp
  25. const unsigned short ID_IPX = 0x0E; // ncacn_ipx
  26. const unsigned short ID_DCOMHTTP = 0x1F;
  27. //
  28. // Globals
  29. //
  30. extern ID gLocalMid; // MID of the string bindings of this machine.
  31. // Building blocks
  32. #include <time.hxx>
  33. #include <locks.hxx>
  34. #include <string.hxx>
  35. #include <misc.hxx>
  36. #include <callid.hxx>
  37. #include <blist.hxx>
  38. #include <refobj.hxx>
  39. #include <list.hxx>
  40. #include <plist.hxx>
  41. #include <gentable.hxx>
  42. #include <idtable.hxx>
  43. // I am #undefing this because by the time we get here, it has
  44. // already been defined (in propstm.hxx) and I don't see an easy
  45. // way of doing a conditional defn in either header. (it is
  46. // also defined in winsock2.h)
  47. #undef LITTLEENDIAN
  48. #include <winsock2.h>
  49. //
  50. // Class forward declarations
  51. //
  52. class CProcess;
  53. class CToken;
  54. class CServerSet;
  55. class CServerOxid;
  56. class CServerOid;
  57. class CClientSet;
  58. class CClientOxid;
  59. class CClientOid;
  60. class CServerSetTable;
  61. //
  62. // Global tables, plists and locks
  63. //
  64. extern CSharedLock *gpServerLock;
  65. extern CSharedLock *gpClientLock;
  66. extern CSharedLock *gpIPCheckLock;
  67. extern CHashTable *gpServerOidTable;
  68. extern CServerOidPList *gpServerOidPList;
  69. extern CList *gpServerPinnedOidList;
  70. extern CHashTable *gpClientOidTable;
  71. extern CHashTable *gpServerOxidTable;
  72. extern CHashTable *gpClientOxidTable;
  73. extern CPList *gpClientOxidPList;
  74. extern CServerSetTable *gpServerSetTable;
  75. extern CHashTable *gpClientSetTable;
  76. extern CPList *gpClientSetPList;
  77. extern CList *gpTokenList;
  78. extern CHashTable *gpMidTable;
  79. extern DWORD gNextThreadID;
  80. // Headers which may use globals
  81. #include <partitions.h> // token.hxx needs IUserToken
  82. #include <token.hxx>
  83. #include <process.hxx>
  84. #include <mid.hxx>
  85. #include <cset.hxx>
  86. #include <coxid.hxx>
  87. #include <coid.hxx>
  88. #include <sset.hxx>
  89. #include <soxid.hxx>
  90. #include <soid.hxx>
  91. //
  92. // Prototypes
  93. //
  94. void *ComputeSvcList( const DUALSTRINGARRAY *pBinding );
  95. BOOL ValidAuthnSvc( const DUALSTRINGARRAY *pBinding, USHORT wService );
  96. //
  97. // REG_MULTI_SZ array of protseqs to listen on.
  98. //
  99. extern PWSTR gpwstrProtseqs;
  100. //
  101. // Count and array of remote protseq's used by this OR.
  102. //
  103. extern USHORT cMyProtseqs;
  104. extern USHORT *aMyProtseqs;
  105. //
  106. // Security data passed to processes on connect.
  107. //
  108. extern BOOL s_fEnableDCOM;
  109. extern BOOL s_fCatchServerExceptions;
  110. extern BOOL s_fBreakOnSilencedServerExceptions;
  111. extern DWORD s_lAuthnLevel;
  112. extern DWORD s_lImpLevel;
  113. extern BOOL s_fMutualAuth;
  114. extern BOOL s_fSecureRefs;
  115. extern HKEY s_hOle;
  116. extern DWORD s_cRpcssSvc;
  117. extern SECPKG *s_aRpcssSvc;
  118. //Com Internet services stuff
  119. extern BOOL s_fEnableDCOMHTTP;
  120. extern BOOL g_fClientHttp;
  121. extern BOOL IsHttpClient();
  122. // Configuration info retrieval\cleanup functions
  123. BOOL
  124. GetLegacySecurity(
  125. WCHAR** ppszLegacySecurity
  126. );
  127. void
  128. SetLegacySecurity(
  129. WCHAR* pszLegacySecurity,
  130. DWORD dwDataSize
  131. );
  132. void
  133. SetClientServerSvcs(
  134. DWORD cClientSvcs,
  135. SECPKG* aClientSvcs,
  136. DWORD cServerSvcs,
  137. USHORT* aServerSvcs
  138. );
  139. BOOL
  140. GetClientServerSvcs(
  141. DWORD* pcClientSvcs,
  142. SECPKG** paClientSvcs,
  143. DWORD* pcServerSvcs,
  144. USHORT** paServerSvcs
  145. );
  146. void
  147. CleanupClientServerSvcs(
  148. DWORD cClientSvcs,
  149. SECPKG* aClientSvcs,
  150. DWORD cServerSvcs, // unused
  151. USHORT* aServerSvcs
  152. );
  153. #ifndef __ACT_HXX__
  154. #pragma hdrstop
  155. #endif
  156. class CParallelPing;
  157. // Parallel Ping base class
  158. struct PROTSEQINFO
  159. {
  160. RPC_BINDING_HANDLE hRpc;
  161. union
  162. {
  163. PVOID pvUserInfo;
  164. DWORD dwUserInfo;
  165. };
  166. };
  167. void ServerAliveAPC( IN PRPC_ASYNC_STATE pAsync,
  168. IN void *Context,
  169. IN RPC_ASYNC_EVENT flags) ;
  170. #define PARALLEL_PING_STAGGER_TIME 1000
  171. #define _alloca_free(x)
  172. #define REALLOC(a, f, t, v, oldCount, newCount, sc) \
  173. { \
  174. t *tmp = (t *) a((newCount) * sizeof(t)); \
  175. if (tmp) \
  176. { \
  177. if (oldCount) \
  178. { \
  179. memcpy(tmp, v, (oldCount) * sizeof(t)); \
  180. f(v); \
  181. } \
  182. sc = RPC_S_OK; \
  183. v = tmp; \
  184. } \
  185. else \
  186. sc = E_OUTOFMEMORY; \
  187. }
  188. class CParallelPing
  189. {
  190. public:
  191. CParallelPing() :
  192. _pProtseqInfo(NULL),
  193. _cHandles(0),
  194. _cProtseqMax(0),
  195. _pWinner(NULL),
  196. _pdsaOrBindings(NULL),
  197. _sc(RPC_S_SERVER_UNAVAILABLE)
  198. {}
  199. ~CParallelPing()
  200. {
  201. MIDL_user_free(_pdsaOrBindings);
  202. }
  203. void Reset()
  204. {
  205. for (ULONG i=0; i<_cHandles; i++)
  206. {
  207. ReleaseCall(_pProtseqInfo + i);
  208. }
  209. MIDL_user_free(_pProtseqInfo);
  210. _cHandles = 0;
  211. _pProtseqInfo = 0;
  212. _cProtseqMax = 0;
  213. }
  214. virtual BOOL NextCall(PROTSEQINFO *) = 0;
  215. virtual void ReleaseCall(PROTSEQINFO *) = 0;
  216. RPC_STATUS Ping();
  217. PROTSEQINFO *GetWinner() { return _pWinner;}
  218. void ServerAliveWork( PRPC_ASYNC_STATE pAsyncState,
  219. RPC_STATUS scBegin);
  220. ULONG HandleCount() { return _cHandles;}
  221. PROTSEQINFO *Info(ULONG ndx)
  222. { return _pProtseqInfo ? _pProtseqInfo + ndx : NULL; }
  223. CDualStringArray *TakeOrBindings()
  224. {
  225. CDualStringArray *pTmp = NULL;
  226. if (_pdsaOrBindings)
  227. {
  228. pTmp = new CDualStringArray(_pdsaOrBindings);
  229. if (pTmp)
  230. _pdsaOrBindings = NULL;
  231. }
  232. return pTmp;
  233. }
  234. private:
  235. ULONG _cHandles;
  236. ULONG _cCalls;
  237. ULONG _cReceived;
  238. ULONG _ndxWinner;
  239. ULONG _cProtseqMax;
  240. PRPC_ASYNC_STATE *_arAsyncCallInfo;
  241. RPC_STATUS _sc;
  242. COMVERSION _tmpComVersion;
  243. DUALSTRINGARRAY *_tmpOrBindings;
  244. DWORD _tmpReserved;
  245. DUALSTRINGARRAY *_pdsaOrBindings;
  246. PROTSEQINFO *_pProtseqInfo;
  247. PROTSEQINFO *_pWinner;
  248. };
  249. #endif // __OR_HXX