VirtualBox

Changeset 15372 in vbox for trunk/src


Ignore:
Timestamp:
Dec 12, 2008 2:51:29 PM (16 years ago)
Author:
vboxsync
Message:

#3282: HostNetIf API implementation for Darwin. Common part revised. Stubs for other platforms.

Location:
trunk/src/VBox
Files:
6 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r15235 r15372  
    4949        case HostNetworkInterfaceType_PPP: return "PPP";
    5050        case HostNetworkInterfaceType_SLIP: return "SLIP";
     51    }
     52    return "Unknown";
     53}
     54
     55static const char *getHostIfStatusText(HostNetworkInterfaceStatus_T enmStatus)
     56{
     57    switch (enmStatus)
     58    {
     59        case HostNetworkInterfaceStatus_Up: return "Up";
     60        case HostNetworkInterfaceStatus_Down: return "Down";
    5161    }
    5262    return "Unknown";
     
    204214                ComPtr<IHostNetworkInterface> networkInterface;
    205215                CHECK_RC_BREAK(enumerator->GetNext(networkInterface.asOutParam()));
     216#ifndef VBOX_WITH_HOSTNETIF_API
    206217                Bstr interfaceName;
    207218                networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
     
    210221                networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
    211222                RTPrintf("GUID:        %lS\n\n", Bstr(interfaceGuid.toString()).raw());
    212 #ifdef VBOX_WITH_HOSTNETIF_API
    213             ULONG IPAddress;
    214             networkInterface->COMGETTER(IPAddress)(&IPAddress);
    215             RTPrintf("IPAddress:       %d.%d.%d.%d\n",
    216                      ((uint8_t*)&IPAddress)[0],
    217                      ((uint8_t*)&IPAddress)[1],
    218                      ((uint8_t*)&IPAddress)[2],
    219                      ((uint8_t*)&IPAddress)[3]);
    220             ULONG NetworkMask;
    221             networkInterface->COMGETTER(NetworkMask)(&NetworkMask);
    222             RTPrintf("NetworkMask:     %d.%d.%d.%d\n",
    223                      ((uint8_t*)&NetworkMask)[0],
    224                      ((uint8_t*)&NetworkMask)[1],
    225                      ((uint8_t*)&NetworkMask)[2],
    226                      ((uint8_t*)&NetworkMask)[3]);
    227             Bstr IPV6Address;
    228             networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
    229             RTPrintf("IPV6Address:     %lS\n", IPV6Address.raw());
    230             Bstr HardwareAddress;
    231             networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
    232             RTPrintf("HardwareAddress: %lS\n", HardwareAddress.raw());
    233             HostNetworkInterfaceType_T Type;
    234             networkInterface->COMGETTER(Type)(&Type);
    235             RTPrintf("Type:            %s\n", getHostIfTypeText(Type));
    236             HostNetworkInterfaceStatus_T Status;
    237             networkInterface->COMGETTER(Status)(&Status);
    238             RTPrintf("Status:          %s\n\n", Status ? "Down":"Up");
     223#else /* VBOX_WITH_HOSTNETIF_API */
     224                Bstr interfaceName;
     225                networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
     226                RTPrintf("Name:            %lS\n", interfaceName.raw());
     227                Guid interfaceGuid;
     228                networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
     229                RTPrintf("GUID:            %lS\n", Bstr(interfaceGuid.toString()).raw());
     230                ULONG IPAddress;
     231                networkInterface->COMGETTER(IPAddress)(&IPAddress);
     232                RTPrintf("IPAddress:       %d.%d.%d.%d\n",
     233                         ((uint8_t*)&IPAddress)[0],
     234                         ((uint8_t*)&IPAddress)[1],
     235                         ((uint8_t*)&IPAddress)[2],
     236                         ((uint8_t*)&IPAddress)[3]);
     237                ULONG NetworkMask;
     238                networkInterface->COMGETTER(NetworkMask)(&NetworkMask);
     239                RTPrintf("NetworkMask:     %d.%d.%d.%d\n",
     240                         ((uint8_t*)&NetworkMask)[0],
     241                         ((uint8_t*)&NetworkMask)[1],
     242                         ((uint8_t*)&NetworkMask)[2],
     243                         ((uint8_t*)&NetworkMask)[3]);
     244                Bstr IPV6Address;
     245                networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
     246                RTPrintf("IPV6Address:     %lS\n", IPV6Address.raw());
     247                Bstr IPV6NetworkMask;
     248                networkInterface->COMGETTER(IPV6NetworkMask)(IPV6NetworkMask.asOutParam());
     249                RTPrintf("IPV6NetworkMask: %lS\n", IPV6NetworkMask.raw());
     250                Bstr HardwareAddress;
     251                networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
     252                RTPrintf("HardwareAddress: %lS\n", HardwareAddress.raw());
     253                HostNetworkInterfaceType_T Type;
     254                networkInterface->COMGETTER(Type)(&Type);
     255                RTPrintf("Type:            %s\n", getHostIfTypeText(Type));
     256                HostNetworkInterfaceStatus_T Status;
     257                networkInterface->COMGETTER(Status)(&Status);
     258                RTPrintf("Status:          %s\n\n", getHostIfStatusText(Status));
    239259#endif
    240260            }
  • trunk/src/VBox/Main/HostImpl.cpp

    r15235 r15372  
    117117#endif
    118118#ifdef VBOX_WITH_HOSTNETIF_API
    119 #include <iprt/netif.h>
     119#include "netif.h"
    120120#endif
    121121
     
    762762
    763763#ifdef VBOX_WITH_HOSTNETIF_API
    764     PRTNETIFINFO pIfs = RTNetIfList();
     764    PNETIFINFO pIfs = NetIfList();
    765765    while (pIfs)
    766766    {
  • trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp

    r15235 r15372  
    7272
    7373#ifdef VBOX_WITH_HOSTNETIF_API
     74static Bstr composeIPv6Address(PRTNETADDRIPV6 aAddrPtr)
     75{
     76    char szTmp[8*5];
     77
     78    RTStrPrintf(szTmp, sizeof(szTmp),
     79                "%02x%02x:%02x%02x:%02x%02x:%02x%02x:"
     80                "%02x%02x:%02x%02x:%02x%02x:%02x%02x",
     81                aAddrPtr->au8[0], aAddrPtr->au8[1],
     82                aAddrPtr->au8[2], aAddrPtr->au8[3],
     83                aAddrPtr->au8[4], aAddrPtr->au8[5],
     84                aAddrPtr->au8[6], aAddrPtr->au8[7],
     85                aAddrPtr->au8[8], aAddrPtr->au8[9],
     86                aAddrPtr->au8[10], aAddrPtr->au8[11],
     87                aAddrPtr->au8[12], aAddrPtr->au8[13],
     88                aAddrPtr->au8[14], aAddrPtr->au8[15]);
     89    return Bstr(szTmp);
     90}
     91
     92static Bstr composeHardwareAddress(PRTMAC aMacPtr)
     93{
     94    char szTmp[6*3];
     95
     96    RTStrPrintf(szTmp, sizeof(szTmp),
     97                "%02x:%02x:%02x:%02x:%02x:%02x",
     98                aMacPtr->au8[0], aMacPtr->au8[1],
     99                aMacPtr->au8[2], aMacPtr->au8[3],
     100                aMacPtr->au8[4], aMacPtr->au8[5]);
     101    return Bstr(szTmp);
     102}
     103
    74104/**
    75105 * Initializes the host object.
     
    79109 * @param   aGuid GUID of the host network interface
    80110 */
    81 HRESULT HostNetworkInterface::init (PRTNETIFINFO pIf)
     111HRESULT HostNetworkInterface::init (PNETIFINFO pIf)
    82112{
    83113//    LogFlowThisFunc (("aInterfaceName={%ls}, aGuid={%s}\n",
     
    86116//    ComAssertRet (aInterfaceName, E_INVALIDARG);
    87117//    ComAssertRet (!aGuid.isEmpty(), E_INVALIDARG);
    88     ComAssertRet (!pIf, E_INVALIDARG);
     118    ComAssertRet (pIf, E_INVALIDARG);
    89119
    90120    /* Enclose the state transition NotReady->InInit->Ready */
     
    94124    unconst (mInterfaceName) = Bstr(pIf->szName);
    95125    unconst (mGuid) = pIf->Uuid;
    96 //    m.IPAddress = pIf->IPAddress;
    97 //    m.networkMask = pIf->IPNetMask;
    98 //    m.IPv6Address = composeIPv6Address(pIf->IPv6Address, pIf->IPv6NetMask);
     126    m.IPAddress = pIf->IPAddress.u;
     127    m.networkMask = pIf->IPNetMask.u;
     128    m.IPV6Address = composeIPv6Address(&pIf->IPv6Address);
     129    m.IPV6NetworkMask = composeIPv6Address(&pIf->IPv6NetMask);
     130    m.hardwareAddress = composeHardwareAddress(&pIf->MACAddress);
     131    m.type = pIf->enmType;
     132    m.status = pIf->enmStatus;
    99133
    100134    /* Confirm a successful initialization */
     
    200234
    201235/**
     236 * Returns the IP V6 network mask of the host network interface.
     237 *
     238 * @returns COM status code
     239 * @param   aIPV6Mask address of result pointer
     240 */
     241STDMETHODIMP HostNetworkInterface::COMGETTER(IPV6NetworkMask) (BSTR *aIPV6Mask)
     242{
     243    CheckComArgOutPointerValid(aIPV6Mask);
     244
     245    AutoCaller autoCaller (this);
     246    CheckComRCReturnRC (autoCaller.rc());
     247
     248    m.IPV6NetworkMask.cloneTo (aIPV6Mask);
     249
     250    return S_OK;
     251}
     252
     253/**
    202254 * Returns the hardware address of the host network interface.
    203255 *
  • trunk/src/VBox/Main/Makefile.kmk

    r15235 r15372  
    341341endif
    342342
     343ifdef VBOX_WITH_HOSTNETIF_API
     344 VBoxSVC_SOURCES.win     +=     win/NetIfList-win.cpp
     345 VBoxSVC_SOURCES.linux   +=   linux/NetIfList-linux.cpp
     346 VBoxSVC_SOURCES.os2     +=     os2/NetIfList-os2.cpp
     347 VBoxSVC_SOURCES.darwin  +=  darwin/NetIfList-darwin.cpp
     348 VBoxSVC_SOURCES.solaris += solaris/NetIfList-solaris.cpp
     349 VBoxSVC_DEFS            += VBOX_WITH_HOSTNETIF_API
     350endif
     351
    343352win/VBoxSVC.rc_INCS  = $(PATH_VBoxSVC)
    344353win/VBoxSVC.rc_DEPS  = $(PATH_VBoxSVC)/VBoxSVC.rgs $(PATH_VBoxSVC)/VBoxSVC-icon.rc
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r15335 r15372  
    59025902    </desc>
    59035903
    5904     <const name="Up" value="0">
     5904    <const name="Unknown" value="0">
     5905      <desc>
     5906        The state of interface cannot be determined.
     5907      </desc>
     5908    </const>
     5909    <const name="Up" value="1">
    59055910      <desc>
    59065911        The interface is fully operational.
    59075912      </desc>
    59085913    </const>
    5909     <const name="Down" value="1">
     5914    <const name="Down" value="2">
    59105915      <desc>
    59115916        The interface is not functioning.
     
    59375942    <attribute name="IPV6Address" type="wstring" readonly="yes">
    59385943      <desc>Returns the IP V6 address of the interface.</desc>
     5944    </attribute>
     5945
     5946    <attribute name="IPV6NetworkMask" type="wstring" readonly="yes">
     5947      <desc>Returns the IP V6 network mask of the interface.</desc>
    59395948    </attribute>
    59405949
  • trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h

    r15235 r15372  
    2828#include "Collection.h"
    2929#ifdef VBOX_WITH_HOSTNETIF_API
    30 #include "iprt/netif.h"
     30#include "netif.h"
    3131#endif
    3232
     
    6060    HRESULT init (Bstr interfaceName, Guid guid);
    6161#ifdef VBOX_WITH_HOSTNETIF_API
    62     HRESULT init (PRTNETIFINFO pIfs);
     62    HRESULT init (PNETIFINFO pIfs);
    6363#endif
    6464
     
    6969    STDMETHOD(COMGETTER(NetworkMask)) (ULONG *aNetworkMask);
    7070    STDMETHOD(COMGETTER(IPV6Address)) (BSTR *aIPV6Address);
     71    STDMETHOD(COMGETTER(IPV6NetworkMask)) (BSTR *aIPV6Mask);
    7172    STDMETHOD(COMGETTER(HardwareAddress)) (BSTR *aHardwareAddress);
    7273    STDMETHOD(COMGETTER(Type)) (HostNetworkInterfaceType_T *aType);
     
    8889        ULONG networkMask;
    8990        Bstr IPV6Address;
     91        Bstr IPV6NetworkMask;
    9092        Bstr hardwareAddress;
    9193        HostNetworkInterfaceType_T type;
  • trunk/src/VBox/Runtime/Makefile.kmk

    r15301 r15372  
    287287        r3/tcp.cpp
    288288
    289 ifdef VBOX_WITH_HOSTNETIF_API
    290  RuntimeR3_SOURCES     += \
    291         generic/RTNetIfList-generic.cpp
    292  RuntimeR3_DEFS        += VBOX_WITH_HOSTNETIF_API
    293 endif
    294 
    295289#if1of ($(KBUILD_TARGET_ARCH),amd64 x86)
    296290# RuntimeR3_SOURCES += common/time/timesupA.asm
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