summaryrefslogtreecommitdiffstats
path: root/src/interface/efi/efi_path.c
diff options
context:
space:
mode:
authorMichael Brown2024-03-26 16:16:33 +0100
committerMichael Brown2024-03-26 16:16:33 +0100
commit170bbfd4875b2a3479101b5f5892cdedcf857fd0 (patch)
tree36f5aed7cdabbd80b26925ae729bf33ccf4d2926 /src/interface/efi/efi_path.c
parent[efi] Add support for driving EFI_MANAGED_NETWORK_PROTOCOL devices (diff)
downloadipxe-170bbfd4875b2a3479101b5f5892cdedcf857fd0.tar.gz
ipxe-170bbfd4875b2a3479101b5f5892cdedcf857fd0.tar.xz
ipxe-170bbfd4875b2a3479101b5f5892cdedcf857fd0.zip
[efi] Add efi_path_mac() to parse a MAC address from an EFI device path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi/efi_path.c')
-rw-r--r--src/interface/efi/efi_path.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/interface/efi/efi_path.c b/src/interface/efi/efi_path.c
index 4e37d248..23f1bb84 100644
--- a/src/interface/efi/efi_path.c
+++ b/src/interface/efi/efi_path.c
@@ -112,6 +112,30 @@ size_t efi_path_len ( EFI_DEVICE_PATH_PROTOCOL *path ) {
}
/**
+ * Get MAC address from device path
+ *
+ * @v path Device path
+ * @ret mac MAC address, or NULL if not found
+ */
+void * efi_path_mac ( EFI_DEVICE_PATH_PROTOCOL *path ) {
+ EFI_DEVICE_PATH_PROTOCOL *next;
+ MAC_ADDR_DEVICE_PATH *mac;
+
+ /* Search for MAC address path */
+ for ( ; ( next = efi_path_next ( path ) ) ; path = next ) {
+ if ( ( path->Type == MESSAGING_DEVICE_PATH ) &&
+ ( path->SubType == MSG_MAC_ADDR_DP ) ) {
+ mac = container_of ( path, MAC_ADDR_DEVICE_PATH,
+ Header );
+ return &mac->MacAddress;
+ }
+ }
+
+ /* No MAC address found */
+ return NULL;
+}
+
+/**
* Get VLAN tag from device path
*
* @v path Device path