VirtualBox

Changeset 36615 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Apr 7, 2011 12:45:27 PM (14 years ago)
Author:
vboxsync
Message:

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

Location:
trunk/src/VBox/Main/src-server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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