summaryrefslogtreecommitdiffstats
path: root/src/hci/commands
diff options
context:
space:
mode:
authorMichael Brown2013-11-04 18:06:21 +0100
committerMichael Brown2013-11-05 18:42:55 +0100
commit506152d46739be0afda75dab480b77adf99e9b14 (patch)
treeb2c2716261c47f44d85e70559233d1678790453c /src/hci/commands
parent[autoboot] Use ifconf() to configure network device (diff)
downloadipxe-506152d46739be0afda75dab480b77adf99e9b14.tar.gz
ipxe-506152d46739be0afda75dab480b77adf99e9b14.tar.xz
ipxe-506152d46739be0afda75dab480b77adf99e9b14.zip
[cmdline] Add "ifconf" command
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci/commands')
-rw-r--r--src/hci/commands/ifmgmt_cmd.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/hci/commands/ifmgmt_cmd.c b/src/hci/commands/ifmgmt_cmd.c
index 771d947f..2fd56ce5 100644
--- a/src/hci/commands/ifmgmt_cmd.c
+++ b/src/hci/commands/ifmgmt_cmd.c
@@ -187,6 +187,61 @@ static int ifstat_exec ( int argc, char **argv ) {
return ifcommon_exec ( argc, argv, &ifstat_cmd );
}
+/** "ifconf" options */
+struct ifconf_options {
+ /** Configurator */
+ struct net_device_configurator *configurator;
+};
+
+/** "ifconf" option list */
+static struct option_descriptor ifconf_opts[] = {
+ OPTION_DESC ( "configurator", 'c', required_argument,
+ struct ifconf_options, configurator,
+ parse_netdev_configurator ),
+};
+
+/**
+ * "ifconf" payload
+ *
+ * @v netdev Network device
+ * @v opts Command options
+ * @ret rc Return status code
+ */
+static int ifconf_payload ( struct net_device *netdev,
+ struct ifconf_options *opts ) {
+ int rc;
+
+ /* Attempt configuration */
+ if ( ( rc = ifconf ( netdev, opts->configurator ) ) != 0 ) {
+
+ /* Close device on failure, to avoid memory exhaustion */
+ netdev_close ( netdev );
+
+ return rc;
+ }
+
+ return 0;
+}
+
+/** "ifconf" command descriptor */
+static struct ifcommon_command_descriptor ifconf_cmd =
+ IFCOMMON_COMMAND_DESC ( struct ifconf_options, ifconf_opts,
+ 0, MAX_ARGUMENTS,
+ "[--configurator <configurator>] "
+ "[<interface>...]",
+ ifconf_payload, 1 );
+
+/**
+ * The "ifconf" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int ifconf_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, &ifconf_cmd );
+}
+
/** Interface management commands */
struct command ifmgmt_commands[] __command = {
{
@@ -201,4 +256,8 @@ struct command ifmgmt_commands[] __command = {
.name = "ifstat",
.exec = ifstat_exec,
},
+ {
+ .name = "ifconf",
+ .exec = ifconf_exec,
+ },
};