From 4d5d7be005bb5c15c07472461b528dea65a58cc6 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Thu, 7 Jan 2016 22:55:13 -0800 Subject: [PATCH] Send a user class identifier in bootp requests It's helpful to determine that a request was sent by grub in order to permit the server to provide different information at different stages of the boot process. Send GRUB2 as a type 77 DHCP option when sending bootp packets in order to make this possible. --- grub-core/net/bootp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 4fdeac3ef..8519847eb 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -25,6 +25,11 @@ #include #include +static grub_uint8_t grub_userclass[] = {GRUB_NET_BOOTP_RFC1048_MAGIC_0, + GRUB_NET_BOOTP_RFC1048_MAGIC_1, + GRUB_NET_BOOTP_RFC1048_MAGIC_2, + GRUB_NET_BOOTP_RFC1048_MAGIC_3, + 0x4D, 0x05, 'G', 'R', 'U', 'B', '2'}; static void parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) { @@ -525,6 +530,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), pack->seconds = grub_cpu_to_be16 (t); grub_memcpy (&pack->mac_addr, &ifaces[j].hwaddress.mac, 6); + grub_memcpy (&pack->vendor, grub_userclass, sizeof(grub_userclass)); grub_netbuff_push (nb, sizeof (*udph));