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 4c0bd143e nshlib/ifconfig: Let "dns" option depends on 
`CONFIG_NETDB_DNSCLIENT`
4c0bd143e is described below

commit 4c0bd143ebad529cd32f2911424d765cc55f095c
Author: Zhe Weng <weng...@xiaomi.com>
AuthorDate: Fri Dec 29 17:14:42 2023 +0800

    nshlib/ifconfig: Let "dns" option depends on `CONFIG_NETDB_DNSCLIENT`
    
    "dns" option of `ifconfig` can work just with `CONFIG_NETDB_DNSCLIENT`,
    no need to depend on `CONFIG_NETINIT_DNS` or `CONFIG_NETINIT_DHCPC`.
    
    Signed-off-by: Zhe Weng <weng...@xiaomi.com>
---
 nshlib/nsh_netcmds.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/nshlib/nsh_netcmds.c b/nshlib/nsh_netcmds.c
index 7c234dff9..5f6c03201 100644
--- a/nshlib/nsh_netcmds.c
+++ b/nshlib/nsh_netcmds.c
@@ -90,7 +90,7 @@
 #  endif
 #endif
 
-#if defined(CONFIG_NETINIT_DHCPC) || defined(CONFIG_NETINIT_DNS)
+#ifdef CONFIG_NETINIT_DHCPC
 #  include "netutils/dhcpc.h"
 #endif
 
@@ -569,7 +569,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR 
char **argv)
 #ifdef HAVE_HWADDR
   FAR char *hw = NULL;
 #endif
-#if defined(CONFIG_NETINIT_DHCPC) || defined(CONFIG_NETINIT_DNS)
+#ifdef CONFIG_NETDB_DNSCLIENT
   FAR char *dns = NULL;
 #endif
 #if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
@@ -705,7 +705,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR 
char **argv)
                 }
 #endif
 
-#if defined(CONFIG_NETINIT_DHCPC) || defined(CONFIG_NETINIT_DNS)
+#ifdef CONFIG_NETDB_DNSCLIENT
               else if (!strcmp(tmp, "dns"))
                 {
                   if (argc - 1 >= i + 1)
@@ -994,7 +994,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, FAR 
char **argv)
 
   UNUSED(ifname); /* Not used in all configurations */
 
-#if defined(CONFIG_NETINIT_DHCPC) || defined(CONFIG_NETINIT_DNS)
+#ifdef CONFIG_NETDB_DNSCLIENT
 #ifdef CONFIG_NET_IPv6
 #ifdef CONFIG_NET_IPv4
   if (inet6)
@@ -1039,7 +1039,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, 
FAR char **argv)
       netlib_set_ipv4dnsaddr(&addr);
     }
 #endif /* CONFIG_NET_IPv4 */
-#endif /* CONFIG_NETINIT_DHCPC || CONFIG_NETINIT_DNS */
+#endif /* CONFIG_NETDB_DNSCLIENT */
 
 #if defined(CONFIG_NETINIT_DHCPC)
   /* Get the MAC address of the NIC */
@@ -1074,10 +1074,12 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, 
FAR char **argv)
               netlib_set_dripv4addr("eth0", &ds.default_router);
             }
 
+#ifdef CONFIG_NETDB_DNSCLIENT
           if (ds.dnsaddr.s_addr != 0)
             {
               netlib_set_ipv4dnsaddr(&ds.dnsaddr);
             }
+#endif
 
           dhcpc_close(handle);
         }

Reply via email to