VirtualBox

Changeset 42020 in vbox


Ignore:
Timestamp:
Jul 4, 2012 2:16:39 PM (13 years ago)
Author:
vboxsync
Message:

NAT: adds TFTP ACK verification.

File:
1 edited

Legend:

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

    r42014 r42020  
    6969    int         iTimestamp;
    7070    uint64_t    cbTransfered;
     71    uint16_t    cTftpAck;
    7172    ENMTFTPSESSIONFMT enmTftpFmt;
    7273    TFPTPSESSIONOPTDESC OptionBlkSize;
     
    620621static int tftpSendData(PNATState pData,
    621622                          PTFTPSESSION pTftpSession,
    622                           u_int16_t block_nr,
     623                          uint16_t u16Block,
    623624                          PCTFTPIPHDR pcTftpIpHeaderRecv)
    624625{
     
    627628    int cbRead;
    628629    int rc = VINF_SUCCESS;
     630
     631    if (u16Block == pTftpSession->cTftpAck)
     632        pTftpSession->cTftpAck++;
     633    else
     634    {
     635        tftpSendError(pData, pTftpSession, 6, "ACK is wrong", pcTftpIpHeaderRecv);
     636        tftpSessionTerminate(pTftpSession);
     637        return -1;
     638    }
    629639
    630640    m = slirpTftpMbufAlloc(pData);
     
    638648
    639649    pTftpIpHeader->u16TftpOpType = RT_H2N_U16_C(TFTP_DATA);
    640     pTftpIpHeader->Core.u16TftpOpCode = RT_H2N_U16(block_nr);
     650    pTftpIpHeader->Core.u16TftpOpCode = RT_H2N_U16(pTftpSession->cTftpAck);
    641651
    642652    rc = tftpReadDataBlock(pData, pTftpSession, (uint8_t *)&pTftpIpHeader->Core.u16TftpOpCode + sizeof(uint16_t), &cbRead);
     
    729739    AssertReturnVoid(tftpSendData(pData,
    730740                                    pTftpSession,
    731                                     RT_N2H_U16(pTftpIpHeader->Core.u16TftpOpCode) + 1, pTftpIpHeader) == 0);
     741                                    RT_N2H_U16(pTftpIpHeader->Core.u16TftpOpCode), pTftpIpHeader) == 0);
    732742}
    733743
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