Support PXE option and new command pxecfg
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.
Signature · 4 lines
Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/
Hello. Could you send this as a patch?
Quoted 10 lines · Bean
Hi,
Extends pxe command:
(quoted diff) +0
-2-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?
Quoted 10 lines
Set variable
PXE_150to 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)
Quoted 34 lines
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.
Signature · 3 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 1 line · Vladimir 'phcoder' Serbinenko
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.
Quoted 5 lines
Quoted 4 lines · Bean
Hi,
Extends pxe command:
Quoted 7 lines
Quoted 6 lines
(quoted diff) +0
-2-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.
Quoted 5 lines
Quoted 5 lines
Set variable
PXE_150to the value of dhcp option 150, you can then use command like source to load it:source ${PXE_150}
Quoted 8 lines
Quoted 5 lines
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.
Quoted 48 lines
Quoted 26 lines
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 *-*-*-*-*-*"
}
}Quoted 8 lines
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
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 4 lines
Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/
Quoted 12 lines · Bean
Quoted 2 lines · Vladimir 'phcoder' Serbinenko
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?
Quoted 16 lines
Quoted 6 lines
Quoted 4 lines · Bean
Hi,
Extends pxe command:
Quoted 9 lines
Quoted 7 lines
(quoted diff) +0
-2-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?
Quoted 5 lines
Right, perhaps we can export
PXE_IP,PXE_MACandPXE_150by 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
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Set variable
PXE_150to 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
Quoted 8 lines
Quoted 4 lines
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>
Signature · 3 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 7 lines · Vladimir 'phcoder' Serbinenko
Quoted 6 lines · Bean
Quoted 2 lines · Vladimir 'phcoder' Serbinenko
Hello. Could you send this as a patch?
Quoted 7 lines
Quoted 6 lines
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.
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 11 lines · Bean
Hi,
Extends pxe command:
(quoted diff) +0
-2-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?
Quoted 7 lines
Quoted 5 lines
Right, perhaps we can export
PXE_IP,PXE_MACandPXE_150by 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.
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 11 lines
Set variable
PXE_150to 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)
Quoted 5 lines
Quoted 3 lines
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.
Signature · 4 lines
Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/
Quoted 19 lines · Bean
Quoted 16 lines · Vladimir 'phcoder' Serbinenko
Quoted 14 lines · Bean
Quoted 3 lines · Vladimir 'phcoder' Serbinenko
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.
Quoted 7 lines
Quoted 2 lines
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?
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 11 lines
Quoted 7 lines · Bean
Hi,
Extends pxe command:
(quoted diff) +0
-2-i (--info) now shows mac and dhcp options -e (--export) export a dhcp option as grub variable, for example:Quoted 8 lines
Quoted 5 lines
pxe -e 150
Why can't this be exported unconditionally on pxe system startup?
Right, perhaps we can export
PXE_IP,PXE_MACandPXE_150by default, but this function is also useful in case we need to use other string option.
Quoted 8 lines
Quoted 3 lines
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
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 7 lines
Quoted 7 lines
Set variable
PXE_150to 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:
Quoted 10 lines
Quoted 5 lines
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.
Quoted 8 lines
Quoted 3 lines
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
Signature · 3 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 2 lines · Bean
Source is at http://github.com/bean123/grub/, master branch.
Please could you attach it?
Signature · 5 lines
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."
Am Freitag, den 16.10.2009, 19:30 +0200 schrieb Vladimir 'phcoder' Serbinenko:
Quoted 10 lines
Quoted 8 lines
Quoted 3 lines
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?
Signature · 2 lines
Felix Zielcke Proud Debian Maintainer and GNU GRUB developer
Quoted 2 lines · Vladimir 'phcoder' Serbinenko
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()).
Signature · 5 lines
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."
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.
Signature · 4 lines
Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/
Quoted 5 lines · Bean
Hi,
Update:
Now pxe fs exports
PXE_MACandPXE_IPon startup.
Hi Bean,
Are you going to provide a patch?
Signature · 5 lines
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."
Quoted 10 lines · Robert Millan
Quoted 5 lines · Bean
Hi,
Update:
Now pxe fs exports
PXE_MACandPXE_IPon 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.
Signature · 4 lines
Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/
commands/i386/pc/pxecmd.c +72 -7
@@ -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); }
fs/i386/pc/pxe.c +39 -12
95 lines not on this page · raw message