|
@@ -30,8 +30,9 @@
|
30
|
30
|
#include <usr/fetch.h>
|
31
|
31
|
|
32
|
32
|
#include <byteswap.h>
|
33
|
|
-#include <gpxe/tftp.h>
|
34
|
33
|
#include <gpxe/dhcp.h>
|
|
34
|
+#include <gpxe/tftp.h>
|
|
35
|
+#include <gpxe/http.h>
|
35
|
36
|
|
36
|
37
|
/**
|
37
|
38
|
* Fetch file
|
|
@@ -53,23 +54,41 @@ int fetch ( const char *filename, userptr_t *data, size_t *len ) {
|
53
|
54
|
if ( ( rc = ebuffer_alloc ( &buffer, 0 ) ) != 0 )
|
54
|
55
|
return rc;
|
55
|
56
|
|
|
57
|
+#warning "Temporary pseudo-URL parsing code"
|
|
58
|
+
|
56
|
59
|
/* Retrieve the file */
|
57
|
|
- struct tftp_session tftp;
|
58
|
60
|
union {
|
59
|
61
|
struct sockaddr_tcpip st;
|
60
|
62
|
struct sockaddr_in sin;
|
61
|
63
|
} server;
|
|
64
|
+ struct tftp_session tftp;
|
|
65
|
+ struct http_request http;
|
|
66
|
+ struct async_operation *aop;
|
62
|
67
|
|
63
|
68
|
memset ( &tftp, 0, sizeof ( tftp ) );
|
|
69
|
+ memset ( &http, 0, sizeof ( http ) );
|
64
|
70
|
memset ( &server, 0, sizeof ( server ) );
|
65
|
71
|
server.sin.sin_family = AF_INET;
|
66
|
72
|
find_global_dhcp_ipv4_option ( DHCP_EB_SIADDR,
|
67
|
73
|
&server.sin.sin_addr );
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+#if 0
|
68
|
77
|
server.sin.sin_port = htons ( TFTP_PORT );
|
69
|
78
|
udp_connect ( &tftp.udp, &server.st );
|
70
|
79
|
tftp.filename = filename;
|
71
|
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
|
92
|
efree ( buffer.addr );
|
74
|
93
|
return rc;
|
75
|
94
|
}
|