diff --git a/commands/i386/pc/pxecmd.c b/commands/i386/pc/pxecmd.c
index df53870..0521f1a 100644
--- a/commands/i386/pc/pxecmd.c
+++ b/commands/i386/pc/pxecmd.c
@@ -19,14 +19,16 @@
 
 #include <grub/dl.h>
 #include <grub/err.h>
+#include <grub/env.h>
 #include <grub/misc.h>
 #include <grub/machine/pxe.h>
 #include <grub/extcmd.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},
+    {"export", 'e', 0, "export PXE option.", 0, ARG_TYPE_INT},
     {"unload", 'u', 0, "unload PXE stack.", 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
@@ -44,6 +46,52 @@ print_ip (grub_uint32_t ip)
   grub_printf ("%d", ip);
 }
 
+static void
+print_options (void)
+{
+  grub_uint8_t *p, *start;
+
+  p = start = (grub_uint8_t *) &grub_pxe_bootinfo.vendor.v.flags;
+  while ((*p) && (p - start < GRUB_PXE_BOOTP_DHCPVEND - 4))
+    {
+      if (*p == 255)
+	break;
+
+      grub_printf (" %d(%d)", *p, *(p + 1));
+      p += *(p + 1) + 2;
+    }
+}
+
+static void
+export_option (int num)
+{
+  grub_uint8_t *p, *start;
+
+  p = start = (grub_uint8_t *) &grub_pxe_bootinfo.vendor.v.flags;
+  while ((*p) && (p - start < GRUB_PXE_BOOTP_DHCPVEND - 4))
+    {
+      if (*p == 255)
+	break;
+
+      if (*p == num)
+	{
+	  char name[10], c;
+	  int len;
+
+	  grub_sprintf (name, "PXE_%d", num);
+	  p += 2;
+	  len = *(p - 1);
+	  c = p[len];
+	  p[len] = 0;
+	  grub_env_set (name, (char *) p);
+	  p[len] = c;
+	  break;
+	}
+
+      p += *(p + 1) + 2;
+    }
+}
+
 static grub_err_t
 grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)),
 	      char **args __attribute__ ((unused)))
@@ -59,26 +107,43 @@ grub_cmd_pxe (grub_extcmd_t cmd, int argc __attribute__ ((unused)),
 
       size = grub_strtoul (state[1].arg, 0, 0);
       if (size < GRUB_PXE_MIN_BLKSIZE)
-        size = GRUB_PXE_MIN_BLKSIZE;
+	size = GRUB_PXE_MIN_BLKSIZE;
       else if (size > GRUB_PXE_MAX_BLKSIZE)
-        size = GRUB_PXE_MAX_BLKSIZE;
+	size = GRUB_PXE_MAX_BLKSIZE;
 
       grub_pxe_blksize = size;
     }
 
   if (state[0].set)
     {
+      char *mac;
+
       grub_printf ("blksize : %d\n", grub_pxe_blksize);
       grub_printf ("client ip  : ");
-      print_ip (grub_pxe_your_ip);
+      print_ip (grub_pxe_bootinfo.your_ip);
       grub_printf ("\nserver ip  : ");
-      print_ip (grub_pxe_server_ip);
+      print_ip (grub_pxe_bootinfo.server_ip);
       grub_printf ("\ngateway ip : ");
-      print_ip (grub_pxe_gateway_ip);
+      print_ip (grub_pxe_bootinfo.gateway_ip);
+
+      mac = grub_env_get ("PXE_MAC");
+      if (mac)
+	grub_printf ("\nMAC : %s", mac);
+
+      grub_printf ("\noptions:");
+      print_options ();
       grub_printf ("\n");
     }
 
   if (state[2].set)
+    {
+      int num;
+
+      num = grub_strtoul (state[2].arg, 0, 0);
+      export_option (num);
+    }
+
+  if (state[3].set)
     grub_pxe_unload ();
 
   return 0;
@@ -89,7 +154,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 [OPTIONS]",
 			      "Command to control the PXE device.", options);
 }
 
diff --git a/fs/i386/pc/pxe.c b/fs/i386/pc/pxe.c
index 4032e12..4802df4 100644
--- a/fs/i386/pc/pxe.c
+++ b/fs/i386/pc/pxe.c
@@ -20,6 +20,7 @@
 #include <grub/dl.h>
 #include <grub/fs.h>
 #include <grub/mm.h>
