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