From 8f30ea4a6bf753c964a56a456ba558c7b52054e2 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 21 Oct 2013 14:02:19 +0100 Subject: [PATCH] [netdevice] Add find_netdev_by_index() Signed-off-by: Michael Brown --- src/include/ipxe/netdevice.h | 1 + src/net/netdevice.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h index 7f819d9a..2d08f34f 100644 --- a/src/include/ipxe/netdevice.h +++ b/src/include/ipxe/netdevice.h @@ -605,6 +605,7 @@ extern void netdev_close ( struct net_device *netdev ); extern void unregister_netdev ( struct net_device *netdev ); extern void netdev_irq ( struct net_device *netdev, int enable ); extern struct net_device * find_netdev ( const char *name ); +extern struct net_device * find_netdev_by_index ( unsigned int index ); extern struct net_device * find_netdev_by_location ( unsigned int bus_type, unsigned int location ); extern struct net_device * last_opened_netdev ( void ); diff --git a/src/net/netdevice.c b/src/net/netdevice.c index 283632f6..c7c86c1a 100644 --- a/src/net/netdevice.c +++ b/src/net/netdevice.c @@ -684,6 +684,24 @@ struct net_device * find_netdev ( const char *name ) { return NULL; } +/** + * Get network device by index + * + * @v index Network device index + * @ret netdev Network device, or NULL + */ +struct net_device * find_netdev_by_index ( unsigned int index ) { + struct net_device *netdev; + + /* Identify network device by index */ + list_for_each_entry ( netdev, &net_devices, list ) { + if ( netdev->index == index ) + return netdev; + } + + return NULL; +} + /** * Get network device by PCI bus:dev.fn address *