aboutsummaryrefslogtreecommitdiff
path: root/src/hci/commands/ifmgmt_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hci/commands/ifmgmt_cmd.c')
-rw-r--r--src/hci/commands/ifmgmt_cmd.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/hci/commands/ifmgmt_cmd.c b/src/hci/commands/ifmgmt_cmd.c
index 2e976d3..591cb3d 100644
--- a/src/hci/commands/ifmgmt_cmd.c
+++ b/src/hci/commands/ifmgmt_cmd.c
@@ -250,6 +250,58 @@ int ifconf_exec ( int argc, char **argv ) {
return ifcommon_exec ( argc, argv, &ifconf_cmd );
}
+/** "iflinkwait" option list */
+struct iflinkwait_options {
+ /** Link timeout */
+ unsigned long timeout;
+};
+
+/** "iflinkwait" option list */
+static struct option_descriptor iflinkwait_opts[] = {
+ OPTION_DESC ( "timeout", 't', required_argument,
+ struct iflinkwait_options, timeout, parse_timeout ),
+};
+
+/**
+ * "iflinkwait" payload
+ *
+ * @v netdev Network device
+ * @v opts Command options
+ * @ret rc Return status code
+ */
+static int iflinkwait_payload ( struct net_device *netdev,
+ struct iflinkwait_options *opts ) {
+ int rc;
+
+ /* Wait for link-up */
+ if ( ( rc = iflinkwait ( netdev, opts->timeout, 1 ) ) != 0 ) {
+
+ /* Close device on failure, to avoid memory exhaustion */
+ netdev_close ( netdev );
+
+ return rc;
+ }
+
+ return 0;
+}
+
+/** "iflinkwait" command descriptor */
+static struct ifcommon_command_descriptor iflinkwait_cmd =
+ IFCOMMON_COMMAND_DESC ( struct iflinkwait_options, iflinkwait_opts,
+ 0, MAX_ARGUMENTS, "[<interface>...]",
+ iflinkwait_payload, 1 );
+
+/**
+ * The "iflinkwait" command
+ *
+ * @v argc Argument count
+ * @v argv Argument list
+ * @ret rc Return status code
+ */
+static int iflinkwait_exec ( int argc, char **argv ) {
+ return ifcommon_exec ( argc, argv, &iflinkwait_cmd );
+}
+
/** Interface management commands */
struct command ifmgmt_commands[] __command = {
{
@@ -268,4 +320,8 @@ struct command ifmgmt_commands[] __command = {
.name = "ifconf",
.exec = ifconf_exec,
},
+ {
+ .name = "iflinkwait",
+ .exec = iflinkwait_exec,
+ },
};