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