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 
24 FILE_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  */
53 static 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 */
76 struct init_fn cachedhcp_init_fn __init_fn ( INIT_NORMAL ) = {
77  .name = "cachedhcp",
78  .initialise = cachedhcp_init,
79 };
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define cached_dhcpack_phys
#define DBGC(...)
Definition: compiler.h:505
uint32_t __bss16(cached_dhcpack_phys)
Cached DHCPACK physical address.
struct init_fn cachedhcp_init_fn __init_fn(INIT_NORMAL)
Cached DHCPACK initialisation function.
#define INIT_NORMAL
Normal initialisation.
Definition: init.h:31
An initialisation function.
Definition: init.h:14
static void cachedhcp_init(void)
Cached DHCPACK initialisation function.
const char * name
Definition: init.h:15
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:202
Cached DHCP packet.
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
Preboot eXecution Environment (PXE) API.
unsigned int uint32_t
Definition: stdint.h:12
struct cached_dhcp_packet cached_dhcpack
Cached DHCPACK.
Definition: cachedhcp.c:62
#define colour
Colour for debug messages.
Format of buffer filled in by pxenv_get_cached_info()
Definition: pxe_api.h:322
String functions.