Browse Source

[netdevice] Add find_netdev_by_index()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
8f30ea4a6b
2 changed files with 19 additions and 0 deletions
  1. 1
    0
      src/include/ipxe/netdevice.h
  2. 18
    0
      src/net/netdevice.c

+ 1
- 0
src/include/ipxe/netdevice.h View File

605
 extern void unregister_netdev ( struct net_device *netdev );
605
 extern void unregister_netdev ( struct net_device *netdev );
606
 extern void netdev_irq ( struct net_device *netdev, int enable );
606
 extern void netdev_irq ( struct net_device *netdev, int enable );
607
 extern struct net_device * find_netdev ( const char *name );
607
 extern struct net_device * find_netdev ( const char *name );
608
+extern struct net_device * find_netdev_by_index ( unsigned int index );
608
 extern struct net_device * find_netdev_by_location ( unsigned int bus_type,
609
 extern struct net_device * find_netdev_by_location ( unsigned int bus_type,
609
 						     unsigned int location );
610
 						     unsigned int location );
610
 extern struct net_device * last_opened_netdev ( void );
611
 extern struct net_device * last_opened_netdev ( void );

+ 18
- 0
src/net/netdevice.c View File

684
 	return NULL;
684
 	return NULL;
685
 }
685
 }
686
 
686
 
687
+/**
688
+ * Get network device by index
689
+ *
690
+ * @v index		Network device index
691
+ * @ret netdev		Network device, or NULL
692
+ */
693
+struct net_device * find_netdev_by_index ( unsigned int index ) {
694
+	struct net_device *netdev;
695
+
696
+	/* Identify network device by index */
697
+	list_for_each_entry ( netdev, &net_devices, list ) {
698
+		if ( netdev->index == index )
699
+			return netdev;
700
+	}
701
+
702
+	return NULL;
703
+}
704
+
687
 /**
705
 /**
688
  * Get network device by PCI bus:dev.fn address
706
  * Get network device by PCI bus:dev.fn address
689
  *
707
  *

Loading…
Cancel
Save