Home | History | Annotate | Line # | Download | only in ultrix
ultrix_ioctl.c revision 1.33
      1  1.33  christos /*	$NetBSD: ultrix_ioctl.c,v 1.33 2007/12/27 17:18:11 christos 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.33  christos __KERNEL_RCSID(0, "$NetBSD: ultrix_ioctl.c,v 1.33 2007/12/27 17:18:11 christos 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.26     perry static const u_long 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.14  augustss 	u_long l, r;
    147   1.1  jonathan 
    148   1.1  jonathan 	l = st->c_iflag;
    149   1.1  jonathan 	r = 	((l & 0x00000001) ? IGNBRK	: 0);
    150   1.1  jonathan 	r |=	((l & 0x00000002) ? BRKINT	: 0);
    151   1.1  jonathan 	r |=	((l & 0x00000004) ? IGNPAR	: 0);
    152   1.1  jonathan 	r |=	((l & 0x00000008) ? PARMRK	: 0);
    153   1.1  jonathan 	r |=	((l & 0x00000010) ? INPCK	: 0);
    154   1.1  jonathan 	r |=	((l & 0x00000020) ? ISTRIP	: 0);
    155   1.1  jonathan 	r |= 	((l & 0x00000040) ? INLCR	: 0);
    156   1.1  jonathan 	r |=	((l & 0x00000080) ? IGNCR	: 0);
    157   1.1  jonathan 	r |=	((l & 0x00000100) ? ICRNL	: 0);
    158   1.1  jonathan 	/*	((l & 0x00000200) ? IUCLC	: 0) */
    159   1.1  jonathan 	r |=	((l & 0x00000400) ? IXON	: 0);
    160   1.1  jonathan 	r |=	((l & 0x00000800) ? IXANY	: 0);
    161   1.1  jonathan 	r |=	((l & 0x00001000) ? IXOFF	: 0);
    162   1.1  jonathan 	r |=	((l & 0x00002000) ? IMAXBEL	: 0);
    163   1.1  jonathan 	bt->c_iflag = r;
    164   1.1  jonathan 
    165   1.1  jonathan 	l = st->c_oflag;
    166   1.1  jonathan 	r = 	((l & 0x00000001) ? OPOST	: 0);
    167   1.1  jonathan 	/*	((l & 0x00000002) ? OLCUC	: 0) */
    168   1.1  jonathan 	r |=	((l & 0x00000004) ? ONLCR	: 0);
    169   1.1  jonathan 	/*	((l & 0x00000008) ? OCRNL	: 0) */
    170   1.1  jonathan 	/*	((l & 0x00000010) ? ONOCR	: 0) */
    171   1.1  jonathan 	/*	((l & 0x00000020) ? ONLRET	: 0) */
    172   1.1  jonathan 	/*	((l & 0x00000040) ? OFILL	: 0) */
    173   1.1  jonathan 	/*	((l & 0x00000080) ? OFDEL	: 0) */
    174   1.1  jonathan 	/*	((l & 0x00000100) ? NLDLY	: 0) */
    175   1.1  jonathan 	/*	((l & 0x00000100) ? NL1		: 0) */
    176   1.1  jonathan 	/*	((l & 0x00000600) ? CRDLY	: 0) */
    177   1.1  jonathan 	/*	((l & 0x00000200) ? CR1		: 0) */
    178   1.1  jonathan 	/*	((l & 0x00000400) ? CR2		: 0) */
    179   1.1  jonathan 	/*	((l & 0x00000600) ? CR3		: 0) */
    180   1.1  jonathan 	/*	((l & 0x00001800) ? TABDLY	: 0) */
    181   1.1  jonathan 	/*	((l & 0x00000800) ? TAB1	: 0) */
    182   1.1  jonathan 	/*	((l & 0x00001000) ? TAB2	: 0) */
    183   1.1  jonathan 	r |=	((l & 0x00001800) ? OXTABS	: 0);
    184   1.1  jonathan 	/*	((l & 0x00002000) ? BSDLY	: 0) */
    185   1.1  jonathan 	/*	((l & 0x00002000) ? BS1		: 0) */
    186   1.1  jonathan 	/*	((l & 0x00004000) ? VTDLY	: 0) */
    187   1.1  jonathan 	/*	((l & 0x00004000) ? VT1		: 0) */
    188   1.1  jonathan 	/*	((l & 0x00008000) ? FFDLY	: 0) */
    189   1.1  jonathan 	/*	((l & 0x00008000) ? FF1		: 0) */
    190   1.1  jonathan 	/*	((l & 0x00010000) ? PAGEOUT	: 0) */
    191   1.1  jonathan 	/*	((l & 0x00020000) ? WRAP	: 0) */
    192   1.1  jonathan 	bt->c_oflag = r;
    193   1.1  jonathan 
    194   1.1  jonathan 	l = st->c_cflag;
    195   1.1  jonathan 	switch (l & 0x00000030) {
    196   1.1  jonathan 	case 0:
    197   1.1  jonathan 		r = CS5;
    198   1.1  jonathan 		break;
    199   1.1  jonathan 	case 0x00000010:
    200   1.1  jonathan 		r = CS6;
    201   1.1  jonathan 		break;
    202   1.1  jonathan 	case 0x00000020:
    203   1.1  jonathan 		r = CS7;
    204   1.1  jonathan 		break;
    205   1.1  jonathan 	case 0x00000030:
    206   1.1  jonathan 		r = CS8;
    207   1.1  jonathan 		break;
    208  1.26     perry 	}
    209   1.1  jonathan 	r |=	((l & 0x00000040) ? CSTOPB	: 0);
    210   1.1  jonathan 	r |=	((l & 0x00000080) ? CREAD	: 0);
    211   1.1  jonathan 	r |= 	((l & 0x00000100) ? PARENB	: 0);
    212   1.1  jonathan 	r |=	((l & 0x00000200) ? PARODD	: 0);
    213   1.1  jonathan 	r |=	((l & 0x00000400) ? HUPCL	: 0);
    214   1.1  jonathan 	r |=	((l & 0x00000800) ? CLOCAL	: 0);
    215   1.1  jonathan 	/*	((l & 0x00001000) ? LOBLK	: 0) */
    216   1.1  jonathan 	r |=	((l & 0x80000000) ? (CRTS_IFLOW|CCTS_OFLOW) : 0);
    217   1.1  jonathan 	bt->c_cflag = r;
    218   1.1  jonathan 
    219   1.1  jonathan 	bt->c_ispeed = bt->c_ospeed = s2btab[l & 0x0000000f];
    220   1.1  jonathan 
    221   1.1  jonathan 	l = st->c_lflag;
    222   1.1  jonathan 	r = 	((l & 0x00000001) ? ISIG	: 0);
    223   1.1  jonathan 	r |=	((l & 0x00000002) ? ICANON	: 0);
    224   1.1  jonathan 	/*	((l & 0x00000004) ? XCASE	: 0) */
    225   1.1  jonathan 	r |=	((l & 0x00000008) ? ECHO	: 0);
    226   1.1  jonathan 	r |=	((l & 0x00000010) ? ECHOE	: 0);
    227   1.1  jonathan 	r |=	((l & 0x00000020) ? ECHOK	: 0);
    228   1.1  jonathan 	r |=	((l & 0x00000040) ? ECHONL	: 0);
    229   1.1  jonathan 	r |= 	((l & 0x00000080) ? NOFLSH	: 0);
    230   1.1  jonathan 	r |=	((l & 0x00000100) ? TOSTOP	: 0);
    231   1.1  jonathan 	r |=	((l & 0x00000200) ? ECHOCTL	: 0);
    232   1.1  jonathan 	r |=	((l & 0x00000400) ? ECHOPRT	: 0);
    233   1.1  jonathan 	r |=	((l & 0x00000800) ? ECHOKE	: 0);
    234   1.1  jonathan 	/*	((l & 0x00001000) ? DEFECHO	: 0) */
    235   1.1  jonathan 	r |=	((l & 0x00002000) ? FLUSHO	: 0);
    236   1.1  jonathan 	r |=	((l & 0x00004000) ? PENDIN	: 0);
    237   1.1  jonathan 	bt->c_lflag = r;
    238   1.1  jonathan 
    239   1.2  jonathan 	bt->c_cc[VINTR]    = EMUL_TO_NATIVE_CC(st->c_cc[0]);
    240   1.2  jonathan 	bt->c_cc[VQUIT]    = EMUL_TO_NATIVE_CC(st->c_cc[1]);
    241   1.2  jonathan 	bt->c_cc[VERASE]   = EMUL_TO_NATIVE_CC(st->c_cc[2]);
    242   1.2  jonathan 	bt->c_cc[VKILL]    = EMUL_TO_NATIVE_CC(st->c_cc[3]);
    243   1.2  jonathan 	bt->c_cc[VEOF]     = EMUL_TO_NATIVE_CC(st->c_cc[4]);
    244   1.2  jonathan 	bt->c_cc[VEOL]     = EMUL_TO_NATIVE_CC(st->c_cc[5]);
    245   1.2  jonathan 	bt->c_cc[VEOL2]    = EMUL_TO_NATIVE_CC(st->c_cc[6]);
    246   1.2  jonathan 	/* not present on NetBSD */
    247   1.2  jonathan 	/* bt->c_cc[VSWTCH]   = EMUL_TO_NATIVE_CC(st->c_cc[7]); */
    248   1.2  jonathan 	bt->c_cc[VSTART]   = EMUL_TO_NATIVE_CC(st->c_cc[10]);
    249   1.2  jonathan 	bt->c_cc[VSTOP]    = EMUL_TO_NATIVE_CC(st->c_cc[11]);
    250   1.4  jonathan 	bt->c_cc[VSUSP]    = EMUL_TO_NATIVE_CC(st->c_cc[12]);
    251   1.4  jonathan 	bt->c_cc[VDSUSP]   = EMUL_TO_NATIVE_CC(st->c_cc[13]);
    252   1.2  jonathan 	bt->c_cc[VREPRINT] = EMUL_TO_NATIVE_CC(st->c_cc[14]);
    253   1.2  jonathan 	bt->c_cc[VDISCARD] = EMUL_TO_NATIVE_CC(st->c_cc[15]);
    254   1.2  jonathan 	bt->c_cc[VWERASE]  = EMUL_TO_NATIVE_CC(st->c_cc[16]);
    255   1.2  jonathan 	bt->c_cc[VLNEXT]   = EMUL_TO_NATIVE_CC(st->c_cc[17]);
    256   1.2  jonathan 	bt->c_cc[VSTATUS]  = EMUL_TO_NATIVE_CC(st->c_cc[18]);
    257   1.2  jonathan 
    258   1.2  jonathan #ifdef COMPAT_ULTRIX
    259   1.2  jonathan 	/* Ultrix termio/termios has real vmin/vtime */
    260   1.2  jonathan 	bt->c_cc[VMIN]	   = EMUL_TO_NATIVE_CC(st->c_cc[8]);
    261   1.2  jonathan 	bt->c_cc[VTIME]	   = EMUL_TO_NATIVE_CC(st->c_cc[9]);
    262   1.2  jonathan #else
    263   1.1  jonathan 	/* if `raw mode', create native VMIN/VTIME from SunOS VEOF/VEOL */
    264   1.1  jonathan 	bt->c_cc[VMIN]	   = (bt->c_lflag & ICANON) ? 1 : bt->c_cc[VEOF];
    265   1.1  jonathan 	bt->c_cc[VTIME]	   = (bt->c_lflag & ICANON) ? 1 : bt->c_cc[VEOL];
    266   1.2  jonathan #endif
    267   1.2  jonathan 
    268   1.1  jonathan }
    269   1.1  jonathan 
    270   1.2  jonathan /*
    271   1.2  jonathan  * Convert bsd termios to "sunos" emulated termios
    272   1.2  jonathan  */
    273   1.1  jonathan static void
    274  1.24    simonb btios2stios(struct termios *bt, struct emul_termios *st)
    275   1.1  jonathan {
    276  1.14  augustss 	u_long l, r;
    277  1.33  christos 	int speed;
    278   1.1  jonathan 
    279   1.1  jonathan 	l = bt->c_iflag;
    280   1.1  jonathan 	r = 	((l &  IGNBRK) ? 0x00000001	: 0);
    281   1.1  jonathan 	r |=	((l &  BRKINT) ? 0x00000002	: 0);
    282   1.1  jonathan 	r |=	((l &  IGNPAR) ? 0x00000004	: 0);
    283   1.1  jonathan 	r |=	((l &  PARMRK) ? 0x00000008	: 0);
    284   1.1  jonathan 	r |=	((l &   INPCK) ? 0x00000010	: 0);
    285   1.1  jonathan 	r |=	((l &  ISTRIP) ? 0x00000020	: 0);
    286   1.1  jonathan 	r |=	((l &   INLCR) ? 0x00000040	: 0);
    287   1.1  jonathan 	r |=	((l &   IGNCR) ? 0x00000080	: 0);
    288   1.1  jonathan 	r |=	((l &   ICRNL) ? 0x00000100	: 0);
    289   1.1  jonathan 	/*	((l &   IUCLC) ? 0x00000200	: 0) */
    290   1.1  jonathan 	r |=	((l &    IXON) ? 0x00000400	: 0);
    291   1.1  jonathan 	r |=	((l &   IXANY) ? 0x00000800	: 0);
    292   1.1  jonathan 	r |=	((l &   IXOFF) ? 0x00001000	: 0);
    293   1.1  jonathan 	r |=	((l & IMAXBEL) ? 0x00002000	: 0);
    294   1.1  jonathan 	st->c_iflag = r;
    295   1.1  jonathan 
    296   1.1  jonathan 	l = bt->c_oflag;
    297   1.1  jonathan 	r =	((l &   OPOST) ? 0x00000001	: 0);
    298   1.1  jonathan 	/*	((l &   OLCUC) ? 0x00000002	: 0) */
    299   1.1  jonathan 	r |=	((l &   ONLCR) ? 0x00000004	: 0);
    300   1.1  jonathan 	/*	((l &   OCRNL) ? 0x00000008	: 0) */
    301   1.1  jonathan 	/*	((l &   ONOCR) ? 0x00000010	: 0) */
    302   1.1  jonathan 	/*	((l &  ONLRET) ? 0x00000020	: 0) */
    303   1.1  jonathan 	/*	((l &   OFILL) ? 0x00000040	: 0) */
    304   1.1  jonathan 	/*	((l &   OFDEL) ? 0x00000080	: 0) */
    305   1.1  jonathan 	/*	((l &   NLDLY) ? 0x00000100	: 0) */
    306   1.1  jonathan 	/*	((l &     NL1) ? 0x00000100	: 0) */
    307   1.1  jonathan 	/*	((l &   CRDLY) ? 0x00000600	: 0) */
    308   1.1  jonathan 	/*	((l &     CR1) ? 0x00000200	: 0) */
    309   1.1  jonathan 	/*	((l &     CR2) ? 0x00000400	: 0) */
    310   1.1  jonathan 	/*	((l &     CR3) ? 0x00000600	: 0) */
    311   1.1  jonathan 	/*	((l &  TABDLY) ? 0x00001800	: 0) */
    312   1.1  jonathan 	/*	((l &    TAB1) ? 0x00000800	: 0) */
    313   1.1  jonathan 	/*	((l &    TAB2) ? 0x00001000	: 0) */
    314   1.1  jonathan 	r |=	((l &  OXTABS) ? 0x00001800	: 0);
    315   1.1  jonathan 	/*	((l &   BSDLY) ? 0x00002000	: 0) */
    316   1.1  jonathan 	/*	((l &     BS1) ? 0x00002000	: 0) */
    317   1.1  jonathan 	/*	((l &   VTDLY) ? 0x00004000	: 0) */
    318   1.1  jonathan 	/*	((l &     VT1) ? 0x00004000	: 0) */
    319   1.1  jonathan 	/*	((l &   FFDLY) ? 0x00008000	: 0) */
    320   1.1  jonathan 	/*	((l &     FF1) ? 0x00008000	: 0) */
    321   1.1  jonathan 	/*	((l & PAGEOUT) ? 0x00010000	: 0) */
    322   1.1  jonathan 	/*	((l &    WRAP) ? 0x00020000	: 0) */
    323   1.1  jonathan 	st->c_oflag = r;
    324   1.1  jonathan 
    325   1.1  jonathan 	l = bt->c_cflag;
    326   1.1  jonathan 	switch (l & CSIZE) {
    327   1.1  jonathan 	case CS5:
    328   1.1  jonathan 		r = 0;
    329   1.1  jonathan 		break;
    330   1.1  jonathan 	case CS6:
    331   1.1  jonathan 		r = 0x00000010;
    332   1.1  jonathan 		break;
    333   1.1  jonathan 	case CS7:
    334   1.1  jonathan 		r = 0x00000020;
    335   1.1  jonathan 		break;
    336   1.1  jonathan 	case CS8:
    337   1.1  jonathan 		r = 0x00000030;
    338   1.1  jonathan 		break;
    339   1.1  jonathan 	}
    340   1.1  jonathan 	r |=	((l &  CSTOPB) ? 0x00000040	: 0);
    341   1.1  jonathan 	r |=	((l &   CREAD) ? 0x00000080	: 0);
    342   1.1  jonathan 	r |=	((l &  PARENB) ? 0x00000100	: 0);
    343   1.1  jonathan 	r |=	((l &  PARODD) ? 0x00000200	: 0);
    344   1.1  jonathan 	r |=	((l &   HUPCL) ? 0x00000400	: 0);
    345   1.1  jonathan 	r |=	((l &  CLOCAL) ? 0x00000800	: 0);
    346   1.1  jonathan 	/*	((l &   LOBLK) ? 0x00001000	: 0) */
    347   1.1  jonathan 	r |=	((l & (CRTS_IFLOW|CCTS_OFLOW)) ? 0x80000000 : 0);
    348   1.1  jonathan 	st->c_cflag = r;
    349   1.1  jonathan 
    350   1.1  jonathan 	l = bt->c_lflag;
    351   1.1  jonathan 	r =	((l &    ISIG) ? 0x00000001	: 0);
    352   1.1  jonathan 	r |=	((l &  ICANON) ? 0x00000002	: 0);
    353   1.1  jonathan 	/*	((l &   XCASE) ? 0x00000004	: 0) */
    354   1.1  jonathan 	r |=	((l &    ECHO) ? 0x00000008	: 0);
    355   1.1  jonathan 	r |=	((l &   ECHOE) ? 0x00000010	: 0);
    356   1.1  jonathan 	r |=	((l &   ECHOK) ? 0x00000020	: 0);
    357   1.1  jonathan 	r |=	((l &  ECHONL) ? 0x00000040	: 0);
    358   1.1  jonathan 	r |=	((l &  NOFLSH) ? 0x00000080	: 0);
    359   1.1  jonathan 	r |=	((l &  TOSTOP) ? 0x00000100	: 0);
    360   1.1  jonathan 	r |=	((l & ECHOCTL) ? 0x00000200	: 0);
    361   1.1  jonathan 	r |=	((l & ECHOPRT) ? 0x00000400	: 0);
    362   1.1  jonathan 	r |=	((l &  ECHOKE) ? 0x00000800	: 0);
    363   1.1  jonathan 	/*	((l & DEFECHO) ? 0x00001000	: 0) */
    364   1.1  jonathan 	r |=	((l &  FLUSHO) ? 0x00002000	: 0);
    365   1.1  jonathan 	r |=	((l &  PENDIN) ? 0x00004000	: 0);
    366   1.1  jonathan 	st->c_lflag = r;
    367   1.1  jonathan 
    368  1.33  christos 	speed = ttspeedtab(bt->c_ospeed, sptab);
    369  1.33  christos 	if (speed != -1)
    370  1.33  christos 	    st->c_cflag |= speed;
    371   1.1  jonathan 
    372   1.2  jonathan 	st->c_cc[0] = NATIVE_TO_EMUL_CC(bt->c_cc[VINTR]);
    373   1.2  jonathan 	st->c_cc[1] = NATIVE_TO_EMUL_CC(bt->c_cc[VQUIT]);
    374   1.2  jonathan 	st->c_cc[2] = NATIVE_TO_EMUL_CC(bt->c_cc[VERASE]);
    375   1.2  jonathan 	st->c_cc[3] = NATIVE_TO_EMUL_CC(bt->c_cc[VKILL]);
    376   1.2  jonathan 	st->c_cc[4] = NATIVE_TO_EMUL_CC(bt->c_cc[VEOF]);
    377   1.2  jonathan 	st->c_cc[5] = NATIVE_TO_EMUL_CC(bt->c_cc[VEOL]);
    378   1.2  jonathan 	st->c_cc[6] = NATIVE_TO_EMUL_CC(bt->c_cc[VEOL2]);
    379   1.9  jonathan 
    380   1.9  jonathan 	/* XXX ultrix has a VSWTCH.  NetBSD does not. */
    381   1.9  jonathan #ifdef notdef
    382   1.2  jonathan 	st->c_cc[7] = NATIVE_TO_EMUL_CC(bt->c_cc[VSWTCH]);
    383   1.2  jonathan #else
    384   1.1  jonathan 	st->c_cc[7] = 0;
    385   1.2  jonathan #endif
    386   1.2  jonathan 	st->c_cc[10] = NATIVE_TO_EMUL_CC(bt->c_cc[VSTART]);
    387   1.2  jonathan 	st->c_cc[11] = NATIVE_TO_EMUL_CC(bt->c_cc[VSTOP]);
    388   1.2  jonathan 	st->c_cc[12]= NATIVE_TO_EMUL_CC(bt->c_cc[VSUSP]);
    389   1.2  jonathan 	st->c_cc[13]= NATIVE_TO_EMUL_CC(bt->c_cc[VDSUSP]);
    390   1.2  jonathan 	st->c_cc[14]= NATIVE_TO_EMUL_CC(bt->c_cc[VREPRINT]);
    391   1.2  jonathan 	st->c_cc[15]= NATIVE_TO_EMUL_CC(bt->c_cc[VDISCARD]);
    392   1.2  jonathan 	st->c_cc[16]= NATIVE_TO_EMUL_CC(bt->c_cc[VWERASE]);
    393   1.2  jonathan 	st->c_cc[17]= NATIVE_TO_EMUL_CC(bt->c_cc[VLNEXT]);
    394   1.2  jonathan 	st->c_cc[18]= NATIVE_TO_EMUL_CC(bt->c_cc[VSTATUS]);
    395   1.2  jonathan 
    396   1.2  jonathan #ifdef COMPAT_ULTRIX
    397   1.2  jonathan 	st->c_cc[8]= NATIVE_TO_EMUL_CC(bt->c_cc[VMIN]);
    398   1.2  jonathan 	st->c_cc[9]= NATIVE_TO_EMUL_CC(bt->c_cc[VTIME]);
    399   1.2  jonathan #else
    400   1.1  jonathan 	if (!(bt->c_lflag & ICANON)) {
    401   1.1  jonathan 		/* SunOS stores VMIN/VTIME in VEOF/VEOL (if ICANON is off) */
    402   1.1  jonathan 		st->c_cc[4] = bt->c_cc[VMIN];
    403   1.1  jonathan 		st->c_cc[5] = bt->c_cc[VTIME];
    404   1.1  jonathan 	}
    405   1.2  jonathan #endif
    406   1.1  jonathan 
    407   1.2  jonathan #ifdef COMPAT_SUNOS
    408   1.2  jonathan 	st->c_line = 0;	/* 4.3bsd "old" line discipline */
    409   1.2  jonathan #else
    410   1.9  jonathan 	st->c_line = 2;	/* 4.3bsd "new" line discipline, Ultrix default. */
    411   1.2  jonathan #endif
    412   1.1  jonathan }
    413   1.1  jonathan 
    414   1.2  jonathan #define TERMIO_NCC 10	/* ultrix termio NCC is 10 */
    415   1.2  jonathan 
    416   1.2  jonathan /*
    417   1.2  jonathan  * Convert emulated struct termios to termio(?)
    418   1.2  jonathan  */
    419   1.1  jonathan static void
    420  1.24    simonb stios2stio(struct emul_termios *ts, struct emul_termio *t)
    421   1.1  jonathan {
    422   1.1  jonathan 	t->c_iflag = ts->c_iflag;
    423   1.1  jonathan 	t->c_oflag = ts->c_oflag;
    424   1.1  jonathan 	t->c_cflag = ts->c_cflag;
    425   1.1  jonathan 	t->c_lflag = ts->c_lflag;
    426   1.1  jonathan 	t->c_line  = ts->c_line;
    427  1.13     perry 	memcpy(t->c_cc, ts->c_cc, TERMIO_NCC);
    428   1.1  jonathan }
    429   1.1  jonathan 
    430   1.2  jonathan /*
    431   1.2  jonathan  * Convert the other way
    432   1.2  jonathan  */
    433   1.1  jonathan static void
    434  1.24    simonb stio2stios(struct emul_termio *t, struct emul_termios *ts)
    435   1.1  jonathan {
    436   1.1  jonathan 	ts->c_iflag = t->c_iflag;
    437   1.1  jonathan 	ts->c_oflag = t->c_oflag;
    438   1.1  jonathan 	ts->c_cflag = t->c_cflag;
    439   1.1  jonathan 	ts->c_lflag = t->c_lflag;
    440   1.1  jonathan 	ts->c_line  = t->c_line;
    441  1.13     perry 	memcpy(ts->c_cc, t->c_cc, TERMIO_NCC); /* don't touch the upper fields! */
    442   1.1  jonathan }
    443   1.1  jonathan 
    444   1.1  jonathan int
    445  1.32       dsl ultrix_sys_ioctl(struct lwp *l, const struct ultrix_sys_ioctl_args *uap, register_t *retval)
    446   1.1  jonathan {
    447  1.23      fvdl 	struct proc *p = l->l_proc;
    448  1.23      fvdl 	struct filedesc *fdp = p->p_fd;
    449  1.14  augustss 	struct file *fp;
    450  1.28  christos 	int (*ctl)(struct file *, u_long, void *, struct lwp *);
    451  1.33  christos 	struct sys_ioctl_args ap;
    452   1.1  jonathan 	int error;
    453   1.1  jonathan 
    454  1.17   thorpej 	if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
    455   1.1  jonathan 		return EBADF;
    456   1.1  jonathan 
    457   1.1  jonathan 	if ((fp->f_flag & (FREAD|FWRITE)) == 0)
    458   1.1  jonathan 		return EBADF;
    459   1.1  jonathan 
    460   1.1  jonathan 	ctl = fp->f_ops->fo_ioctl;
    461   1.1  jonathan 
    462  1.33  christos 	SCARG(&ap, fd) = SCARG(uap, fd);
    463  1.33  christos 	SCARG(&ap, data) = SCARG(uap, data);
    464  1.33  christos 	SCARG(&ap, com) = SCARG(uap, com);
    465  1.33  christos 	switch (SCARG(&ap, com)) {
    466   1.1  jonathan 	case _IOR('t', 0, int):
    467  1.33  christos 		SCARG(&ap, com) = TIOCGETD;
    468   1.1  jonathan 		break;
    469   1.1  jonathan 	case _IOW('t', 1, int):
    470   1.1  jonathan 	    {
    471   1.1  jonathan 		int disc;
    472   1.1  jonathan 
    473  1.33  christos 		if ((error = copyin(SCARG(&ap, data), &disc, sizeof disc)) != 0)
    474   1.1  jonathan 			return error;
    475   1.1  jonathan 
    476   1.1  jonathan 		/* map SunOS NTTYDISC into our termios discipline */
    477   1.1  jonathan 		if (disc == 2)
    478   1.1  jonathan 			disc = 0;
    479   1.1  jonathan 		/* all other disciplines are not supported by NetBSD */
    480   1.1  jonathan 		if (disc)
    481   1.1  jonathan 			return ENXIO;
    482   1.1  jonathan 
    483  1.28  christos 		return (*ctl)(fp, TIOCSETD, &disc, l);
    484   1.1  jonathan 	    }
    485   1.1  jonathan 	case _IOW('t', 101, int):	/* sun SUNOS_TIOCSSOFTCAR */
    486   1.1  jonathan 	    {
    487   1.1  jonathan 		int x;	/* unused */
    488   1.1  jonathan 
    489  1.33  christos 		return copyin(&x, SCARG(&ap, data), sizeof x);
    490   1.1  jonathan 	    }
    491   1.1  jonathan 	case _IOR('t', 100, int):	/* sun SUNOS_TIOCSSOFTCAR */
    492   1.1  jonathan 	    {
    493   1.1  jonathan 		int x = 0;
    494   1.1  jonathan 
    495  1.33  christos 		return copyout(&x, SCARG(&ap, data), sizeof x);
    496   1.1  jonathan 	    }
    497   1.1  jonathan 	case _IO('t', 36): 		/* sun TIOCCONS, no parameters */
    498   1.1  jonathan 	    {
    499   1.1  jonathan 		int on = 1;
    500  1.28  christos 		return (*ctl)(fp, TIOCCONS, &on, l);
    501   1.1  jonathan 	    }
    502  1.26     perry 	case _IOW('t', 37, struct sunos_ttysize):
    503   1.1  jonathan 	    {
    504   1.1  jonathan 		struct winsize ws;
    505   1.1  jonathan 		struct sunos_ttysize ss;
    506   1.1  jonathan 
    507  1.28  christos 		if ((error = (*ctl)(fp, TIOCGWINSZ, &ws, l)) != 0)
    508  1.33  christos 			return error;
    509   1.1  jonathan 
    510  1.33  christos 		if ((error = copyin(SCARG(&ap, data), &ss, sizeof (ss))) != 0)
    511   1.1  jonathan 			return error;
    512   1.1  jonathan 
    513   1.1  jonathan 		ws.ws_row = ss.ts_row;
    514   1.1  jonathan 		ws.ws_col = ss.ts_col;
    515   1.1  jonathan 
    516  1.28  christos 		return (*ctl)(fp, TIOCSWINSZ, &ws, l);
    517   1.1  jonathan 	    }
    518  1.26     perry 	case _IOW('t', 38, struct sunos_ttysize):
    519   1.1  jonathan 	    {
    520   1.1  jonathan 		struct winsize ws;
    521   1.1  jonathan 		struct sunos_ttysize ss;
    522   1.1  jonathan 
    523  1.28  christos 		if ((error = (*ctl)(fp, TIOCGWINSZ, &ws, l)) != 0)
    524  1.33  christos 			return error;
    525   1.1  jonathan 
    526   1.1  jonathan 		ss.ts_row = ws.ws_row;
    527   1.1  jonathan 		ss.ts_col = ws.ws_col;
    528   1.1  jonathan 
    529  1.33  christos 		return copyout (&ss, SCARG(&ap, data), sizeof (ss));
    530   1.1  jonathan 	    }
    531   1.8  jonathan 	case _IOW('t', 118, int):
    532  1.33  christos 		SCARG(&ap, com) = TIOCSPGRP;
    533   1.1  jonathan 		break;
    534   1.8  jonathan 	case _IOR('t', 119, int):
    535  1.33  christos 		SCARG(&ap, com) = TIOCGPGRP;
    536   1.1  jonathan 		break;
    537   1.8  jonathan 
    538  1.26     perry 	/* Emulate termio or termios tcget() */
    539   1.1  jonathan 	case ULTRIX_TCGETA:
    540  1.26     perry 	case ULTRIX_TCGETS:
    541   1.1  jonathan 	    {
    542   1.1  jonathan 		struct termios bts;
    543   1.1  jonathan 		struct ultrix_termios sts;
    544   1.1  jonathan 		struct ultrix_termio st;
    545  1.26     perry 
    546  1.28  christos 		if ((error = (*ctl)(fp, TIOCGETA, &bts, l)) != 0)
    547   1.1  jonathan 			return error;
    548  1.26     perry 
    549   1.1  jonathan 		btios2stios (&bts, &sts);
    550  1.33  christos 		if (SCARG(&ap, com) == ULTRIX_TCGETA) {
    551   1.1  jonathan 			stios2stio (&sts, &st);
    552  1.33  christos 			return copyout(&st, SCARG(&ap, data), sizeof (st));
    553   1.1  jonathan 		} else
    554  1.33  christos 			return copyout(&sts, SCARG(&ap, data), sizeof (sts));
    555   1.1  jonathan 		/*NOTREACHED*/
    556   1.1  jonathan 	    }
    557   1.2  jonathan 	/* Emulate termio tcset() */
    558   1.1  jonathan 	case ULTRIX_TCSETA:
    559   1.1  jonathan 	case ULTRIX_TCSETAW:
    560   1.1  jonathan 	case ULTRIX_TCSETAF:
    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.1  jonathan 		int result;
    566  1.26     perry 
    567  1.33  christos 		if ((error = copyin(SCARG(&ap, data), &st, sizeof (st))) != 0)
    568   1.1  jonathan 			return error;
    569   1.1  jonathan 
    570   1.1  jonathan 		/* get full BSD termios so we don't lose information */
    571  1.28  christos 		if ((error = (*ctl)(fp, TIOCGETA, &bts, l)) != 0)
    572   1.1  jonathan 			return error;
    573   1.1  jonathan 
    574   1.1  jonathan 		/*
    575   1.1  jonathan 		 * convert to sun termios, copy in information from
    576   1.1  jonathan 		 * termio, and convert back, then set new values.
    577   1.1  jonathan 		 */
    578   1.1  jonathan 		btios2stios(&bts, &sts);
    579   1.1  jonathan 		stio2stios(&st, &sts);
    580   1.1  jonathan 		stios2btios(&sts, &bts);
    581   1.1  jonathan 
    582   1.1  jonathan 		/*
    583   1.1  jonathan 		 * map ioctl code: ultrix tcsets are numbered in reverse order
    584   1.1  jonathan 		 */
    585   1.1  jonathan #ifdef notyet
    586  1.33  christos 		return (*ctl)(fp, ULTRIX_TCSETA - SCARG(&ap, com) + TIOCSETA,
    587  1.28  christos 		    &bts, l);
    588   1.1  jonathan #else
    589  1.33  christos 		result= (*ctl)(fp, ULTRIX_TCSETA -  SCARG(&ap, com) + TIOCSETA,
    590  1.28  christos 		    &bts, l);
    591   1.7  christos 		printf("ultrix TCSETA %lx returns %d\n",
    592  1.33  christos 		    ULTRIX_TCSETA - SCARG(&ap, com), result);
    593   1.1  jonathan 		return result;
    594   1.1  jonathan #endif
    595   1.1  jonathan 
    596   1.1  jonathan 	    }
    597   1.2  jonathan 	/* Emulate termios tcset() */
    598   1.1  jonathan 	case ULTRIX_TCSETS:
    599   1.1  jonathan 	case ULTRIX_TCSETSW:
    600   1.1  jonathan 	case ULTRIX_TCSETSF:
    601   1.1  jonathan 	    {
    602   1.1  jonathan 		struct termios bts;
    603   1.1  jonathan 		struct ultrix_termios sts;
    604   1.1  jonathan 
    605  1.33  christos 		if ((error = copyin(SCARG(&ap, data), &sts, sizeof (sts))) != 0)
    606   1.1  jonathan 			return error;
    607   1.1  jonathan 		stios2btios (&sts, &bts);
    608  1.33  christos 		return (*ctl)(fp, ULTRIX_TCSETS - SCARG(&ap, com) + TIOCSETA,
    609  1.28  christos 		    &bts, l);
    610   1.1  jonathan 	    }
    611   1.1  jonathan /*
    612   1.1  jonathan  * Pseudo-tty ioctl translations.
    613   1.1  jonathan  */
    614   1.1  jonathan 	case _IOW('t', 32, int): {	/* TIOCTCNTL */
    615  1.27  drochner 		int on;
    616   1.1  jonathan 
    617  1.33  christos 		error = copyin(SCARG(&ap, data), &on, sizeof (on));
    618   1.3  jonathan 		if (error != 0)
    619   1.1  jonathan 			return error;
    620  1.28  christos 		return (*ctl)(fp, TIOCUCNTL, &on, l);
    621   1.1  jonathan 	}
    622   1.1  jonathan 	case _IOW('t', 33, int): {	/* TIOCSIGNAL */
    623  1.27  drochner 		int sig;
    624   1.1  jonathan 
    625  1.33  christos 		error = copyin(SCARG(&ap, data), &sig, sizeof (sig));
    626   1.3  jonathan 		if (error != 0)
    627   1.1  jonathan 			return error;
    628  1.28  christos 		return (*ctl)(fp, TIOCSIG, &sig, l);
    629   1.1  jonathan 	}
    630   1.8  jonathan 
    631   1.1  jonathan /*
    632   1.1  jonathan  * Socket ioctl translations.
    633   1.1  jonathan  */
    634   1.3  jonathan #define IN_TYPE(a, type_t) { \
    635   1.3  jonathan 	type_t localbuf; \
    636  1.33  christos 	if ((error = copyin(SCARG(&ap, data), \
    637  1.20       dsl 				&localbuf, sizeof (type_t))) != 0) \
    638   1.3  jonathan 		return error; \
    639  1.28  christos 	return (*ctl)(fp, a, &localbuf, l); \
    640   1.3  jonathan }
    641   1.3  jonathan 
    642   1.3  jonathan #define INOUT_TYPE(a, type_t) { \
    643   1.3  jonathan 	type_t localbuf; \
    644  1.33  christos 	if ((error = copyin(SCARG(&ap, data), &localbuf,	\
    645   1.3  jonathan 			     sizeof (type_t))) != 0) \
    646   1.3  jonathan 		return error; \
    647  1.28  christos 	if ((error = (*ctl)(fp, a, &localbuf, l)) != 0) \
    648   1.3  jonathan 		return error; \
    649  1.33  christos 	return copyout(&localbuf, SCARG(&ap, data), sizeof (type_t)); \
    650   1.3  jonathan }
    651   1.3  jonathan 
    652   1.3  jonathan 
    653   1.1  jonathan #define IFREQ_IN(a) { \
    654  1.30  christos 	struct oifreq ifreq; \
    655  1.33  christos 	if ((error = copyin(SCARG(&ap, data), &ifreq, sizeof (ifreq))) != 0) \
    656   1.1  jonathan 		return error; \
    657  1.28  christos 	return (*ctl)(fp, a, &ifreq, l); \
    658   1.1  jonathan }
    659   1.3  jonathan 
    660   1.1  jonathan #define IFREQ_INOUT(a) { \
    661  1.30  christos 	struct oifreq ifreq; \
    662  1.33  christos 	if ((error = copyin(SCARG(&ap, data), &ifreq, sizeof (ifreq))) != 0) \
    663   1.1  jonathan 		return error; \
    664  1.28  christos 	if ((error = (*ctl)(fp, a, &ifreq, l)) != 0) \
    665   1.1  jonathan 		return error; \
    666  1.33  christos 	return copyout(&ifreq, SCARG(&ap, data), sizeof (ifreq)); \
    667   1.1  jonathan }
    668   1.1  jonathan 
    669  1.30  christos 	case _IOW('i', 12, struct oifreq):
    670   1.1  jonathan 		/* SIOCSIFADDR */
    671   1.1  jonathan 		break;
    672   1.1  jonathan 
    673  1.30  christos 	case _IOWR('i', 13, struct oifreq):
    674  1.31        he 		IFREQ_INOUT(OOSIOCGIFADDR);
    675   1.1  jonathan 
    676  1.30  christos 	case _IOW('i', 14, struct oifreq):
    677   1.1  jonathan 		/* SIOCSIFDSTADDR */
    678   1.1  jonathan 		break;
    679   1.1  jonathan 
    680  1.30  christos 	case _IOWR('i', 15, struct oifreq):
    681  1.31        he 		IFREQ_INOUT(OOSIOCGIFDSTADDR);
    682   1.1  jonathan 
    683  1.30  christos 	case _IOW('i', 16, struct oifreq):
    684   1.1  jonathan 		/* SIOCSIFFLAGS */
    685   1.1  jonathan 		break;
    686   1.1  jonathan 
    687  1.30  christos 	case _IOWR('i', 17, struct oifreq):
    688   1.1  jonathan 		/* SIOCGIFFLAGS */
    689   1.1  jonathan 		break;
    690   1.1  jonathan 
    691  1.30  christos 	case _IOWR('i', 18, struct oifreq):
    692   1.1  jonathan 		IFREQ_INOUT(SIOCGIFBRDADDR);
    693   1.1  jonathan 
    694  1.30  christos 	case _IOWR('i', 19, struct oifreq):
    695   1.8  jonathan 		IFREQ_INOUT(SIOCSIFBRDADDR);
    696   1.1  jonathan 
    697  1.21  christos 	case _IOWR('i', 20, struct ifconf):	/* SIOCGIFCONF */
    698  1.21  christos 	    {
    699  1.27  drochner 		struct ifconf ifconfarg;
    700  1.21  christos 
    701  1.21  christos 		/*
    702  1.21  christos 		 * XXX: two more problems
    703  1.21  christos 		 * 1. our sockaddr's are variable length, not always sizeof(sockaddr)
    704  1.21  christos 		 * 2. this returns a name per protocol, ie. it returns two "lo0"'s
    705  1.21  christos 		 */
    706  1.33  christos 		error = copyin(SCARG(&ap, data), &ifconfarg, sizeof (ifconfarg));
    707  1.21  christos 		if (error)
    708  1.21  christos 			return error;
    709  1.28  christos 		error = (*ctl)(fp, OSIOCGIFCONF, &ifconfarg, l);
    710  1.21  christos 		if (error)
    711  1.21  christos 			return error;
    712  1.33  christos 		return copyout(&ifconfarg, SCARG(&ap, data), sizeof (ifconfarg));
    713  1.21  christos 	    }
    714  1.21  christos 
    715  1.21  christos 
    716  1.30  christos 	case _IOWR('i', 21, struct oifreq):
    717  1.31        he 		IFREQ_INOUT(OOSIOCGIFNETMASK);
    718   1.1  jonathan 
    719  1.30  christos 	case _IOW('i', 22, struct oifreq):
    720   1.1  jonathan 		IFREQ_IN(SIOCSIFNETMASK);
    721   1.1  jonathan 
    722  1.30  christos 	/* 23: _IOWR('i', 23, struct oifreq):  Ultrix SIOCSPHYADDR */
    723  1.30  christos 	/* 24: _IOWR('i', 24, struct oifreq):  Ultrix SIOCSADDMULTI */
    724  1.30  christos 	/* 25: _IOWR('i', 25, struct oifreq):  Ultrix SIOCSDELMULTI */
    725  1.30  christos 
    726  1.30  christos 	case _IOW('i',  26, struct oifreq):	/* SIOCSIFRDCTRS? */
    727  1.30  christos 	case _IOWR('i', 27, struct oifreq):	/* SIOCGIFZCTRS? */
    728  1.30  christos 	case _IOWR('i', 28, struct oifreq):	/* read physaddr ? */
    729  1.21  christos 		return EOPNOTSUPP;
    730   1.1  jonathan 
    731   1.1  jonathan 
    732   1.1  jonathan 	case _IOW('i', 30, struct arpreq):
    733   1.1  jonathan 		/* SIOCSARP */
    734   1.1  jonathan 		break;
    735   1.1  jonathan 
    736   1.1  jonathan 	case _IOWR('i', 31, struct arpreq):
    737   1.1  jonathan 		/* SIOCGARP */
    738   1.1  jonathan 		break;
    739   1.1  jonathan 
    740   1.1  jonathan 	case _IOW('i', 32, struct arpreq):
    741   1.1  jonathan 		/* SIOCDARP */
    742   1.1  jonathan 		break;
    743   1.1  jonathan 
    744  1.30  christos 	case _IOW('i', 40, struct oifreq):	/* SIOCARPREQ */
    745  1.21  christos 		return EOPNOTSUPP;
    746  1.21  christos 
    747  1.30  christos 	case _IOWR('i', 41, struct oifreq):
    748  1.21  christos 		IFREQ_INOUT(SIOCGIFMETRIC);
    749  1.21  christos 
    750  1.30  christos 	case _IOWR('i', 42, struct oifreq):
    751  1.21  christos 		IFREQ_IN(SIOCSIFMETRIC);
    752   1.8  jonathan 
    753  1.30  christos 	case _IOW('i', 44, struct oifreq):	/* SIOCSETSYNC */
    754  1.30  christos 	case _IOWR('i', 45, struct oifreq):	/* SIOCGETSYNC */
    755  1.30  christos 	case _IOWR('i', 46, struct oifreq):	/* SIOCSDSTATS */
    756  1.30  christos 	case _IOWR('i', 47, struct oifreq):	/* SIOCSESTATS */
    757   1.1  jonathan 	case _IOW('i', 48, int):		/* SIOCSPROMISC */
    758   1.8  jonathan 		return EOPNOTSUPP;
    759   1.8  jonathan 
    760   1.8  jonathan 	/* emulate for vat, vic tools */
    761  1.30  christos 	case _IOW('i', 49, struct oifreq):	/* SIOCADDMULTI */
    762  1.30  christos 	case _IOW('i', 50, struct oifreq):	/* SIOCDELMULTI */
    763   1.1  jonathan 		return EOPNOTSUPP;
    764   1.1  jonathan 
    765   1.1  jonathan 	}
    766  1.33  christos 	return sys_ioctl(l, &ap, retval);
    767   1.1  jonathan }
    768