xref: /freebsd/contrib/ntp/include/ntp_tty.h (revision f5f40dd63bc7acbb5312b26ac1ea1103c12352a6)
1224ba2bdSOllivier Robert /*
2224ba2bdSOllivier Robert  * ntp_tty.h - header file for serial lines handling
3224ba2bdSOllivier Robert  */
4224ba2bdSOllivier Robert #ifndef NTP_TTY_H
5224ba2bdSOllivier Robert #define NTP_TTY_H
6224ba2bdSOllivier Robert 
72b15cb3dSCy Schubert /*
82b15cb3dSCy Schubert  * use only one tty model - no use in initialising
92b15cb3dSCy Schubert  * a tty in three ways
102b15cb3dSCy Schubert  * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
112b15cb3dSCy Schubert  */
122b15cb3dSCy Schubert 
132b15cb3dSCy Schubert #if defined(HAVE_TERMIOS_H) || defined(HAVE_SYS_TERMIOS_H)
142b15cb3dSCy Schubert # define HAVE_TERMIOS
152b15cb3dSCy Schubert #elif defined(HAVE_TERMIO_H)
162b15cb3dSCy Schubert # define HAVE_SYSV_TTYS
172b15cb3dSCy Schubert #elif defined(HAVE_SGTTY_H)
182b15cb3dSCy Schubert # define HAVE_BSD_TTYS
192b15cb3dSCy Schubert #endif
202b15cb3dSCy Schubert 
212b15cb3dSCy Schubert #if !defined(VMS) && !defined(SYS_VXWORKS)
222b15cb3dSCy Schubert # if	!defined(HAVE_SYSV_TTYS) \
232b15cb3dSCy Schubert 	&& !defined(HAVE_BSD_TTYS) \
242b15cb3dSCy Schubert 	&& !defined(HAVE_TERMIOS)
252b15cb3dSCy Schubert #include "ERROR: no tty type defined!"
262b15cb3dSCy Schubert # endif
272b15cb3dSCy Schubert #endif /* !VMS && !SYS_VXWORKS*/
282b15cb3dSCy Schubert 
29224ba2bdSOllivier Robert #if defined(HAVE_BSD_TTYS)
30224ba2bdSOllivier Robert #include <sgtty.h>
31224ba2bdSOllivier Robert #define TTY	struct sgttyb
32224ba2bdSOllivier Robert #endif /* HAVE_BSD_TTYS */
33224ba2bdSOllivier Robert 
34224ba2bdSOllivier Robert #if defined(HAVE_SYSV_TTYS)
35224ba2bdSOllivier Robert #include <termio.h>
36224ba2bdSOllivier Robert #define TTY	struct termio
37224ba2bdSOllivier Robert #ifndef tcsetattr
38224ba2bdSOllivier Robert #define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)
39224ba2bdSOllivier Robert #endif
40224ba2bdSOllivier Robert #ifndef TCSANOW
41224ba2bdSOllivier Robert #define TCSANOW	TCSETA
42224ba2bdSOllivier Robert #endif
43224ba2bdSOllivier Robert #ifndef TCIFLUSH
44224ba2bdSOllivier Robert #define TCIFLUSH 0
45224ba2bdSOllivier Robert #endif
46224ba2bdSOllivier Robert #ifndef TCOFLUSH
47224ba2bdSOllivier Robert #define TCOFLUSH 1
48224ba2bdSOllivier Robert #endif
49224ba2bdSOllivier Robert #ifndef TCIOFLUSH
50224ba2bdSOllivier Robert #define TCIOFLUSH 2
51224ba2bdSOllivier Robert #endif
52224ba2bdSOllivier Robert #ifndef tcflush
53224ba2bdSOllivier Robert #define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
54224ba2bdSOllivier Robert #endif
55224ba2bdSOllivier Robert #endif /* HAVE_SYSV_TTYS */
56224ba2bdSOllivier Robert 
57224ba2bdSOllivier Robert #if defined(HAVE_TERMIOS)
582b15cb3dSCy Schubert # if defined(HAVE_TERMIOS_H)
59224ba2bdSOllivier Robert #  ifdef TERMIOS_NEEDS__SVID3
60224ba2bdSOllivier Robert #   define _SVID3
61224ba2bdSOllivier Robert #  endif
62224ba2bdSOllivier Robert #  include <termios.h>
63224ba2bdSOllivier Robert #  ifdef TERMIOS_NEEDS__SVID3
64224ba2bdSOllivier Robert #   undef _SVID3
65224ba2bdSOllivier Robert #  endif
662b15cb3dSCy Schubert # elif defined(HAVE_SYS_TERMIOS_H)
672b15cb3dSCy Schubert #  include <sys/termios.h>
682b15cb3dSCy Schubert # endif
69224ba2bdSOllivier Robert # define TTY	struct termios
70224ba2bdSOllivier Robert #endif
71224ba2bdSOllivier Robert 
72224ba2bdSOllivier Robert #if defined(HAVE_SYS_MODEM_H)
73224ba2bdSOllivier Robert #include <sys/modem.h>
74224ba2bdSOllivier Robert #endif
75224ba2bdSOllivier Robert 
762b15cb3dSCy Schubert /*
772b15cb3dSCy Schubert  * Line discipline flags.  The depredated ones required line discipline
782b15cb3dSCy Schubert  * or streams modules to be installed/loaded in the kernel and are now
792b15cb3dSCy Schubert  * ignored.  Leave the LDISC_CLK and other deprecated symbols defined
802b15cb3dSCy Schubert  * until 2013 or 2014 to avoid complicating the use of newer drivers on
812b15cb3dSCy Schubert  * older ntpd, which is often as easy as dropping in the refclock *.c.
822b15cb3dSCy Schubert  */
832b15cb3dSCy Schubert #define LDISC_STD	0x000	/* standard */
842b15cb3dSCy Schubert #define LDISC_CLK	0x001	/* depredated tty_clk \n */
852b15cb3dSCy Schubert #define LDISC_CLKPPS	0x002	/* depredated tty_clk \377 */
862b15cb3dSCy Schubert #define LDISC_ACTS	0x004	/* depredated tty_clk #* */
872b15cb3dSCy Schubert #define LDISC_CHU	0x008	/* depredated */
882b15cb3dSCy Schubert #define LDISC_PPS	0x010	/* depredated */
892b15cb3dSCy Schubert #define LDISC_RAW	0x020	/* raw binary */
902b15cb3dSCy Schubert #define LDISC_ECHO	0x040	/* enable echo */
912b15cb3dSCy Schubert #define	LDISC_REMOTE	0x080	/* remote mode */
922b15cb3dSCy Schubert #define	LDISC_7O1	0x100	/* 7-bit, odd parity for Z3801A */
932b15cb3dSCy Schubert 
942b15cb3dSCy Schubert /* function prototypes for ntp_tty.c */
952b15cb3dSCy Schubert #if !defined(SYS_VXWORKS) && !defined(SYS_WINNT)
962b15cb3dSCy Schubert # if defined(HAVE_TERMIOS) || defined(HAVE_SYSV_TTYS) || \
972b15cb3dSCy Schubert      defined(HAVE_BSD_TTYS)
982b15cb3dSCy Schubert extern	int	ntp_tty_setup(int, u_int, u_int);
992b15cb3dSCy Schubert extern	int	ntp_tty_ioctl(int, u_int);
1002b15cb3dSCy Schubert # endif
1012b15cb3dSCy Schubert #endif
102224ba2bdSOllivier Robert 
103*f5f40dd6SCy Schubert extern	int	symBaud2numBaud(int symBaud);
104*f5f40dd6SCy Schubert # if 0
105*f5f40dd6SCy Schubert extern	int	numBaud2symBaud(int numBaud);
106*f5f40dd6SCy Schubert #endif
107*f5f40dd6SCy Schubert 
108224ba2bdSOllivier Robert #endif /* NTP_TTY_H */
109