|
|
0dc71c |
From 533058df7c164a4d3498dfaa626923904597f162 Mon Sep 17 00:00:00 2001
|
|
|
0dc71c |
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
|
|
|
0dc71c |
Date: Tue, 4 Feb 2014 18:41:38 -0200
|
|
|
0dc71c |
Subject: [PATCH 058/143] add grub_env_set_net_property function
|
|
|
0dc71c |
|
|
|
0dc71c |
* grub-core/net/bootp.c: Remove set_env_limn_ro.
|
|
|
0dc71c |
* grub-core/net/net.c: Add grub_env_set_net_property.
|
|
|
0dc71c |
* include/grub/net.h: Likewise.
|
|
|
0dc71c |
---
|
|
|
0dc71c |
ChangeLog | 8 +++++++
|
|
|
0dc71c |
grub-core/net/bootp.c | 63 +++++++++++++--------------------------------------
|
|
|
0dc71c |
grub-core/net/net.c | 38 +++++++++++++++++++++++++++++++
|
|
|
0dc71c |
include/grub/net.h | 4 ++++
|
|
|
0dc71c |
4 files changed, 66 insertions(+), 47 deletions(-)
|
|
|
0dc71c |
|
|
|
0dc71c |
diff --git a/ChangeLog b/ChangeLog
|
|
|
0dc71c |
index f4a4721..63f5aa3 100644
|
|
|
0dc71c |
--- a/ChangeLog
|
|
|
0dc71c |
+++ b/ChangeLog
|
|
|
0dc71c |
@@ -1,3 +1,11 @@
|
|
|
0dc71c |
+2014-02-04 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
|
|
|
0dc71c |
+
|
|
|
0dc71c |
+ Add grub_env_set_net_property function.
|
|
|
0dc71c |
+
|
|
|
0dc71c |
+ * grub-core/net/bootp.c: Remove set_env_limn_ro.
|
|
|
0dc71c |
+ * grub-core/net/net.c: Add grub_env_set_net_property.
|
|
|
0dc71c |
+ * include/grub/net.h: Likewise.
|
|
|
0dc71c |
+
|
|
|
0dc71c |
2014-02-03 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
0dc71c |
|
|
|
0dc71c |
* util/grub-mkrescue.c: Build fix for argp.h with older gcc.
|
|
|
0dc71c |
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
|
|
|
0dc71c |
index c14e9de..6310ed4 100644
|
|
|
0dc71c |
--- a/grub-core/net/bootp.c
|
|
|
0dc71c |
+++ b/grub-core/net/bootp.c
|
|
|
0dc71c |
@@ -25,41 +25,6 @@
|
|
|
0dc71c |
#include <grub/net/udp.h>
|
|
|
0dc71c |
#include <grub/datetime.h>
|
|
|
0dc71c |
|
|
|
0dc71c |
-static char *
|
|
|
0dc71c |
-grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)),
|
|
|
0dc71c |
- const char *val __attribute__ ((unused)))
|
|
|
0dc71c |
-{
|
|
|
0dc71c |
- return NULL;
|
|
|
0dc71c |
-}
|
|
|
0dc71c |
-
|
|
|
0dc71c |
-static void
|
|
|
0dc71c |
-set_env_limn_ro (const char *intername, const char *suffix,
|
|
|
0dc71c |
- const char *value, grub_size_t len)
|
|
|
0dc71c |
-{
|
|
|
0dc71c |
- char *varname, *varvalue;
|
|
|
0dc71c |
- char *ptr;
|
|
|
0dc71c |
- varname = grub_xasprintf ("net_%s_%s", intername, suffix);
|
|
|
0dc71c |
- if (!varname)
|
|
|
0dc71c |
- return;
|
|
|
0dc71c |
- for (ptr = varname; *ptr; ptr++)
|
|
|
0dc71c |
- if (*ptr == ':')
|
|
|
0dc71c |
- *ptr = '_';
|
|
|
0dc71c |
- varvalue = grub_malloc (len + 1);
|
|
|
0dc71c |
- if (!varvalue)
|
|
|
0dc71c |
- {
|
|
|
0dc71c |
- grub_free (varname);
|
|
|
0dc71c |
- return;
|
|
|
0dc71c |
- }
|
|
|
0dc71c |
-
|
|
|
0dc71c |
- grub_memcpy (varvalue, value, len);
|
|
|
0dc71c |
- varvalue[len] = 0;
|
|
|
0dc71c |
- grub_env_set (varname, varvalue);
|
|
|
0dc71c |
- grub_register_variable_hook (varname, 0, grub_env_write_readonly);
|
|
|
0dc71c |
- grub_env_export (varname);
|
|
|
0dc71c |
- grub_free (varname);
|
|
|
0dc71c |
- grub_free (varvalue);
|
|
|
0dc71c |
-}
|
|
|
0dc71c |
-
|
|
|
0dc71c |
static void
|
|
|
0dc71c |
parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask)
|
|
|
0dc71c |
{
|
|
|
0dc71c |
@@ -136,20 +101,24 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask)
|
|
|
0dc71c |
}
|
|
|
0dc71c |
continue;
|
|
|
0dc71c |
case GRUB_NET_BOOTP_HOSTNAME:
|
|
|
0dc71c |
- set_env_limn_ro (name, "hostname", (const char *) ptr, taglength);
|
|
|
0dc71c |
- break;
|
|
|
0dc71c |
+ grub_env_set_net_property (name, "hostname", (const char *) ptr,
|
|
|
0dc71c |
+ taglength);
|
|
|
0dc71c |
+ break;
|
|
|
0dc71c |
|
|
|
0dc71c |
case GRUB_NET_BOOTP_DOMAIN:
|
|
|
0dc71c |
- set_env_limn_ro (name, "domain", (const char *) ptr, taglength);
|
|
|
0dc71c |
- break;
|
|
|
0dc71c |
+ grub_env_set_net_property (name, "domain", (const char *) ptr,
|
|
|
0dc71c |
+ taglength);
|
|
|
0dc71c |
+ break;
|
|
|
0dc71c |
|
|
|
0dc71c |
case GRUB_NET_BOOTP_ROOT_PATH:
|
|
|
0dc71c |
- set_env_limn_ro (name, "rootpath", (const char *) ptr, taglength);
|
|
|
0dc71c |
- break;
|
|
|
0dc71c |
+ grub_env_set_net_property (name, "rootpath", (const char *) ptr,
|
|
|
0dc71c |
+ taglength);
|
|
|
0dc71c |
+ break;
|
|
|
0dc71c |
|
|
|
0dc71c |
case GRUB_NET_BOOTP_EXTENSIONS_PATH:
|
|
|
0dc71c |
- set_env_limn_ro (name, "extensionspath", (const char *) ptr, taglength);
|
|
|
0dc71c |
- break;
|
|
|
0dc71c |
+ grub_env_set_net_property (name, "extensionspath", (const char *) ptr,
|
|
|
0dc71c |
+ taglength);
|
|
|
0dc71c |
+ break;
|
|
|
0dc71c |
|
|
|
0dc71c |
/* If you need any other options please contact GRUB
|
|
|
0dc71c |
development team. */
|
|
|
0dc71c |
@@ -211,8 +180,8 @@ grub_net_configure_by_dhcp_ack (const char *name,
|
|
|
0dc71c |
}
|
|
|
0dc71c |
|
|
|
0dc71c |
if (size > OFFSET_OF (boot_file, bp))
|
|
|
0dc71c |
- set_env_limn_ro (name, "boot_file", (char *) bp->boot_file,
|
|
|
0dc71c |
- sizeof (bp->boot_file));
|
|
|
0dc71c |
+ grub_env_set_net_property (name, "boot_file", bp->boot_file,
|
|
|
0dc71c |
+ sizeof (bp->boot_file));
|
|
|
0dc71c |
if (is_def)
|
|
|
0dc71c |
grub_net_default_server = 0;
|
|
|
0dc71c |
if (is_def && !grub_net_default_server && bp->server_ip)
|
|
|
0dc71c |
@@ -243,8 +212,8 @@ grub_net_configure_by_dhcp_ack (const char *name,
|
|
|
0dc71c |
if (size > OFFSET_OF (server_name, bp)
|
|
|
0dc71c |
&& bp->server_name[0])
|
|
|
0dc71c |
{
|
|
|
0dc71c |
- set_env_limn_ro (name, "dhcp_server_name", (char *) bp->server_name,
|
|
|
0dc71c |
- sizeof (bp->server_name));
|
|
|
0dc71c |
+ grub_env_set_net_property (name, "dhcp_server_name", bp->server_name,
|
|
|
0dc71c |
+ sizeof (bp->server_name));
|
|
|
0dc71c |
if (is_def && !grub_net_default_server)
|
|
|
0dc71c |
{
|
|
|
0dc71c |
grub_net_default_server = grub_strdup (bp->server_name);
|
|
|
0dc71c |
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
|
|
|
0dc71c |
index 1521d8d..f2e723b 100644
|
|
|
0dc71c |
--- a/grub-core/net/net.c
|
|
|
0dc71c |
+++ b/grub-core/net/net.c
|
|
|
0dc71c |
@@ -1480,6 +1480,44 @@ receive_packets (struct grub_net_card *card, int *stop_condition)
|
|
|
0dc71c |
grub_print_error ();
|
|
|
0dc71c |
}
|
|
|
0dc71c |
|
|
|
0dc71c |
+static char *
|
|
|
0dc71c |
+grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)),
|
|
|
0dc71c |
+ const char *val __attribute__ ((unused)))
|
|
|
0dc71c |
+{
|
|
|
0dc71c |
+ return NULL;
|
|
|
0dc71c |
+}
|
|
|
0dc71c |
+
|
|
|
0dc71c |
+grub_err_t
|
|
|
0dc71c |
+grub_env_set_net_property (const char *intername, const char *suffix,
|
|
|
0dc71c |
+ const char *value, grub_size_t len)
|
|
|
0dc71c |
+{
|
|
|
0dc71c |
+ char *varname, *varvalue;
|
|
|
0dc71c |
+ char *ptr;
|
|
|
0dc71c |
+
|
|
|
0dc71c |
+ varname = grub_xasprintf ("net_%s_%s", intername, suffix);
|
|
|
0dc71c |
+ if (!varname)
|
|
|
0dc71c |
+ return grub_errno;
|
|
|
0dc71c |
+ for (ptr = varname; *ptr; ptr++)
|
|
|
0dc71c |
+ if (*ptr == ':')
|
|
|
0dc71c |
+ *ptr = '_';
|
|
|
0dc71c |
+ varvalue = grub_malloc (len + 1);
|
|
|
0dc71c |
+ if (!varvalue)
|
|
|
0dc71c |
+ {
|
|
|
0dc71c |
+ grub_free (varname);
|
|
|
0dc71c |
+ return grub_errno;
|
|
|
0dc71c |
+ }
|
|
|
0dc71c |
+
|
|
|
0dc71c |
+ grub_memcpy (varvalue, value, len);
|
|
|
0dc71c |
+ varvalue[len] = 0;
|
|
|
0dc71c |
+ grub_err_t ret = grub_env_set (varname, varvalue);
|
|
|
0dc71c |
+ grub_register_variable_hook (varname, 0, grub_env_write_readonly);
|
|
|
0dc71c |
+ grub_env_export (varname);
|
|
|
0dc71c |
+ grub_free (varname);
|
|
|
0dc71c |
+ grub_free (varvalue);
|
|
|
0dc71c |
+
|
|
|
0dc71c |
+ return ret;
|
|
|
0dc71c |
+}
|
|
|
0dc71c |
+
|
|
|
0dc71c |
void
|
|
|
0dc71c |
grub_net_poll_cards (unsigned time, int *stop_condition)
|
|
|
0dc71c |
{
|
|
|
0dc71c |
diff --git a/include/grub/net.h b/include/grub/net.h
|
|
|
0dc71c |
index 0e0a605..538baa3 100644
|
|
|
0dc71c |
--- a/include/grub/net.h
|
|
|
0dc71c |
+++ b/include/grub/net.h
|
|
|
0dc71c |
@@ -480,6 +480,10 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target,
|
|
|
0dc71c |
void
|
|
|
0dc71c |
grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str);
|
|
|
0dc71c |
|
|
|
0dc71c |
+grub_err_t
|
|
|
0dc71c |
+grub_env_set_net_property (const char *intername, const char *suffix,
|
|
|
0dc71c |
+ const char *value, grub_size_t len);
|
|
|
0dc71c |
+
|
|
|
0dc71c |
void
|
|
|
0dc71c |
grub_net_poll_cards (unsigned time, int *stop_condition);
|
|
|
0dc71c |
|
|
|
0dc71c |
--
|
|
|
0dc71c |
1.9.3
|
|
|
0dc71c |
|