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 <ipxe/init.h>
28 #include <ipxe/cachedhcp.h>
29 #include <realmode.h>
30 #include <pxe_api.h>
31 
32 /** @file
33  *
34  * Cached DHCP packet
35  *
36  */
37 
38 /** Cached DHCPACK physical address
39  *
40  * This can be set by the prefix.
41  */
43 #define cached_dhcpack_phys __use_data16 ( cached_dhcpack_phys )
44 
45 /** Colour for debug messages */
46 #define colour &cached_dhcpack_phys
47 
48 /**
49  * Cached DHCPACK initialisation function
50  *
51  */
52 static void cachedhcp_init ( void ) {
53  int rc;
54 
55  /* Do nothing if no cached DHCPACK is present */
56  if ( ! cached_dhcpack_phys ) {
57  DBGC ( colour, "CACHEDHCP found no cached DHCPACK\n" );
58  return;
59  }
60 
61  /* Record cached DHCPACK */
62  if ( ( rc = cachedhcp_record ( &cached_dhcpack, 0,
64  sizeof ( BOOTPLAYER_t ) ) ) != 0 ) {
65  DBGC ( colour, "CACHEDHCP could not record DHCPACK: %s\n",
66  strerror ( rc ) );
67  return;
68  }
69 
70  /* Mark as consumed */
72 }
73 
74 /** Cached DHCPACK initialisation function */
75 struct init_fn cachedhcp_init_fn __init_fn ( INIT_NORMAL ) = {
77 };
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void(* initialise)(void)
Definition: init.h:15
#define cached_dhcpack_phys
#define DBGC(...)
Definition: compiler.h:505
uint32_t __bss16(cached_dhcpack_phys)
Cached DHCPACK physical address.
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
struct init_fn cachedhcp_init_fn __init_fn(INIT_NORMAL)
Cached DHCPACK initialisation function.
#define INIT_NORMAL
Normal initialisation.
Definition: init.h:30
An initialisation function.
Definition: init.h:14
static void cachedhcp_init(void)
Cached DHCPACK initialisation function.
Cached DHCP packet.
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int cachedhcp_record(struct cached_dhcp_packet *cache, unsigned int vlan, userptr_t data, size_t max_len)
Record cached DHCP packet.
Definition: cachedhcp.c:200
Preboot eXecution Environment (PXE) API.
unsigned int uint32_t
Definition: stdint.h:12
struct cached_dhcp_packet cached_dhcpack
Cached DHCPACK.
Definition: cachedhcp.c:60
#define colour
Colour for debug messages.
Format of buffer filled in by pxenv_get_cached_info()
Definition: pxe_api.h:322