PDMAllNetShaper.cpp revision 1c511098095d1a92509192393fe382493c016127
/* $Id$ */
/** @file
* PDM Network Shaper - Limit network traffic according to bandwidth group settings.
*/
/*
* Copyright (C) 2011-2013 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_NET_SHAPER
#include "PDMNetShaperInternal.h"
/**
* Obtain bandwidth in a bandwidth group.
*
* @returns True if bandwidth was allocated, false if not.
* @param pFilter Pointer to the filter that allocates bandwidth.
* @param cbTransfer Number of bytes to allocate.
*/
{
AssertPtrReturn(pFilter, true);
return true;
return true;
bool fAllowed = true;
if (pBwGroup->cbPerSecMax)
{
/* Re-fill the bucket first */
uint32_t uTokensAdded = (tsNow - pBwGroup->tsUpdatedLast) * pBwGroup->cbPerSecMax / (1000 * 1000 * 1000);
if (cbTransfer > uTokens)
{
fAllowed = false;
}
else
{
}
Log2(("pdmNsAllocateBandwidth: BwGroup=%#p{%s} cbTransfer=%u uTokens=%u uTokensAdded=%u fAllowed=%RTbool\n",
}
else
Log2(("pdmNsAllocateBandwidth: BwGroup=%#p{%s} disabled fAllowed=%RTbool\n",
return fAllowed;
}