97 sizeof (
hdr ) ) ) != 0 ) {
98 DBGC (
ntp,
"NTP %p could not send request: %s\n",
124 DBGC (
ntp,
"NTP %p received non-NTP packet:\n",
ntp );
131 DBGC (
ntp,
"NTP %p received malformed packet:\n",
ntp );
139 DBGC (
ntp,
"NTP %p received non-server packet:\n",
ntp );
146 DBGC (
ntp,
"NTP %p received unrecognised packet:\n",
ntp );
152 if ( !
hdr->stratum ) {
153 DBGC (
ntp,
"NTP %p received kiss-o'-death:\n",
ntp );
160 delta = (
ntohl (
hdr->receive.seconds ) -
162 DBGC (
ntp,
"NTP %p delta %d seconds\n",
ntp, delta );
165 time_adjust ( delta );
258 memset ( &server, 0,
sizeof ( server ) );
261 hostname,
NULL ) ) != 0 ) {
262 DBGC (
ntp,
"NTP %p could not open socket: %s\n",
282 .description =
"NTP server",
284 .type = &setting_type_ipv4,
An object interface operation.
#define DHCP_NTP_SERVERS
NTP servers.
struct arbelprm_rc_send_wqe rc
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
void intf_close(struct interface *intf, int rc)
Close an object interface.
Dynamic Host Configuration Protocol.
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
static void ntp_window_changed(struct ntp_client *ntp)
Handle data transfer window change.
#define ref_init(refcnt, free)
Initialise a reference counter.
struct golan_inbox_hdr hdr
Message header.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
#define NTP_EPOCH
NTP timestamp for start of Unix epoch.
int start_ntp(struct interface *job, const char *hostname)
Start NTP client.
#define NTP_FL_VN_1
NTP version: 1.
#define NTP_FL_MODE_CLIENT
NTP mode: client.
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Dynamic memory allocation.
Data transfer interfaces.
#define NTP_FRACTION_MAGIC
NTP fraction of a second magic value.
#define ENOMEM
Not enough space.
#define SETTING_IP4_EXTRA
IPv4 additional settings.
#define container_of(ptr, type, field)
Get containing structure.
struct interface xfer
Data transfer interface.
Transport-network layer interface.
int ntp(const char *hostname)
Get time and date via NTP.
#define EPROTO
Protocol error.
uint16_t st_port
TCP/IP port.
Generalized socket address structure.
An object interface descriptor.
#define NTP_PORT
NTP port.
char * strerror(int errno)
Retrieve string representation of error number.
const struct setting ntp_setting __setting(SETTING_IP4_EXTRA, ntp)
IPv4 NTP server setting.
void * zalloc(size_t size)
Allocate cleared memory.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
static struct interface_descriptor ntp_xfer_desc
Data transfer interface descriptor.
static struct interface_descriptor ntp_job_desc
Job control interface descriptor.
static int ntp_request(struct ntp_client *ntp)
Send NTP request.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Data transfer interface opening.
#define NTP_FL_LI_UNKNOWN
Leap second indicator: unknown.
#define NTP_MIN_TIMEOUT
NTP minimum retransmission timeout.
void start_timer(struct retry_timer *timer)
Start timer.
static int ntp_deliver(struct ntp_client *ntp, struct io_buffer *iobuf, struct xfer_metadata *meta)
Handle NTP response.
void stop_timer(struct retry_timer *timer)
Stop timer.
static struct interface_operation ntp_xfer_op[]
Data transfer interface operations.
static void ntp_close(struct ntp_client *ntp, int rc)
Close NTP client.
#define NTP_MAX_TIMEOUT
NTP maximum retransmission timeout.
void * data
Start of data.
static void ntp_expired(struct retry_timer *timer, int fail)
Handle NTP timer expiry.
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
#define NTP_FL_MODE_SERVER
NTP mode: server.
static struct evtchn_close * close
#define NTP_FL_MODE_MASK
NTP mode mask.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
struct interface job
Job control interface.
#define NULL
NULL pointer (VOID *)
#define ETIMEDOUT
Connection timed out.
static struct interface_operation ntp_job_op[]
Job control interface operations.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int xfer_open_named_socket(struct interface *xfer, int semantics, struct sockaddr *peer, const char *name, struct sockaddr *local)
Open named socket.
#define ref_put(refcnt)
Drop reference to object.
void * memset(void *dest, int character, size_t len) __nonnull