summaryrefslogtreecommitdiffstats
path: root/src/proto
diff options
context:
space:
mode:
authorMichael Brown2005-06-01 21:10:25 +0200
committerMichael Brown2005-06-01 21:10:25 +0200
commitfa17bf09179d07bb5affe0ac1fccfed2144acb13 (patch)
tree29bdd968f95d5244f2d10b4eaaa247e9a7818e48 /src/proto
parentRe-order functions for more logical documentation (diff)
downloadipxe-fa17bf09179d07bb5affe0ac1fccfed2144acb13.tar.gz
ipxe-fa17bf09179d07bb5affe0ac1fccfed2144acb13.tar.xz
ipxe-fa17bf09179d07bb5affe0ac1fccfed2144acb13.zip
Make rfc2090 multicast option optional
Diffstat (limited to 'src/proto')
-rw-r--r--src/proto/tftpcore.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/proto/tftpcore.c b/src/proto/tftpcore.c
index b97cd681..de1aa0eb 100644
--- a/src/proto/tftpcore.c
+++ b/src/proto/tftpcore.c
@@ -125,6 +125,7 @@ int tftp_get ( struct tftp_state *state, long timeout,
* @v tftp_state::client::sin_port Client UDP port, or 0
* @v tftp_state::blksize Requested blksize, or 0
* @v filename File name
+ * @v multicast Enable/disable rfc2090 multicast TFTP
* @ret True Received a non-error response
* @ret False Received error response / no response
* @ret tftp_state::server::sin_port TFTP server UDP port
@@ -182,9 +183,10 @@ int tftp_get ( struct tftp_state *state, long timeout,
* the server's response originated. This may or may not be the port
* to which the open request was sent.
*
- * The options "blksize", "tsize" and "multicast" will always be
- * appended to a TFTP open request. Servers that do not understand
- * any of these options should simply ignore them.
+ * The options "blksize" and "tsize" will always be appended to a TFTP
+ * open request. The option "multicast" will be appended to the
+ * request if #multicast is True. Servers that do not understand any
+ * of these options should simply ignore them.
*
* tftp_open() will not automatically join or leave multicast groups;
* the caller is responsible for calling join_group() and
@@ -194,10 +196,11 @@ int tftp_get ( struct tftp_state *state, long timeout,
* will return False and #errno will be set accordingly.
*/
int tftp_open ( struct tftp_state *state, const char *filename,
- union tftp_any **reply ) {
+ union tftp_any **reply, int multicast ) {
static unsigned short lport = 2000; /* local port */
int fixed_lport;
struct tftp_rrq rrq;
+ char *p;
unsigned int rrqlen;
int retry;
@@ -217,11 +220,13 @@ int tftp_open ( struct tftp_state *state, const char *filename,
/* Set up RRQ */
rrq.opcode = htons ( TFTP_RRQ );
- rrqlen = ( offsetof ( typeof ( rrq ), data ) +
- sprintf ( rrq.data,
- "%s%coctet%cblksize%c%d%ctsize%c0%cmulticast%c",
- filename, 0, 0, 0, state->blksize, 0, 0, 0, 0 )
- + 1 );
+ p = rrq.data;
+ p += sprintf ( p, "%s%coctet%cblksize%c%d%ctsize%c0",
+ filename, 0, 0, 0, state->blksize, 0, 0 ) + 1;
+ if ( multicast ) {
+ p += sprintf ( p, "multicast%c", 0 ) + 1;
+ }
+ rrqlen = ( p - ( char * ) &rrq );
/* Set negotiated blksize to default value */
state->blksize = TFTP_DEFAULT_BLKSIZE;
@@ -257,7 +262,7 @@ int tftp_open ( struct tftp_state *state, const char *filename,
state->server.sin_port );
return 1;
}
- if ( reply ) {
+ if ( *reply ) {
/* We got an error response; abort */
return 0;
}
@@ -463,7 +468,7 @@ int tftp_ack ( struct tftp_state *state, union tftp_any **reply ) {
/* We got a non-error response */
return 1;
}
- if ( reply ) {
+ if ( *reply ) {
/* We got an error response */
return 0;
}