aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGene Cumm <gene.cumm@gmail.com>2015-06-20 21:17:18 -0400
committerGene Cumm <gene.cumm@gmail.com>2015-06-20 21:17:18 -0400
commit38e861ebf45a804bc5fbd74d9c19292822c84487 (patch)
tree644756b1a1d16670aae8e36bb9289e7fae5dbb8b
parent536b893e159259c8cd7ed0b196343ad60e0e4579 (diff)
downloadsyslinux-38e861ebf45a804bc5fbd74d9c19292822c84487.tar.gz
syslinux-38e861ebf45a804bc5fbd74d9c19292822c84487.tar.xz
syslinux-38e861ebf45a804bc5fbd74d9c19292822c84487.zip
core/pxe: extend parse_dhcp() for packet type
Add packet type so we can eventually only grab certain data elements from the DHCP packets appropriately Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
-rw-r--r--core/fs/pxe/bios.c6
-rw-r--r--core/fs/pxe/dhcp_option.c6
-rw-r--r--core/fs/pxe/pxe.h2
-rw-r--r--efi/pxe.c6
4 files changed, 11 insertions, 9 deletions
diff --git a/core/fs/pxe/bios.c b/core/fs/pxe/bios.c
index 6eb37626..91b48fe6 100644
--- a/core/fs/pxe/bios.c
+++ b/core/fs/pxe/bios.c
@@ -414,7 +414,7 @@ void net_parse_dhcp(void)
*/
ddprintf("Getting cached packet ");
pkt_len = pxe_get_cached_info(1, bp, dhcp_max_packet);
- parse_dhcp(bp, pkt_len);
+ parse_dhcp(bp, pkt_len, 1);
/*
* We don't use flags from the request packet, so
@@ -432,7 +432,7 @@ void net_parse_dhcp(void)
* address). This lives in the DHCPACK packet (query info 2)
*/
pkt_len = pxe_get_cached_info(2, bp, dhcp_max_packet);
- parse_dhcp(bp, pkt_len);
+ parse_dhcp(bp, pkt_len, 2);
/*
* Save away MAC address (assume this is in query info 2. If this
* turns out to be problematic it might be better getting it from
@@ -447,7 +447,7 @@ void net_parse_dhcp(void)
* packet (query info 3)
*/
pkt_len = pxe_get_cached_info(3, bp, dhcp_max_packet);
- parse_dhcp(bp, pkt_len);
+ parse_dhcp(bp, pkt_len, 3);
ddprintf("\n");
/*
diff --git a/core/fs/pxe/dhcp_option.c b/core/fs/pxe/dhcp_option.c
index 8a0dee3b..c1f4e509 100644
--- a/core/fs/pxe/dhcp_option.c
+++ b/core/fs/pxe/dhcp_option.c
@@ -212,6 +212,8 @@ void parse_dhcp_options(const void *option, int size, uint8_t opt_filter)
* Parse a DHCP packet. This includes dealing with "overloaded"
* option fields (see RFC 2132, section 9.3)
*
+ * pkt_type 1 for Discover, 2 for Ack, 3 for ProxyDHCP, 0 for everything
+ *
* This should fill in the following global variables, if the
* information is present:
*
@@ -225,7 +227,7 @@ void parse_dhcp_options(const void *option, int size, uint8_t opt_filter)
* MAC_len, MAC - Client identifier, if MAC_len == 0
*
*/
-void parse_dhcp(const void *pkt, size_t pkt_len)
+void parse_dhcp(const void *pkt, size_t pkt_len, int pkt_type)
{
const struct bootp_t *dhcp = (const struct bootp_t *)pkt;
int opt_len;
@@ -233,7 +235,7 @@ void parse_dhcp(const void *pkt, size_t pkt_len)
IPInfo.ipver = 4; /* This is IPv4 only for now... */
over_load = 0;
- if (ip_ok(dhcp->yip))
+ if ((pkt_type == 0 || pkt_type == 2) && ip_ok(dhcp->yip))
IPInfo.myip = dhcp->yip;
if (ip_ok(dhcp->sip))
diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h
index 15252fff..271005c7 100644
--- a/core/fs/pxe/pxe.h
+++ b/core/fs/pxe/pxe.h
@@ -232,7 +232,7 @@ 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);
+void parse_dhcp(const void *, size_t, int);
/* idle.c */
void pxe_idle_init(void);
diff --git a/efi/pxe.c b/efi/pxe.c
index 7b3f9a0d..443ab471 100644
--- a/efi/pxe.c
+++ b/efi/pxe.c
@@ -123,7 +123,7 @@ void net_parse_dhcp(void)
* Get the DHCP client identifiers (BIOS/PXE query info 1)
*/
Print(L"Getting cached packet ");
- parse_dhcp(&mode->DhcpDiscover.Dhcpv4, pkt_len);
+ parse_dhcp(&mode->DhcpDiscover.Dhcpv4, pkt_len, 1);
/*
* We don't use flags from the request packet, so
* this is a good time to initialize DHCPMagic...
@@ -139,7 +139,7 @@ void net_parse_dhcp(void)
* Get the BOOTP/DHCP packet that brought us file (and an IP
* address). This lives in the DHCPACK packet (BIOS/PXE query info 2)
*/
- parse_dhcp(&mode->DhcpAck.Dhcpv4, pkt_len);
+ parse_dhcp(&mode->DhcpAck.Dhcpv4, pkt_len, 2);
/*
* Get the boot file and other info. This lives in the CACHED_REPLY
@@ -153,7 +153,7 @@ void net_parse_dhcp(void)
pkt_v4 = &mode->ProxyOffer.Dhcpv4;
if (pkt_v4)
- parse_dhcp(pkt_v4, pkt_len);
+ parse_dhcp(pkt_v4, pkt_len, 3);
/*
* Save away MAC address (assume this is in query info 2. If this