xref: /netbsd-src/external/bsd/ntp/dist/include/ntp_io.h (revision cdfa2a7ef92791ba9db70a584a1d904730e6fb46)
1*cdfa2a7eSchristos /*	$NetBSD: ntp_io.h,v 1.6 2020/05/25 20:47:19 christos Exp $	*/
2abb0f93cSkardel 
3abb0f93cSkardel #ifndef NTP_IO_H
4abb0f93cSkardel #define NTP_IO_H
58585484eSchristos 
68585484eSchristos #include "ntp_workimpl.h"
78585484eSchristos 
8abb0f93cSkardel /*
9abb0f93cSkardel  * POSIX says use <fnct.h> to get O_* symbols and
10abb0f93cSkardel  * SEEK_SET symbol form <unistd.h>.
11abb0f93cSkardel  */
12abb0f93cSkardel #include <sys/types.h>
13abb0f93cSkardel #ifdef HAVE_UNISTD_H
14abb0f93cSkardel # include <unistd.h>
15abb0f93cSkardel #endif
16abb0f93cSkardel #include <stdio.h>
17abb0f93cSkardel #ifdef HAVE_SYS_FILE_H
18abb0f93cSkardel # include <sys/file.h>
19abb0f93cSkardel #endif
20abb0f93cSkardel #ifdef HAVE_FCNTL_H
21abb0f93cSkardel # include <fcntl.h>
22abb0f93cSkardel #endif
23abb0f93cSkardel #if !defined(SEEK_SET) && defined(L_SET)
24abb0f93cSkardel # define SEEK_SET L_SET
25abb0f93cSkardel #endif
26abb0f93cSkardel 
27abb0f93cSkardel #ifdef SYS_WINNT
28abb0f93cSkardel # include <io.h>
29abb0f93cSkardel # include "win32_io.h"
30abb0f93cSkardel #endif
31abb0f93cSkardel 
32abb0f93cSkardel #include <isc/boolean.h>
33abb0f93cSkardel #include <isc/netaddr.h>
34abb0f93cSkardel 
35f003fb54Skardel #if defined(HAVE_NETINET_IN_H) && defined(HAVE_NETINET_IP_H)
36abb0f93cSkardel # include <netinet/in.h>
37f003fb54Skardel # ifdef HAVE_NETINET_IN_SYSTM_H
38abb0f93cSkardel #  include <netinet/in_systm.h>
39abb0f93cSkardel # endif
40abb0f93cSkardel # include <netinet/ip.h>
41abb0f93cSkardel #endif
42abb0f93cSkardel 
438585484eSchristos #include "libntp.h"	/* This needs Something above for GETDTABLESIZE */
448585484eSchristos 
4568dbbb44Schristos #include "ntp_keyacc.h"
4668dbbb44Schristos 
47abb0f93cSkardel /*
48abb0f93cSkardel  * Define FNDELAY and FASYNC using O_NONBLOCK and O_ASYNC if we need
49abb0f93cSkardel  * to (and can).  This is here initially for QNX, but may help for
50abb0f93cSkardel  * others as well...
51abb0f93cSkardel  */
52abb0f93cSkardel #ifndef FNDELAY
53abb0f93cSkardel # ifdef O_NONBLOCK
54abb0f93cSkardel #  define FNDELAY O_NONBLOCK
55abb0f93cSkardel # endif
56abb0f93cSkardel #endif
57abb0f93cSkardel 
58abb0f93cSkardel #ifndef FASYNC
59abb0f93cSkardel # ifdef O_ASYNC
60abb0f93cSkardel #  define FASYNC O_ASYNC
61abb0f93cSkardel # endif
62abb0f93cSkardel #endif
63abb0f93cSkardel 
64abb0f93cSkardel 
65abb0f93cSkardel /*
66abb0f93cSkardel  * NIC rule match types
67abb0f93cSkardel  */
68abb0f93cSkardel typedef enum {
69abb0f93cSkardel 	MATCH_ALL,
70abb0f93cSkardel 	MATCH_IPV4,
71abb0f93cSkardel 	MATCH_IPV6,
72abb0f93cSkardel 	MATCH_WILDCARD,
73abb0f93cSkardel 	MATCH_IFNAME,
74abb0f93cSkardel 	MATCH_IFADDR
75abb0f93cSkardel } nic_rule_match;
76abb0f93cSkardel 
77abb0f93cSkardel /*
78abb0f93cSkardel  * NIC rule actions
79abb0f93cSkardel  */
80abb0f93cSkardel typedef enum {
81abb0f93cSkardel 	ACTION_LISTEN,
82abb0f93cSkardel 	ACTION_IGNORE,
83abb0f93cSkardel 	ACTION_DROP
84abb0f93cSkardel } nic_rule_action;
85abb0f93cSkardel 
86abb0f93cSkardel 
875d681e99Schristos extern int	qos;
888585484eSchristos SOCKET		move_fd(SOCKET fd);
89*cdfa2a7eSchristos /*isc_boolean_t	get_broadcastclient_flag(void);*/
90abb0f93cSkardel extern void	sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *);
918585484eSchristos extern void	add_nic_rule(nic_rule_match match_type,
928585484eSchristos 			     const char *if_name, int prefixlen,
938585484eSchristos 			     nic_rule_action action);
948585484eSchristos #ifndef HAVE_IO_COMPLETION_PORT
958585484eSchristos extern	void	maintain_activefds(int fd, int closing);
968585484eSchristos #else
978585484eSchristos #define		maintain_activefds(f, c)	do {} while (0)
988585484eSchristos #endif
998585484eSchristos 
100abb0f93cSkardel 
101abb0f93cSkardel #endif	/* NTP_IO_H */
102