mirror of
https://github.com/ipxe/ipxe
synced 2025-12-15 09:04:37 +03:00
Gave asynchronous operations approximate POSIX signal semantics. This
will enable us to cascade async operations, which is necessary in order to properly support DNS. (For example, an HTTP request may have to redirect to a new location and will have to perform a new DNS lookup, so we can't just rely on doing the name lookup at the time of parsing the initial URL). Anything other than HTTP is probably broken right now; I'll fix the others up asap.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <vsprintf.h>
|
||||
#include <console.h>
|
||||
#include <gpxe/netdevice.h>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <vsprintf.h>
|
||||
#include <byteswap.h>
|
||||
#include <gpxe/ip.h>
|
||||
@@ -7,6 +8,8 @@
|
||||
#include <gpxe/iscsi.h>
|
||||
#include <gpxe/netdevice.h>
|
||||
|
||||
#if 0
|
||||
|
||||
static int test_dhcp_aoe_boot ( struct net_device *netdev,
|
||||
char *aoename ) {
|
||||
unsigned int drivenum;
|
||||
@@ -263,3 +266,5 @@ int test_dhcp ( struct net_device *netdev ) {
|
||||
out_no_del_ipv4:
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <byteswap.h>
|
||||
#include <console.h>
|
||||
#include <vsprintf.h>
|
||||
#include <gpxe/async.h>
|
||||
#include <gpxe/buffer.h>
|
||||
#include <gpxe/ftp.h>
|
||||
|
||||
static void print_ftp_response ( char *data, size_t len ) {
|
||||
unsigned int i;
|
||||
char c;
|
||||
|
||||
for ( i = 0 ; i < len ; i++ ) {
|
||||
c = data[i];
|
||||
if ( c == '\r' ) {
|
||||
/* Print nothing */
|
||||
} else if ( ( c == '\n' ) || ( c >= 32 ) || ( c <= 126 ) ) {
|
||||
putchar ( c );
|
||||
} else {
|
||||
putchar ( '.' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_ftp ( struct sockaddr_tcpip *server, const char *filename ) {
|
||||
char data[256];
|
||||
struct buffer buffer;
|
||||
struct ftp_request ftp;
|
||||
int rc;
|
||||
|
||||
printf ( "FTP fetching %s\n", filename );
|
||||
|
||||
memset ( &buffer, 0, sizeof ( buffer ) );
|
||||
buffer.addr = virt_to_user ( data );
|
||||
buffer.len = sizeof ( data );
|
||||
|
||||
memset ( &ftp, 0, sizeof ( ftp ) );
|
||||
memcpy ( &ftp.server, server, sizeof ( ftp.server ) );
|
||||
ftp.filename = filename;
|
||||
ftp.buffer = &buffer;
|
||||
|
||||
rc = async_wait ( ftp_get ( &ftp ) );
|
||||
if ( rc ) {
|
||||
printf ( "FTP fetch failed\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
printf ( "FTP received %d bytes\n", buffer.fill );
|
||||
|
||||
print_ftp_response ( data, buffer.fill );
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <byteswap.h>
|
||||
#include <console.h>
|
||||
#include <vsprintf.h>
|
||||
#include <gpxe/async.h>
|
||||
#include <gpxe/hello.h>
|
||||
|
||||
static void test_hello_callback ( char *data, size_t len ) {
|
||||
unsigned int i;
|
||||
char c;
|
||||
|
||||
for ( i = 0 ; i < len ; i++ ) {
|
||||
c = data[i];
|
||||
if ( c == '\r' ) {
|
||||
/* Print nothing */
|
||||
} else if ( ( c == '\n' ) || ( c >= 32 ) || ( c <= 126 ) ) {
|
||||
putchar ( c );
|
||||
} else {
|
||||
putchar ( '.' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_hello ( struct sockaddr_tcpip *server, const char *message ) {
|
||||
/* Quick and dirty hack */
|
||||
struct sockaddr_in *sin = ( struct sockaddr_in * ) server;
|
||||
struct hello_request hello;
|
||||
int rc;
|
||||
|
||||
printf ( "Saying \"%s\" to %s:%d\n", message,
|
||||
inet_ntoa ( sin->sin_addr ), ntohs ( sin->sin_port ) );
|
||||
|
||||
memset ( &hello, 0, sizeof ( hello ) );
|
||||
memcpy ( &hello.server, server, sizeof ( hello.server ) );
|
||||
hello.message = message;
|
||||
hello.callback = test_hello_callback;
|
||||
|
||||
rc = async_wait ( say_hello ( &hello ) );
|
||||
if ( rc ) {
|
||||
printf ( "HELLO fetch failed\n" );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user