Changeset 48096 in vbox
- Timestamp:
- Aug 27, 2013 5:00:31 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 88471
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageNATNetwork.cpp
r47704 r48096 48 48 49 49 #include <vector> 50 #include <string> 50 51 51 52 #include "VBoxManage.h" … … 75 76 { "--port-forward-4", 'p', RTGETOPT_REQ_STRING }, 76 77 { "--port-forward-6", 'P', RTGETOPT_REQ_STRING }, 78 { "--loopback-4", 'l', RTGETOPT_REQ_STRING }, 79 { "--loopback-6", 'L', RTGETOPT_REQ_STRING }, 80 77 81 }; 78 82 … … 89 93 typedef VPF2ADD::const_iterator VPF2ADDITERATOR; 90 94 95 typedef std::vector<std::string> LOOPBACK2DELETEADD; 96 typedef LOOPBACK2DELETEADD::iterator LOOPBACK2DELETEADDITERATOR; 91 97 92 98 static int handleOp(HandlerArg *a, OPCODE enmCode, int iStart, int *pcProcessed) … … 106 112 VPF2DELETE vPfName2Delete; 107 113 VPF2ADD vPf2Add; 114 115 LOOPBACK2DELETEADD vLoopback2Delete; 116 LOOPBACK2DELETEADD vLoopback2Add; 117 118 LONG loopback6Offset = 0; /* ignore me */ 108 119 109 120 int c; … … 169 180 ipv6 = ValueUnion.f; 170 181 break; 182 183 case 'L': /* ipv6 loopback */ 184 case 'l': /* ipv4 loopback */ 185 if (RTStrCmp(ValueUnion.psz, "delete") == 0) 186 { 187 /* deletion */ 188 if (enmCode != OP_MODIFY) 189 errorSyntax(USAGE_NATNETWORK, 190 "loopback couldn't be deleted on modified\n"); 191 if (c == 'L') 192 loopback6Offset = -1; 193 else 194 { 195 int vrc; 196 RTGETOPTUNION Addr2Delete; 197 vrc = RTGetOptFetchValue(&GetState, 198 &Addr2Delete, 199 RTGETOPT_REQ_STRING); 200 if (RT_FAILURE(vrc)) 201 return errorSyntax(USAGE_NATNETWORK, 202 "Not enough parmaters\n"); 203 204 vLoopback2Delete.push_back(std::string(Addr2Delete.psz)); 205 } 206 } 207 else /* addition */ 208 { 209 if (c == 'L') 210 loopback6Offset = ValueUnion.u32; 211 else 212 vLoopback2Add.push_back(std::string(ValueUnion.psz)); 213 } 214 break; 171 215 172 216 case 'P': /* ipv6 portforwarding*/ … … 349 393 } 350 394 } 395 396 if (loopback6Offset) 397 { 398 if (loopback6Offset == -1) 399 loopback6Offset = 0; /* deletion */ 400 401 CHECK_ERROR_RET(net, COMSETTER(LoopbackIp6)(loopback6Offset), rc); 402 } 403 404 /* addLocalMapping (hostid, offset) */ 405 if (!vLoopback2Add.empty()) 406 { 407 /* we're expecting stings 127.0.0.1;5 */ 408 LOOPBACK2DELETEADDITERATOR it; 409 for (it = vLoopback2Add.begin(); 410 it != vLoopback2Add.end(); 411 ++it) 412 { 413 std::string address, strOffset; 414 int pos = it->find(';'); 415 LONG lOffset = 0; 416 Bstr bstrAddress; 417 418 AssertReturn(pos != -1, errorArgument("invalid loopback string")); 419 420 address = it->substr(0, pos); 421 strOffset = it->substr(pos + 1); 422 423 lOffset = RTStrToUInt32(strOffset.c_str()); 424 AssertReturn(lOffset > 0, errorArgument("invalid loopback string")); 425 426 bstrAddress = Bstr(address.c_str()); 427 428 CHECK_ERROR_RET(net, AddLocalMapping(bstrAddress.raw(), lOffset), rc); 429 } 430 } 431 432 if (!vLoopback2Delete.empty()) 433 { 434 /* we're expecting stings 127.0.0.1 */ 435 LOOPBACK2DELETEADDITERATOR it; 436 for (it = vLoopback2Add.begin(); 437 it != vLoopback2Add.end(); 438 ++it) 439 { 440 Bstr bstrAddress; 441 bstrAddress = Bstr(it->c_str()); 442 443 CHECK_ERROR_RET(net, AddLocalMapping(bstrAddress.raw(), 0), rc); 444 } 445 } 446 351 447 352 448 if(enable >= 0)
Note:
See TracChangeset
for help on using the changeset viewer.