blob: c38bceed3f6a2044a91b970ada43eb2ef95d5889 [file] [log] [blame]
wdenkb4ad9622005-04-01 00:25:43 +00001/*
2 * (C) Masami Komiya <mkomiya@sonare.it> 2005
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
wdenkb4ad9622005-04-01 00:25:43 +00005 */
6
7#ifndef __SNTP_H__
8#define __SNTP_H__
9
10#define NTP_SERVICE_PORT 123
11#define SNTP_PACKET_LEN 48
12
13
14/* Leap Indicator */
15#define NTP_LI_NOLEAP 0x0
16#define NTP_LI_61SECS 0x1
17#define NTP_LI_59SECS 0x2
18#define NTP_LI_ALARM 0x3
19
20/* Version */
21
22#define NTP_VERSION 4
23
24/* Mode */
25#define NTP_MODE_RESERVED 0
26#define NTP_MODE_SYMACTIVE 1 /* Symmetric Active */
27#define NTP_MODE_SYMPASSIVE 2 /* Symmetric Passive */
28#define NTP_MODE_CLIENT 3
29#define NTP_MODE_SERVER 4
30#define NTP_MODE_BROADCAST 5
31#define NTP_MODE_NTPCTRL 6 /* Reserved for NTP control message */
32#define NTP_MODE_PRIVATE 7 /* Reserved for private use */
33
34struct sntp_pkt_t {
35#if __LITTLE_ENDIAN
36 uchar mode:3;
37 uchar vn:3;
38 uchar li:2;
39#else
40 uchar li:2;
41 uchar vn:3;
42 uchar mode:3;
43#endif
44 uchar stratum;
45 uchar poll;
46 uchar precision;
47 uint root_delay;
48 uint root_dispersion;
49 uint reference_id;
50 unsigned long long reference_timestamp;
51 unsigned long long originate_timestamp;
52 unsigned long long receive_timestamp;
53 unsigned long long transmit_timestamp;
Denis Pynkin4c7a6e02017-07-21 19:28:42 +030054} __attribute__((packed));
wdenkb4ad9622005-04-01 00:25:43 +000055
Joe Hershberger4af0b772015-04-08 01:41:12 -050056void sntp_start(void); /* Begin SNTP */
wdenkb4ad9622005-04-01 00:25:43 +000057
58#endif /* __SNTP_H__ */