cachedhcp.c File Reference

Cached DHCP packet handling. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gpxe/dhcp.h>
#include <gpxe/dhcppkt.h>
#include <gpxe/netdevice.h>
#include <gpxe/iobuf.h>
#include <gpxe/uaccess.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
void store_cached_dhcpack (userptr_t data, size_t len)
 Store cached DHCPACK packet.


Detailed Description

Cached DHCP packet handling.

Definition in file cachedhcp.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

void store_cached_dhcpack ( userptr_t  data,
size_t  len 
)

Store cached DHCPACK packet.

Parameters:
data User pointer to cached DHCP packet data
len Length of cached DHCP packet data
Return values:
rc Return status code
This function should be called by the architecture-specific get_cached_dhcpack() handler.

Definition at line 46 of file cachedhcp.c.

References copy_from_user(), dhcp_options::data, DBG, DBG_HD, dhcppkt_init(), dhcppkt_put(), last_opened_netdev(), dhcp_options::len, netdev_settings(), dhcp_packet::options, settings::parent, register_settings(), dhcp_packet::settings, strerror(), and zalloc().

Referenced by get_cached_dhcpack().

00046                                                          {
00047         struct dhcp_packet *dhcppkt;
00048         struct dhcphdr *dhcphdr;
00049         struct settings *parent;
00050         int rc;
00051 
00052         /* Create DHCP packet */
00053         dhcppkt = zalloc ( sizeof ( *dhcppkt ) + len );
00054         if ( ! dhcppkt )
00055                 return;
00056 
00057         /* Fill in data for DHCP packet */
00058         dhcphdr = ( ( ( void * ) dhcppkt ) + sizeof ( * dhcppkt ) );
00059         copy_from_user ( dhcphdr, data, 0, len );
00060         dhcppkt_init ( dhcppkt, dhcphdr, len );
00061         DBG_HD ( dhcppkt->options.data, dhcppkt->options.len );
00062 
00063         /* Register settings on the last opened network device.
00064          * This will have the effect of registering cached settings
00065          * with a network device when "dhcp netX" is performed for that
00066          * device, which is usually what we want.
00067          */
00068         parent = netdev_settings ( last_opened_netdev() );
00069         if ( ( rc = register_settings ( &dhcppkt->settings, parent ) ) != 0 )
00070                 DBG ( "DHCP could not register cached settings: %s\n",
00071                       strerror ( rc ) );
00072 
00073         dhcppkt_put ( dhcppkt );
00074 
00075         DBG ( "DHCP registered cached settings\n" );
00076 }


Generated on Tue Apr 6 20:01:54 2010 for gPXE by  doxygen 1.5.7.1