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

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

commit c094580ea97b3f49ea2848e19b1fdc1a1a018027
Author: wangchen <[email protected]>
AuthorDate: Fri Sep 1 18:59:22 2023 +0800

    netutils/netlib: add netlib_clear_dnsaddr().
    
    Add a helper that drops every configured DNS server and restores the
    build-time default by calling dns_default_nameserver().  It is built
    with CONFIG_NETDB_DNSCLIENT, in both Make and CMake.
    
    Signed-off-by: wangchen <[email protected]>
    Assisted-by: Kiro:claude-opus-4
---
 include/netutils/netlib.h             |  4 +++
 netutils/netlib/CMakeLists.txt        |  4 +++
 netutils/netlib/Makefile              |  4 +++
 netutils/netlib/netlib_cleardnsaddr.c | 56 +++++++++++++++++++++++++++++++++++
 4 files changed, 68 insertions(+)

diff --git a/include/netutils/netlib.h b/include/netutils/netlib.h
index d99bae3a3..57491645e 100644
--- a/include/netutils/netlib.h
+++ b/include/netutils/netlib.h
@@ -562,6 +562,10 @@ int netlib_del_ipv6dnsaddr(FAR const struct in6_addr 
*inaddr);
 int netlib_del_ipv6dnsaddr_by_index(int index);
 #endif
 
+#ifdef CONFIG_NETDB_DNSCLIENT
+void netlib_clear_dnsaddr(void);
+#endif
+
 int netlib_set_mtu(FAR const char *ifname, int mtu);
 
 #if defined(CONFIG_NETDEV_STATISTICS)
diff --git a/netutils/netlib/CMakeLists.txt b/netutils/netlib/CMakeLists.txt
index 27c03f88f..bfea011a5 100644
--- a/netutils/netlib/CMakeLists.txt
+++ b/netutils/netlib/CMakeLists.txt
@@ -84,6 +84,10 @@ if(CONFIG_NETUTILS_NETLIB)
     endif()
   endif()
 
+  if(CONFIG_NETDB_DNSCLIENT)
+    list(APPEND SRCS netlib_cleardnsaddr.c)
+  endif()
+
   # Device support
 
   if(CONFIG_NETLINK_ROUTE)
diff --git a/netutils/netlib/Makefile b/netutils/netlib/Makefile
index f606d50d7..2850cddeb 100644
--- a/netutils/netlib/Makefile
+++ b/netutils/netlib/Makefile
@@ -85,6 +85,10 @@ CSRCS += netlib_ip6tables.c
 endif
 endif
 
+ifeq ($(CONFIG_NETDB_DNSCLIENT),y)
+CSRCS += netlib_cleardnsaddr.c
+endif
+
 # Device support
 
 ifeq ($(CONFIG_NETLINK_ROUTE),y)
diff --git a/netutils/netlib/netlib_cleardnsaddr.c 
b/netutils/netlib/netlib_cleardnsaddr.c
new file mode 100644
index 000000000..e71e06928
--- /dev/null
+++ b/netutils/netlib/netlib_cleardnsaddr.c
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * apps/netutils/netlib/netlib_cleardnsaddr.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/net/dns.h>
+
+#include "netutils/netlib.h"
+
+#ifdef CONFIG_NETDB_DNSCLIENT
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: netlib_clear_dnsaddr
+ *
+ * Description:
+ *   Clear the DNS server address
+ *
+ * Parameters:
+ *   void
+ *
+ * Return:
+ *  void
+ *
+ ****************************************************************************/
+
+void netlib_clear_dnsaddr(void)
+{
+  dns_default_nameserver();
+}
+
+#endif /* CONFIG_NETDB_DNSCLIENT */

Reply via email to