VBoxNetAdp-freebsd.c revision 41ca46e5127405aab2b9014db90bfcd8684083b8
/* $Id$ */
/** @file
* VBoxNetAdp - Virtual Network Adapter Driver (Host), FreeBSD Specific Code.
*/
/*-
* Copyright (c) 2009 Fredrik Lindberg <fli@shapeshifter.se>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <net/if_types.h>
#include <net/ethernet.h>
#define LOG_GROUP LOG_GROUP_NET_ADP_DRV
#include <iprt/initterm.h>
#include <iprt/spinlock.h>
#define VBOXNETADP_OS_SPECFIC 1
#include "../VBoxNetAdpInternal.h"
struct thread *);
static struct cdevsw vboxnetadp_cdevsw =
{
};
static struct cdev *VBoxNetAdpFreeBSDcdev;
static int VBoxNetAdpFreeBSDModuleEvent(struct module *, int, void *);
static moduledata_t g_VBoxNetAdpFreeBSDModule = {
"vboxnetadp",
};
/** Declare the module as a pseudo device. */
/**
* Module event handler
*/
static int
{
int rc = 0;
Log(("VBoxNetAdpFreeBSDModuleEvent\n"));
switch (enmEventType)
{
case MOD_LOAD:
if (RT_FAILURE(rc))
{
return RTErrConvertToErrno(rc);
}
rc = vboxNetAdpInit();
if (RT_FAILURE(rc))
{
RTR0Term();
return RTErrConvertToErrno(rc);
}
/* Create dev node */
break;
case MOD_UNLOAD:
RTR0Term();
break;
case MOD_SHUTDOWN:
case MOD_QUIESCE:
default:
return EOPNOTSUPP;
}
if (RT_SUCCESS(rc))
return 0;
return RTErrConvertToErrno(rc);
}
/**
* Device I/O Control entry point.
*/
static int
VBoxNetAdpFreeBSDCtrlioctl(struct cdev *dev, u_long iCmd, caddr_t data, int flags, struct thread *td)
{
int rc;
switch (iCmd)
{
case VBOXNETADP_CTL_ADD:
return EINVAL;
if (RT_FAILURE(rc))
return EINVAL;
break;
case VBOXNETADP_CTL_REMOVE:
return EINVAL;
if (!pAdp)
return EINVAL;
if (RT_FAILURE(rc))
return EINVAL;
break;
default:
return EINVAL;
}
return 0;
}
/**
* Initialize device, just set the running flag.
*/
static void VBoxNetAdpFreeBSDNetinit(void *priv)
{
}
/**
* Transmit packets.
* netflt has already done everything for us so we just hand the
* packets to BPF and increment the packet stats.
*/
{
struct mbuf *m;
return;
{
ifp->if_opackets++;
m_freem(m);
}
}
/**
* Interface ioctl handling
*/
{
switch (cmd)
{
case SIOCSIFFLAGS:
{
}
else
{
}
break;
default:
}
return 0;
}
{
return VINF_SUCCESS;;
}
{
return VERR_NO_MEMORY;
ifp->if_baudrate = 0;
return 0;
}
{
}