]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
cmd: net: add 'netdev' command to select a specific network interface
authorLothar Waßmann <LW@KARO-electronics.de>
Wed, 15 Mar 2017 08:09:46 +0000 (09:09 +0100)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 15 Mar 2017 08:09:46 +0000 (09:09 +0100)
cmd/net.c

index b2f3c7b709bc59f7449b86a540faaf78d1cce292..487ea7d01ae9a145071741040576611169f42776 100644 (file)
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -445,3 +445,34 @@ U_BOOT_CMD(
 );
 
 #endif  /* CONFIG_CMD_LINK_LOCAL */
+
+static int do_netdev(cmd_tbl_t *cmdtp, int flag, int argc,
+                       char *const argv[])
+{
+       const char *curdev = getenv("ethact");
+
+       if (argc > 1 || curdev)
+               printf("Current network device ");
+       else
+               printf("No network device selected\n");
+       if (curdev)
+               printf("%s\n", curdev);
+
+       if (argc <= 1)
+               return CMD_RET_SUCCESS;
+
+       setenv("ethact", argv[1]);
+       eth_set_current();
+       curdev = getenv("ethact");
+       if (strcmp(curdev, argv[1]) == 0)
+               printf("set to %s\n", getenv("ethact"));
+       else
+               printf("Could not set net device to '%s'\n", argv[1]);
+
+       return CMD_RET_SUCCESS;
+}
+U_BOOT_CMD(
+       netdev, 2, 0, do_netdev,
+       "select network device",
+       "<device name>"
+       );