VirtualBox

Changeset 15372 in vbox for trunk/src/VBox/Main


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/Main
Files:
6 added
5 edited

Legend:

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