10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*9354STim.Marsland@Sun.COM * Common Development and Distribution License (the "License"). 6*9354STim.Marsland@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*9354STim.Marsland@Sun.COM 220Sstevel@tonic-gate /* 23*9354STim.Marsland@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 280Sstevel@tonic-gate /* All Rights Reserved */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <stdio.h> 320Sstevel@tonic-gate #include <sys/types.h> 330Sstevel@tonic-gate #include <termio.h> 340Sstevel@tonic-gate #include <sys/stermio.h> 350Sstevel@tonic-gate #include <sys/termiox.h> 360Sstevel@tonic-gate #include "stty.h" 370Sstevel@tonic-gate 380Sstevel@tonic-gate const struct speeds speeds[] = { 390Sstevel@tonic-gate "0", B0, 400Sstevel@tonic-gate "50", B50, 410Sstevel@tonic-gate "75", B75, 420Sstevel@tonic-gate "110", B110, 430Sstevel@tonic-gate "134", B134, 44*9354STim.Marsland@Sun.COM "134.5", B134, 450Sstevel@tonic-gate "150", B150, 460Sstevel@tonic-gate "200", B200, 470Sstevel@tonic-gate "300", B300, 480Sstevel@tonic-gate "600", B600, 490Sstevel@tonic-gate "1200", B1200, 500Sstevel@tonic-gate "1800", B1800, 510Sstevel@tonic-gate "2400", B2400, 520Sstevel@tonic-gate "4800", B4800, 530Sstevel@tonic-gate "9600", B9600, 540Sstevel@tonic-gate "19200", B19200, 550Sstevel@tonic-gate "19.2", B19200, 560Sstevel@tonic-gate "exta", EXTA, 570Sstevel@tonic-gate "38400", B38400, 580Sstevel@tonic-gate "38.4", B38400, 590Sstevel@tonic-gate "extb", EXTB, 600Sstevel@tonic-gate "57600", B57600, 610Sstevel@tonic-gate "76800", B76800, 620Sstevel@tonic-gate "115200", B115200, 630Sstevel@tonic-gate "153600", B153600, 640Sstevel@tonic-gate "230400", B230400, 650Sstevel@tonic-gate "307200", B307200, 660Sstevel@tonic-gate "460800", B460800, 67*9354STim.Marsland@Sun.COM "921600", B921600, 680Sstevel@tonic-gate 0, 690Sstevel@tonic-gate }; 700Sstevel@tonic-gate /* Control Modes */ 710Sstevel@tonic-gate const struct mds cmodes[] = { 720Sstevel@tonic-gate "-parity", CS8, PARENB|CSIZE, 730Sstevel@tonic-gate "-evenp", CS8, PARENB|CSIZE, 740Sstevel@tonic-gate "-even", CS8, PARENB|CSIZE, 750Sstevel@tonic-gate "-oddp", CS8, PARENB|PARODD|CSIZE, 760Sstevel@tonic-gate "-odd", CS8, PARENB|PARODD|CSIZE, 770Sstevel@tonic-gate "parity", PARENB|CS7, PARODD|CSIZE, 780Sstevel@tonic-gate "evenp", PARENB|CS7, PARODD|CSIZE, 790Sstevel@tonic-gate "even", PARENB|CS7, PARODD|CSIZE, 800Sstevel@tonic-gate "oddp", PARENB|PARODD|CS7, CSIZE, 810Sstevel@tonic-gate "odd", PARENB|PARODD|CS7, CSIZE, 820Sstevel@tonic-gate "parenb", PARENB, 0, 830Sstevel@tonic-gate "-parenb", 0, PARENB, 840Sstevel@tonic-gate "parodd", PARODD, 0, 850Sstevel@tonic-gate "-parodd", 0, PARODD, 860Sstevel@tonic-gate "cs8", CS8, CSIZE, 870Sstevel@tonic-gate "cs7", CS7, CSIZE, 880Sstevel@tonic-gate "cs6", CS6, CSIZE, 890Sstevel@tonic-gate "cs5", CS5, CSIZE, 900Sstevel@tonic-gate "cstopb", CSTOPB, 0, 910Sstevel@tonic-gate "-cstopb", 0, CSTOPB, 920Sstevel@tonic-gate "hupcl", HUPCL, 0, 930Sstevel@tonic-gate "hup", HUPCL, 0, 940Sstevel@tonic-gate "-hupcl", 0, HUPCL, 950Sstevel@tonic-gate "-hup", 0, HUPCL, 960Sstevel@tonic-gate "clocal", CLOCAL, 0, 970Sstevel@tonic-gate "-clocal", 0, CLOCAL, 980Sstevel@tonic-gate "loblk", LOBLK, 0, 990Sstevel@tonic-gate "-loblk", 0, LOBLK, 1000Sstevel@tonic-gate "cread", CREAD, 0, 1010Sstevel@tonic-gate "-cread", 0, CREAD, 1020Sstevel@tonic-gate "litout", CS8, (CSIZE|PARENB), 1030Sstevel@tonic-gate "-litout", (CS7|PARENB), CSIZE, 1040Sstevel@tonic-gate "pass8", CS8, (CSIZE|PARENB), 1050Sstevel@tonic-gate "-pass8", (CS7|PARENB), CSIZE, 1060Sstevel@tonic-gate "raw", CS8, (CSIZE|PARENB), 1070Sstevel@tonic-gate "-raw", (CS7|PARENB), CSIZE, 1080Sstevel@tonic-gate "cooked", (CS7|PARENB), CSIZE, 1090Sstevel@tonic-gate "sane", (CS7|PARENB|CREAD), (CSIZE|PARODD|CLOCAL), 1100Sstevel@tonic-gate 0 1110Sstevel@tonic-gate }; 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate const struct mds ncmodes[] = { 1140Sstevel@tonic-gate "parext", PAREXT, 0, 1150Sstevel@tonic-gate "-parext", 0, PAREXT, 1160Sstevel@tonic-gate "markp", (PARENB|PARODD|CS7|PAREXT), CSIZE, 1170Sstevel@tonic-gate "-markp", CS8, (PARENB|PARODD|CSIZE|PAREXT), 1180Sstevel@tonic-gate "spacep", (PARENB|CS7|PAREXT), PARODD|CSIZE, 1190Sstevel@tonic-gate "-spacep", CS8, (PARENB|CSIZE|PAREXT), 1200Sstevel@tonic-gate 0 1210Sstevel@tonic-gate }; 1220Sstevel@tonic-gate /* Input Modes */ 1230Sstevel@tonic-gate const struct mds imodes[] = { 1240Sstevel@tonic-gate "ignbrk", IGNBRK, 0, 1250Sstevel@tonic-gate "-ignbrk", 0, IGNBRK, 1260Sstevel@tonic-gate "brkint", BRKINT, 0, 1270Sstevel@tonic-gate "-brkint", 0, BRKINT, 1280Sstevel@tonic-gate "ignpar", IGNPAR, 0, 1290Sstevel@tonic-gate "-ignpar", 0, IGNPAR, 1300Sstevel@tonic-gate "parmrk", PARMRK, 0, 1310Sstevel@tonic-gate "-parmrk", 0, PARMRK, 1320Sstevel@tonic-gate "inpck", INPCK, 0, 133*9354STim.Marsland@Sun.COM "-inpck", 0, INPCK, 1340Sstevel@tonic-gate "istrip", ISTRIP, 0, 1350Sstevel@tonic-gate "-istrip", 0, ISTRIP, 1360Sstevel@tonic-gate "inlcr", INLCR, 0, 1370Sstevel@tonic-gate "-inlcr", 0, INLCR, 1380Sstevel@tonic-gate "igncr", IGNCR, 0, 1390Sstevel@tonic-gate "-igncr", 0, IGNCR, 1400Sstevel@tonic-gate "icrnl", ICRNL, 0, 1410Sstevel@tonic-gate "-icrnl", 0, ICRNL, 1420Sstevel@tonic-gate "-nl", ICRNL, (INLCR|IGNCR), 1430Sstevel@tonic-gate "nl", 0, ICRNL, 1440Sstevel@tonic-gate "iuclc", IUCLC, 0, 1450Sstevel@tonic-gate "-iuclc", 0, IUCLC, 1460Sstevel@tonic-gate "lcase", IUCLC, 0, 1470Sstevel@tonic-gate "-lcase", 0, IUCLC, 1480Sstevel@tonic-gate "LCASE", IUCLC, 0, 1490Sstevel@tonic-gate "-LCASE", 0, IUCLC, 1500Sstevel@tonic-gate "ixon", IXON, 0, 1510Sstevel@tonic-gate "-ixon", 0, IXON, 1520Sstevel@tonic-gate "ixany", IXANY, 0, 1530Sstevel@tonic-gate "-ixany", 0, IXANY, 1540Sstevel@tonic-gate "decctlq", 0, IXANY, 1550Sstevel@tonic-gate "-decctlq", IXANY, 0, 1560Sstevel@tonic-gate "ixoff", IXOFF, 0, 1570Sstevel@tonic-gate "-ixoff", 0, IXOFF, 1580Sstevel@tonic-gate "tandem", IXOFF, 0, 1590Sstevel@tonic-gate "-tandem", 0, IXOFF, 1600Sstevel@tonic-gate "pass8", 0, ISTRIP, 1610Sstevel@tonic-gate "-pass8", ISTRIP, 0, 1620Sstevel@tonic-gate "raw", 0, -1, 1630Sstevel@tonic-gate "-raw", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON|IMAXBEL), 0, 1640Sstevel@tonic-gate "cooked", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON), 0, 1650Sstevel@tonic-gate "sane", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON|IMAXBEL), 1660Sstevel@tonic-gate (IGNBRK|PARMRK|INPCK|INLCR|IGNCR|IUCLC|IXOFF), 1670Sstevel@tonic-gate 0 1680Sstevel@tonic-gate }; 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate const struct mds nimodes[] = { 1710Sstevel@tonic-gate "imaxbel", IMAXBEL, 0, 1720Sstevel@tonic-gate "-imaxbel", 0, IMAXBEL, 1730Sstevel@tonic-gate 0 1740Sstevel@tonic-gate }; 1750Sstevel@tonic-gate /* Local Modes */ 1760Sstevel@tonic-gate const struct mds lmodes[] = { 1770Sstevel@tonic-gate "isig", ISIG, 0, 1780Sstevel@tonic-gate "-isig", 0, ISIG, 1790Sstevel@tonic-gate "icanon", ICANON, 0, 1800Sstevel@tonic-gate "-icanon", 0, ICANON, 1810Sstevel@tonic-gate "cbreak", 0, ICANON, 1820Sstevel@tonic-gate "-cbreak", ICANON, 0, 1830Sstevel@tonic-gate "xcase", XCASE, 0, 1840Sstevel@tonic-gate "-xcase", 0, XCASE, 1850Sstevel@tonic-gate "lcase", XCASE, 0, 1860Sstevel@tonic-gate "-lcase", 0, XCASE, 1870Sstevel@tonic-gate "LCASE", XCASE, 0, 1880Sstevel@tonic-gate "-LCASE", 0, XCASE, 1890Sstevel@tonic-gate "echo", ECHO, 0, 1900Sstevel@tonic-gate "-echo", 0, ECHO, 1910Sstevel@tonic-gate "echoe", ECHOE, 0, 1920Sstevel@tonic-gate "-echoe", 0, ECHOE, 1930Sstevel@tonic-gate "crterase", ECHOE, 0, 1940Sstevel@tonic-gate "-crterase", 0, ECHOE, 1950Sstevel@tonic-gate "echok", ECHOK, 0, 1960Sstevel@tonic-gate "-echok", 0, ECHOK, 1970Sstevel@tonic-gate "lfkc", ECHOK, 0, 1980Sstevel@tonic-gate "-lfkc", 0, ECHOK, 1990Sstevel@tonic-gate "echonl", ECHONL, 0, 2000Sstevel@tonic-gate "-echonl", 0, ECHONL, 2010Sstevel@tonic-gate "noflsh", NOFLSH, 0, 2020Sstevel@tonic-gate "-noflsh", 0, NOFLSH, 2030Sstevel@tonic-gate "raw", 0, (ISIG|ICANON|XCASE|IEXTEN), 2040Sstevel@tonic-gate "-raw", (ISIG|ICANON|IEXTEN), 0, 2050Sstevel@tonic-gate "cooked", (ISIG|ICANON), 0, 2060Sstevel@tonic-gate "sane", (ISIG|ICANON|IEXTEN|ECHO|ECHOK|ECHOE|ECHOCTL|ECHOKE), 2070Sstevel@tonic-gate (XCASE|ECHONL|NOFLSH|STFLUSH|STWRAP|STAPPL), 2080Sstevel@tonic-gate "stflush", STFLUSH, 0, 2090Sstevel@tonic-gate "-stflush", 0, STFLUSH, 2100Sstevel@tonic-gate "stwrap", STWRAP, 0, 2110Sstevel@tonic-gate "-stwrap", 0, STWRAP, 2120Sstevel@tonic-gate "stappl", STAPPL, 0, 2130Sstevel@tonic-gate "-stappl", 0, STAPPL, 2140Sstevel@tonic-gate 0, 2150Sstevel@tonic-gate }; 2160Sstevel@tonic-gate 2170Sstevel@tonic-gate const struct mds nlmodes[] = { 2180Sstevel@tonic-gate "tostop", TOSTOP, 0, 2190Sstevel@tonic-gate "-tostop", 0, TOSTOP, 2200Sstevel@tonic-gate "echoctl", ECHOCTL, 0, 2210Sstevel@tonic-gate "-echoctl", 0, ECHOCTL, 2220Sstevel@tonic-gate "ctlecho", ECHOCTL, 0, 2230Sstevel@tonic-gate "-ctlecho", 0, ECHOCTL, 2240Sstevel@tonic-gate "echoprt", ECHOPRT, 0, 2250Sstevel@tonic-gate "-echoprt", 0, ECHOPRT, 2260Sstevel@tonic-gate "prterase", ECHOPRT, 0, 2270Sstevel@tonic-gate "-prterase", 0, ECHOPRT, 2280Sstevel@tonic-gate "echoke", ECHOKE, 0, 2290Sstevel@tonic-gate "-echoke", 0, ECHOKE, 2300Sstevel@tonic-gate "crtkill", ECHOKE, 0, 2310Sstevel@tonic-gate "-crtkill", 0, ECHOKE, 2320Sstevel@tonic-gate "defecho", DEFECHO, 0, 2330Sstevel@tonic-gate "-defecho", 0, DEFECHO, 2340Sstevel@tonic-gate "flusho", FLUSHO, 0, 2350Sstevel@tonic-gate "-flusho", 0, FLUSHO, 2360Sstevel@tonic-gate "pendin", PENDIN, 0, 2370Sstevel@tonic-gate "-pendin", 0, PENDIN, 2380Sstevel@tonic-gate "iexten", IEXTEN, 0, 2390Sstevel@tonic-gate "-iexten", 0, IEXTEN, 2400Sstevel@tonic-gate 0 2410Sstevel@tonic-gate }; 2420Sstevel@tonic-gate /* Output Modes */ 2430Sstevel@tonic-gate const struct mds omodes[] = { 2440Sstevel@tonic-gate "opost", OPOST, 0, 2450Sstevel@tonic-gate "-opost", 0, OPOST, 2460Sstevel@tonic-gate "olcuc", OLCUC, 0, 2470Sstevel@tonic-gate "-olcuc", 0, OLCUC, 2480Sstevel@tonic-gate "lcase", OLCUC, 0, 2490Sstevel@tonic-gate "-lcase", 0, OLCUC, 2500Sstevel@tonic-gate "LCASE", OLCUC, 0, 2510Sstevel@tonic-gate "-LCASE", 0, OLCUC, 2520Sstevel@tonic-gate "onlcr", ONLCR, 0, 2530Sstevel@tonic-gate "-onlcr", 0, ONLCR, 2540Sstevel@tonic-gate "-nl", ONLCR, (OCRNL|ONLRET), 2550Sstevel@tonic-gate "nl", 0, ONLCR, 2560Sstevel@tonic-gate "ocrnl", OCRNL, 0, 257*9354STim.Marsland@Sun.COM "-ocrnl", 0, OCRNL, 2580Sstevel@tonic-gate "onocr", ONOCR, 0, 2590Sstevel@tonic-gate "-onocr", 0, ONOCR, 2600Sstevel@tonic-gate "onlret", ONLRET, 0, 2610Sstevel@tonic-gate "-onlret", 0, ONLRET, 2620Sstevel@tonic-gate "fill", OFILL, OFDEL, 2630Sstevel@tonic-gate "-fill", 0, OFILL|OFDEL, 2640Sstevel@tonic-gate "nul-fill", OFILL, OFDEL, 2650Sstevel@tonic-gate "del-fill", OFILL|OFDEL, 0, 2660Sstevel@tonic-gate "ofill", OFILL, 0, 2670Sstevel@tonic-gate "-ofill", 0, OFILL, 2680Sstevel@tonic-gate "ofdel", OFDEL, 0, 2690Sstevel@tonic-gate "-ofdel", 0, OFDEL, 2700Sstevel@tonic-gate "cr0", CR0, CRDLY, 2710Sstevel@tonic-gate "cr1", CR1, CRDLY, 2720Sstevel@tonic-gate "cr2", CR2, CRDLY, 2730Sstevel@tonic-gate "cr3", CR3, CRDLY, 2740Sstevel@tonic-gate "tab0", TAB0, TABDLY, 2750Sstevel@tonic-gate "tabs", TAB0, TABDLY, 2760Sstevel@tonic-gate "tab1", TAB1, TABDLY, 2770Sstevel@tonic-gate "tab2", TAB2, TABDLY, 2780Sstevel@tonic-gate "tab3", TAB3, TABDLY, 2790Sstevel@tonic-gate "-tabs", TAB3, TABDLY, 2800Sstevel@tonic-gate "nl0", NL0, NLDLY, 2810Sstevel@tonic-gate "nl1", NL1, NLDLY, 2820Sstevel@tonic-gate "ff0", FF0, FFDLY, 2830Sstevel@tonic-gate "ff1", FF1, FFDLY, 2840Sstevel@tonic-gate "vt0", VT0, VTDLY, 2850Sstevel@tonic-gate "vt1", VT1, VTDLY, 2860Sstevel@tonic-gate "bs0", BS0, BSDLY, 2870Sstevel@tonic-gate "bs1", BS1, BSDLY, 2880Sstevel@tonic-gate "litout", 0, OPOST, 2890Sstevel@tonic-gate "-litout", OPOST, 0, 2900Sstevel@tonic-gate "raw", 0, OPOST, 2910Sstevel@tonic-gate "-raw", OPOST, 0, 2920Sstevel@tonic-gate "cooked", OPOST, 0, 2930Sstevel@tonic-gate "tty33", CR1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY), 2940Sstevel@tonic-gate "tn300", CR1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY), 2950Sstevel@tonic-gate "ti700", CR2, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY), 2960Sstevel@tonic-gate "vt05", NL1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY), 2970Sstevel@tonic-gate "tek", FF1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY), 2980Sstevel@tonic-gate "tty37", (FF1|VT1|CR2|TAB1|NL1), (NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY), 2990Sstevel@tonic-gate "sane", (OPOST|ONLCR), (OLCUC|OCRNL|ONOCR|ONLRET|OFILL|OFDEL| 3000Sstevel@tonic-gate NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY), 3010Sstevel@tonic-gate 0, 3020Sstevel@tonic-gate }; 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate const struct mds hmodes[] = { 3050Sstevel@tonic-gate "-rtsxoff", 0, RTSXOFF, 3060Sstevel@tonic-gate "rtsxoff", RTSXOFF, 0, 3070Sstevel@tonic-gate "-ctsxon", 0, CTSXON, 3080Sstevel@tonic-gate "ctsxon", CTSXON, 0, 3090Sstevel@tonic-gate "-dterxoff", 0, DTRXOFF, 3100Sstevel@tonic-gate "dterxoff", DTRXOFF, 0, 3110Sstevel@tonic-gate "-rlsdxon", 0, CDXON, 3120Sstevel@tonic-gate "rlsdxon", CDXON, 0, 3130Sstevel@tonic-gate "-isxoff", 0, ISXOFF, 3140Sstevel@tonic-gate "isxoff", ISXOFF, 0, 3150Sstevel@tonic-gate 0, 3160Sstevel@tonic-gate }; 3170Sstevel@tonic-gate 3180Sstevel@tonic-gate const struct mds clkmodes[] = { 319*9354STim.Marsland@Sun.COM "xcibrg", XCIBRG, XMTCLK, 320*9354STim.Marsland@Sun.COM "xctset", XCTSET, XMTCLK, 321*9354STim.Marsland@Sun.COM "xcrset", XCRSET, XMTCLK, 322*9354STim.Marsland@Sun.COM "rcibrg", RCIBRG, RCVCLK, 323*9354STim.Marsland@Sun.COM "rctset", RCTSET, RCVCLK, 324*9354STim.Marsland@Sun.COM "rcrset", RCRSET, RCVCLK, 325*9354STim.Marsland@Sun.COM "tsetcoff", TSETCOFF, TSETCLK, 326*9354STim.Marsland@Sun.COM "tsetcrc", TSETCRBRG, TSETCLK, 327*9354STim.Marsland@Sun.COM "tsetcxc", TSETCTBRG, TSETCLK, 328*9354STim.Marsland@Sun.COM "rsetcoff", RSETCOFF, RSETCLK, 329*9354STim.Marsland@Sun.COM "rsetcrc", RSETCRBRG, RSETCLK, 330*9354STim.Marsland@Sun.COM "rsetcxc", RSETCTBRG, RSETCLK, 331*9354STim.Marsland@Sun.COM "async", 332*9354STim.Marsland@Sun.COM XCIBRG|RCIBRG|TSETCOFF|RSETCOFF, XMTCLK|RCVCLK|TSETCLK|RSETCLK, 3330Sstevel@tonic-gate 0, 3340Sstevel@tonic-gate }; 335