All of lore.kernel.org
 help / color / mirror / Atom feed
* Using network informations from PXE as grub2 enviroment variables
@ 2009-10-16 11:42 Aleš Kapica
  2009-10-16 11:57 ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 9+ messages in thread
From: Aleš Kapica @ 2009-10-16 11:42 UTC (permalink / raw)
  To: grub-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 969 bytes --]

Dear friends,

You have missunderstood my previous post from Thu, 15 Oct 2009 08:52:01 +0200 when I post patch, which fixies problem with identification of the booting machine in network by IP address.
The following discussion have nothing to do with my post. I want to clarify porpose of my patch.

Nobody can't use options 150 from DHCP, because GRUB2 don't have any driver for network adapters. Network task are done only through adapters PXE firmware. PXE passes informations only about IP addresses, but no DHCP options.

In current state these informations is possible only to list, that means that they aren't a part of the grubs environment.
My patch solve this. Now is this possible to set PXE informations as grubs environment variables, and use in them in grub.cfg for identification of the booting machine.

Is there any problem with adding of my patch?

Aleš Kapica

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

[-- Attachment #2: set_pxeinfo_into_enviroment_variables.diff --]
[-- Type: application/octet-stream, Size: 1657 bytes --]

diff --git a/grub2/commands/i386/pc/pxecmd.c b/grub2/commands/i386/pc/pxecmd.c
index df53870..066d9a0 100644
--- a/grub2/commands/i386/pc/pxecmd.c
+++ b/grub2/commands/i386/pc/pxecmd.c
@@ -22,12 +22,14 @@
 #include <grub/misc.h>
 #include <grub/machine/pxe.h>
 #include <grub/extcmd.h>
+#include <grub/env.h>
 
 static const struct grub_arg_option options[] =
 {
     {"info", 'i', 0, "show PXE information.", 0, 0},
     {"bsize", 'b', 0, "set PXE block size", 0, ARG_TYPE_INT},
     {"unload", 'u', 0, "unload PXE stack.", 0, 0},
+    {"set", 's', 0, "set network variables PXE_IP etc.", 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -43,6 +45,15 @@ print_ip (grub_uint32_t ip)
     }
   grub_printf ("%d", ip);
 }
+static void
+set_ip2env_var(char *var_name, grub_uint32_t ip)
+{
+	char s[20];
+	grub_sprintf (s,"%d.%d.%d.%d", (ip>>0)&0xFF,
+		(ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF);
+	grub_env_set (var_name, s);
+}
+
 
 static grub_err_t
 grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)),
@@ -78,6 +89,13 @@ grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)),
       grub_printf ("\n");
     }
 
+  if (state[3].set)
+    {
+		set_ip2env_var ("pxe_your_ip", grub_pxe_your_ip);
+		set_ip2env_var ("pxe_server_ip", grub_pxe_server_ip);
+		set_ip2env_var ("pxe_gateway_ip", grub_pxe_gateway_ip);
+	}
+
   if (state[2].set)
     grub_pxe_unload ();
 
@@ -89,7 +107,7 @@ static grub_extcmd_t cmd;
 GRUB_MOD_INIT(pxecmd)
 {
   cmd = grub_register_extcmd ("pxe", grub_cmd_pxe, GRUB_COMMAND_FLAG_BOTH,
-			      "pxe [-i|-b|-u]",
+			      "pxe [-i|-b|-u|-s']",
 			      "Command to control the PXE device.", options);
 }
 

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-10-19 21:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-16 11:42 Using network informations from PXE as grub2 enviroment variables Aleš Kapica
2009-10-16 11:57 ` Vladimir 'phcoder' Serbinenko
2009-10-16 18:12   ` Pavel Pisa
2009-10-16 20:51     ` Seth Goldberg
2009-10-16 21:05       ` Vladimir 'phcoder' Serbinenko
2009-10-16 21:16         ` Seth Goldberg
2009-10-19 14:48     ` Brendan Trotter
2009-10-19 19:59       ` Seth Goldberg
2009-10-19 21:18       ` Vladimir 'phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.