OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
NetworkBootInternal.h File Reference
#include <Uefi.h>
#include <Uefi/UefiSpec.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/NetLib.h>
#include <Library/PrintLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcDebugLogLib.h>
#include <Library/OcFlexArrayLib.h>
#include <Library/OcStringLib.h>
#include <Library/OcVirtualFsLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Protocol/HttpBootCallback.h>
#include <Protocol/Ip4Config2.h>
#include <Protocol/LoadFile.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/OcBootEntry.h>
#include <Protocol/RamDisk.h>
#include <Guid/ImageAuthentication.h>
#include <Guid/TlsAuthentication.h>

Go to the source code of this file.

Data Structures

struct  IP4_CONFIG2_DATA_RECORD
 
struct  IP4_CONFIG2_VARIABLE
 
struct  IP4_CONFIG2_OC_CONFIG_DATA
 

Macros

#define IP4_CONFIG2_VARIABLE_ATTRIBUTE   (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
 
#define IP4_ALLZERO_ADDRESS   0x00000000u
 

Typedefs

typedef EFI_STATUS(* VALIDATE_BOOT_DEVICE_PATH) (IN VOID *Context, IN EFI_DEVICE_PATH_PROTOCOL *Path)
 

Functions

EFI_STATUS Ip4Config2ConvertOcConfigDataToNvData (IN CHAR16 *VarName, IN IP4_CONFIG2_OC_CONFIG_DATA *ConfigData)
 
EFI_STATUS Ip4Config2DeleteStaticIpNvData (IN CHAR16 *VarName)
 
EFI_DEVICE_PATH_PROTOCOL * GetUriNode (EFI_DEVICE_PATH_PROTOCOL *DevicePath)
 
CHAR16 * BmGetNetworkDescription (IN EFI_HANDLE Handle)
 
EFI_DEVICE_PATH_PROTOCOL * BmExpandLoadFiles (IN EFI_DEVICE_PATH_PROTOCOL *FilePath, OUT VOID **Data, OUT UINT32 *DataSize, IN BOOLEAN ValidateHttp)
 
EFI_DEVICE_PATH_PROTOCOL * BmGetRamDiskDevicePath (IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
 
VOID BmDestroyRamDisk (IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath)
 
EFI_STATUS EFIAPI HttpBootCustomFree (IN VOID *Context)
 
EFI_STATUS EFIAPI HttpBootCustomRead (IN OC_STORAGE_CONTEXT *Storage, IN OC_BOOT_ENTRY *ChosenEntry, OUT VOID **Data, OUT UINT32 *DataSize, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, OUT EFI_HANDLE *StorageHandle, OUT EFI_DEVICE_PATH_PROTOCOL **StoragePath, IN OC_DMG_LOADING_SUPPORT DmgLoading, OUT OC_APPLE_DISK_IMAGE_PRELOAD_CONTEXT *DmgPreloadContext, OUT VOID **Context)
 
EFI_STATUS EFIAPI PxeBootCustomRead (IN OC_STORAGE_CONTEXT *Storage, IN OC_BOOT_ENTRY *ChosenEntry, OUT VOID **Data, OUT UINT32 *DataSize, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, OUT EFI_HANDLE *StorageHandle, OUT EFI_DEVICE_PATH_PROTOCOL **StoragePath, IN OC_DMG_LOADING_SUPPORT DmgLoading, OUT OC_APPLE_DISK_IMAGE_PRELOAD_CONTEXT *DmgPreloadContext, OUT VOID **Context)
 
BOOLEAN HasHttpsUri (CHAR16 *Uri)
 
EFI_STATUS ExtractOtherUriFromDevicePath (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CHAR8 *FromExt, IN CHAR8 *ToExt, OUT CHAR8 **OtherUri, IN BOOLEAN OnlySearchForFromExt)
 
BOOLEAN UriFileHasExtension (IN CHAR8 *Uri, IN CHAR8 *Ext)
 
EFI_STATUS HttpBootAddUri (EFI_DEVICE_PATH_PROTOCOL *DevicePath, VOID *Uri, OC_STRING_FORMAT StringFormat, EFI_DEVICE_PATH_PROTOCOL **UriDevicePath)
 
EFI_EVENT MonitorHttpBootCallback (EFI_HANDLE LoadFileHandle)
 
BOOLEAN UriWasValidated (VOID)
 
EFI_STATUS LogInstalledCerts (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid)
 
EFI_STATUS CertIsPresent (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN EFI_GUID *OwnerGuid, IN UINTN X509DataSize, IN VOID *X509Data)
 
EFI_STATUS DeleteCertsForOwner (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN EFI_GUID *OwnerGuid, IN UINTN X509DataSize, IN VOID *X509Data, OUT UINTN *DeletedCount)
 
EFI_STATUS EnrollX509toVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN EFI_GUID *OwnerGuid, IN UINTN X509DataSize, IN VOID *X509Data)
 
