summaryrefslogtreecommitdiffstats
path: root/src/net/udp/tftp.c
diff options
context:
space:
mode:
authorMichael Brown2013-03-06 18:35:30 +0100
committerMichael Brown2013-03-06 18:35:30 +0100
commit02b914e8129c55a1b8766de0ab49928929392e89 (patch)
treed7259f5a4796e2b7bcf6ecb175191ed4a2892d8e /src/net/udp/tftp.c
parent[menu] Prevent separators with shortcut keys from being selected (diff)
downloadipxe-02b914e8129c55a1b8766de0ab49928929392e89.tar.gz
ipxe-02b914e8129c55a1b8766de0ab49928929392e89.tar.xz
ipxe-02b914e8129c55a1b8766de0ab49928929392e89.zip
[tftp] Allow TFTP block size to be controlled via the PXE TFTP API
The PXE TFTP API allows the caller to request a particular TFTP block size. Since mid-2008, iPXE has appended a "?blksize=xxx" parameter to the TFTP URI constructed internally; nothing has ever parsed this parameter. Nobody seems to have cared that this parameter has been ignored for almost five years. Fix by using xfer_window(), which provides a fairly natural way to convey the block size information from the PXE TFTP API to the TFTP protocol layer. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/udp/tftp.c')
-rw-r--r--src/net/udp/tftp.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c
index a6c64b4a..d686aac9 100644
--- a/src/net/udp/tftp.c
+++ b/src/net/udp/tftp.c
@@ -288,24 +288,6 @@ static int tftp_presize ( struct tftp_request *tftp, size_t filesize ) {
}
/**
- * TFTP requested blocksize
- *
- * This is treated as a global configuration parameter.
- */
-static unsigned int tftp_request_blksize = TFTP_MAX_BLKSIZE;
-
-/**
- * Set TFTP request blocksize
- *
- * @v blksize Requested block size
- */
-void tftp_set_request_blksize ( unsigned int blksize ) {
- if ( blksize < TFTP_DEFAULT_BLKSIZE )
- blksize = TFTP_DEFAULT_BLKSIZE;
- tftp_request_blksize = blksize;
-}
-
-/**
* MTFTP multicast receive address
*
* This is treated as a global configuration parameter.
@@ -345,6 +327,7 @@ static int tftp_send_rrq ( struct tftp_request *tftp ) {
const char *path;
size_t len;
struct io_buffer *iobuf;
+ size_t blksize;
/* Strip initial '/' if present. If we were opened via the
* URI interface, then there will be an initial '/', since a
@@ -370,6 +353,11 @@ static int tftp_send_rrq ( struct tftp_request *tftp ) {
if ( ! iobuf )
return -ENOMEM;
+ /* Determine block size */
+ blksize = xfer_window ( &tftp->xfer );
+ if ( blksize > TFTP_MAX_BLKSIZE )
+ blksize = TFTP_MAX_BLKSIZE;
+
/* Build request */
rrq = iob_put ( iobuf, sizeof ( *rrq ) );
rrq->opcode = htons ( TFTP_RRQ );
@@ -378,8 +366,8 @@ static int tftp_send_rrq ( struct tftp_request *tftp ) {
if ( tftp->flags & TFTP_FL_RRQ_SIZES ) {
iob_put ( iobuf, snprintf ( iobuf->tail,
iob_tailroom ( iobuf ),
- "blksize%c%d%ctsize%c0", 0,
- tftp_request_blksize, 0, 0 ) + 1 );
+ "blksize%c%zd%ctsize%c0",
+ 0, blksize, 0, 0 ) + 1 );
}
if ( tftp->flags & TFTP_FL_RRQ_MULTICAST ) {
iob_put ( iobuf, snprintf ( iobuf->tail,