xref: /netbsd/external/bsd/ntp/dist/include/ntp_tty.h (revision 9034ec65)
1 /*	$NetBSD: ntp_tty.h,v 1.5 2020/05/25 20:47:20 christos Exp $	*/
2 
3 /*
4  * ntp_tty.h - header file for serial lines handling
5  */
6 #ifndef NTP_TTY_H
7 #define NTP_TTY_H
8 
9 /*
10  * use only one tty model - no use in initialising
11  * a tty in three ways
12  * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
13  */
14 
15 #if defined(HAVE_TERMIOS_H) || defined(HAVE_SYS_TERMIOS_H)
16 # define HAVE_TERMIOS
17 #elif defined(HAVE_TERMIO_H)
18 # define HAVE_SYSV_TTYS
19 #elif defined(HAVE_SGTTY_H)
20 # define HAVE_BSD_TTYS
21 #endif
22 
23 #if !defined(VMS) && !defined(SYS_VXWORKS)
24 # if	!defined(HAVE_SYSV_TTYS) \
25 	&& !defined(HAVE_BSD_TTYS) \
26 	&& !defined(HAVE_TERMIOS)
27 #include "ERROR: no tty type defined!"
28 # endif
29 #endif /* !VMS && !SYS_VXWORKS*/
30 
31 #if defined(HAVE_BSD_TTYS)
32 #include <sgtty.h>
33 #define TTY	struct sgttyb
34 #endif /* HAVE_BSD_TTYS */
35 
36 #if defined(HAVE_SYSV_TTYS)
37 #include <termio.h>
38 #define TTY	struct termio
39 #ifndef tcsetattr
40 #define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)
41 #endif
42 #ifndef TCSANOW
43 #define TCSANOW	TCSETA
44 #endif
45 #ifndef TCIFLUSH
46 #define TCIFLUSH 0
47 #endif
48 #ifndef TCOFLUSH
49 #define TCOFLUSH 1
50 #endif
51 #ifndef TCIOFLUSH
52 #define TCIOFLUSH 2
53 #endif
54 #ifndef tcflush
55 #define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
56 #endif
57 #endif /* HAVE_SYSV_TTYS */
58 
59 #if defined(HAVE_TERMIOS)
60 # if defined(HAVE_TERMIOS_H)
61 #  ifdef TERMIOS_NEEDS__SVID3
62 #   define _SVID3
63 #  endif
64 #  include <termios.h>
65 #  ifdef TERMIOS_NEEDS__SVID3
66 #   undef _SVID3
67 #  endif
68 # elif defined(HAVE_SYS_TERMIOS_H)
69 #  include <sys/termios.h>
70 # endif
71 # define TTY	struct termios
72 #endif
73 
74 #if defined(HAVE_SYS_MODEM_H)
75 #include <sys/modem.h>
76 #endif
77 
78 /*
79  * Line discipline flags.  The depredated ones required line discipline
80  * or streams modules to be installed/loaded in the kernel and are now
81  * ignored.  Leave the LDISC_CLK and other deprecated symbols defined
82  * until 2013 or 2014 to avoid complicating the use of newer drivers on
83  * older ntpd, which is often as easy as dropping in the refclock *.c.
84  */
85 #define LDISC_STD	0x000	/* standard */
86 #define LDISC_CLK	0x001	/* depredated tty_clk \n */
87 #define LDISC_CLKPPS	0x002	/* depredated tty_clk \377 */
88 #define LDISC_ACTS	0x004	/* depredated tty_clk #* */
89 #define LDISC_CHU	0x008	/* depredated */
90 #define LDISC_PPS	0x010	/* depredated */
91 #define LDISC_RAW	0x020	/* raw binary */
92 #define LDISC_ECHO	0x040	/* enable echo */
93 #define	LDISC_REMOTE	0x080	/* remote mode */
94 #define	LDISC_7O1	0x100	/* 7-bit, odd parity for Z3801A */
95 
96 /* function prototypes for ntp_tty.c */
97 #if !defined(SYS_VXWORKS) && !defined(SYS_WINNT)
98 # if defined(HAVE_TERMIOS) || defined(HAVE_SYSV_TTYS) || \
99      defined(HAVE_BSD_TTYS)
100 extern	int	ntp_tty_setup(int, u_int, u_int);
101 extern	int	ntp_tty_ioctl(int, u_int);
102 # endif
103 #endif
104 
105 #endif /* NTP_TTY_H */
106