Time Shield Library
C++ library for working with time
Loading...
Searching...
No Matches
ntp_packet.hpp File Reference

Go to the source code of this file.

Classes

struct  time_shield::detail::NtpPacket
 NTP packet layout (48 bytes). More...
 

Namespaces

namespace  time_shield
 Main namespace for the Time Shield library.
 
namespace  time_shield::detail
 

Enumerations

enum  time_shield::detail::NtpProtoError {
  time_shield::detail::NTP_EPROTO_BASE = -10000 , time_shield::detail::NTP_E_BAD_MODE = NTP_EPROTO_BASE - 1 , time_shield::detail::NTP_E_BAD_VERSION = NTP_EPROTO_BASE - 2 , time_shield::detail::NTP_E_BAD_LI = NTP_EPROTO_BASE - 3 ,
  time_shield::detail::NTP_E_BAD_STRATUM = NTP_EPROTO_BASE - 4 , time_shield::detail::NTP_E_KOD = NTP_EPROTO_BASE - 5 , time_shield::detail::NTP_E_BAD_TS = NTP_EPROTO_BASE - 6
}
 Protocol-level error codes for NTP parsing. More...
 

Functions

static uint8_t time_shield::detail::ntp_li (uint8_t li_vn_mode) noexcept
 Extract leap indicator from LI/VN/Mode field.
 
static uint8_t time_shield::detail::ntp_vn (uint8_t li_vn_mode) noexcept
 Extract version number from LI/VN/Mode field.
 
static uint8_t time_shield::detail::ntp_mode (uint8_t li_vn_mode) noexcept
 Extract mode from LI/VN/Mode field.
 
static uint64_t time_shield::detail::ntp_frac_to_us (uint32_t frac_net) noexcept
 Convert NTP fractional seconds to microseconds.
 
static bool time_shield::detail::ntp_ts_to_unix_us (uint32_t sec_net, uint32_t frac_net, uint64_t &out_us) noexcept
 Convert NTP timestamp parts to Unix microseconds.
 
static void time_shield::detail::fill_client_packet (NtpPacket &pkt, uint64_t now_us)
 Fill an NTP client request packet using local time.
 
static bool time_shield::detail::parse_server_packet (const NtpPacket &pkt, uint64_t arrival_us, int64_t &offset_us, int64_t &delay_us, int &stratum, int &out_error_code) noexcept
 Parse server response and compute offset and delay.