forked from systemd/systemd
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
timesync: save and expose NTP responce on bus
- Loading branch information
Showing
5 changed files
with
126 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* SPDX-License-Identifier: LGPL-2.1+ */ | ||
#pragma once | ||
|
||
#include "sparse-endian.h" | ||
|
||
/* NTP protocol, packet header */ | ||
#define NTP_LEAP_PLUSSEC 1 | ||
#define NTP_LEAP_MINUSSEC 2 | ||
#define NTP_LEAP_NOTINSYNC 3 | ||
#define NTP_MODE_CLIENT 3 | ||
#define NTP_MODE_SERVER 4 | ||
#define NTP_FIELD_LEAP(f) (((f) >> 6) & 3) | ||
#define NTP_FIELD_VERSION(f) (((f) >> 3) & 7) | ||
#define NTP_FIELD_MODE(f) ((f) & 7) | ||
#define NTP_FIELD(l, v, m) (((l) << 6) | ((v) << 3) | (m)) | ||
|
||
/* | ||
* "NTP timestamps are represented as a 64-bit unsigned fixed-point number, | ||
* in seconds relative to 0h on 1 January 1900." | ||
*/ | ||
#define OFFSET_1900_1970 UINT64_C(2208988800) | ||
|
||
struct ntp_ts { | ||
be32_t sec; | ||
be32_t frac; | ||
} _packed_; | ||
|
||
struct ntp_ts_short { | ||
be16_t sec; | ||
be16_t frac; | ||
} _packed_; | ||
|
||
struct ntp_msg { | ||
uint8_t field; | ||
uint8_t stratum; | ||
int8_t poll; | ||
int8_t precision; | ||
struct ntp_ts_short root_delay; | ||
struct ntp_ts_short root_dispersion; | ||
char refid[4]; | ||
struct ntp_ts reference_time; | ||
struct ntp_ts origin_time; | ||
struct ntp_ts recv_time; | ||
struct ntp_ts trans_time; | ||
} _packed_; |