Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | b4ad962 | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Masami Komiya <mkomiya@sonare.it> 2005 |
wdenk | b4ad962 | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef __SNTP_H__ |
| 7 | #define __SNTP_H__ |
| 8 | |
| 9 | #define NTP_SERVICE_PORT 123 |
| 10 | #define SNTP_PACKET_LEN 48 |
| 11 | |
wdenk | b4ad962 | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 12 | /* Leap Indicator */ |
| 13 | #define NTP_LI_NOLEAP 0x0 |
| 14 | #define NTP_LI_61SECS 0x1 |
| 15 | #define NTP_LI_59SECS 0x2 |
| 16 | #define NTP_LI_ALARM 0x3 |
| 17 | |
| 18 | /* Version */ |
| 19 | |
| 20 | #define NTP_VERSION 4 |
| 21 | |
| 22 | /* Mode */ |
| 23 | #define NTP_MODE_RESERVED 0 |
| 24 | #define NTP_MODE_SYMACTIVE 1 /* Symmetric Active */ |
| 25 | #define NTP_MODE_SYMPASSIVE 2 /* Symmetric Passive */ |
| 26 | #define NTP_MODE_CLIENT 3 |
| 27 | #define NTP_MODE_SERVER 4 |
| 28 | #define NTP_MODE_BROADCAST 5 |
| 29 | #define NTP_MODE_NTPCTRL 6 /* Reserved for NTP control message */ |
| 30 | #define NTP_MODE_PRIVATE 7 /* Reserved for private use */ |
| 31 | |
| 32 | struct sntp_pkt_t { |
| 33 | #if __LITTLE_ENDIAN |
| 34 | uchar mode:3; |
| 35 | uchar vn:3; |
| 36 | uchar li:2; |
| 37 | #else |
| 38 | uchar li:2; |
| 39 | uchar vn:3; |
| 40 | uchar mode:3; |
| 41 | #endif |
| 42 | uchar stratum; |
| 43 | uchar poll; |
| 44 | uchar precision; |
| 45 | uint root_delay; |
| 46 | uint root_dispersion; |
| 47 | uint reference_id; |
| 48 | unsigned long long reference_timestamp; |
| 49 | unsigned long long originate_timestamp; |
| 50 | unsigned long long receive_timestamp; |
| 51 | unsigned long long transmit_timestamp; |
Denis Pynkin | 4c7a6e0 | 2017-07-21 19:28:42 +0300 | [diff] [blame] | 52 | } __attribute__((packed)); |
wdenk | b4ad962 | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 53 | |
Philippe Reynes | 2829d99 | 2020-09-18 14:13:02 +0200 | [diff] [blame] | 54 | int sntp_prereq(void *data); |
| 55 | int sntp_start(void *data); /* Begin SNTP */ |
wdenk | b4ad962 | 2005-04-01 00:25:43 +0000 | [diff] [blame] | 56 | |
| 57 | #endif /* __SNTP_H__ */ |