diff options
author | Michael Brown <mcb30@ipxe.org> | 2015-08-26 22:35:42 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2015-09-02 13:38:53 +0100 |
commit | 53d2d9e3c37d6170341818a254e18d341ee15511 (patch) | |
tree | 53cd2b5a20c37d270e3046d4823e62d3337ca7c2 /src/arch/i386 | |
parent | be51713474e015eea2ed268348d26fb6b06e3105 (diff) | |
download | ipxe-53d2d9e3c37d6170341818a254e18d341ee15511.tar.gz |
[uri] Generalise tftp_uri() to pxe_uri()
Merge the functionality of parse_next_server_and_filename() and
tftp_uri() into a single pxe_uri(), which takes a server address
(IPv4/IPv6/none) and a filename, and produces a URI using the rule:
- if the filename is a hierarchical absolute URI (i.e. includes a
scheme such as "http://" or "tftp://") then use that URI and ignore
the server address,
- otherwise, if the server address is recognised (according to
sa_family) then construct a TFTP URI based on the server address,
port, and filename
- otherwise fail.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/i386')
-rw-r--r-- | src/arch/i386/interface/pxe/pxe_tftp.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/arch/i386/interface/pxe/pxe_tftp.c b/src/arch/i386/interface/pxe/pxe_tftp.c index 068d8a7b2..3b4c6d847 100644 --- a/src/arch/i386/interface/pxe/pxe_tftp.c +++ b/src/arch/i386/interface/pxe/pxe_tftp.c @@ -160,25 +160,20 @@ static struct pxe_tftp_connection pxe_tftp = { }; /** - * Maximum length of a PXE TFTP URI - * - * The PXE TFTP API provides 128 characters for the filename; the - * extra 128 bytes allow for the remainder of the URI. - */ -#define PXE_TFTP_URI_LEN 256 - -/** * Open PXE TFTP connection * * @v ipaddress IP address - * @v port TFTP server port + * @v port TFTP server port (in network byte order) * @v filename File name * @v blksize Requested block size * @ret rc Return status code */ static int pxe_tftp_open ( IP4_t ipaddress, UDP_PORT_t port, UINT8_t *filename, UINT16_t blksize ) { - struct in_addr address; + union { + struct sockaddr sa; + struct sockaddr_in sin; + } server; struct uri *uri; int rc; @@ -191,12 +186,15 @@ static int pxe_tftp_open ( IP4_t ipaddress, UDP_PORT_t port, pxe_tftp.rc = -EINPROGRESS; /* Construct URI */ - address.s_addr = ipaddress; - DBG ( " %s", inet_ntoa ( address ) ); + memset ( &server, 0, sizeof ( server ) ); + server.sin.sin_family = AF_INET; + server.sin.sin_addr.s_addr = ipaddress; + server.sin.sin_port = port; + DBG ( " %s", sock_ntoa ( &server.sa ) ); if ( port ) DBG ( ":%d", ntohs ( port ) ); DBG ( ":%s", filename ); - uri = tftp_uri ( address, ntohs ( port ), ( ( char * ) filename ) ); + uri = pxe_uri ( &server.sa, ( ( char * ) filename ) ); if ( ! uri ) { DBG ( " could not create URI\n" ); return -ENOMEM; |