summaryrefslogtreecommitdiffstats
path: root/src/net/udp
diff options
context:
space:
mode:
authorMichael Brown2014-02-27 14:32:53 +0100
committerMichael Brown2014-02-27 14:32:53 +0100
commit76675365271291beb9ddaeec10da14f4faa55ecc (patch)
tree0143200258d478e381b9d492bead2bdda91fe865 /src/net/udp
parent[params] Use reference counters for form parameter lists (diff)
downloadipxe-76675365271291beb9ddaeec10da14f4faa55ecc.tar.gz
ipxe-76675365271291beb9ddaeec10da14f4faa55ecc.tar.xz
ipxe-76675365271291beb9ddaeec10da14f4faa55ecc.zip
[uri] Refactor URI parsing and formatting
Add support for parsing of URIs containing literal IPv6 addresses (e.g. "http://[fe80::69ff:fe50:5845%25net0]/boot.ipxe"). Duplicate URIs by directly copying the relevant fields, rather than by formatting and reparsing a URI string. This relaxes the requirements on the URI formatting code and allows it to focus on generating human-readable URIs (e.g. by not escaping ':' characters within literal IPv6 addresses). As a side-effect, this allows relative URIs containing parameter lists (e.g. "../boot.php##params") to function as expected. Add validity check for FTP paths to ensure that only printable characters are accepted (since FTP is a human-readable line-based protocol with no support for character escaping). Construct TFTP next-server+filename URIs directly, rather than parsing a constructed "tftp://..." string, Add self-tests for URI functions. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/udp')
-rw-r--r--src/net/udp/slam.c2
-rw-r--r--src/net/udp/tftp.c14
2 files changed, 2 insertions, 14 deletions
diff --git a/src/net/udp/slam.c b/src/net/udp/slam.c
index e1b584fe..3cb492d7 100644
--- a/src/net/udp/slam.c
+++ b/src/net/udp/slam.c
@@ -723,7 +723,7 @@ static int slam_open ( struct interface *xfer, struct uri *uri ) {
/* Open multicast socket */
memcpy ( &multicast, &default_multicast, sizeof ( multicast ) );
- if ( uri->path &&
+ if ( uri->path &&
( ( rc = slam_parse_multicast_address ( slam, uri->path,
&multicast ) ) != 0 ) ) {
goto err;
diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c
index d686aac9..ee827ae3 100644
--- a/src/net/udp/tftp.c
+++ b/src/net/udp/tftp.c
@@ -323,24 +323,12 @@ void tftp_set_mtftp_port ( unsigned int port ) {
* @ret rc Return status code
*/
static int tftp_send_rrq ( struct tftp_request *tftp ) {
+ const char *path = tftp->uri->path;
struct tftp_rrq *rrq;
- 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
- * full tftp:// URI provides no way to specify a non-absolute
- * path. However, many TFTP servers (particularly Windows
- * TFTP servers) complain about having an initial '/', and it
- * violates user expectations to have a '/' silently added to
- * the DHCP-specified filename.
- */
- path = tftp->uri->path;
- if ( *path == '/' )
- path++;
-
DBGC ( tftp, "TFTP %p requesting \"%s\"\n", tftp, path );
/* Allocate buffer */