]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[autoboot] Add "netboot" command
authorMichael Brown <mcb30@ipxe.org>
Sat, 20 Nov 2010 17:20:03 +0000 (17:20 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sat, 20 Nov 2010 17:20:03 +0000 (17:20 +0000)
Originally-implemented-by: michael-dev@fami-braun.de
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/hci/commands/autoboot_cmd.c
src/include/usr/autoboot.h
src/usr/autoboot.c

index 51ba6f1fdfc8b5ba4581c72078263651330c4dbf..17bd6bcfcdd45a53f7ed450139bea2c194d765b2 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <ipxe/command.h>
+#include <ipxe/netdevice.h>
 #include <usr/autoboot.h>
 
 FILE_LICENCE ( GPL2_OR_LATER );
@@ -21,7 +22,39 @@ static int autoboot_exec ( int argc, char **argv ) {
        return 1;
 }
 
-struct command autoboot_command __command = {
-       .name = "autoboot",
-       .exec = autoboot_exec,
+static int netboot_exec ( int argc, char **argv ) {
+       const char *netdev_name;
+       struct net_device *netdev;
+
+       if ( argc != 2 ) {
+               printf ( "Usage:\n"
+                        "  %s <interface>\n"
+                        "\n"
+                        "Attempts to boot the system from <interface>\n",
+                        argv[0] );
+               return 1;
+       }
+       netdev_name = argv[1];
+
+       netdev = find_netdev ( netdev_name );
+       if ( ! netdev ) {
+               printf ( "%s: no such interface\n", netdev_name );
+               return 1;
+       }
+
+       netboot ( netdev );
+
+       /* Can never return success by definition */
+       return 1;
+}
+
+struct command autoboot_commands[] __command = {
+       {
+               .name = "autoboot",
+               .exec = autoboot_exec,
+       },
+       {
+               .name = "netboot",
+               .exec = netboot_exec,
+       },
 };
index 81b686b546af3f9f1e30c8f38e232f1e9083c780..46e3b48164070217480dfaa93b2814532efc9795 100644 (file)
@@ -14,6 +14,7 @@ struct net_device;
 
 extern int shutdown_exit_flags;
 
+extern int netboot ( struct net_device *netdev );
 extern void autoboot ( void );
 extern int boot_next_server_and_filename ( struct in_addr next_server,
                                           const char *filename );
index 4e8db60e2e50568f85369c17b67dc5aa7094dd18..d87e36270380ef786a974138e7a89918a6041a80 100644 (file)
@@ -220,7 +220,7 @@ int boot_root_path ( const char *root_path ) {
  * @v netdev           Network device
  * @ret rc             Return status code
  */
-static int netboot ( struct net_device *netdev ) {
+int netboot ( struct net_device *netdev ) {
        struct setting vendor_class_id_setting
                = { .tag = DHCP_VENDOR_CLASS_ID };
        struct setting pxe_discovery_control_setting