EFI_STATUS AddRemoveStaticIPs (OC_FLEX_ARRAY *ParsedLoadOptions)
 
BOOLEAN Ip4StationAddressValid (IN IP4_ADDR Ip, IN IP4_ADDR Netmask)
 
UINT8 GetSubnetMaskPrefixLength (IN EFI_IPv4_ADDRESS *SubnetMask)
 
EFI_STATUS Ip4Config2StrToIp (IN CHAR16 *Str, OUT EFI_IPv4_ADDRESS *Ip)
 
EFI_STATUS Ip4Config2StrToIpList (IN CHAR16 *Str, OUT EFI_IPv4_ADDRESS **PtrIpList, OUT UINTN *IpCount)
 

Variables

BOOLEAN gRequireHttpsUri
 
OC_DMG_LOADING_SUPPORT gDmgLoading
 

Detailed Description

Copyright (C) 2024, Mike Beaton. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause

Definition in file NetworkBootInternal.h.

Macro Definition Documentation

◆ IP4_ALLZERO_ADDRESS

#define IP4_ALLZERO_ADDRESS   0x00000000u

Definition at line 58 of file NetworkBootInternal.h.

◆ IP4_CONFIG2_VARIABLE_ATTRIBUTE

#define IP4_CONFIG2_VARIABLE_ATTRIBUTE   (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)

Definition at line 50 of file NetworkBootInternal.h.

Typedef Documentation

◆ VALIDATE_BOOT_DEVICE_PATH

typedef EFI_STATUS(* VALIDATE_BOOT_DEVICE_PATH) (IN VOID *Context, IN EFI_DEVICE_PATH_PROTOCOL *Path)

Custom validation for network boot device path.

Parameters
PathDevice path to validate.
Return values
EFI_SUCCESSDevice path should be accepted.
otherDevice path should be rejected.

Definition at line 100 of file NetworkBootInternal.h.

Function Documentation

◆ AddRemoveStaticIPs()

EFI_STATUS AddRemoveStaticIPs ( OC_FLEX_ARRAY * ParsedLoadOptions)

StaticIp4.c

Definition at line 142 of file StaticIp4.c.

◆ BmDestroyRamDisk()

VOID BmDestroyRamDisk ( IN EFI_DEVICE_PATH_PROTOCOL * RamDiskDevicePath)

Destroy the RAM Disk.

The destroy operation includes to call RamDisk.Unregister to unregister the RAM DISK from RAM DISK driver, free the memory allocated for the RAM Disk.

Parameters
RamDiskDevicePathRAM Disk device path.

Definition at line 345 of file BmBoot.c.

◆ BmExpandLoadFiles()

EFI_DEVICE_PATH_PROTOCOL * BmExpandLoadFiles ( IN EFI_DEVICE_PATH_PROTOCOL * FilePath,
OUT VOID ** Data,
OUT UINT32 * DataSize,
IN BOOLEAN ValidateHttp )

BmBoot.c

Return the full device path pointing to the load option.

FilePath may:

  1. Exactly matches to a LoadFile instance.
  2. Cannot match to any LoadFile instance. Wide match is required. In either case, the routine may return:
  1. A copy of FilePath when FilePath matches to a LoadFile instance and the LoadFile returns a load option buffer.
  2. A new device path with IP and URI information updated when wide match happens.
  3. A new device path pointing to a load option in RAM disk. In either case, only one full device path is returned for a specified FilePath.
Parameters
FilePathThe media device path pointing to a LoadFile instance.
Returns
The load option buffer.

< Sort out cramped spacing

Definition at line 530 of file BmBoot.c.

◆ BmGetNetworkDescription()

CHAR16 * BmGetNetworkDescription ( IN EFI_HANDLE Handle)

BmBootDescription.c

Return the description for network boot device.

Parameters
HandleController handle.
Returns
The description string.

Definition at line 21 of file BmBootDescription.c.

◆ BmGetRamDiskDevicePath()

EFI_DEVICE_PATH_PROTOCOL * BmGetRamDiskDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL * FilePath)

Return the RAM Disk device path created by LoadFile.

Parameters
FilePathThe source file path.
Returns
Callee-to-free RAM Disk device path

Definition at line 267 of file BmBoot.c.

◆ CertIsPresent()

EFI_STATUS CertIsPresent ( IN CHAR16 * VariableName,
IN EFI_GUID * VendorGuid,
IN EFI_GUID * OwnerGuid,
IN UINTN X509DataSize,
IN VOID * X509Data )

Report whether specified signature is already enrolled for given owner.

