xref: /freebsd/contrib/ntp/include/ntp_io.h (revision e43d33d286a1aa41b6fc6a209f28a18e8cd7437a)
12b15cb3dSCy Schubert #ifndef NTP_IO_H
22b15cb3dSCy Schubert #define NTP_IO_H
32b15cb3dSCy Schubert 
42b15cb3dSCy Schubert #include "ntp_workimpl.h"
52b15cb3dSCy Schubert 
6c0b746e5SOllivier Robert /*
7c0b746e5SOllivier Robert  * POSIX says use <fnct.h> to get O_* symbols and
8c0b746e5SOllivier Robert  * SEEK_SET symbol form <unistd.h>.
9c0b746e5SOllivier Robert  */
10c0b746e5SOllivier Robert #include <sys/types.h>
11c0b746e5SOllivier Robert #ifdef HAVE_UNISTD_H
12c0b746e5SOllivier Robert # include <unistd.h>
13c0b746e5SOllivier Robert #endif
14c0b746e5SOllivier Robert #include <stdio.h>
15c0b746e5SOllivier Robert #ifdef HAVE_SYS_FILE_H
16c0b746e5SOllivier Robert # include <sys/file.h>
17c0b746e5SOllivier Robert #endif
18c0b746e5SOllivier Robert #ifdef HAVE_FCNTL_H
19c0b746e5SOllivier Robert # include <fcntl.h>
20c0b746e5SOllivier Robert #endif
21c0b746e5SOllivier Robert #if !defined(SEEK_SET) && defined(L_SET)
22c0b746e5SOllivier Robert # define SEEK_SET L_SET
23c0b746e5SOllivier Robert #endif
24c0b746e5SOllivier Robert 
25c0b746e5SOllivier Robert #ifdef SYS_WINNT
26c0b746e5SOllivier Robert # include <io.h>
27c0b746e5SOllivier Robert # include "win32_io.h"
28c0b746e5SOllivier Robert #endif
29c0b746e5SOllivier Robert 
302b15cb3dSCy Schubert #include <isc/boolean.h>
312b15cb3dSCy Schubert #include <isc/netaddr.h>
322b15cb3dSCy Schubert 
332b15cb3dSCy Schubert #if defined(HAVE_NETINET_IN_H) && defined(HAVE_NETINET_IP_H)
342b15cb3dSCy Schubert # include <netinet/in.h>
352b15cb3dSCy Schubert # ifdef HAVE_NETINET_IN_SYSTM_H
362b15cb3dSCy Schubert #  include <netinet/in_systm.h>
372b15cb3dSCy Schubert # endif
382b15cb3dSCy Schubert # include <netinet/ip.h>
392b15cb3dSCy Schubert #endif
402b15cb3dSCy Schubert 
412b15cb3dSCy Schubert #include "libntp.h"	/* This needs Something above for GETDTABLESIZE */
422b15cb3dSCy Schubert 
4368ba7e87SXin LI #include "ntp_keyacc.h"
4468ba7e87SXin LI 
459c2daa00SOllivier Robert /*
469c2daa00SOllivier Robert  * Define FNDELAY and FASYNC using O_NONBLOCK and O_ASYNC if we need
479c2daa00SOllivier Robert  * to (and can).  This is here initially for QNX, but may help for
489c2daa00SOllivier Robert  * others as well...
499c2daa00SOllivier Robert  */
509c2daa00SOllivier Robert #ifndef FNDELAY
519c2daa00SOllivier Robert # ifdef O_NONBLOCK
529c2daa00SOllivier Robert #  define FNDELAY O_NONBLOCK
539c2daa00SOllivier Robert # endif
549c2daa00SOllivier Robert #endif
559c2daa00SOllivier Robert 
569c2daa00SOllivier Robert #ifndef FASYNC
579c2daa00SOllivier Robert # ifdef O_ASYNC
589c2daa00SOllivier Robert #  define FASYNC O_ASYNC
599c2daa00SOllivier Robert # endif
609c2daa00SOllivier Robert #endif
619c2daa00SOllivier Robert 
622b15cb3dSCy Schubert 
632b15cb3dSCy Schubert /*
642b15cb3dSCy Schubert  * NIC rule match types
652b15cb3dSCy Schubert  */
662b15cb3dSCy Schubert typedef enum {
672b15cb3dSCy Schubert 	MATCH_ALL,
682b15cb3dSCy Schubert 	MATCH_IPV4,
692b15cb3dSCy Schubert 	MATCH_IPV6,
702b15cb3dSCy Schubert 	MATCH_WILDCARD,
712b15cb3dSCy Schubert 	MATCH_IFNAME,
722b15cb3dSCy Schubert 	MATCH_IFADDR
732b15cb3dSCy Schubert } nic_rule_match;
742b15cb3dSCy Schubert 
752b15cb3dSCy Schubert /*
762b15cb3dSCy Schubert  * NIC rule actions
772b15cb3dSCy Schubert  */
782b15cb3dSCy Schubert typedef enum {
792b15cb3dSCy Schubert 	ACTION_LISTEN,
802b15cb3dSCy Schubert 	ACTION_IGNORE,
812b15cb3dSCy Schubert 	ACTION_DROP
822b15cb3dSCy Schubert } nic_rule_action;
832b15cb3dSCy Schubert 
842b15cb3dSCy Schubert 
85276da39aSCy Schubert extern int	qos;
862b15cb3dSCy Schubert SOCKET		move_fd(SOCKET fd);
87*2d4e511cSCy Schubert /*isc_boolean_t	get_broadcastclient_flag(void);*/
882b15cb3dSCy Schubert extern void	sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *);
892b15cb3dSCy Schubert extern void	add_nic_rule(nic_rule_match match_type,
902b15cb3dSCy Schubert 			     const char *if_name, int prefixlen,
912b15cb3dSCy Schubert 			     nic_rule_action action);
922b15cb3dSCy Schubert #ifndef HAVE_IO_COMPLETION_PORT
932b15cb3dSCy Schubert extern	void	maintain_activefds(int fd, int closing);
942b15cb3dSCy Schubert #else
952b15cb3dSCy Schubert #define		maintain_activefds(f, c)	do {} while (0)
96c0b746e5SOllivier Robert #endif
972b15cb3dSCy Schubert 
982b15cb3dSCy Schubert 
992b15cb3dSCy Schubert #endif	/* NTP_IO_H */
100