xref: /freebsd/contrib/ntp/include/ntp_io.h (revision e43d33d286a1aa41b6fc6a209f28a18e8cd7437a)
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 #include "ntp_keyacc.h"
44 
45 /*
46  * Define FNDELAY and FASYNC using O_NONBLOCK and O_ASYNC if we need
47  * to (and can).  This is here initially for QNX, but may help for
48  * others as well...
49  */
50 #ifndef FNDELAY
51 # ifdef O_NONBLOCK
52 #  define FNDELAY O_NONBLOCK
53 # endif
54 #endif
55 
56 #ifndef FASYNC
57 # ifdef O_ASYNC
58 #  define FASYNC O_ASYNC
59 # endif
60 #endif
61 
62 
63 /*
64  * NIC rule match types
65  */
66 typedef enum {
67 	MATCH_ALL,
68 	MATCH_IPV4,
69 	MATCH_IPV6,
70 	MATCH_WILDCARD,
71 	MATCH_IFNAME,
72 	MATCH_IFADDR
73 } nic_rule_match;
74 
75 /*
76  * NIC rule actions
77  */
78 typedef enum {
79 	ACTION_LISTEN,
80 	ACTION_IGNORE,
81 	ACTION_DROP
82 } nic_rule_action;
83 
84 
85 extern int	qos;
86 SOCKET		move_fd(SOCKET fd);
87 /*isc_boolean_t	get_broadcastclient_flag(void);*/
88 extern void	sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *);
89 extern void	add_nic_rule(nic_rule_match match_type,
90 			     const char *if_name, int prefixlen,
91 			     nic_rule_action action);
92 #ifndef HAVE_IO_COMPLETION_PORT
93 extern	void	maintain_activefds(int fd, int closing);
94 #else
95 #define		maintain_activefds(f, c)	do {} while (0)
96 #endif
97 
98 
99 #endif	/* NTP_IO_H */
100