Changeset 35785 in vbox
- Timestamp:
- Jan 31, 2011 12:45:37 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69756
- Location:
- trunk/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdp.c
r33540 r35785 1077 1077 } 1078 1078 1079 int vboxNetAdpCreate (PVBOXNETADP *ppNew )1079 int vboxNetAdpCreate (PVBOXNETADP *ppNew, const char *pcszName) 1080 1080 { 1081 1081 int rc; … … 1091 1091 Log(("vboxNetAdpCreate: found empty slot: %d\n", i)); 1092 1092 vboxNetAdpComposeMACAddress(pThis, &Mac); 1093 rc = vboxNetAdpOsCreate(pThis, &Mac );1093 rc = vboxNetAdpOsCreate(pThis, &Mac, pcszName); 1094 1094 Log(("vboxNetAdpCreate: pThis=%p pThis->szName=%p\n", pThis, pThis->szName)); 1095 1095 if (RT_SUCCESS(rc)) … … 1143 1143 } 1144 1144 1145 /* Create vboxnet0 */ 1146 return vboxNetAdpCreate(&pVboxnet0); 1145 return VINF_SUCCESS; 1146 /* Create vboxnet0 1147 return vboxNetAdpCreate(&pVboxnet0);*/ 1147 1148 } 1148 1149 -
trunk/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdpInternal.h
r28800 r35785 141 141 DECLHIDDEN(int) vboxNetAdpInit(void); 142 142 DECLHIDDEN(void) vboxNetAdpShutdown(void); 143 DECLHIDDEN(int) vboxNetAdpCreate (PVBOXNETADP *ppNew );143 DECLHIDDEN(int) vboxNetAdpCreate (PVBOXNETADP *ppNew, const char *pcszName); 144 144 DECLHIDDEN(int) vboxNetAdpDestroy(PVBOXNETADP pThis); 145 145 DECLHIDDEN(PVBOXNETADP) vboxNetAdpFindByName(const char *pszName); … … 177 177 * @remarks Owns no locks. 178 178 */ 179 DECLHIDDEN(int) vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMac );179 DECLHIDDEN(int) vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMac, const char *pcszName); 180 180 181 181 -
trunk/src/VBox/HostDrivers/VBoxNetAdp/darwin/VBoxNetAdp-darwin.cpp
r30320 r35785 193 193 194 194 195 int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMACAddress) 196 { 195 int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMACAddress, const char *pcszName) 196 { 197 /* TODO: Use pcszName */ 197 198 int rc; 198 199 struct ifnet_init_params Params; -
trunk/src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c
r33540 r35785 255 255 } 256 256 257 int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMac) 258 { 257 int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMac, const char *pcszName) 258 { 259 /* TODO: Use pcszName */ 259 260 struct ifnet *ifp; 260 261 -
trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c
r33540 r35785 176 176 177 177 178 int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMACAddress )178 int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMACAddress, const char *pcszName) 179 179 { 180 180 int rc = VINF_SUCCESS; … … 182 182 183 183 /* No need for private data. */ 184 pNetDev = alloc_netdev(sizeof(VBOXNETADPPRIV), VBOXNETADP_LINUX_NAME, vboxNetAdpNetDevInit); 184 pNetDev = alloc_netdev(sizeof(VBOXNETADPPRIV), 185 pcszName ? pcszName : VBOXNETADP_LINUX_NAME, 186 vboxNetAdpNetDevInit); 185 187 if (pNetDev) 186 188 { … … 277 279 PVBOXNETADP pAdp; 278 280 int rc; 281 char *pszName = NULL; 279 282 280 283 Log(("VBoxNetAdpLinuxIOCtl: param len %#x; uCmd=%#x; add=%#x\n", _IOC_SIZE(uCmd), uCmd, VBOXNETADP_CTL_ADD)); … … 289 292 case VBOXNETADP_CTL_ADD: 290 293 Log(("VBoxNetAdpLinuxIOCtl: _IOC_DIR(uCmd)=%#x; IOC_OUT=%#x\n", _IOC_DIR(uCmd), IOC_OUT)); 291 rc = vboxNetAdpCreate(&pAdp); 294 if (RT_UNLIKELY(copy_from_user(&Req, (void *)ulArg, sizeof(Req)))) 295 { 296 Log(("VBoxNetAdpLinuxIOCtl: copy_from_user(,%#lx,) failed; uCmd=%#x.\n", ulArg, uCmd)); 297 return -EFAULT; 298 } 299 Log(("VBoxNetAdpLinuxIOCtl: Add %s\n", Req.szName)); 300 301 if (Req.szName[0]) 302 { 303 pAdp = vboxNetAdpFindByName(Req.szName); 304 if (pAdp) 305 { 306 Log(("VBoxNetAdpLinuxIOCtl: '%s' already exists\n", Req.szName)); 307 return -EINVAL; 308 } 309 pszName = Req.szName; 310 } 311 rc = vboxNetAdpCreate(&pAdp, pszName); 292 312 if (RT_FAILURE(rc)) 293 313 { -
trunk/src/VBox/Main/include/netif.h
r35356 r35785 87 87 int NetIfEnableStaticIpConfigV6(VirtualBox *pVbox, HostNetworkInterface * pIf, IN_BSTR aOldIPV6Address, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength); 88 88 int NetIfEnableDynamicIpConfig(VirtualBox *pVbox, HostNetworkInterface * pIf); 89 int NetIfCreateHostOnlyNetworkInterface (VirtualBox *pVbox, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress );89 int NetIfCreateHostOnlyNetworkInterface (VirtualBox *pVbox, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress, const char *pcszName = NULL); 90 90 int NetIfRemoveHostOnlyNetworkInterface (VirtualBox *pVbox, IN_GUID aId, IProgress **aProgress); 91 91 int NetIfGetConfig(HostNetworkInterface * pIf, NETIFINFO *); -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r35638 r35785 41 41 #if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) 42 42 # include <HostHardwareLinux.h> 43 #endif 44 45 #if defined(RT_OS_LINUX) 46 # include <set> 43 47 #endif 44 48 … … 362 366 m->f3DAccelerationSupported = is3DAccelerationSupported(); 363 367 #endif /* VBOX_WITH_CROGL */ 368 369 #if defined (RT_OS_LINUX) 370 /* Extract the list of configured host-only interfaces */ 371 std::set<Utf8Str> aConfiguredNames; 372 SafeArray<BSTR> aGlobalExtraDataKeys; 373 hrc = aParent->GetExtraDataKeys(ComSafeArrayAsOutParam(aGlobalExtraDataKeys)); 374 AssertMsg(SUCCEEDED(hrc), ("VirtualBox::GetExtraDataKeys failed with %Rhrc\n", hrc)); 375 for (size_t i = 0; i < aGlobalExtraDataKeys.size(); ++i) 376 { 377 Utf8Str strKey = aGlobalExtraDataKeys[i]; 378 379 if (!strKey.startsWith("HostOnly/vboxnet")) 380 continue; 381 382 size_t pos = strKey.find("/", sizeof("HostOnly/vboxnet")); 383 if (pos != Utf8Str::npos) 384 aConfiguredNames.insert(strKey.substr(sizeof("HostOnly"), 385 pos - sizeof("HostOnly"))); 386 } 387 388 for (std::set<Utf8Str>::const_iterator it = aConfiguredNames.begin(); 389 it != aConfiguredNames.end(); 390 ++it) 391 { 392 ComPtr<IHostNetworkInterface> hif; 393 ComPtr<IProgress> progress; 394 395 int r = NetIfCreateHostOnlyNetworkInterface(m->pParent, 396 hif.asOutParam(), 397 progress.asOutParam(), 398 it->c_str()); 399 if (RT_FAILURE(r)) 400 return E_FAIL; 401 } 402 403 #endif /* defined (RT_OS_LINUX) */ 364 404 365 405 /* Confirm a successful initialization */ … … 1082 1122 * violations with the called functions. */ 1083 1123 1124 Bstr name; 1125 HRESULT rc; 1126 1084 1127 /* first check whether an interface with the given name already exists */ 1085 1128 { … … 1090 1133 tr("Host network interface with UUID {%RTuuid} does not exist"), 1091 1134 Guid (aId).raw()); 1135 rc = iface->COMGETTER(Name)(name.asOutParam()); 1136 ComAssertComRCRet(rc, rc); 1092 1137 } 1093 1138 1094 1139 int r = NetIfRemoveHostOnlyNetworkInterface(m->pParent, Guid(aId).ref(), aProgress); 1095 1140 if (RT_SUCCESS(r)) 1141 { 1142 /* Drop configuration parameters for removed interface */ 1143 rc = m->pParent->SetExtraData(BstrFmt("HostOnly/%ls/IPAddress", name.raw()).raw(), NULL); 1144 rc = m->pParent->SetExtraData(BstrFmt("HostOnly/%ls/IPNetMask", name.raw()).raw(), NULL); 1145 rc = m->pParent->SetExtraData(BstrFmt("HostOnly/%ls/IPV6Address", name.raw()).raw(), NULL); 1146 rc = m->pParent->SetExtraData(BstrFmt("HostOnly/%ls/IPV6NetMask", name.raw()).raw(), NULL); 1147 1096 1148 return S_OK; 1149 } 1097 1150 1098 1151 return r == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL; -
trunk/src/VBox/Main/src-server/generic/NetIf-generic.cpp
r32718 r35785 127 127 128 128 129 int NetIfCreateHostOnlyNetworkInterface(VirtualBox *pVBox, IHostNetworkInterface **aHostNetworkInterface, IProgress **aProgress) 129 int NetIfCreateHostOnlyNetworkInterface(VirtualBox *pVBox, 130 IHostNetworkInterface **aHostNetworkInterface, 131 IProgress **aProgress, 132 const char *pcszName) 130 133 { 131 134 #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) … … 155 158 return rc; 156 159 } 157 strcat(szAdpCtl, "/" VBOXNETADPCTL_NAME " add"); 160 strcat(szAdpCtl, "/" VBOXNETADPCTL_NAME " "); 161 if (pcszName && strlen(pcszName) <= RTPATH_MAX - strlen(szAdpCtl) - sizeof(" add")) 162 { 163 strcat(szAdpCtl, pcszName); 164 strcat(szAdpCtl, " add"); 165 } 166 else 167 strcat(szAdpCtl, "add"); 158 168 FILE *fp = popen(szAdpCtl, "r"); 159 169 -
trunk/src/VBox/Main/src-server/win/NetIf-win.cpp
r35368 r35785 1085 1085 int NetIfCreateHostOnlyNetworkInterface(VirtualBox *pVBox, 1086 1086 IHostNetworkInterface **aHostNetworkInterface, 1087 IProgress **aProgress) 1087 IProgress **aProgress, 1088 const char *pcszName) 1088 1089 { 1089 1090 #ifndef VBOX_WITH_NETFLT -
trunk/src/apps/adpctl/VBoxNetAdpCtl.cpp
r28800 r35785 66 66 { 67 67 fprintf(stderr, "Usage: VBoxNetAdpCtl <adapter> <address> ([netmask <address>] | remove)\n"); 68 fprintf(stderr, " | VBoxNetAdpCtl add\n");68 fprintf(stderr, " | VBoxNetAdpCtl [<adapter>] add\n"); 69 69 fprintf(stderr, " | VBoxNetAdpCtl <adapter> remove\n"); 70 70 } … … 268 268 case 3: 269 269 { 270 /* Remove an existing interface */271 270 pszAdapterName = argv[1]; 271 memset(&Req, '\0', sizeof(Req)); 272 rc = checkAdapterName(pszAdapterName, szAdapterName); 273 if (rc) 274 return rc; 275 snprintf(Req.szName, sizeof(Req.szName), "%s", szAdapterName); 272 276 pszAddress = argv[2]; 273 277 if (strcmp("remove", pszAddress) == 0) 274 278 { 275 rc = checkAdapterName(pszAdapterName, szAdapterName); 276 if (rc) 277 return rc; 278 #ifdef RT_OS_SOLARIS 279 return 1; 280 #else 281 memset(&Req, '\0', sizeof(Req)); 282 snprintf(Req.szName, sizeof(Req.szName), "%s", szAdapterName); 279 /* Remove an existing interface */ 280 #ifdef RT_OS_SOLARIS 281 return 1; 282 #else 283 283 return doIOCtl(VBOXNETADP_CTL_REMOVE, &Req); 284 284 #endif 285 } 286 else if (strcmp("add", pszAddress) == 0) 287 { 288 /* Create an interface with given name */ 289 #ifdef RT_OS_SOLARIS 290 return 1; 291 #else 292 rc = doIOCtl(VBOXNETADP_CTL_ADD, &Req); 293 if (rc == 0) 294 puts(Req.szName); 295 #endif 296 return rc; 285 297 } 286 298 break;
Note:
See TracChangeset
for help on using the changeset viewer.