[U-Boot] [PATCH v3 6/8] net/bootp: add VCI support for BOOTP also

Ilya Yanok ilya.yanok at cogentembedded.com
Wed Jul 25 00:22:21 CEST 2012


Vendor Class Identifier option is common to BOOTP and DHCP and
can be useful without PXE. So send VCI in both BOOTP and DHCP
requests if CONFIG_BOOTP_VCI_STRING is defined.

Signed-off-by: Ilya Yanok <ilya.yanok at cogentembedded.com>
---

 net/bootp.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/net/bootp.c b/net/bootp.c
index 0f0867b..a68f914 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -339,6 +339,14 @@ BootpTimeout(void)
 	}
 }
 
+#define put_vci(e, str)				\
+	do {					\
+		*e++ = 60;			\
+		*e++ = sizeof(str);		\
+		memcpy(e, str, sizeof(str));	\
+		e += sizeof(str);		\
+	} while (0)
+
 /*
  *	Initialize BOOTP extension fields in the request.
  */
@@ -435,12 +443,10 @@ static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID,
 			printf("Invalid pxeuuid: %s\n", uuid);
 		}
 	}
+#endif
 
-	*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;
+#ifdef CONFIG_BOOTP_VCI_STRING
+	put_vci(e, CONFIG_VCI_STRING);
 #endif
 
 #if defined(CONFIG_BOOTP_VENDOREX)
@@ -527,6 +533,10 @@ static int BootpExtended(u8 *e)
 	*e++ = (576 - 312 + OPT_FIELD_SIZE) & 0xff;
 #endif
 
+#ifdef CONFIG_BOOTP_VCI_STRING
+	put_vci(e, CONFIG_VCI_STRING);
+#endif
+
 #if defined(CONFIG_BOOTP_SUBNETMASK)
 	*e++ = 1;		/* Subnet mask request */
 	*e++ = 4;
-- 
1.7.9.5



More information about the U-Boot mailing list