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