mirror of
https://github.com/ipxe/ipxe
synced 2025-12-25 00:17:57 +03:00
[efi] Add efi_path_mac() to parse a MAC address from an EFI device path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -111,6 +111,30 @@ size_t efi_path_len ( EFI_DEVICE_PATH_PROTOCOL *path ) {
|
||||
return ( ( ( void * ) end ) - ( ( void * ) 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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user