- Timestamp:
- Jul 17, 2012 12:51:06 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/tftp.c
r42020 r42180 58 58 { 59 59 int fRequested; 60 int u16Value;60 uint64_t u64Value; 61 61 } TFPTPSESSIONOPTDESC, *PTFPTPSESSIONOPTDESC; 62 62 … … 73 73 TFPTPSESSIONOPTDESC OptionBlkSize; 74 74 TFPTPSESSIONOPTDESC OptionTSize; 75 TFPTPSESSIONOPTDESC OptionSize;76 75 TFPTPSESSIONOPTDESC OptionTimeout; 77 76 } TFTPSESSION, *PTFTPSESSION, **PPTFTPSESSION; … … 244 243 { 245 244 int rc = VINF_SUCCESS; 246 rc = RTStrToInt 16Full(pcszRawOption, 0, (int16_t *)&pTftpSessionOption->u16Value);245 rc = RTStrToInt64Full(pcszRawOption, 0, (int64_t *)&pTftpSessionOption->u64Value); 247 246 AssertRCReturn(rc, rc); 248 247 pTftpSessionOption->fRequested = 1; … … 293 292 if (!RTStrICmp("blksize", g_TftpDesc[idxOptionArg].pszName)) 294 293 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionBlkSize); 295 else if (!RTStrICmp("size", g_TftpDesc[idxOptionArg].pszName)) 296 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionSize); 297 else if (!RTStrICmp("tsize", g_TftpDesc[idxOptionArg].pszName)) 294 if (!RTStrICmp("tsize", g_TftpDesc[idxOptionArg].pszName)) 298 295 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionTSize); 299 else if (!RTStrICmp("timeoute", g_TftpDesc[idxOptionArg].pszName)) 300 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionSize); 296 if (!RTStrICmp("timeoute", g_TftpDesc[idxOptionArg].pszName)) 297 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionTimeout); 298 /* 299 @todo: process unrecognized options ?? 301 300 else 302 301 rc = VERR_INVALID_PARAMETER; 302 */ 303 303 if (RT_FAILURE(rc)) 304 304 { … … 397 397 size_t cbSessionFileName; 398 398 int rc = VINF_SUCCESS; 399 LogFlowFuncEnter(); 399 400 cbSessionFileName = RTStrPrintf(aszSessionFileName, TFTP_FILENAME_MAX, "%s/%s", 400 401 tftp_prefix, pTftpSession->pszFilename); … … 404 405 return VERR_INTERNAL_ERROR; 405 406 } 407 LogFunc(("aszSessionFileName: %s\n", aszSessionFileName)); 406 408 407 409 if (!RTFileExists(aszSessionFileName)) … … 439 441 440 442 if (pTftpSession->OptionTSize.fRequested) 441 pTftpSession->OptionTSize.u16Value = (uint16_t)cbSessionFile; 442 if ( !pTftpSession->OptionBlkSize.u16Value 443 { 444 pTftpSession->OptionTSize.u64Value = cbSessionFile; 445 } 446 if ( !pTftpSession->OptionBlkSize.u64Value 443 447 && !pTftpSession->OptionBlkSize.fRequested) 444 448 { 445 pTftpSession->OptionBlkSize.u 16Value = 1428;449 pTftpSession->OptionBlkSize.u64Value = 1428; 446 450 } 447 451 LogFlowFuncLeaveRC(rc); … … 484 488 AssertPtrReturn(pu8Data, VERR_INVALID_PARAMETER); 485 489 AssertPtrReturn(pcbReadData, VERR_INVALID_PARAMETER); 490 AssertReturn(pcTftpSession->OptionBlkSize.u64Value < UINT16_MAX, VERR_INVALID_PARAMETER); 486 491 LogFlowFunc(("pcTftpSession:%p, pu8Data:%p, pcbReadData:%p\n", 487 492 pcTftpSession, … … 489 494 pcbReadData)); 490 495 491 u16BlkSize = pcTftpSession->OptionBlkSize.u16Value;496 u16BlkSize = (uint16_t)pcTftpSession->OptionBlkSize.u64Value; 492 497 rc = pftpSessionOpenFile(pData, pcTftpSession, &hSessionFile); 493 498 if (RT_FAILURE(rc)) … … 524 529 } 525 530 526 DECLINLINE(int) tftpAddOptionToOACK(PNATState pData, struct mbuf *pMBuf, const char *pszOptName, uint 16_t u16OptValue)531 DECLINLINE(int) tftpAddOptionToOACK(PNATState pData, struct mbuf *pMBuf, const char *pszOptName, uint64_t u64OptValue) 527 532 { 528 533 char aszOptionBuffer[256]; … … 530 535 int rc = VINF_SUCCESS; 531 536 int cbMBufCurrent = pMBuf->m_len; 532 LogFlowFunc(("pMBuf:%p, pszOptName:%s, u16OptValue:% u\n", pMBuf, pszOptName, u16OptValue));537 LogFlowFunc(("pMBuf:%p, pszOptName:%s, u16OptValue:%ld\n", pMBuf, pszOptName, u64OptValue)); 533 538 AssertPtrReturn(pMBuf, VERR_INVALID_PARAMETER); 534 539 AssertPtrReturn(pszOptName, VERR_INVALID_PARAMETER); … … 536 541 RT_ZERO(aszOptionBuffer); 537 542 iOptLength += RTStrPrintf(aszOptionBuffer, 256 , "%s", pszOptName) + 1; 538 iOptLength += RTStrPrintf(aszOptionBuffer + iOptLength, 256 - iOptLength , "%u", u 16OptValue) + 1;543 iOptLength += RTStrPrintf(aszOptionBuffer + iOptLength, 256 - iOptLength , "%u", u64OptValue) + 1; 539 544 if (iOptLength > M_TRAILINGSPACE(pMBuf)) 540 545 rc = VERR_BUFFER_OVERFLOW; /* buffer too small */ … … 578 583 579 584 if (pTftpSession->OptionBlkSize.fRequested) 580 rc = tftpAddOptionToOACK(pData, m, "blksize", pTftpSession->OptionBlkSize.u16Value); 581 else if (pTftpSession->OptionSize.fRequested) 582 rc = tftpAddOptionToOACK(pData, m, "size", pTftpSession->OptionSize.u16Value); 583 else if (pTftpSession->OptionTSize.fRequested) 584 rc = tftpAddOptionToOACK(pData, m, "tsize", pTftpSession->OptionTSize.u16Value); 585 { 586 if (pTftpSession->OptionBlkSize.u64Value > UINT16_MAX) 587 return -1; 588 else 589 rc = tftpAddOptionToOACK(pData, m, "blksize", pTftpSession->OptionBlkSize.u64Value); 590 } 591 if (pTftpSession->OptionTSize.fRequested) 592 rc = tftpAddOptionToOACK(pData, m, "tsize", pTftpSession->OptionTSize.u64Value); 585 593 586 594 rc = tftpSend(pData, pTftpSession, m, pcTftpIpHeaderRecv); … … 597 605 PTFTPIPHDR pTftpIpHeader = NULL; 598 606 607 LogFlowFunc(("ENTER: errorcode: %RX16, msg: %s\n", errorcode, msg)); 599 608 m = slirpTftpMbufAlloc(pData); 600 609 if (!m) 610 { 611 LogFlowFunc(("LEAVE: Can't allocate mbuf\n")); 601 612 return -1; 613 } 602 614 603 615 m->m_data += if_maxlinkhdr; … … 616 628 tftpSessionTerminate(pTftpSession); 617 629 630 LogFlowFuncLeave(); 618 631 return 0; 619 632 } … … 626 639 struct mbuf *m; 627 640 PTFTPIPHDR pTftpIpHeader; 628 int cbRead ;641 int cbRead = 0; 629 642 int rc = VINF_SUCCESS; 630 643
Note:
See TracChangeset
for help on using the changeset viewer.