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