iPXE
ntp.h
Go to the documentation of this file.
1#ifndef _IPXE_NTP_H
2#define _IPXE_NTP_H
3
4/** @file
5 *
6 * Network Time Protocol
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/in.h>
15#include <ipxe/interface.h>
16
17/** NTP port */
18#define NTP_PORT 123
19
20/** An NTP short-format timestamp */
21struct ntp_short {
22 /** Seconds */
24 /** Fraction of a second */
26} __attribute__ (( packed ));
27
28/** An NTP timestamp */
30 /** Seconds */
32 /** Fraction of a second */
34} __attribute__ (( packed ));
35
36/** An NTP reference identifier */
37union ntp_id {
38 /** Textual identifier */
39 char text[4];
40 /** IPv4 address */
41 struct in_addr in;
42 /** Opaque integer */
44};
45
46/** An NTP header */
47struct ntp_header {
48 /** Flags */
50 /** Stratum */
52 /** Polling rate */
54 /** Precision */
56 /** Root delay */
58 /** Root dispersion */
60 /** Reference clock identifier */
61 union ntp_id id;
62 /** Reference timestamp */
64 /** Originate timestamp */
66 /** Receive timestamp */
68 /** Transmit timestamp */
70} __attribute__ (( packed ));
71
72/** Leap second indicator: unknown */
73#define NTP_FL_LI_UNKNOWN 0xc0
74
75/** NTP version: 1 */
76#define NTP_FL_VN_1 0x20
77
78/** NTP mode: client */
79#define NTP_FL_MODE_CLIENT 0x03
80
81/** NTP mode: server */
82#define NTP_FL_MODE_SERVER 0x04
83
84/** NTP mode mask */
85#define NTP_FL_MODE_MASK 0x07
86
87/** NTP timestamp for start of Unix epoch */
88#define NTP_EPOCH 2208988800UL
89
90/** NTP fraction of a second magic value
91 *
92 * This is a policy decision.
93 */
94#define NTP_FRACTION_MAGIC 0x69505845UL
95
96/** NTP minimum retransmission timeout
97 *
98 * This is a policy decision.
99 */
100#define NTP_MIN_TIMEOUT ( 1 * TICKS_PER_SEC )
101
102/** NTP maximum retransmission timeout
103 *
104 * This is a policy decision.
105 */
106#define NTP_MAX_TIMEOUT ( 10 * TICKS_PER_SEC )
107
108extern int start_ntp ( struct interface *job, const char *hostname );
109
110#endif /* _IPXE_NTP_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
signed char int8_t
Definition stdint.h:15
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
Object interfaces.
int start_ntp(struct interface *job, const char *hostname)
Start NTP client.
Definition ntp.c:238
IP address structure.
Definition in.h:42
An object interface.
Definition interface.h:125
An NTP header.
Definition ntp.h:47
struct ntp_timestamp originate
Originate timestamp.
Definition ntp.h:65
struct ntp_timestamp transmit
Transmit timestamp.
Definition ntp.h:69
int8_t precision
Precision.
Definition ntp.h:55
struct ntp_timestamp reference
Reference timestamp.
Definition ntp.h:63
uint8_t stratum
Stratum.
Definition ntp.h:51
struct ntp_short delay
Root delay.
Definition ntp.h:57
uint8_t flags
Flags.
Definition ntp.h:49
struct ntp_timestamp receive
Receive timestamp.
Definition ntp.h:67
union ntp_id id
Reference clock identifier.
Definition ntp.h:61
int8_t poll
Polling rate.
Definition ntp.h:53
struct ntp_short dispersion
Root dispersion.
Definition ntp.h:59
An NTP short-format timestamp.
Definition ntp.h:21
uint16_t fraction
Fraction of a second.
Definition ntp.h:25
uint16_t seconds
Seconds.
Definition ntp.h:23
An NTP timestamp.
Definition ntp.h:29
uint32_t fraction
Fraction of a second.
Definition ntp.h:33
uint32_t seconds
Seconds.
Definition ntp.h:31
An NTP reference identifier.
Definition ntp.h:37
struct in_addr in
IPv4 address.
Definition ntp.h:41
uint32_t opaque
Opaque integer.
Definition ntp.h:43
char text[4]
Textual identifier.
Definition ntp.h:39