iPXE
bios_cachedhcp.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Michael Brown <mbrown@fensystems.co.uk>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
22 */
23
24FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25
26#include <stdint.h>
27#include <string.h>
28#include <ipxe/init.h>
29#include <ipxe/cachedhcp.h>
30#include <realmode.h>
31#include <pxe_api.h>
32
33/** @file
34 *
35 * Cached DHCP packet
36 *
37 */
38
39/** Cached DHCPACK physical address
40 *
41 * This can be set by the prefix.
42 */
44#define cached_dhcpack_phys __use_data16 ( cached_dhcpack_phys )
45
46/** Colour for debug messages */
47#define colour &cached_dhcpack_phys
48
49/**
50 * Cached DHCPACK initialisation function
51 *
52 */
53static void cachedhcp_init ( void ) {
54 int rc;
55
56 /* Do nothing if no cached DHCPACK is present */
57 if ( ! cached_dhcpack_phys ) {
58 DBGC ( colour, "CACHEDHCP found no cached DHCPACK\n" );
59 return;
60 }
61
62 /* Record cached DHCPACK */
63 if ( ( rc = cachedhcp_record ( &cached_dhcpack, 0,
64 phys_to_virt ( cached_dhcpack_phys ),
65 sizeof ( BOOTPLAYER_t ) ) ) != 0 ) {
66 DBGC ( colour, "CACHEDHCP could not record DHCPACK: %s\n",
67 strerror ( rc ) );
68 return;
69 }
70
71 /* Mark as consumed */
73}
74
75/** Cached DHCPACK initialisation function */
76struct init_fn cachedhcp_init_fn __init_fn ( INIT_NORMAL ) = {
77 .name = "cachedhcp",
78 .initialise = cachedhcp_init,
79};
#define colour
Colour for debug messages.
Definition acpi.c:42
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
unsigned int uint32_t
Definition stdint.h:12
#define cached_dhcpack_phys
static void cachedhcp_init(void)
Cached DHCPACK initialisation function.
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
Cached DHCP packet.
#define DBGC(...)
Definition compiler.h:505
#define INIT_NORMAL
Normal initialisation.
Definition init.h:32
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
struct bootph BOOTPLAYER_t
Definition pxe_api.h:406
String functions.
#define __init_fn(init_order)
Declare an initialisation functon.
Definition init.h:24
#define __bss16(variable)
Definition libkir.h:16
Preboot eXecution Environment (PXE) API.
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
An initialisation function.
Definition init.h:15