RFC1350 uses the 'opcode' term for the first 2-bytes field
of TFTP packet. But the U-boot tftp code uses the 'proto' term
for the same thing.
The patch takes back original term and makes opcode calculation
more clear.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The separation of incoming packets handling makes it much easier
to run barebox tftp client on top of picotcp network stack in the future.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This file originates in Linux. Linux has it under include/linux/
directory since commit dccd2304cc90.
Let's move it to the same place as well in barebox.
This commit was generated by the following commands:
find -name '*.[chS]' | xargs sed -i -e 's:<sizes.h>:<linux/sizes.h>:'
git mv include/sizes.h include/linux/
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
If there's packet loss and the remote server needs to retransmit,
there is falsely no timeframe left because TIMEOUT (server wait time)
and TFTP_TIMEOUT (abort timer) are the same.
This patch increases TFTP_TIMEOUT.
See RFC2349 for more info: http://tools.ietf.org/html/rfc2349
Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Copying files to tftp is broken since:
| commit d4f5bb1e01
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date: Sat Sep 28 13:12:50 2013 +0200
|
| copy_file: Add missing O_TRUNC
|
| Without it, when copying a smaller file over a larger file the
| resulting file still has the remaining space from the larger file.
|
| Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Since this commit copy_file passes O_TRUNC to open(). This results in the
fs layer calling fsdrv->truncate. tftp returns -ENOSYS here and open returns
with an error. To fix this return 0 for the truncate callback in tftp. Also
enforce the O_TRUNC flag when opening a file for writing on tftp as the files
are always truncated on tftp anyway.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: andreas.willig@rafi.de
Some tftp servers (for example netkit-tftp) do not pass the filesize.
Add a workaround for read_file which reads the file into a temporary
file which then is copied to a buffer.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
When during tftp receive operation a ACK packet can't successfully be sent
the timer was resetted directly after send resulting in a deadlock.
This patch changes the timer reset operation in a way that it is only resetted
when the actually is progress, namely in the TFTP_ACK/TFTP_DATA pathes in the
tftp handler.
Reported-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Antony Pavlov <antonynpavlov@gmail.com>
In tftp_read we send a request for a new packet without checking if we
have enough space in the FIFO. This can lead to a FIFO overflow and a
corrupt file. Add a check for it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
tftp_send is called often. Each time, when in STATE_RDATA, a packet
is requested from the tftp server, even if we requested the same packet
already.
Stop this by tracking which packet we requested.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The FSF address has changed in the past. Instead of updating it
each time the address changes, just drop it completely treewide.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
With files smaller than the tftp block size the whole transfer is done
in tftp_do_open already. In this case we are in STATE_DONE, but there
is no error. Set priv->err to 0 and check for it to be able to transfer
small files.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
instead of assuming the backingstore is a ip address, use resolv()
to make it possible to pass in a hostname.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This adds tftp filesystem support. It currently duplicates
significant amounts of the tftp (command) support. This is ok
since we can eventually drop the original tftp command later.
tftp is not really suitable to be handled as a filesystem. It lacks
support for stat, reading directories and other things. Handling
it as a filesystem has one big advantage though: tftp is no special
case for boot scripts and/or commands anymore which makes them simpler.
This implementation has some improvements to the original tftp command.
It supports blocksize negotiation which speeds up transfers if the tftp
server supports it. Also we can determine the filesize to transfer if
the remote end supports it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>