Parameters
[in]VariableNameVariable name of CA database.
[in]VendorGuidUnique identifier for the CA database vendor.
[in]OwnerGuidUnique identifier for owner of the certificate to be searched for.
[in]X509DataSizeCertificate data size.
[in]X509DataCertificate data.
Return values
EFI_SUCCESSCertificate is already enrolled.
EFI_OUT_OF_RESOURCESCould not allocate needed resources.

Definition at line 219 of file TlsAuthConfigImpl.c.

◆ DeleteCertsForOwner()

EFI_STATUS DeleteCertsForOwner ( IN CHAR16 * VariableName,
IN EFI_GUID * VendorGuid,
IN EFI_GUID * OwnerGuid,
IN UINTN X509DataSize,
IN VOID * X509Data,
OUT UINTN * DeletedCount )

Delete specific entry or all entries with owner guid from signature database. (Based on original EDK 2 DeleteCert which removes one cert, identified by index.)

Parameters
[in]VariableNameThe variable name of the signature database.
[in]VendorGuidA unique identifier for the signature database vendor.
[in]OwnerGuidA unique identifier for owner of the certificate(s) to be deleted.
[in]X509DataSizeOptional certificate data size.
[in]X509DataOptional certificate data. If non-NULL, delete only specific certificate for owner, if present. If NULL, delete all certificates for owner.
[in]DeletedCountOptional return count of deleted certificates.
Return values
EFI_SUCCESSDelete signature successfully.
EFI_OUT_OF_RESOURCESCould not allocate needed resources.

Definition at line 259 of file TlsAuthConfigImpl.c.

◆ EnrollX509toVariable()

EFI_STATUS EnrollX509toVariable ( IN CHAR16 * VariableName,
IN EFI_GUID * VendorGuid,
IN EFI_GUID * OwnerGuid,
IN UINTN X509DataSize,
IN VOID * X509Data )

Enroll a new X509 certificate into Variable.

Parameters
[in]VariableNameVariable name of CA database.
[in]VendorGuidUnique identifier for the CA database vendor.
[in]OwnerGuidUnique identifier for owner of the certificate to be installed.
[in]X509DataSizeCertificate data size.
[in]X509DataCertificate data.
Return values
EFI_SUCCESSNew X509 is enrolled successfully.
EFI_OUT_OF_RESOURCESCould not allocate needed resources.

Definition at line 433 of file TlsAuthConfigImpl.c.

◆ ExtractOtherUriFromDevicePath()

EFI_STATUS ExtractOtherUriFromDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
IN CHAR8 * FromExt,
IN CHAR8 * ToExt,
OUT CHAR8 ** OtherUri,
IN BOOLEAN OnlySearchForFromExt )

Definition at line 186 of file Uri.c.

◆ GetSubnetMaskPrefixLength()

UINT8 GetSubnetMaskPrefixLength ( IN EFI_IPv4_ADDRESS * SubnetMask)

Calculate the prefix length of the IPv4 subnet mask.

Parameters
[in]SubnetMaskThe IPv4 subnet mask.
Returns
The prefix length of the subnet mask.
Return values
0Other errors as indicated.

Definition at line 66 of file Ip4Utils.c.

◆ GetUriNode()

EFI_DEVICE_PATH_PROTOCOL * GetUriNode ( EFI_DEVICE_PATH_PROTOCOL * DevicePath)

Definition at line 30 of file Uri.c.

◆ HasHttpsUri()

BOOLEAN HasHttpsUri ( CHAR16 * Uri)

Uri.c

Definition at line 20 of file Uri.c.

◆ HttpBootAddUri()

EFI_STATUS HttpBootAddUri ( EFI_DEVICE_PATH_PROTOCOL * DevicePath,
VOID * Uri,
OC_STRING_FORMAT StringFormat,
EFI_DEVICE_PATH_PROTOCOL ** UriDevicePath )

Definition at line 231 of file Uri.c.

◆ HttpBootCustomFree()

EFI_STATUS EFIAPI HttpBootCustomFree ( IN VOID * Context)

CustomRead.c

Definition at line 84 of file HttpBootCustomRead.c.

◆ HttpBootCustomRead()

EFI_STATUS EFIAPI HttpBootCustomRead ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_BOOT_ENTRY * ChosenEntry,
OUT VOID ** Data,
OUT UINT32 * DataSize,
OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,
OUT EFI_HANDLE * StorageHandle,
OUT EFI_DEVICE_PATH_PROTOCOL ** StoragePath,
IN OC_DMG_LOADING_SUPPORT DmgLoading,
OUT OC_APPLE_DISK_IMAGE_PRELOAD_CONTEXT * DmgPreloadContext,
OUT VOID ** Context )

