Browse Source

[cmdline] Add "ifconf" command

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
506152d467
1 changed files with 59 additions and 0 deletions
  1. 59
    0
      src/hci/commands/ifmgmt_cmd.c

+ 59
- 0
src/hci/commands/ifmgmt_cmd.c View File

@@ -187,6 +187,61 @@ static int ifstat_exec ( int argc, char **argv ) {
187 187
 	return ifcommon_exec ( argc, argv, &ifstat_cmd );
188 188
 }
189 189
 
190
+/** "ifconf" options */
191
+struct ifconf_options {
192
+	/** Configurator */
193
+	struct net_device_configurator *configurator;
194
+};
195
+
196
+/** "ifconf" option list */
197
+static struct option_descriptor ifconf_opts[] = {
198
+	OPTION_DESC ( "configurator", 'c', required_argument,
199
+		      struct ifconf_options, configurator,
200
+		      parse_netdev_configurator ),
201
+};
202
+
203
+/**
204
+ * "ifconf" payload
205
+ *
206
+ * @v netdev		Network device
207
+ * @v opts		Command options
208
+ * @ret rc		Return status code
209
+ */
210
+static int ifconf_payload ( struct net_device *netdev,
211
+			    struct ifconf_options *opts ) {
212
+	int rc;
213
+
214
+	/* Attempt configuration */
215
+	if ( ( rc = ifconf ( netdev, opts->configurator ) ) != 0 ) {
216
+
217
+		/* Close device on failure, to avoid memory exhaustion */
218
+		netdev_close ( netdev );
219
+
220
+		return rc;
221
+	}
222
+
223
+	return 0;
224
+}
225
+
226
+/** "ifconf" command descriptor */
227
+static struct ifcommon_command_descriptor ifconf_cmd =
228
+	IFCOMMON_COMMAND_DESC ( struct ifconf_options, ifconf_opts,
229
+				0, MAX_ARGUMENTS,
230
+				"[--configurator <configurator>] "
231
+				"[<interface>...]",
232
+				ifconf_payload, 1 );
233
+
234
+/**
235
+ * The "ifconf" command
236
+ *
237
+ * @v argc		Argument count
238
+ * @v argv		Argument list
239
+ * @ret rc		Return status code
240
+ */
241
+static int ifconf_exec ( int argc, char **argv ) {
242
+	return ifcommon_exec ( argc, argv, &ifconf_cmd );
243
+}
244
+
190 245
 /** Interface management commands */
191 246
 struct command ifmgmt_commands[] __command = {
192 247
 	{
@@ -201,4 +256,8 @@ struct command ifmgmt_commands[] __command = {
201 256
 		.name = "ifstat",
202 257
 		.exec = ifstat_exec,
203 258
 	},
259
+	{
260
+		.name = "ifconf",
261
+		.exec = ifconf_exec,
262
+	},
204 263
 };

Loading…
Cancel
Save