Legrand / Raritan / Server Technology Xerus™ JSON-RPC API
Loading...
Searching...
No Matches
DateTime.idl
1/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * Copyright 2009 Raritan Inc. All rights reserved.
4 */
5
6#include <Event.idl>
7
8/**
9 * Device Date and Time Configuration
10 */
11module datetime {
12
13 /**
14 * Date and time configuration methods
15 *
16 * Example to set timezone (id-based approach): @anchor set-timezone-example
17 *
18 * @code{.py}
19 * zoneinfos = getZoneInfos(False)
20 * cfg = getCfg()
21 * cfg.zoneCfg.id = ... # choose zone id from returned zoneinfos
22 * status = setCfg(cfg)
23 * if status != 0: ... # error handling
24 * @endcode
25 */
26 interface DateTime {
27
28 /** Success code */
29 constant int SUCCESS = 0;
30
31 /** NTP server check errors */
32 constant int ERR_NTP_CHECK_INTERNAL = 1;
33 constant int ERR_NTP_CHECK_INVALID_ARGUMENT = 2;
34 constant int ERR_NTP_CHECK_ADDRESS_RESOLVE_ERROR = 3;
35 constant int ERR_NTP_CHECK_AUTH_KEY_ID_UNKNOWN = 4;
36 constant int ERR_NTP_CHECK_NETWORK_OR_HOST_UNREACHABLE = 5;
37 constant int ERR_NTP_CHECK_CONNECTION_REFUSED = 6;
38 constant int ERR_NTP_CHECK_NO_RESPONSE = 7;
39 constant int ERR_NTP_CHECK_RESPONSE_FORMAT_INVALID = 8;
40 constant int ERR_NTP_CHECK_SERVER_VERSION_UNSUPPORTED = 9;
41 constant int ERR_NTP_CHECK_MAC_MISSING_OR_INVALID = 10;
42 constant int ERR_NTP_CHECK_MODE_INVALID = 11;
43 constant int ERR_NTP_CHECK_SERVER_NOT_SYNCHRONIZED = 12;
44 constant int ERR_NTP_CHECK_ROOT_DISTANCE_TOO_LARGE = 13;
45 constant int ERR_NTP_CHECK_ORIGIN_TIME_DOES_NOT_MATCH = 14;
46 constant int ERR_NTP_CHECK_RECV_OR_XMIT_TIME_NOT_SET = 15;
47
48 /**
49 * Time zone information (see also ZoneCfg)
50 *
51 * There are two different approaches on how to identify timezones. See the ZoneCfg description.
52 *
53 * For timezones with non-trivial daylight saving time rules #hasDSTInfo is \c false.
54 */
55 structure ZoneInfo {
56 int id; ///< Time zone id
57 string name; ///< Time zone name
58 boolean hasDSTInfo; ///< \c true if the time zone has daylight saving time rules
59 };
60
61 /**
62 * Time zone configuration
63 *
64 * There are two approaches on how timezones are identified:
65 *
66 * 1. id-based
67 * - timezone data identified with a numeric non-zero id
68 * - #id != 0
69 * - #name is the display name of the timezone and ignored on setCfg()
70 *
71 * 2. name-based (see NOTES below!)
72 * - timezone data identified with a name from the IANA timezone database (aka Olson database)
73 * - #id == 0
74 * - #name is the official IANA timezone name, e.g. Europe/Berlin or America/New_York
75 *
76 * **NOTES**:
77 * - The user frontends currently only support the id-based approach and may not work correctly with
78 * the name-based approach.
79 * - Setting #enableAutoDST to \c true has only an effect if the according ZoneInfo::hasDSTInfo
80 * field is also \c true.
81 */
82 structure ZoneCfg {
83 int id; ///< Selected time zone id
84 string name; ///< Selected time zone name (ignored on setCfg() if id != 0)
85 boolean enableAutoDST; ///< Enable automatic daylight saving time adjustment
86 };
87
88 /** Time synchronization protocol */
89 enumeration Protocol {
90 STATIC, ///< Device time is configured locally
91 NTP ///< Device time is synchronized via NTP
92 };
93
94 /** NTP authentication key type */
95 enumeration NtpAuthKeyType {
96 SHA256, ///< SHA-256 authentication key
97 SHA512, ///< SHA-512 authentication key
98 AES128CMAC, ///< AES128-CMAC authentication key
99 AES256CMAC ///< AES256-CMAC authentication key
100 };
101
102 /** NTP authentication key */
103 structure NtpAuthKey {
104 NtpAuthKeyType type; ///< NTP authentication key type
105 ///< (only honoured on write if dataHex is provided as well)
106 string dataHex; ///< NTP authentication key data as case insensitive hex string
107 ///< (write-only; leave empty to keep current value)
108 };
109
110 /** Static NTP server configuration */
111 structure NtpCfg {
112 string server1; ///< Primary NTP server
113 int server1AuthKeyId; ///< Primary NTP server authetication key id
114 ///< (interpreted as 32bit unsigned int; 0 means no authentication)
115 string server2; ///< Secondary NTP server
116 int server2AuthKeyId; ///< Secondary NTP server authetication key id
117 ///< (interpreted as 32bit unsigned int; 0 means no authentication)
118 map<int, NtpAuthKey> authKeys; ///< NTP authentication keys indext by the key id.
119 ///< The key id is to be treated as unsigned 32bit integer.
120 };
121
122 /** Device date and time configuration */
123 structure Cfg {
124 ZoneCfg zoneCfg; ///< Time zone configuration
125 Protocol protocol; ///< Time synchronization protocol
126 time deviceTime; ///< Device date and time (local time)
127 NtpCfg ntpCfg; ///< NTP server configuration
128 };
129
130 /** Event that is sent when the configuration changes */
131 valueobject ConfigurationChangedEvent extends idl.Event {
132 };
133
134 /** Event that is sent when the device time is changed */
135 valueobject ClockChangedEvent extends idl.Event {
136 time oldTime; ///< Device time before change (UNIX timestamp, UTC)
137 time newTime; ///< Device time after change (UNIX timestamp, UTC)
138 };
139
140 /**
141 * List all supported time zones.
142 *
143 * @param zoneInfos Result: List of time zones
144 * @param useOlson Use Olson timezone names (see also ZoneCfg)
145 */
146 void getZoneInfos(out vector<ZoneInfo> zoneInfos, in boolean useOlson);
147
148 /**
149 * Check if a specified NTP server is usable.
150 *
151 * When calling this method a potentially referenced authentication key must have been defined first.
152 *
153 * @param ntpServer NTP server to be checked
154 * @param ntpAuthKeyId NTP authentication key id (0 for no authentication)
155 * @param ntpAuthKeyOverride NTP authentication key (leave key data empty to use existing key & type)
156 *
157 * @return \c SUCCESS or one of the ERR_NTP_CHECK_* error codes
158 */
159 int checkNtpServer(in string ntpServer, in int ntpAuthKeyId, in NtpAuthKey ntpAuthKeyOverride);
160
161 /**
162 * Get active NTP servers.
163 *
164 * @return List of currently active NTP servers (IP addresses and/or hostnames)
165 */
166 vector<string> getActiveNtpServers();
167
168 /**
169 * Retrieve the device date and time configuration.
170 *
171 * @param cfg Result: Current date and time configuration
172 */
173 void getCfg(out Cfg cfg);
174
175 /**
176 * Set the device date and time configuration.
177 * Depending on the value of the \e protocol field either \e deviceTime
178 * or \e ntpCfg will be used from the \e cfg parameter.
179 *
180 * Specific @ref set-timezone-example "example" to set timezone.
181 *
182 * @param cfg New date and time configuration.
183 *
184 * @return 0 if OK
185 * @return 1 if the configuration is invalid
186 */
187 int setCfg(in Cfg cfg);
188
189 /**
190 * Retrieve the current device date and time.
191 *
192 * @param useOlson Use Olson timezone name (see also ZoneCfg)
193 * @param zone Result: Active time zone
194 * @param dstEnabled if false, the time zone daylight saving time flag is not used
195 * @param utcOffset Result: Offset (in minutes) between local time and UTC
196 * @param currentTime Result: Device date and time (UNIX timestamp, UTC)
197 */
198 void getTime(in boolean useOlson, out ZoneInfo zone,
199 out boolean dstEnabled, out int utcOffset,
200 out time currentTime);
201
202 };
203
204}
Date and time configuration methods.
Definition DateTime.idl:26
constant int ERR_NTP_CHECK_INTERNAL
NTP server check errors.
Definition DateTime.idl:32
NtpAuthKeyType
NTP authentication key type.
Definition DateTime.idl:95
@ AES128CMAC
AES128-CMAC authentication key.
Definition DateTime.idl:98
@ SHA512
SHA-512 authentication key.
Definition DateTime.idl:97
@ SHA256
SHA-256 authentication key.
Definition DateTime.idl:96
@ AES256CMAC
AES256-CMAC authentication key.
Definition DateTime.idl:99
constant int SUCCESS
Success code.
Definition DateTime.idl:29
int setCfg(in Cfg cfg)
Set the device date and time configuration.
Protocol
Time synchronization protocol.
Definition DateTime.idl:89
@ NTP
Device time is synchronized via NTP.
Definition DateTime.idl:91
@ STATIC
Device time is configured locally.
Definition DateTime.idl:90
int checkNtpServer(in string ntpServer, in int ntpAuthKeyId, in NtpAuthKey ntpAuthKeyOverride)
Check if a specified NTP server is usable.
void getZoneInfos(out vector< ZoneInfo > zoneInfos, in boolean useOlson)
List all supported time zones.
vector< string > getActiveNtpServers()
Get active NTP servers.
void getCfg(out Cfg cfg)
Retrieve the device date and time configuration.
void getTime(in boolean useOlson, out ZoneInfo zone, out boolean dstEnabled, out int utcOffset, out time currentTime)
Retrieve the current device date and time.
Device Date and Time Configuration.
Definition DateTime.idl:11
Basic IDL definitions.
Definition Event.idl:10
Device date and time configuration.
Definition DateTime.idl:123
time deviceTime
Device date and time (local time)
Definition DateTime.idl:126
NtpCfg ntpCfg
NTP server configuration.
Definition DateTime.idl:127
Protocol protocol
Time synchronization protocol.
Definition DateTime.idl:125
ZoneCfg zoneCfg
Time zone configuration.
Definition DateTime.idl:124
Event that is sent when the device time is changed.
Definition DateTime.idl:135
time oldTime
Device time before change (UNIX timestamp, UTC)
Definition DateTime.idl:136
time newTime
Device time after change (UNIX timestamp, UTC)
Definition DateTime.idl:137
Event that is sent when the configuration changes.
Definition DateTime.idl:131
NTP authentication key.
Definition DateTime.idl:103
string dataHex
NTP authentication key data as case insensitive hex string (write-only; leave empty to keep current v...
Definition DateTime.idl:106
NtpAuthKeyType type
NTP authentication key type (only honoured on write if dataHex is provided as well)
Definition DateTime.idl:104
Static NTP server configuration.
Definition DateTime.idl:111
string server1
Primary NTP server.
Definition DateTime.idl:112
string server2
Secondary NTP server.
Definition DateTime.idl:115
int server1AuthKeyId
Primary NTP server authetication key id (interpreted as 32bit unsigned int; 0 means no authentication...
Definition DateTime.idl:113
map< int, NtpAuthKey > authKeys
NTP authentication keys indext by the key id.
Definition DateTime.idl:118
int server2AuthKeyId
Secondary NTP server authetication key id (interpreted as 32bit unsigned int; 0 means no authenticati...
Definition DateTime.idl:116
Time zone configuration.
Definition DateTime.idl:82
boolean enableAutoDST
Enable automatic daylight saving time adjustment.
Definition DateTime.idl:85
int id
Selected time zone id.
Definition DateTime.idl:83
string name
Selected time zone name (ignored on setCfg() if id != 0)
Definition DateTime.idl:84
Time zone information (see also ZoneCfg)
Definition DateTime.idl:55
string name
Time zone name.
Definition DateTime.idl:57
boolean hasDSTInfo
true if the time zone has daylight saving time rules
Definition DateTime.idl:58
Common base for all events.
Definition Event.idl:13