VirtualBox

Changeset 13426 in vbox


Ignore:
Timestamp:
Oct 21, 2008 9:59:54 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
38186
Message:

Main/Solaris: Enumerate NICs for zones, fixed duplicate enumeration.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/HostImpl.cpp

    r13286 r13426  
    5454# ifdef VBOX_SOLARIS_NSL_RESOLVED
    5555#  include <libdevinfo.h>
    56 # else
    57 #  include <net/if.h>
    58 #  include <sys/socket.h>
    59 #  include <sys/sockio.h>
    60 #  include <net/if_arp.h>
    61 #  include <net/if.h>
    62 # endif /* VBOX_SOLARIS_USE_DEVINFO */
     56# endif
     57# include <net/if.h>
     58# include <sys/socket.h>
     59# include <sys/sockio.h>
     60# include <net/if_arp.h>
     61# include <net/if.h>
    6362# include <sys/types.h>
    6463# include <sys/stat.h>
     
    617616{
    618617    /*
    619      * Clip off the instance number from the interface name.
     618     * Clip off the zone instance number from the interface name (if any).
     619     */
     620    char szIfaceName[128];
     621    strcpy(szIfaceName, pszIface);
     622    char *pszColon = (char *)memchr(szIfaceName, ':', sizeof(szIfaceName));
     623    if (pszColon)
     624        *pszColon = '\0';
     625
     626    /*
     627     * Get the instance number from the interface name, then clip it off.
    620628     */
    621629    int cbInstance = 0;
    622     int cbIface = strlen(pszIface);
     630    int cbIface = strlen(szIfaceName);
    623631    const char *pszEnd = pszIface + cbIface - 1;
    624632    for (int i = 0; i < cbIface - 1; i++)
     
    630638    }
    631639
     640    int Instance = atoi(pszEnd + 1);
     641    strncpy(szIfaceName, pszIface, cbIface - cbInstance);
     642    szIfaceName[cbIface - cbInstance] = '\0';
     643
    632644    /*
    633645     * Add the interface.
    634646     */
    635     char szIfaceName[128];
    636     strncpy(szIfaceName, pszIface, cbIface - cbInstance);
    637     szIfaceName[cbIface - cbInstance] = '\0';
    638     int Instance = atoi(pszEnd + 1);
    639647    vboxSolarisAddHostIface(szIfaceName, Instance, NULL, pvHostNetworkInterfaceList);
    640648
     
    643651     */
    644652    return _B_FALSE;
     653}
     654
     655static bool vboxSolarisSortNICList(const ComObjPtr <HostNetworkInterface> Iface1, const ComObjPtr <HostNetworkInterface> Iface2)
     656{
     657    Bstr Iface1Str;
     658    (*Iface1).COMGETTER(Name) (Iface1Str.asOutParam());
     659
     660    Bstr Iface2Str;
     661    (*Iface2).COMGETTER(Name) (Iface2Str.asOutParam());
     662
     663    return Iface1Str < Iface2Str;   
     664}
     665
     666static bool vboxSolarisSameNIC(const ComObjPtr <HostNetworkInterface> Iface1, const ComObjPtr <HostNetworkInterface> Iface2)
     667{
     668    Bstr Iface1Str;
     669    (*Iface1).COMGETTER(Name) (Iface1Str.asOutParam());
     670
     671    Bstr Iface2Str;
     672    (*Iface2).COMGETTER(Name) (Iface2Str.asOutParam());
     673
     674    return (Iface1Str == Iface2Str);
    645675}
    646676
     
    663693        return DI_WALK_CONTINUE;
    664694}
    665 
    666 static bool vboxSolarisSameNIC(ComObjPtr <HostNetworkInterface> Iface1, ComObjPtr <HostNetworkInterface> Iface2)
    667 {
    668     Bstr Iface1Str;
    669     (*Iface1).COMGETTER(Name) (Iface1Str.asOutParam());
    670 
    671     Bstr Iface2Str;
    672     (*Iface2).COMGETTER(Name) (Iface2Str.asOutParam());
    673 
    674     return (Iface1Str == Iface2Str);
    675 }
    676 
    677 # endif /* VBOX_SOLARIS_USE_DEVINFO */
     695# endif /* VBOX_SOLARIS_NSL_RESOLVED */
    678696
    679697#endif
     
    10671085# elif defined(RT_OS_SOLARIS)
    10681086
    1069 #ifdef VBOX_SOLARIS_NSL_RESOLVED
     1087#  ifdef VBOX_SOLARIS_NSL_RESOLVED
    10701088
    10711089    /*
     
    10861104        g_pfnLibDlpiWalk(vboxSolarisAddLinkHostIface, &list, 0);
    10871105
    1088     /*
    1089      * Weed out duplicates caused by dlpi_walk inconsistencies across Nevadas.
    1090      */
    1091     list.unique(vboxSolarisSameNIC);
    1092 
    1093 #else
     1106#  endif    /* VBOX_SOLARIS_NSL_RESOLVED */
     1107
    10941108    /*
    10951109     * This gets only the list of all plumbed logical interfaces.
     1110     * This is needed for zones which cannot access the device tree
     1111     * and in this case we just let them use the list of plumbed interfaces
     1112     * on the zone.
    10961113     */
    10971114    int Sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
     
    11131130            if (!rc)
    11141131            {
    1115                 /*
    1116                  * Ok now we go the interfaces, get the info we need (i.e MAC address).
    1117                  */
    11181132                for (int i = 0; i < IfNum.lifn_count; i++)
    11191133                {
     
    11241138                        continue;
    11251139
     1140#if 0
    11261141                    rc = ioctl(Sock, SIOCGLIFADDR, &(Ifaces[i]));
    11271142                    if (!rc)
     
    11491164                        vboxSolarisAddLinkHostIface(pszIface, &list);
    11501165                    }
     1166#endif
     1167
     1168                    char *pszIface = Ifaces[i].lifr_name;
     1169                    vboxSolarisAddLinkHostIface(pszIface, &list);
    11511170                }
    11521171            }
     
    11541173        close(Sock);
    11551174    }
    1156 #endif
     1175
     1176    /*
     1177     * Weed out duplicates caused by dlpi_walk inconsistencies across Nevadas.
     1178     */
     1179    list.sort(vboxSolarisSortNICList);
     1180    list.unique(vboxSolarisSameNIC);
    11571181
    11581182# elif defined RT_OS_WINDOWS
  • trunk/src/VBox/Main/Makefile.kmk

    r13222 r13426  
    238238 ifdef VBOX_SOLARIS_NSL_RESOLVED
    239239  VBoxSVC_LIBS.solaris += devinfo
    240  else
    241   VBoxSVC_LIBS.solaris += socket
    242240 endif
     241 VBoxSVC_LIBS.solaris += socket
    243242endif
    244243ifdef VBOX_WITH_USB
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