This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 93b4dc269 ifconfig: Support `ifconfig interface` and update arg limit
93b4dc269 is described below

commit 93b4dc26928ea2827da01ca2a820d6ce46c67181
Author: Zhe Weng <weng...@xiaomi.com>
AuthorDate: Thu Dec 29 15:35:26 2022 +0800

    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 <weng...@xiaomi.com>
---
 nshlib/README.md     | 2 +-
 nshlib/nsh_command.c | 7 ++++---
 nshlib/nsh_netcmds.c | 5 +++++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/nshlib/README.md b/nshlib/README.md
index b95aeefe4..975df7ea1 100644
--- a/nshlib/README.md
+++ b/nshlib/README.md
@@ -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:
 
diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c
index ba8bf74f0..28009f49b 100644
--- a/nshlib/nsh_command.c
+++ b/nshlib/nsh_command.c
@@ -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>" },
diff --git a/nshlib/nsh_netcmds.c b/nshlib/nsh_netcmds.c
index ca7655b90..5d0810e9d 100644
--- a/nshlib/nsh_netcmds.c
+++ b/nshlib/nsh_netcmds.c
@@ -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)
         {

Reply via email to