pxe_tftp->rc = rc;
}
+/**
+ * Check flow control window
+ *
+ * @v pxe_tftp PXE TFTP connection
+ * @ret len Length of window
+ */
+static size_t pxe_tftp_xfer_window ( struct pxe_tftp_connection *pxe_tftp ) {
+
+ return pxe_tftp->blksize;
+}
+
/**
* Receive new data
*
static struct interface_operation pxe_tftp_xfer_ops[] = {
INTF_OP ( xfer_deliver, struct pxe_tftp_connection *,
pxe_tftp_xfer_deliver ),
+ INTF_OP ( xfer_window, struct pxe_tftp_connection *,
+ pxe_tftp_xfer_window ),
INTF_OP ( intf_close, struct pxe_tftp_connection *, pxe_tftp_close ),
};
/* Reset PXE TFTP connection structure */
memset ( &pxe_tftp, 0, sizeof ( pxe_tftp ) );
intf_init ( &pxe_tftp.xfer, &pxe_tftp_xfer_desc, NULL );
+ if ( blksize < TFTP_DEFAULT_BLKSIZE )
+ blksize = TFTP_DEFAULT_BLKSIZE;
+ pxe_tftp.blksize = blksize;
pxe_tftp.rc = -EINPROGRESS;
/* Construct URI string */
address.s_addr = ipaddress;
if ( ! port )
port = htons ( TFTP_PORT );
- if ( blksize < TFTP_DEFAULT_BLKSIZE )
- blksize = TFTP_DEFAULT_BLKSIZE;
- snprintf ( uri_string, sizeof ( uri_string ),
- "tftp%s://%s:%d%s%s?blksize=%zd",
- sizeonly ? "size" : "",
- inet_ntoa ( address ), ntohs ( port ),
- ( ( filename[0] == '/' ) ? "" : "/" ), filename, blksize );
+ snprintf ( uri_string, sizeof ( uri_string ), "tftp%s://%s:%d%s%s",
+ sizeonly ? "size" : "", inet_ntoa ( address ),
+ ntohs ( port ), ( ( filename[0] == '/' ) ? "" : "/" ),
+ filename );
DBG ( " %s", uri_string );
/* Open PXE TFTP connection */
return 0;
}
-/**
- * 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
*
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
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 );
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,