mirror of https://github.com/ipxe/ipxe.git
[cmdline] Add "--timeout" parameter to "ifconf" command
Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/129/head
parent
145311c62e
commit
a08ee6e722
|
@ -193,6 +193,8 @@ static int ifstat_exec ( int argc, char **argv ) {
|
||||||
|
|
||||||
/** "ifconf" options */
|
/** "ifconf" options */
|
||||||
struct ifconf_options {
|
struct ifconf_options {
|
||||||
|
/** Configuration timeout */
|
||||||
|
unsigned long timeout;
|
||||||
/** Configurator */
|
/** Configurator */
|
||||||
struct net_device_configurator *configurator;
|
struct net_device_configurator *configurator;
|
||||||
};
|
};
|
||||||
|
@ -202,6 +204,9 @@ static struct option_descriptor ifconf_opts[] = {
|
||||||
OPTION_DESC ( "configurator", 'c', required_argument,
|
OPTION_DESC ( "configurator", 'c', required_argument,
|
||||||
struct ifconf_options, configurator,
|
struct ifconf_options, configurator,
|
||||||
parse_netdev_configurator ),
|
parse_netdev_configurator ),
|
||||||
|
OPTION_DESC ( "timeout", 't', required_argument,
|
||||||
|
struct ifconf_options, timeout,
|
||||||
|
parse_timeout ),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,7 +221,8 @@ static int ifconf_payload ( struct net_device *netdev,
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Attempt configuration */
|
/* Attempt configuration */
|
||||||
if ( ( rc = ifconf ( netdev, opts->configurator ) ) != 0 ) {
|
if ( ( rc = ifconf ( netdev, opts->configurator,
|
||||||
|
opts->timeout ) ) != 0 ) {
|
||||||
|
|
||||||
/* Close device on failure, to avoid memory exhaustion */
|
/* Close device on failure, to avoid memory exhaustion */
|
||||||
netdev_close ( netdev );
|
netdev_close ( netdev );
|
||||||
|
|
|
@ -14,7 +14,8 @@ struct net_device_configurator;
|
||||||
|
|
||||||
extern int ifopen ( struct net_device *netdev );
|
extern int ifopen ( struct net_device *netdev );
|
||||||
extern int ifconf ( struct net_device *netdev,
|
extern int ifconf ( struct net_device *netdev,
|
||||||
struct net_device_configurator *configurator );
|
struct net_device_configurator *configurator,
|
||||||
|
unsigned long timeout );
|
||||||
extern void ifclose ( struct net_device *netdev );
|
extern void ifclose ( struct net_device *netdev );
|
||||||
extern void ifstat ( struct net_device *netdev );
|
extern void ifstat ( struct net_device *netdev );
|
||||||
extern int iflinkwait ( struct net_device *netdev, unsigned long timeout );
|
extern int iflinkwait ( struct net_device *netdev, unsigned long timeout );
|
||||||
|
|
|
@ -396,7 +396,7 @@ int netboot ( struct net_device *netdev ) {
|
||||||
ifstat ( netdev );
|
ifstat ( netdev );
|
||||||
|
|
||||||
/* Configure device */
|
/* Configure device */
|
||||||
if ( ( rc = ifconf ( netdev, NULL ) ) != 0 )
|
if ( ( rc = ifconf ( netdev, NULL, 0 ) ) != 0 )
|
||||||
goto err_dhcp;
|
goto err_dhcp;
|
||||||
route();
|
route();
|
||||||
|
|
||||||
|
|
|
@ -264,10 +264,12 @@ static int ifconf_progress ( struct ifpoller *ifpoller ) {
|
||||||
*
|
*
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
* @v configurator Network device configurator, or NULL to use all
|
* @v configurator Network device configurator, or NULL to use all
|
||||||
|
* @v timeout Timeout period, in ticks
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int ifconf ( struct net_device *netdev,
|
int ifconf ( struct net_device *netdev,
|
||||||
struct net_device_configurator *configurator ) {
|
struct net_device_configurator *configurator,
|
||||||
|
unsigned long timeout ) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Ensure device is open and link is up */
|
/* Ensure device is open and link is up */
|
||||||
|
@ -296,5 +298,5 @@ int ifconf ( struct net_device *netdev,
|
||||||
( configurator ? configurator->name : "" ),
|
( configurator ? configurator->name : "" ),
|
||||||
( configurator ? "] " : "" ),
|
( configurator ? "] " : "" ),
|
||||||
netdev->name, netdev->ll_protocol->ntoa ( netdev->ll_addr ) );
|
netdev->name, netdev->ll_protocol->ntoa ( netdev->ll_addr ) );
|
||||||
return ifpoller_wait ( netdev, configurator, 0, ifconf_progress );
|
return ifpoller_wait ( netdev, configurator, timeout, ifconf_progress );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue