[syslinux:master] pxe: Re-add support for embedded DHCP options
syslinux-bot for H. Peter Anvin
hpa at zytor.com
Mon Jun 16 17:45:06 PDT 2014
Commit-ID: 191e622cdd85271783682ff38f4c307b89cfe040
Gitweb: http://www.syslinux.org/commit/191e622cdd85271783682ff38f4c307b89cfe040
Author: H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 16 Jun 2014 17:39:24 -0700
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 16 Jun 2014 17:42:36 -0700
pxe: Re-add support for embedded DHCP options
Fix the support for embedded DHCP options. Although we were
diligently saving them away, we never actually parsed them.
This fixes embedded options for BIOS only -- for EFI we need to modify
the encoding scheme so that it can fit inside an EFI PECOFF image.
Signed-off-by: H. Peter Anvin <hpa at zytor.com>
---
core/fs/pxe/bios.c | 17 +++++++++++++++++
core/fs/pxe/dhcp_option.c | 7 ++++---
core/fs/pxe/pxe.h | 1 +
core/pxelinux.asm | 1 +
4 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/core/fs/pxe/bios.c b/core/fs/pxe/bios.c
index 6d514df..6eb3762 100644
--- a/core/fs/pxe/bios.c
+++ b/core/fs/pxe/bios.c
@@ -5,6 +5,7 @@
#include <net.h>
#include <minmax.h>
#include <bios.h>
+#include <dprintf.h>
static uint16_t real_base_mem; /* Amount of DOS memory after freeing */
@@ -385,6 +386,9 @@ cant_free:
return;
}
+extern const char bdhcp_data[], adhcp_data[];
+extern const uint32_t bdhcp_len, adhcp_len;
+
void net_parse_dhcp(void)
{
int pkt_len;
@@ -400,11 +404,18 @@ void net_parse_dhcp(void)
*LocalDomain = 0; /* No LocalDomain received */
/*
+ * Parse any "before" hardcoded options
+ */
+ dprintf("DHCP: bdhcp_len = %d\n", bdhcp_len);
+ parse_dhcp_options(bdhcp_data, bdhcp_len, 0);
+
+ /*
* Get the DHCP client identifiers (query info 1)
*/
ddprintf("Getting cached packet ");
pkt_len = pxe_get_cached_info(1, bp, dhcp_max_packet);
parse_dhcp(bp, pkt_len);
+
/*
* We don't use flags from the request packet, so
* this is a good time to initialize DHCPMagic...
@@ -439,5 +450,11 @@ void net_parse_dhcp(void)
parse_dhcp(bp, pkt_len);
ddprintf("\n");
+ /*
+ * Parse any "after" hardcoded options
+ */
+ dprintf("DHCP: adhcp_len = %d\n", adhcp_len);
+ parse_dhcp_options(adhcp_data, adhcp_len, 0);
+
lfree(bp);
}
diff --git a/core/fs/pxe/dhcp_option.c b/core/fs/pxe/dhcp_option.c
index 3517161..1fdcc70 100644
--- a/core/fs/pxe/dhcp_option.c
+++ b/core/fs/pxe/dhcp_option.c
@@ -3,6 +3,7 @@
#include <core.h>
#include <sys/cpu.h>
#include <lwip/opt.h> /* DNS_MAX_SERVERS */
+#include <dprintf.h>
#include "pxe.h"
char LocalDomain[256];
@@ -11,8 +12,6 @@ int over_load;
uint8_t uuid_type;
uint8_t uuid[16];
-static void parse_dhcp_options(const void *, int, uint8_t);
-
static void subnet_mask(const void *data, int opt_len)
{
if (opt_len != 4)
@@ -164,7 +163,7 @@ static const struct dhcp_options dhcp_opts[] = {
* filter contains the minimum value for the option to recognize
* -- this is used to restrict parsing to PXELINUX-specific options only.
*/
-static void parse_dhcp_options(const void *option, int size, uint8_t opt_filter)
+void parse_dhcp_options(const void *option, int size, uint8_t opt_filter)
{
int opt_num;
int opt_len;
@@ -189,6 +188,8 @@ static void parse_dhcp_options(const void *option, int size, uint8_t opt_filter)
if (size < 0)
break;
+ dprintf("DHCP: option %d, len %d\n", opt_num, opt_len);
+
if (opt_num >= opt_filter) {
opt = dhcp_opts;
for (i = 0; i < opt_entries; i++) {
diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h
index 279957a..15252ff 100644
--- a/core/fs/pxe/pxe.h
+++ b/core/fs/pxe/pxe.h
@@ -231,6 +231,7 @@ int undiif_start(uint32_t ip, uint32_t netmask, uint32_t gw);
void undiif_input(t_PXENV_UNDI_ISR *isr);
/* dhcp_options.c */
+void parse_dhcp_options(const void *, int, uint8_t);
void parse_dhcp(const void *, size_t);
/* idle.c */
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index 953a906..d4b1a07 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -93,6 +93,7 @@ _start:
hcdhcp_magic dd 0x2983c8ac ; Magic number
hcdhcp_len dd 7*4 ; Size of this structure
hcdhcp_flags dd 0 ; Reserved for the future
+ global bdhcp_len, adhcp_len
; Parameters to be parsed before the ones from PXE
bdhcp_offset dd 0 ; Offset (entered by patcher)
bdhcp_len dd 0 ; Length (entered by patcher)
More information about the Syslinux-commits
mailing list