VirtualBox

Ignore:
Timestamp:
Dec 16, 2008 10:39:34 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
41079
Message:

#3282: Collection got replaced with safe array. Warning, windows builds/tests may break.

File:
1 edited

Legend:

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

    r15372 r15570  
    203203        ComPtr<IHost> host;
    204204        CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
    205         ComPtr<IHostNetworkInterfaceCollection> coll;
    206         ComPtr<IHostNetworkInterfaceEnumerator> enumerator;
    207         CHECK_ERROR(host, COMGETTER(NetworkInterfaces)(coll.asOutParam()));
    208         if (SUCCEEDED(rc) && coll)
    209         {
    210             CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
    211             BOOL hasMore;
    212             while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
    213             {
    214                 ComPtr<IHostNetworkInterface> networkInterface;
    215                 CHECK_RC_BREAK(enumerator->GetNext(networkInterface.asOutParam()));
     205        com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
     206        CHECK_ERROR(host,
     207                    COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces)));
     208        for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
     209        {
     210            ComPtr<IHostNetworkInterface> networkInterface = hostNetworkInterfaces[i];
    216211#ifndef VBOX_WITH_HOSTNETIF_API
    217                 Bstr interfaceName;
    218                 networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
    219                 RTPrintf("Name:        %lS\n", interfaceName.raw());
    220                 Guid interfaceGuid;
    221                 networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
    222                 RTPrintf("GUID:        %lS\n\n", Bstr(interfaceGuid.toString()).raw());
     212            Bstr interfaceName;
     213            networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
     214            RTPrintf("Name:        %lS\n", interfaceName.raw());
     215            Guid interfaceGuid;
     216            networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
     217            RTPrintf("GUID:        %lS\n\n", Bstr(interfaceGuid.toString()).raw());
    223218#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));
     219            Bstr interfaceName;
     220            networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
     221            RTPrintf("Name:            %lS\n", interfaceName.raw());
     222            Guid interfaceGuid;
     223            networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
     224            RTPrintf("GUID:            %lS\n", Bstr(interfaceGuid.toString()).raw());
     225            ULONG IPAddress;
     226            networkInterface->COMGETTER(IPAddress)(&IPAddress);
     227            RTPrintf("IPAddress:       %d.%d.%d.%d\n",
     228                     ((uint8_t*)&IPAddress)[0],
     229                     ((uint8_t*)&IPAddress)[1],
     230                     ((uint8_t*)&IPAddress)[2],
     231                     ((uint8_t*)&IPAddress)[3]);
     232            ULONG NetworkMask;
     233            networkInterface->COMGETTER(NetworkMask)(&NetworkMask);
     234            RTPrintf("NetworkMask:     %d.%d.%d.%d\n",
     235                     ((uint8_t*)&NetworkMask)[0],
     236                     ((uint8_t*)&NetworkMask)[1],
     237                     ((uint8_t*)&NetworkMask)[2],
     238                     ((uint8_t*)&NetworkMask)[3]);
     239            Bstr IPV6Address;
     240            networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
     241            RTPrintf("IPV6Address:     %lS\n", IPV6Address.raw());
     242            Bstr IPV6NetworkMask;
     243            networkInterface->COMGETTER(IPV6NetworkMask)(IPV6NetworkMask.asOutParam());
     244            RTPrintf("IPV6NetworkMask: %lS\n", IPV6NetworkMask.raw());
     245            Bstr HardwareAddress;
     246            networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
     247            RTPrintf("HardwareAddress: %lS\n", HardwareAddress.raw());
     248            HostNetworkInterfaceType_T Type;
     249            networkInterface->COMGETTER(Type)(&Type);
     250            RTPrintf("Type:            %s\n", getHostIfTypeText(Type));
     251            HostNetworkInterfaceStatus_T Status;
     252            networkInterface->COMGETTER(Status)(&Status);
     253            RTPrintf("Status:          %s\n\n", getHostIfStatusText(Status));
    259254#endif
    260             }
    261255        }
    262256    }
Note: See TracChangeset for help on using the changeset viewer.

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