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