|
|
f96e0b |
From af13434ca0de9ef01b5f77fb85d5b3ac6c3d1d91 Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
|
|
|
f96e0b |
Date: Tue, 27 Nov 2012 17:18:53 -0200
|
|
|
f96e0b |
Subject: [PATCH 456/482] DHCP client ID and UUID options added.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
grub-core/net/bootp.c | 52 +++++++++++++++++++++++++++++++++++++++++++--------
|
|
|
f96e0b |
include/grub/net.h | 2 ++
|
|
|
f96e0b |
2 files changed, 46 insertions(+), 8 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
|
|
|
f96e0b |
index c8ef4d6..af3cb62 100644
|
|
|
f96e0b |
--- a/grub-core/net/bootp.c
|
|
|
f96e0b |
+++ b/grub-core/net/bootp.c
|
|
|
f96e0b |
@@ -51,6 +51,14 @@ set_env_limn_ro (const char *intername, const char *suffix,
|
|
|
f96e0b |
grub_register_variable_hook (varname, 0, grub_env_write_readonly);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
+static char
|
|
|
f96e0b |
+hexdigit (grub_uint8_t val)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ if (val < 10)
|
|
|
f96e0b |
+ return val + '0';
|
|
|
f96e0b |
+ return val + 'a' - 10;
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
static void
|
|
|
f96e0b |
parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
@@ -81,6 +89,9 @@ parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
|
|
|
f96e0b |
|
|
|
f96e0b |
taglength = *ptr++;
|
|
|
f96e0b |
|
|
|
f96e0b |
+ grub_dprintf("net", "DHCP option %u (0x%02x) found with length %u.\n",
|
|
|
f96e0b |
+ tagtype, tagtype, taglength);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
switch (tagtype)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
case GRUB_NET_BOOTP_NETMASK:
|
|
|
f96e0b |
@@ -139,6 +150,39 @@ parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
|
|
|
f96e0b |
set_env_limn_ro (name, "extensionspath", (char *) ptr, taglength);
|
|
|
f96e0b |
break;
|
|
|
f96e0b |
|
|
|
f96e0b |
+ case GRUB_NET_BOOTP_CLIENT_ID:
|
|
|
f96e0b |
+ set_env_limn_ro (name, "clientid", (char *) ptr, taglength);
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ case GRUB_NET_BOOTP_CLIENT_UUID:
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ if (taglength != 17)
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ /* The format is 9cfe245e-d0c8-bd45-a79f-54ea5fbd3d97 */
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ ptr += 1;
|
|
|
f96e0b |
+ taglength -= 1;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ char *val = grub_malloc (2 * taglength + 4 + 1);
|
|
|
f96e0b |
+ int i = 0;
|
|
|
f96e0b |
+ int j = 0;
|
|
|
f96e0b |
+ for (i = 0; i < taglength; i++)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ val[2 * i + j] = hexdigit (ptr[i] >> 4);
|
|
|
f96e0b |
+ val[2 * i + 1 + j] = hexdigit (ptr[i] & 0xf);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if ((i == 3) || (i == 5) || (i == 7) || (i == 9))
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ j++;
|
|
|
f96e0b |
+ val[2 * i + 1+ j] = '-';
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ set_env_limn_ro (name, "clientuuid", (char *) val, 2 * taglength + 4);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
/* If you need any other options please contact GRUB
|
|
|
f96e0b |
development team. */
|
|
|
f96e0b |
}
|
|
|
f96e0b |
@@ -302,14 +346,6 @@ grub_net_process_dhcp (struct grub_net_buff *nb,
|
|
|
f96e0b |
}
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
-static char
|
|
|
f96e0b |
-hexdigit (grub_uint8_t val)
|
|
|
f96e0b |
-{
|
|
|
f96e0b |
- if (val < 10)
|
|
|
f96e0b |
- return val + '0';
|
|
|
f96e0b |
- return val + 'a' - 10;
|
|
|
f96e0b |
-}
|
|
|
f96e0b |
-
|
|
|
f96e0b |
static grub_err_t
|
|
|
f96e0b |
grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
|
|
|
f96e0b |
int argc, char **args)
|
|
|
f96e0b |
diff --git a/include/grub/net.h b/include/grub/net.h
|
|
|
f96e0b |
index fe29b16..36ac906 100644
|
|
|
f96e0b |
--- a/include/grub/net.h
|
|
|
f96e0b |
+++ b/include/grub/net.h
|
|
|
f96e0b |
@@ -424,6 +424,8 @@ enum
|
|
|
f96e0b |
GRUB_NET_BOOTP_DOMAIN = 0x0f,
|
|
|
f96e0b |
GRUB_NET_BOOTP_ROOT_PATH = 0x11,
|
|
|
f96e0b |
GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12,
|
|
|
f96e0b |
+ GRUB_NET_BOOTP_CLIENT_ID = 0x3d,
|
|
|
f96e0b |
+ GRUB_NET_BOOTP_CLIENT_UUID = 0x61,
|
|
|
f96e0b |
GRUB_NET_BOOTP_END = 0xff
|
|
|
f96e0b |
};
|
|
|
f96e0b |
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|