1 /* $NetBSD: sockio.h,v 1.21 2022/09/28 15:32:09 msaitoh Exp $ */ 2 3 /*- 4 * Copyright (c) 1982, 1986, 1990, 1993, 1994 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the University nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32 #ifndef _COMPAT_SYS_SOCKIO_H_ 33 #define _COMPAT_SYS_SOCKIO_H_ 34 35 #include <sys/ioccom.h> 36 #include <compat/net/if.h> 37 38 #define OSIOCSIFADDR _IOW('i', 12, struct oifreq) /* set ifnet address */ 39 #define OOSIOCGIFADDR _IOWR('i', 13, struct oifreq) /* get ifnet address */ 40 #define OSIOCSIFDSTADDR _IOW('i', 14, struct oifreq) /* set p-p address */ 41 #define OOSIOCGIFDSTADDR _IOWR('i', 15, struct oifreq) /* get p-p address */ 42 #define OSIOCSIFFLAGS _IOW('i', 16, struct oifreq) /* set ifnet flags */ 43 #define OSIOCGIFFLAGS _IOWR('i', 17, struct oifreq) /* get ifnet flags */ 44 #define OOSIOCGIFBRDADDR _IOWR('i', 18, struct oifreq) /* get bcast addr */ 45 #define OSIOCSIFBRDADDR _IOW('i', 19, struct oifreq) /* set bcast addr */ 46 #define OOSIOCGIFCONF _IOWR('i', 20, struct ifconf) /* get ifnet list */ 47 #define OOSIOCGIFNETMASK _IOWR('i', 21, struct oifreq) /* get net addr mask */ 48 #define OSIOCSIFNETMASK _IOW('i', 22, struct oifreq) /* set net addr mask */ 49 #define OSIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */ 50 #define OSIOCADDMULTI _IOW('i', 49, struct oifreq) /* add m'cast addr */ 51 #define OSIOCDELMULTI _IOW('i', 50, struct oifreq) /* del m'cast addr */ 52 #define SIOCSIFMEDIA_43 _IOWR('i', 53, struct oifreq) /* set net media */ 53 #define SIOCSIFMEDIA_80 _IOWR('i', 53, struct ifreq) /* set net media */ 54 #define SIOCGIFMEDIA_80 _IOWR('i', 54, struct ifmediareq) /* set net media */ 55 #define OSIOCGIFMTU _IOWR('i', 126, struct oifreq) /* get ifnet mtu */ 56 #define OSIOCGIFDATA _IOWR('i', 128, struct ifdatareq50) /* get if_data */ 57 #define OSIOCZIFDATA _IOWR('i', 129, struct ifdatareq50) /* get if_data then 58 zero ctrs*/ 59 60 #define OBIOCGETIF _IOR('B', 107, struct oifreq) 61 #define OBIOCSETIF _IOW('B', 108, struct oifreq) 62 #define OTAPGIFNAME _IOR('e', 0, struct oifreq) 63 64 #define IFREQN2O_43(oi, ni) \ 65 do { \ 66 (void)memcpy((oi)->ifr_name, (ni)->ifr_name, \ 67 sizeof((oi)->ifr_name)); \ 68 (void)memcpy(&(oi)->ifr_ifru, &(ni)->ifr_ifru, \ 69 sizeof((oi)->ifr_ifru)); \ 70 } while (/*CONSTCOND*/0) 71 72 #define IFREQO2N_43(oi, ni) \ 73 do { \ 74 (void)memcpy((ni)->ifr_name, (oi)->ifr_name, \ 75 sizeof((oi)->ifr_name)); \ 76 (void)memcpy(&(ni)->ifr_ifru, &(oi)->ifr_ifru, \ 77 sizeof((oi)->ifr_ifru)); \ 78 } while (/*CONSTCOND*/0) 79 80 #define ifdatan2o(oi, ni) \ 81 do { \ 82 (void)memcpy((oi), (ni), sizeof(*(oi))); \ 83 (oi)->ifi_lastchange.tv_sec = \ 84 (int32_t)(ni)->ifi_lastchange.tv_sec; \ 85 (oi)->ifi_lastchange.tv_usec = \ 86 (ni)->ifi_lastchange.tv_nsec / 1000; \ 87 } while (/*CONSTCOND*/0) 88 89 #define ifdatao2n(oi, ni) \ 90 do { \ 91 (void)memcpy((ni), (oi), sizeof(*(oi))); \ 92 (ni)->ifi_lastchange.tv_sec = (oi)->ifi_lastchange.tv_sec; \ 93 (ni)->ifi_lastchange.tv_nsec = \ 94 (oi)->ifi_lastchange.tv_usec * 1000; \ 95 } while (/*CONSTCOND*/0) 96 97 #endif /* _COMPAT_SYS_SOCKIO_H_ */ 98