Loading...
Searching...
No Matches
ntp_packet.h File Reference

NTP packet definitions. More...

Detailed Description

#include <stdint.h>
#include "byteorder.h"
+ Include dependency graph for ntp_packet.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ntp_timestamp_t
 NTP timestamp. More...
 
struct  ntp_packet_t
 NTP packet. More...
 

Macros

#define NTP_VERSION   (4U)
 NTP version.
 
#define NTP_PORT   (123U)
 NTP port number.
 
#define NTP_UNIX_OFFSET   (2208988800)
 Offset in seconds of NTP timestamp (seconds from 1990-01-01 00:00:00 UTC) to UNIX timestamp (seconds from 1970-01-01 00:00:00 UTC).
 

Enumerations

enum  ntp_mode_t {
  NTP_MODE_RESERVED = 0 , NTP_MODE_SYM_ACTIVE , NTP_MODE_SYM_PASSIVE , NTP_MODE_CLIENT ,
  NTP_MODE_SERVER , NTP_MODE_BROADCAST , NTP_MODE_PRIV
}
 NTP modes. More...
 

Functions

static void ntp_packet_set_li (ntp_packet_t *packet, uint8_t li)
 Set leap indicator in a NTP packet.
 
static void ntp_packet_set_vn (ntp_packet_t *packet)
 Set version in a NTP packet.
 
static void ntp_packet_set_mode (ntp_packet_t *packet, ntp_mode_t mode)
 Set mode in a NTP packet.
 
static uint8_t ntp_packet_get_li (ntp_packet_t *packet)
 Get leap indicator from a NTP packet.
 
static uint8_t ntp_packet_get_vn (ntp_packet_t *packet)
 Get version from a NTP packet.
 
static ntp_mode_t ntp_packet_get_mode (ntp_packet_t *packet)
 Get mode from a NTP packet.
 
#define NTP_PACKET_LI_POS   (6U)
 Bit positions and masks for ntp_packet_t::li_vn_mode.
 
#define NTP_PACKET_LI_MASK   (0xc0)
 leap indicator mask
 
#define NTP_PACKET_VN_POS   (3U)
 version position
 
#define NTP_PACKET_VN_MASK   (0x38)
 version mask
 
#define NTP_PACKET_MODE_MASK   (0x07)
 mode mask