summaryrefslogtreecommitdiffstats
path: root/src/usr/dhcpmgmt.c
diff options
context:
space:
mode:
authorMichael Brown2007-01-15 09:49:10 +0100
committerMichael Brown2007-01-15 09:49:10 +0100
commit4e20d73bb52326261f8cf49c20d6de2edea309ee (patch)
tree3d24466a78c4c8f53294384b76e62e871eb96def /src/usr/dhcpmgmt.c
parentAdd missing include (diff)
downloadipxe-4e20d73bb52326261f8cf49c20d6de2edea309ee.tar.gz
ipxe-4e20d73bb52326261f8cf49c20d6de2edea309ee.tar.xz
ipxe-4e20d73bb52326261f8cf49c20d6de2edea309ee.zip
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.
Diffstat (limited to 'src/usr/dhcpmgmt.c')
-rw-r--r--src/usr/dhcpmgmt.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/usr/dhcpmgmt.c b/src/usr/dhcpmgmt.c
index 6042f8b2..0e36d555 100644
--- a/src/usr/dhcpmgmt.c
+++ b/src/usr/dhcpmgmt.c
@@ -23,6 +23,7 @@
#include <gpxe/dhcp.h>
#include <gpxe/async.h>
#include <gpxe/netdevice.h>
+#include <usr/ifmgmt.h>
#include <usr/dhcpmgmt.h>
/** @file
@@ -43,6 +44,7 @@ int dhcp ( struct net_device *netdev ) {
struct in_addr address = { htonl ( 0 ) };
struct in_addr netmask = { htonl ( 0 ) };
struct in_addr gateway = { INADDR_NONE };
+ struct async async;
int rc;
/* Check we can open the interface first */
@@ -60,8 +62,14 @@ int dhcp ( struct net_device *netdev ) {
printf ( "DHCP (%s %s)...", netdev->name, netdev_hwaddr ( netdev ) );
memset ( &dhcp, 0, sizeof ( dhcp ) );
dhcp.netdev = netdev;
- if ( ( rc = async_wait ( start_dhcp ( &dhcp ) ) ) != 0 ) {
- printf ( "failed\n" );
+ async_init_orphan ( &async );
+ if ( ( rc = start_dhcp ( &dhcp, &async ) ) != 0 ) {
+ printf ( "could not start (%s)\n", strerror ( rc ) );
+ return rc;
+ }
+ async_wait ( &async, &rc, 1 );
+ if ( rc != 0 ) {
+ printf ( "failed (%s)\n", strerror ( rc ) );
return rc;
}
printf ( "done\n" );