VirtualBox

Changeset 40652 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Mar 26, 2012 4:36:16 PM (13 years ago)
Author:
vboxsync
Message:

NetShaper,E1000: Basic framework and partial implementation for network shaper

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r40633 r40652  
    10201020        InsertConfigNode(pAc,  "File", &pAcFile);
    10211021        InsertConfigNode(pAcFile,  "BwGroups", &pAcFileBwGroups);
     1022#ifdef VBOX_WITH_NETSHAPER
     1023        PCFGMNODE pNetworkShaper;
     1024        PCFGMNODE pNetworkBwGroups;
     1025
     1026        InsertConfigNode(pPDM, "NetworkShaper",  &pNetworkShaper);
     1027        InsertConfigNode(pNetworkShaper, "BwGroups", &pNetworkBwGroups);
     1028#endif /* VBOX_WITH_NETSHAPER */
    10221029
    10231030        for (size_t i = 0; i < bwGroups.size(); i++)
     
    10391046                InsertConfigInteger(pBwGroup, "Step", 0);
    10401047            }
     1048#ifdef VBOX_WITH_NETSHAPER
     1049            else if (enmType == BandwidthGroupType_Network)
     1050            {
     1051                /* Network bandwidth groups. */
     1052                PCFGMNODE pBwGroup;
     1053                InsertConfigNode(pNetworkBwGroups, Utf8Str(strName).c_str(), &pBwGroup);
     1054                InsertConfigInteger(pBwGroup, "Max", cMaxMbPerSec * 1000); // @todo: _1M);
     1055            }
     1056#endif /* VBOX_WITH_NETSHAPER */
    10411057        }
    10421058
     
    36783694        }
    36793695
    3680         Utf8Str strNetDriver;
    3681         if (fAttachDetach && fSniffer)
    3682         {
    3683             const char *pszNetDriver = "IntNet";
    3684             if (meAttachmentType[uInstance] == NetworkAttachmentType_NAT)
    3685                 pszNetDriver = "NAT";
    3686 #if !defined(VBOX_WITH_NETFLT) && defined(RT_OS_LINUX)
    3687             if (meAttachmentType[uInstance] == NetworkAttachmentType_Bridged)
    3688                 pszNetDriver = "HostInterface";
    3689 #endif
    3690             if (meAttachmentType[uInstance] == NetworkAttachmentType_Generic)
    3691             {
    3692                 hrc = aNetworkAdapter->COMGETTER(GenericDriver)(bstr.asOutParam()); H();
    3693                 strNetDriver = bstr;
    3694                 pszNetDriver = strNetDriver.c_str();
    3695             }
    3696 
    3697             rc = PDMR3DriverDetach(pVM, pszDevice, uInstance, uLun, pszNetDriver, 0, 0 /*fFlags*/);
    3698             if (rc == VINF_PDM_NO_DRIVER_ATTACHED_TO_LUN)
    3699                 rc = VINF_SUCCESS;
    3700             AssertLogRelRCReturn(rc, rc);
    3701 
    3702             pLunL0 = CFGMR3GetChildF(pInst, "LUN#%u", uLun);
    3703             PCFGMNODE pLunAD = CFGMR3GetChildF(pLunL0, "AttachedDriver");
    3704             if (pLunAD)
    3705             {
    3706                 CFGMR3RemoveNode(pLunAD);
    3707             }
    3708             else
    3709             {
    3710                 CFGMR3RemoveNode(pLunL0);
    3711                 InsertConfigNode(pInst, "LUN#0", &pLunL0);
    3712                 InsertConfigString(pLunL0, "Driver", "NetSniffer");
    3713                 InsertConfigNode(pLunL0, "Config", &pCfg);
    3714                 hrc = aNetworkAdapter->COMGETTER(TraceFile)(bstr.asOutParam());             H();
    3715                 if (!bstr.isEmpty()) /* check convention for indicating default file. */
    3716                     InsertConfigString(pCfg, "File", bstr);
    3717             }
    3718         }
    3719         else if (fAttachDetach && !fSniffer)
     3696        if (fAttachDetach)
    37203697        {
    37213698            rc = PDMR3DeviceDetach(pVM, pszDevice, uInstance, uLun, 0 /*fFlags*/);
     
    37273704            CFGMR3RemoveNode(CFGMR3GetChildF(pInst, "LUN#%u", uLun));
    37283705        }
    3729         else if (!fAttachDetach && fSniffer)
     3706
     3707#ifdef VBOX_WITH_NETSHAPER
     3708        ComObjPtr<IBandwidthGroup> pBwGroup;
     3709        Bstr strBwGroup;
     3710        PNETSHAPER pShaper = NULL;
     3711        PNETSHAPERFILTER pFilter = NULL;
     3712        hrc = aNetworkAdapter->COMGETTER(BandwidthGroup)(pBwGroup.asOutParam());            H();
     3713
     3714        if (!pBwGroup.isNull())
    37303715        {
    3731             /* insert the sniffer filter driver. */
    3732             InsertConfigNode(pInst, "LUN#0", &pLunL0);
     3716            hrc = pBwGroup->COMGETTER(Name)(strBwGroup.asOutParam());                       H();
     3717        }
     3718#endif /* VBOX_WITH_NETSHAPER */
     3719
     3720        Utf8Str strNetDriver;
     3721
     3722
     3723        InsertConfigNode(pInst, "LUN#0", &pLunL0);
     3724
     3725#ifdef VBOX_WITH_NETSHAPER
     3726        if (!strBwGroup.isEmpty())
     3727        {
     3728            InsertConfigString(pLunL0, "Driver", "NetShaper");
     3729            InsertConfigNode(pLunL0, "Config", &pCfg);
     3730            InsertConfigString(pCfg, "BwGroup", strBwGroup);
     3731            InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
     3732        }
     3733#endif /* VBOX_WITH_NETSHAPER */
     3734
     3735        if (fSniffer)
     3736        {
    37333737            InsertConfigString(pLunL0, "Driver", "NetSniffer");
    37343738            InsertConfigNode(pLunL0, "Config", &pCfg);
    3735             hrc = aNetworkAdapter->COMGETTER(TraceFile)(bstr.asOutParam());                 H();
     3739            hrc = aNetworkAdapter->COMGETTER(TraceFile)(bstr.asOutParam());             H();
    37363740            if (!bstr.isEmpty()) /* check convention for indicating default file. */
    37373741                InsertConfigString(pCfg, "File", bstr);
     3742            InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
    37383743        }
     3744
    37393745
    37403746        Bstr networkName, trunkName, trunkType;
     
    37503756                ComPtr<INATEngine> natDriver;
    37513757                hrc = aNetworkAdapter->COMGETTER(NatDriver)(natDriver.asOutParam());        H();
    3752                 if (fSniffer)
    3753                     InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
    3754                 else
    3755                     InsertConfigNode(pInst, "LUN#0", &pLunL0);
    37563758                InsertConfigString(pLunL0, "Driver", "NAT");
    37573759                InsertConfigNode(pLunL0, "Config", &pCfg);
     
    39183920                if ((int)maTapFD[uInstance] >= 0)
    39193921                {
    3920                     if (fSniffer)
    3921                     {
    3922                         InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
    3923                     }
    3924                     else
    3925                     {
    3926                         InsertConfigNode(pInst, "LUN#0", &pLunL0);
    3927                     }
    39283922                    InsertConfigString(pLunL0, "Driver", "HostInterface");
    39293923                    InsertConfigNode(pLunL0, "Config", &pCfg);
     
    39353929                 * This is the new VBoxNetFlt+IntNet stuff.
    39363930                 */
    3937                 if (fSniffer)
    3938                 {
    3939                     InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
    3940                 }
    3941                 else
    3942                 {
    3943                     InsertConfigNode(pInst, "LUN#0", &pLunL0);
    3944                 }
    3945 
    39463931                Bstr BridgedIfName;
    39473932                hrc = aNetworkAdapter->COMGETTER(BridgedInterface)(BridgedIfName.asOutParam());
     
    43454330                if (!bstr.isEmpty())
    43464331                {
    4347                     if (fSniffer)
    4348                         InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
    4349                     else
    4350                         InsertConfigNode(pInst, "LUN#0", &pLunL0);
    43514332                    InsertConfigString(pLunL0, "Driver", "IntNet");
    43524333                    InsertConfigNode(pLunL0, "Config", &pCfg);
     
    43624343            case NetworkAttachmentType_HostOnly:
    43634344            {
    4364                 if (fSniffer)
    4365                     InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
    4366                 else
    4367                     InsertConfigNode(pInst, "LUN#0", &pLunL0);
    4368 
    43694345                InsertConfigString(pLunL0, "Driver", "IntNet");
    43704346                InsertConfigNode(pLunL0, "Config", &pCfg);
     
    45734549                                                     ComSafeArrayAsOutParam(values));       H();
    45744550
    4575                 if (fSniffer)
    4576                     InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
    4577                 else
    4578                     InsertConfigNode(pInst, "LUN#0", &pLunL0);
    45794551                InsertConfigString(pLunL0, "Driver", bstr);
    45804552                InsertConfigNode(pLunL0, "Config", &pCfg);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette