summaryrefslogtreecommitdiffstats
path: root/src/net/netdevice.c
diff options
context:
space:
mode:
authorMichael Brown2013-10-21 15:02:19 +0200
committerMichael Brown2013-10-21 15:34:02 +0200
commit8f30ea4a6bf753c964a56a456ba558c7b52054e2 (patch)
treeeb6f1028fadc48954cf2d5c4204118aeef4da37b /src/net/netdevice.c
parent[udp] Add AF_INET6 socket opener (diff)
downloadipxe-8f30ea4a6bf753c964a56a456ba558c7b52054e2.tar.gz
ipxe-8f30ea4a6bf753c964a56a456ba558c7b52054e2.tar.xz
ipxe-8f30ea4a6bf753c964a56a456ba558c7b52054e2.zip
[netdevice] Add find_netdev_by_index()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/netdevice.c')
-rw-r--r--src/net/netdevice.c18
1 files changed, 18 insertions, 0 deletions
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
@@ -685,6 +685,24 @@ struct net_device * find_netdev ( const char *name ) {
}
/**
+ * 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
*
* @v bus_type Bus type