1 /*
2   chronyd/chronyc - Programs for keeping computer clocks accurate.
3 
4  **********************************************************************
5  * Copyright (C) Richard P. Curnow  1997-2002
6  * Copyright (C) Miroslav Lichvar  2014
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of version 2 of the GNU General Public License as
10  * published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20  *
21  **********************************************************************
22 
23   =======================================================================
24 
25   This is the header file for the NTP socket I/O bits.
26 
27   */
28 
29 #ifndef GOT_NTP_IO_H
30 #define GOT_NTP_IO_H
31 
32 #include "ntp.h"
33 #include "addressing.h"
34 #include "socket.h"
35 
36 /* Function to initialise the module. */
37 extern void NIO_Initialise(void);
38 
39 /* Function to finalise the module */
40 extern void NIO_Finalise(void);
41 
42 /* Function to obtain a socket for sending client packets */
43 extern int NIO_OpenClientSocket(NTP_Remote_Address *remote_addr);
44 
45 /* Function to obtain a socket for sending server/peer packets */
46 extern int NIO_OpenServerSocket(NTP_Remote_Address *remote_addr);
47 
48 /* Function to close a socket returned by NIO_OpenClientSocket() */
49 extern void NIO_CloseClientSocket(int sock_fd);
50 
51 /* Function to close a socket returned by NIO_OpenServerSocket() */
52 extern void NIO_CloseServerSocket(int sock_fd);
53 
54 /* Function to check if socket is a server socket */
55 extern int NIO_IsServerSocket(int sock_fd);
56 
57 /* Function to check if a server socket is currently open */
58 extern int NIO_IsServerSocketOpen(void);
59 
60 /* Function to check if client packets can be sent to a server */
61 extern int NIO_IsServerConnectable(NTP_Remote_Address *remote_addr);
62 
63 /* Function to unwrap an NTP message from non-native transport (e.g. PTP) */
64 extern int NIO_UnwrapMessage(SCK_Message *message, int sock_fd);
65 
66 /* Function to transmit a packet */
67 extern int NIO_SendPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr,
68                           NTP_Local_Address *local_addr, int length, int process_tx);
69 
70 #endif /* GOT_NTP_IO_H */
71