mirror of
https://github.com/xcat2/xNBA.git
synced 2025-01-07 20:15:06 +00:00
[DHCP] Add support for ProxyDHCP requests
The PXE spec is (as usual) unclear on precisely when ProxyDHCPREQUESTs should be issued. We adapt the following, slightly paranoid approach: If an offer contains an IP address, then it is a normal DHCPOFFER. If an offer contains an option #60 "PXEClient", then it is a ProxyDHCPOFFER. Note that the same packet can be both a normal DHCPOFFER and a ProxyDHCPOFFER. After receiving the normal DHCPACK, if we have received a ProxyDHCPOFFER, we unicast a ProxyDHCPREQUEST back to the ProxyDHCP server on port 4011. If we time out waiting for a ProxyDHCPACK, we treat this as a non-fatal error.
This commit is contained in:
parent
af466aedf1
commit
aa74a7d53c
@ -24,6 +24,9 @@ struct dhcp_packet;
|
||||
/** BOOTP/DHCP client port */
|
||||
#define BOOTPC_PORT 68
|
||||
|
||||
/** ProxyDHCP server port */
|
||||
#define PROXYDHCP_PORT 4011
|
||||
|
||||
/** Construct a tag value for an encapsulated option
|
||||
*
|
||||
* This tag value can be passed to Etherboot functions when searching
|
||||
@ -433,7 +436,7 @@ struct dhcphdr {
|
||||
*/
|
||||
#define DHCP_MIN_LEN 552
|
||||
|
||||
/** Maximum time that we will wait for ProxyDHCP offers */
|
||||
/** Maximum time that we will wait for ProxyDHCP responses */
|
||||
#define PROXYDHCP_WAIT_TIME ( TICKS_PER_SEC * 1 )
|
||||
|
||||
/** Settings block name used for DHCP responses */
|
||||
@ -442,12 +445,13 @@ struct dhcphdr {
|
||||
/** Settings block name used for ProxyDHCP responses */
|
||||
#define PROXYDHCP_SETTINGS_NAME "proxydhcp"
|
||||
|
||||
extern int create_dhcp_packet ( struct dhcp_packet *dhcppkt,
|
||||
extern int dhcp_create_packet ( struct dhcp_packet *dhcppkt,
|
||||
struct net_device *netdev, uint8_t msgtype,
|
||||
struct dhcp_options *options,
|
||||
void *data, size_t max_len );
|
||||
extern int create_dhcp_request ( struct dhcp_packet *dhcppkt,
|
||||
extern int dhcp_create_request ( struct dhcp_packet *dhcppkt,
|
||||
struct net_device *netdev,
|
||||
struct in_addr ciaddr,
|
||||
struct dhcp_packet *dhcpoffer,
|
||||
void *data, size_t max_len );
|
||||
extern int start_dhcp ( struct job_interface *job, struct net_device *netdev );
|
||||
|
@ -108,9 +108,10 @@ static int copy_settings ( struct dhcp_packet *dest,
|
||||
int create_fakedhcpdiscover ( struct net_device *netdev,
|
||||
void *data, size_t max_len ) {
|
||||
struct dhcp_packet dhcppkt;
|
||||
struct in_addr ciaddr = { 0 };
|
||||
int rc;
|
||||
|
||||
if ( ( rc = create_dhcp_request ( &dhcppkt, netdev, NULL, data,
|
||||
if ( ( rc = dhcp_create_request ( &dhcppkt, netdev, ciaddr, NULL, data,
|
||||
max_len ) ) != 0 ) {
|
||||
DBG ( "Could not create DHCPDISCOVER: %s\n",
|
||||
strerror ( rc ) );
|
||||
@ -136,7 +137,7 @@ int create_fakedhcpack ( struct net_device *netdev,
|
||||
int rc;
|
||||
|
||||
/* Create base DHCPACK packet */
|
||||
if ( ( rc = create_dhcp_packet ( &dhcppkt, netdev, DHCPACK, NULL,
|
||||
if ( ( rc = dhcp_create_packet ( &dhcppkt, netdev, DHCPACK, NULL,
|
||||
data, max_len ) ) != 0 ) {
|
||||
DBG ( "Could not create DHCPACK: %s\n", strerror ( rc ) );
|
||||
return rc;
|
||||
@ -187,7 +188,7 @@ int create_fakeproxydhcpack ( struct net_device *netdev,
|
||||
}
|
||||
|
||||
/* Create base DHCPACK packet */
|
||||
if ( ( rc = create_dhcp_packet ( &dhcppkt, netdev, DHCPACK, NULL,
|
||||
if ( ( rc = dhcp_create_packet ( &dhcppkt, netdev, DHCPACK, NULL,
|
||||
data, max_len ) ) != 0 ) {
|
||||
DBG ( "Could not create ProxyDHCPACK: %s\n",
|
||||
strerror ( rc ) );
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user