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.

162 lines
7.3 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation
  4. //
  5. // File: rpselect.h
  6. //
  7. // Contents: Function & Data Structure prototypes for replica selection.
  8. //
  9. // Classes:
  10. //
  11. // Functions: ReplFindFirstProvider - find first appropriate provider and
  12. // initialize the select context.
  13. // ReplFindNextProvider - get next provider from the list of
  14. // providers based on an initialized select context.
  15. // ReplSetActiveService - a courtesy routine to tell replica
  16. // selection that a particular service "worked". Will
  17. // cause this service to be the first one to be tried
  18. // on subsequent calls to FindFirst.
  19. // ReplIsRecoverableError - see if error code is something worth
  20. // trying a replica for.
  21. //
  22. // Data Structures:
  23. // REPL_SELECT_CONTEXT
  24. //
  25. // History: 02 Sep 92 MilanS created.
  26. //
  27. //-----------------------------------------------------------------------------
  28. #ifndef _RPSELECT_
  29. #define _RPSELECT_
  30. //
  31. // This structure is supposed to be opaque to the user of this module.
  32. // It should only be used to create select contexts to be passed to
  33. // FindFirstProvider and FindNextProvider.
  34. //
  35. typedef struct _REPL_SELECT_CONTEXT {
  36. unsigned short Flags;
  37. ULONG iFirstSvcIndex; // index of first svc
  38. ULONG iSvcIndex; // index of the last svc
  39. // returned to caller.
  40. } REPL_SELECT_CONTEXT, *PREPL_SELECT_CONTEXT;
  41. //
  42. // Define flags for SelectContext structures.
  43. //
  44. #define REPL_UNINITIALIZED 0x0001
  45. #define REPL_SVC_IS_LOCAL 0x0002
  46. #define REPL_SVC_IS_REMOTE 0x0004
  47. #define REPL_PRINCIPAL_SPECD 0x0008
  48. #define REPL_NO_MORE_ENTRIES 0x0010
  49. NTSTATUS
  50. ReplFindFirstProvider(
  51. IN PDFS_PKT_ENTRY pPktEntry, // for which a svc is needed
  52. IN GUID *pidPrincipal, // look for this service
  53. IN PUNICODE_STRING pustrPrincipal, // or look for this service
  54. OUT PDFS_SERVICE *ppService, // return selected service
  55. OUT PREPL_SELECT_CONTEXT pSelectContext, // Context to be initialized.
  56. OUT BOOLEAN *pLastEntry // Last entry
  57. );
  58. NTSTATUS
  59. ReplFindNextProvider(
  60. IN PDFS_PKT_ENTRY pPktEntry, // for which another svc is
  61. OUT PDFS_SERVICE *ppService, // needed.
  62. IN OUT PREPL_SELECT_CONTEXT pSelectContext, // Context to use
  63. OUT BOOLEAN *pLastEntry // Last entry
  64. );
  65. PPROVIDER_DEF
  66. ReplLookupProvider(ULONG ProviderId);
  67. //+----------------------------------------------------------------------------
  68. //
  69. // Function: ReplSetActiveService
  70. //
  71. // Synopsis: Sets the ActiveService pointer of a PKT Entry. This is an
  72. // Optimization. People who later look for a service for this
  73. // PKT Entry will be asked to look at the ActiveService first.
  74. //
  75. // Arguments: [pPktEntry] Pointer to PKT Entry.
  76. // [SelectContext] Initialized Select Context returned by
  77. // FindFirst or FindNext.
  78. //
  79. // Returns: Nothing
  80. //
  81. // Notes: For now, this is a #define. Later, when we support multi-
  82. // threaded operation, we can change it to a function that tests
  83. // whether the Pkt Entry has changed under it etc.
  84. //
  85. //-----------------------------------------------------------------------------
  86. #define ReplSetActiveService(p,s) \
  87. { \
  88. if ((s).Flags & REPL_SVC_IS_REMOTE ) { \
  89. (p)->ActiveService = &(p)->Info.ServiceList[(s).iSvcIndex]; \
  90. if ((p)->ActiveService->pMachEntry != NULL) { \
  91. InterlockedIncrement( \
  92. &(p)->ActiveService->pMachEntry->ConnectionCount); \
  93. } \
  94. } \
  95. }
  96. //+----------------------------------------------------------------------------
  97. //
  98. // Function: ReplIsRecoverableError
  99. //
  100. // Synopsis: True if the argument is an NTSTATUS error code for which it
  101. // makes sense to try a replica if one is available.
  102. //
  103. // Arguments: [x] - The NTSTATUS error code to be tested.
  104. //
  105. // Returns: True / False
  106. //
  107. // Notes: For now, this is simply #defined to be a relatively big OR
  108. // statement that tests for a bunch of specific error codes. If we
  109. // need to test for more error codes, it might be worth organizing
  110. // them into a hash table, which can then quickly be tested.
  111. //
  112. // My initial estimates are that a hash table with either a modulo
  113. // or multiplication hash function will become cheaper at around
  114. // 7-8 error codes, assuming clock cycle estimates of x86. A tree
  115. // type organization becomes effective after 10 error codes. The
  116. // problem with the latter is generating at compile time a
  117. // static, balanced tree.
  118. //
  119. //-----------------------------------------------------------------------------
  120. #define ReplIsRecoverableError(x) ( (x) == STATUS_IO_TIMEOUT || \
  121. (x) == STATUS_REMOTE_NOT_LISTENING || \
  122. (x) == STATUS_VIRTUAL_CIRCUIT_CLOSED || \
  123. (x) == STATUS_BAD_NETWORK_PATH || \
  124. (x) == STATUS_NETWORK_BUSY || \
  125. (x) == STATUS_INVALID_NETWORK_RESPONSE || \
  126. (x) == STATUS_UNEXPECTED_NETWORK_ERROR || \
  127. (x) == STATUS_NETWORK_NAME_DELETED || \
  128. (x) == STATUS_BAD_NETWORK_NAME || \
  129. (x) == STATUS_REQUEST_NOT_ACCEPTED || \
  130. (x) == STATUS_DISK_OPERATION_FAILED || \
  131. (x) == STATUS_DEVICE_OFF_LINE || \
  132. (x) == STATUS_NETWORK_UNREACHABLE || \
  133. (x) == STATUS_INSUFFICIENT_RESOURCES || \
  134. (x) == STATUS_SHARING_PAUSED || \
  135. (x) == STATUS_DFS_UNAVAILABLE || \
  136. (x) == STATUS_NO_SUCH_DEVICE || \
  137. (x) == STATUS_NETLOGON_NOT_STARTED || \
  138. (x) == STATUS_UNMAPPABLE_CHARACTER || \
  139. (x) == STATUS_CONNECTION_DISCONNECTED || \
  140. (x) == STATUS_USER_SESSION_DELETED || \
  141. (x) == STATUS_NO_SUCH_LOGON_SESSION \
  142. )
  143. #endif