diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index 098abaa76..8e136edc7 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -296,7 +296,7 @@ static const struct cmdmap_s g_cmdmap[] = CMD_MAP("ifconfig", cmd_ifconfig, 1, 12, "[interface [mtu ]|[address_family] [[add|del] |dhcp]]" "[dr|gw|gateway ] [netmask |prefixlen ] " - "[dns ] [hw ]"), + "[dns ] [hw ] [up|down]"), # endif # if defined(CONFIG_NET_VLAN) && !defined(CONFIG_NSH_DISABLE_VCONFIG) CMD_MAP("vconfig", cmd_vconfig, 3, 5, diff --git a/nshlib/nsh_netcmds.c b/nshlib/nsh_netcmds.c index defcb717f..c281650d2 100644 --- a/nshlib/nsh_netcmds.c +++ b/nshlib/nsh_netcmds.c @@ -584,6 +584,8 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) #endif bool missingarg = true; bool badarg = false; + bool ifup = false; + bool ifdown = false; #ifdef CONFIG_NET_ARP arp_cfg_e arpflag = ARP_DEFAULT; #endif @@ -766,6 +768,14 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) arpflag = ARP_DISABLE; } #endif + else if (!strcmp(tmp, "up")) + { + ifup = true; + } + else if (!strcmp(tmp, "down")) + { + ifdown = true; + } else if (hostip == NULL && i <= 4) { /* Let first non-option be host ip, to support inet/inet6 @@ -1079,6 +1089,17 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) } #endif + /* Bring the interface up or down once everything else is in place. */ + + if (ifup) + { + netlib_ifup(ifname); + } + else if (ifdown) + { + netlib_ifdown(ifname); + } + #if !defined(CONFIG_NET_IPv4) && !defined(CONFIG_NET_IPv6) UNUSED(hostip); UNUSED(mask);