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.

251 lines
5.8 KiB

  1. /*++
  2. Microsoft Windows NT RPC Name Service
  3. Copyright (C) Microsoft Corporation, 1995 - 1999
  4. Module Name:
  5. globals.hxx
  6. Abstract:
  7. This module, contains all global definitions and declarations needed by
  8. other modules, except those which depend on locator-related classes.
  9. The latter are in "var.hxx".
  10. Author:
  11. Satish Thatte (SatishT) 08/16/95 Created all the code below except where
  12. otherwise indicated.
  13. --*/
  14. #ifndef _GLOBALS_
  15. #define _GLOBALS_
  16. typedef unsigned short STATUS;
  17. #ifndef TRUE
  18. #define TRUE 1
  19. #define FALSE 0
  20. #endif
  21. #define IN // Attributes to describe parms on functions
  22. #define OUT // for documention purposes only.
  23. #define IO
  24. #define OPT
  25. #define WNL TEXT("\n")
  26. // extern RPC_SYNTAX_IDENTIFIER NilSyntaxID;
  27. // extern NSI_INTERFACE_ID_T NilNsiIfIdOnWire;
  28. // extern NSI_UUID_T NilGlobalID;
  29. const WCHAR NSnameDelimiter = L'/';
  30. const WCHAR WStringTerminator = UNICODE_NULL;
  31. #define RelativePrefix TEXT("/.:/")
  32. #define GlobalPrefix TEXT("/.../")
  33. #define LDAPPrefix TEXT("LDAP:")
  34. #define RelativePrefixLength 4
  35. #define GlobalPrefixLength 5
  36. #define LDAPPrefixLength 5
  37. #define DSDomainBeginLength 2
  38. #define DSDomainEndLength 1
  39. #define X500NameDelimiter TEXT("/CN=")
  40. #define DNNamePrefix TEXT("CN=")
  41. #define DNNameDelimiter TEXT(",")
  42. #define DSDomainBegin TEXT("//")
  43. #define DSDomainEnd TEXT('/')
  44. #define DSDomainEndStr TEXT("/")
  45. #define X500NameDelimiterLength 4
  46. #define DNNamePrefixLength 3
  47. #define DNNameDelimiterLength 1
  48. // need to regularize these codes --
  49. // punt for now since we are cloning the old locator
  50. #define NSI_S_ENTRY_TYPE_MISMATCH 1112
  51. #define NSI_S_INTERNAL_ERROR 1113
  52. #define NSI_S_CORRUPTED_ENTRY 1114
  53. #define NSI_S_HEAP_TRASHED 1115
  54. #define NSI_S_UNMARSHALL_UNSUCCESSFUL 1116
  55. #define NSI_S_UNSUPPORTED_BUFFER_TYPE 1117
  56. #define NSI_S_ENTRY_NO_NEW_INFO 1118
  57. #define NSI_S_DC_BINDING_FAILURE 1119
  58. #define NSI_S_MAILSLOT_ERROR 1120
  59. // This needs to go into rpcdce.h --
  60. // punt for now since we are cloning the old locator
  61. #define RPC_C_BINDING_MAX_COUNT 100
  62. #define RPC_NS_HANDLE_LIFETIME 300 // this is in seconds
  63. #define RPC_NS_MAX_CALLS 100
  64. #define RPC_NS_MAX_THREADS 200
  65. #define NET_REPLY_INITIAL_TIMEOUT 10000
  66. #define CONNECTION_TIMEOUT 10
  67. /* The following four constants affect compatibility with the old locator */
  68. #define MAX_DOMAIN_NAME_LENGTH 20 // this is dictated by the old locator
  69. #define MAX_ENTRY_NAME_LENGTH 100 // this is dictated by the old locator
  70. #define NET_REPLY_BUFFER_SIZE 1000 // this is dictated by the old locator
  71. #define NET_REPLY_MAILSLOT_BUFFER_SIZE 350 // nt5 mailslot size. This should be the size used
  72. // in marshalling. Unmarshall uses the bigger size.
  73. #define INITIAL_MAILSLOT_READ_WAIT 3000 // in milliseconds (for broadcasts)
  74. // The master seems to be timing out.
  75. typedef const WCHAR * const CONST_STRING_T;
  76. #define MAX_CACHE_AGE (2*3600L) // Default expiration age (ditto)
  77. #define CACHE_GRACE 5
  78. /* interval between cleanup of delayed destruct objects, in seconds */
  79. #define RPC_NS_CLEANUP_INTERVAL 300
  80. extern unsigned long CurrentTime(void);
  81. extern unsigned long LocatorCount;
  82. // the version number of locator structure. (number of times locator structure was created.)
  83. extern CReadWriteSection rwLocatorGuard;
  84. void
  85. StopLocator(
  86. char * szReason,
  87. long code = 0
  88. );
  89. STRING_T catenate(
  90. STRING_T pszPrefix,
  91. STRING_T pszSuffix
  92. );
  93. RPC_BINDING_HANDLE
  94. MakeDClocTolocHandle(
  95. STRING_T pszDCName
  96. );
  97. inline void
  98. Raise(unsigned long ErrorCode) {
  99. RaiseException(
  100. ErrorCode,
  101. EXCEPTION_NONCONTINUABLE,
  102. 0,
  103. NULL
  104. );
  105. }
  106. STRING_T
  107. makeBindingStringWithObject(
  108. STRING_T binding,
  109. STRING_T object
  110. );
  111. void NSI_NS_HANDLE_T_done(
  112. /* [out][in] */ NSI_NS_HANDLE_T __RPC_FAR *inq_context,
  113. /* [out] */ UNSIGNED16 __RPC_FAR *status);
  114. BOOL
  115. IsStillCurrent(
  116. ULONG ulCacheTime,
  117. ULONG ulTolerance
  118. );
  119. typedef int (__cdecl * _PNH)( size_t );
  120. void *new_handler(size_t);
  121. STRING_T
  122. makeGlobalName(
  123. const STRING_T szDomainName,
  124. const STRING_T szEntryName
  125. );
  126. extern
  127. RPC_BINDING_HANDLE
  128. ConnectToMasterLocator(
  129. ULONG& Status
  130. );
  131. int
  132. IsNormalCode(
  133. IN ULONG StatusCode
  134. );
  135. void InitializeLocator();
  136. inline int
  137. IsNilIfId(
  138. RPC_SYNTAX_IDENTIFIER* IID
  139. )
  140. /*++
  141. Routine Description:
  142. Check the given interface to see if it has a null UUID in it.
  143. Arguments:
  144. IID - input interface
  145. Returns:
  146. TRUE, FALSE
  147. --*/
  148. {
  149. RPC_STATUS status;
  150. return UuidIsNil(&(IID->SyntaxGUID),&status);
  151. }
  152. unsigned
  153. RandomBit(
  154. unsigned long *pState
  155. );
  156. BOOL
  157. hasWhacksInMachineName(
  158. STRING_T szName
  159. );
  160. enum ExportType {
  161. Local,
  162. NonLocal
  163. };
  164. extern CReadWriteSection rwEntryGuard; // single shared guard for all local entries
  165. extern CReadWriteSection rwNonLocalEntryGuard; // single shared guard for all nonlocal entries
  166. extern CReadWriteSection rwFullEntryGuard; // single shared guard for all full entries
  167. extern CPrivateCriticalSection csBindingBroadcastGuard;
  168. extern CPrivateCriticalSection csMasterBroadcastGuard;
  169. extern CPrivateCriticalSection csDSSettingsGuard; // critical section for reading vals frm DS.
  170. extern BOOL fDC;
  171. BOOL
  172. IsClientLocal (
  173. void
  174. );
  175. #define CheckForLocalClientIfNecessary() \
  176. if (!fDC && !IsClientLocal()) \
  177. { \
  178. RpcRaiseException(RPC_S_ACCESS_DENIED); \
  179. }
  180. #endif // _GLOBALS_