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.

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