[syslinux:master] core/pxe: extend parse_dhcp() for packet type

syslinux-bot for Gene Cumm gene.cumm at gmail.com
Sun Jun 21 11:12:07 PDT 2015


Commit-ID:  38e861ebf45a804bc5fbd74d9c19292822c84487
Gitweb:     http://www.syslinux.org/commit/38e861ebf45a804bc5fbd74d9c19292822c84487
Author:     Gene Cumm <gene.cumm at gmail.com>
AuthorDate: Sat, 20 Jun 2015 21:17:18 -0400
Committer:  Gene Cumm <gene.cumm at gmail.com>
CommitDate: Sat, 20 Jun 2015 21:17:18 -0400

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 at gmail.com>

---
 core/fs/pxe/bios.c        | 6 +++---
 core/fs/pxe/dhcp_option.c | 6 ++++--
 core/fs/pxe/pxe.h         | 2 +-
 efi/pxe.c                 | 6 +++---
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/core/fs/pxe/bios.c b/core/fs/pxe/bios.c
index 6eb3762..91b48fe 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 8a0dee3..c1f4e50 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 15252ff..271005c 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 7b3f9a0..443ab47 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


More information about the Syslinux-commits mailing list