pxeparent_dhcp.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 FILE_LICENCE ( GPL2_OR_LATER );
00020 
00021 #include <string.h>
00022 #include <gpxe/dhcp.h>
00023 #include <gpxe/netdevice.h>
00024 #include <undipreload.h>
00025 #include <pxeparent.h>
00026 #include <realmode.h>
00027 #include <pxe_api.h>
00028 
00029 /**
00030  * Present cached DHCP packet if it exists
00031  */
00032 void __weak_impl ( get_cached_dhcpack ) ( void ) {
00033         struct undi_device *undi;
00034         struct s_PXENV_GET_CACHED_INFO get_cached_info;
00035         int rc;
00036 
00037         /* Use preloaded UNDI device to get at PXE entry point */
00038         undi = &preloaded_undi;
00039         if ( ! undi->entry.segment ) {
00040                 DBG ( "PXEDHCP no preloaded UNDI device found\n" );
00041                 return;
00042         }
00043 
00044         /* Check that stack is available to get cached info */
00045         if ( ! ( undi->flags & UNDI_FL_KEEP_ALL ) ) {
00046                 DBG ( "PXEDHCP stack was unloaded, no cache available\n" );
00047                 return;
00048         }
00049 
00050         /* Obtain cached DHCP packet */
00051         memset ( &get_cached_info, 0, sizeof ( get_cached_info ) );
00052         get_cached_info.PacketType = PXENV_PACKET_TYPE_DHCP_ACK;
00053 
00054         if ( ( rc = pxeparent_call ( undi->entry, PXENV_GET_CACHED_INFO,
00055                                      &get_cached_info,
00056                                      sizeof ( get_cached_info ) ) ) != 0 ) {
00057                 DBG ( "PXEDHCP GET_CACHED_INFO failed: %s\n", strerror ( rc ) );
00058                 return;
00059         }
00060 
00061         DBG ( "PXEDHCP got cached info at %04x:%04x length %d\n",
00062               get_cached_info.Buffer.segment, get_cached_info.Buffer.offset,
00063               get_cached_info.BufferSize );
00064 
00065         /* Present cached DHCP packet */
00066         store_cached_dhcpack ( real_to_user ( get_cached_info.Buffer.segment,
00067                                               get_cached_info.Buffer.offset ),
00068                                get_cached_info.BufferSize );
00069 }

Generated on Tue Apr 6 20:00:51 2010 for gPXE by  doxygen 1.5.7.1