- Timestamp:
- Feb 24, 2015 12:04:44 AM (10 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/DHCPServerImpl.h
r54351 r54407 64 64 using settings::DhcpOptIterator; 65 65 66 using settings::VmNameSlotKey; 66 67 using settings::VmSlot2OptionsMap; 67 68 using settings::VmSlot2OptionsPair; … … 93 94 HRESULT encodeOption(com::Utf8Str &aEncoded, 94 95 uint32_t aOptCode, const DhcpOptValue &aOptValue); 96 int addOption(DhcpOptionMap &aMap, 97 DhcpOpt_T aOption, const com::Utf8Str &aValue); 95 98 96 99 // wrapped IDHCPServer properties -
trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp
r54351 r54407 318 318 319 319 320 int DHCPServer::addOption(DhcpOptionMap &aMap, 321 DhcpOpt_T aOption, const com::Utf8Str &aValue) 322 { 323 DhcpOptValue OptValue; 324 325 if (aOption != 0) 326 { 327 OptValue = DhcpOptValue(aValue, DhcpOptValue::LEGACY); 328 } 329 /* 330 * This is a kludge to sneak in option encoding information 331 * through existing API. We use option 0 and supply the real 332 * option/value in the same format that encodeOption() above 333 * produces for getter methods. 334 */ 335 else 336 { 337 uint8_t u8Code; 338 uint32_t u32Enc; 339 char *pszNext; 340 int rc; 341 342 rc = RTStrToUInt8Ex(aValue.c_str(), &pszNext, 10, &u8Code); 343 if (!RT_SUCCESS(rc)) 344 return VERR_PARSE_ERROR; 345 346 switch (*pszNext) 347 { 348 case ':': /* support legacy format too */ 349 { 350 u32Enc = DhcpOptValue::LEGACY; 351 break; 352 } 353 354 case '=': 355 { 356 u32Enc = DhcpOptValue::HEX; 357 break; 358 } 359 360 case '@': 361 { 362 rc = RTStrToUInt32Ex(pszNext + 1, &pszNext, 10, &u32Enc); 363 if (!RT_SUCCESS(rc)) 364 return VERR_PARSE_ERROR; 365 if (*pszNext != '=') 366 return VERR_PARSE_ERROR; 367 break; 368 } 369 370 default: 371 return VERR_PARSE_ERROR; 372 } 373 374 aOption = (DhcpOpt_T)u8Code; 375 OptValue = DhcpOptValue(pszNext + 1, (DhcpOptValue::Encoding)u32Enc); 376 } 377 378 aMap[aOption] = OptValue; 379 return VINF_SUCCESS; 380 } 381 382 320 383 HRESULT DHCPServer::addGlobalOption(DhcpOpt_T aOption, const com::Utf8Str &aValue) 321 384 { 322 385 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 323 386 324 m->GlobalDhcpOptions[aOption] = aValue; 387 int rc = addOption(m->GlobalDhcpOptions, aOption, aValue); 388 if (!RT_SUCCESS(rc)) 389 return E_INVALIDARG; 325 390 326 391 /* Indirect way to understand that we're on NAT network */ … … 373 438 { 374 439 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 375 m->VmSlot2Options[settings::VmNameSlotKey(aVmName, aSlot)][aOption] = aValue; 440 441 DhcpOptionMap &map = m->VmSlot2Options[VmNameSlotKey(aVmName, aSlot)]; 442 int rc = addOption(map, aOption, aValue); 443 if (!RT_SUCCESS(rc)) 444 return E_INVALIDARG; 445 376 446 alock.release(); 377 447
Note:
See TracChangeset
for help on using the changeset viewer.