Home | History | Annotate | Line # | Download | only in ultrix
ultrix_ioctl.c revision 1.39
      1  1.39  riastrad /*	$NetBSD: ultrix_ioctl.c,v 1.39 2021/09/07 11:43:05 riastradh Exp $ */
      2   1.1  jonathan /*	from : NetBSD: sunos_ioctl.c,v 1.21 1995/10/07 06:27:31 mycroft Exp */
      3   1.1  jonathan 
      4   1.1  jonathan /*
      5   1.1  jonathan  * Copyright (c) 1993 Markus Wild.
      6   1.1  jonathan  * All rights reserved.
      7   1.1  jonathan  *
      8   1.1  jonathan  * Redistribution and use in source and binary forms, with or without
      9   1.1  jonathan  * modification, are permitted provided that the following conditions
     10   1.1  jonathan  * are met:
     11   1.1  jonathan  * 1. Redistributions of source code must retain the above copyright
     12   1.1  jonathan  *    notice, this list of conditions and the following disclaimer.
     13   1.1  jonathan  * 2. The name of the author may not be used to endorse or promote products
     14   1.1  jonathan  *    derived from this software without specific prior written permission
     15   1.1  jonathan  *
     16   1.1  jonathan  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17   1.1  jonathan  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18   1.1  jonathan  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19   1.1  jonathan  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20   1.1  jonathan  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21   1.1  jonathan  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22   1.1  jonathan  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23   1.1  jonathan  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24   1.1  jonathan  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25   1.1  jonathan  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26   1.1  jonathan  *
     27  1.26     perry  * loosely from: Header: sunos_ioctl.c,v 1.7 93/05/28 04:40:43 torek Exp
     28   1.1  jonathan  */
     29  1.18     lukem 
     30  1.18     lukem #include <sys/cdefs.h>
     31  1.39  riastrad __KERNEL_RCSID(0, "$NetBSD: ultrix_ioctl.c,v 1.39 2021/09/07 11:43:05 riastradh Exp $");
     32  1.11   thorpej 
     33  1.16       mrg #if defined(_KERNEL_OPT)
     34  1.11   thorpej #include "opt_compat_ultrix.h"
     35  1.12   thorpej #include "opt_compat_sunos.h"
     36  1.15  jdolecek #endif
     37   1.1  jonathan 
     38   1.1  jonathan #include <sys/param.h>
     39   1.1  jonathan #include <sys/proc.h>
     40   1.1  jonathan #include <sys/systm.h>
     41   1.1  jonathan #include <sys/file.h>
     42   1.1  jonathan #include <sys/filedesc.h>
     43   1.1  jonathan #include <sys/ioctl.h>
     44   1.1  jonathan #include <sys/termios.h>
     45   1.1  jonathan #include <sys/tty.h>
     46   1.1  jonathan #include <sys/socket.h>
     47   1.1  jonathan #include <sys/audioio.h>
     48   1.1  jonathan #include <net/if.h>
     49   1.1  jonathan 
     50   1.1  jonathan #include <sys/mount.h>
     51   1.1  jonathan 
     52  1.31        he #include <compat/sys/sockio.h>
     53   1.1  jonathan #include <compat/ultrix/ultrix_syscallargs.h>
     54   1.1  jonathan #include <sys/syscallargs.h>
     55   1.1  jonathan 
     56   1.1  jonathan #include <compat/sunos/sunos.h>
     57   1.1  jonathan 
     58  1.15  jdolecek #include <compat/ultrix/ultrix_tty.h>
     59   1.1  jonathan 
     60   1.2  jonathan #define emul_termio	ultrix_termio
     61   1.2  jonathan #define emul_termios	ultrix_termios
     62   1.1  jonathan 
     63   1.1  jonathan /*
     64   1.1  jonathan  * SunOS ioctl calls.
     65   1.1  jonathan  * This file is something of a hodge-podge.
     66   1.1  jonathan  * Support gets added as things turn up....
     67   1.1  jonathan  */
     68   1.1  jonathan 
     69  1.25      matt static const struct speedtab sptab[] = {
     70   1.1  jonathan 	{ 0, 0 },
     71   1.1  jonathan 	{ 50, 1 },
     72   1.1  jonathan 	{ 75, 2 },
     73   1.1  jonathan 	{ 110, 3 },
     74   1.1  jonathan 	{ 134, 4 },
     75   1.1  jonathan 	{ 135, 4 },
     76   1.1  jonathan 	{ 150, 5 },
     77   1.1  jonathan 	{ 200, 6 },
     78   1.1  jonathan 	{ 300, 7 },
     79   1.1  jonathan 	{ 600, 8 },
     80   1.1  jonathan 	{ 1200, 9 },
     81   1.1  jonathan 	{ 1800, 10 },
     82   1.1  jonathan 	{ 2400, 11 },
     83   1.1  jonathan 	{ 4800, 12 },
     84   1.1  jonathan 	{ 9600, 13 },
     85   1.1  jonathan 	{ 19200, 14 },
     86   1.1  jonathan 	{ 38400, 15 },
     87   1.1  jonathan 	{ -1, -1 }
     88   1.1  jonathan };
     89   1.1  jonathan 
     90  1.36      matt static const uint16_t s2btab[] = {
     91   1.1  jonathan 	0,
     92   1.1  jonathan 	50,
     93   1.1  jonathan 	75,
     94   1.1  jonathan 	110,
     95   1.1  jonathan 	134,
     96   1.1  jonathan 	150,
     97   1.1  jonathan 	200,
     98   1.1  jonathan 	300,
     99   1.1  jonathan 	600,
    100   1.1  jonathan 	1200,
    101   1.1  jonathan 	1800,
    102   1.1  jonathan 	2400,
    103   1.1  jonathan 	4800,
    104   1.1  jonathan 	9600,
    105   1.1  jonathan 	19200,
    106   1.1  jonathan 	38400,
    107   1.1  jonathan };
    108   1.1  jonathan 
    109   1.2  jonathan 
    110   1.2  jonathan /*
    111   1.2  jonathan  * Translate a single tty control char from the emulation value
    112   1.2  jonathan  * to native termios, and vice-versa. Special-case
    113   1.2  jonathan  * the value of POSIX_VDISABLE, mapping it to and from 0.
    114   1.2  jonathan  */
    115   1.2  jonathan #define NATIVE_TO_EMUL_CC(bsd_cc) \
    116   1.2  jonathan  (((bsd_cc)   != _POSIX_VDISABLE) ? (bsd_cc) : 0)
    117   1.2  jonathan 
    118   1.2  jonathan #define EMUL_TO_NATIVE_CC(emul_cc) \
    119   1.2  jonathan  (emul_cc) ? (emul_cc) : _POSIX_VDISABLE;
    120   1.2  jonathan 
    121   1.2  jonathan 
    122  1.24    simonb static void stios2btios(struct emul_termios *, struct termios *);
    123  1.24    simonb static void btios2stios(struct termios *, struct emul_termios *);
    124  1.24    simonb static void stios2stio(struct emul_termios *, struct emul_termio *);
    125  1.24    simonb static void stio2stios(struct emul_termio *, struct emul_termios *);
    126   1.2  jonathan 
    127   1.1  jonathan /*
    128   1.1  jonathan  * these two conversion functions have mostly been done
    129   1.1  jonathan  * with some perl cut&paste, then handedited to comment
    130   1.1  jonathan  * out what doesn't exist under NetBSD.
    131   1.1  jonathan  * A note from Markus's code:
    132   1.1  jonathan  *	(l & BITMASK1) / BITMASK1 * BITMASK2  is translated
    133   1.1  jonathan  *	optimally by gcc m68k, much better than any ?: stuff.
    134   1.1  jonathan  *	Code may vary with different architectures of course.
    135   1.1  jonathan  *
    136   1.1  jonathan  * I don't know what optimizer you used, but seeing divu's and
    137   1.1  jonathan  * bfextu's in the m68k assembly output did not encourage me...
    138   1.1  jonathan  * as well, gcc on the sparc definately generates much better
    139   1.1  jonathan  * code with ?:.
    140   1.1  jonathan  */
    141   1.1  jonathan 
    142   1.2  jonathan 
    143   1.1  jonathan static void
    144  1.24    simonb stios2btios(struct emul_termios *st, struct termios *bt)
    145   1.1  jonathan {
    146  1.36      matt 	uint32_t l, r;
    147   1.1  jonathan 
    148  1.39  riastrad 	memset(bt, 0, sizeof(*bt));
    149  1.39  riastrad 
    150   1.1  jonathan 	l = st->c_iflag;
    151   1.1  jonathan 	r = 	((l & 0x00000001) ? IGNBRK	: 0);
    152   1.1  jonathan 	r |=	((l & 0x00000002) ? BRKINT	: 0);
    153   1.1  jonathan 	r |=	((l & 0x00000004) ? IGNPAR	: 0);
    154   1.1  jonathan 	r |=	((l & 0x00000008) ? PARMRK	: 0);
    155   1.1  jonathan 	r |=	((l & 0x00000010) ? INPCK	: 0);
    156   1.1  jonathan 	r |=	((l & 0x00000020) ? ISTRIP	: 0);
    157   1.1  jonathan 	r |= 	((l & 0x00000040) ? INLCR	: 0);
    158   1.1  jonathan 	r |=	((l & 0x00000080) ? IGNCR	: 0);
    159   1.1  jonathan 	r |=	((l & 0x00000100) ? ICRNL	: 0);
    160   1.1  jonathan 	/*	((l & 0x00000200) ? IUCLC	: 0) */
    161   1.1  jonathan 	r |=	((l & 0x00000400) ? IXON	: 0);
    162   1.1  jonathan 	r |=	((l & 0x00000800) ? IXANY	: 0);
    163   1.1  jonathan 	r |=	((l & 0x00001000) ? IXOFF	: 0);
    164   1.1  jonathan 	r |=	((l & 0x00002000) ? IMAXBEL	: 0);
    165   1.1  jonathan 	bt->c_iflag = r;
    166   1.1  jonathan 
    167   1.1  jonathan 	l = st->c_oflag;
    168   1.1  jonathan 	r = 	((l & 0x00000001) ? OPOST	: 0);
    169   1.1  jonathan 	/*	((l & 0x00000002) ? OLCUC	: 0) */
    170   1.1  jonathan 	r |=	((l & 0x00000004) ? ONLCR	: 0);
    171   1.1  jonathan 	/*	((l & 0x00000008) ? OCRNL	: 0) */
    172   1.1  jonathan 	/*	((l & 0x00000010) ? ONOCR	: 0) */
    173   1.1  jonathan 	/*	((l & 0x00000020) ? ONLRET	: 0) */
    174   1.1  jonathan 	/*	((l & 0x00000040) ? OFILL	: 0) */
    175   1.1  jonathan 	/*	((l & 0x00000080) ? OFDEL	: 0) */
    176   1.1  jonathan 	/*	((l & 0x00000100) ? NLDLY	: 0) */
    177   1.1  jonathan 	/*	((l & 0x00000100) ? NL1		: 0) */
    178   1.1  jonathan 	/*	((l & 0x00000600) ? CRDLY	: 0) */
    179   1.1  jonathan 	/*	((l & 0x00000200) ? CR1		: 0) */
    180   1.1  jonathan 	/*	((l & 0x00000400) ? CR2		: 0) */
    181   1.1  jonathan 	/*	((l & 0x00000600) ? CR3		: 0) */
    182   1.1  jonathan 	/*	((l & 0x00001800) ? TABDLY	: 0) */
    183   1.1  jonathan 	/*	((l & 0x00000800) ? TAB1	: 0) */
    184   1.1  jonathan 	/*	((l & 0x00001000) ? TAB2	: 0) */
    185   1.1  jonathan 	r |=	((l & 0x00001800) ? OXTABS	: 0);
    186   1.1  jonathan 	/*	((l & 0x00002000) ? BSDLY	: 0) */
    187   1.1  jonathan 	/*	((l & 0x00002000) ? BS1		: 0) */
    188   1.1  jonathan 	/*	((l & 0x00004000) ? VTDLY	: 0) */
    189   1.1  jonathan 	/*	((l & 0x00004000) ? VT1		: 0) */
    190   1.1  jonathan 	/*	((l & 0x00008000) ? FFDLY	: 0) */
    191   1.1  jonathan 	/*	((l & 0x00008000) ? FF1		: 0) */
    192   1.1  jonathan 	/*	((l & 0x00010000) ? PAGEOUT	: 0) */
    193   1.1  jonathan 	/*	((l & 0x00020000) ? WRAP	: 0) */
    194   1.1  jonathan 	bt->c_oflag = r;
    195   1.1  jonathan 
    196   1.1  jonathan 	l = st->c_cflag;
    197   1.1  jonathan 	switch (l & 0x00000030) {
    198   1.1  jonathan 	case 0:
    199   1.1  jonathan 		r = CS5;
    200   1.1  jonathan 		break;
    201   1.1  jonathan 	case 0x00000010:
    202   1.1  jonathan 		r = CS6;
    203   1.1  jonathan 		break;
    204   1.1  jonathan 	case 0x00000020:
    205   1.1  jonathan 		r = CS7;
    206   1.1  jonathan 		break;
    207   1.1  jonathan 	case 0x00000030:
    208   1.1  jonathan 		r = CS8;
    209   1.1  jonathan 		break;
    210  1.26     perry 	}
    211   1.1  jonathan 	r |=	((l & 0x00000040) ? CSTOPB	: 0);
    212   1.1  jonathan 	r |=	((l & 0x00000080) ? CREAD	: 0);
    213   1.1  jonathan 	r |= 	((l & 0x00000100) ? PARENB	: 0);
    214   1.1  jonathan 	r |=	((l & 0x00000200) ? PARODD	: 0);
    215   1.1  jonathan 	r |=	((l & 0x00000400) ? HUPCL	: 0);
    216   1.1  jonathan 	r |=	((l & 0x00000800) ? CLOCAL	: 0);
    217   1.1  jonathan 	/*	((l & 0x00001000) ? LOBLK	: 0) */
    218   1.1  jonathan 	r |=	((l & 0x80000000) ? (CRTS_IFLOW|CCTS_OFLOW) : 0);
    219   1.1  jonathan 	bt->c_cflag = r;
    220   1.1  jonathan 
    221   1.1  jonathan 	bt->c_ispeed = bt->c_ospeed = s2btab[l & 0x0000000f];
    222   1.1  jonathan 
    223   1.1  jonathan 	l = st->c_lflag;
    224   1.1  jonathan 	r = 	((l & 0x00000001) ? ISIG	: 0);
    225   1.1  jonathan 	r |=	((l & 0x00000002) ? ICANON	: 0);
    226   1.1  jonathan 	/*	((l & 0x00000004) ? XCASE	: 0) */
    227   1.1  jonathan 	r |=	((l & 0x00000008) ? ECHO	: 0);
    228   1.1  jonathan 	r |=	((l & 0x00000010) ? ECHOE	: 0);
    229   1.1  jonathan 	r |=	((l & 0x00000020) ? ECHOK	: 0);
    230   1.1  jonathan 	r |=	((l & 0x00000040) ? ECHONL	: 0);
    231   1.1  jonathan 	r |= 	((l & 0x00000080) ? NOFLSH	: 0);
    232   1.1  jonathan 	r |=	((l & 0x00000100) ? TOSTOP	: 0);
    233   1.1  jonathan 	r |=	((l & 0x00000200) ? ECHOCTL	: 0);
    234   1.1  jonathan 	r |=	((l & 0x00000400) ? ECHOPRT	: 0);
    235   1.1  jonathan 	r |=	((l & 0x00000800) ? ECHOKE	: 0);
    236   1.1  jonathan 	/*	((l & 0x00001000) ? DEFECHO	: 0) */
    237   1.1  jonathan 	r |=	((l & 0x00002000) ? FLUSHO	: 0);
    238   1.1  jonathan 	r |=	((l & 0x00004000) ? PENDIN	: 0);
    239   1.1  jonathan 	bt->c_lflag = r;
    240   1.1  jonathan 
    241   1.2  jonathan 	bt->c_cc[VINTR]    = EMUL_TO_NATIVE_CC(st->c_cc[0]);
    242   1.2  jonathan 	bt->c_cc[VQUIT]    = EMUL_TO_NATIVE_CC(st->c_cc[1]);
    243   1.2  jonathan 	bt->c_cc[VERASE]   = EMUL_TO_NATIVE_CC(st->c_cc[2]);
    244   1.2  jonathan 	bt->c_cc[VKILL]    = EMUL_TO_NATIVE_CC(st->c_cc[3]);
    245   1.2  jonathan 	bt->c_cc[VEOF]     = EMUL_TO_NATIVE_CC(st->c_cc[4]);
    246   1.2  jonathan 	bt->c_cc[VEOL]     = EMUL_TO_NATIVE_CC(st->c_cc[5]);
    247   1.2  jonathan 	bt->c_cc[VEOL2]    = EMUL_TO_NATIVE_CC(st->c_cc[6]);
    248   1.2  jonathan 	/* not present on NetBSD */
    249   1.2  jonathan 	/* bt->c_cc[VSWTCH]   = EMUL_TO_NATIVE_CC(st->c_cc[7]); */
    250   1.2  jonathan 	bt->c_cc[VSTART]   = EMUL_TO_NATIVE_CC(st->c_cc[10]);
    251   1.2  jonathan 	bt->c_cc[VSTOP]    = EMUL_TO_NATIVE_CC(st->c_cc[11]);
    252   1.4  jonathan 	bt->c_cc[VSUSP]    = EMUL_TO_NATIVE_CC(st->c_cc[12]);
    253   1.4  jonathan 	bt->c_cc[VDSUSP]   = EMUL_TO_NATIVE_CC(st->c_cc[13]);
    254   1.2  jonathan 	bt->c_cc[VREPRINT] = EMUL_TO_NATIVE_CC(st->c_cc[14]);
    255   1.2  jonathan 	bt->c_cc[VDISCARD] = EMUL_TO_NATIVE_CC(st->c_cc[15]);
    256   1.2  jonathan 	bt->c_cc[VWERASE]  = EMUL_TO_NATIVE_CC(st->c_cc[16]);
    257   1.2  jonathan 	bt->c_cc[VLNEXT]   = EMUL_TO_NATIVE_CC(st->c_cc[17]);
    258   1.2  jonathan 	bt->c_cc[VSTATUS]  = EMUL_TO_NATIVE_CC(st->c_cc[18]);
    259   1.2  jonathan 
    260   1.2  jonathan #ifdef COMPAT_ULTRIX
    261   1.2  jonathan 	/* Ultrix termio/termios has real vmin/vtime */
    262   1.2  jonathan 	bt->c_cc[VMIN]	   = EMUL_TO_NATIVE_CC(st->c_cc[8]);
    263   1.2  jonathan 	bt->c_cc[VTIME]	   = EMUL_TO_NATIVE_CC(st->c_cc[9]);
    264   1.2  jonathan #else
    265   1.1  jonathan 	/* if `raw mode', create native VMIN/VTIME from SunOS VEOF/VEOL */
    266   1.1  jonathan 	bt->c_cc[VMIN]	   = (bt->c_lflag & ICANON) ? 1 : bt->c_cc[VEOF];
    267   1.1  jonathan 	bt->c_cc[VTIME]	   = (bt->c_lflag & ICANON) ? 1 : bt->c_cc[VEOL];
    268   1.2  jonathan #endif
    269   1.2  jonathan 
    270   1.1  jonathan }
    271   1.1  jonathan 
    272   1.2  jonathan /*
    273   1.2  jonathan  * Convert bsd termios to "sunos" emulated termios
    274   1.2  jonathan  */
    275   1.1  jonathan static void
    276  1.24    simonb btios2stios(struct termios *bt, struct emul_termios *st)
    277   1.1  jonathan {
    278  1.36      matt 	uint32_t l, r;
    279  1.33  christos 	int speed;
    280   1.1  jonathan 
    281  1.39  riastrad 	memset(st, 0, sizeof(*st));
    282  1.39  riastrad 
    283   1.1  jonathan 	l = bt->c_iflag;
    284   1.1  jonathan 	r = 	((l &  IGNBRK) ? 0x00000001	: 0);
    285   1.1  jonathan 	r |=	((l &  BRKINT) ? 0x00000002	: 0);
    286   1.1  jonathan 	r |=	((l &  IGNPAR) ? 0x00000004	: 0);
    287   1.1  jonathan 	r |=	((l &  PARMRK) ? 0x00000008	: 0);
    288   1.1  jonathan 	r |=	((l &   INPCK) ? 0x00000010	: 0);
    289   1.1  jonathan 	r |=	((l &  ISTRIP) ? 0x00000020	: 0);
    290   1.1  jonathan 	r |=	((l &   INLCR) ? 0x00000040	: 0);
    291   1.1  jonathan 	r |=	((l &   IGNCR) ? 0x00000080	: 0);
    292   1.1  jonathan 	r |=	((l &   ICRNL) ? 0x00000100	: 0);
    293   1.1  jonathan 	/*	((l &   IUCLC) ? 0x00000200	: 0) */
    294   1.1  jonathan 	r |=	((l &    IXON) ? 0x00000400	: 0);
    295   1.1  jonathan 	r |=	((l &   IXANY) ? 0x00000800	: 0);
    296   1.1  jonathan 	r |=	((l &   IXOFF) ? 0x00001000	: 0);
    297   1.1  jonathan 	r |=	((l & IMAXBEL) ? 0x00002000	: 0);
    298   1.1  jonathan 	st->c_iflag = r;
    299   1.1  jonathan 
    300   1.1  jonathan 	l = bt->c_oflag;
    301   1.1  jonathan 	r =	((l &   OPOST) ? 0x00000001	: 0);
    302   1.1  jonathan 	/*	((l &   OLCUC) ? 0x00000002	: 0) */
    303   1.1  jonathan 	r |=	((l &   ONLCR) ? 0x00000004	: 0);
    304   1.1  jonathan 	/*	((l &   OCRNL) ? 0x00000008	: 0) */
    305   1.1  jonathan 	/*	((l &   ONOCR) ? 0x00000010	: 0) */
    306   1.1  jonathan 	/*	((l &  ONLRET) ? 0x00000020	: 0) */
    307   1.1  jonathan 	/*	((l &   OFILL) ? 0x00000040	: 0) */
    308   1.1  jonathan 	/*	((l &   OFDEL) ? 0x00000080	: 0) */
    309   1.1  jonathan 	/*	((l &   NLDLY) ? 0x00000100	: 0) */
    310   1.1  jonathan 	/*	((l &     NL1) ? 0x00000100	: 0) */
    311   1.1  jonathan 	/*	((l &   CRDLY) ? 0x00000600	: 0) */
    312   1.1  jonathan 	/*	((l &     CR1) ? 0x00000200	: 0) */
    313   1.1  jonathan 	/*	((l &     CR2) ? 0x00000400	: 0) */
    314   1.1  jonathan 	/*	((l &     CR3) ? 0x00000600	: 0) */
    315   1.1  jonathan 	/*	((l &  TABDLY) ? 0x00001800	: 0) */
    316   1.1  jonathan 	/*	((l &    TAB1) ? 0x00000800	: 0) */
    317   1.1  jonathan 	/*	((l &    TAB2) ? 0x00001000	: 0) */
    318   1.1  jonathan 	r |=	((l &  OXTABS) ? 0x00001800	: 0);
    319   1.1  jonathan 	/*	((l &   BSDLY) ? 0x00002000	: 0) */
    320   1.1  jonathan 	/*	((l &     BS1) ? 0x00002000	: 0) */
    321   1.1  jonathan 	/*	((l &   VTDLY) ? 0x00004000	: 0) */
    322   1.1  jonathan 	/*	((l &     VT1) ? 0x00004000	: 0) */
    323   1.1  jonathan 	/*	((l &   FFDLY) ? 0x00008000	: 0) */
    324   1.1  jonathan 	/*	((l &     FF1) ? 0x00008000	: 0) */
    325   1.1  jonathan 	/*	((l & PAGEOUT) ? 0x00010000	: 0) */
    326   1.1  jonathan 	/*	((l &    WRAP) ? 0x00020000	: 0) */
    327   1.1  jonathan 	st->c_oflag = r;
    328   1.1  jonathan 
    329   1.1  jonathan 	l = bt->c_cflag;
    330   1.1  jonathan 	switch (l & CSIZE) {
    331   1.1  jonathan 	case CS5:
    332   1.1  jonathan 		r = 0;
    333   1.1  jonathan 		break;
    334   1.1  jonathan 	case CS6:
    335   1.1  jonathan 		r = 0x00000010;
    336   1.1  jonathan 		break;
    337   1.1  jonathan 	case CS7:
    338   1.1  jonathan 		r = 0x00000020;
    339   1.1  jonathan 		break;
    340   1.1  jonathan 	case CS8:
    341   1.1  jonathan 		r = 0x00000030;
    342   1.1  jonathan 		break;
    343   1.1  jonathan 	}
    344   1.1  jonathan 	r |=	((l &  CSTOPB) ? 0x00000040	: 0);
    345   1.1  jonathan 	r |=	((l &   CREAD) ? 0x00000080	: 0);
    346   1.1  jonathan 	r |=	((l &  PARENB) ? 0x00000100	: 0);
    347   1.1  jonathan 	r |=	((l &  PARODD) ? 0x00000200	: 0);
    348   1.1  jonathan 	r |=	((l &   HUPCL) ? 0x00000400	: 0);
    349   1.1  jonathan 	r |=	((l &  CLOCAL) ? 0x00000800	: 0);
    350   1.1  jonathan 	/*	((l &   LOBLK) ? 0x00001000	: 0) */
    351   1.1  jonathan 	r |=	((l & (CRTS_IFLOW|CCTS_OFLOW)) ? 0x80000000 : 0);
    352   1.1  jonathan 	st->c_cflag = r;
    353   1.1  jonathan 
    354   1.1  jonathan 	l = bt->c_lflag;
    355   1.1  jonathan 	r =	((l &    ISIG) ? 0x00000001	: 0);
    356   1.1  jonathan 	r |=	((l &  ICANON) ? 0x00000002	: 0);
    357   1.1  jonathan 	/*	((l &   XCASE) ? 0x00000004	: 0) */
    358   1.1  jonathan 	r |=	((l &    ECHO) ? 0x00000008	: 0);
    359   1.1  jonathan 	r |=	((l &   ECHOE) ? 0x00000010	: 0);
    360   1.1  jonathan 	r |=	((l &   ECHOK) ? 0x00000020	: 0);
    361   1.1  jonathan 	r |=	((l &  ECHONL) ? 0x00000040	: 0);
    362   1.1  jonathan 	r |=	((l &  NOFLSH) ? 0x00000080	: 0);
    363   1.1  jonathan 	r |=	((l &  TOSTOP) ? 0x00000100	: 0);
    364   1.1  jonathan 	r |=	((l & ECHOCTL) ? 0x00000200	: 0);
    365   1.1  jonathan 	r |=	((l & ECHOPRT) ? 0x00000400	: 0);
    366   1.1  jonathan 	r |=	((l &  ECHOKE) ? 0x00000800	: 0);
    367   1.1  jonathan 	/*	((l & DEFECHO) ? 0x00001000	: 0) */
    368   1.1  jonathan 	r |=	((l &  FLUSHO) ? 0x00002000	: 0);
    369   1.1  jonathan 	r |=	((l &  PENDIN) ? 0x00004000	: 0);
    370   1.1  jonathan 	st->c_lflag = r;
    371   1.1  jonathan 
    372  1.33  christos 	speed = ttspeedtab(bt->c_ospeed, sptab);
    373  1.33  christos 	if (speed != -1)
    374  1.33  christos 	    st->c_cflag |= speed;
    375   1.1  jonathan 
    376   1.2  jonathan 	st->c_cc[0] = NATIVE_TO_EMUL_CC(bt->c_cc[VINTR]);
    377   1.2  jonathan 	st->c_cc[1] = NATIVE_TO_EMUL_CC(bt->c_cc[VQUIT]);
    378   1.2  jonathan 	st->c_cc[2] = NATIVE_TO_EMUL_CC(bt->c_cc[VERASE]);
    379   1.2  jonathan 	st->c_cc[3] = NATIVE_TO_EMUL_CC(bt->c_cc[VKILL]);
    380   1.2  jonathan 	st->c_cc[4] = NATIVE_TO_EMUL_CC(bt->c_cc[VEOF]);
    381   1.2  jonathan 	st->c_cc[5] = NATIVE_TO_EMUL_CC(bt->c_cc[VEOL]);
    382   1.2  jonathan 	st->c_cc[6] = NATIVE_TO_EMUL_CC(bt->c_cc[VEOL2]);
    383   1.9  jonathan 
    384   1.9  jonathan 	/* XXX ultrix has a VSWTCH.  NetBSD does not. */
    385   1.9  jonathan #ifdef notdef
    386   1.2  jonathan 	st->c_cc[7] = NATIVE_TO_EMUL_CC(bt->c_cc[VSWTCH]);
    387   1.2  jonathan #else
    388   1.1  jonathan 	st->c_cc[7] = 0;
    389   1.2  jonathan #endif
    390   1.2  jonathan 	st->c_cc[10] = NATIVE_TO_EMUL_CC(bt->c_cc[VSTART]);
    391   1.2  jonathan 	st->c_cc[11] = NATIVE_TO_EMUL_CC(bt->c_cc[VSTOP]);
    392   1.2  jonathan 	st->c_cc[12]= NATIVE_TO_EMUL_CC(bt->c_cc[VSUSP]);
    393   1.2  jonathan 	st->c_cc[13]= NATIVE_TO_EMUL_CC(bt->c_cc[VDSUSP]);
    394   1.2  jonathan 	st->c_cc[14]= NATIVE_TO_EMUL_CC(bt->c_cc[VREPRINT]);
    395   1.2  jonathan 	st->c_cc[15]= NATIVE_TO_EMUL_CC(bt->c_cc[VDISCARD]);
    396   1.2  jonathan 	st->c_cc[16]= NATIVE_TO_EMUL_CC(bt->c_cc[VWERASE]);
    397   1.2  jonathan 	st->c_cc[17]= NATIVE_TO_EMUL_CC(bt->c_cc[VLNEXT]);
    398   1.2  jonathan 	st->c_cc[18]= NATIVE_TO_EMUL_CC(bt->c_cc[VSTATUS]);
    399   1.2  jonathan 
    400   1.2  jonathan #ifdef COMPAT_ULTRIX
    401   1.2  jonathan 	st->c_cc[8]= NATIVE_TO_EMUL_CC(bt->c_cc[VMIN]);
    402   1.2  jonathan 	st->c_cc[9]= NATIVE_TO_EMUL_CC(bt->c_cc[VTIME]);
    403   1.2  jonathan #else
    404   1.1  jonathan 	if (!(bt->c_lflag & ICANON)) {
    405   1.1  jonathan 		/* SunOS stores VMIN/VTIME in VEOF/VEOL (if ICANON is off) */
    406   1.1  jonathan 		st->c_cc[4] = bt->c_cc[VMIN];
    407   1.1  jonathan 		st->c_cc[5] = bt->c_cc[VTIME];
    408   1.1  jonathan 	}
    409   1.2  jonathan #endif
    410   1.1  jonathan 
    411   1.2  jonathan #ifdef COMPAT_SUNOS
    412   1.2  jonathan 	st->c_line = 0;	/* 4.3bsd "old" line discipline */
    413   1.2  jonathan #else
    414   1.9  jonathan 	st->c_line = 2;	/* 4.3bsd "new" line discipline, Ultrix default. */
    415   1.2  jonathan #endif
    416   1.1  jonathan }
    417   1.1  jonathan 
    418   1.2  jonathan #define TERMIO_NCC 10	/* ultrix termio NCC is 10 */
    419   1.2  jonathan 
    420   1.2  jonathan /*
    421   1.2  jonathan  * Convert emulated struct termios to termio(?)
    422   1.2  jonathan  */
    423   1.1  jonathan static void
    424  1.24    simonb stios2stio(struct emul_termios *ts, struct emul_termio *t)
    425   1.1  jonathan {
    426  1.39  riastrad 
    427  1.39  riastrad 	memset(t, 0, sizeof(*t));
    428   1.1  jonathan 	t->c_iflag = ts->c_iflag;
    429   1.1  jonathan 	t->c_oflag = ts->c_oflag;
    430   1.1  jonathan 	t->c_cflag = ts->c_cflag;
    431   1.1  jonathan 	t->c_lflag = ts->c_lflag;
    432   1.1  jonathan 	t->c_line  = ts->c_line;
    433  1.13     perry 	memcpy(t->c_cc, ts->c_cc, TERMIO_NCC);
    434   1.1  jonathan }
    435   1.1  jonathan 
    436   1.2  jonathan /*
    437   1.2  jonathan  * Convert the other way
    438   1.2  jonathan  */
    439   1.1  jonathan static void
    440  1.24    simonb stio2stios(struct emul_termio *t, struct emul_termios *ts)
    441   1.1  jonathan {
    442  1.39  riastrad 
    443  1.39  riastrad 	memset(ts, 0, sizeof(*t));
    444   1.1  jonathan 	ts->c_iflag = t->c_iflag;
    445   1.1  jonathan 	ts->c_oflag = t->c_oflag;
    446   1.1  jonathan 	ts->c_cflag = t->c_cflag;
    447   1.1  jonathan 	ts->c_lflag = t->c_lflag;
    448   1.1  jonathan 	ts->c_line  = t->c_line;
    449  1.38   msaitoh 
    450  1.38   msaitoh 	/* don't touch the upper fields! */
    451  1.38   msaitoh 	memcpy(ts->c_cc, t->c_cc, TERMIO_NCC);
    452   1.1  jonathan }
    453   1.1  jonathan 
    454  1.34       dsl static int
    455  1.34       dsl ultrix_do_ioctl(int fd, int cmd, void *arg, struct lwp *l)
    456   1.1  jonathan {
    457  1.35        ad 	file_t *fp;
    458   1.1  jonathan 	int error;
    459   1.1  jonathan 
    460  1.35        ad 	if ((fp = fd_getfile(fd)) == NULL)
    461   1.1  jonathan 		return EBADF;
    462   1.1  jonathan 
    463  1.35        ad 	if ((fp->f_flag & (FREAD|FWRITE)) == 0)
    464  1.35        ad 		error = EBADF;
    465  1.35        ad 	else
    466  1.35        ad 		error = fp->f_ops->fo_ioctl(fp, cmd, arg);
    467  1.35        ad 	fd_putfile(fd);
    468  1.34       dsl 	return error;
    469  1.34       dsl }
    470   1.1  jonathan 
    471  1.34       dsl int
    472  1.38   msaitoh ultrix_sys_ioctl(struct lwp *l, const struct ultrix_sys_ioctl_args *uap,
    473  1.38   msaitoh     register_t *retval)
    474  1.34       dsl {
    475  1.34       dsl 	struct sys_ioctl_args ap;
    476  1.34       dsl 	int error;
    477   1.1  jonathan 
    478  1.33  christos 	SCARG(&ap, fd) = SCARG(uap, fd);
    479  1.33  christos 	SCARG(&ap, data) = SCARG(uap, data);
    480  1.33  christos 	SCARG(&ap, com) = SCARG(uap, com);
    481  1.33  christos 	switch (SCARG(&ap, com)) {
    482   1.1  jonathan 	case _IOR('t', 0, int):
    483  1.33  christos 		SCARG(&ap, com) = TIOCGETD;
    484   1.1  jonathan 		break;
    485   1.1  jonathan 	case _IOW('t', 1, int):
    486   1.1  jonathan 	    {
    487   1.1  jonathan 		int disc;
    488   1.1  jonathan 
    489  1.38   msaitoh 		error = copyin(SCARG(&ap, data), &disc, sizeof disc);
    490  1.38   msaitoh 		if (error != 0)
    491   1.1  jonathan 			return error;
    492   1.1  jonathan 
    493   1.1  jonathan 		/* map SunOS NTTYDISC into our termios discipline */
    494   1.1  jonathan 		if (disc == 2)
    495   1.1  jonathan 			disc = 0;
    496   1.1  jonathan 		/* all other disciplines are not supported by NetBSD */
    497   1.1  jonathan 		if (disc)
    498   1.1  jonathan 			return ENXIO;
    499   1.1  jonathan 
    500  1.34       dsl 		return ultrix_do_ioctl(SCARG(&ap, fd), TIOCSETD, &disc, l);
    501   1.1  jonathan 	    }
    502   1.1  jonathan 	case _IOW('t', 101, int):	/* sun SUNOS_TIOCSSOFTCAR */
    503   1.1  jonathan 	    {
    504   1.1  jonathan 		int x;	/* unused */
    505   1.1  jonathan 
    506  1.37      maxv 		return copyin(SCARG(&ap, data), &x, sizeof x);
    507   1.1  jonathan 	    }
    508   1.1  jonathan 	case _IOR('t', 100, int):	/* sun SUNOS_TIOCSSOFTCAR */
    509   1.1  jonathan 	    {
    510   1.1  jonathan 		int x = 0;
    511   1.1  jonathan 
    512  1.33  christos 		return copyout(&x, SCARG(&ap, data), sizeof x);
    513   1.1  jonathan 	    }
    514   1.1  jonathan 	case _IO('t', 36): 		/* sun TIOCCONS, no parameters */
    515   1.1  jonathan 	    {
    516   1.1  jonathan 		int on = 1;
    517  1.34       dsl 		return ultrix_do_ioctl(SCARG(&ap, fd), TIOCCONS, &on, l);
    518   1.1  jonathan 	    }
    519  1.26     perry 	case _IOW('t', 37, struct sunos_ttysize):
    520   1.1  jonathan 	    {
    521   1.1  jonathan 		struct winsize ws;
    522   1.1  jonathan 		struct sunos_ttysize ss;
    523   1.1  jonathan 
    524  1.38   msaitoh 		error = ultrix_do_ioctl(SCARG(&ap, fd), TIOCGWINSZ, &ws, l);
    525  1.38   msaitoh 		if (error != 0)
    526  1.33  christos 			return error;
    527   1.1  jonathan 
    528  1.38   msaitoh 		if ((error = copyin(SCARG(&ap, data), &ss, sizeof(ss))) != 0)
    529   1.1  jonathan 			return error;
    530   1.1  jonathan 
    531   1.1  jonathan 		ws.ws_row = ss.ts_row;
    532   1.1  jonathan 		ws.ws_col = ss.ts_col;
    533   1.1  jonathan 
    534  1.34       dsl 		return ultrix_do_ioctl(SCARG(&ap, fd), TIOCSWINSZ, &ws, l);
    535   1.1  jonathan 	    }
    536  1.26     perry 	case _IOW('t', 38, struct sunos_ttysize):
    537   1.1  jonathan 	    {
    538   1.1  jonathan 		struct winsize ws;
    539   1.1  jonathan 		struct sunos_ttysize ss;
    540   1.1  jonathan 
    541  1.38   msaitoh 		error = ultrix_do_ioctl(SCARG(&ap, fd), TIOCGWINSZ, &ws, l);
    542  1.38   msaitoh 		if (error != 0)
    543  1.33  christos 			return error;
    544   1.1  jonathan 
    545  1.39  riastrad 		memset(&ss, 0, sizeof(ss));
    546   1.1  jonathan 		ss.ts_row = ws.ws_row;
    547   1.1  jonathan 		ss.ts_col = ws.ws_col;
    548   1.1  jonathan 
    549  1.38   msaitoh 		return copyout(&ss, SCARG(&ap, data), sizeof(ss));
    550   1.1  jonathan 	    }
    551   1.8  jonathan 	case _IOW('t', 118, int):
    552  1.33  christos 		SCARG(&ap, com) = TIOCSPGRP;
    553   1.1  jonathan 		break;
    554   1.8  jonathan 	case _IOR('t', 119, int):
    555  1.33  christos 		SCARG(&ap, com) = TIOCGPGRP;
    556   1.1  jonathan 		break;
    557   1.8  jonathan 
    558  1.26     perry 	/* Emulate termio or termios tcget() */
    559   1.1  jonathan 	case ULTRIX_TCGETA:
    560  1.26     perry 	case ULTRIX_TCGETS:
    561   1.1  jonathan 	    {
    562   1.1  jonathan 		struct termios bts;
    563   1.1  jonathan 		struct ultrix_termios sts;
    564   1.1  jonathan 		struct ultrix_termio st;
    565  1.26     perry 
    566  1.38   msaitoh 		error = ultrix_do_ioctl(SCARG(&ap, fd), TIOCGETA, &bts, l);
    567  1.38   msaitoh 		if (error != 0)
    568   1.1  jonathan 			return error;
    569  1.26     perry 
    570   1.1  jonathan 		btios2stios (&bts, &sts);
    571  1.33  christos 		if (SCARG(&ap, com) == ULTRIX_TCGETA) {
    572   1.1  jonathan 			stios2stio (&sts, &st);
    573  1.38   msaitoh 			return copyout(&st, SCARG(&ap, data), sizeof(st));
    574   1.1  jonathan 		} else
    575  1.38   msaitoh 			return copyout(&sts, SCARG(&ap, data), sizeof(sts));
    576   1.1  jonathan 		/*NOTREACHED*/
    577   1.1  jonathan 	    }
    578   1.2  jonathan 	/* Emulate termio tcset() */
    579   1.1  jonathan 	case ULTRIX_TCSETA:
    580   1.1  jonathan 	case ULTRIX_TCSETAW:
    581   1.1  jonathan 	case ULTRIX_TCSETAF:
    582   1.1  jonathan 	    {
    583   1.1  jonathan 		struct termios bts;
    584   1.1  jonathan 		struct ultrix_termios sts;
    585   1.1  jonathan 		struct ultrix_termio st;
    586   1.1  jonathan 		int result;
    587  1.26     perry 
    588  1.38   msaitoh 		if ((error = copyin(SCARG(&ap, data), &st, sizeof(st))) != 0)
    589   1.1  jonathan 			return error;
    590   1.1  jonathan 
    591   1.1  jonathan 		/* get full BSD termios so we don't lose information */
    592  1.38   msaitoh 		error = ultrix_do_ioctl(SCARG(&ap, fd), TIOCGETA, &bts, l);
    593  1.38   msaitoh 		if (error != 0)
    594   1.1  jonathan 			return error;
    595   1.1  jonathan 
    596   1.1  jonathan 		/*
    597   1.1  jonathan 		 * convert to sun termios, copy in information from
    598   1.1  jonathan 		 * termio, and convert back, then set new values.
    599   1.1  jonathan 		 */
    600   1.1  jonathan 		btios2stios(&bts, &sts);
    601   1.1  jonathan 		stio2stios(&st, &sts);
    602   1.1  jonathan 		stios2btios(&sts, &bts);
    603   1.1  jonathan 
    604   1.1  jonathan 		/*
    605   1.1  jonathan 		 * map ioctl code: ultrix tcsets are numbered in reverse order
    606   1.1  jonathan 		 */
    607   1.1  jonathan #ifdef notyet
    608  1.38   msaitoh 		return ultrix_do_ioctl(SCARG(&ap, fd),
    609  1.38   msaitoh 		    ULTRIX_TCSETA - SCARG(&ap, com) + TIOCSETA, &bts, l);
    610   1.1  jonathan #else
    611  1.38   msaitoh 		result = ultrix_do_ioctl(SCARG(&ap, fd),
    612  1.38   msaitoh 		    ULTRIX_TCSETA - SCARG(&ap, com) + TIOCSETA, &bts, l);
    613   1.7  christos 		printf("ultrix TCSETA %lx returns %d\n",
    614  1.33  christos 		    ULTRIX_TCSETA - SCARG(&ap, com), result);
    615   1.1  jonathan 		return result;
    616   1.1  jonathan #endif
    617   1.1  jonathan 
    618   1.1  jonathan 	    }
    619   1.2  jonathan 	/* Emulate termios tcset() */
    620   1.1  jonathan 	case ULTRIX_TCSETS:
    621   1.1  jonathan 	case ULTRIX_TCSETSW:
    622   1.1  jonathan 	case ULTRIX_TCSETSF:
    623   1.1  jonathan 	    {
    624   1.1  jonathan 		struct termios bts;
    625   1.1  jonathan 		struct ultrix_termios sts;
    626   1.1  jonathan 
    627  1.38   msaitoh 		error = copyin(SCARG(&ap, data), &sts, sizeof(sts));
    628  1.38   msaitoh 		if (error != 0)
    629   1.1  jonathan 			return error;
    630   1.1  jonathan 		stios2btios (&sts, &bts);
    631  1.38   msaitoh 		return ultrix_do_ioctl(SCARG(&ap, fd),
    632  1.38   msaitoh 		    ULTRIX_TCSETS - SCARG(&ap, com) + TIOCSETA, &bts, l);
    633   1.1  jonathan 	    }
    634   1.1  jonathan /*
    635   1.1  jonathan  * Pseudo-tty ioctl translations.
    636   1.1  jonathan  */
    637   1.1  jonathan 	case _IOW('t', 32, int): {	/* TIOCTCNTL */
    638  1.27  drochner 		int on;
    639   1.1  jonathan 
    640  1.38   msaitoh 		error = copyin(SCARG(&ap, data), &on, sizeof(on));
    641   1.3  jonathan 		if (error != 0)
    642   1.1  jonathan 			return error;
    643  1.34       dsl 		return ultrix_do_ioctl(SCARG(&ap, fd), TIOCUCNTL, &on, l);
    644   1.1  jonathan 	}
    645   1.1  jonathan 	case _IOW('t', 33, int): {	/* TIOCSIGNAL */
    646  1.27  drochner 		int sig;
    647   1.1  jonathan 
    648  1.38   msaitoh 		error = copyin(SCARG(&ap, data), &sig, sizeof(sig));
    649   1.3  jonathan 		if (error != 0)
    650   1.1  jonathan 			return error;
    651  1.34       dsl 		return ultrix_do_ioctl(SCARG(&ap, fd), TIOCSIG, &sig, l);
    652   1.1  jonathan 	}
    653   1.8  jonathan 
    654   1.1  jonathan /*
    655   1.1  jonathan  * Socket ioctl translations.
    656   1.1  jonathan  */
    657   1.3  jonathan #define IN_TYPE(a, type_t) { \
    658   1.3  jonathan 	type_t localbuf; \
    659  1.33  christos 	if ((error = copyin(SCARG(&ap, data), \
    660  1.38   msaitoh 				&localbuf, sizeof(type_t))) != 0) \
    661   1.3  jonathan 		return error; \
    662  1.34       dsl 	return ultrix_do_ioctl(SCARG(&ap, fd), a, &localbuf, l); \
    663   1.3  jonathan }
    664   1.3  jonathan 
    665   1.3  jonathan #define INOUT_TYPE(a, type_t) { \
    666   1.3  jonathan 	type_t localbuf; \
    667  1.33  christos 	if ((error = copyin(SCARG(&ap, data), &localbuf,	\
    668  1.38   msaitoh 			     sizeof(type_t))) != 0) \
    669   1.3  jonathan 		return error; \
    670  1.34       dsl 	if ((error = ultrix_do_ioctl(SCARG(&ap, fd), a, &localbuf, l)) != 0) \
    671   1.3  jonathan 		return error; \
    672  1.38   msaitoh 	return copyout(&localbuf, SCARG(&ap, data), sizeof(type_t)); \
    673   1.3  jonathan }
    674   1.3  jonathan 
    675   1.3  jonathan 
    676   1.1  jonathan #define IFREQ_IN(a) { \
    677  1.30  christos 	struct oifreq ifreq; \
    678  1.38   msaitoh 	if ((error = copyin(SCARG(&ap, data), &ifreq, sizeof(ifreq))) != 0) \
    679   1.1  jonathan 		return error; \
    680  1.34       dsl 	return ultrix_do_ioctl(SCARG(&ap, fd), a, &ifreq, l); \
    681   1.1  jonathan }
    682   1.3  jonathan 
    683   1.1  jonathan #define IFREQ_INOUT(a) { \
    684  1.30  christos 	struct oifreq ifreq; \
    685  1.38   msaitoh 	if ((error = copyin(SCARG(&ap, data), &ifreq, sizeof(ifreq))) != 0) \
    686   1.1  jonathan 		return error; \
    687  1.34       dsl 	if ((error = ultrix_do_ioctl(SCARG(&ap, fd), a, &ifreq, l)) != 0) \
    688   1.1  jonathan 		return error; \
    689  1.38   msaitoh 	return copyout(&ifreq, SCARG(&ap, data), sizeof(ifreq)); \
    690   1.1  jonathan }
    691   1.1  jonathan 
    692  1.30  christos 	case _IOW('i', 12, struct oifreq):
    693   1.1  jonathan 		/* SIOCSIFADDR */
    694   1.1  jonathan 		break;
    695   1.1  jonathan 
    696  1.30  christos 	case _IOWR('i', 13, struct oifreq):
    697  1.31        he 		IFREQ_INOUT(OOSIOCGIFADDR);
    698   1.1  jonathan 
    699  1.30  christos 	case _IOW('i', 14, struct oifreq):
    700   1.1  jonathan 		/* SIOCSIFDSTADDR */
    701   1.1  jonathan 		break;
    702   1.1  jonathan 
    703  1.30  christos 	case _IOWR('i', 15, struct oifreq):
    704  1.31        he 		IFREQ_INOUT(OOSIOCGIFDSTADDR);
    705   1.1  jonathan 
    706  1.30  christos 	case _IOW('i', 16, struct oifreq):
    707   1.1  jonathan 		/* SIOCSIFFLAGS */
    708   1.1  jonathan 		break;
    709   1.1  jonathan 
    710  1.30  christos 	case _IOWR('i', 17, struct oifreq):
    711   1.1  jonathan 		/* SIOCGIFFLAGS */
    712   1.1  jonathan 		break;
    713   1.1  jonathan 
    714  1.30  christos 	case _IOWR('i', 18, struct oifreq):
    715   1.1  jonathan 		IFREQ_INOUT(SIOCGIFBRDADDR);
    716   1.1  jonathan 
    717  1.30  christos 	case _IOWR('i', 19, struct oifreq):
    718   1.8  jonathan 		IFREQ_INOUT(SIOCSIFBRDADDR);
    719   1.1  jonathan 
    720  1.21  christos 	case _IOWR('i', 20, struct ifconf):	/* SIOCGIFCONF */
    721  1.21  christos 	    {
    722  1.27  drochner 		struct ifconf ifconfarg;
    723  1.21  christos 
    724  1.21  christos 		/*
    725  1.21  christos 		 * XXX: two more problems
    726  1.38   msaitoh 		 * 1. Our sockaddr's are variable length, not always
    727  1.38   msaitoh 		 *    sizeof(sockaddr)
    728  1.38   msaitoh 		 * 2. This returns a name per protocol, ie. it returns two
    729  1.38   msaitoh 		 *    "lo0"'s
    730  1.21  christos 		 */
    731  1.38   msaitoh 		error = copyin(SCARG(&ap, data), &ifconfarg,
    732  1.38   msaitoh 		    sizeof(ifconfarg));
    733  1.21  christos 		if (error)
    734  1.21  christos 			return error;
    735  1.38   msaitoh 
    736  1.38   msaitoh 		error = ultrix_do_ioctl(SCARG(&ap, fd), OSIOCGIFCONF,
    737  1.38   msaitoh 		    &ifconfarg, l);
    738  1.21  christos 		if (error)
    739  1.21  christos 			return error;
    740  1.38   msaitoh 
    741  1.38   msaitoh 		return copyout(&ifconfarg, SCARG(&ap, data),
    742  1.38   msaitoh 		    sizeof(ifconfarg));
    743  1.21  christos 	    }
    744  1.21  christos 
    745  1.21  christos 
    746  1.30  christos 	case _IOWR('i', 21, struct oifreq):
    747  1.31        he 		IFREQ_INOUT(OOSIOCGIFNETMASK);
    748   1.1  jonathan 
    749  1.30  christos 	case _IOW('i', 22, struct oifreq):
    750   1.1  jonathan 		IFREQ_IN(SIOCSIFNETMASK);
    751   1.1  jonathan 
    752  1.30  christos 	/* 23: _IOWR('i', 23, struct oifreq):  Ultrix SIOCSPHYADDR */
    753  1.30  christos 	/* 24: _IOWR('i', 24, struct oifreq):  Ultrix SIOCSADDMULTI */
    754  1.30  christos 	/* 25: _IOWR('i', 25, struct oifreq):  Ultrix SIOCSDELMULTI */
    755  1.30  christos 
    756  1.30  christos 	case _IOW('i',  26, struct oifreq):	/* SIOCSIFRDCTRS? */
    757  1.30  christos 	case _IOWR('i', 27, struct oifreq):	/* SIOCGIFZCTRS? */
    758  1.30  christos 	case _IOWR('i', 28, struct oifreq):	/* read physaddr ? */
    759  1.21  christos 		return EOPNOTSUPP;
    760   1.1  jonathan 
    761   1.1  jonathan 
    762   1.1  jonathan 	case _IOW('i', 30, struct arpreq):
    763   1.1  jonathan 		/* SIOCSARP */
    764   1.1  jonathan 		break;
    765   1.1  jonathan 
    766   1.1  jonathan 	case _IOWR('i', 31, struct arpreq):
    767   1.1  jonathan 		/* SIOCGARP */
    768   1.1  jonathan 		break;
    769   1.1  jonathan 
    770   1.1  jonathan 	case _IOW('i', 32, struct arpreq):
    771   1.1  jonathan 		/* SIOCDARP */
    772   1.1  jonathan 		break;
    773   1.1  jonathan 
    774  1.30  christos 	case _IOW('i', 40, struct oifreq):	/* SIOCARPREQ */
    775  1.21  christos 		return EOPNOTSUPP;
    776  1.21  christos 
    777  1.30  christos 	case _IOWR('i', 41, struct oifreq):
    778  1.21  christos 		IFREQ_INOUT(SIOCGIFMETRIC);
    779  1.21  christos 
    780  1.30  christos 	case _IOWR('i', 42, struct oifreq):
    781  1.21  christos 		IFREQ_IN(SIOCSIFMETRIC);
    782   1.8  jonathan 
    783  1.30  christos 	case _IOW('i', 44, struct oifreq):	/* SIOCSETSYNC */
    784  1.30  christos 	case _IOWR('i', 45, struct oifreq):	/* SIOCGETSYNC */
    785  1.30  christos 	case _IOWR('i', 46, struct oifreq):	/* SIOCSDSTATS */
    786  1.30  christos 	case _IOWR('i', 47, struct oifreq):	/* SIOCSESTATS */
    787   1.1  jonathan 	case _IOW('i', 48, int):		/* SIOCSPROMISC */
    788   1.8  jonathan 		return EOPNOTSUPP;
    789   1.8  jonathan 
    790   1.8  jonathan 	/* emulate for vat, vic tools */
    791  1.30  christos 	case _IOW('i', 49, struct oifreq):	/* SIOCADDMULTI */
    792  1.30  christos 	case _IOW('i', 50, struct oifreq):	/* SIOCDELMULTI */
    793   1.1  jonathan 		return EOPNOTSUPP;
    794   1.1  jonathan 
    795   1.1  jonathan 	}
    796  1.33  christos 	return sys_ioctl(l, &ap, retval);
    797   1.1  jonathan }
    798