+#include <grub/env.h>
 #include <grub/disk.h>
 #include <grub/file.h>
 #include <grub/misc.h>
@@ -28,16 +29,19 @@
 #include <grub/machine/pxe.h>
 #include <grub/machine/memory.h>
 
 #define SEGMENT(x)	((x) >> 4)
 #define OFFSET(x)	((x) & 0xF)
 #define SEGOFS(x)	((SEGMENT(x) << 16) + OFFSET(x))
 #define LINEAR(x)	(void *) (((x >> 16) <<4) + (x & 0xFFFF))
 
 struct grub_pxenv *grub_pxe_pxenv;
-grub_uint32_t grub_pxe_your_ip;
-grub_uint32_t grub_pxe_server_ip;
-grub_uint32_t grub_pxe_gateway_ip;
 int grub_pxe_blksize = GRUB_PXE_MIN_BLKSIZE;
+struct grub_pxenv_boot_player grub_pxe_bootinfo;
 
 static grub_file_t curr_file = 0;
 
@@ -131,8 +134,8 @@ grub_pxefs_open (struct grub_file *file, const char *name)
       curr_file = 0;
     }
 
-  c.c1.server_ip = grub_pxe_server_ip;
-  c.c1.gateway_ip = grub_pxe_gateway_ip;
+  c.c1.server_ip = grub_pxe_bootinfo.server_ip;
+  c.c1.gateway_ip = grub_pxe_bootinfo.gateway_ip;
   grub_strcpy ((char *)&c.c1.filename[0], name);
   grub_pxe_call (GRUB_PXENV_TFTP_GET_FSIZE, &c.c1);
   if (c.c1.status)
@@ -199,10 +202,10 @@ grub_pxefs_read (grub_file_t file, char *buf, grub_size_t len)
       struct grub_pxenv_tftp_open o;
 
       if (curr_file != 0)
-        grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &o);
+	grub_pxe_call (GRUB_PXENV_TFTP_CLOSE, &o);
 
-      o.server_ip = grub_pxe_server_ip;
-      o.gateway_ip = grub_pxe_gateway_ip;
+      o.server_ip = grub_pxe_bootinfo.server_ip;
+      o.gateway_ip = grub_pxe_bootinfo.gateway_ip;
       grub_strcpy ((char *)&o.filename[0], data->filename);
       o.tftp_port = grub_cpu_to_be16 (GRUB_PXE_TFTP_PORT);
       o.packet_size = data->block_size;
@@ -270,6 +273,36 @@ static struct grub_fs grub_pxefs_fs =
   };
 
 static void
+export_variable (struct grub_pxenv_boot_player *bp)
+{
+  char buf[6 * 3], *p;
+  grub_uint8_t *s;
+  int i;
+
+  p = buf;
+  s = (grub_uint8_t *) &bp->mac_addr;
+  for (i = 0; i < 6; i++)
+    {
+      grub_sprintf (p, "%02x", *(s++));
+      p += 3;
+      *(p - 1) = '-';
+    }
+  *(p - 1) = 0;
+  grub_env_set ("PXE_MAC", buf);
+
+  p = buf;
+  s = (grub_uint8_t *) &bp->your_ip;
+  for (i = 0; i < 4; i++)
+    {
+      grub_sprintf (p, "%d", *(s++));
+      p += grub_strlen (p) + 1;
+      *(p - 1) = '.';
+    }
+  *(p - 1) = 0;
+  grub_env_set ("PXE_IP", buf);
+}
+
+static void
 grub_pxe_detect (void)
 {
   struct grub_pxenv *pxenv;
@@ -288,10 +321,8 @@ grub_pxe_detect (void)
     return;
 
   bp = LINEAR (ci.buffer);
-
-  grub_pxe_your_ip = bp->your_ip;
-  grub_pxe_server_ip = bp->server_ip;
-  grub_pxe_gateway_ip = bp->gateway_ip;
+  export_variable (bp);
+  grub_memcpy (&grub_pxe_bootinfo, bp, sizeof (grub_pxe_bootinfo));
 
   grub_pxe_pxenv = pxenv;
 }
