xref: /freebsd/contrib/ntp/include/ntp_io.h (revision 119b75925c562202145d7bac7b676b98029c6cb9)
1 #ifndef NTP_IO_H
2 #define NTP_IO_H
3 
4 #include "ntp_workimpl.h"
5 
6 /*
7  * POSIX says use <fnct.h> to get O_* symbols and
8  * SEEK_SET symbol form <unistd.h>.
9  */
10 #include <sys/types.h>
11 #ifdef HAVE_UNISTD_H
12 # include <unistd.h>
13 #endif
14 #include <stdio.h>
15 #ifdef HAVE_SYS_FILE_H
16 # include <sys/file.h>
17 #endif
18 #ifdef HAVE_FCNTL_H
19 # include <fcntl.h>
20 #endif
21 #if !defined(SEEK_SET) && defined(L_SET)
22 # define SEEK_SET L_SET
23 #endif
24 
25 #ifdef SYS_WINNT
26 # include <io.h>
27 # include "win32_io.h"
28 #endif
29 
30 #include <isc/boolean.h>
31 #include <isc/netaddr.h>
32 
33 #if defined(HAVE_NETINET_IN_H) && defined(HAVE_NETINET_IP_H)
34 # include <netinet/in.h>
35 # ifdef HAVE_NETINET_IN_SYSTM_H
36 #  include <netinet/in_systm.h>
37 # endif
38 # include <netinet/ip.h>
39 #endif
40 
41 #include "libntp.h"	/* This needs Something above for GETDTABLESIZE */
42 
43 /*
44  * Define FNDELAY and FASYNC using O_NONBLOCK and O_ASYNC if we need
45  * to (and can).  This is here initially for QNX, but may help for
46  * others as well...
47  */
48 #ifndef FNDELAY
49 # ifdef O_NONBLOCK
50 #  define FNDELAY O_NONBLOCK
51 # endif
52 #endif
53 
54 #ifndef FASYNC
55 # ifdef O_ASYNC
56 #  define FASYNC O_ASYNC
57 # endif
58 #endif
59 
60 
61 /*
62  * NIC rule match types
63  */
64 typedef enum {
65 	MATCH_ALL,
66 	MATCH_IPV4,
67 	MATCH_IPV6,
68 	MATCH_WILDCARD,
69 	MATCH_IFNAME,
70 	MATCH_IFADDR
71 } nic_rule_match;
72 
73 /*
74  * NIC rule actions
75  */
76 typedef enum {
77 	ACTION_LISTEN,
78 	ACTION_IGNORE,
79 	ACTION_DROP
80 } nic_rule_action;
81 
82 
83 extern int	qos;
84 SOCKET		move_fd(SOCKET fd);
85 isc_boolean_t	get_broadcastclient_flag(void);
86 extern int	is_ip_address(const char *, u_short, sockaddr_u *);
87 extern void	sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *);
88 extern void	add_nic_rule(nic_rule_match match_type,
89 			     const char *if_name, int prefixlen,
90 			     nic_rule_action action);
91 #ifndef HAVE_IO_COMPLETION_PORT
92 extern	void	maintain_activefds(int fd, int closing);
93 #else
94 #define		maintain_activefds(f, c)	do {} while (0)
95 #endif
96 
97 
98 #endif	/* NTP_IO_H */
99