[pxe] Use tftp_uri() to construct PXE TFTP URIs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
e2a26f76de
commit
c9dbe1d39c
@ -36,6 +36,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||||||
#include <ipxe/xfer.h>
|
#include <ipxe/xfer.h>
|
||||||
#include <ipxe/open.h>
|
#include <ipxe/open.h>
|
||||||
#include <ipxe/process.h>
|
#include <ipxe/process.h>
|
||||||
|
#include <ipxe/uri.h>
|
||||||
#include <pxe.h>
|
#include <pxe.h>
|
||||||
|
|
||||||
/** A PXE TFTP connection */
|
/** A PXE TFTP connection */
|
||||||
@ -170,10 +171,10 @@ static struct pxe_tftp_connection pxe_tftp = {
|
|||||||
* @v blksize Requested block size
|
* @v blksize Requested block size
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int pxe_tftp_open ( uint32_t ipaddress, unsigned int port,
|
static int pxe_tftp_open ( IP4_t ipaddress, UDP_PORT_t port,
|
||||||
const unsigned char *filename, size_t blksize ) {
|
UINT8_t *filename, UINT16_t blksize ) {
|
||||||
char uri_string[PXE_TFTP_URI_LEN];
|
|
||||||
struct in_addr address;
|
struct in_addr address;
|
||||||
|
struct uri *uri;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Reset PXE TFTP connection structure */
|
/* Reset PXE TFTP connection structure */
|
||||||
@ -184,18 +185,20 @@ static int pxe_tftp_open ( uint32_t ipaddress, unsigned int port,
|
|||||||
pxe_tftp.blksize = blksize;
|
pxe_tftp.blksize = blksize;
|
||||||
pxe_tftp.rc = -EINPROGRESS;
|
pxe_tftp.rc = -EINPROGRESS;
|
||||||
|
|
||||||
/* Construct URI string */
|
/* Construct URI */
|
||||||
address.s_addr = ipaddress;
|
address.s_addr = ipaddress;
|
||||||
if ( ! port )
|
DBG ( " %s", inet_ntoa ( address ) );
|
||||||
port = htons ( TFTP_PORT );
|
if ( port )
|
||||||
snprintf ( uri_string, sizeof ( uri_string ), "tftp://%s:%d%s%s",
|
DBG ( ":%d", ntohs ( port ) );
|
||||||
inet_ntoa ( address ), ntohs ( port ),
|
DBG ( ":%s", filename );
|
||||||
( ( filename[0] == '/' ) ? "" : "/" ), filename );
|
uri = tftp_uri ( address, ntohs ( port ), ( ( char * ) filename ) );
|
||||||
DBG ( " %s", uri_string );
|
if ( ! uri ) {
|
||||||
|
DBG ( " could not create URI\n" );
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
/* Open PXE TFTP connection */
|
/* Open PXE TFTP connection */
|
||||||
if ( ( rc = xfer_open_uri_string ( &pxe_tftp.xfer,
|
if ( ( rc = xfer_open_uri ( &pxe_tftp.xfer, uri ) ) != 0 ) {
|
||||||
uri_string ) ) != 0 ) {
|
|
||||||
DBG ( " could not open (%s)\n", strerror ( rc ) );
|
DBG ( " could not open (%s)\n", strerror ( rc ) );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user