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.

212 lines
8.3 KiB

  1. //--------------------------------------------------------------------
  2. // TimeProv - header
  3. // Copyright (C) Microsoft Corporation, 1999
  4. //
  5. // Created by: Louis Thomas (louisth), 9-2-99
  6. //
  7. // Definitions for time providers
  8. //
  9. #ifndef TIMEPROV_H
  10. #define TIMEPROV_H
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. //--------------------------------------------------------------------
  15. // Registry keys and values
  16. // Each time provider should create their own subkey under this key
  17. // and store their configuration there.
  18. #define wszW32TimeRegKeyTimeProviders L"System\\CurrentControlSet\\Services\\W32Time\\TimeProviders"
  19. // Each time providers configured through policy should create their
  20. // own subkey under this subkey and store their configuration there.
  21. #define wszW32TimeRegKeyPolicyTimeProviders L"Software\\Policies\\Microsoft\\W32Time\\TimeProviders"
  22. // Path: ...\TimeProviders\<PrividerName>\Enabled
  23. // Type: REG_DWORD (cast to BOOL)
  24. // Meaning: If true, this provider will be started by the time service.
  25. #define wszW32TimeRegValueEnabled L"Enabled"
  26. // Path: ...\TimeProviders\<PrividerName>\DllName
  27. // Type: REG_SZ
  28. // Meaning: The dll that contains the provider. The time service will
  29. // call LoadLibrary on this value.
  30. #define wszW32TimeRegValueDllName L"DllName"
  31. // Path: ...\TimeProviders\<PrividerName>\InputProvider
  32. // Type: REG_DWORD (cast to BOOL)
  33. // Meaning: If true, this provider is an input provider, and will be
  34. // called upon to return time samples. If false, this provider
  35. // is an output provider.
  36. #define wszW32TimeRegValueInputProvider L"InputProvider"
  37. //--------------------------------------------------------------------
  38. // types
  39. // Time Source Flags
  40. #define TSF_Hardware 0x00000001
  41. #define TSF_Authenticated 0x00000002
  42. // commands that can be issued through TimeProvCommand
  43. typedef enum TimeProvCmd {
  44. TPC_TimeJumped, // (TpcTimeJumpedArgs *)pvArgs
  45. TPC_UpdateConfig, // (void)pvArgs
  46. TPC_PollIntervalChanged,// (void)pvArgs
  47. TPC_GetSamples, // (TpcGetSamplesArgs *)pvArgs
  48. TPC_NetTopoChange, // (TpcNetTopoChangeArgs *)pvArgs
  49. TPC_Query, // (W32TIME_PROVIDER_STATUS *)pvArgs
  50. TPC_Shutdown, // (void)pvArgs
  51. } TimeProvCmd;
  52. // info that can be requested through GetTimeSysInfo
  53. typedef enum TimeSysInfo {
  54. TSI_LastSyncTime, // (unsigned __int64 *)pvInfo, NtTimeEpoch, in (10^-7)s
  55. TSI_ClockTickSize, // (unsigned __int64 *)pvInfo, NtTimePeriod, in (10^-7)s
  56. TSI_ClockPrecision, // ( signed __int32 *)pvInfo, ClockTickSize, in log2(s)
  57. TSI_CurrentTime, // (unsigned __int64 *)pvInfo, NtTimeEpoch, in (10^-7)s
  58. TSI_PhaseOffset, // ( signed __int64 *)pvInfo, opaque
  59. TSI_TickCount, // (unsigned __int64 *)pvInfo, opaque
  60. TSI_LeapFlags, // ( BYTE *)pvInfo, a warning of an impending leap second or loss of synchronization
  61. TSI_Stratum, // ( BYTE *)pvInfo, how far away the computer is from a reference source
  62. TSI_ReferenceIdentifier, // ( DWORD *)pvInfo, NtpRefId
  63. TSI_PollInterval, // ( signed __int32 *)pvInfo, poll interval, in log2(s)
  64. TSI_RootDelay, // ( signed __int64 *)pvInfo, NtTimeOffset, in (10^-7)s
  65. TSI_RootDispersion, // (unsigned __int64 *)pvInfo, NtTimePeriod, in (10^-7)s
  66. TSI_TSFlags, // ( DWORD *)pvInfo, Time source flags
  67. } TimeSysInfo;
  68. // flags which provide information about a time jump
  69. typedef enum TimeJumpedFlags {
  70. TJF_Default=0,
  71. TJF_UserRequested=1,
  72. };
  73. // flags which provide information about a network topography change
  74. typedef enum NetTopoChangeFlags {
  75. NTC_Default=0,
  76. NTC_UserRequested=1,
  77. };
  78. typedef enum TimeProvState {
  79. TPS_Running,
  80. TPS_Error,
  81. } TimeProvState;
  82. struct SetProviderStatusInfo;
  83. typedef void (__stdcall
  84. SetProviderStatusInfoFreeFunc)
  85. (IN struct SetProviderStatusInfo *pspsi);
  86. // parameter to SetProviderStatusFunc
  87. typedef struct SetProviderStatusInfo {
  88. TimeProvState tpsCurrentState; // IN the new state of the provider.
  89. DWORD dwStratum; // IN the new stratum of the provider.
  90. LPWSTR wszProvName; // IN the name of the provider who's status should be adjusted
  91. HANDLE hWaitEvent; // IN the event to signal when the operation is complete, NULL if notification is not needed
  92. SetProviderStatusInfoFreeFunc *pfnFree; // IN function used to free the struct on completion
  93. HRESULT *pHr; // OUT on completion, set to the result of the operation
  94. DWORD *pdwSysStratum; // OUT on completion, set to the new system stratum
  95. } SetProviderStatusInfo;
  96. // Time Service provided callback to get system state information
  97. typedef HRESULT (__stdcall
  98. GetTimeSysInfoFunc)(
  99. IN TimeSysInfo eInfo,
  100. OUT void * pvInfo
  101. );
  102. // Time Service provided callback to log an event on behalf of the Time Provider.
  103. typedef HRESULT (__stdcall
  104. LogTimeProvEventFunc)(
  105. IN WORD wType,
  106. IN WCHAR * wszProvName,
  107. IN WCHAR * wszMessage);
  108. // Time Service provided callback to inform the system of newly available samples
  109. typedef HRESULT (__stdcall
  110. AlertSamplesAvailFunc)(
  111. void
  112. );
  113. // Time Service provided callback to set the provider's stratum
  114. typedef HRESULT (__stdcall SetProviderStatusFunc)
  115. (IN SetProviderStatusInfo *pspsi);
  116. // All the callbacsk provided by the Time Service to the Time Provider.
  117. typedef struct TimeProvSysCallbacks {
  118. DWORD dwSize;
  119. GetTimeSysInfoFunc * pfnGetTimeSysInfo;
  120. LogTimeProvEventFunc * pfnLogTimeProvEvent;
  121. AlertSamplesAvailFunc * pfnAlertSamplesAvail;
  122. SetProviderStatusFunc * pfnSetProviderStatus;
  123. } TimeProvSysCallbacks;
  124. typedef void * TimeProvArgs;
  125. typedef struct TimeSample {
  126. DWORD dwSize; // size of this structure
  127. DWORD dwRefid; // NtpRefId
  128. signed __int64 toOffset; // NtTimeOffset, in (10^-7)s - difference between local and remote clocks
  129. signed __int64 toDelay; // NtTimeOffset, in (10^-7)s - round trip delay; time packets spent in flight, INCLUDING root delay
  130. unsigned __int64 tpDispersion; // NtTimePeriod, in (10^-7)s - measurement error, INCLUDING root dispersion
  131. unsigned __int64 nSysTickCount; // opaque, must be GetTimeSysInfo(TSI_TickCount)
  132. signed __int64 nSysPhaseOffset; // opaque, must be GetTimeSysInfo(TSI_PhaseOffset)
  133. BYTE nLeapFlags; // a warning of an impending leap second or loss of synchronization
  134. BYTE nStratum; // how far away the computer is from a reference source
  135. DWORD dwTSFlags; // time source flags
  136. WCHAR wszUniqueName[256]; // Admin readable name that uniquely identifies this peer
  137. } TimeSample;
  138. typedef struct TpcGetSamplesArgs {
  139. BYTE * pbSampleBuf;
  140. DWORD cbSampleBuf;
  141. DWORD dwSamplesReturned;
  142. DWORD dwSamplesAvailable;
  143. } TpcGetSamplesArgs;
  144. typedef struct TpcTimeJumpedArgs {
  145. TimeJumpedFlags tjfFlags;
  146. } TpcTimeJumpedArgs;
  147. typedef struct TpcNetTopoChangeArgs {
  148. NetTopoChangeFlags ntcfFlags;
  149. } TpcNetTopoChangeArgs;
  150. // An opaque handle to a Time Provider used by the Time Service to identify an
  151. // opened Provider in a dll. NULL is considered an invalid value.
  152. typedef void * TimeProvHandle;
  153. //--------------------------------------------------------------------
  154. // functions that a Time Provider must implement and export
  155. HRESULT __stdcall
  156. TimeProvOpen(
  157. IN WCHAR * wszName,
  158. IN TimeProvSysCallbacks * pSysCallbacks, // copy this data, do not free it!
  159. OUT TimeProvHandle * phTimeProv);
  160. HRESULT __stdcall
  161. TimeProvCommand(
  162. IN TimeProvHandle hTimeProv,
  163. IN TimeProvCmd eCmd,
  164. IN TimeProvArgs pvArgs);
  165. HRESULT __stdcall
  166. TimeProvClose(
  167. IN TimeProvHandle hTimeProv);
  168. #ifdef __cplusplus
  169. } // <- end extern "C"
  170. #endif
  171. #endif //TIMEPROV_H