2 * Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
19 FILE_LICENCE ( GPL2_OR_LATER
);
22 #include <gpxe/dhcp.h>
23 #include <gpxe/netdevice.h>
24 #include <undipreload.h>
25 #include <pxeparent.h>
30 * Present cached DHCP packet if it exists
32 void get_cached_dhcpack ( void ) {
33 struct undi_device
*undi
;
34 struct s_PXENV_GET_CACHED_INFO get_cached_info
;
37 /* Use preloaded UNDI device to get at PXE entry point */
38 undi
= &preloaded_undi
;
39 if ( ! undi
->entry
.segment
) {
40 DBG ( "PXEDHCP no preloaded UNDI device found\n" );
44 /* Check that stack is available to get cached info */
45 if ( ! ( undi
->flags
& UNDI_FL_KEEP_ALL
) ) {
46 DBG ( "PXEDHCP stack was unloaded, no cache available\n" );
50 /* Obtain cached DHCP packet */
51 memset ( &get_cached_info
, 0, sizeof ( get_cached_info
) );
52 get_cached_info
.PacketType
= PXENV_PACKET_TYPE_DHCP_ACK
;
54 if ( ( rc
= pxeparent_call ( undi
->entry
, PXENV_GET_CACHED_INFO
,
56 sizeof ( get_cached_info
) ) ) != 0 ) {
57 DBG ( "PXEDHCP GET_CACHED_INFO failed: %s\n", strerror ( rc
) );
61 DBG ( "PXEDHCP got cached info at %04x:%04x length %d\n",
62 get_cached_info
.Buffer
.segment
, get_cached_info
.Buffer
.offset
,
63 get_cached_info
.BufferSize
);
65 /* Present cached DHCP packet */
66 store_cached_dhcpack ( real_to_user ( get_cached_info
.Buffer
.segment
,
67 get_cached_info
.Buffer
.offset
),
68 get_cached_info
.BufferSize
);