Zephyr Project API 3.5.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sntp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Linaro Limited
3 * Copyright (c) 2019 Intel Corporation
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef ZEPHYR_INCLUDE_NET_SNTP_H_
9#define ZEPHYR_INCLUDE_NET_SNTP_H_
10
11#include <zephyr/net/socket.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
25struct sntp_ctx {
26 struct {
27 struct zsock_pollfd fds[1];
28 int nfds;
29 int fd;
31
37};
38
44
54int sntp_init(struct sntp_ctx *ctx, struct sockaddr *addr,
55 socklen_t addr_len);
56
68 struct sntp_time *time);
69
75void sntp_close(struct sntp_ctx *ctx);
76
90int sntp_simple(const char *server, uint32_t timeout,
91 struct sntp_time *time);
92
93#ifdef __cplusplus
94}
95#endif
96
101#endif
ZTEST_BMEM int timeout
Definition main.c:31
size_t socklen_t
Length of a socket address.
Definition net_ip.h:168
void sntp_close(struct sntp_ctx *ctx)
Release SNTP context.
int sntp_query(struct sntp_ctx *ctx, uint32_t timeout, struct sntp_time *time)
Perform SNTP query.
int sntp_init(struct sntp_ctx *ctx, struct sockaddr *addr, socklen_t addr_len)
Initialize SNTP context.
int sntp_simple(const char *server, uint32_t timeout, struct sntp_time *time)
Convenience function to query SNTP in one-shot fashion.
time_t time(time_t *tloc)
BSD Sockets compatible API definitions.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
SNTP context.
Definition sntp.h:25
int nfds
Definition sntp.h:28
int fd
Definition sntp.h:29
struct sntp_ctx::@323 sock
struct zsock_pollfd fds[1]
Definition sntp.h:27
uint32_t expected_orig_ts
Timestamp when the request was sent from client to server.
Definition sntp.h:36
Time as returned by SNTP API, fractional seconds since 1 Jan 1970.
Definition sntp.h:40
uint64_t seconds
Definition sntp.h:41
uint32_t fraction
Definition sntp.h:42
Generic sockaddr struct.
Definition net_ip.h:347
Definition socket.h:38