]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[netdevice] Add find_netdev_by_index()
authorMichael Brown <mcb30@ipxe.org>
Mon, 21 Oct 2013 13:02:19 +0000 (14:02 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 21 Oct 2013 13:34:02 +0000 (14:34 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/netdevice.h
src/net/netdevice.c

index 7f819d9ab84afd4e5b1d8ef531e79d1724b0de20..2d08f34ff530821ad932354957d3d2c9351a95fe 100644 (file)
@@ -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 );
index 283632f62f3465b219aa2bfadd1df0ff013050df..c7c86c1a27a607ba5ae72525ebfeb39e85039a4a 100644 (file)
@@ -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
  *