Home | History | Annotate | Line # | Download | only in rumpnet
net_stub.c revision 1.4.2.2
      1  1.4.2.2  haad /*	$NetBSD: net_stub.c,v 1.4.2.2 2008/10/19 22:18:07 haad Exp $	*/
      2  1.4.2.2  haad 
      3  1.4.2.2  haad /*
      4  1.4.2.2  haad  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
      5  1.4.2.2  haad  *
      6  1.4.2.2  haad  * Redistribution and use in source and binary forms, with or without
      7  1.4.2.2  haad  * modification, are permitted provided that the following conditions
      8  1.4.2.2  haad  * are met:
      9  1.4.2.2  haad  * 1. Redistributions of source code must retain the above copyright
     10  1.4.2.2  haad  *    notice, this list of conditions and the following disclaimer.
     11  1.4.2.2  haad  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.4.2.2  haad  *    notice, this list of conditions and the following disclaimer in the
     13  1.4.2.2  haad  *    documentation and/or other materials provided with the distribution.
     14  1.4.2.2  haad  *
     15  1.4.2.2  haad  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     16  1.4.2.2  haad  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     17  1.4.2.2  haad  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     18  1.4.2.2  haad  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19  1.4.2.2  haad  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20  1.4.2.2  haad  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     21  1.4.2.2  haad  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.4.2.2  haad  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23  1.4.2.2  haad  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  1.4.2.2  haad  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  1.4.2.2  haad  * SUCH DAMAGE.
     26  1.4.2.2  haad  */
     27  1.4.2.2  haad 
     28  1.4.2.2  haad #include <sys/param.h>
     29  1.4.2.2  haad #include <sys/protosw.h>
     30  1.4.2.2  haad #include <sys/socketvar.h>
     31  1.4.2.2  haad 
     32  1.4.2.2  haad #include <net/if.h>
     33  1.4.2.2  haad #include <net/route.h>
     34  1.4.2.2  haad 
     35  1.4.2.2  haad #include <compat/sys/socket.h>
     36  1.4.2.2  haad #include <compat/sys/sockio.h>
     37  1.4.2.2  haad 
     38  1.4.2.2  haad int __rtioctl_unimpl(u_long, void *, struct lwp *);
     39  1.4.2.2  haad int
     40  1.4.2.2  haad __rtioctl_unimpl(u_long req, void *data, struct lwp *l)
     41  1.4.2.2  haad {
     42  1.4.2.2  haad 
     43  1.4.2.2  haad 	panic("%s: not implemented, librumpnet_net required", __func__);
     44  1.4.2.2  haad }
     45  1.4.2.2  haad __weak_alias(rtioctl,__rtioctl_unimpl);
     46  1.4.2.2  haad 
     47  1.4.2.2  haad int __ifioctl_unimpl(struct socket *, u_long, void *, struct lwp *);
     48  1.4.2.2  haad int
     49  1.4.2.2  haad __ifioctl_unimpl(struct socket *so, u_long cmd, void *data, struct lwp *l)
     50  1.4.2.2  haad {
     51  1.4.2.2  haad 
     52  1.4.2.2  haad 	panic("%s: not implemented, librumpnet_net required", __func__);
     53  1.4.2.2  haad }
     54  1.4.2.2  haad __weak_alias(ifioctl,__ifioctl_unimpl);
     55  1.4.2.2  haad 
     56  1.4.2.2  haad struct ifnet_head ifnet;
     57  1.4.2.2  haad 
     58  1.4.2.2  haad u_long
     59  1.4.2.2  haad compat_cvtcmd(u_long cmd)
     60  1.4.2.2  haad {
     61  1.4.2.2  haad 
     62  1.4.2.2  haad 	return cmd;
     63  1.4.2.2  haad }
     64  1.4.2.2  haad 
     65  1.4.2.2  haad int
     66  1.4.2.2  haad compat_ifconf(u_long cmd, void *data)
     67  1.4.2.2  haad {
     68  1.4.2.2  haad 
     69  1.4.2.2  haad 	return EOPNOTSUPP;
     70  1.4.2.2  haad }
     71  1.4.2.2  haad 
     72  1.4.2.2  haad int
     73  1.4.2.2  haad compat_ifioctl(struct socket *so, u_long ocmd, u_long cmd, void *data,
     74  1.4.2.2  haad 	struct lwp *l)
     75  1.4.2.2  haad {
     76  1.4.2.2  haad 	struct ifreq *ifr = data;
     77  1.4.2.2  haad 	struct ifnet *ifp = ifunit(ifr->ifr_name);
     78  1.4.2.2  haad 
     79  1.4.2.2  haad 	if (!ifp)
     80  1.4.2.2  haad 		return ENXIO;
     81  1.4.2.2  haad 
     82  1.4.2.2  haad 	return (*so->so_proto->pr_usrreq)(so, PRU_CONTROL,
     83  1.4.2.2  haad 	    (struct mbuf *)cmd, (struct mbuf *)data, (struct mbuf *)ifp, l);
     84  1.4.2.2  haad }
     85