diff options
author | Michael Brown <mcb30@etherboot.org> | 2007-01-04 04:20:08 +0000 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2007-01-04 04:20:08 +0000 |
commit | 0c03bb5a9a0649ec7009e334c0e42290af330437 (patch) | |
tree | d523c7ba2ae84b0998b7e8121d70a603d6fd087a /src/usr/autoboot.c | |
parent | d4894f0127399cb3a91c6e8e0b450ce71573eec9 (diff) | |
download | ipxe-0c03bb5a9a0649ec7009e334c0e42290af330437.tar.gz |
Make open() and close() an official part of the netdevice API.
Call netdevice's poll() and transmit() methods only when device is open.
Diffstat (limited to 'src/usr/autoboot.c')
-rw-r--r-- | src/usr/autoboot.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c index ddfc37819..e67722981 100644 --- a/src/usr/autoboot.c +++ b/src/usr/autoboot.c @@ -16,7 +16,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <string.h> #include <vsprintf.h> +#include <gpxe/netdevice.h> #include <gpxe/autoboot.h> /** @file @@ -30,11 +32,21 @@ void test_dhcp ( struct net_device *netdev ); void autoboot ( void ) { struct net_device *netdev; + int rc; netdev = next_netdev (); - if ( netdev ) { - test_dhcp ( netdev ); - } else { + if ( ! netdev ) { printf ( "No network device found\n" ); + return; + } + + if ( ( rc = netdev_open ( netdev ) ) != 0 ) { + printf ( "Could not open %s: %s\n", netdev_name ( netdev ), + strerror ( rc ) ); + return; } + + test_dhcp ( netdev ); + + netdev_close ( netdev ); } |