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.

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