1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 /**************************************************************************/ 12 /**************************************************************************/ 13 /** */ 14 /** NetX SNTP Client Component */ 15 /** */ 16 /** Simple Network Time Protocol (SNTP) */ 17 /** */ 18 /**************************************************************************/ 19 /**************************************************************************/ 20 21 /**************************************************************************/ 22 /* */ 23 /* APPLICATION INTERFACE DEFINITION RELEASE */ 24 /* */ 25 /* nxd_sntp_client.h PORTABLE C */ 26 /* 6.1 */ 27 /* AUTHOR */ 28 /* */ 29 /* Yuxin Zhou, Microsoft Corporation */ 30 /* */ 31 /* DESCRIPTION */ 32 /* */ 33 /* This file defines the NetX Simple Network Time Protocol (SNTP) */ 34 /* Client component, including all data types and external references. */ 35 /* It is assumed that tx_api.h, tx_port.h, nx_api.h, and nx_port.h, */ 36 /* have already been included. */ 37 /* */ 38 /* RELEASE HISTORY */ 39 /* */ 40 /* DATE NAME DESCRIPTION */ 41 /* */ 42 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 43 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 44 /* resulting in version 6.1 */ 45 /* */ 46 /**************************************************************************/ 47 48 #ifndef NXD_SNTP_CLIENT_H 49 #define NXD_SNTP_CLIENT_H 50 51 #include "nx_ip.h" 52 53 /* Determine if a C++ compiler is being used. If so, ensure that standard 54 C is used to process the API information. */ 55 56 #ifdef __cplusplus 57 58 /* Yes, C++ compiler is present. Use standard C. */ 59 extern "C" { 60 61 #endif 62 63 64 #define NXD_SNTP_ID 0x534E5460UL 65 66 67 /* Conversion between seconds and timer ticks. This must equal the 68 NetX timer tick to seconds ratio. */ 69 70 #define NX_SNTP_MILLISECONDS_PER_TICK (1000 / NX_IP_PERIODIC_RATE) 71 72 /* Set minimum and maximum Client unicast poll period (in seconds) for requesting 73 time data. RFC 4330 polling range is from 16 - 131072 seconds. 74 Note that the RFC 4330 strongly recommends polling intervals of at least 75 one minute to unnecessary reduce demand on public time servers. */ 76 77 #define NX_SNTP_CLIENT_MIN_UNICAST_POLL_INTERVAL 64 78 #define NX_SNTP_CLIENT_MAX_UNICAST_POLL_INTERVAL 131072 79 80 /* Define Client request types. Note that this does not limit the 81 NetX SNTP Client from using MANYCAST or MULTICAST discovery options. */ 82 83 #define BROADCAST_MODE 1 84 #define UNICAST_MODE 2 85 86 #define NX_SNTP_CLIENT_RECEIVE_EVENT ((ULONG) 0x00000001) /* Event flag to signal a receive packet event */ 87 88 /* Define the minimum size of the packet NTP/SNTP time message 89 (e.g. without authentication data). */ 90 91 #define NX_SNTP_TIME_MESSAGE_MIN_SIZE 48 92 93 94 /* Define the maximum size of the packet NTP/SNTP time message (includes 20 bytes for 95 optional authentication data). */ 96 97 #define NX_SNTP_TIME_MESSAGE_MAX_SIZE 68 98 99 /* Define the largest IP4 size for ip address e.g. xxx.xxx.xxx.xxx */ 100 101 #define NX_SNTP_CLIENT_MAX_IP_ADDRESS_SIZE 15 102 103 104 105 /* Define fields in the NTP message format. */ 106 107 #define REFERENCE_TIME 0 108 #define ORIGINATE_TIME 1 109 #define RECEIVE_TIME 2 110 #define TRANSMIT_TIME 3 111 112 /* Define masks for stratum levels. */ 113 114 #define STRATUM_KISS_OF_DEATH 0x00 115 #define STRATUM_PRIMARY 0x01 116 #define STRATUM_SECONDARY 0x0E /* 2 - 15 */ 117 #define STRATUM_RESERVED 0xF0 /* 16 - 255*/ 118 119 120 /* Kiss of death strings (see Codes below). Applicable when stratum = 0 121 122 Code Meaning 123 -------------------------------------------------------------- */ 124 125 126 #define ANYCAST "ACST" /* The association belongs to an anycast server. */ 127 #define AUTH_FAIL "AUTH" /* Server authentication failed. */ 128 #define AUTOKEY_FAIL "AUTO" /* Autokey sequence failed. */ 129 #define BROADCAST "BCST" /* The association belongs to a broadcast server. */ 130 #define CRYP_FAIL "CRYP" /* Cryptographic authentication or identification failed. */ 131 #define DENY "DENY" /* Access denied by remote server. */ 132 #define DROP "DROP" /* Lost peer in symmetric mode. */ 133 #define DENY_POLICY "RSTR" /* Access denied due to local policy. */ 134 #define NOT_INIT "INIT" /* The association has not yet synchronized for the first time. */ 135 #define MANYCAST "MCST" /* The association belongs to a manycast server. */ 136 #define NO_KEY "NKEY" /* No key found. Either the key was never installed or is not trusted. */ 137 #define RATE "RATE" /* Rate exceeded. The server temporarily denied access; client exceeded rate threshold. */ 138 #define RMOT "RMOT" /* Somebody is tinkering with association from remote host running ntpdc. OK unless they've stolen your keys. */ 139 #define STEP "STEP" /* A step change in system time has occurred, but association has not yet resynchronized. */ 140 141 /* Define Kiss of Death error codes. Note: there should be a 1 : 1 correspondence of 142 KOD strings to KOD error codes! */ 143 144 #define NX_SNTP_KISS_OF_DEATH_PACKET 0xF00 145 146 #define NX_SNTP_KOD_ANYCAST (NX_SNTP_KISS_OF_DEATH_PACKET | 0x01) 147 #define NX_SNTP_KOD_AUTH_FAIL (NX_SNTP_KISS_OF_DEATH_PACKET | 0x02) 148 #define NX_SNTP_KOD_AUTOKEY_FAIL (NX_SNTP_KISS_OF_DEATH_PACKET | 0x03) 149 #define NX_SNTP_KOD_BROADCAST (NX_SNTP_KISS_OF_DEATH_PACKET | 0x04) 150 #define NX_SNTP_KOD_CRYP_FAIL (NX_SNTP_KISS_OF_DEATH_PACKET | 0x05) 151 #define NX_SNTP_KOD_DENY (NX_SNTP_KISS_OF_DEATH_PACKET | 0x06) 152 #define NX_SNTP_KOD_DROP (NX_SNTP_KISS_OF_DEATH_PACKET | 0x07) 153 #define NX_SNTP_KOD_DENY_POLICY (NX_SNTP_KISS_OF_DEATH_PACKET | 0x08) 154 #define NX_SNTP_KOD_NOT_INIT (NX_SNTP_KISS_OF_DEATH_PACKET | 0x09) 155 #define NX_SNTP_KOD_MANYCAST (NX_SNTP_KISS_OF_DEATH_PACKET | 0x0A) 156 #define NX_SNTP_KOD_NO_KEY (NX_SNTP_KISS_OF_DEATH_PACKET | 0x0B) 157 #define NX_SNTP_KOD_RATE (NX_SNTP_KISS_OF_DEATH_PACKET | 0x0C) 158 #define NX_SNTP_KOD_RMOT (NX_SNTP_KISS_OF_DEATH_PACKET | 0x0D) 159 #define NX_SNTP_KOD_STEP (NX_SNTP_KISS_OF_DEATH_PACKET | 0x0E) 160 161 /* Define SNTP protocol modes. SNTP is limited to primarily Client, server and broadcast modes. */ 162 163 #define PROTOCOL_MODE_RESERVED 0 164 #define PROTOCOL_MODE_SYMM_ACTIVE 1 165 #define PROTOCOL_MODE_SYMM_PASSIVE 2 166 #define PROTOCOL_MODE_CLIENT 3 167 #define PROTOCOL_MODE_SERVER_UNICAST 4 168 #define PROTOCOL_MODE_SERVER_BROADCAST 5 169 #define PROTOCOL_MODE_NTP_CNTL_MSG 6 170 #define PROTOCOL_MODE_PRIVATE 7 171 172 173 /* NX SNTP Client configurable options. */ 174 175 176 177 /* Set the NetX SNTP client thread stack size . */ 178 179 #ifndef NX_SNTP_CLIENT_THREAD_STACK_SIZE 180 #define NX_SNTP_CLIENT_THREAD_STACK_SIZE 2048 181 #endif 182 183 184 /* Set the client thread time slice. */ 185 186 #ifndef NX_SNTP_CLIENT_THREAD_TIME_SLICE 187 #define NX_SNTP_CLIENT_THREAD_TIME_SLICE TX_NO_TIME_SLICE 188 #endif 189 190 191 192 #ifndef NX_SNTP_CLIENT_THREAD_PRIORITY 193 #define NX_SNTP_CLIENT_THREAD_PRIORITY 2 194 #endif 195 196 197 /* Set NetX SNTP client thread preemption threshold. */ 198 199 #ifndef NX_SNTP_CLIENT_PREEMPTION_THRESHOLD 200 #define NX_SNTP_CLIENT_PREEMPTION_THRESHOLD NX_SNTP_CLIENT_THREAD_PRIORITY 201 #endif 202 203 204 205 /* Configure the NetX SNTP client network parameters */ 206 207 /* Set Client UDP socket name. */ 208 209 #ifndef NX_SNTP_CLIENT_UDP_SOCKET_NAME 210 #define NX_SNTP_CLIENT_UDP_SOCKET_NAME "SNTP Client socket" 211 #endif 212 213 214 /* Set port for client to bind UDP socket. */ 215 216 #ifndef NX_SNTP_CLIENT_UDP_PORT 217 #define NX_SNTP_CLIENT_UDP_PORT 123 218 #endif 219 220 /* Set port for client to connect to SNTP server. */ 221 222 #ifndef NX_SNTP_SERVER_UDP_PORT 223 #define NX_SNTP_SERVER_UDP_PORT 123 224 #endif 225 226 /* Set Time to Live (TTL) value for transmitted UDP packets, including manycast and 227 multicast transmissions. The default TTL for windows operating system time 228 server is used. */ 229 230 #ifndef NX_SNTP_CLIENT_TIME_TO_LIVE 231 #define NX_SNTP_CLIENT_TIME_TO_LIVE NX_IP_TIME_TO_LIVE 232 #endif 233 234 235 /* Set maximum queue depth for client socket.*/ 236 237 #ifndef NX_SNTP_CLIENT_MAX_QUEUE_DEPTH 238 #define NX_SNTP_CLIENT_MAX_QUEUE_DEPTH 5 239 #endif 240 241 242 /* Set the time out (timer ticks) for packet allocation from the client packet pool. */ 243 244 #ifndef NX_SNTP_CLIENT_PACKET_TIMEOUT 245 #define NX_SNTP_CLIENT_PACKET_TIMEOUT (1 * NX_IP_PERIODIC_RATE) 246 #endif 247 248 249 /* Set the NTP/SNTP version of this NTP Client. */ 250 251 #ifndef NX_SNTP_CLIENT_NTP_VERSION 252 #define NX_SNTP_CLIENT_NTP_VERSION 3 253 #endif 254 255 256 /* Set minimum NTP/SNTP version the Client will accept from its time server. */ 257 258 #ifndef NX_SNTP_CLIENT_MIN_NTP_VERSION 259 #define NX_SNTP_CLIENT_MIN_NTP_VERSION 3 260 #endif 261 262 263 264 /* Define the minimum (numerically highest) stratum the Client will 265 accept for a time server. Valid range is 1 - 15. */ 266 267 #ifndef NX_SNTP_CLIENT_MIN_SERVER_STRATUM 268 #define NX_SNTP_CLIENT_MIN_SERVER_STRATUM 2 269 #endif 270 271 272 /* Define minimum time difference (msec) between server and client time 273 the Client requires to change its local time. */ 274 275 #ifndef NX_SNTP_CLIENT_MIN_TIME_ADJUSTMENT 276 #define NX_SNTP_CLIENT_MIN_TIME_ADJUSTMENT 10 277 #endif 278 279 280 /* Define maximum time update (msec) the Client will make to its local time 281 per update. */ 282 283 #ifndef NX_SNTP_CLIENT_MAX_TIME_ADJUSTMENT 284 #define NX_SNTP_CLIENT_MAX_TIME_ADJUSTMENT 180000 285 #endif 286 287 288 /* Determine if the Client should ignore the maximum time adjustment on startup. If the 289 host application has a pretty accurate notion of time, this can be set to false. If not 290 the SNTP Client may be unable to apply the first (any) updates. */ 291 292 #ifndef NX_SNTP_CLIENT_IGNORE_MAX_ADJUST_STARTUP 293 #define NX_SNTP_CLIENT_IGNORE_MAX_ADJUST_STARTUP NX_TRUE 294 #endif 295 296 297 /* Determine if the Client should create a random delay before starting SNTP polling. */ 298 299 #ifndef NX_SNTP_CLIENT_RANDOMIZE_ON_STARTUP 300 #define NX_SNTP_CLIENT_RANDOMIZE_ON_STARTUP NX_FALSE 301 #endif 302 303 304 /* Set the maximum time lapse (in seconds) without a time update that can be tolerated by 305 the Client (application). This should be determined by application time sensitivity. 306 For unicast operation, the max lapse could be set to three successive poll requests 307 without an update. Here we set it to 2 hour based on the RFC recommendation to limit 308 traffic congestion. */ 309 310 #ifndef NX_SNTP_CLIENT_MAX_TIME_LAPSE 311 #define NX_SNTP_CLIENT_MAX_TIME_LAPSE 7200 312 #endif 313 314 315 /* Define a time out (seconds) for the SNTP Client timer. */ 316 317 #ifndef NX_SNTP_UPDATE_TIMEOUT_INTERVAL 318 #define NX_SNTP_UPDATE_TIMEOUT_INTERVAL 1 319 #endif 320 321 /* Define the SNTP Client task sleep interval in timer ticks when 322 the SNTP CLient thread is idle. */ 323 324 #ifndef NX_SNTP_CLIENT_SLEEP_INTERVAL 325 #define NX_SNTP_CLIENT_SLEEP_INTERVAL 1 326 #endif 327 328 329 /* Set the unicast poll interval (in seconds) for Client time update requests. RFC 4330 330 recommends a minimum polling interval of once per hour to minimize traffic congestion. */ 331 332 #ifndef NX_SNTP_CLIENT_UNICAST_POLL_INTERVAL 333 #define NX_SNTP_CLIENT_UNICAST_POLL_INTERVAL 3600 334 #endif 335 336 337 /* Set the Client exponential back off rate for extending Client poll interval. 338 To effectively disable, set to 1. */ 339 340 #ifndef NX_SNTP_CLIENT_EXP_BACKOFF_RATE 341 #define NX_SNTP_CLIENT_EXP_BACKOFF_RATE 2 342 #endif 343 344 /* Determine if the Client requires round trip calculation of SNTP messages. */ 345 346 #ifndef NX_SNTP_CLIENT_RTT_REQUIRED 347 #define NX_SNTP_CLIENT_RTT_REQUIRED NX_FALSE 348 #endif 349 350 351 /* Define the upper limit of server clock dispersion (usec) the Client 352 will accept. To disable this check, set this parameter to 0x0. */ 353 354 #ifndef NX_SNTP_CLIENT_MAX_ROOT_DISPERSION 355 #define NX_SNTP_CLIENT_MAX_ROOT_DISPERSION 50000 356 #endif 357 358 359 /* Set the limit on consecutive bad updates from server before Client 360 switches to alternate server. */ 361 362 #ifndef NX_SNTP_CLIENT_INVALID_UPDATE_LIMIT 363 #define NX_SNTP_CLIENT_INVALID_UPDATE_LIMIT 3 364 #endif 365 366 /* Set size of SNTP data in bytes, not including IP and UDP header fields or authentication. */ 367 #define NX_SNTP_CLIENT_PACKET_DATA_SIZE 48 368 369 /* To display date in year/month/date format, set the current year (same year as in NTP time being evaluated) e.g 2015. 370 Otherwise set to zero. */ 371 #ifndef NX_SNTP_CURRENT_YEAR 372 #define NX_SNTP_CURRENT_YEAR 2015 373 #endif /* NX_SNTP_CURRENT_YEAR */ 374 375 376 /* Define status levels for SNTP update processing */ 377 378 #define UPDATE_STATUS_CONTINUE 1 379 #define UPDATE_STATUS_BREAK 2 380 #define UPDATE_STATUS_ERROR 3 381 #define UPDATE_STATUS_SUCCESS 4 382 383 384 /* Define the number of seconds from 01-01-1990 00:00:00 to 01-01-1999 00:00:00 (last occurrance 385 of a leap second) to be able to define time in year, month, date. If zero, 386 no date time is displayed. */ 387 #ifndef NTP_SECONDS_AT_01011999 388 #define NTP_SECONDS_AT_01011999 0xBA368E80 389 #endif /* NTP_SECONDS_AT_01011999 */ 390 391 /* Define which epoch time is relative on the host system. */ 392 393 #define UNIX_EPOCH 1 394 #define NTP_EPOCH 2 395 396 397 398 /* Enumerate months*/ 399 400 #define JANUARY 1 401 #define FEBRUARY 2 402 #define MARCH 3 403 #define APRIL 4 404 #define MAY 5 405 #define JUNE 6 406 #define JULY 7 407 #define AUGUST 8 408 #define SEPTEMBER 9 409 #define OCTOBER 10 410 #define NOVEMBER 11 411 #define DECEMBER 12 412 413 414 /* Compute seconds per month for convenience computating date and time. */ 415 416 #define SEC_IN_JAN (31 * SECONDS_PER_DAY) 417 #define SEC_IN_LEAPFEB (29 * SECONDS_PER_DAY) 418 #define SEC_IN_NONLEAPFEB (28 * SECONDS_PER_DAY) 419 #define SEC_IN_MAR (31 * SECONDS_PER_DAY) 420 #define SEC_IN_APR (30 * SECONDS_PER_DAY) 421 #define SEC_IN_MAY (31 * SECONDS_PER_DAY) 422 #define SEC_IN_JUN (30 * SECONDS_PER_DAY) 423 #define SEC_IN_JUL (31 * SECONDS_PER_DAY) 424 #define SEC_IN_AUG (31 * SECONDS_PER_DAY) 425 #define SEC_IN_SEP (30 * SECONDS_PER_DAY) 426 #define SEC_IN_OCT (31 * SECONDS_PER_DAY) 427 #define SEC_IN_NOV (30 * SECONDS_PER_DAY) 428 #define SEC_IN_DEC (31 * SECONDS_PER_DAY) 429 430 /* Compute seconds per year, month,day for convenience computating date and time. */ 431 432 #define SECONDS_PER_LEAPYEAR (86400 * 366) 433 #define SECONDS_PER_NONLEAPYEAR (86400 * 365) 434 #define SECONDS_PER_DAY 86400 435 #define SECONDS_PER_HOUR 3600 436 #define SECONDS_PER_MINUTE 60 437 438 439 /* Internal SNTP error processing codes. */ 440 441 #define NX_SNTP_ERROR_CONSTANT 0xD00 442 443 444 /* Client side errors. */ 445 #define NX_SNTP_CLIENT_NOT_INITIALIZED (NX_SNTP_ERROR_CONSTANT | 0x01) /* Client not properly initialized to receive time data. */ 446 #define NX_SNTP_OVER_LIMIT_ON_SERVERS (NX_SNTP_ERROR_CONSTANT | 0x02) /* Cannot accept server because client list has reached max # servers. */ 447 #define NX_SNTP_INVALID_DOMAIN (NX_SNTP_ERROR_CONSTANT | 0x03) /* Invalid domain such as bad IP format or empty string. Applicable to broadcast mode. */ 448 #define NX_SNTP_NO_AVAILABLE_SERVERS (NX_SNTP_ERROR_CONSTANT | 0x04) /* Client has no available time servers to contact. */ 449 #define NX_SNTP_INVALID_LOCAL_TIME (NX_SNTP_ERROR_CONSTANT | 0x05) /* Client local time has not been set or is invalid. */ 450 #define NX_SNTP_OUT_OF_DOMAIN_SERVER (NX_SNTP_ERROR_CONSTANT | 0x06) /* Broadcast server does not belong to client broadcast domain. */ 451 #define NX_SNTP_INVALID_DATETIME_BUFFER (NX_SNTP_ERROR_CONSTANT | 0x07) /* Insufficient or invalid buffer for writing human readable time date string. */ 452 #define NX_SNTP_ERROR_CONVERTING_DATETIME (NX_SNTP_ERROR_CONSTANT | 0x08) /* An internal error has occurred converting NTP time to mm-dd-yy time format. */ 453 #define NX_SNTP_UNABLE_TO_CONVERT_DATETIME (NX_SNTP_ERROR_CONSTANT | 0x09) /* An internal error has occurred converting NTP time to mm-dd-yy time format. */ 454 #define NX_SNTP_INVALID_SERVER_ADDRESS (NX_SNTP_ERROR_CONSTANT | 0x0A) /* Invalid server type e.g. IPv4 or IPv6 incompatible. */ 455 #define NX_SNTP_CLIENT_NOT_STARTED (NX_SNTP_ERROR_CONSTANT | 0x0B) /* SNTP Client task is not running */ 456 #define NX_SNTP_CLIENT_ALREADY_STARTED (NX_SNTP_ERROR_CONSTANT | 0x0C) /* SNTP Client task is already running */ 457 #define NX_SNTP_PARAM_ERROR (NX_SNTP_ERROR_CONSTANT | 0x0D) /* Invalid non pointer parameter. */ 458 459 /* Server side errors */ 460 #define NX_SNTP_SERVER_NOT_AVAILABLE (NX_SNTP_ERROR_CONSTANT | 0x10) /* Client will not get any time update service from current server. */ 461 #define NX_SNTP_NO_UNICAST_FROM_SERVER (NX_SNTP_ERROR_CONSTANT | 0x11) /* Client did not receive a valid unicast response from server. */ 462 #define NX_SNTP_SERVER_CLOCK_NOT_SYNC (NX_SNTP_ERROR_CONSTANT | 0x12) /* Server clock not synchronized. */ 463 #define NX_SNTP_KOD_SERVER_NOT_AVAILABLE (NX_SNTP_ERROR_CONSTANT | 0x13) /* Server sent a KOD packet indicating service temporarily not available. */ 464 #define NX_SNTP_KOD_REMOVE_SERVER (NX_SNTP_ERROR_CONSTANT | 0x14) /* Server sent a KOD packet indicating service is not available to client (ever). */ 465 #define NX_SNTP_SERVER_AUTH_FAIL (NX_SNTP_ERROR_CONSTANT | 0x15) /* Server rejects Client packet on basis of missing or invalid authorization data. */ 466 467 /* Bad packet and time update errors */ 468 #define NX_SNTP_INVALID_TIME_PACKET (NX_SNTP_ERROR_CONSTANT | 0x20) /* Invalid packet (length or data incorrect). */ 469 #define NX_SNTP_INVALID_NTP_VERSION (NX_SNTP_ERROR_CONSTANT | 0x21) /* Server NTP/SNTP version not incompatible with client. */ 470 #define NX_SNTP_INVALID_SERVER_MODE (NX_SNTP_ERROR_CONSTANT | 0x22) /* Server association invalid (out of protocol with client). */ 471 #define NX_SNTP_INVALID_SERVER_PORT (NX_SNTP_ERROR_CONSTANT | 0x23) /* Server port does not match what the client expects. */ 472 #define NX_SNTP_INVALID_IP_ADDRESS (NX_SNTP_ERROR_CONSTANT | 0x24) /* Server IP address does not match what the client expects. */ 473 #define NX_SNTP_INVALID_SERVER_STRATUM (NX_SNTP_ERROR_CONSTANT | 0x25) /* Server stratum is invalid or below client stratum. */ 474 #define NX_SNTP_BAD_SERVER_ROOT_DISPERSION (NX_SNTP_ERROR_CONSTANT | 0x26) /* Server root dispersion (clock precision) is too high or invalid value (0) reported. */ 475 #define NX_SNTP_OVER_INVALID_LIMIT (NX_SNTP_ERROR_CONSTANT | 0x27) /* Client over the limit on consecutive server updates with bad data received. */ 476 #define NX_SNTP_DUPE_SERVER_PACKET (NX_SNTP_ERROR_CONSTANT | 0x28) /* Client has received duplicate packets from server. */ 477 #define NX_SNTP_INVALID_TIMESTAMP (NX_SNTP_ERROR_CONSTANT | 0x29) /* Server time packet has one or more invalid time stamps in update message. */ 478 #define NX_SNTP_INSUFFICIENT_PACKET_PAYLOAD (NX_SNTP_ERROR_CONSTANT | 0x2A) /* Packet payload not large enough for SNTP message. */ 479 #define NX_SNTP_INVALID_SNTP_PACKET (NX_SNTP_ERROR_CONSTANT | 0x2B) /* Server IP version does not match what the client expects. */ 480 481 /* Arithmetic errors or invalid results */ 482 #define NX_SNTP_INVALID_TIME (NX_SNTP_ERROR_CONSTANT | 0x30) /* Invalid time resulting from arithmetic operation. */ 483 #define NX_SNTP_INVALID_RTT_TIME (NX_SNTP_ERROR_CONSTANT | 0x31) /* Round trip time correction to server time yields invalid time (e.g. <0). */ 484 #define NX_SNTP_OVERFLOW_ERROR (NX_SNTP_ERROR_CONSTANT | 0x32) /* Overflow error resulting from multiplying/adding two 32 bit (timestamp) numbers. */ 485 #define NX_SNTP_SIGN_ERROR (NX_SNTP_ERROR_CONSTANT | 0x33) /* Loss of sign error resulting from multiplying/adding two 32 bit (timestamp) numbers. */ 486 487 /* Time out errors */ 488 #define NX_SNTP_TIMED_OUT_ON_SERVER (NX_SNTP_ERROR_CONSTANT | 0x44) /* Client did not receive update from the current server within specified timeout. */ 489 #define NX_SNTP_MAX_TIME_LAPSE_EXCEEDED (NX_SNTP_ERROR_CONSTANT | 0x45) /* Client has not received update from any server within the max allowed time lapse. */ 490 491 492 493 /* Define the Netx Date Time structure. */ 494 495 typedef struct NX_SNTP_DATE_TIME_STRUCT 496 { 497 UINT year; 498 UINT month; 499 UINT day; 500 UINT hour; 501 UINT minute; 502 UINT second; 503 UINT millisecond; /* This is the fraction part of the NTP time data. */ 504 UINT time_zone; /* NTP time is represented in Coordinated Universal Time (UTC). */ 505 UINT leap_year; /* Indicates if current time is in a leap year. */ 506 507 } NX_SNTP_DATE_TIME; 508 509 510 /* Define the Netx SNTP Time structure. */ 511 512 typedef struct NX_SNTP_TIME_STRUCT 513 { 514 ULONG seconds; /* Seconds, in the 32 bit field of an NTP time data. */ 515 ULONG fraction; /* Fraction of a second, in the 32 bit fraction field of an NTP time data. */ 516 517 } NX_SNTP_TIME; 518 519 520 /* Define the NetX SNTP Time Message structure. The Client only uses the flags field and the transmit_time_stamp field 521 in time requests it sends to its time server. */ 522 523 typedef struct NX_SNTP_TIME_MESSAGE_STRUCT 524 { 525 /* These are represented as 8 bit data fields in the time message format. */ 526 UINT flags; /* Flag containing host's NTP version, mode and leap indicator. */ 527 UINT peer_clock_stratum; /* Level of precision in the NTP network. Applicable only in server NTP messages. */ 528 UINT peer_poll_interval; /* Frequency at which an NTP host polls its NTP peer. Applicable only in server NTP messages. */ 529 UINT peer_clock_precision; /* Precision of the NTP server clock. Applicable only in server NTP messages. */ 530 531 /* These are represented as 32 bit data fields in the time message format*/ 532 ULONG root_delay; /* Round trip time from NTP Server to primary reference source. Applicable only in server NTP messages. */ 533 ULONG clock_dispersion; /* Server reference clock type (but if stratum is zero, indicates server status when not able to send time updates. */ 534 UCHAR reference_clock_id[4]; /* Maximum error in server clock based to the clock frequency tolerance. Applicable only in server NTP messages. */ 535 536 /* These are represented as 64 bit data fields in the time message format*/ 537 ULONG reference_clock_update_time_stamp[2]; /* Time at which the server clock was last set or corrected in a server time message. */ 538 ULONG originate_time_stamp[2]; /* Time at which the Client update request left the Client in a server time message. */ 539 ULONG receive_time_stamp[2]; /* Time at which the server received the Client request in a server time message. */ 540 ULONG transmit_time_stamp[2]; /* Time at which the server transmitted its reply to the Client in a server time message (or the time client request was sent in the client request message). */ 541 542 /* Optional authenticator fields. */ 543 UCHAR KeyIdentifier[4]; /* Key Identifier and Message Digest fields contain the... */ 544 UCHAR MessageDigest[16]; /* ...message authentication code (MAC) information defined. */ 545 546 /* These fields are used internally for 'convert' UCHAR data in NX_SNTP_TIME data e.g. seconds and fractions. */ 547 NX_SNTP_TIME reference_clock_update_time; /* Time at which the server clock was last set or corrected in a server time message. */ 548 NX_SNTP_TIME originate_time; /* Time at which the Client update request left the Client in a server time message. */ 549 NX_SNTP_TIME receive_time; /* Time at which the server received the Client request in a server time message. */ 550 NX_SNTP_TIME transmit_time; /* Time at which the server transmitted its reply to the Client in a server time message (or the time client request was sent in the client request message). */ 551 552 } NX_SNTP_TIME_MESSAGE; 553 554 555 /* Define the SNTP client structure. */ 556 557 typedef struct NX_SNTP_CLIENT_STRUCT 558 { 559 ULONG nx_sntp_client_id; /* SNTP ID for identifying the client service task. */ 560 NX_IP *nx_sntp_client_ip_ptr; /* Pointer to the Client IP instance. */ 561 UINT nx_sntp_client_interface_index; /* Index to SNTP network interface */ 562 NX_PACKET_POOL *nx_sntp_client_packet_pool_ptr; /* Pointer to the Client packet pool. */ 563 UINT nx_sntp_client_sleep_flag; /* The flag indicating the SNTP Client thread is sleeping */ 564 UINT nx_sntp_client_started; /* Flag indicating the SNTP Client task is running */ 565 TX_THREAD nx_sntp_client_thread; /* The SNTP Client processing thread */ 566 TX_MUTEX nx_sntp_client_mutex; /* The SNTP Client mutex for protecting access */ 567 UCHAR nx_sntp_client_thread_stack[NX_SNTP_CLIENT_THREAD_STACK_SIZE]; /* Stack size for SNTP client thread */ 568 NXD_ADDRESS nx_sntp_server_ip_address; /* Client's current time server IP address. */ 569 NX_UDP_SOCKET nx_sntp_client_udp_socket; /* Client UDP socket for sending and receiving time updates. */ 570 UINT nx_sntp_client_first_update_pending; /* First SNTP update not yet received with current server */ 571 UINT nx_sntp_client_time_start_wait; /* Initial time at start of receiving broadcast SNTP updates */ 572 UINT nx_sntp_client_sent_initial_unicast; /* Status on initial unicast transmittal for clients in broadcast mode */ 573 UINT nx_sntp_client_invalid_time_updates; /* Number of invalid SNTP messages received */ 574 UINT nx_sntp_valid_server_status; /* Server status; if receiving valid updates, status is TRUE */ 575 UINT nx_sntp_client_protocol_mode; /* Mode of operation, either unicast or broadcast */ 576 UINT nx_sntp_client_broadcast_initialized; /* Client task is ready to receive broadcast time data. */ 577 NXD_ADDRESS nx_sntp_broadcast_time_server; /* Client's broadcast SNTP server */ 578 NXD_ADDRESS nx_sntp_multicast_server_address; /* IP address Client should listen on to receive broadcasts from a multicast server. */ 579 UINT nx_sntp_client_unicast_initialized; /* Client task is ready to receive unicast time data. */ 580 NXD_ADDRESS nx_sntp_unicast_time_server; /* Client's unicast time server. */ 581 ULONG nx_sntp_client_unicast_poll_interval; /* Unicast interval at which client is polling the time server. */ 582 UINT nx_sntp_client_backoff_count; /* Count of times the back off rate has been applied to the poll interval */ 583 TX_TIMER nx_sntp_update_timer; /* SNTP update timer; expires when no data received for specified time lapse. */ 584 ULONG nx_sntp_update_time_remaining; /* Time (in seconds) remaining that the Client task can continue running without receiving a valid update. */ 585 LONG nx_sntp_client_roundtrip_time_msec; /* Round trip time (msec) for a packet to travel to server and back to client. Does not include server processing time. */ 586 ULONG nx_sntp_client_local_ntp_time_elapsed; /* Seconds elapsed since local time is updated last time. */ 587 NX_SNTP_TIME_MESSAGE nx_sntp_current_server_time_message; /* Time update which the Client has just received from its server. */ 588 NX_SNTP_TIME_MESSAGE nx_sntp_current_time_message_request; /* Client request to send to its time server. */ 589 NX_SNTP_TIME_MESSAGE nx_sntp_previous_server_time_message; /* Previous valid time update received from the Client time server. */ 590 NX_SNTP_TIME nx_sntp_client_local_ntp_time; /* Client's notion of local time. */ 591 NX_SNTP_TIME nx_sntp_server_update_time; /* Time (based on client local time) when the server update was received in response to the current request. */ 592 UINT (*apply_custom_sanity_checks)(struct NX_SNTP_CLIENT_STRUCT *client_ptr, NX_SNTP_TIME_MESSAGE *client_time_msg_ptr, NX_SNTP_TIME_MESSAGE *server_time_msg_ptr); 593 /* Pointer to callback service for performing additional sanity checks on received time data. */ 594 UINT (*leap_second_handler)(struct NX_SNTP_CLIENT_STRUCT *client_ptr, UINT indicator); 595 /* Pointer to callback service for handling an impending leap second. */ 596 UINT (*kiss_of_death_handler)(struct NX_SNTP_CLIENT_STRUCT *client_ptr, UINT code); 597 /* Pointer to callback service for handling kiss of death packets received from server. */ 598 VOID (*random_number_generator)(struct NX_SNTP_CLIENT_STRUCT *client_ptr, ULONG *rand); 599 /* Pointer to callback service for random number generator. */ 600 601 VOID (*nx_sntp_client_time_update_notify)(NX_SNTP_TIME_MESSAGE *time_update_ptr, NX_SNTP_TIME *local_time); 602 603 } NX_SNTP_CLIENT; 604 605 606 #ifndef NX_SNTP_SOURCE_CODE 607 608 /* Define the system API mappings based on the error checking selected by the user. */ 609 610 611 /* Determine if error checking is desired. If so, map API functions 612 to the appropriate error checking front-ends. Otherwise, map API 613 functions to the core functions that actually perform the work. 614 Note: error checking is enabled by default. */ 615 616 617 #ifdef NX_SNTP_DISABLE_ERROR_CHECKING 618 619 /* Services without error checking. */ 620 621 #define nx_sntp_client_create _nx_sntp_client_create 622 #define nx_sntp_client_delete _nx_sntp_client_delete 623 #define nx_sntp_client_get_local_time _nx_sntp_client_get_local_time 624 #define nx_sntp_client_get_local_time_extended _nx_sntp_client_get_local_time_extended 625 #define nxd_sntp_client_initialize_broadcast _nxd_sntp_client_initialize_broadcast 626 #define nxd_sntp_client_initialize_unicast _nxd_sntp_client_initialize_unicast 627 #define nx_sntp_client_initialize_broadcast _nx_sntp_client_initialize_broadcast 628 #define nx_sntp_client_initialize_unicast _nx_sntp_client_initialize_unicast 629 #define nx_sntp_client_receiving_updates _nx_sntp_client_receiving_updates 630 #define nx_sntp_client_run_broadcast _nx_sntp_client_run_broadcast 631 #define nx_sntp_client_run_unicast _nx_sntp_client_run_unicast 632 #define nx_sntp_client_set_local_time _nx_sntp_client_set_local_time 633 #define nx_sntp_client_stop _nx_sntp_client_stop 634 #define nx_sntp_client_utility_msecs_to_fraction _nx_sntp_client_utility_msecs_to_fraction 635 #define nx_sntp_client_utility_usecs_to_fraction _nx_sntp_client_utility_usecs_to_fraction 636 #define nx_sntp_client_utility_fraction_to_usecs _nx_sntp_client_utility_fraction_to_usecs 637 #define nx_sntp_client_utility_display_date_time _nx_sntp_client_utility_display_date_time 638 #define nx_sntp_client_request_unicast_time _nx_sntp_client_request_unicast_time 639 #define nx_sntp_client_set_time_update_notify _nx_sntp_client_set_time_update_notify 640 641 #else 642 643 /* Services with error checking. */ 644 645 #define nx_sntp_client_create _nxe_sntp_client_create 646 #define nx_sntp_client_delete _nxe_sntp_client_delete 647 #define nx_sntp_client_get_local_time _nxe_sntp_client_get_local_time 648 #define nx_sntp_client_get_local_time_extended _nxe_sntp_client_get_local_time_extended 649 #define nxd_sntp_client_initialize_broadcast _nxde_sntp_client_initialize_broadcast 650 #define nxd_sntp_client_initialize_unicast _nxde_sntp_client_initialize_unicast 651 #define nx_sntp_client_initialize_broadcast _nxe_sntp_client_initialize_broadcast 652 #define nx_sntp_client_initialize_unicast _nxe_sntp_client_initialize_unicast 653 #define nx_sntp_client_receiving_updates _nxe_sntp_client_receiving_updates 654 #define nx_sntp_client_run_broadcast _nxe_sntp_client_run_broadcast 655 #define nx_sntp_client_run_unicast _nxe_sntp_client_run_unicast 656 #define nx_sntp_client_set_local_time _nxe_sntp_client_set_local_time 657 #define nx_sntp_client_stop _nxe_sntp_client_stop 658 #define nx_sntp_client_utility_msecs_to_fraction _nxe_sntp_client_utility_msecs_to_fraction 659 #define nx_sntp_client_utility_usecs_to_fraction _nxe_sntp_client_utility_usecs_to_fraction 660 #define nx_sntp_client_utility_fraction_to_usecs _nxe_sntp_client_utility_fraction_to_usecs 661 #define nx_sntp_client_utility_display_date_time _nxe_sntp_client_utility_display_date_time 662 #define nx_sntp_client_request_unicast_time _nxe_sntp_client_request_unicast_time 663 #define nx_sntp_client_set_time_update_notify _nxe_sntp_client_set_time_update_notify 664 665 #endif /* NX_SNTP_DISABLE_ERROR_CHECKING */ 666 667 668 /* Define the prototypes accessible to the application software. */ 669 670 UINT nx_sntp_client_create(NX_SNTP_CLIENT *client_ptr, NX_IP *ip_ptr, UINT iface_index, NX_PACKET_POOL *packet_pool_ptr, 671 UINT (*leap_second_handler)(NX_SNTP_CLIENT *client_ptr, UINT indicator), 672 UINT (*kiss_of_death_handler)(NX_SNTP_CLIENT *client_ptr, UINT code), 673 VOID (random_number_generator)(struct NX_SNTP_CLIENT_STRUCT *client_ptr, ULONG *rand)); 674 UINT nx_sntp_client_delete (NX_SNTP_CLIENT *client_ptr); 675 UINT nx_sntp_client_get_local_time(NX_SNTP_CLIENT *client_ptr, ULONG *seconds, ULONG *fraction, CHAR *buffer); 676 UINT nx_sntp_client_get_local_time_extended(NX_SNTP_CLIENT *client_ptr, ULONG *seconds, ULONG *fraction, CHAR *buffer, UINT buffer_size); 677 UINT nxd_sntp_client_initialize_broadcast(NX_SNTP_CLIENT *client_ptr, NXD_ADDRESS *multicast_server_address, NXD_ADDRESS *broadcast_time_server); 678 UINT nx_sntp_client_initialize_broadcast(NX_SNTP_CLIENT *client_ptr, ULONG multicast_server_address, ULONG broadcast_time_server); 679 UINT nxd_sntp_client_initialize_unicast(NX_SNTP_CLIENT *client_ptr, NXD_ADDRESS *unicast_time_server); 680 UINT nx_sntp_client_initialize_unicast(NX_SNTP_CLIENT *client_ptr, ULONG unicast_time_server); 681 UINT nx_sntp_client_receiving_updates(NX_SNTP_CLIENT *client_ptr, UINT *server_status); 682 UINT nx_sntp_client_run_broadcast(NX_SNTP_CLIENT *client_ptr); 683 UINT nx_sntp_client_run_unicast(NX_SNTP_CLIENT *client_ptr); 684 UINT nx_sntp_client_set_local_time(NX_SNTP_CLIENT *client_ptr, ULONG seconds, ULONG fraction); 685 UINT nx_sntp_client_stop(NX_SNTP_CLIENT *client_ptr); 686 UINT nx_sntp_client_utility_msecs_to_fraction(ULONG msecs, ULONG *fraction); 687 UINT nx_sntp_client_utility_usecs_to_fraction(ULONG usecs, ULONG *fraction); 688 UINT nx_sntp_client_utility_fraction_to_usecs(ULONG fraction, ULONG *usecs); 689 UINT nx_sntp_client_utility_display_date_time(NX_SNTP_CLIENT *client_ptr, CHAR *buffer, UINT length); 690 UINT nx_sntp_client_request_unicast_time(NX_SNTP_CLIENT *client_ptr, UINT wait_option); 691 UINT nx_sntp_client_set_time_update_notify(NX_SNTP_CLIENT *client_ptr, VOID (time_update_cb)(NX_SNTP_TIME_MESSAGE *time_update_ptr, NX_SNTP_TIME *local_time)); 692 693 #else /* NX_SNTP_SOURCE_CODE */ 694 695 696 /* SNTP source code is being compiled, do not perform any API mapping. */ 697 698 UINT _nx_sntp_client_create(NX_SNTP_CLIENT *client_ptr, NX_IP *ip_ptr, UINT iface_index, NX_PACKET_POOL *packet_pool_ptr, 699 UINT (*leap_second_handler)(NX_SNTP_CLIENT *client_ptr, UINT indicator), 700 UINT (*kiss_of_death_handler)(NX_SNTP_CLIENT *client_ptr, UINT code), 701 VOID (random_number_generator)(struct NX_SNTP_CLIENT_STRUCT *client_ptr, ULONG *rand)); 702 UINT _nxe_sntp_client_create(NX_SNTP_CLIENT *client_ptr, NX_IP *ip_ptr, UINT iface_index, NX_PACKET_POOL *packet_pool_ptr, 703 UINT (*leap_second_handler)(NX_SNTP_CLIENT *client_ptr, UINT indicator), 704 UINT (*kiss_of_death_handler)(NX_SNTP_CLIENT *client_ptr, UINT code), 705 VOID (random_number_generator)(struct NX_SNTP_CLIENT_STRUCT *client_ptr, ULONG *rand)); 706 UINT _nx_sntp_client_delete (NX_SNTP_CLIENT *client_ptr); 707 UINT _nxe_sntp_client_delete (NX_SNTP_CLIENT *client_ptr); 708 UINT _nx_sntp_client_get_local_time(NX_SNTP_CLIENT *client_ptr, ULONG *seconds, ULONG *fraction, CHAR *buffer); 709 UINT _nxe_sntp_client_get_local_time(NX_SNTP_CLIENT *client_ptr, ULONG *seconds, ULONG *fraction, CHAR *buffer); 710 UINT _nx_sntp_client_get_local_time_extended(NX_SNTP_CLIENT *client_ptr, ULONG *seconds, ULONG *fraction, CHAR *buffer, UINT buffer_size); 711 UINT _nxe_sntp_client_get_local_time_extended(NX_SNTP_CLIENT *client_ptr, ULONG *seconds, ULONG *fraction, CHAR *buffer, UINT buffer_size); 712 UINT _nxde_sntp_client_initialize_broadcast(NX_SNTP_CLIENT *client_ptr, NXD_ADDRESS *multicast_server_address, NXD_ADDRESS *broadcast_time_server); 713 UINT _nxd_sntp_client_initialize_broadcast(NX_SNTP_CLIENT *client_ptr, NXD_ADDRESS *multicast_server_address, NXD_ADDRESS *broadcast_time_server); 714 UINT _nx_sntp_client_initialize_broadcast(NX_SNTP_CLIENT *client_ptr, ULONG multicast_server_address, ULONG broadcast_time_server); 715 UINT _nxe_sntp_client_initialize_broadcast(NX_SNTP_CLIENT *client_ptr, ULONG multicast_server_address, ULONG broadcast_time_server); 716 UINT _nxde_sntp_client_initialize_unicast(NX_SNTP_CLIENT *client_ptr, NXD_ADDRESS *unicast_time_server); 717 UINT _nxd_sntp_client_initialize_unicast(NX_SNTP_CLIENT *client_ptr, NXD_ADDRESS *unicast_time_server); 718 UINT _nx_sntp_client_initialize_unicast(NX_SNTP_CLIENT *client_ptr, ULONG unicast_time_server); 719 UINT _nxe_sntp_client_initialize_unicast(NX_SNTP_CLIENT *client_ptr, ULONG unicast_time_server); 720 UINT _nx_sntp_client_receiving_updates(NX_SNTP_CLIENT *client_ptr, UINT *server_status); 721 UINT _nxe_sntp_client_receiving_updates(NX_SNTP_CLIENT *client_ptr, UINT *server_status); 722 UINT _nx_sntp_client_run_broadcast(NX_SNTP_CLIENT *client_ptr); 723 UINT _nxe_sntp_client_run_broadcast(NX_SNTP_CLIENT *client_ptr); 724 UINT _nx_sntp_client_run_unicast(NX_SNTP_CLIENT *client_ptr); 725 UINT _nxe_sntp_client_run_unicast(NX_SNTP_CLIENT *client_ptr); 726 UINT _nx_sntp_client_set_local_time(NX_SNTP_CLIENT *client_ptr, ULONG seconds, ULONG fraction); 727 UINT _nxe_sntp_client_set_local_time(NX_SNTP_CLIENT *client_ptr, ULONG seconds, ULONG fraction); 728 UINT _nx_sntp_client_stop(NX_SNTP_CLIENT *client_ptr); 729 UINT _nxe_sntp_client_stop(NX_SNTP_CLIENT *client_ptr); 730 UINT _nx_sntp_client_utility_msecs_to_fraction(ULONG msecs, ULONG *fraction); 731 UINT _nxe_sntp_client_utility_msecs_to_fraction(ULONG msecs, ULONG *fraction); 732 UINT _nx_sntp_client_utility_usecs_to_fraction(ULONG usecs, ULONG *fraction); 733 UINT _nxe_sntp_client_utility_usecs_to_fraction(ULONG usecs, ULONG *fraction); 734 UINT _nx_sntp_client_utility_fraction_to_usecs(ULONG fraction, ULONG *usecs); 735 UINT _nxe_sntp_client_utility_fraction_to_usecs(ULONG fraction, ULONG *usecs); 736 UINT _nx_sntp_client_utility_display_date_time(NX_SNTP_CLIENT *client_ptr, CHAR *buffer, UINT length); 737 UINT _nxe_sntp_client_utility_display_date_time(NX_SNTP_CLIENT *client_ptr, CHAR *buffer, UINT length); 738 UINT _nxe_sntp_client_utility_display_NTP_time(NX_SNTP_CLIENT *client_ptr, CHAR *buffer); 739 UINT _nx_sntp_client_request_unicast_time(NX_SNTP_CLIENT *client_ptr, UINT wait_option); 740 UINT _nxe_sntp_client_request_unicast_time(NX_SNTP_CLIENT *client_ptr, UINT wait_option); 741 UINT _nx_sntp_client_set_time_update_notify(NX_SNTP_CLIENT *client_ptr, VOID (time_update_cb)(NX_SNTP_TIME_MESSAGE *time_update_ptr, NX_SNTP_TIME *local_time)); 742 UINT _nxe_sntp_client_set_time_update_notify(NX_SNTP_CLIENT *client_ptr, VOID (time_update_cb)(NX_SNTP_TIME_MESSAGE *time_update_ptr, NX_SNTP_TIME *local_time)); 743 744 /* Define internal SNTP Client functions. */ 745 746 UINT _nx_sntp_client_apply_sanity_checks(NX_SNTP_CLIENT *client_ptr); 747 UINT _nx_sntp_client_calculate_roundtrip(LONG *roundtrip_time); 748 UINT _nx_sntp_client_check_server_clock_dispersion(NX_SNTP_CLIENT *client_ptr); 749 UINT _nx_sntp_client_create_time_request_packet(NX_SNTP_CLIENT *client_ptr, NX_PACKET *packet_ptr, NX_SNTP_TIME_MESSAGE *time_message_ptr); 750 UINT _nx_sntp_client_duplicate_update_check(NX_SNTP_TIME_MESSAGE *timeA_msg_ptr, NX_SNTP_TIME_MESSAGE *timeB_msg_ptr, UINT *is_a_dupe); 751 UINT _nx_sntp_client_extract_time_message_from_packet(NX_SNTP_CLIENT *client_ptr, NX_PACKET *packet_ptr); 752 VOID _nx_sntp_client_process(NX_SNTP_CLIENT *client_ptr); 753 VOID _nx_sntp_client_process_broadcast(NX_SNTP_CLIENT *client_ptr); 754 VOID _nx_sntp_client_process_unicast(NX_SNTP_CLIENT *client_ptr); 755 UINT _nx_sntp_client_process_time_data(NX_SNTP_CLIENT *client_ptr); 756 UINT _nx_sntp_client_process_update_packet(NX_SNTP_CLIENT *client_ptr); 757 VOID _nx_sntp_client_receive_notify(NX_UDP_SOCKET *socket_ptr); 758 UINT _nx_sntp_client_receive_time_update(NX_SNTP_CLIENT *client_ptr, ULONG timeout); 759 UINT _nx_sntp_client_reset_current_time_message(NX_SNTP_CLIENT *client_ptr); 760 UINT _nx_sntp_client_send_unicast_request(NX_SNTP_CLIENT *client_ptr); 761 VOID _nx_sntp_client_thread_entry(ULONG sntp_instance); 762 VOID _nx_sntp_client_update_timeout_entry(ULONG info); 763 UINT _nx_sntp_client_utility_add_msecs_to_ntp_time(NX_SNTP_TIME *timeA_ptr, LONG msecs_to_add); 764 UINT _nx_sntp_client_utility_convert_fraction_to_msecs(ULONG *milliseconds, NX_SNTP_TIME *time_ptr); 765 UINT _nx_sntp_client_utility_convert_seconds_to_date(NX_SNTP_TIME *current_NTP_time_ptr, UINT current_year, NX_SNTP_DATE_TIME *current_date_time_ptr); 766 UINT _nx_sntp_client_utility_convert_refID_KOD_code(UCHAR *reference_id, UINT *code_id); 767 UINT _nx_sntp_client_utility_get_msec_diff(NX_SNTP_TIME *timeA_ptr, NX_SNTP_TIME *timeB_ptr, ULONG *total_difference_msecs, UINT *pos_diff); 768 UINT _nx_sntp_client_utility_addition_overflow_check(ULONG temp1, ULONG temp2); 769 UINT _nx_sntp_client_utility_convert_time_to_UCHAR(NX_SNTP_TIME *time, NX_SNTP_TIME_MESSAGE *time_message_ptr, UINT which_stamp); 770 UINT _nx_sntp_client_utility_is_zero_data(UCHAR *data, UINT size); 771 772 773 774 #endif /* NX_SNTP_SOURCE_CODE */ 775 776 /* If a C++ compiler is being used....*/ 777 #ifdef __cplusplus 778 } 779 #endif 780 781 782 #endif /* NXD_SNTP_CLIENT_H */ 783