You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/02/19 17:34:21 UTC
[incubator-nuttx] branch master updated: netdb.h: Add NI_MAXHOST
and NI_MAXSERV
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/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 3300589 netdb.h: Add NI_MAXHOST and NI_MAXSERV
3300589 is described below
commit 33005897baafef810d2d6a5803a6134977bea5eb
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Fri Feb 19 12:44:20 2021 +0900
netdb.h: Add NI_MAXHOST and NI_MAXSERV
* These are not parts of the standards as far as I know.
* These are provided by many platforms. (GLIBC, BSD, Windows, etc)
* These are convenient.
---
include/netdb.h | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/include/netdb.h b/include/netdb.h
index 308536d..15b65cc 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -156,6 +156,35 @@
#define NO_RECOVERY 3
#define TRY_AGAIN 4
+/* NI_MAXHOST is the max of
+ *
+ * CONFIG_NETDB_DNSCLIENT_NAMESIZE + 1
+ * INET6_ADDRSTRLEN
+ * INET_ADDRSTRLEN
+ *
+ * Note: INETxxx_ADDRSTRLEN already includes the terminating NUL.
+ * Note: INET6_ADDRSTRLEN > INET_ADDRSTRLEN is assumed.
+ */
+
+#if defined(CONFIG_NET_IPv6)
+#define _INET_ADDRSTRLEN INET6_ADDRSTRLEN
+#else
+#define _INET_ADDRSTRLEN INET_ADDRSTRLEN
+#endif
+
+#if defined(CONFIG_NETDB_DNSCLIENT) && \
+ (CONFIG_NETDB_DNSCLIENT_NAMESIZE + 1) > _INET_ADDRSTRLEN
+#define NI_MAXHOST (CONFIG_NETDB_DNSCLIENT_NAMESIZE + 1)
+#else
+#define NI_MAXHOST _INET_ADDRSTRLEN
+#endif
+
+/* Right now, g_services_db[] only has "ntp".
+ * 16 should be large enough.
+ */
+
+#define NI_MAXSERV 16
+
/****************************************************************************
* Public Types
****************************************************************************/