Changeset 48956 in vbox for trunk/src/VBox/NetworkServices/NetLib
- Timestamp:
- Oct 7, 2013 10:00:27 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 89653
- Location:
- trunk/src/VBox/NetworkServices/NetLib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NetLib/VBoxNetBaseService.cpp
r47118 r48956 102 102 m_Name = "VBoxNetNAT"; 103 103 m_Network = "intnet"; 104 104 105 105 for(unsigned int i = 0; i < RT_ELEMENTS(g_aGetOptDef); ++i) 106 106 m_vecOptionDefs.push_back(&g_aGetOptDef[i]); … … 392 392 /* Commit */ 393 393 IntNetRingCommitFrame(&m_pIfBuf->Send, pHdr); 394 394 395 395 LogFlowFuncLeaveRC(rc); 396 396 return rc; … … 428 428 va_list vaCopy; /* This dude is *very* special, thus the copy. */ 429 429 va_copy(vaCopy, va); 430 RTStrmPrintf(g_pStdErr, "%s: %s: %N\n", 430 RTStrmPrintf(g_pStdErr, "%s: %s: %N\n", 431 431 RTProcShortName(), 432 432 iMinLevel >= 2 ? "debug" : "info", -
trunk/src/VBox/NetworkServices/NetLib/VBoxNetPortForwardString.cpp
r48365 r48956 50 50 #define PF_STR_ADDRESS_FIELD_ENDS "]" 51 51 52 static int netPfStrAddressParse(char *pszRaw, int cbRaw, 52 static int netPfStrAddressParse(char *pszRaw, int cbRaw, 53 53 char *pszAddress, int cbAddress, 54 54 bool fEmptyAcceptable) … … 66 66 pszRaw++; 67 67 cbRaw--; 68 68 69 69 70 70 /* we shouldn't face with ending here */ … … 72 72 73 73 char *pszEndOfAddress = RTStrStr(pszRaw, PF_STR_ADDRESS_FIELD_ENDS); 74 74 75 75 /* no pair closing sign */ 76 76 AssertPtrReturn(pszEndOfAddress, VERR_INVALID_PARAMETER); 77 77 78 78 cbField = pszEndOfAddress - pszRaw; 79 79 80 80 /* field should be less then the rest of the string */ 81 81 AssertReturn(cbField < cbRaw, VERR_INVALID_PARAMETER); 82 82 83 83 if (cbField != 0) 84 84 RTStrCopy(pszAddress, RT_MIN(cbField + 1, cbAddress), pszRaw); … … 89 89 AssertReturn(pszRaw[cbField] == PF_ADDRESS_FIELD_ENDS, -1); 90 90 91 return cbField + 2; /* length of the field and closing braces */ 91 return cbField + 2; /* length of the field and closing braces */ 92 92 } 93 93 … … 113 113 cbRest = strlen(pszRaw); 114 114 115 Assert(cbRaw == cbRest); 116 115 Assert(cbRaw == cbRest); 116 117 117 /* XXX: Assumption that if string is too big, it will be reported by 118 118 * RTStrToUint16. … … 142 142 if (!(u16Port = RTStrToUInt16(aszPort))) 143 143 return -1; 144 144 145 145 *pu16Port = u16Port; 146 146 … … 149 149 150 150 151 static int netPfStrAddressPortPairParse(char *pszRaw, int cbRaw, 152 char *pszAddress, int cbAddress, 151 static int netPfStrAddressPortPairParse(char *pszRaw, int cbRaw, 152 char *pszAddress, int cbAddress, 153 153 bool fEmptyAddressAcceptable, 154 154 uint16_t *pu16Port) … … 173 173 if (pszRaw[0] == PF_ADDRESS_FIELD_STARTS) 174 174 { 175 idxRaw += netPfStrAddressParse(pszRaw, 176 cbRaw - idxRaw, 175 idxRaw += netPfStrAddressParse(pszRaw, 176 cbRaw - idxRaw, 177 177 pszAddress, 178 178 cbAddress, … … 184 184 } 185 185 else return -1; 186 186 187 187 pszRaw += idxRaw; 188 188 idxRawTotal += idxRaw; … … 190 190 191 191 AssertReturn(cbRaw > 0, VERR_INVALID_PARAMETER); 192 192 193 193 idxRaw = 0; 194 194 … … 211 211 } 212 212 213 /* XXX: Having fIPv6 we might emprove adress verification comparing address length 213 /* XXX: Having fIPv6 we might emprove adress verification comparing address length 214 214 * with INET[6]_ADDRLEN 215 215 */ … … 224 224 bool fTcpProto = false; 225 225 226 char *pszRawBegin = NULL; 226 char *pszRawBegin = NULL; 227 227 char *pszRaw = NULL; 228 228 int idxRaw = 0; … … 240 240 pszName = &pPfr->aszPfrName[0]; 241 241 242 cbRaw = strlen(pcszStrPortForward); 242 cbRaw = strlen(pcszStrPortForward); 243 243 244 244 /* Minimal rule ":tcp:[]:0:[]:0" has got lenght 14 */ 245 245 AssertReturn(cbRaw > 14, VERR_INVALID_PARAMETER); 246 246 247 247 pszRaw = RTStrDup(pcszStrPortForward); 248 248 … … 252 252 253 253 /* name */ 254 if (pszRaw[idxRaw] == PF_FIELD_SEPARATOR) 254 if (pszRaw[idxRaw] == PF_FIELD_SEPARATOR) 255 255 idxRaw = 1; /* begin of the next segment */ 256 256 else … … 263 263 /* XXX it's unacceptable to have only name entry in PF */ 264 264 AssertReturn(cbToken < cbRaw, VERR_INVALID_PARAMETER); 265 265 266 266 if ( cbToken < 0 267 267 || (size_t)cbToken >= PF_NAMELEN) 268 268 goto invalid_parameter; 269 269 270 RTStrCopy(pszName, 271 RT_MIN((size_t)cbToken + 1, PF_NAMELEN), 270 RTStrCopy(pszName, 271 RT_MIN((size_t)cbToken + 1, PF_NAMELEN), 272 272 pszRaw); 273 273 pszRaw += cbToken; /* move to separator */ 274 274 } 275 275 276 276 AssertReturn(pszRaw[0] == PF_FIELD_SEPARATOR, VERR_INVALID_PARAMETER); 277 277 /* protocol */ … … 279 279 pszRaw++; /* skip separator */ 280 280 idxRaw = 0; 281 281 282 282 cbRaw--; 283 283 … … 291 291 else 292 292 goto invalid_parameter; 293 293 294 294 pszRaw += idxRaw; 295 295 cbRaw -= idxRaw; 296 296 idxRaw = 0; 297 298 idxRaw = netPfStrAddressPortPairParse(pszRaw, cbRaw, 297 298 idxRaw = netPfStrAddressPortPairParse(pszRaw, cbRaw, 299 299 pszHostAddr, INET6_ADDRSTRLEN, 300 300 true, &u16HostPort); … … 309 309 idxRaw = 0; 310 310 311 idxRaw = netPfStrAddressPortPairParse(pszRaw, cbRaw, 312 pszGuestAddr, 311 idxRaw = netPfStrAddressPortPairParse(pszRaw, cbRaw, 312 pszGuestAddr, 313 313 INET6_ADDRSTRLEN, 314 314 false, … … 322 322 pPfr->iPfrProto = proto; 323 323 324 324 325 325 if (strlen(pszHostAddr)) 326 326 { … … 335 335 goto invalid_parameter; 336 336 } 337 337 338 338 pPfr->u16PfrHostPort = u16HostPort; 339 339 … … 341 341 { 342 342 if (!fIPv6) 343 rc = RTNetStrToIPv4Addr(pszGuestAddr, &pPfr->uPfrGuestAddr.IPv4); 343 rc = RTNetStrToIPv4Addr(pszGuestAddr, &pPfr->uPfrGuestAddr.IPv4); 344 344 #if 0 345 345 else … … 351 351 else 352 352 goto invalid_parameter; /* guest address should be defined */ 353 353 354 354 pPfr->u16PfrGuestPort = u16GuestPort; 355 355 356 356 Log(("name: %s\n" 357 357 "proto: %d\n" … … 366 366 RTStrFree(pszRawBegin); 367 367 return VINF_SUCCESS; 368 368 369 369 invalid_parameter: 370 370 RTStrFree(pszRawBegin); -
trunk/src/VBox/NetworkServices/NetLib/VBoxPortForwardString.h
r48363 r48956 26 26 #define PF_NAMELEN 64 27 27 /* 28 * TBD: Here is shared implementation of parsing port-forward string 28 * TBD: Here is shared implementation of parsing port-forward string 29 29 * of format: 30 30 * name:[ipv4 or ipv6 address]:host-port:[ipv4 or ipv6 guest addr]:guest port 31 * 32 * This code supposed to be used in NetService and Frontend and perhaps in corresponding 31 * 32 * This code supposed to be used in NetService and Frontend and perhaps in corresponding 33 33 * services. 34 34 *
Note:
See TracChangeset
for help on using the changeset viewer.