ifmgmt.c revision a734c64bff58bda2fa48c2795453e092167b0ff7
/*
* Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
*
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <ipxe/netdevice.h>
/** @file
*
* Network interface management
*
*/
/**
* Open network device
*
* @v netdev Network device
* @ret rc Return status code
*/
int rc;
printf ( "Could not open %s: %s\n",
return rc;
}
return 0;
}
/**
* Close network device
*
* @v netdev Network device
*/
netdev_close ( netdev );
}
/**
* Print network device error breakdown
*
* @v stats Network device statistics
* @v prefix Message prefix
*/
const char *prefix ) {
unsigned int i;
}
}
/**
* Print status of network device
*
* @v netdev Network device
*/
printf ( "%s: %s using %s on %s (%s)\n"
" [Link:%s, TX:%d TXE:%d RX:%d RXE:%d]\n",
if ( ! netdev_link_ok ( netdev ) ) {
printf ( " [Link status: %s]\n",
}
}
/**
* Wait for link-up, with status indication
*
* @v netdev Network device
* @v max_wait_ms Maximum time to wait, in ms
*/
int key;
int rc;
/* Allow link state to be updated */
netdev_poll ( netdev );
if ( netdev_link_ok ( netdev ) )
return 0;
while ( 1 ) {
if ( netdev_link_ok ( netdev ) ) {
rc = 0;
break;
}
if ( max_wait_ms-- == 0 ) {
break;
}
step();
if ( iskey() ) {
break;
}
}
mdelay ( 1 );
}
if ( rc == 0 ) {
printf ( " ok\n" );
} else {
}
return rc;
}