1 /* $NetBSD: if_43.c,v 1.1 2008/11/14 23:10:57 ad Exp $ */
4 * Copyright (c) 1982, 1986, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
31 * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: if_43.c,v 1.1 2008/11/14 23:10:57 ad Exp $");
37 #if defined(_KERNEL_OPT)
38 #include "opt_compat_netbsd.h"
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/filedesc.h>
44 #include <sys/kernel.h>
47 #include <sys/socket.h>
48 #include <sys/socketvar.h>
50 #include <sys/ioctl.h>
51 #include <sys/fcntl.h>
52 #include <sys/malloc.h>
53 #include <sys/syslog.h>
54 #include <sys/unistd.h>
55 #include <sys/resourcevar.h>
56 #include <sys/mbuf.h> /* for MLEN */
57 #include <sys/protosw.h>
59 #include <sys/mount.h>
60 #include <sys/syscallargs.h>
64 #include <net/route.h>
65 #include <netinet/in.h>
66 #include <netinet/in_systm.h>
67 #include <netinet/ip.h>
68 #include <net/if_gre.h>
69 #include <net/if_atm.h>
70 #include <net/if_tap.h>
71 #include <net80211/ieee80211_ioctl.h>
72 #include <netinet6/in6_var.h>
73 #include <netinet6/nd6.h>
74 #include <compat/sys/socket.h>
75 #include <compat/sys/sockio.h>
77 #include <compat/common/compat_util.h>
79 #include <uvm/uvm_extern.h>
82 compat_cvtcmd(u_long cmd
)
86 if (IOCPARM_LEN(cmd
) != sizeof(struct oifreq
))
89 ncmd
= ((cmd
) & ~(IOCPARM_MASK
<< IOCPARM_SHIFT
)) |
90 (sizeof(struct ifreq
) << IOCPARM_SHIFT
);
104 case OSIOCG80211STATS
:
105 case OSIOCG80211ZSTATS
:
106 #endif /* COMPAT_20 */
110 case SIOCDIFADDR_IN6
:
112 case SIOCGDEFIFACE_IN6
:
114 case SIOCG80211STATS
:
115 case SIOCG80211ZSTATS
:
117 case SIOCGIFADDR_IN6
:
118 case SIOCGIFAFLAG_IN6
:
119 case SIOCGIFALIFETIME_IN6
:
123 case SIOCGIFDSTADDR_IN6
:
129 case SIOCGIFNETMASK_IN6
:
130 case SIOCGIFPDSTADDR
:
131 case SIOCGIFPDSTADDR_IN6
:
132 case SIOCGIFPSRCADDR
:
133 case SIOCGIFPSRCADDR_IN6
:
134 case SIOCGIFSTAT_ICMP6
:
135 case SIOCGIFSTAT_IN6
:
141 case SIOCSDEFIFACE_IN6
:
143 case SIOCSIFADDR_IN6
:
146 case SIOCSIFDSTADDR_IN6
:
153 case SIOCSIFNETMASK_IN6
:
154 case SIOCSNDFLUSH_IN6
:
155 case SIOCSPFXFLUSH_IN6
:
157 case SIOCSRTRFLUSH_IN6
:
166 compat_ifioctl(struct socket
*so
, u_long ocmd
, u_long cmd
, void *data
,
170 struct ifreq
*ifr
= data
;
171 struct ifnet
*ifp
= ifunit(ifr
->ifr_name
);
179 case OSIOCSIFDSTADDR
:
180 case OSIOCSIFBRDADDR
:
181 case OSIOCSIFNETMASK
:
183 #if BYTE_ORDER != BIG_ENDIAN
184 if (sa
->sa_family
== 0 && sa
->sa_len
< 16) {
185 sa
->sa_family
= sa
->sa_len
;
198 case OOSIOCGIFDSTADDR
:
199 cmd
= SIOCGIFDSTADDR
;
202 case OOSIOCGIFBRDADDR
:
203 cmd
= SIOCGIFBRDADDR
;
206 case OOSIOCGIFNETMASK
:
207 cmd
= SIOCGIFNETMASK
;
210 error
= (*so
->so_proto
->pr_usrreq
)(so
, PRU_CONTROL
,
211 (struct mbuf
*)cmd
, (struct mbuf
*)ifr
, (struct mbuf
*)ifp
, l
);
215 case OOSIOCGIFDSTADDR
:
216 case OOSIOCGIFBRDADDR
:
217 case OOSIOCGIFNETMASK
:
218 *(u_int16_t
*)&ifr
->ifr_addr
=
219 ((struct sockaddr
*)&ifr
->ifr_addr
)->sa_family
;