Doxygen Book
ntputil.h File Reference

A header file of NTP utility functions. More...

#include <stdint.h>
#include <time.h>
Include dependency graph for ntputil.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int64_t ntputil_get_epoch (uint32_t hnums, char **hnames, uint16_t *ports)
 Get NTP timestamps from the given or public NTP servers. More...
 
uint32_t _convert_to_host_byte_order (uint32_t in)
 Converting network byte order to host byte order. More...
 

Detailed Description

A header file of NTP utility functions.

Copyright (C) 2021 Wook Song wook1.nosp@m.6.so.nosp@m.ng@sa.nosp@m.msun.nosp@m.g.com

Date
28 Jul 2021
See also
https://github.com/nnstreamer/nnstreamer
Author
Wook Song wook1.nosp@m.6.so.nosp@m.ng@sa.nosp@m.msun.nosp@m.g.com
Bug:
No known bugs except for NYI items

Definition in file ntputil.h.

Function Documentation

◆ _convert_to_host_byte_order()

uint32_t _convert_to_host_byte_order ( uint32_t  in)

Converting network byte order to host byte order.

Note
There is a problem in mocking ntohl in GMock, so the wrapper function is temporarily used.

Converting network byte order to host byte order.

Definition at line 125 of file ntputil.c.

Here is the caller graph for this function:

◆ ntputil_get_epoch()

int64_t ntputil_get_epoch ( uint32_t  hnums,
char **  hnames,
uint16_t *  ports 
)

Get NTP timestamps from the given or public NTP servers.

Parameters
[in]hnumsA number of hostname and port pairs. If 0 is given, the NTP server pool will be used.
[in]hnamesA list of hostname
[in]portsA list of port
Returns
an Unix epoch time as microseconds on success, negative values on error
Note
ntp_timestamp_t recv_ts in ntp_packet_t means the timestamp as the packet left the NTP server. 'sec' corresponds to the seconds passed since 1900 and 'frac' is needed to convert seconds to smaller units of a second such as microsceonds. Note that the bit/byte order of those data should be converted to the host's endianness.
NTP uses an epoch of January 1, 1900 while the Unix epoch is the number of seconds that have elapsed since January 1, 1970. For this reason, we subtract 70 years worth of seconds from the seconds since 1900

Definition at line 140 of file ntputil.c.

Here is the call graph for this function:
Here is the caller graph for this function: