1*eabc0478Schristos /* $NetBSD: ntp_tty.h,v 1.6 2024/08/18 20:46:50 christos Exp $ */ 2abb0f93cSkardel 3abb0f93cSkardel /* 4abb0f93cSkardel * ntp_tty.h - header file for serial lines handling 5abb0f93cSkardel */ 6abb0f93cSkardel #ifndef NTP_TTY_H 7abb0f93cSkardel #define NTP_TTY_H 8abb0f93cSkardel 98585484eSchristos /* 108585484eSchristos * use only one tty model - no use in initialising 118585484eSchristos * a tty in three ways 128585484eSchristos * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS 138585484eSchristos */ 148585484eSchristos 158585484eSchristos #if defined(HAVE_TERMIOS_H) || defined(HAVE_SYS_TERMIOS_H) 168585484eSchristos # define HAVE_TERMIOS 178585484eSchristos #elif defined(HAVE_TERMIO_H) 188585484eSchristos # define HAVE_SYSV_TTYS 198585484eSchristos #elif defined(HAVE_SGTTY_H) 208585484eSchristos # define HAVE_BSD_TTYS 218585484eSchristos #endif 228585484eSchristos 238585484eSchristos #if !defined(VMS) && !defined(SYS_VXWORKS) 248585484eSchristos # if !defined(HAVE_SYSV_TTYS) \ 258585484eSchristos && !defined(HAVE_BSD_TTYS) \ 268585484eSchristos && !defined(HAVE_TERMIOS) 278585484eSchristos #include "ERROR: no tty type defined!" 288585484eSchristos # endif 298585484eSchristos #endif /* !VMS && !SYS_VXWORKS*/ 308585484eSchristos 31abb0f93cSkardel #if defined(HAVE_BSD_TTYS) 32abb0f93cSkardel #include <sgtty.h> 33abb0f93cSkardel #define TTY struct sgttyb 34abb0f93cSkardel #endif /* HAVE_BSD_TTYS */ 35abb0f93cSkardel 36abb0f93cSkardel #if defined(HAVE_SYSV_TTYS) 37abb0f93cSkardel #include <termio.h> 38abb0f93cSkardel #define TTY struct termio 39abb0f93cSkardel #ifndef tcsetattr 40abb0f93cSkardel #define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg) 41abb0f93cSkardel #endif 42abb0f93cSkardel #ifndef TCSANOW 43abb0f93cSkardel #define TCSANOW TCSETA 44abb0f93cSkardel #endif 45abb0f93cSkardel #ifndef TCIFLUSH 46abb0f93cSkardel #define TCIFLUSH 0 47abb0f93cSkardel #endif 48abb0f93cSkardel #ifndef TCOFLUSH 49abb0f93cSkardel #define TCOFLUSH 1 50abb0f93cSkardel #endif 51abb0f93cSkardel #ifndef TCIOFLUSH 52abb0f93cSkardel #define TCIOFLUSH 2 53abb0f93cSkardel #endif 54abb0f93cSkardel #ifndef tcflush 55abb0f93cSkardel #define tcflush(fd, arg) ioctl(fd, TCFLSH, arg) 56abb0f93cSkardel #endif 57abb0f93cSkardel #endif /* HAVE_SYSV_TTYS */ 58abb0f93cSkardel 59abb0f93cSkardel #if defined(HAVE_TERMIOS) 608585484eSchristos # if defined(HAVE_TERMIOS_H) 61abb0f93cSkardel # ifdef TERMIOS_NEEDS__SVID3 62abb0f93cSkardel # define _SVID3 63abb0f93cSkardel # endif 64abb0f93cSkardel # include <termios.h> 65abb0f93cSkardel # ifdef TERMIOS_NEEDS__SVID3 66abb0f93cSkardel # undef _SVID3 67abb0f93cSkardel # endif 688585484eSchristos # elif defined(HAVE_SYS_TERMIOS_H) 698585484eSchristos # include <sys/termios.h> 708585484eSchristos # endif 71abb0f93cSkardel # define TTY struct termios 72abb0f93cSkardel #endif 73abb0f93cSkardel 74abb0f93cSkardel #if defined(HAVE_SYS_MODEM_H) 75abb0f93cSkardel #include <sys/modem.h> 76abb0f93cSkardel #endif 77abb0f93cSkardel 788585484eSchristos /* 798585484eSchristos * Line discipline flags. The depredated ones required line discipline 808585484eSchristos * or streams modules to be installed/loaded in the kernel and are now 818585484eSchristos * ignored. Leave the LDISC_CLK and other deprecated symbols defined 828585484eSchristos * until 2013 or 2014 to avoid complicating the use of newer drivers on 838585484eSchristos * older ntpd, which is often as easy as dropping in the refclock *.c. 848585484eSchristos */ 858585484eSchristos #define LDISC_STD 0x000 /* standard */ 868585484eSchristos #define LDISC_CLK 0x001 /* depredated tty_clk \n */ 878585484eSchristos #define LDISC_CLKPPS 0x002 /* depredated tty_clk \377 */ 888585484eSchristos #define LDISC_ACTS 0x004 /* depredated tty_clk #* */ 898585484eSchristos #define LDISC_CHU 0x008 /* depredated */ 908585484eSchristos #define LDISC_PPS 0x010 /* depredated */ 918585484eSchristos #define LDISC_RAW 0x020 /* raw binary */ 928585484eSchristos #define LDISC_ECHO 0x040 /* enable echo */ 938585484eSchristos #define LDISC_REMOTE 0x080 /* remote mode */ 948585484eSchristos #define LDISC_7O1 0x100 /* 7-bit, odd parity for Z3801A */ 958585484eSchristos 968585484eSchristos /* function prototypes for ntp_tty.c */ 978585484eSchristos #if !defined(SYS_VXWORKS) && !defined(SYS_WINNT) 988585484eSchristos # if defined(HAVE_TERMIOS) || defined(HAVE_SYSV_TTYS) || \ 998585484eSchristos defined(HAVE_BSD_TTYS) 1008585484eSchristos extern int ntp_tty_setup(int, u_int, u_int); 1018585484eSchristos extern int ntp_tty_ioctl(int, u_int); 1028585484eSchristos # endif 1038585484eSchristos #endif 104abb0f93cSkardel 105*eabc0478Schristos extern int symBaud2numBaud(int symBaud); 106*eabc0478Schristos # if 0 107*eabc0478Schristos extern int numBaud2symBaud(int numBaud); 108*eabc0478Schristos #endif 109*eabc0478Schristos 110abb0f93cSkardel #endif /* NTP_TTY_H */ 111