From 341c0b9cfbb25cc1b2b57900f2f01d01d8482703 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 12 Jan 2007 19:19:59 +0000 Subject: [PATCH] Add HTTP test support --- src/usr/fetch.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/usr/fetch.c b/src/usr/fetch.c index fe5ae59f..ce0fea95 100644 --- a/src/usr/fetch.c +++ b/src/usr/fetch.c @@ -30,8 +30,9 @@ #include #include -#include #include +#include +#include /** * 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; }