iPXE
efi_cachedhcp.c File Reference

EFI cached DHCP packet. More...

#include <string.h>
#include <errno.h>
#include <ipxe/cachedhcp.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_path.h>
#include <ipxe/efi/efi_cachedhcp.h>
#include <ipxe/efi/Protocol/PxeBaseCode.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
int efi_cachedhcp_record (EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path)
 Record cached DHCP packet.

Detailed Description

EFI cached DHCP packet.

Definition in file efi_cachedhcp.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ efi_cachedhcp_record()

int efi_cachedhcp_record ( EFI_HANDLE device,
EFI_DEVICE_PATH_PROTOCOL * path )

Record cached DHCP packet.

Parameters
deviceDevice handle
pathDevice path
Return values
rcReturn status code

Definition at line 48 of file efi_cachedhcp.c.

49 {
50 unsigned int vlan;
53 int rc;
54
55 /* Get VLAN tag, if any */
56 vlan = efi_path_vlan ( path );
57
58 /* Look for a PXE base code instance on the image's device handle */
60 &pxe ) ) != 0 ) {
61 DBGC ( device, "EFI %s has no PXE base code instance: %s\n",
63 return rc;
64 }
65
66 /* Do not attempt to cache IPv6 packets */
67 mode = pxe->Mode;
68 if ( mode->UsingIpv6 ) {
69 DBGC ( device, "EFI %s has IPv6 PXE base code\n",
71 return -ENOTSUP;
72 }
73
74 /* Record DHCPACK, if present */
75 if ( mode->DhcpAckReceived &&
76 ( ( rc = cachedhcp_record ( &cached_dhcpack, vlan, &mode->DhcpAck,
77 sizeof ( mode->DhcpAck ) ) ) != 0 ) ) {
78 DBGC ( device, "EFI %s could not record DHCPACK: %s\n",
80 return rc;
81 }
82
83 /* Record ProxyDHCPOFFER, if present */
84 if ( mode->ProxyOfferReceived &&
86 &mode->ProxyOffer,
87 sizeof ( mode->ProxyOffer ) ) ) != 0)){
88 DBGC ( device, "EFI %s could not record ProxyDHCPOFFER: %s\n",
90 return rc;
91 }
92
93 /* Record PxeBSACK, if present */
94 if ( mode->PxeReplyReceived &&
95 ( ( rc = cachedhcp_record ( &cached_pxebs, vlan, &mode->PxeReply,
96 sizeof ( mode->PxeReply ) ) ) != 0 )){
97 DBGC ( device, "EFI %s could not record PXEBSACK: %s\n",
99 return rc;
100 }
101
102 return 0;
103}
struct _EFI_PXE_BASE_CODE_PROTOCOL EFI_PXE_BASE_CODE_PROTOCOL
Definition PxeBaseCode.h:30
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
struct cached_dhcp_packet cached_proxydhcp
Cached ProxyDHCPOFFER.
Definition cachedhcp.c:69
struct cached_dhcp_packet cached_pxebs
Cached PXEBSACK.
Definition cachedhcp.c:74
struct cached_dhcp_packet cached_dhcpack
Cached DHCPACK.
Definition cachedhcp.c:63
int cachedhcp_record(struct cached_dhcp_packet *cache, unsigned int vlan, const void *data, size_t max_len)
Record cached DHCP packet.
Definition cachedhcp.c:203
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition efi_debug.c:652
EFI_GUID efi_pxe_base_code_protocol_guid
PXE base code protocol GUID.
Definition efi_guid.c:321
unsigned int efi_path_vlan(EFI_DEVICE_PATH_PROTOCOL *path)
Get VLAN tag from device path.
Definition efi_path.c:237
uint16_t mode
Acceleration mode.
Definition ena.h:15
#define DBGC(...)
Definition compiler.h:505
#define ENOTSUP
Operation not supported.
Definition errno.h:590
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition efi.h:444
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
EFI_PXE_BASE_CODE_MODE.
EFI_PXE_BASE_CODE_MODE * Mode
The pointer to the EFI_PXE_BASE_CODE_MODE data for this device.
A hardware device.
Definition device.h:77

References cached_dhcpack, cached_proxydhcp, cached_pxebs, cachedhcp_record(), DBGC, EFI_HANDLE, efi_handle_name(), efi_open, efi_path_vlan(), efi_pxe_base_code_protocol_guid, ENOTSUP, _EFI_PXE_BASE_CODE_PROTOCOL::Mode, mode, rc, and strerror().

Referenced by efi_init_application().