diff mbox

[U-Boot,v5,10/13] net: bootp: add PXE/RFC 4578 DHCP options support

Message ID 1314805054-16250-11-git-send-email-jason.hobbs@calxeda.com
State Accepted
Headers show

Commit Message

Jason Hobbs Aug. 31, 2011, 3:37 p.m. UTC
These options are required to be present in RFC 4578 compliant DHCP
requests. They give more information to DHCP servers to allow serving

Comments

Wolfgang Denk Oct. 17, 2011, 8:21 p.m. UTC | #1
Dear "Jason Hobbs",

In message <1314805054-16250-11-git-send-email-jason.hobbs@calxeda.com> you wrote:
> These options are required to be present in RFC 4578 compliant DHCP
> requests. They give more information to DHCP servers to allow serving
> different DHCP responses to different systems based on client
> architecture, client capabilities, UUID, or vendor.
> 
> Signed-off-by: Jason Hobbs <jason.hobbs@calxeda.com>
> ---
> changes for v2:
> - Use common.h to get uuid_str_to_bin prototype
> 
> changes for v4:
> - Ensure pxeuuid contains a valid UUID string
> 
> changes for v5:
> - none
> 
>  net/bootp.c |   40 ++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 40 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

different DHCP responses to different systems based on client
architecture, client capabilities, UUID, or vendor.

Signed-off-by: Jason Hobbs <jason.hobbs@calxeda.com>
---
changes for v2:
- Use common.h to get uuid_str_to_bin prototype

changes for v4:
- Ensure pxeuuid contains a valid UUID string

changes for v5:
- none

 net/bootp.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/net/bootp.c b/net/bootp.c
index 45eaab1..b04bb2b 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -370,6 +370,11 @@  static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
 {
 	u8 *start = e;
 	u8 *cnt;
+#if defined(CONFIG_BOOTP_PXE)
+	char *uuid;
+	size_t vci_strlen;
+	u16 clientarch;
+#endif
 
 #if defined(CONFIG_BOOTP_VENDOREX)
 	u8 *x;
@@ -424,6 +429,41 @@  static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
 	}
 #endif
 
+#if defined(CONFIG_BOOTP_PXE)
+	clientarch = CONFIG_BOOTP_PXE_CLIENTARCH;
+	*e++ = 93;	/* Client System Architecture */
+	*e++ = 2;
+	*e++ = (clientarch >> 8) & 0xff;
+	*e++ = clientarch & 0xff;
+
+	*e++ = 94;	/* Client Network Interface Identifier */
+	*e++ = 3;
+	*e++ = 1;	/* type field for UNDI */
+	*e++ = 0;	/* major revision */
+	*e++ = 0;	/* minor revision */
+
+	uuid = getenv("pxeuuid");
+
+	if (uuid) {
+		if (uuid_str_valid(uuid)) {
+			*e++ = 97;	/* Client Machine Identifier */
+			*e++ = 17;
+			*e++ = 0;	/* type 0 - UUID */
+
+			uuid_str_to_bin(uuid, e);
+			e += 16;
+		} else {
+			printf("Invalid pxeuuid: %s\n", uuid);
+		}
+	}
+
+	*e++ = 60;	/* Vendor Class Identifier */
+	vci_strlen = strlen(CONFIG_BOOTP_VCI_STRING);
+	*e++ = vci_strlen;
+	memcpy(e, CONFIG_BOOTP_VCI_STRING, vci_strlen);
+	e += vci_strlen;
+#endif
+
 #if defined(CONFIG_BOOTP_VENDOREX)
 	if ((x = dhcp_vendorex_prep (e)))
 		return x - start;