1 From d63a0b7fd665fae1dd34d3e86127b93dd87b8114 Mon Sep 17 00:00:00 2001
2 From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
3 Date: Tue, 27 Nov 2012 17:18:53 -0200
4 Subject: [PATCH 2/3] DHCP client ID and UUID options added.
7 grub-core/net/bootp.c | 56 +++++++++++++++++++++++++++++++++++++++++--------
8 include/grub/net.h | 2 ++
9 2 files changed, 49 insertions(+), 9 deletions(-)
11 diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
12 index bc07d53..3b4130d 100644
13 --- a/grub-core/net/bootp.c
14 +++ b/grub-core/net/bootp.c
15 @@ -51,6 +51,14 @@ set_env_limn_ro (const char *intername, const char *suffix,
16 grub_register_variable_hook (varname, 0, grub_env_write_readonly);
20 +hexdigit (grub_uint8_t val)
24 + return val + 'a' - 10;
28 parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
30 @@ -81,6 +89,9 @@ parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
34 + grub_dprintf("net", "DHCP option %u (0x%02x) found with length %u.\n",
35 + tagtype, tagtype, taglength);
39 case GRUB_NET_BOOTP_NETMASK:
40 @@ -121,7 +132,9 @@ parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
41 grub_net_add_dns_server (&s);
45 + /* Skip adittional increment */
49 case GRUB_NET_BOOTP_HOSTNAME:
50 set_env_limn_ro (name, "hostname", (char *) ptr, taglength);
51 @@ -139,6 +152,39 @@ parse_dhcp_vendor (const char *name, void *vend, int limit, int *mask)
52 set_env_limn_ro (name, "extensionspath", (char *) ptr, taglength);
55 + case GRUB_NET_BOOTP_CLIENT_ID:
56 + set_env_limn_ro (name, "clientid", (char *) ptr, taglength);
59 + case GRUB_NET_BOOTP_CLIENT_UUID:
61 + if (taglength != 17)
64 + /* The format is 9cfe245e-d0c8-bd45-a79f-54ea5fbd3d97 */
69 + char *val = grub_malloc (2 * taglength + 4 + 1);
72 + for (i = 0; i < taglength; i++)
74 + val[2 * i + j] = hexdigit (ptr[i] >> 4);
75 + val[2 * i + 1 + j] = hexdigit (ptr[i] & 0xf);
77 + if ((i == 3) || (i == 5) || (i == 7) || (i == 9))
80 + val[2 * i + 1+ j] = '-';
84 + set_env_limn_ro (name, "clientuuid", (char *) val, 2 * taglength + 4);
88 /* If you need any other options please contact GRUB
89 developpement team. */
91 @@ -299,14 +345,6 @@ grub_net_process_dhcp (struct grub_net_buff *nb,
96 -hexdigit (grub_uint8_t val)
100 - return val + 'a' - 10;
104 grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)),
105 int argc, char **args)
106 diff --git a/include/grub/net.h b/include/grub/net.h
107 index a7e5b2c..45348dd 100644
108 --- a/include/grub/net.h
109 +++ b/include/grub/net.h
110 @@ -423,6 +423,8 @@ enum
111 GRUB_NET_BOOTP_DOMAIN = 0x0f,
112 GRUB_NET_BOOTP_ROOT_PATH = 0x11,
113 GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12,
114 + GRUB_NET_BOOTP_CLIENT_ID = 0x3d,
115 + GRUB_NET_BOOTP_CLIENT_UUID = 0x61,
116 GRUB_NET_BOOTP_END = 0xff