VirtualBox

Ignore:
Timestamp:
Jul 4, 2012 4:57:11 AM (12 years ago)
Author:
vboxsync
Message:

NAT: use read byte counter instead of block number.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/tftp.c

    r41997 r42009  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2012 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6868    uint16_t    u16ClientPort;
    6969    int         iTimestamp;
     70    int         cbTransfered;
    7071    ENMTFTPSESSIONFMT enmTftpFmt;
    7172    TFPTPSESSIONOPTDESC OptionBlkSize;
     
    493494DECLINLINE(int) tftpReadDataBlock(PNATState pData,
    494495                                  PTFTPSESSION pcTftpSession,
    495                                   uint16_t u16BlockNr,
    496496                                  uint8_t *pu8Data,
    497497                                  int *pcbReadData)
     
    521521    {
    522522        rc = RTFileSeek(hSessionFile,
    523                         u16BlockNr * u16BlkSize,
     523                        pcTftpSession->cbTransfered,
    524524                        RTFILE_SEEK_BEGIN,
    525525                        NULL);
     
    647647    struct mbuf *m;
    648648    PTFTPIPHDR pTftpIpHeader;
    649     int nobytes;
    650     int rc = VINF_SUCCESS;
    651 
    652     /* we should be sure that we don't talk about file offset prior 0 ;) */
    653     if (block_nr < 1)
    654         return -1;
     649    int cbRead;
     650    int rc = VINF_SUCCESS;
    655651
    656652    m = slirpTftpMbufAlloc(pData);
     
    666662    pTftpIpHeader->Core.u16TftpOpCode = RT_H2N_U16(block_nr);
    667663
    668     rc = tftpReadDataBlock(pData, pTftpSession, block_nr - 1, (uint8_t *)&pTftpIpHeader->Core.u16TftpOpCode + sizeof(uint16_t), &nobytes);
     664    rc = tftpReadDataBlock(pData, pTftpSession, (uint8_t *)&pTftpIpHeader->Core.u16TftpOpCode + sizeof(uint16_t), &cbRead);
    669665
    670666    if (RT_SUCCESS(rc))
    671667    {
    672         m->m_len += nobytes;
     668        pTftpSession->cbTransfered += cbRead;
     669        m->m_len += cbRead;
    673670        tftpSend(pData, pTftpSession, m, pcTftpIpHeaderRecv);
    674         if (nobytes > 0)
     671        if (cbRead > 0)
    675672            tftpSessionUpdate(pData, pTftpSession);
    676673        else
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette