1 /* pxe.c - command to control the pxe driver */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2008 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #include <grub/normal.h>
24 #include <grub/misc.h>
25 #include <grub/machine/pxe.h>
27 static const struct grub_arg_option options
[] =
29 {"info", 'i', 0, "show PXE information.", 0, 0},
30 {"bsize", 'b', 0, "set PXE block size", 0, ARG_TYPE_INT
},
31 {"unload", 'u', 0, "unload PXE stack.", 0, 0},
36 print_ip (grub_uint32_t ip
)
40 for (i
= 0; i
< 3; i
++)
42 grub_printf ("%d.", ip
& 0xFF);
45 grub_printf ("%d", ip
);
49 grub_cmd_pxe (struct grub_arg_list
*state
, int argc
__attribute__ ((unused
)),
50 char **args
__attribute__ ((unused
)))
53 return grub_error (GRUB_ERR_FILE_NOT_FOUND
, "no pxe environment");
59 size
= grub_strtoul (state
[1].arg
, 0, 0);
60 if (size
< GRUB_PXE_MIN_BLKSIZE
)
61 size
= GRUB_PXE_MIN_BLKSIZE
;
62 else if (size
> GRUB_PXE_MAX_BLKSIZE
)
63 size
= GRUB_PXE_MAX_BLKSIZE
;
65 grub_pxe_blksize
= size
;
70 grub_printf ("blksize : %d\n", grub_pxe_blksize
);
71 grub_printf ("client ip : ");
72 print_ip (grub_pxe_your_ip
);
73 grub_printf ("\nserver ip : ");
74 print_ip (grub_pxe_server_ip
);
75 grub_printf ("\ngateway ip : ");
76 print_ip (grub_pxe_gateway_ip
);
88 (void) mod
; /* To stop warning. */
89 grub_register_command ("pxe", grub_cmd_pxe
, GRUB_COMMAND_FLAG_BOTH
,
91 "Command to control the PXE device.", options
);
96 grub_unregister_command ("pxe");