Definition at line 134 of file HttpBootCustomRead.c.

◆ Ip4Config2ConvertOcConfigDataToNvData()

EFI_STATUS Ip4Config2ConvertOcConfigDataToNvData ( IN CHAR16 * VarName,
IN IP4_CONFIG2_OC_CONFIG_DATA * ConfigData )

Definition at line 127 of file Ip4Config2Nv.c.

◆ Ip4Config2DeleteStaticIpNvData()

EFI_STATUS Ip4Config2DeleteStaticIpNvData ( IN CHAR16 * VarName)

Definition at line 225 of file Ip4Config2Nv.c.

◆ Ip4Config2StrToIp()

EFI_STATUS Ip4Config2StrToIp ( IN CHAR16 * Str,
OUT EFI_IPv4_ADDRESS * Ip )

Convert the decimal dotted IPv4 address into the binary IPv4 address.

Parameters
[in]StrThe UNICODE string.
[out]IpThe storage to return the IPv4 address.
Return values
EFI_SUCCESSThe binary IP address is returned in Ip.
EFI_INVALID_PARAMETERThe IP string is malformatted.

Definition at line 108 of file Ip4Utils.c.

◆ Ip4Config2StrToIpList()

EFI_STATUS Ip4Config2StrToIpList ( IN CHAR16 * Str,
OUT EFI_IPv4_ADDRESS ** PtrIpList,
OUT UINTN * IpCount )

Convert the decimal dotted IPv4 addresses separated by space into the binary IPv4 address list.

Parameters
[in]StrThe UNICODE string contains IPv4 addresses.
[out]PtrIpListThe storage to return the IPv4 address list.
[out]IpCountThe size of the IPv4 address list.
Return values
EFI_SUCCESSThe binary IP address list is returned in PtrIpList.
EFI_OUT_OF_RESOURCESError occurs in allocating memory.
EFI_INVALID_PARAMETERThe IP string is malformatted.

Definition at line 173 of file Ip4Utils.c.

◆ Ip4StationAddressValid()

BOOLEAN Ip4StationAddressValid ( IN IP4_ADDR Ip,
IN IP4_ADDR Netmask )

Ip4Utils.c

Validate that Ip/Netmask pair is OK to be used as station address. Only continuous netmasks are supported. and check that StationAddress is a unicast address on the network.

Parameters
[in]IpThe IP address to validate.
[in]NetmaskThe netmask of the IP.
Return values
TRUEThe Ip/Netmask pair is valid.
FALSEThe Ip/Netmask pair is invalid.

Definition at line 27 of file Ip4Utils.c.

◆ LogInstalledCerts()

EFI_STATUS LogInstalledCerts ( IN CHAR16 * VariableName,
IN EFI_GUID * VendorGuid )

TlsAuthConfigImpl.c

Log owner GUID of each installed certificate in signature database.

Parameters
[in]VariableNameThe variable name of the signature database.
[in]VendorGuidA unique identifier for the signature database vendor.
Return values
EFI_SUCCESSSuccess.

Definition at line 161 of file TlsAuthConfigImpl.c.

◆ MonitorHttpBootCallback()

EFI_EVENT MonitorHttpBootCallback ( EFI_HANDLE LoadFileHandle)

Definition at line 245 of file HttpBootCallback.c.

◆ PxeBootCustomRead()

EFI_STATUS EFIAPI PxeBootCustomRead ( IN OC_STORAGE_CONTEXT * Storage,
IN OC_BOOT_ENTRY * ChosenEntry,
OUT VOID ** Data,
OUT UINT32 * DataSize,
OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,
OUT EFI_HANDLE * StorageHandle,
OUT EFI_DEVICE_PATH_PROTOCOL ** StoragePath,
IN OC_DMG_LOADING_SUPPORT DmgLoading,
OUT OC_APPLE_DISK_IMAGE_PRELOAD_CONTEXT * DmgPreloadContext,
OUT VOID ** Context )

Definition at line 280 of file HttpBootCustomRead.c.

◆ UriFileHasExtension()

BOOLEAN UriFileHasExtension ( IN CHAR8 * Uri,
IN CHAR8 * Ext )

Definition at line 222 of file Uri.c.

◆ UriWasValidated()

BOOLEAN UriWasValidated ( VOID )

Definition at line 237 of file HttpBootCallback.c.

Variable Documentation

◆ gDmgLoading

OC_DMG_LOADING_SUPPORT gDmgLoading
extern

Current DmgLoading setting, for HTTP BOOT callback validation.

Definition at line 16 of file HttpBootCallback.c.

◆ gRequireHttpsUri

BOOLEAN gRequireHttpsUri
extern

Set if we should enforce https only within this driver.

Definition at line 14 of file OpenNetworkBoot.c.