You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

httptest.c 1004B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <stdint.h>
  2. #include <string.h>
  3. #include <byteswap.h>
  4. #include <console.h>
  5. #include <vsprintf.h>
  6. #include <gpxe/async.h>
  7. #include <gpxe/http.h>
  8. #include <gpxe/ip.h>
  9. #include <gpxe/uaccess.h>
  10. #include "pxe.h"
  11. static void test_http_callback ( struct http_request *http, char *data, size_t len ) {
  12. userptr_t pxe_buffer = real_to_user ( 0, 0x7c00 );
  13. unsigned long offset = http->file_recv;
  14. http->file_recv += len;
  15. copy_to_user ( pxe_buffer, offset, data, len );
  16. }
  17. void test_http ( struct net_device *netdev, struct sockaddr_tcpip *server, const char *filename ) {
  18. struct http_request http;
  19. int rc;
  20. memset ( &http, 0, sizeof ( http ) );
  21. memcpy ( &http.tcp.peer, server, sizeof ( http.tcp.peer ) );
  22. http.filename = filename;
  23. http.callback = test_http_callback;
  24. rc = async_wait ( get_http ( &http ) );
  25. if ( rc ) {
  26. printf ( "HTTP fetch failed\n" );
  27. }
  28. printf ( "Attempting PXE boot\n" );
  29. pxe_netdev = netdev;
  30. rc = pxe_boot();
  31. printf ( "PXE NBP returned with status %04x\n", rc);
  32. }