xref: /netbsd-src/external/bsd/ntp/dist/include/ntp_io.h (revision 6a493d6bc668897c91594964a732d38505b70cbb)
1 /*	$NetBSD: ntp_io.h,v 1.1.1.3 2013/12/27 23:30:45 christos Exp $	*/
2 
3 #ifndef NTP_IO_H
4 #define NTP_IO_H
5 
6 #include "ntp_workimpl.h"
7 
8 /*
9  * POSIX says use <fnct.h> to get O_* symbols and
10  * SEEK_SET symbol form <unistd.h>.
11  */
12 #include <sys/types.h>
13 #ifdef HAVE_UNISTD_H
14 # include <unistd.h>
15 #endif
16 #include <stdio.h>
17 #ifdef HAVE_SYS_FILE_H
18 # include <sys/file.h>
19 #endif
20 #ifdef HAVE_FCNTL_H
21 # include <fcntl.h>
22 #endif
23 #if !defined(SEEK_SET) && defined(L_SET)
24 # define SEEK_SET L_SET
25 #endif
26 
27 #ifdef SYS_WINNT
28 # include <io.h>
29 # include "win32_io.h"
30 #endif
31 
32 #include <isc/boolean.h>
33 #include <isc/netaddr.h>
34 
35 #if defined(HAVE_NETINET_IN_H) && defined(HAVE_NETINET_IP_H)
36 # include <netinet/in.h>
37 # ifdef HAVE_NETINET_IN_SYSTM_H
38 #  include <netinet/in_systm.h>
39 # endif
40 # include <netinet/ip.h>
41 #endif
42 
43 #include "libntp.h"	/* This needs Something above for GETDTABLESIZE */
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 SOCKET		move_fd(SOCKET fd);
86 isc_boolean_t	get_broadcastclient_flag(void);
87 extern int	is_ip_address(const char *, u_short, sockaddr_u *);
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