Browse Source

Add HTTP test support

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
341c0b9cfb
1 changed files with 22 additions and 3 deletions
  1. 22
    3
      src/usr/fetch.c

+ 22
- 3
src/usr/fetch.c View File

30
 #include <usr/fetch.h>
30
 #include <usr/fetch.h>
31
 
31
 
32
 #include <byteswap.h>
32
 #include <byteswap.h>
33
-#include <gpxe/tftp.h>
34
 #include <gpxe/dhcp.h>
33
 #include <gpxe/dhcp.h>
34
+#include <gpxe/tftp.h>
35
+#include <gpxe/http.h>
35
 
36
 
36
 /**
37
 /**
37
  * Fetch file
38
  * Fetch file
53
 	if ( ( rc = ebuffer_alloc ( &buffer, 0 ) ) != 0 )
54
 	if ( ( rc = ebuffer_alloc ( &buffer, 0 ) ) != 0 )
54
 		return rc;
55
 		return rc;
55
 
56
 
57
+#warning "Temporary pseudo-URL parsing code"
58
+
56
 	/* Retrieve the file */
59
 	/* Retrieve the file */
57
-	struct tftp_session tftp;
58
 	union {
60
 	union {
59
 		struct sockaddr_tcpip st;
61
 		struct sockaddr_tcpip st;
60
 		struct sockaddr_in sin;
62
 		struct sockaddr_in sin;
61
 	} server;
63
 	} server;
64
+	struct tftp_session tftp;
65
+	struct http_request http;
66
+	struct async_operation *aop;
62
 
67
 
63
 	memset ( &tftp, 0, sizeof ( tftp ) );
68
 	memset ( &tftp, 0, sizeof ( tftp ) );
69
+	memset ( &http, 0, sizeof ( http ) );
64
 	memset ( &server, 0, sizeof ( server ) );
70
 	memset ( &server, 0, sizeof ( server ) );
65
 	server.sin.sin_family = AF_INET;
71
 	server.sin.sin_family = AF_INET;
66
 	find_global_dhcp_ipv4_option ( DHCP_EB_SIADDR,
72
 	find_global_dhcp_ipv4_option ( DHCP_EB_SIADDR,
67
 				       &server.sin.sin_addr );
73
 				       &server.sin.sin_addr );
74
+
75
+
76
+#if 0
68
 	server.sin.sin_port = htons ( TFTP_PORT );
77
 	server.sin.sin_port = htons ( TFTP_PORT );
69
 	udp_connect ( &tftp.udp, &server.st );
78
 	udp_connect ( &tftp.udp, &server.st );
70
 	tftp.filename = filename;
79
 	tftp.filename = filename;
71
 	tftp.buffer = &buffer;
80
 	tftp.buffer = &buffer;
72
-	if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 ) {
81
+	aop = tftp_get ( &tftp );
82
+#else
83
+	server.sin.sin_port = htons ( HTTP_PORT );
84
+	memcpy ( &http.server, &server, sizeof ( http.server ) );
85
+	http.hostname = inet_ntoa ( server.sin.sin_addr );
86
+	http.filename = filename;
87
+	http.buffer = &buffer;
88
+	aop = http_get ( &http );
89
+#endif
90
+
91
+	if ( ( rc = async_wait ( aop ) ) != 0 ) {
73
 		efree ( buffer.addr );
92
 		efree ( buffer.addr );
74
 		return rc;
93
 		return rc;
75
 	}
94
 	}

Loading…
Cancel
Save