ifconfig: Support ifconfig interface and update arg limit

From comment in cmd_ifconfig, it seems that we support `ifconfig [interface]`, but actually not considering the interface param now. After this commit, we only print the information of interface specified in param, just like linux.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
Zhe Weng 2022-12-29 15:35:26 +08:00 committed by Xiang Xiao
parent a275567ad0
commit 93b4dc2692
3 changed files with 10 additions and 4 deletions

View File

@ -670,7 +670,7 @@ system image.
Dump data in hexadecimal format from a file or character device.
- `ifconfig [nic_name [address_family] [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>] [netmask <net-mask>] [prefixlen <len>] [dns <dns-address>] [hw <hw-mac>]`
- `ifconfig [nic_name [address_family] [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>] [netmask <net-mask>|prefixlen <len>] [dns <dns-address>] [hw <hw-mac>]`
Show the current configuration of the network, for example:

View File

@ -244,9 +244,10 @@ static const struct cmdmap_s g_cmdmap[] =
#ifdef CONFIG_NET
# ifndef CONFIG_NSH_DISABLE_IFCONFIG
{ "ifconfig", cmd_ifconfig, 1, 11,
"[interface [<ip-address>|dhcp]] [dr|gw|gateway <dr-address>] "
"[netmask <net-mask>] [dns <dns-address>] [hw <hw-mac>]" },
{ "ifconfig", cmd_ifconfig, 1, 12,
"[interface [address_family] [<ip-address>|dhcp]] "
"[dr|gw|gateway <dr-address>] [netmask <net-mask>|prefixlen <len>] "
"[dns <dns-address>] [hw <hw-mac>]" },
# endif
# ifndef CONFIG_NSH_DISABLE_IFUPDOWN
{ "ifdown", cmd_ifdown, 2, 2, "<interface>" },

View File

@ -595,6 +595,11 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
if (argc <= 2)
{
if (argc == 2)
{
return ifconfig_callback(vtbl, argv[1]);
}
ret = nsh_foreach_netdev(ifconfig_callback, vtbl, "ifconfig");
if (ret < 0)
{