123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- #ifndef ZEPHYR_INCLUDE_NET_SNTP_H_
- #define ZEPHYR_INCLUDE_NET_SNTP_H_
- #ifdef CONFIG_NET_SOCKETS_POSIX_NAMES
- #include <net/socket.h>
- #else
- #include <posix/sys/socket.h>
- #include <posix/unistd.h>
- #include <posix/poll.h>
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- struct sntp_ctx {
- struct {
- struct pollfd fds[1];
- int nfds;
- int fd;
- } sock;
-
- uint32_t expected_orig_ts;
- };
- struct sntp_time {
- uint64_t seconds;
- uint32_t fraction;
- };
- int sntp_init(struct sntp_ctx *ctx, struct sockaddr *addr,
- socklen_t addr_len);
- int sntp_query(struct sntp_ctx *ctx, uint32_t timeout,
- struct sntp_time *time);
- void sntp_close(struct sntp_ctx *ctx);
- int sntp_simple(const char *server, uint32_t timeout,
- struct sntp_time *time);
- #ifdef __cplusplus
- }
- #endif
- #endif
|