VirtualBox

Changeset 36615 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 7, 2011 12:45:27 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71064
Message:

Main/idl: new method IHost::generateMACAddress, including implementation

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r36276 r36615  
    69466946  <interface
    69476947    name="IHost" extends="$unknown"
    6948     uuid="35b004f4-7806-4009-bfa8-d1308adba7e5"
     6948    uuid="dab4a2b8-c735-4f08-94fc-9bec84182e2f"
    69496949    wsmap="managed"
    69506950    >
     
    73777377      <param name="device" type="IHostUSBDevice" dir="return">
    73787378        <desc>Found USB device object.</desc>
     7379      </param>
     7380    </method>
     7381
     7382    <method name="generateMACAddress">
     7383      <desc>
     7384        Generates a valid Ethernet MAC address, 12 hexadecimal characters.
     7385      </desc>
     7386      <param name="address" type="wstring" dir="return">
     7387        <desc>New Ethernet MAC address.</desc>
    73797388      </param>
    73807389    </method>
  • trunk/src/VBox/Main/include/HostImpl.h

    r35813 r36615  
    55
    66/*
    7  * Copyright (C) 2006-2009 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5757
    5858    // IHost properties
    59     STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut (IMedium *, drives));
    60     STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut (IMedium *, drives));
    61     STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut (IHostUSBDevice *, aUSBDevices));
    62     STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut (IHostUSBDeviceFilter *, aUSBDeviceFilters));
    63     STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
     59    STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut(IMedium *, drives));
     60    STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut(IMedium *, drives));
     61    STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut(IHostUSBDevice *, aUSBDevices));
     62    STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut(IHostUSBDeviceFilter *, aUSBDeviceFilters));
     63    STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut(IHostNetworkInterface *, aNetworkInterfaces));
    6464    STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
    6565    STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count);
     
    6767    STDMETHOD(GetProcessorSpeed)(ULONG cpuId, ULONG *speed);
    6868    STDMETHOD(GetProcessorDescription)(ULONG cpuId, BSTR *description);
    69     STDMETHOD(GetProcessorFeature) (ProcessorFeature_T feature, BOOL *supported);
     69    STDMETHOD(GetProcessorFeature)(ProcessorFeature_T feature, BOOL *supported);
    7070    STDMETHOD(GetProcessorCPUIDLeaf)(ULONG aCpuId, ULONG aLeaf, ULONG aSubLeaf, ULONG *aValEAX, ULONG *aValEBX, ULONG *aValECX, ULONG *aValEDX);
    7171    STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
     
    7777
    7878    // IHost methods
    79     STDMETHOD(CreateHostOnlyNetworkInterface) (IHostNetworkInterface **aHostNetworkInterface,
    80                                                IProgress **aProgress);
    81     STDMETHOD(RemoveHostOnlyNetworkInterface) (IN_BSTR aId, IProgress **aProgress);
    82     STDMETHOD(CreateUSBDeviceFilter) (IN_BSTR aName, IHostUSBDeviceFilter **aFilter);
    83     STDMETHOD(InsertUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter *aFilter);
    84     STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition);
     79    STDMETHOD(CreateHostOnlyNetworkInterface)(IHostNetworkInterface **aHostNetworkInterface,
     80                                              IProgress **aProgress);
     81    STDMETHOD(RemoveHostOnlyNetworkInterface)(IN_BSTR aId, IProgress **aProgress);
     82    STDMETHOD(CreateUSBDeviceFilter)(IN_BSTR aName, IHostUSBDeviceFilter **aFilter);
     83    STDMETHOD(InsertUSBDeviceFilter)(ULONG aPosition, IHostUSBDeviceFilter *aFilter);
     84    STDMETHOD(RemoveUSBDeviceFilter)(ULONG aPosition);
    8585
    86     STDMETHOD(FindHostDVDDrive) (IN_BSTR aName, IMedium **aDrive);
    87     STDMETHOD(FindHostFloppyDrive) (IN_BSTR aName, IMedium **aDrive);
    88     STDMETHOD(FindHostNetworkInterfaceByName) (IN_BSTR aName, IHostNetworkInterface **networkInterface);
    89     STDMETHOD(FindHostNetworkInterfaceById) (IN_BSTR id, IHostNetworkInterface **networkInterface);
    90     STDMETHOD(FindHostNetworkInterfacesOfType) (HostNetworkInterfaceType_T type, ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
    91     STDMETHOD(FindUSBDeviceByAddress) (IN_BSTR aAddress, IHostUSBDevice **aDevice);
    92     STDMETHOD(FindUSBDeviceById) (IN_BSTR aId, IHostUSBDevice **aDevice);
     86    STDMETHOD(FindHostDVDDrive)(IN_BSTR aName, IMedium **aDrive);
     87    STDMETHOD(FindHostFloppyDrive)(IN_BSTR aName, IMedium **aDrive);
     88    STDMETHOD(FindHostNetworkInterfaceByName)(IN_BSTR aName, IHostNetworkInterface **networkInterface);
     89    STDMETHOD(FindHostNetworkInterfaceById)(IN_BSTR id, IHostNetworkInterface **networkInterface);
     90    STDMETHOD(FindHostNetworkInterfacesOfType)(HostNetworkInterfaceType_T type, ComSafeArrayOut(IHostNetworkInterface *, aNetworkInterfaces));
     91    STDMETHOD(FindUSBDeviceByAddress)(IN_BSTR aAddress, IHostUSBDevice **aDevice);
     92    STDMETHOD(FindUSBDeviceById)(IN_BSTR aId, IHostUSBDevice **aDevice);
     93    STDMETHOD(GenerateMACAddress)(BSTR *aAddress);
    9394
    9495    // public methods only for internal purposes
     
    125126#endif /* !VBOX_WITH_USB */
    126127
     128    static void generateMACAddress(Utf8Str &mac);
     129
    127130private:
    128131
     
    143146
    144147#ifdef VBOX_WITH_RESOURCE_USAGE_API
    145     void registerMetrics (PerformanceCollector *aCollector);
    146     void unregisterMetrics (PerformanceCollector *aCollector);
     148    void registerMetrics(PerformanceCollector *aCollector);
     149    void unregisterMetrics(PerformanceCollector *aCollector);
    147150#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    148151
  • trunk/src/VBox/Main/src-server/HostImpl.cpp

    r36451 r36615  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    15111511    return E_NOTIMPL;
    15121512#endif  /* !VBOX_WITH_USB */
     1513}
     1514
     1515STDMETHODIMP Host::GenerateMACAddress(BSTR *aAddress)
     1516{
     1517    CheckComArgOutPointerValid(aAddress);
     1518    // no locking required
     1519    Utf8Str mac;
     1520    generateMACAddress(mac);
     1521    Bstr(mac).cloneTo(aAddress);
     1522    return S_OK;
    15131523}
    15141524
     
    27962806                                                    ramUsageFree);
    27972807    aCollector->registerBaseMetric (ramUsage);
    2798     pm::BaseMetric *ramVmm = new pm::HostRamVmm(aCollector->getGuestManager(), objptr, 
     2808    pm::BaseMetric *ramVmm = new pm::HostRamVmm(aCollector->getGuestManager(), objptr,
    27992809                                                ramVMMUsed,
    28002810                                                ramVMMFree,
     
    28982908}
    28992909
     2910
     2911/* static */
     2912void Host::generateMACAddress(Utf8Str &mac)
     2913{
     2914    /*
     2915     * Our strategy is as follows: the first three bytes are our fixed
     2916     * vendor ID (080027). The remaining 3 bytes will be taken from the
     2917     * start of a GUID. This is a fairly safe algorithm.
     2918     */
     2919    Guid guid;
     2920    guid.create();
     2921    mac = Utf8StrFmt("080027%02X%02X%02X",
     2922                     guid.raw()->au8[0], guid.raw()->au8[1], guid.raw()->au8[2]);
     2923}
     2924
    29002925#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    29012926
  • trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp

    r36276 r36615  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2222#include "MachineImpl.h"
    2323#include "GuestOSTypeImpl.h"
     24#include "HostImpl.h"
    2425
    2526#include <iprt/string.h>
     
    12651266        if (FAILED(rc)) return rc;
    12661267    }
    1267    
     1268
    12681269    // leave the lock before attaching
    12691270    alock.release();
     
    15731574void NetworkAdapter::generateMACAddress()
    15741575{
    1575     /*
    1576      * Our strategy is as follows: the first three bytes are our fixed
    1577      * vendor ID (080027). The remaining 3 bytes will be taken from the
    1578      * start of a GUID. This is a fairly safe algorithm.
    1579      */
    1580     char strMAC[13];
    1581     Guid guid;
    1582     guid.create();
    1583     RTStrPrintf (strMAC, sizeof(strMAC), "080027%02X%02X%02X",
    1584                  guid.raw()->au8[0], guid.raw()->au8[1], guid.raw()->au8[2]);
    1585     LogFlowThisFunc(("generated MAC: '%s'\n", strMAC));
    1586     mData->mMACAddress = strMAC;
     1576    Utf8Str mac;
     1577    Host::generateMACAddress(mac);
     1578    LogFlowThisFunc(("generated MAC: '%s'\n", mac.c_str()));
     1579    mData->mMACAddress = mac;
    15871580}
    15881581
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