VBoxNetAdp-win.cpp revision da34f66f1d7f32c00dcccd9164bc10435de15952
/* $Id$ */
/** @file
* VBoxNetAdp-win.cpp - NDIS6 Host-only Networking Driver, Windows-specific code.
*/
/*
* Copyright (C) 2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#define LOG_GROUP LOG_GROUP_NET_ADP_DRV
#include <iprt/initterm.h>
#include <ndis.h>
#include "VBoxNetAdp-win.h"
#include "VBoxNetCmn-win.h"
/* Forward declarations */
typedef struct _VBOXNETADPGLOBALS
{
/** ndis device */
/** device object */
/** our miniport driver handle */
/** power management capabilities, shared by all instances, do not change after init */
/* win-specific global data */
typedef struct _VBOXNETADP_ADAPTER {
typedef VBOXNETADP_ADAPTER *PVBOXNETADP_ADAPTER;
{
switch (pIrpSl->MajorFunction)
{
case IRP_MJ_DEVICE_CONTROL:
break;
case IRP_MJ_CREATE:
case IRP_MJ_CLEANUP:
case IRP_MJ_CLOSE:
break;
default:
Assert(0);
break;
}
return Status;
}
{
return Status;
}
{
}
{
};
DECLHIDDEN(NDIS_STATUS) vboxNetAdpWinAllocAdapter(NDIS_HANDLE hAdapter, PVBOXNETADP_ADAPTER *ppAdapter, ULONG64 NetLuid)
{
pAdapter = (PVBOXNETADP_ADAPTER)NdisAllocateMemoryWithTagPriority(g_VBoxNetAdpGlobals.hMiniportDriver,
sizeof(VBOXNETADP_ADAPTER),
if (!pAdapter)
{
Log((__FUNCTION__": Out of memory while allocating adapter context (size=%d)\n", sizeof(VBOXNETADP_ADAPTER)));
}
else
{
// TODO: Use netadp structure instead!
/* Use a locally administered version of the OUI we use for the guest NICs. */
//TODO: Statistics?
}
return Status;
}
{
NdisFreeMemory(pAdapter, 0, 0);
}
{
return MediaConnectStateConnected;
}
{
do
{
Status = vboxNetAdpWinAllocAdapter(NdisMiniportHandle, &pAdapter, MiniportInitParameters->NetLuid.Value);
if (Status != NDIS_STATUS_SUCCESS)
{
break;
}
if (Status != NDIS_STATUS_SUCCESS)
{
break;
}
// TODO: Registry?
// TODO: WDM stack?
// TODO: DPC?
GAttrs.IfConnectorPresent = false;
GAttrs.DataBackFillSize = 0;
if (Status != NDIS_STATUS_SUCCESS)
{
break;
}
} while (false);
if (Status != NDIS_STATUS_SUCCESS)
{
if (pAdapter)
}
return Status;
}
{
// TODO: Stop something?
}
{
return Status;
}
{
return Status;
}
{
{
{
break;
break;
}
break;
case OID_GEN_RCV_OK:
case OID_GEN_XMIT_OK:
u64Tmp = 0;
break;
// TODO: Make configurable
break;
case OID_GEN_STATISTICS:
{
break;
// TODO: We need some stats, don't we?
break;
}
pInfo = "Oracle";
break;
break;
case OID_GEN_VENDOR_ID:
break;
break;
//case OID_802_3_MULTICAST_LIST:
break;
case OID_PNP_CAPABILITIES:
break;
case OID_PNP_QUERY_POWER:
cbInfo = 0;
break;
default:
break;
}
if (Status == NDIS_STATUS_SUCCESS)
{
{
}
else
{
if (pInfo)
}
}
return Status;
}
{
{
{
break;
}
// TODO: For the time being we simply ignore lookahead settings.
break;
{
break;
}
// TODO: For the time being we simply ignore packet filter settings.
break;
pSet->BytesNeeded = 0;
break;
case OID_PNP_SET_POWER:
{
break;
}
break;
default:
break;
}
return Status;
}
{
switch (NdisRequest->RequestType)
{
#if 0
case NdisRequestMethod:
break;
#endif
break;
break;
default:
break;
}
return Status;
}
{
}
{
}
{
}
{
return FALSE;
}
{
return Status;
}
{
}
{
}
{
}
{
//vboxNetAdpWinDevDestroy(&g_VBoxNetAdpGlobals);
//NdisFreeSpinLock(&g_VBoxNetAdpGlobals.Lock);
RTR0Term();
}
/**
* register the miniport driver
*/
DECLHIDDEN(NDIS_STATUS) vboxNetAdpWinRegister(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPathStr)
{
Log(("vboxNetAdpWinRegister: registering miniport driver...\n"));
&MChars,
if (Status == STATUS_SUCCESS)
{
Log(("vboxNetAdpWinRegister: successfully registered miniport driver; registering device...\n"));
//Status = vboxNetAdpWinDevCreate(&g_VBoxNetAdpGlobals);
//Assert(Status == STATUS_SUCCESS);
//Log(("vboxNetAdpWinRegister: vboxNetAdpWinDevCreate() returned 0x%x\n", Status));
}
else
{
}
return Status;
}
{
int rc;
if (RT_SUCCESS(rc))
{
//NdisAllocateSpinLock(&g_VBoxNetAdpGlobals.Lock);
//g_VBoxNetAdpGlobals.PMCaps.WakeUpCapabilities.Flags = NDIS_DEVICE_WAKE_UP_ENABLE;
if (Status == NDIS_STATUS_SUCCESS)
{
Log(("NETADP: started successfully\n"));
return STATUS_SUCCESS;
}
//NdisFreeSpinLock(&g_VBoxNetAdpGlobals.Lock);
RTR0Term();
}
else
{
}
return Status;
}