aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGene Cumm <gene.cumm@gmail.com>2015-07-19 14:09:05 -0400
committerGene Cumm <gene.cumm@gmail.com>2015-07-19 14:09:05 -0400
commite3fe9e942a7e6b4257e0262c140b35f41de5d17d (patch)
tree4832b1332cf50fad3c270adf03a3644ad72aab0e
parent8702009fc7a6689432d17d4ea05d9c878452c57a (diff)
downloadsyslinux-e3fe9e942a7e6b4257e0262c140b35f41de5d17d.tar.gz
syslinux-e3fe9e942a7e6b4257e0262c140b35f41de5d17d.tar.xz
syslinux-e3fe9e942a7e6b4257e0262c140b35f41de5d17d.zip
efi: add efi_get_MAC()
Extracts a MAC address from a device path Originally-By: Patrick Masotta <masottaus@yahoo.com> [gene.cumm@gmail.com: Respace] Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
-rw-r--r--efi/main.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/efi/main.c b/efi/main.c
index 9c3c2f28..45748e96 100644
--- a/efi/main.c
+++ b/efi/main.c
@@ -15,6 +15,7 @@
#include "efi.h"
#include "fio.h"
#include "version.h"
+#include "efi_pxe.h"
__export uint16_t PXERetry;
__export char copyright_str[] = "Copyright (C) 2011-" YEAR_STR "\n";
@@ -40,6 +41,41 @@ efi_close_protocol(EFI_HANDLE handle, EFI_GUID *guid, EFI_HANDLE agent,
guid, agent, controller);
}
+bool efi_get_MAC( EFI_DEVICE_PATH * pDevPath, uint8_t * mac, uint16_t mac_size)
+{
+ /*
+ * in case the DevPath contains more than one instance we consider all of them
+ * contain "the same" MAC Address Device Path structure
+ */
+ EFI_DEVICE_PATH *DevPathNode;
+ MAC_ADDR_DEVICE_PATH *MAC;
+
+ if (!pDevPath)
+ return FALSE;
+
+ pDevPath = UnpackDevicePath(pDevPath);
+
+ /* Process each device path node */
+ DevPathNode = pDevPath;
+ while (!IsDevicePathEnd(DevPathNode)) {
+ /* Find the handler to dump this device path node */
+ if (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH &&
+ DevicePathSubType(DevPathNode) == MSG_MAC_ADDR_DP) {
+ MAC = DevPathNode;
+ CopyMem(mac, MAC->MacAddress.Addr, PXE_MAC_LENGTH);
+ FreePool(pDevPath);
+ return TRUE;
+ }
+
+ /* Next device path node */
+ DevPathNode = NextDevicePathNode(DevPathNode);
+ }
+
+ FreePool(pDevPath);
+ return FALSE;
+}
+
+
/* As of UEFI-2.4.0, all EFI_SERVICE_BINDINGs are for networking */
struct efi_binding *efi_create_binding(EFI_GUID *bguid, EFI_GUID *pguid)
{