mirror of https://github.com/ipxe/ipxe.git
Add HTTP test support
parent
497c3a5aad
commit
341c0b9cfb
|
@ -30,8 +30,9 @@
|
||||||
#include <usr/fetch.h>
|
#include <usr/fetch.h>
|
||||||
|
|
||||||
#include <byteswap.h>
|
#include <byteswap.h>
|
||||||
#include <gpxe/tftp.h>
|
|
||||||
#include <gpxe/dhcp.h>
|
#include <gpxe/dhcp.h>
|
||||||
|
#include <gpxe/tftp.h>
|
||||||
|
#include <gpxe/http.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch file
|
* Fetch file
|
||||||
|
@ -53,23 +54,41 @@ int fetch ( const char *filename, userptr_t *data, size_t *len ) {
|
||||||
if ( ( rc = ebuffer_alloc ( &buffer, 0 ) ) != 0 )
|
if ( ( rc = ebuffer_alloc ( &buffer, 0 ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
#warning "Temporary pseudo-URL parsing code"
|
||||||
|
|
||||||
/* Retrieve the file */
|
/* Retrieve the file */
|
||||||
struct tftp_session tftp;
|
|
||||||
union {
|
union {
|
||||||
struct sockaddr_tcpip st;
|
struct sockaddr_tcpip st;
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
} server;
|
} server;
|
||||||
|
struct tftp_session tftp;
|
||||||
|
struct http_request http;
|
||||||
|
struct async_operation *aop;
|
||||||
|
|
||||||
memset ( &tftp, 0, sizeof ( tftp ) );
|
memset ( &tftp, 0, sizeof ( tftp ) );
|
||||||
|
memset ( &http, 0, sizeof ( http ) );
|
||||||
memset ( &server, 0, sizeof ( server ) );
|
memset ( &server, 0, sizeof ( server ) );
|
||||||
server.sin.sin_family = AF_INET;
|
server.sin.sin_family = AF_INET;
|
||||||
find_global_dhcp_ipv4_option ( DHCP_EB_SIADDR,
|
find_global_dhcp_ipv4_option ( DHCP_EB_SIADDR,
|
||||||
&server.sin.sin_addr );
|
&server.sin.sin_addr );
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
server.sin.sin_port = htons ( TFTP_PORT );
|
server.sin.sin_port = htons ( TFTP_PORT );
|
||||||
udp_connect ( &tftp.udp, &server.st );
|
udp_connect ( &tftp.udp, &server.st );
|
||||||
tftp.filename = filename;
|
tftp.filename = filename;
|
||||||
tftp.buffer = &buffer;
|
tftp.buffer = &buffer;
|
||||||
if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 ) {
|
aop = tftp_get ( &tftp );
|
||||||
|
#else
|
||||||
|
server.sin.sin_port = htons ( HTTP_PORT );
|
||||||
|
memcpy ( &http.server, &server, sizeof ( http.server ) );
|
||||||
|
http.hostname = inet_ntoa ( server.sin.sin_addr );
|
||||||
|
http.filename = filename;
|
||||||
|
http.buffer = &buffer;
|
||||||
|
aop = http_get ( &http );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( ( rc = async_wait ( aop ) ) != 0 ) {
|
||||||
efree ( buffer.addr );
|
efree ( buffer.addr );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue