Commit Graph

69 Commits

Author SHA1 Message Date
YAMAMOTO Takashi
4666b39f9c dns_recv_response: Fix IPv6 address in an ninfo() 2021-06-17 02:52:04 -05:00
chao.an
f3a5aee7d7 libs/libc/netdb: add dns clear interface
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-11 04:54:30 -05:00
Virus.V
317bd40fec net/dns:fix unaligned access in dns query 2021-06-10 02:03:31 -05:00
Xiang Xiao
2e54df0f35 Don't include assert.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-03 08:36:03 -07:00
YAMAMOTO Takashi
d6ed7464b3 Kconfig: Make NETDB_DNSCLIENT select NET_SOCKOPTS
Because it uses SO_RCVTIMEO.
2021-06-03 10:05:33 -05:00
Xiang Xiao
d7f96003cf Don't include debug.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-01 06:42:02 +09:00
Alin Jerpelea
c6252c9e32 libs: libc: update licenses to Apache
Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-05-27 08:07:25 +09:00
Gustavo Henrique Nihei
330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +08:00
Alin Jerpelea
b5d4a01821 libs: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can migrate the licenses
 to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-03-03 18:52:53 -08:00
Michael Jung
cbe3fb5c60 libs/libc: License Clearance
Change the copyright header of assorted source files in libs/libc to the
ASF version.  I was listed as the author in these files.  I did also
check the heritage of those files and besides me they have only been
changed by the following people, all of whom did sign a CLA to the best
of my knowledge:

Alin Jerpelea
Haitao Liu
Gregory Nutt
Yamamoto Takashi
Xiang Xiao

Signed-off-by: Michael Jung <mijung@gmx.net>
2021-03-02 03:44:06 -08:00
Xiang Xiao
9473434587 Ensure the kernel component don't call userspace API
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-03-01 09:23:09 +09:00
Xiang Xiao
f3043d133e netdb: Don't call _NX_RECV and _NX_SEND
since netdb should only be called from userspace

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-02-21 12:33:02 +00:00
YAMAMOTO Takashi
6b48f8b397 netdb: A few build fixes 2021-01-27 11:04:58 +00:00
Xiang Xiao
922cf0612b libc/netdb: Move hostbuffer out of the stack
The length of hostbuffer come from Kconfig, it isn't safe to
allocate this variable on the stack.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I75213688153a1cba738544de2a51fa3247626dd3
2020-12-22 10:40:22 -03:00
YAMAMOTO Takashi
5566d9ad03 libs/libc/netdb/lib_dnsquery.c: Fix a syslog format 2020-11-23 05:00:10 -08:00
Xiang Xiao
ae356001cf Change all files come from Xiaomi/Pinecone to Apache License 2.0
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-22 17:37:21 -06:00
YAMAMOTO Takashi
76add63598 Bump the default of CONFIG_NETDB_DNSCLIENT_MAXRESPONSE
It's better to have a default working for many cases.
Usually DNS servers are not optimized for embedded clients.
Users can fine tune for their environment anyway.
2020-05-15 14:23:48 +08:00
YAMAMOTO Takashi
e783a59f9d netdb: Truncate the list of ips instead of bailing out with ERANGE
In many cases, users only care the first address anyway.
2020-05-15 14:23:48 +08:00
YAMAMOTO Takashi
b36420ef32 Bump the default of CONFIG_NETDB_BUFSIZE
The old default didn't work even for moderate cases.
(eg. strlen(name) == 17, two ipv4 addresses, on 64-bit sim)
2020-05-15 14:23:48 +08:00
Juha Niskanen
b34d7bf56d libc/netdb: support multiple DNS nameservers when not using resolv.conf
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-04-27 19:52:24 +08:00
Juha Niskanen
ba0a17ca8c libc/netdb: make getaddrinfo re-entrant also when querying with service name
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-04-27 19:52:24 +08:00
YAMAMOTO Takashi
804c719319 getnameinfo: Rename a variable to avoid shadowing a global 2020-04-02 14:17:15 +08:00
YAMAMOTO Takashi
da48d912e4 gethostbyaddr_r: Fix an unsed variable warning 2020-04-02 13:38:21 +08:00
Xiang Xiao
4addf6c308 libc/netdb: query IPv6 first than IPv4
since some host have multiple IPv4 address, the dns cache may fill in all
Ipv4 address and refuse to accept any IPv6 address if we query IPv4 first

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I229a7a524fb9daa7498c66913a2de61f11d6fb43
2020-04-01 16:09:28 -06:00
Xiang Xiao
0b662d60fc libc/netdb: Add hostent_s to avoid the change of hostent
and let other function call the new internal function gethostentbyname_r

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ic6137d6cf03f75d6ed33e23bf04ae74b7264e682
2020-04-01 16:09:28 -06:00
Xiang Xiao
99dc8bf4e9 libc/netdb: Return EAI_FAMILY in getaddrinfo if the final address is empty
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I510d4e8f79d2b4e78c550b35b7b07f2d0943e32d
2020-04-01 16:09:28 -06:00
Xiang Xiao
8d66a316da libc/netdb: Support save the mix of IPv4/IPv6 address into hostent
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I704d38afde14b6d90a7726096fd1f483f96ba237
2020-04-01 16:09:28 -06:00
Xiang Xiao
7f2810f73a libc/netdb: Should query both IPv4 and IPv6 address regardless the server address type
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I1ba17b3078837cd5b857a13f104550613050d3e0
2020-04-01 16:09:28 -06:00
Xiang Xiao
2e57583219 libc/netdb: Connect to the server before sending
so we can remove the server check in response

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I7ddc00807feb92bb6f0851023bb63d38bf3fdac2
2020-04-01 16:09:28 -06:00
YAMAMOTO Takashi
4dffb8c584 Fix a typo in Kconfig help 2020-04-01 10:23:56 +01:00
Xiang Xiao
15fac7743c libc/netdb: Fix nxstyle issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-03-30 09:47:28 -06:00
Xiang Xiao
d8b5362380 libc/netdb: Fix typo error in the implementation of gethostbyname_r
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I6675e800ad5627881ca904e80317df94f5973eb7
2020-03-30 09:47:28 -06:00
Xiang Xiao
dd0aca6822 libc/netdb: Make host and serv optional for getnameinfo
and fix other minor style

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I107ee5b141f39e1e08967373b1ead4495bc55aa7
2020-03-30 09:47:28 -06:00
Xiang Xiao
a709c83b2e libc/netdb: Make gethostbyaddr_r callable even without CONFIG_NETDB_HOSTFILE
and fix other minor issue

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I1c12440cfb7aef4394539e02a12aeb10088f236b
2020-03-30 09:47:28 -06:00
Xiang Xiao
c85fe67ebc net/loopback: Move g_lo_* global variable to libc/net/
so netdb could reuse these global variable directly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Iaa26ddbdaf416f64d43c6e8888a14bbe0c3405eb
2020-03-30 09:47:28 -06:00
Xiang Xiao
eaab17b66a libc/netdb: Change the default max number of host IP to 2 if both IPv4 and Ipv6 enable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I02614cb34647eaa03b476a6755d0667dc8392036
2020-03-30 09:47:28 -06:00
Xiang Xiao
bd9fbade05 libc/netdb: Fix the buffer overwrite in lib_parse_hostfile
and other minor issue

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I732f63a312ac5c2ddf61ab8084c404bde1b114d4
2020-03-30 09:47:28 -06:00
Xiang Xiao
9e277c6c50 libc/netdb: Return null alias for getservbyport_r/getservbyname_r
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I82728a8ea9a5136e0154cd67ec8de70a4e0ac6ed
2020-03-30 09:47:28 -06:00
Xiang Xiao
d05de762bc libc/netdb: Don't need call dns_initialize in dns_find_answer
so let remove it

