Pārlūkot izejas kodu

[netdevice] Add find_netdev_by_index()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 gadus atpakaļ
vecāks
revīzija
8f30ea4a6b
2 mainītis faili ar 19 papildinājumiem un 0 dzēšanām
  1. 1
    0
      src/include/ipxe/netdevice.h
  2. 18
    0
      src/net/netdevice.c

+ 1
- 0
src/include/ipxe/netdevice.h Parādīt failu

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

+ 18
- 0
src/net/netdevice.c Parādīt failu

@@ -684,6 +684,24 @@ struct net_device * find_netdev ( const char *name ) {
684 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 706
  * Get network device by PCI bus:dev.fn address
689 707
  *

Notiek ielāde…
Atcelt
Saglabāt