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.
This commit is contained in:
Matthew Garrett 2016-01-07 22:55:13 -08:00
parent 78db6bcf33
commit 4d5d7be005
1 changed files with 6 additions and 0 deletions

View File

@ -25,6 +25,11 @@
#include <grub/net/udp.h>
#include <grub/datetime.h>
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));