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