Windows NT 4.0 source code leak
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.

154 lines
6.4 KiB

4 years ago
  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. );
  57. NTSTATUS
  58. ReplFindNextProvider(
  59. IN PDFS_PKT_ENTRY pPktEntry, // for which another svc is
  60. OUT PDFS_SERVICE *ppService, // needed.
  61. IN OUT PREPL_SELECT_CONTEXT pSelectContext
  62. );
  63. PPROVIDER_DEF
  64. ReplLookupProvider(ULONG ProviderId);
  65. //+----------------------------------------------------------------------------
  66. //
  67. // Function: ReplSetActiveService
  68. //
  69. // Synopsis: Sets the ActiveService pointer of a PKT Entry. This is an
  70. // Optimization. People who later look for a service for this
  71. // PKT Entry will be asked to look at the ActiveService first.
  72. //
  73. // Arguments: [pPktEntry] Pointer to PKT Entry.
  74. // [SelectContext] Initialized Select Context returned by
  75. // FindFirst or FindNext.
  76. //
  77. // Returns: Nothing
  78. //
  79. // Notes: For now, this is a #define. Later, when we support multi-
  80. // threaded operation, we can change it to a function that tests
  81. // whether the Pkt Entry has changed under it etc.
  82. //
  83. //-----------------------------------------------------------------------------
  84. #define ReplSetActiveService(p,s) \
  85. { \
  86. if ((s).Flags & REPL_SVC_IS_REMOTE ) { \
  87. (p)->ActiveService = &(p)->Info.ServiceList[(s).iSvcIndex]; \
  88. if ((p)->ActiveService->pMachEntry != NULL) { \
  89. ExInterlockedIncrementLong( \
  90. &(p)->ActiveService->pMachEntry->ConnectionCount, \
  91. &DfsData.Pkt.UseCountLock); \
  92. } \
  93. } \
  94. }
  95. //+----------------------------------------------------------------------------
  96. //
  97. // Function: ReplIsRecoverableError
  98. //
  99. // Synopsis: True if the argument is an NTSTATUS error code for which it
  100. // makes sense to try a replica if one is available.
  101. //
  102. // Arguments: [x] - The NTSTATUS error code to be tested.
  103. //
  104. // Returns: True / False
  105. //
  106. // Notes: For now, this is simply #defined to be a relatively big OR
  107. // statement that tests for a bunch of specific error codes. If we
  108. // need to test for more error codes, it might be worth organizing
  109. // them into a hash table, which can then quickly be tested.
  110. //
  111. // My initial estimates are that a hash table with either a modulo
  112. // or multiplication hash function will become cheaper at around
  113. // 7-8 error codes, assuming clock cycle estimates of x86. A tree
  114. // type organization becomes effective after 10 error codes. The
  115. // problem with the latter is generating at compile time a
  116. // static, balanced tree.
  117. //
  118. //-----------------------------------------------------------------------------
  119. // BUGBUG - Need a complete list.
  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_NO_SUCH_DEVICE \
  133. )
  134. #endif