ntp_tty.h revision 303975
174462Salfred/*
274462Salfred * ntp_tty.h - header file for serial lines handling
3258578Shrs */
4258578Shrs#ifndef NTP_TTY_H
5258578Shrs#define NTP_TTY_H
6258578Shrs
7258578Shrs/*
8258578Shrs * use only one tty model - no use in initialising
9258578Shrs * a tty in three ways
10258578Shrs * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
11258578Shrs */
12258578Shrs
13258578Shrs#if defined(HAVE_TERMIOS_H) || defined(HAVE_SYS_TERMIOS_H)
14258578Shrs# define HAVE_TERMIOS
15258578Shrs#elif defined(HAVE_TERMIO_H)
16258578Shrs# define HAVE_SYSV_TTYS
1774462Salfred#elif defined(HAVE_SGTTY_H)
18258578Shrs# define HAVE_BSD_TTYS
19258578Shrs#endif
20258578Shrs
21258578Shrs#if !defined(VMS) && !defined(SYS_VXWORKS)
22258578Shrs# if	!defined(HAVE_SYSV_TTYS) \
23258578Shrs	&& !defined(HAVE_BSD_TTYS) \
24258578Shrs	&& !defined(HAVE_TERMIOS)
25258578Shrs#include "ERROR: no tty type defined!"
26258578Shrs# endif
27258578Shrs#endif /* !VMS && !SYS_VXWORKS*/
28258578Shrs
2974462Salfred#if defined(HAVE_BSD_TTYS)
3074462Salfred#include <sgtty.h>
3174462Salfred#define TTY	struct sgttyb
3274462Salfred#endif /* HAVE_BSD_TTYS */
3374462Salfred
34136581Sobrien#if defined(HAVE_SYSV_TTYS)
35136581Sobrien#include <termio.h>
3674462Salfred#define TTY	struct termio
3774462Salfred#ifndef tcsetattr
3892990Sobrien#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)
3992990Sobrien#endif
4074462Salfred#ifndef TCSANOW
4174462Salfred#define TCSANOW	TCSETA
4274462Salfred#endif
4374462Salfred#ifndef TCIFLUSH
4474462Salfred#define TCIFLUSH 0
4575094Siedowse#endif
4674462Salfred#ifndef TCOFLUSH
4774462Salfred#define TCOFLUSH 1
48105189Siedowse#endif
4974462Salfred#ifndef TCIOFLUSH
5074462Salfred#define TCIOFLUSH 2
5174462Salfred#endif
5290868Smike#ifndef tcflush
5374462Salfred#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
54181344Sdfr#endif
5574462Salfred#endif /* HAVE_SYSV_TTYS */
5674462Salfred
5774462Salfred#if defined(HAVE_TERMIOS)
5874462Salfred# if defined(HAVE_TERMIOS_H)
5974462Salfred#  ifdef TERMIOS_NEEDS__SVID3
6074462Salfred#   define _SVID3
6174462Salfred#  endif
6274462Salfred#  include <termios.h>
63156090Sdeischen#  ifdef TERMIOS_NEEDS__SVID3
6474462Salfred#   undef _SVID3
6574462Salfred#  endif
66167199Ssimon# elif defined(HAVE_SYS_TERMIOS_H)
67167199Ssimon#  include <sys/termios.h>
68167199Ssimon# endif
69167199Ssimon# define TTY	struct termios
70167199Ssimon#endif
71167199Ssimon
7274462Salfred#if defined(HAVE_SYS_MODEM_H)
73167199Ssimon#include <sys/modem.h>
7474462Salfred#endif
7574462Salfred
7692905Sobrien/*
7792905Sobrien * Line discipline flags.  The depredated ones required line discipline
7895658Sdes * or streams modules to be installed/loaded in the kernel and are now
7995658Sdes * ignored.  Leave the LDISC_CLK and other deprecated symbols defined
8092905Sobrien * until 2013 or 2014 to avoid complicating the use of newer drivers on
8195658Sdes * older ntpd, which is often as easy as dropping in the refclock *.c.
8292905Sobrien */
8399996Salfred#define LDISC_STD	0x000	/* standard */
8492905Sobrien#define LDISC_CLK	0x001	/* depredated tty_clk \n */
8574462Salfred#define LDISC_CLKPPS	0x002	/* depredated tty_clk \377 */
8674462Salfred#define LDISC_ACTS	0x004	/* depredated tty_clk #* */
8774462Salfred#define LDISC_CHU	0x008	/* depredated */
8874462Salfred#define LDISC_PPS	0x010	/* depredated */
8974462Salfred#define LDISC_RAW	0x020	/* raw binary */
9074462Salfred#define LDISC_ECHO	0x040	/* enable echo */
9174462Salfred#define	LDISC_REMOTE	0x080	/* remote mode */
9274462Salfred#define	LDISC_7O1	0x100	/* 7-bit, odd parity for Z3801A */
9374462Salfred
9474462Salfred/* function prototypes for ntp_tty.c */
9574462Salfred#if !defined(SYS_VXWORKS) && !defined(SYS_WINNT)
9674462Salfred# if defined(HAVE_TERMIOS) || defined(HAVE_SYSV_TTYS) || \
9774462Salfred     defined(HAVE_BSD_TTYS)
9874462Salfredextern	int	ntp_tty_setup(int, u_int, u_int);
9974462Salfredextern	int	ntp_tty_ioctl(int, u_int);
10074462Salfred# endif
10174462Salfred#endif
10274462Salfred
10374462Salfred#endif /* NTP_TTY_H */
10474462Salfred