\hypertarget{ntputil_8h}{}\doxysection{mqtt/ntputil.h File Reference}
\label{ntputil_8h}\index{mqtt/ntputil.h@{mqtt/ntputil.h}}


A header file of N\+TP utility functions.  


{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$time.\+h$>$}\newline
Include dependency graph for ntputil.\+h\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=200pt]{ntputil_8h__incl}
\end{center}
\end{figure}
This graph shows which files directly or indirectly include this file\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=276pt]{ntputil_8h__dep__incl}
\end{center}
\end{figure}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int64\+\_\+t \mbox{\hyperlink{ntputil_8h_a841bdcb296a30cbb219bf12e819c0423}{ntputil\+\_\+get\+\_\+epoch}} (uint32\+\_\+t hnums, char $\ast$$\ast$hnames, uint16\+\_\+t $\ast$ports)
\begin{DoxyCompactList}\small\item\em Get N\+TP timestamps from the given or public N\+TP servers. \end{DoxyCompactList}\item 
uint32\+\_\+t \mbox{\hyperlink{ntputil_8h_a22348663e96af2a1bfb051c63ddc6a87}{\+\_\+convert\+\_\+to\+\_\+host\+\_\+byte\+\_\+order}} (uint32\+\_\+t in)
\begin{DoxyCompactList}\small\item\em Converting network byte order to host byte order. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
A header file of N\+TP utility functions. 

Copyright (C) 2021 Wook Song \href{mailto:wook16.song@samsung.com}{\texttt{ wook16.\+song@samsung.\+com}}

\begin{DoxyDate}{Date}
28 Jul 2021 
\end{DoxyDate}
\begin{DoxySeeAlso}{See also}
\href{https://github.com/nnstreamer/nnstreamer}{\texttt{ https\+://github.\+com/nnstreamer/nnstreamer}} 
\end{DoxySeeAlso}
\begin{DoxyAuthor}{Author}
Wook Song \href{mailto:wook16.song@samsung.com}{\texttt{ wook16.\+song@samsung.\+com}} 
\end{DoxyAuthor}
\begin{DoxyRefDesc}{Bug}
\item[\mbox{\hyperlink{bug__bug000023}{Bug}}]No known bugs except for N\+YI items \end{DoxyRefDesc}


\doxysubsection{Function Documentation}
\mbox{\Hypertarget{ntputil_8h_a22348663e96af2a1bfb051c63ddc6a87}\label{ntputil_8h_a22348663e96af2a1bfb051c63ddc6a87}} 
\index{ntputil.h@{ntputil.h}!\_convert\_to\_host\_byte\_order@{\_convert\_to\_host\_byte\_order}}
\index{\_convert\_to\_host\_byte\_order@{\_convert\_to\_host\_byte\_order}!ntputil.h@{ntputil.h}}
\doxysubsubsection{\texorpdfstring{\_convert\_to\_host\_byte\_order()}{\_convert\_to\_host\_byte\_order()}}
{\footnotesize\ttfamily uint32\+\_\+t \+\_\+convert\+\_\+to\+\_\+host\+\_\+byte\+\_\+order (\begin{DoxyParamCaption}\item[{uint32\+\_\+t}]{in }\end{DoxyParamCaption})}



Converting network byte order to host byte order. 

\begin{DoxyNote}{Note}
There is a problem in mocking ntohl in G\+Mock, so the wrapper function is temporarily used.
\end{DoxyNote}
Converting network byte order to host byte order. 

Definition at line 125 of file ntputil.\+c.

Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{ntputil_8h_a22348663e96af2a1bfb051c63ddc6a87_icgraph}
\end{center}
\end{figure}
\mbox{\Hypertarget{ntputil_8h_a841bdcb296a30cbb219bf12e819c0423}\label{ntputil_8h_a841bdcb296a30cbb219bf12e819c0423}} 
\index{ntputil.h@{ntputil.h}!ntputil\_get\_epoch@{ntputil\_get\_epoch}}
\index{ntputil\_get\_epoch@{ntputil\_get\_epoch}!ntputil.h@{ntputil.h}}
\doxysubsubsection{\texorpdfstring{ntputil\_get\_epoch()}{ntputil\_get\_epoch()}}
{\footnotesize\ttfamily int64\+\_\+t ntputil\+\_\+get\+\_\+epoch (\begin{DoxyParamCaption}\item[{uint32\+\_\+t}]{hnums,  }\item[{char $\ast$$\ast$}]{hnames,  }\item[{uint16\+\_\+t $\ast$}]{ports }\end{DoxyParamCaption})}



Get N\+TP timestamps from the given or public N\+TP servers. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em hnums} & A number of hostname and port pairs. If 0 is given, the N\+TP server pool will be used. \\
\hline
\mbox{\texttt{ in}}  & {\em hnames} & A list of hostname \\
\hline
\mbox{\texttt{ in}}  & {\em ports} & A list of port \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
an Unix epoch time as microseconds on success, negative values on error 
\end{DoxyReturn}
\begin{DoxyNote}{Note}
ntp\+\_\+timestamp\+\_\+t recv\+\_\+ts in ntp\+\_\+packet\+\_\+t means the timestamp as the packet left the N\+TP server. \textquotesingle{}sec\textquotesingle{} corresponds to the seconds passed since 1900 and \textquotesingle{}frac\textquotesingle{} 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\textquotesingle{}s endianness.

N\+TP 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
\end{DoxyNote}


Definition at line 140 of file ntputil.\+c.

Here is the call graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=347pt]{ntputil_8h_a841bdcb296a30cbb219bf12e819c0423_cgraph}
\end{center}
\end{figure}
Here is the caller graph for this function\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{ntputil_8h_a841bdcb296a30cbb219bf12e819c0423_icgraph}
\end{center}
\end{figure}
