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.

340 lines
7.0 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1990 - 1999
  3. Module Name:
  4. local.h
  5. Abstract:
  6. Header file for Server side EP
  7. Author:
  8. Bharat Shah 2/22/92
  9. Revision History:
  10. 06-03-97 gopalp Added code to cleanup stale EP Mapper entries.
  11. --*/
  12. #ifndef __LOCAL_H__
  13. #define __LOCAL_H__
  14. //#define DBG_DETAIL
  15. #define EP_TABLE_ENTRIES 12
  16. #define CLEANUP_MAGIC_VALUE 0xDECAFBAD
  17. #define PROCESS_MAGIC_VALUE ((CLEANUP_MAGIC_VALUE)+1)
  18. extern HANDLE hEpMapperHeap;
  19. extern CRITICAL_SECTION EpCritSec;
  20. extern CRITICAL_SECTION TableMutex;
  21. extern PIFOBJNode IFObjList;
  22. extern unsigned long cTotalEpEntries;
  23. extern unsigned long GlobalIFOBJid;
  24. extern unsigned long GlobalEPid;
  25. extern PSAVEDCONTEXT GlobalContextList;
  26. extern UUID NilUuid;
  27. extern ProtseqEndpointPair EpMapperTable[EP_TABLE_ENTRIES];
  28. //
  29. // Global thread locking functions
  30. //
  31. #ifdef NTENV
  32. #define CheckInSem() \
  33. ASSERT(EpCritSec.OwningThread == ULongToPtr(GetCurrentThreadId()))
  34. #else
  35. #define CheckInSem()
  36. #endif
  37. #define EnterSem() EnterCriticalSection(&EpCritSec)
  38. #define LeaveSem() LeaveCriticalSection(&EpCritSec)
  39. //
  40. // Allocation routines.
  41. //
  42. _inline void *
  43. AllocMem(
  44. size_t Size
  45. )
  46. {
  47. return (HeapAlloc(hEpMapperHeap, 0, Size));
  48. }
  49. _inline void
  50. FreeMem(
  51. void * pvMem
  52. )
  53. {
  54. HeapFree(hEpMapperHeap, 0, pvMem);
  55. }
  56. //
  57. // Forward definitions
  58. //
  59. PIENTRY
  60. Link(
  61. PIENTRY *ppHead,
  62. PIENTRY pNode
  63. );
  64. PIENTRY
  65. UnLink(
  66. PIENTRY *ppHead,
  67. PIENTRY pNode
  68. );
  69. PIFOBJNode
  70. FindIFOBJVer(
  71. PIFOBJNode *pList,
  72. I_EPENTRY *ep
  73. );
  74. RPC_STATUS
  75. IsNullUuid(
  76. UUID * Uuid
  77. );
  78. RPC_STATUS
  79. GetEntries(
  80. UUID *ObjUuid,
  81. UUID *IFUuid,
  82. ulong ver,
  83. char * pseq,
  84. PSID pSID,
  85. ept_lookup_handle_t *map_lookup_handle,
  86. char * binding,
  87. ulong calltype,
  88. ulong maxrequested,
  89. ulong *returned,
  90. ulong InqType,
  91. ulong VersOpts,
  92. PFNPointer Match
  93. );
  94. RPC_STATUS
  95. PackDataIntoBuffer(
  96. char * * buffer,
  97. PIFOBJNode pNode, PPSEPNode pPSEP,
  98. ulong fType,
  99. BOOL fPatchTower,
  100. int PatchTowerAddress
  101. );
  102. RPC_STATUS
  103. ExactMatch(
  104. PIFOBJNode pNode,
  105. UUID * Obj,
  106. UUID *If,
  107. unsigned long Ver,
  108. PSID pSID,
  109. unsigned long InqType,
  110. unsigned long Options
  111. );
  112. RPC_STATUS
  113. WildCardMatch(
  114. PIFOBJNode pNode,
  115. UUID * Obj,
  116. UUID * If,
  117. unsigned long Vers,
  118. PSID pSID,
  119. unsigned long InqType,
  120. unsigned long Options
  121. );
  122. RPC_STATUS
  123. SearchIFObjNode(
  124. PIFOBJNode pNode,
  125. UUID * Obj,
  126. UUID * If,
  127. unsigned long Vers,
  128. PSID pSID,
  129. unsigned long InqType,
  130. unsigned long Options
  131. );
  132. RPC_STATUS
  133. StartServer(
  134. );
  135. VOID
  136. LinkAtEnd(
  137. PIFOBJNode *Head,
  138. PIFOBJNode Node
  139. );
  140. RPC_STATUS RPC_ENTRY
  141. GetForwardEp(
  142. UUID *IfId,
  143. RPC_VERSION * IFVersion,
  144. UUID * Object,
  145. unsigned char* Protseq,
  146. void * * EpString
  147. );
  148. //
  149. // Link list manipulation rountines
  150. //
  151. RPC_STATUS
  152. EnLinkOnIFOBJList(
  153. PEP_CLEANUP ProcessCtxt,
  154. PIFOBJNode NewNode
  155. );
  156. RPC_STATUS
  157. UnLinkFromIFOBJList(
  158. PEP_CLEANUP ProcessCtxt,
  159. PIFOBJNode DeleteMe
  160. );
  161. #define EnLinkOnPSEPList(x,p) \
  162. \
  163. (PPSEPNode) \
  164. Link( \
  165. (PIENTRY *)(x), \
  166. (PIENTRY)(p) \
  167. )
  168. #define EnLinkContext(p) \
  169. \
  170. (PSAVEDCONTEXT) \
  171. Link( \
  172. (PIENTRY *)(&GlobalContextList),\
  173. (PIENTRY)(p) \
  174. )
  175. #define UnLinkContext(p) \
  176. \
  177. (PSAVEDCONTEXT) \
  178. UnLink( \
  179. (PIENTRY *)&GlobalContextList, \
  180. (PIENTRY) (p) \
  181. )
  182. #define UnLinkFromPSEPList(x,p) \
  183. \
  184. (PPSEPNode) \
  185. UnLink( \
  186. (PIENTRY *)(x), \
  187. (PIENTRY)(p) \
  188. )
  189. #define MatchByIFOBJKey(x, p) \
  190. \
  191. (PIFOBJNode) \
  192. MatchByKey( \
  193. (PIENTRY)(x), \
  194. (ulong)(p) \
  195. )
  196. #define MatchByPSEPKey(x, p) \
  197. \
  198. (PPSEPNode) \
  199. MatchByKey( \
  200. (PIENTRY)(x), \
  201. (ulong)(p) \
  202. )
  203. #define MAXIFOBJID (256L)
  204. #define MAKEGLOBALIFOBJID(x) ( ( ((x-1) % MAXIFOBJID) << 24 ) & 0xFF000000L )
  205. #define MAKEGLOBALEPID(x,y) ( ( ((x) &0xFF000000L) | ((y) & 0x00FFFFFFL) ) )
  206. #define IFOBJSIGN (0x49464F42L)
  207. #define PSEPSIGN (0x50534550L)
  208. #define FREE (0xBADDC0DEL)
  209. //
  210. // Error Codes Here ??
  211. //
  212. #define EP_LOOKUP 0x00000001L
  213. #define EP_MAP 0x00000002L
  214. #define RPC_C_EP_ALL_ELTS 0
  215. #define RPC_C_EP_MATCH_BY_IF 1
  216. #define RPC_C_EP_MATCH_BY_OBJ 2
  217. #define RPC_C_EP_MATCH_BY_BOTH 3
  218. #define I_RPC_C_VERS_UPTO_AND_COMPATIBLE 6
  219. #define VERSION(x,y) ( ((0x0000FFFFL & x)<<16) | (y) )
  220. //
  221. // States of listening..
  222. //
  223. #define NOTSTARTED 0
  224. #define STARTINGTOLISTEN 1
  225. #define STARTED 2
  226. //
  227. // IP Port Management stuff
  228. //
  229. // Each server process connected to the endpoint mapper
  230. // keeps on an open context handle so that rpcss can
  231. // clean up the database when a process dies.
  232. // The PROCESS struct is the context handle.
  233. typedef struct _IP_PORT
  234. {
  235. struct _IP_PORT *pNext;
  236. USHORT Type;
  237. USHORT Port;
  238. } IP_PORT;
  239. typedef struct _PROCESS
  240. {
  241. DWORD MagicVal;
  242. //
  243. // Zero if the process doesn't own any reserved IP ports.
  244. //
  245. IP_PORT *pPorts;
  246. } PROCESS;
  247. typedef struct _PORT_RANGE
  248. {
  249. struct _PORT_RANGE *pNext;
  250. USHORT Max; // Inclusive
  251. USHORT Min; // Inclusive
  252. } PORT_RANGE;
  253. #ifdef DBG
  254. void CountProcessContextList(EP_CLEANUP *pProcessContext, unsigned long nExpectedCount);
  255. #define ASSERT_PROCESS_CONTEXT_LIST_COUNT(p, c) \
  256. CountProcessContextList(p, c)
  257. #else
  258. #define ASSERT_PROCESS_CONTEXT_LIST_COUNT(p, c)
  259. #endif
  260. #endif // __LOCAL_H__