* [GITGRUB] Support PXE option and new command pxecfg
@ 2009-10-16 14:45 Bean
2009-10-16 15:26 ` Vladimir 'phcoder' Serbinenko
2009-10-16 18:38 ` Robert Millan
0 siblings, 2 replies; 12+ messages in thread
From: Bean @ 2009-10-16 14:45 UTC (permalink / raw)
To: The development of GRUB 2
Hi,
Extends pxe command:
-i (--info) now shows mac and dhcp options
-e (--export) export a dhcp option as grub variable, for example:
pxe -e 150
Set variable PXE_150 to the value of dhcp option 150, you can then use
command like source to load it:
source ${PXE_150}
New command pxecfg, which allows you to run a command based on current ip/mac:
pxecfg /pxe.txt
Here is an example config file:
pxe {
ip {
192 {
168.2 {
command = "echo ip 192.168.2.*"
}
169 {
command = "echo ip 192.169.*.*"
}
command = "echo ip 192.*.*.*"
}
}
mac {
00-0c-29-1a {
command = "echo mac 00-0c-29-1a-*-*"
}
command = "echo mac *-*-*-*-*-*"
}
}
The config file should be self-explaining, you can use \n to specify
multiple line of commands:
command = "linux /vmlinuz\ninitrd /initrd\nboot"
Source is at http://github.com/bean123/grub/, master branch.
--
Bean
gitgrub home: http://github.com/grub/grub/
my fork page: http://github.com/bean123/grub/
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-16 14:45 [GITGRUB] Support PXE option and new command pxecfg Bean @ 2009-10-16 15:26 ` Vladimir 'phcoder' Serbinenko 2009-10-16 16:13 ` Bean 2009-10-16 18:38 ` Robert Millan 1 sibling, 1 reply; 12+ messages in thread From: Vladimir 'phcoder' Serbinenko @ 2009-10-16 15:26 UTC (permalink / raw) To: The development of GRUB 2 Hello. Could you send this as a patch? Bean wrote: > Hi, > > Extends pxe command: > > -i (--info) now shows mac and dhcp options > -e (--export) export a dhcp option as grub variable, for example: > > pxe -e 150 > > Why can't this be exported unconditionally on pxe system startup? > Set variable PXE_150 to the value of dhcp option 150, you can then use > command like source to load it: > > source ${PXE_150} > > New command pxecfg, which allows you to run a command based on current ip/mac: > > pxecfg /pxe.txt > > What's wrong with standard if? I would prefer to extend "if" if necessary rather than having ad-hoc command for every condition (later is inexpandable) > Here is an example config file: > > pxe { > ip { > 192 { > 168.2 { > command = "echo ip 192.168.2.*" > } > > 169 { > command = "echo ip 192.169.*.*" > } > > command = "echo ip 192.*.*.*" > } > } > > mac { > 00-0c-29-1a { > command = "echo mac 00-0c-29-1a-*-*" > } > > command = "echo mac *-*-*-*-*-*" > } > } > > The config file should be self-explaining, you can use \n to specify > multiple line of commands: > > command = "linux /vmlinuz\ninitrd /initrd\nboot" > > Source is at http://github.com/bean123/grub/, master branch. > > -- Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-16 15:26 ` Vladimir 'phcoder' Serbinenko @ 2009-10-16 16:13 ` Bean 2009-10-16 16:47 ` Vladimir 'phcoder' Serbinenko 0 siblings, 1 reply; 12+ messages in thread From: Bean @ 2009-10-16 16:13 UTC (permalink / raw) To: The development of GRUB 2 On Fri, Oct 16, 2009 at 11:26 PM, Vladimir 'phcoder' Serbinenko <phcoder@gmail.com> wrote: > Hello. Could you send this as a patch? Hi, This function depends on my menu branch, it can't be applied to svn head, so patch file is not very useful. > Bean wrote: >> Hi, >> >> Extends pxe command: >> >> -i (--info) now shows mac and dhcp options >> -e (--export) export a dhcp option as grub variable, for example: >> >> pxe -e 150 >> >> > Why can't this be exported unconditionally on pxe system startup? Right, perhaps we can export PXE_IP, PXE_MAC and PXE_150 by default, but this function is also useful in case we need to use other string option. >> Set variable PXE_150 to the value of dhcp option 150, you can then use >> command like source to load it: >> >> source ${PXE_150} >> >> New command pxecfg, which allows you to run a command based on current ip/mac: >> >> pxecfg /pxe.txt >> >> > What's wrong with standard if? I would prefer to extend "if" if > necessary rather than having ad-hoc command for every condition (later > is inexpandable) IIRC the test command can't compare partial string. >> Here is an example config file: >> >> pxe { >> ip { >> 192 { >> 168.2 { >> command = "echo ip 192.168.2.*" >> } >> >> 169 { >> command = "echo ip 192.169.*.*" >> } >> >> command = "echo ip 192.*.*.*" >> } >> } >> >> mac { >> 00-0c-29-1a { >> command = "echo mac 00-0c-29-1a-*-*" >> } >> >> command = "echo mac *-*-*-*-*-*" >> } >> } >> >> The config file should be self-explaining, you can use \n to specify >> multiple line of commands: >> >> command = "linux /vmlinuz\ninitrd /initrd\nboot" >> >> Source is at http://github.com/bean123/grub/, master branch. >> >> > > > -- > Regards > Vladimir 'phcoder' Serbinenko > Personal git repository: http://repo.or.cz/w/grub2/phcoder.git > > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > -- Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-16 16:13 ` Bean @ 2009-10-16 16:47 ` Vladimir 'phcoder' Serbinenko 2009-10-16 17:20 ` Bean 0 siblings, 1 reply; 12+ messages in thread From: Vladimir 'phcoder' Serbinenko @ 2009-10-16 16:47 UTC (permalink / raw) To: The development of GRUB 2 Bean wrote: > On Fri, Oct 16, 2009 at 11:26 PM, Vladimir 'phcoder' Serbinenko > <phcoder@gmail.com> wrote: > >> Hello. Could you send this as a patch? >> > > Hi, > > This function depends on my menu branch, it can't be applied to svn > head, so patch file is not very useful. > > Could you explain me why PXE depends on menu? >> Bean wrote: >> >>> Hi, >>> >>> Extends pxe command: >>> >>> -i (--info) now shows mac and dhcp options >>> -e (--export) export a dhcp option as grub variable, for example: >>> >>> pxe -e 150 >>> >>> >>> >> Why can't this be exported unconditionally on pxe system startup? >> > > Right, perhaps we can export PXE_IP, PXE_MAC and PXE_150 by default, > but this function is also useful in case we need to use other string > option. > > Is it possible just enumerate all available options and export them to PXE.<option name> similarly to how we treat FreeBSD environment >>> Set variable PXE_150 to the value of dhcp option 150, you can then use >>> command like source to load it: >>> >>> source ${PXE_150} >>> >>> New command pxecfg, which allows you to run a command based on current ip/mac: >>> >>> pxecfg /pxe.txt >>> >>> >>> >> What's wrong with standard if? I would prefer to extend "if" if >> necessary rather than having ad-hoc command for every condition (later >> is inexpandable) >> > > IIRC the test command can't compare partial string. > > We need an improvement to test command then. What about having test <string> -regexp <regexp> -- Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-16 16:47 ` Vladimir 'phcoder' Serbinenko @ 2009-10-16 17:20 ` Bean 2009-10-16 17:30 ` Vladimir 'phcoder' Serbinenko 0 siblings, 1 reply; 12+ messages in thread From: Bean @ 2009-10-16 17:20 UTC (permalink / raw) To: The development of GRUB 2 On Sat, Oct 17, 2009 at 12:47 AM, Vladimir 'phcoder' Serbinenko <phcoder@gmail.com> wrote: > Bean wrote: >> On Fri, Oct 16, 2009 at 11:26 PM, Vladimir 'phcoder' Serbinenko >> <phcoder@gmail.com> wrote: >> >>> Hello. Could you send this as a patch? >>> >> >> Hi, >> >> This function depends on my menu branch, it can't be applied to svn >> head, so patch file is not very useful. >> >> > Could you explain me why PXE depends on menu? Hi, The pxecfg command use the the same config file parser as menu. >>> Bean wrote: >>> >>>> Hi, >>>> >>>> Extends pxe command: >>>> >>>> -i (--info) now shows mac and dhcp options >>>> -e (--export) export a dhcp option as grub variable, for example: >>>> >>>> pxe -e 150 >>>> >>>> >>>> >>> Why can't this be exported unconditionally on pxe system startup? >>> >> >> Right, perhaps we can export PXE_IP, PXE_MAC and PXE_150 by default, >> but this function is also useful in case we need to use other string >> option. >> >> > Is it possible just enumerate all available options and export them to > PXE.<option name> similarly to how we treat FreeBSD environment Most DHCP option are binary format, only string option can be exported as variable. >>>> Set variable PXE_150 to the value of dhcp option 150, you can then use >>>> command like source to load it: >>>> >>>> source ${PXE_150} >>>> >>>> New command pxecfg, which allows you to run a command based on current ip/mac: >>>> >>>> pxecfg /pxe.txt >>>> >>>> >>>> >>> What's wrong with standard if? I would prefer to extend "if" if >>> necessary rather than having ad-hoc command for every condition (later >>> is inexpandable) >>> >> >> IIRC the test command can't compare partial string. >> >> > We need an improvement to test command then. What about having > test <string> -regexp <regexp> I think that's a little overkill, regular expression parser can be quite complex. -- Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-16 17:20 ` Bean @ 2009-10-16 17:30 ` Vladimir 'phcoder' Serbinenko 2009-10-16 21:05 ` Felix Zielcke 2009-10-16 21:13 ` Robert Millan 0 siblings, 2 replies; 12+ messages in thread From: Vladimir 'phcoder' Serbinenko @ 2009-10-16 17:30 UTC (permalink / raw) To: The development of GRUB 2 Bean wrote: > On Sat, Oct 17, 2009 at 12:47 AM, Vladimir 'phcoder' Serbinenko > <phcoder@gmail.com> wrote: > >> Bean wrote: >> >>> On Fri, Oct 16, 2009 at 11:26 PM, Vladimir 'phcoder' Serbinenko >>> <phcoder@gmail.com> wrote: >>> >>> >>>> Hello. Could you send this as a patch? >>>> >>>> >>> Hi, >>> >>> This function depends on my menu branch, it can't be applied to svn >>> head, so patch file is not very useful. >>> >>> >>> >> Could you explain me why PXE depends on menu? >> > > Hi, > > The pxecfg command use the the same config file parser as menu. > Could you perhaps send only the part without pxecfg then? > >>>> Bean wrote: >>>> >>>> >>>>> Hi, >>>>> >>>>> Extends pxe command: >>>>> >>>>> -i (--info) now shows mac and dhcp options >>>>> -e (--export) export a dhcp option as grub variable, for example: >>>>> >>>>> pxe -e 150 >>>>> >>>>> >>>>> >>>>> >>>> Why can't this be exported unconditionally on pxe system startup? >>>> >>>> >>> Right, perhaps we can export PXE_IP, PXE_MAC and PXE_150 by default, >>> but this function is also useful in case we need to use other string >>> option. >>> >>> >>> >> Is it possible just enumerate all available options and export them to >> PXE.<option name> similarly to how we treat FreeBSD environment >> > > Most DHCP option are binary format, only string option can be exported > as variable. > > We can export these ones as hex >>>>> Set variable PXE_150 to the value of dhcp option 150, you can then use >>>>> command like source to load it: >>>>> >>>>> source ${PXE_150} >>>>> >>>>> New command pxecfg, which allows you to run a command based on current ip/mac: >>>>> >>>>> pxecfg /pxe.txt >>>>> >>>>> >>>>> >>>>> >>>> What's wrong with standard if? I would prefer to extend "if" if >>>> necessary rather than having ad-hoc command for every condition (later >>>> is inexpandable) >>>> >>>> >>> IIRC the test command can't compare partial string. >>> >>> >>> >> We need an improvement to test command then. What about having >> test <string> -regexp <regexp> >> > > I think that's a little overkill, regular expression parser can be > quite complex. > > We don't need to reinvent the wheel. We can import regexp parser from GNU sed -- Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-16 17:30 ` Vladimir 'phcoder' Serbinenko @ 2009-10-16 21:05 ` Felix Zielcke 2009-10-16 21:13 ` Robert Millan 1 sibling, 0 replies; 12+ messages in thread From: Felix Zielcke @ 2009-10-16 21:05 UTC (permalink / raw) To: The development of GRUB 2 Am Freitag, den 16.10.2009, 19:30 +0200 schrieb Vladimir 'phcoder' Serbinenko: > >> We need an improvement to test command then. What about having > >> test <string> -regexp <regexp> > >> > > > > I think that's a little overkill, regular expression parser can be > > quite complex. > > > > > We don't need to reinvent the wheel. We can import regexp parser from > GNU sed Would it be really that useful to have full regexp support inside GRUB? I can't currently imagine a case where I'd use that. Shouldn't be just normal shell wildcards (? and *) be enough? -- Felix Zielcke Proud Debian Maintainer and GNU GRUB developer ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-16 17:30 ` Vladimir 'phcoder' Serbinenko 2009-10-16 21:05 ` Felix Zielcke @ 2009-10-16 21:13 ` Robert Millan 2009-10-19 9:02 ` Bean 1 sibling, 1 reply; 12+ messages in thread From: Robert Millan @ 2009-10-16 21:13 UTC (permalink / raw) To: The development of GRUB 2 On Fri, Oct 16, 2009 at 07:30:03PM +0200, Vladimir 'phcoder' Serbinenko wrote: > We don't need to reinvent the wheel. We can import regexp parser from > GNU sed I think there's one in GNU libc too (see regcomp()). -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-16 21:13 ` Robert Millan @ 2009-10-19 9:02 ` Bean 2009-10-20 10:21 ` Robert Millan 0 siblings, 1 reply; 12+ messages in thread From: Bean @ 2009-10-19 9:02 UTC (permalink / raw) To: The development of GRUB 2 Hi, Update: Now pxe fs exports PXE_MAC and PXE_IP on startup. pxecfg can support multiple files, and the syntax is changed a bit: ip { 192 { 168.2 { command = "echo ip 192.168.2.*" } 169 { command = "echo ip 192.169.*.*" } command = "echo ip 192.*.*.*" } } mac { 00-0c-29-1a { command = "echo mac 00-0c-29-1a-*-*" } command = "echo mac *-*-*-*-*-*" } The top level pxe node is removed, and you can have multiple ip or mac section. -- Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-19 9:02 ` Bean @ 2009-10-20 10:21 ` Robert Millan 2009-10-20 10:51 ` Bean 0 siblings, 1 reply; 12+ messages in thread From: Robert Millan @ 2009-10-20 10:21 UTC (permalink / raw) To: The development of GRUB 2 On Mon, Oct 19, 2009 at 05:02:13PM +0800, Bean wrote: > Hi, > > Update: > > Now pxe fs exports PXE_MAC and PXE_IP on startup. Hi Bean, Are you going to provide a patch? -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-20 10:21 ` Robert Millan @ 2009-10-20 10:51 ` Bean 0 siblings, 0 replies; 12+ messages in thread From: Bean @ 2009-10-20 10:51 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 437 bytes --] On Tue, Oct 20, 2009 at 6:21 PM, Robert Millan <rmh@aybabtu.com> wrote: > On Mon, Oct 19, 2009 at 05:02:13PM +0800, Bean wrote: >> Hi, >> >> Update: >> >> Now pxe fs exports PXE_MAC and PXE_IP on startup. > > Hi Bean, > > Are you going to provide a patch? Hi, Here is it, the command pxecfg is skipped as it depends on my menu system. -- Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/ [-- Attachment #2: pxe.diff --] [-- Type: application/octet-stream, Size: 6143 bytes --] 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; } ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [GITGRUB] Support PXE option and new command pxecfg 2009-10-16 14:45 [GITGRUB] Support PXE option and new command pxecfg Bean 2009-10-16 15:26 ` Vladimir 'phcoder' Serbinenko @ 2009-10-16 18:38 ` Robert Millan 1 sibling, 0 replies; 12+ messages in thread From: Robert Millan @ 2009-10-16 18:38 UTC (permalink / raw) To: The development of GRUB 2 On Fri, Oct 16, 2009 at 10:45:08PM +0800, Bean wrote: > > Source is at http://github.com/bean123/grub/, master branch. Please could you attach it? -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-10-20 10:51 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-10-16 14:45 [GITGRUB] Support PXE option and new command pxecfg Bean 2009-10-16 15:26 ` Vladimir 'phcoder' Serbinenko 2009-10-16 16:13 ` Bean 2009-10-16 16:47 ` Vladimir 'phcoder' Serbinenko 2009-10-16 17:20 ` Bean 2009-10-16 17:30 ` Vladimir 'phcoder' Serbinenko 2009-10-16 21:05 ` Felix Zielcke 2009-10-16 21:13 ` Robert Millan 2009-10-19 9:02 ` Bean 2009-10-20 10:21 ` Robert Millan 2009-10-20 10:51 ` Bean 2009-10-16 18:38 ` Robert Millan
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.