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