Changeset 68026 in vbox
- Timestamp:
- Jul 18, 2017 2:15:32 PM (7 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 9 edited
-
idl/VirtualBox.xidl (modified) (1 diff)
-
include/HostNetworkInterfaceImpl.h (modified) (3 diffs)
-
include/netif.h (modified) (1 diff)
-
src-client/ConsoleImpl2.cpp (modified) (4 diffs)
-
src-server/HostNetworkInterfaceImpl.cpp (modified) (5 diffs)
-
src-server/darwin/NetIf-darwin.cpp (modified) (1 diff)
-
src-server/freebsd/NetIf-freebsd.cpp (modified) (2 diffs)
-
src-server/linux/NetIf-linux.cpp (modified) (2 diffs)
-
src-server/win/NetIf-win.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r68024 r68026 8927 8927 </attribute> 8928 8928 8929 <attribute name="wireless" type="boolean" readonly="yes"> 8930 <desc>Specifies whether the interface is wireless.</desc> 8931 </attribute> 8932 8929 8933 <method name="enableStaticIPConfig"> 8930 8934 <desc>sets and enables the static IP V4 configuration for the given interface.</desc> -
trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h
r65120 r68026 70 70 HRESULT getInterfaceType(HostNetworkInterfaceType_T *aType); 71 71 HRESULT getNetworkName(com::Utf8Str &aNetworkName); 72 HRESULT getWireless(BOOL *aWireless); 72 73 73 74 // Wrapped IHostNetworkInterface methods … … 93 94 Data() : IPAddress(0), networkMask(0), dhcpEnabled(FALSE), 94 95 mediumType(HostNetworkInterfaceMediumType_Unknown), 95 status(HostNetworkInterfaceStatus_Down) {}96 status(HostNetworkInterfaceStatus_Down), wireless(FALSE){} 96 97 97 98 ULONG IPAddress; … … 108 109 HostNetworkInterfaceStatus_T status; 109 110 ULONG speedMbits; 111 BOOL wireless; 110 112 } m; 111 113 -
trunk/src/VBox/Main/include/netif.h
r67566 r68026 68 68 RTNETADDRIPV6 IPv6Address; 69 69 RTNETADDRIPV6 IPv6NetMask; 70 BOOL bDhcpEnabled; 71 BOOL bIsDefault; 70 BOOL fDhcpEnabled; 71 BOOL fIsDefault; 72 BOOL fWireless; 72 73 RTMAC MACAddress; 73 74 NETIFTYPE enmMediumType; -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r67918 r68026 104 104 # include <linux/types.h> 105 105 # include <linux/if.h> 106 # include <linux/wireless.h>107 106 # elif defined(RT_OS_FREEBSD) 108 107 # include <unistd.h> … … 5185 5184 const char *pszBridgedIfName = BridgedIfNameUtf8.c_str(); 5186 5185 5186 ComPtr<IHostNetworkInterface> hostInterface; 5187 hrc = host->FindHostNetworkInterfaceByName(BridgedIfName.raw(), 5188 hostInterface.asOutParam()); 5189 if (!SUCCEEDED(hrc)) 5190 { 5191 AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: FindByName failed, rc=%Rhrc (0x%x)", hrc, hrc)); 5192 return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS, 5193 N_("Nonexistent host networking interface, name '%ls'"), 5194 BridgedIfName.raw()); 5195 } 5196 5187 5197 # if defined(RT_OS_DARWIN) 5188 5198 /* The name is on the form 'ifX: long name', chop it off at the colon. */ … … 5230 5240 5231 5241 # elif defined(RT_OS_WINDOWS) 5232 ComPtr<IHostNetworkInterface> hostInterface;5233 hrc = host->FindHostNetworkInterfaceByName(BridgedIfName.raw(),5234 hostInterface.asOutParam());5235 if (!SUCCEEDED(hrc))5236 {5237 AssertLogRelMsgFailed(("NetworkAttachmentType_Bridged: FindByName failed, rc=%Rhrc (0x%x)", hrc, hrc));5238 return VMSetError(VMR3GetVM(mpUVM), VERR_INTERNAL_ERROR, RT_SRC_POS,5239 N_("Nonexistent host networking interface, name '%ls'"),5240 BridgedIfName.raw());5241 }5242 5243 5242 HostNetworkInterfaceType_T eIfType; 5244 5243 hrc = hostInterface->COMGETTER(InterfaceType)(&eIfType); … … 5423 5422 trunkType = Bstr(TRUNKTYPE_NETFLT); 5424 5423 5425 # if defined(RT_OS_DARWIN) 5426 /** @todo Come up with a better deal here. Problem is that IHostNetworkInterface is completely useless here. */ 5427 if ( strstr(pszBridgedIfName, "Wireless") 5428 || strstr(pszBridgedIfName, "AirPort" )) 5424 BOOL fSharedMacOnWire = false; 5425 hrc = hostInterface->COMGETTER(Wireless)(&fSharedMacOnWire); 5426 if (FAILED(hrc)) 5427 { 5428 LogRel(("NetworkAttachmentType_Bridged: COMGETTER(Wireless) failed, hrc (0x%x)\n", hrc)); 5429 H(); 5430 } 5431 else if (fSharedMacOnWire) 5432 { 5429 5433 InsertConfigInteger(pCfg, "SharedMacOnWire", true); 5430 # elif defined(RT_OS_LINUX) 5431 int iSock = socket(AF_INET, SOCK_DGRAM, 0); 5432 if (iSock >= 0) 5433 { 5434 struct iwreq WRq; 5435 5436 RT_ZERO(WRq); 5437 strncpy(WRq.ifr_name, pszBridgedIfName, IFNAMSIZ); 5438 bool fSharedMacOnWire = ioctl(iSock, SIOCGIWNAME, &WRq) >= 0; 5439 close(iSock); 5440 if (fSharedMacOnWire) 5441 { 5442 InsertConfigInteger(pCfg, "SharedMacOnWire", true); 5443 Log(("Set SharedMacOnWire\n")); 5444 } 5445 else 5446 Log(("Failed to get wireless name\n")); 5447 } 5448 else 5449 Log(("Failed to open wireless socket\n")); 5450 # elif defined(RT_OS_FREEBSD) 5451 int iSock = socket(AF_INET, SOCK_DGRAM, 0); 5452 if (iSock >= 0) 5453 { 5454 struct ieee80211req WReq; 5455 uint8_t abData[32]; 5456 5457 RT_ZERO(WReq); 5458 strncpy(WReq.i_name, pszBridgedIfName, sizeof(WReq.i_name)); 5459 WReq.i_type = IEEE80211_IOC_SSID; 5460 WReq.i_val = -1; 5461 WReq.i_data = abData; 5462 WReq.i_len = sizeof(abData); 5463 5464 bool fSharedMacOnWire = ioctl(iSock, SIOCG80211, &WReq) >= 0; 5465 close(iSock); 5466 if (fSharedMacOnWire) 5467 { 5468 InsertConfigInteger(pCfg, "SharedMacOnWire", true); 5469 Log(("Set SharedMacOnWire\n")); 5470 } 5471 else 5472 Log(("Failed to get wireless name\n")); 5473 } 5474 else 5475 Log(("Failed to open wireless socket\n")); 5476 # elif defined(RT_OS_WINDOWS) 5477 # define DEVNAME_PREFIX L"\\\\.\\" 5478 /* we are getting the medium type via IOCTL_NDIS_QUERY_GLOBAL_STATS Io Control 5479 * there is a pretty long way till there though since we need to obtain the symbolic link name 5480 * for the adapter device we are going to query given the device Guid */ 5481 5482 5483 /* prepend the "\\\\.\\" to the bind name to obtain the link name */ 5484 5485 wchar_t FileName[MAX_PATH]; 5486 wcscpy(FileName, DEVNAME_PREFIX); 5487 wcscpy((wchar_t*)(((char*)FileName) + sizeof(DEVNAME_PREFIX) - sizeof(FileName[0])), pswzBindName); 5488 5489 /* open the device */ 5490 HANDLE hDevice = CreateFile(FileName, 5491 GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 5492 NULL, 5493 OPEN_EXISTING, 5494 FILE_ATTRIBUTE_NORMAL, 5495 NULL); 5496 5497 if (hDevice != INVALID_HANDLE_VALUE) 5498 { 5499 bool fSharedMacOnWire = false; 5500 5501 /* now issue the OID_GEN_PHYSICAL_MEDIUM query */ 5502 DWORD Oid = OID_GEN_PHYSICAL_MEDIUM; 5503 NDIS_PHYSICAL_MEDIUM PhMedium; 5504 DWORD cbResult; 5505 if (DeviceIoControl(hDevice, 5506 IOCTL_NDIS_QUERY_GLOBAL_STATS, 5507 &Oid, 5508 sizeof(Oid), 5509 &PhMedium, 5510 sizeof(PhMedium), 5511 &cbResult, 5512 NULL)) 5513 { 5514 /* that was simple, now examine PhMedium */ 5515 if ( PhMedium == NdisPhysicalMediumWirelessWan 5516 || PhMedium == NdisPhysicalMediumWirelessLan 5517 || PhMedium == NdisPhysicalMediumNative802_11 5518 || PhMedium == NdisPhysicalMediumBluetooth) 5519 fSharedMacOnWire = true; 5520 } 5521 else 5522 { 5523 int winEr = GetLastError(); 5524 LogRel(("Console::configNetwork: DeviceIoControl failed, err (0x%x), ignoring\n", winEr)); 5525 Assert(winEr == ERROR_INVALID_PARAMETER || winEr == ERROR_NOT_SUPPORTED || winEr == ERROR_BAD_COMMAND); 5526 } 5527 CloseHandle(hDevice); 5528 5529 if (fSharedMacOnWire) 5530 { 5531 Log(("this is a wireless adapter")); 5532 InsertConfigInteger(pCfg, "SharedMacOnWire", true); 5533 Log(("Set SharedMacOnWire\n")); 5534 } 5535 else 5536 Log(("this is NOT a wireless adapter")); 5537 } 5538 else 5539 { 5540 int winEr = GetLastError(); 5541 AssertLogRelMsgFailed(("Console::configNetwork: CreateFile failed, err (0x%x), ignoring\n", winEr)); 5542 } 5543 5544 CoTaskMemFree(pswzBindName); 5545 5546 pAdaptorComponent.setNull(); 5547 /* release the pNc finally */ 5548 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE /*fHasWriteLock*/); 5549 # else 5550 /** @todo PORTME: wireless detection */ 5551 # endif 5434 Log(("Set SharedMacOnWire\n")); 5435 } 5552 5436 5553 5437 # if defined(RT_OS_SOLARIS) -
trunk/src/VBox/Main/src-server/HostNetworkInterfaceImpl.cpp
r67636 r68026 167 167 m.realIPAddress = m.IPAddress = info.IPAddress.u; 168 168 m.realNetworkMask = m.networkMask = info.IPNetMask.u; 169 m.dhcpEnabled = info. bDhcpEnabled;169 m.dhcpEnabled = info.fDhcpEnabled; 170 170 if (info.IPv6Address.s.Lo || info.IPv6Address.s.Hi) 171 171 m.realIPV6Address = m.IPV6Address = Bstr(Utf8StrFmt("%RTnaipv6", &info.IPv6Address)); … … 183 183 #endif /* !RT_OS_WINDOWS */ 184 184 m.speedMbits = info.uSpeedMbits; 185 m.wireless = info.fWireless; 185 186 return S_OK; 186 187 } … … 236 237 RTNetMaskToPrefixIPv6(&pIf->IPv6NetMask, &iPrefixIPv6); 237 238 m.realIPV6PrefixLength = m.IPV6NetworkMaskPrefixLength = iPrefixIPv6; 238 m.dhcpEnabled = pIf-> bDhcpEnabled;239 m.dhcpEnabled = pIf->fDhcpEnabled; 239 240 m.hardwareAddress = Bstr(Utf8StrFmt("%RTmac", &pIf->MACAddress)); 240 241 #ifdef RT_OS_WINDOWS … … 246 247 #endif /* !RT_OS_WINDOWS */ 247 248 m.speedMbits = pIf->uSpeedMbits; 249 m.wireless = pIf->fWireless; 248 250 249 251 /* Confirm a successful initialization */ … … 444 446 { 445 447 aNetworkName = mNetworkName; 448 449 return S_OK; 450 } 451 452 HRESULT HostNetworkInterface::getWireless(BOOL *aWireless) 453 { 454 *aWireless = m.wireless; 446 455 447 456 return S_OK; -
trunk/src/VBox/Main/src-server/darwin/NetIf-darwin.cpp
r65088 r68026 361 361 memcpy(pNew->szName, pNIC->szName, cbNameLen); 362 362 pNew->Uuid = pNIC->Uuid; 363 pNew->fWireless = pNIC->fWireless; 363 364 } 364 365 else -
trunk/src/VBox/Main/src-server/freebsd/NetIf-freebsd.cpp
r62485 r68026 176 176 177 177 178 static bool isWireless(const char *pszName) 179 { 180 bool fWireless = false; 181 int iSock = socket(AF_INET, SOCK_DGRAM, 0); 182 if (iSock >= 0) 183 { 184 struct ieee80211req WReq; 185 uint8_t abData[32]; 186 187 RT_ZERO(WReq); 188 strncpy(WReq.i_name, pszName, sizeof(WReq.i_name)); 189 WReq.i_type = IEEE80211_IOC_SSID; 190 WReq.i_val = -1; 191 WReq.i_data = abData; 192 WReq.i_len = sizeof(abData); 193 194 fWireless = ioctl(iSock, SIOCG80211, &WReq) >= 0; 195 close(iSock); 196 } 197 198 return fWireless; 199 } 200 178 201 int NetIfList(std::list <ComObjPtr<HostNetworkInterface> > &list) 179 202 { … … 289 312 enmType = HostNetworkInterfaceType_HostOnly; 290 313 314 pNew->wireless = isWireless(pNew->szName); 315 291 316 ComObjPtr<HostNetworkInterface> IfObj; 292 317 IfObj.createObject(); -
trunk/src/VBox/Main/src-server/linux/NetIf-linux.cpp
r67432 r68026 26 26 #include <list> 27 27 #include <sys/ioctl.h> 28 #include <net/if.h> 28 #include <sys/socket.h> 29 #include <linux/wireless.h> 29 30 #include <net/if_arp.h> 30 31 #include <net/route.h> … … 164 165 if (ioctl(iSocket, SIOCGIFFLAGS, &Req) >= 0) 165 166 pInfo->enmStatus = Req.ifr_flags & IFF_UP ? NETIF_S_UP : NETIF_S_DOWN; 167 168 struct iwreq WRq; 169 RT_ZERO(WRq); 170 RTStrCopy(WRq.ifr_name, sizeof(WRq.ifr_name), pszName); 171 pInfo->fWireless = ioctl(iSocket, SIOCGIWNAME, &WRq) >= 0; 166 172 167 173 FILE *fp = fopen("/proc/net/if_inet6", "r"); -
trunk/src/VBox/Main/src-server/win/NetIf-win.cpp
r67725 r68026 40 40 41 41 #include <iprt/win/iphlpapi.h> 42 #include <iprt/win/ntddndis.h> 42 43 43 44 #include "Logging.h" … … 195 196 pInfo->enmMediumType = NETIF_T_ETHERNET; 196 197 pInfo->enmStatus = pAdapter->OperStatus == IfOperStatusUp ? NETIF_S_UP : NETIF_S_DOWN; 197 pInfo-> bIsDefault = (pAdapter->IfIndex == (DWORD)iDefault);198 pInfo->fIsDefault = (pAdapter->IfIndex == (DWORD)iDefault); 198 199 RTStrFree(pszUuid); 199 200 break; … … 212 213 pInfo->IPNetMask.u = Settings.mask; 213 214 } 214 pInfo-> bDhcpEnabled = Settings.bDhcp;215 pInfo->fDhcpEnabled = Settings.bDhcp; 215 216 } 216 217 else 217 218 { 218 pInfo-> bDhcpEnabled = false;219 pInfo->fDhcpEnabled = false; 219 220 } 220 221 } … … 995 996 if (SUCCEEDED(rc)) 996 997 { 997 if (Info. bIsDefault)998 if (Info.fIsDefault) 998 999 pPist->push_front(iface); 999 1000 else … … 1460 1461 RTUUID guid; 1461 1462 PIP_ADAPTER_ADDRESSES pAdapter; 1463 BOOL fWireless; 1462 1464 }; 1463 1465 … … 1509 1511 netIfLog(("return\n")); 1510 1512 return VINF_SUCCESS; 1513 } 1514 1515 #define DEVNAME_PREFIX L"\\\\.\\" 1516 1517 static BOOL netIfIsWireless(INetCfgComponent *pAdapter) 1518 { 1519 HRESULT hr; 1520 wchar_t * pswzBindName; 1521 wchar_t FileName[MAX_PATH]; 1522 bool fWireless = false; 1523 1524 hr = pAdapter->GetBindName(&pswzBindName); 1525 wcscpy(FileName, DEVNAME_PREFIX); 1526 wcscpy((wchar_t*)(((char*)FileName) + sizeof(DEVNAME_PREFIX) - sizeof(FileName[0])), pswzBindName); 1527 1528 /* open the device */ 1529 HANDLE hDevice = CreateFile(FileName, 1530 GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 1531 NULL, 1532 OPEN_EXISTING, 1533 FILE_ATTRIBUTE_NORMAL, 1534 NULL); 1535 1536 if (hDevice != INVALID_HANDLE_VALUE) 1537 { 1538 1539 /* now issue the OID_GEN_PHYSICAL_MEDIUM query */ 1540 DWORD Oid = OID_GEN_PHYSICAL_MEDIUM; 1541 NDIS_PHYSICAL_MEDIUM PhMedium; 1542 DWORD cbResult; 1543 if (DeviceIoControl(hDevice, 1544 IOCTL_NDIS_QUERY_GLOBAL_STATS, 1545 &Oid, 1546 sizeof(Oid), 1547 &PhMedium, 1548 sizeof(PhMedium), 1549 &cbResult, 1550 NULL)) 1551 { 1552 /* that was simple, now examine PhMedium */ 1553 fWireless = PhMedium == NdisPhysicalMediumWirelessWan 1554 || PhMedium == NdisPhysicalMediumWirelessLan 1555 || PhMedium == NdisPhysicalMediumNative802_11 1556 || PhMedium == NdisPhysicalMediumBluetooth; 1557 } 1558 else 1559 { 1560 int winEr = GetLastError(); 1561 LogRel(("netIfIsWireless: DeviceIoControl failed, err (0x%x), ignoring\n", winEr)); 1562 Assert(winEr == ERROR_INVALID_PARAMETER || winEr == ERROR_NOT_SUPPORTED || winEr == ERROR_BAD_COMMAND); 1563 } 1564 CloseHandle(hDevice); 1565 } 1566 else 1567 { 1568 int winEr = GetLastError(); 1569 AssertLogRelMsgFailed(("netIfIsWireless: CreateFile failed, err (0x%x), ignoring\n", winEr)); 1570 } 1571 1572 CoTaskMemFree(pswzBindName); 1573 return fWireless; 1511 1574 } 1512 1575 … … 1610 1673 adapter.guid = *(Guid(guid).raw()); 1611 1674 adapter.pAdapter = NULL; 1675 adapter.fWireless = netIfIsWireless(pAdapter); 1612 1676 netIfLog(("guid=%RTuuid, name=%ls, hwid=%ls, status=%x, chars=%x\n", 1613 1677 &adapter.guid, pwszName, pwszHwId, uStatus, dwChars)); … … 1873 1937 { 1874 1938 info.enmStatus = pAdapter->OperStatus == IfOperStatusUp ? NETIF_S_UP : NETIF_S_DOWN; 1875 info. bIsDefault = (pAdapter->IfIndex == (DWORD)iDefault);1876 info. bDhcpEnabled = pAdapter->Flags & IP_ADAPTER_DHCP_ENABLED;1939 info.fIsDefault = (pAdapter->IfIndex == (DWORD)iDefault); 1940 info.fDhcpEnabled = pAdapter->Flags & IP_ADAPTER_DHCP_ENABLED; 1877 1941 OSVERSIONINFOEX OSInfoEx; 1878 1942 RT_ZERO(OSInfoEx); … … 1900 1964 else 1901 1965 { 1902 if (info. bIsDefault)1966 if (info.fIsDefault) 1903 1967 list.push_front(iface); 1904 1968 else
Note:
See TracChangeset
for help on using the changeset viewer.

