diff options
| author | Derek Pryor | 2006-08-11 16:13:02 +0200 |
|---|---|---|
| committer | Derek Pryor | 2006-08-11 16:13:02 +0200 |
| commit | 25ea34a8d75f637c4b4e80c4ec3891ddc56e80b0 (patch) | |
| tree | 786e7bd76109d8b1492e655aff2052e939763fe3 /src/tests/httptest.c | |
| parent | command->data_{in,out} are now userptr_t, so it is invalid to compare (diff) | |
| download | ipxe-25ea34a8d75f637c4b4e80c4ec3891ddc56e80b0.tar.gz ipxe-25ea34a8d75f637c4b4e80c4ec3891ddc56e80b0.tar.xz ipxe-25ea34a8d75f637c4b4e80c4ec3891ddc56e80b0.zip | |
New HTTP protocol and test code
Diffstat (limited to 'src/tests/httptest.c')
| -rw-r--r-- | src/tests/httptest.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/tests/httptest.c b/src/tests/httptest.c new file mode 100644 index 000000000..4b569e854 --- /dev/null +++ b/src/tests/httptest.c @@ -0,0 +1,37 @@ +#include <stdint.h> +#include <string.h> +#include <byteswap.h> +#include <console.h> +#include <vsprintf.h> +#include <gpxe/async.h> +#include <gpxe/http.h> +#include <gpxe/ip.h> +#include <gpxe/uaccess.h> +#include "pxe.h" + +static void test_http_callback ( struct http_request *http, char *data, size_t len ) { + userptr_t pxe_buffer = real_to_user ( 0, 0x7c00 ); + unsigned long offset = http->file_recv; + http->file_recv += len; + copy_to_user ( pxe_buffer, offset, data, len ); +} + +void test_http ( struct net_device *netdev, struct sockaddr_tcpip *server, const char *filename ) { + struct http_request http; + int rc; + + memset ( &http, 0, sizeof ( http ) ); + memcpy ( &http.tcp.peer, server, sizeof ( http.tcp.peer ) ); + http.filename = filename; + http.callback = test_http_callback; + + rc = async_wait ( get_http ( &http ) ); + if ( rc ) { + printf ( "HTTP fetch failed\n" ); + } + + printf ( "Attempting PXE boot\n" ); + pxe_netdev = netdev; + rc = pxe_boot(); + printf ( "PXE NBP returned with status %04x\n", rc); +} |