Change-Id: I6b09673caf8cb16d90cbda8b791f1ef0ba59e2a2
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-03-30 09:47:28 -06:00
Xiang Xiao
673a43d5fa libc/netdb: Need skip ':' to get port in dns_foreach_nameserver
Change-Id: Ic9555832c4404a59e1117dce06a5de13f0cc4141
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-03-30 09:47:28 -06:00
Xiang Xiao
35b98f2361 libc/netdb: Change the fopen mode from "rt" to "r"
since the text mode is the default

Change-Id: If4df0c69d998a36df541a968d14fc4d6e159db57
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-03-30 09:47:28 -06:00
Xiang Xiao
64a230df7a libc/netdb: Should use ntohs not htons for the receiving data
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I36e508c1ba952d9229790abdb47f4f9dc654d326
2020-03-30 09:47:28 -06:00
Xiang Xiao
07c3b16462 libc/netdb: Replace get_errno with errno
and fix the typo error

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I51e2e4dbdb46fea89f4e18a41d99b943b03cedab
2020-03-30 09:47:28 -06:00
Gregory Nutt
533528af01 libs/libc: Remove support CONFIG_FS_READABLE 2020-03-22 08:24:07 -05:00
Gregory Nutt
266849549a libs/libc/netdb/lib_dnsaddserver.c: Fix wrong fopen() mode.
dns_add_nameserver(): As reported by Surya Prakash Verma, call to
fopen() used nonexistent file open mode "at"; changed this to "r"
per Surya's analysis. See Surya's email to dev@ on 12 Mar 2020,
archived here: https://lists.apache.org/thread.html/rbbbee93f79dd8f4224969bb03bf093d8c96421380a1d955167a2f661%40%3Cdev.nuttx.apache.org%3E
2020-03-14 01:19:11 +01:00
Xiang Xiao
bd4e8e19d3 Run codespell -w against all files
and fix the wrong correction
2020-02-22 14:45:07 -06:00
Xiang Xiao
5c80b94820 Replace #include <semaphore.h> to #include <nuttx/semaphore.h>
Since the kernel side should call nxsem_xxx instead and remove the unused inclusion
2020-02-01 08:27:30 -06:00
Xiang Xiao
68951e8d72 Remove exra whitespace from files (#189)
* Remove multiple newlines at the end of files
* Remove the whitespace from the end of lines
2020-01-31 09:24:49 -06:00
Xiang Xiao
6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Xiang Xiao
111fc0c83e libs/libc/netdb/lib_getaddrinfo.c: getaddrinfo() should return EAI_FAMILY if res equals NULL. 2019-11-18 11:36:48 -06:00