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.

336 lines
6.7 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. ept_lookup_handle_t *map_lookup_handle,
  85. char * binding,
  86. ulong calltype,
  87. ulong maxrequested,
  88. ulong *returned,
  89. ulong InqType,
  90. ulong VersOpts,
  91. PFNPointer Match
  92. );
  93. RPC_STATUS
  94. PackDataIntoBuffer(
  95. char * * buffer,
  96. PIFOBJNode pNode, PPSEPNode pPSEP,
  97. ulong fType,
  98. BOOL fPatchTower,
  99. int PatchTowerAddress
  100. );
  101. RPC_STATUS
  102. ExactMatch(
  103. PIFOBJNode pNode,
  104. UUID * Obj,
  105. UUID *If,
  106. unsigned long Ver,
  107. unsigned long InqType,
  108. unsigned long Options
  109. );
  110. RPC_STATUS
  111. WildCardMatch(
  112. PIFOBJNode pNode,
  113. UUID * Obj,
  114. UUID * If,
  115. unsigned long Vers,
  116. unsigned long InqType,
  117. unsigned long Options
  118. );
  119. RPC_STATUS
  120. SearchIFObjNode(
  121. PIFOBJNode pNode,
  122. UUID * Obj,
  123. UUID * If,
  124. unsigned long Vers,
  125. unsigned long InqType,
  126. unsigned long Options
  127. );
  128. RPC_STATUS
  129. StartServer(
  130. );
  131. VOID
  132. LinkAtEnd(
  133. PIFOBJNode *Head,
  134. PIFOBJNode Node
  135. );
  136. RPC_STATUS RPC_ENTRY
  137. GetForwardEp(
  138. UUID *IfId,
  139. RPC_VERSION * IFVersion,
  140. UUID * Object,
  141. unsigned char* Protseq,
  142. void * * EpString
  143. );
  144. //
  145. // Link list manipulation rountines
  146. //
  147. RPC_STATUS
  148. EnLinkOnIFOBJList(
  149. PEP_CLEANUP ProcessCtxt,
  150. PIFOBJNode NewNode
  151. );
  152. RPC_STATUS
  153. UnLinkFromIFOBJList(
  154. PEP_CLEANUP ProcessCtxt,
  155. PIFOBJNode DeleteMe
  156. );
  157. #define EnLinkOnPSEPList(x,p) \
  158. \
  159. (PPSEPNode) \
  160. Link( \
  161. (PIENTRY *)(x), \
  162. (PIENTRY)(p) \
  163. )
  164. #define EnLinkContext(p) \
  165. \
  166. (PSAVEDCONTEXT) \
  167. Link( \
  168. (PIENTRY *)(&GlobalContextList),\
  169. (PIENTRY)(p) \
  170. )
  171. #define UnLinkContext(p) \
  172. \
  173. (PSAVEDCONTEXT) \
  174. UnLink( \
  175. (PIENTRY *)&GlobalContextList, \
  176. (PIENTRY) (p) \
  177. )
  178. #define UnLinkFromPSEPList(x,p) \
  179. \
  180. (PPSEPNode) \
  181. UnLink( \
  182. (PIENTRY *)(x), \
  183. (PIENTRY)(p) \
  184. )
  185. #define MatchByIFOBJKey(x, p) \
  186. \
  187. (PIFOBJNode) \
  188. MatchByKey( \
  189. (PIENTRY)(x), \
  190. (ulong)(p) \
  191. )
  192. #define MatchByPSEPKey(x, p) \
  193. \
  194. (PPSEPNode) \
  195. MatchByKey( \
  196. (PIENTRY)(x), \
  197. (ulong)(p) \
  198. )
  199. #define MAXIFOBJID (256L)
  200. #define MAKEGLOBALIFOBJID(x) ( ( ((x-1) % MAXIFOBJID) << 24 ) & 0xFF000000L )
  201. #define MAKEGLOBALEPID(x,y) ( ( ((x) &0xFF000000L) | ((y) & 0x00FFFFFFL) ) )
  202. #define IFOBJSIGN (0x49464F42L)
  203. #define PSEPSIGN (0x50534550L)
  204. #define FREE (0xBADDC0DEL)
  205. //
  206. // Error Codes Here ??
  207. //
  208. #define EP_LOOKUP 0x00000001L
  209. #define EP_MAP 0x00000002L
  210. #define RPC_C_EP_ALL_ELTS 0
  211. #define RPC_C_EP_MATCH_BY_IF 1
  212. #define RPC_C_EP_MATCH_BY_OBJ 2
  213. #define RPC_C_EP_MATCH_BY_BOTH 3
  214. #define I_RPC_C_VERS_UPTO_AND_COMPATIBLE 6
  215. #define VERSION(x,y) ( ((0x0000FFFFL & x)<<16) | (y) )
  216. //
  217. // States of listening..
  218. //
  219. #define NOTSTARTED 0
  220. #define STARTINGTOLISTEN 1
  221. #define STARTED 2
  222. //
  223. // IP Port Management stuff
  224. //
  225. // Each server process connected to the endpoint mapper
  226. // keeps on an open context handle so that rpcss can
  227. // clean up the database when a process dies.
  228. // The PROCESS struct is the context handle.
  229. typedef struct _IP_PORT
  230. {
  231. struct _IP_PORT *pNext;
  232. USHORT Type;
  233. USHORT Port;
  234. } IP_PORT;
  235. typedef struct _PROCESS
  236. {
  237. DWORD MagicVal;
  238. //
  239. // Zero if the process doesn't own any reserved IP ports.
  240. //
  241. IP_PORT *pPorts;
  242. } PROCESS;
  243. typedef struct _PORT_RANGE
  244. {
  245. struct _PORT_RANGE *pNext;
  246. USHORT Max; // Inclusive
  247. USHORT Min; // Inclusive
  248. } PORT_RANGE;
  249. #ifdef DBG
  250. void CountProcessContextList(EP_CLEANUP *pProcessContext, unsigned long nExpectedCount);
  251. #define ASSERT_PROCESS_CONTEXT_LIST_COUNT(p, c) \
  252. CountProcessContextList(p, c)
  253. #else
  254. #define ASSERT_PROCESS_CONTEXT_LIST_COUNT(p, c)
  255. #endif
  256. #endif // __LOCAL_H__