|  | @@ -36,6 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 | 
		
	
		
			
			| 36 | 36 |  #include <ipxe/xfer.h>
 | 
		
	
		
			
			| 37 | 37 |  #include <ipxe/open.h>
 | 
		
	
		
			
			| 38 | 38 |  #include <ipxe/process.h>
 | 
		
	
		
			
			|  | 39 | +#include <ipxe/uri.h>
 | 
		
	
		
			
			| 39 | 40 |  #include <pxe.h>
 | 
		
	
		
			
			| 40 | 41 |  
 | 
		
	
		
			
			| 41 | 42 |  /** A PXE TFTP connection */
 | 
		
	
	
		
			
			|  | @@ -170,10 +171,10 @@ static struct pxe_tftp_connection pxe_tftp = {
 | 
		
	
		
			
			| 170 | 171 |   * @v blksize		Requested block size
 | 
		
	
		
			
			| 171 | 172 |   * @ret rc		Return status code
 | 
		
	
		
			
			| 172 | 173 |   */
 | 
		
	
		
			
			| 173 |  | -static int pxe_tftp_open ( uint32_t ipaddress, unsigned int port,
 | 
		
	
		
			
			| 174 |  | -			   const unsigned char *filename, size_t blksize ) {
 | 
		
	
		
			
			| 175 |  | -	char uri_string[PXE_TFTP_URI_LEN];
 | 
		
	
		
			
			|  | 174 | +static int pxe_tftp_open ( IP4_t ipaddress, UDP_PORT_t port,
 | 
		
	
		
			
			|  | 175 | +			   UINT8_t *filename, UINT16_t blksize ) {
 | 
		
	
		
			
			| 176 | 176 |  	struct in_addr address;
 | 
		
	
		
			
			|  | 177 | +	struct uri *uri;
 | 
		
	
		
			
			| 177 | 178 |  	int rc;
 | 
		
	
		
			
			| 178 | 179 |  
 | 
		
	
		
			
			| 179 | 180 |  	/* Reset PXE TFTP connection structure */
 | 
		
	
	
		
			
			|  | @@ -184,18 +185,20 @@ static int pxe_tftp_open ( uint32_t ipaddress, unsigned int port,
 | 
		
	
		
			
			| 184 | 185 |  	pxe_tftp.blksize = blksize;
 | 
		
	
		
			
			| 185 | 186 |  	pxe_tftp.rc = -EINPROGRESS;
 | 
		
	
		
			
			| 186 | 187 |  
 | 
		
	
		
			
			| 187 |  | -	/* Construct URI string */
 | 
		
	
		
			
			|  | 188 | +	/* Construct URI */
 | 
		
	
		
			
			| 188 | 189 |  	address.s_addr = ipaddress;
 | 
		
	
		
			
			| 189 |  | -	if ( ! port )
 | 
		
	
		
			
			| 190 |  | -		port = htons ( TFTP_PORT );
 | 
		
	
		
			
			| 191 |  | -	snprintf ( uri_string, sizeof ( uri_string ), "tftp://%s:%d%s%s",
 | 
		
	
		
			
			| 192 |  | -		   inet_ntoa ( address ), ntohs ( port ),
 | 
		
	
		
			
			| 193 |  | -		   ( ( filename[0] == '/' ) ? "" : "/" ), filename );
 | 
		
	
		
			
			| 194 |  | -	DBG ( " %s", uri_string );
 | 
		
	
		
			
			|  | 190 | +	DBG ( " %s", inet_ntoa ( address ) );
 | 
		
	
		
			
			|  | 191 | +	if ( port )
 | 
		
	
		
			
			|  | 192 | +		DBG ( ":%d", ntohs ( port ) );
 | 
		
	
		
			
			|  | 193 | +	DBG ( ":%s", filename );
 | 
		
	
		
			
			|  | 194 | +	uri = tftp_uri ( address, ntohs ( port ), ( ( char * ) filename ) );
 | 
		
	
		
			
			|  | 195 | +	if ( ! uri ) {
 | 
		
	
		
			
			|  | 196 | +		DBG ( " could not create URI\n" );
 | 
		
	
		
			
			|  | 197 | +		return -ENOMEM;
 | 
		
	
		
			
			|  | 198 | +	}
 | 
		
	
		
			
			| 195 | 199 |  
 | 
		
	
		
			
			| 196 | 200 |  	/* Open PXE TFTP connection */
 | 
		
	
		
			
			| 197 |  | -	if ( ( rc = xfer_open_uri_string ( &pxe_tftp.xfer,
 | 
		
	
		
			
			| 198 |  | -					   uri_string ) ) != 0 ) {
 | 
		
	
		
			
			|  | 201 | +	if ( ( rc = xfer_open_uri ( &pxe_tftp.xfer, uri ) ) != 0 ) {
 | 
		
	
		
			
			| 199 | 202 |  		DBG ( " could not open (%s)\n", strerror ( rc ) );
 | 
		
	
		
			
			| 200 | 203 |  		return rc;
 | 
		
	
		
			
			| 201 | 204 |  	}
 |