Go to the documentation of this file.
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)
73 typedef struct __attribute__((packed)) {
83 typedef struct __attribute__((packed)) {
A 32 bit integer in big endian aka network byte order.
static uint8_t ntp_packet_get_vn(ntp_packet_t *packet)
Get version from a NTP packet.
static void ntp_packet_set_mode(ntp_packet_t *packet, ntp_mode_t mode)
Set mode in a NTP packet.
uint8_t li_vn_mode
leap indicator, version and mode
Functions to work with different byte orders.
network_uint32_t root_dispersion
root dispersion in NTP short format
@ NTP_MODE_RESERVED
reserved
uint8_t poll
poll in log2 seconds
#define NTP_PACKET_LI_POS
Bit positions and masks for ntp_packet_t::li_vn_mode.
network_uint32_t root_delay
root delay in NTP short format
static void ntp_packet_set_vn(ntp_packet_t *packet)
Set version in a NTP packet.
static uint8_t ntp_packet_get_li(ntp_packet_t *packet)
Get leap indicator from a NTP packet.
static void ntp_packet_set_li(ntp_packet_t *packet, uint8_t li)
Set leap indicator in a NTP packet.
@ NTP_MODE_SYM_ACTIVE
symmetric active
network_uint32_t fraction
fraction of seconds in 232 picoseconds
network_uint32_t reference_id
reference ID
#define NTP_PACKET_VN_MASK
version mask
uint8_t precision
precision in log2 seconds
@ NTP_MODE_SYM_PASSIVE
symmetric passive
#define NTP_PACKET_MODE_MASK
mode mask
@ NTP_MODE_PRIV
reserved for private use
network_uint32_t seconds
seconds since 1 January 1900 00:00 UTC
ntp_timestamp_t reference
reference timestamp
#define NTP_VERSION
NTP version.
static ntp_mode_t ntp_packet_get_mode(ntp_packet_t *packet)
Get mode from a NTP packet.
ntp_timestamp_t origin
origin timesptamp
#define NTP_PACKET_LI_MASK
leap indicator mask
@ NTP_MODE_BROADCAST
broadcast
ntp_timestamp_t transmit
transmit timestamp
ntp_timestamp_t receive
receive timestamp
#define NTP_PACKET_VN_POS
version position