Changeset 17759 in vbox
- Timestamp:
- Mar 12, 2009 3:57:18 PM (16 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r17680 r17759 488 488 if (u64Cmd & USAGE_HOSTONLYIFS) 489 489 { 490 RTPrintf("VBoxManage hostonlyif ipconfig <name> [-dhcp| -ip<ipv4> -netmask<ipv4> | -ipv6<ipv6> -netmasklengthv6<length>]"490 RTPrintf("VBoxManage hostonlyif ipconfig <name> [-dhcp| -ip<ipv4> [-netmask<ipv4> (default is 255.255.255.0)]| -ipv6<ipv6> [-netmasklengthv6<length> (default is 64)]]" 491 491 # if defined(RT_OS_WINDOWS) 492 492 "|\n" -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHostonly.cpp
r17679 r17759 153 153 = { 154 154 { "-dhcp", DHCP, RTGETOPT_REQ_NOTHING }, 155 { "-ip", IP, RTGETOPT_REQ_ IPV4ADDR},156 { "-netmask", NETMASK, RTGETOPT_REQ_ IPV4ADDR},155 { "-ip", IP, RTGETOPT_REQ_STRING }, 156 { "-netmask", NETMASK, RTGETOPT_REQ_STRING }, 157 157 { "-ipv6", IPV6, RTGETOPT_REQ_STRING }, 158 158 { "-netmasklengthv6", NETMASKLENGTHV6, RTGETOPT_REQ_UINT8 } … … 172 172 bool bDhcp = false; 173 173 bool bNetmasklengthv6 = false; 174 uint 8_t uNetmasklengthv6 = 0;174 uint32_t uNetmasklengthv6 = -1; 175 175 const char *pIpv6 = NULL; 176 bool bIp = false; 177 RTNETADDRIPV4 ip; 178 bool bNetmask = false; 179 RTNETADDRIPV4 netmask; 176 const char * pIp = NULL; 177 const char * pNetmask = NULL; 180 178 181 179 int c; … … 196 194 if (bDhcp) 197 195 return errorSyntax(USAGE_HOSTONLYIFS, "You can only specify -dhcp once."); 198 else if(bNetmasklengthv6 || pIpv6 || bIp || bNetmask)196 else if(bNetmasklengthv6 || pIpv6 || pIp || pNetmask) 199 197 return errorSyntax(USAGE_HOSTONLYIFS, "You can not use -dhcp with static ip configuration parameters: -ip, -netmask, -ipv6 and -netmasklengthv6."); 200 198 else … … 202 200 break; 203 201 case IP: 204 if( bIp)202 if(pIp) 205 203 return errorSyntax(USAGE_HOSTONLYIFS, "You can only specify -ip once."); 206 204 else if (bDhcp) … … 210 208 else 211 209 { 212 bIp = true; 213 ip = ValueUnion.IPv4Addr; 210 pIp = ValueUnion.psz; 214 211 } 215 212 break; 216 213 case NETMASK: 217 if( bNetmask)214 if(pNetmask) 218 215 return errorSyntax(USAGE_HOSTONLYIFS, "You can only specify -netmask once."); 219 216 else if (bDhcp) … … 223 220 else 224 221 { 225 bNetmask = true; 226 netmask = ValueUnion.IPv4Addr; 222 pNetmask = ValueUnion.psz; 227 223 } 228 224 break; … … 232 228 else if (bDhcp) 233 229 return errorSyntax(USAGE_HOSTONLYIFS, "You can not use -dhcp with static ip configuration parameters: -ip, -netmask, -ipv6 and -netmasklengthv6."); 234 else if( bIp || bNetmask)230 else if(pIp || pNetmask) 235 231 return errorSyntax(USAGE_HOSTONLYIFS, "You can not use ipv4 configuration (-ip and -netmask) with ipv6 (-ipv6 and -netmasklengthv6) simultaneously."); 236 232 else … … 242 238 else if (bDhcp) 243 239 return errorSyntax(USAGE_HOSTONLYIFS, "You can not use -dhcp with static ip configuration parameters: -ip, -netmask, -ipv6 and -netmasklengthv6."); 244 else if( bIp || bNetmask)240 else if(pIp || pNetmask) 245 241 return errorSyntax(USAGE_HOSTONLYIFS, "You can not use ipv4 configuration (-ip and -netmask) with ipv6 (-ipv6 and -netmasklengthv6) simultaneously."); 246 242 else … … 249 245 uNetmasklengthv6 = ValueUnion.u8; 250 246 } 247 break; 248 case VINF_GETOPT_NOT_OPTION: 249 case VERR_GETOPT_UNKNOWN_OPTION: 250 return errorSyntax(USAGE_HOSTONLYIFS, "Unknown option \"%s\".", ValueUnion.psz); 251 251 break; 252 252 default: … … 266 266 CHECK_ERROR(host, FindHostNetworkInterfaceByName(name, hif.asOutParam())); 267 267 268 if(FAILED(rc)) 269 return errorArgument("could not find interface '%s'", a->argv[iStart]); 270 268 271 if(bDhcp) 269 272 { 270 273 CHECK_ERROR(hif, EnableDynamicIpConfig ()); 271 274 } 272 else if(bIp) 273 { 274 if(!bNetmask) 275 { 276 netmask.u = 0; 277 } 278 279 CHECK_ERROR(hif, EnableStaticIpConfig (ip.u, netmask.u)); 275 else if(pIp) 276 { 277 if(!pNetmask) 278 pNetmask = "255.255.255.0"; /* ?? */ 279 280 CHECK_ERROR(hif, EnableStaticIpConfig (Bstr(pIp), Bstr(pNetmask))); 280 281 } 281 282 else if(pIpv6) 282 283 { 284 if(uNetmasklengthv6 == -1) 285 uNetmasklengthv6 = 64; /* ?? */ 286 287 BOOL bIpV6Supported; 288 CHECK_ERROR(hif, COMGETTER(IPV6Supported) (&bIpV6Supported)); 289 if(!bIpV6Supported) 290 { 291 RTPrintf("IPv6 setting is not supported for this adapter\n"); 292 return 1; 293 } 294 295 283 296 Bstr ipv6str(pIpv6); 284 297 CHECK_ERROR(hif, EnableStaticIpConfigV6 (ipv6str, (ULONG)uNetmasklengthv6)); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r17737 r17759 331 331 RTPrintf("Dhcp: %s\n", bDhcpEnabled ? "Enabled" : "Disabled"); 332 332 333 ULONG IPAddress; 334 networkInterface->COMGETTER(IPAddress)(&IPAddress); 335 RTPrintf("IPAddress: %d.%d.%d.%d\n", 336 ((uint8_t*)&IPAddress)[0], 337 ((uint8_t*)&IPAddress)[1], 338 ((uint8_t*)&IPAddress)[2], 339 ((uint8_t*)&IPAddress)[3]); 340 ULONG NetworkMask; 341 networkInterface->COMGETTER(NetworkMask)(&NetworkMask); 342 RTPrintf("NetworkMask: %d.%d.%d.%d\n", 343 ((uint8_t*)&NetworkMask)[0], 344 ((uint8_t*)&NetworkMask)[1], 345 ((uint8_t*)&NetworkMask)[2], 346 ((uint8_t*)&NetworkMask)[3]); 333 Bstr IPAddress; 334 networkInterface->COMGETTER(IPAddress)(IPAddress.asOutParam()); 335 RTPrintf("IPAddress: %lS\n", IPAddress.raw()); 336 Bstr NetworkMask; 337 networkInterface->COMGETTER(NetworkMask)(NetworkMask.asOutParam()); 338 RTPrintf("NetworkMask: %lS\n", NetworkMask.raw()); 347 339 Bstr IPV6Address; 348 340 networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam()); -
trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp
r17713 r17759 204 204 * @param aIPAddress address of result pointer 205 205 */ 206 STDMETHODIMP HostNetworkInterface::COMGETTER(IPAddress) ( ULONG*aIPAddress)206 STDMETHODIMP HostNetworkInterface::COMGETTER(IPAddress) (BSTR *aIPAddress) 207 207 { 208 208 CheckComArgOutPointerValid(aIPAddress); … … 211 211 CheckComRCReturnRC (autoCaller.rc()); 212 212 213 *aIPAddress = m.IPAddress; 214 215 return S_OK; 213 in_addr tmp; 214 tmp.S_un.S_addr = m.IPAddress; 215 char *addr = inet_ntoa(tmp); 216 if(addr) 217 { 218 Bstr(addr).detachTo(aIPAddress); 219 return S_OK; 220 } 221 222 return E_FAIL; 216 223 } 217 224 … … 222 229 * @param aNetworkMask address of result pointer 223 230 */ 224 STDMETHODIMP HostNetworkInterface::COMGETTER(NetworkMask) ( ULONG*aNetworkMask)231 STDMETHODIMP HostNetworkInterface::COMGETTER(NetworkMask) (BSTR *aNetworkMask) 225 232 { 226 233 CheckComArgOutPointerValid(aNetworkMask); … … 229 236 CheckComRCReturnRC (autoCaller.rc()); 230 237 231 *aNetworkMask = m.networkMask; 232 233 return S_OK; 238 in_addr tmp; 239 tmp.S_un.S_addr = m.networkMask; 240 char *addr = inet_ntoa(tmp); 241 if(addr) 242 { 243 Bstr(addr).detachTo(aNetworkMask); 244 return S_OK; 245 } 246 247 return E_FAIL; 234 248 } 235 249 … … 237 251 { 238 252 CheckComArgOutPointerValid(aIPV6Supported); 239 253 #if defined(RT_OS_WINDOWS) 254 *aIPV6Supported = FALSE; 255 #else 240 256 *aIPV6Supported = TRUE; 257 #endif 241 258 242 259 return S_OK; … … 352 369 } 353 370 354 STDMETHODIMP HostNetworkInterface::EnableStaticIpConfig ( ULONG aIPAddress, ULONG aNetworkMask)371 STDMETHODIMP HostNetworkInterface::EnableStaticIpConfig (IN_BSTR aIPAddress, IN_BSTR aNetMask) 355 372 { 356 373 #ifndef VBOX_WITH_HOSTNETIF_API … … 360 377 CheckComRCReturnRC (autoCaller.rc()); 361 378 362 int rc = NetIfEnableStaticIpConfig(mVBox, this, aIPAddress, aNetworkMask); 363 if (RT_FAILURE(rc)) 364 { 365 LogRel(("Failed to EnableStaticIpConfigV6 with rc=%Vrc\n", rc)); 366 return rc == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL; 367 } 368 return S_OK; 379 ULONG ip, mask; 380 ip = inet_addr(Utf8Str(aIPAddress).raw()); 381 if(ip != INADDR_NONE) 382 { 383 mask = inet_addr(Utf8Str(aNetMask).raw()); 384 if(mask != INADDR_NONE) 385 { 386 int rc = NetIfEnableStaticIpConfig(mVBox, this, ip, mask); 387 if (RT_SUCCESS(rc)) 388 { 389 return S_OK; 390 } 391 else 392 { 393 LogRel(("Failed to EnableStaticIpConfig with rc=%Vrc\n", rc)); 394 return rc == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL; 395 } 396 397 } 398 } 399 return E_FAIL; 369 400 #endif 370 401 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r17755 r17759 6534 6534 <interface 6535 6535 name="IHostNetworkInterface" extends="$unknown" 6536 uuid=" 63d66df2-e40b-4289-acc2-7e260fe6e51e"6536 uuid="09de36e8-2588-4050-a791-655240b556e0" 6537 6537 wsmap="managed" 6538 6538 > … … 6555 6555 </attribute> 6556 6556 6557 <attribute name="IPAddress" type=" unsigned long" readonly="yes">6557 <attribute name="IPAddress" type="wstring" readonly="yes"> 6558 6558 <desc>Returns the IP V4 address of the interface.</desc> 6559 6559 </attribute> 6560 6560 6561 <attribute name="networkMask" type=" unsigned long" readonly="yes">6561 <attribute name="networkMask" type="wstring" readonly="yes"> 6562 6562 <desc>Returns the network mask of the interface.</desc> 6563 6563 </attribute> … … 6593 6593 <method name="enableStaticIpConfig"> 6594 6594 <desc>sets and enables the static IP V4 configuration for the given interface.</desc> 6595 <param name="IPAddress" type=" unsigned long" dir="in">6595 <param name="IPAddress" type="wstring" dir="in"> 6596 6596 <desc> 6597 6597 IP address. 6598 6598 </desc> 6599 6599 </param> 6600 <param name="networkMask" type=" unsigned long" dir="in">6600 <param name="networkMask" type="wstring" dir="in"> 6601 6601 <desc> 6602 6602 network mask. -
trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h
r17710 r17759 71 71 STDMETHOD(COMGETTER(Id)) (OUT_GUID aGuid); 72 72 STDMETHOD(COMGETTER(DhcpEnabled)) (BOOL *aDhcpEnabled); 73 STDMETHOD(COMGETTER(IPAddress)) ( ULONG*aIPAddress);74 STDMETHOD(COMGETTER(NetworkMask)) ( ULONG*aNetworkMask);73 STDMETHOD(COMGETTER(IPAddress)) (BSTR *aIPAddress); 74 STDMETHOD(COMGETTER(NetworkMask)) (BSTR *aNetworkMask); 75 75 STDMETHOD(COMGETTER(IPV6Supported)) (BOOL *aIPV6Supported); 76 76 STDMETHOD(COMGETTER(IPV6Address)) (BSTR *aIPV6Address); … … 81 81 STDMETHOD(COMGETTER(InterfaceType)) (HostNetworkInterfaceType_T *aType); 82 82 83 STDMETHOD(EnableStaticIpConfig) ( ULONG aIPAddress, ULONGaNetworkMask);83 STDMETHOD(EnableStaticIpConfig) (IN_BSTR aIPAddress, IN_BSTR aNetworkMask); 84 84 STDMETHOD(EnableStaticIpConfigV6) (IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength); 85 85 STDMETHOD(EnableDynamicIpConfig) ();
Note:
See TracChangeset
for help on using the changeset viewer.