summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorMichael Brown2007-01-12 20:19:59 +0100
committerMichael Brown2007-01-12 20:19:59 +0100
commit341c0b9cfbb25cc1b2b57900f2f01d01d8482703 (patch)
tree5d3e012e8261a39c0ea6e705a55bf21c57f27d16 /src/usr
parentFixed HTTP (diff)
downloadipxe-341c0b9cfbb25cc1b2b57900f2f01d01d8482703.tar.gz
ipxe-341c0b9cfbb25cc1b2b57900f2f01d01d8482703.tar.xz
ipxe-341c0b9cfbb25cc1b2b57900f2f01d01d8482703.zip
Add HTTP test support
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/fetch.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/usr/fetch.c b/src/usr/fetch.c
index fe5ae59fa..ce0fea954 100644
--- a/src/usr/fetch.c
+++ b/src/usr/fetch.c
@@ -30,8 +30,9 @@
#include <usr/fetch.h>
#include <byteswap.h>
-#include <gpxe/tftp.h>
#include <gpxe/dhcp.h>
+#include <gpxe/tftp.h>
+#include <gpxe/http.h>
/**
* Fetch file
@@ -53,23 +54,41 @@ int fetch ( const char *filename, userptr_t *data, size_t *len ) {
if ( ( rc = ebuffer_alloc ( &buffer, 0 ) ) != 0 )
return rc;
+#warning "Temporary pseudo-URL parsing code"
+
/* Retrieve the file */
- struct tftp_session tftp;
union {
struct sockaddr_tcpip st;
struct sockaddr_in sin;
} server;
+ struct tftp_session tftp;
+ struct http_request http;
+ struct async_operation *aop;
memset ( &tftp, 0, sizeof ( tftp ) );
+ memset ( &http, 0, sizeof ( http ) );
memset ( &server, 0, sizeof ( server ) );
server.sin.sin_family = AF_INET;
find_global_dhcp_ipv4_option ( DHCP_EB_SIADDR,
&server.sin.sin_addr );
+
+
+#if 0
server.sin.sin_port = htons ( TFTP_PORT );
udp_connect ( &tftp.udp, &server.st );
tftp.filename = filename;
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 );
return rc;
}