Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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#ifdef CONFIG_NET_SOCKETS_POSIX_NAMES
12#include <net/socket.h>
13#else
14#include <posix/sys/socket.h>
15#include <posix/unistd.h>
16#include <posix/poll.h>
17#endif
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
31struct sntp_ctx {
32 struct {
33 struct pollfd fds[1];
34 int nfds;
35 int fd;
37
43};
44
46struct sntp_time {
49};
50
60int sntp_init(struct sntp_ctx *ctx, struct sockaddr *addr,
61 socklen_t addr_len);
62
74 struct sntp_time *time);
75
81void sntp_close(struct sntp_ctx *ctx);
82
96int sntp_simple(const char *server, uint32_t timeout,
97 struct sntp_time *time);
98
99#ifdef __cplusplus
100}
101#endif
102
107#endif
ZTEST_BMEM int timeout
Definition: main.c:31
size_t socklen_t
Definition: net_ip.h:161
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.
#define pollfd
Definition: poll.h:15
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
Definition: sntp.h:31
int nfds
Definition: sntp.h:34
struct pollfd fds[1]
Definition: sntp.h:33
int fd
Definition: sntp.h:35
struct sntp_ctx::@188 sock
uint32_t expected_orig_ts
Definition: sntp.h:42
Definition: sntp.h:46
uint64_t seconds
Definition: sntp.h:47
uint32_t fraction
Definition: sntp.h:48
Definition: net_ip.h:335