22#ifndef NET_NTP_PACKET_H
23#define NET_NTP_PACKET_H
39#define NTP_PACKET_LI_POS (6U)
40#define NTP_PACKET_LI_MASK (0xc0)
41#define NTP_PACKET_VN_POS (3U)
42#define NTP_PACKET_VN_MASK (0x38)
43#define NTP_PACKET_MODE_MASK (0x07)
46#define NTP_VERSION (4U)
47#define NTP_PORT (123U)
53#define NTP_UNIX_OFFSET (2208988800)
73typedef struct __attribute__((packed)) {
83typedef struct __attribute__((packed)) {
Functions to work with different byte orders.
#define NTP_VERSION
NTP version.
static uint8_t ntp_packet_get_li(ntp_packet_t *packet)
Get leap indicator from a NTP packet.
static void ntp_packet_set_mode(ntp_packet_t *packet, ntp_mode_t mode)
Set mode in a NTP packet.
static void ntp_packet_set_li(ntp_packet_t *packet, uint8_t li)
Set leap indicator in a NTP packet.
#define NTP_PACKET_VN_POS
version position
static ntp_mode_t ntp_packet_get_mode(ntp_packet_t *packet)
Get mode from a NTP packet.
#define NTP_PACKET_LI_POS
Bit positions and masks for ntp_packet_t::li_vn_mode.
#define NTP_PACKET_VN_MASK
version mask
static void ntp_packet_set_vn(ntp_packet_t *packet)
Set version in a NTP packet.
#define NTP_PACKET_MODE_MASK
mode mask
#define NTP_PACKET_LI_MASK
leap indicator mask
static uint8_t ntp_packet_get_vn(ntp_packet_t *packet)
Get version from a NTP packet.
@ NTP_MODE_RESERVED
reserved
@ NTP_MODE_SYM_ACTIVE
symmetric active
@ NTP_MODE_SYM_PASSIVE
symmetric passive
@ NTP_MODE_PRIV
reserved for private use
@ NTP_MODE_BROADCAST
broadcast
ntp_timestamp_t receive
receive timestamp
uint8_t li_vn_mode
leap indicator, version and mode
ntp_timestamp_t reference
reference timestamp
uint8_t precision
precision in log2 seconds
uint8_t poll
poll in log2 seconds
ntp_timestamp_t transmit
transmit timestamp
network_uint32_t root_dispersion
root dispersion in NTP short format
ntp_timestamp_t origin
origin timesptamp
network_uint32_t reference_id
reference ID
network_uint32_t root_delay
root delay in NTP short format
network_uint32_t seconds
seconds since 1 January 1900 00:00 UTC
network_uint32_t fraction
fraction of seconds in 232 picoseconds
A 32 bit integer in big endian aka network byte order.