summaryrefslogtreecommitdiff
path: root/lib/libc/net/getaddrinfo.c
Commit message (Collapse)AuthorAgeFilesLines
* Don't ignore trailing spaces after numerical IP addresses.Hajimu UMEMOTO2017-12-201-1/+2
| | | | | | | | | | PR: 224403 Reported by: Michael Kaufmann Reviewed by: Michael Kaufmann MFC after: 1 week Notes: svn path=/head/; revision=327029
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* Silently handle freeaddrinfo(NULL) for compatibility with code whichKonstantin Belousov2017-09-141-5/+4
| | | | | | | | | | | | | works on other OSes. Also avoid unnecessary NULL check, free(NULL) is valid. Reviewed by: bjk (man page), hrs, hselasky, ume Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D12354 Notes: svn path=/head/; revision=323597
* Cleanup inelegant calloc(3) introduced in r310984.Pedro F. Giffuni2017-01-021-1/+1
| | | | Notes: svn path=/head/; revision=311102
* Use calloc instead of malloc + memset(.., 0, ..)Enji Cooper2016-12-311-8/+4
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=310984
* 'addrlen' does not matter when we need to find the first non-zero bit inAndrey A. Chernov2016-08-311-1/+1
| | | | | | | | | | | the byte from the left and 'addrlen' already counted in 'lim'. PR: 212121 Submitted by: Herbie.Robinson@stratus.com MFC after: 7 days Notes: svn path=/head/; revision=305144
* The formal behavior of qsort is unstable with regard to objects thatAndrey A. Chernov2016-08-271-0/+19
| | | | | | | | | | | | | | | | are equal. Unfortunately, RFC 3484 requires that otherwise equal objects remain in the order supplied by the DNS server. The present code attempts to deal with this by returning -1 for objects that are equal (i.e., returns that the first parameter is less then the second parameter). Unfortunately, the qsort API does not state that the first parameter passed in is in any particular position in the list. PR: 212122 Submitted by: Herbie.Robinson@stratus.com MFC after: 3 days Notes: svn path=/head/; revision=304911
* Initialize `ai` to NULL and test for `ai` with type-appropriate valuesEnji Cooper2016-08-131-3/+5
| | | | | | | | | | | | | | | Depending on the address family and ai_flags containing AI_V4MAPPED, it might not do a proper DNS lookup on the provided DNS address Convert some `ai` boolean true/false checks to NULL/non-NULL while here. MFC after: 1 week PR: 211790 Reported by: Herbie.Robinson@stratus.com Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=304034
* libc: spelling fixes.Pedro F. Giffuni2016-04-301-1/+1
| | | | | | | Mostly on comments. Notes: svn path=/head/; revision=298830
* libc: do not include <sys/types.h> where <sys/param.h> was already includedAndriy Voskoboinyk2016-04-181-1/+0
| | | | | | | | | According to style(9): > normally, include <sys/types.h> OR <sys/param.h>, but not both. (<sys/param.h> already includes <sys/types.h> when LOCORE is not defined). Notes: svn path=/head/; revision=298226
* libc: make some more use of the nitems() macro.Pedro F. Giffuni2016-04-161-3/+3
| | | | | | | | | | | We have an nitems() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read. Given that it is available already without adding additional headers and other parts of libc already use it, extend a bit more its use. Notes: svn path=/head/; revision=298120
* If we end up following a CNAME chain that does not findHajimu UMEMOTO2015-12-211-1/+6
| | | | | | | | | | | any data return that instead of internal error. PR: 156684 Obtained from: NetBSD MFC after: 1 week Notes: svn path=/head/; revision=292539
* Use _map_v4v6_address().Hajimu UMEMOTO2015-12-181-4/+3
| | | | | | | | Suggested by: hrs MFC after: 1 week Notes: svn path=/head/; revision=292445
* Add AI_V4MAPPED and AI_ALL support for getaddrinfo(3).Hajimu UMEMOTO2015-12-181-25/+131
| | | | | | | | PR: 198092 MFC after: 1 week Notes: svn path=/head/; revision=292444
* RFC 3493 requires ignoring the loopback address for A_ADDRCONFIG.Hajimu UMEMOTO2015-12-121-1/+1
| | | | | | | | | | | | Since it breaks certain jail setup, we ignore just 127.0.0.1 instead of whole loopback address range. PR: 192014 Reviewed by: hrs MFC after: 1 week Notes: svn path=/head/; revision=292129
* The calls to RES_SET_H_ERRNO() macro on error paths wind upHajimu UMEMOTO2015-12-101-1/+2
| | | | | | | | | | | dereferencing an uninitialized res. PR: 202142 Submitted by: Sean Boudreau MFC after: 1 week Notes: svn path=/head/; revision=292059
* - Move PF_LOCAL at the end of the array. PF_INET{,6} is used more often.Hiroki Sato2015-10-031-7/+9
| | | | | | | | | | - Add SOCKTYPE_ANY to PF_LOCAL. - Apply AI_CANONNAME to only AF_INET{,6}. It is not meaningful for the other AFs. Notes: svn path=/head/; revision=288601
* Add PF_LOCAL support in getaddrinfo(3) and getnameinfo(3):Hiroki Sato2015-09-201-20/+72
| | | | | | | | | | | | | | | | - In a PF_LOCAL address, "hostname" must begins with '/' and "servname" is always NULL. All of ai_flags are ignored. - PF_UNSPEC matches PF_LOCAL. EAI_SERVICE is not returned to make AF-independent programming easier; "servname" is always ignored in PF_LOCAL. In practice, PF_INET* and PF_LOCAL are mutually-exclusive because a hostname which begins with '/' is invalid in PF_INET*. No domain name resolution is performed for a PF_LOCAL address. Differential Revision: https://reviews.freebsd.org/D3634 Notes: svn path=/head/; revision=287999
* Stop including if_var.h from userland.Gleb Smirnoff2015-04-061-1/+0
| | | | | | | Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=281143
* Renove faith(4) and faithd(8) from base. It looks like industryAlexander V. Chernikov2014-11-091-52/+0
| | | | | | | | | | | | have chosen different (and more traditional) stateless/statuful NAT64 as translation mechanism. Last non-trivial commits to both faith(4) and faithd(8) happened more than 12 years ago, so I assume it is time to drop RFC3142 in FreeBSD. No objections from: net@ Notes: svn path=/head/; revision=274331
* Fix build with WITHOUT_INET6.Hajimu UMEMOTO2014-06-261-0/+2
| | | | | | | | Spotted by: bf MFC after: 1 week Notes: svn path=/head/; revision=267915
* - Exclude loopback address rather than loopback interface.Hajimu UMEMOTO2014-06-261-13/+27
| | | | | | | | | | | | | | - style(9) TODO: When AI_ADDRCONFIG is specified, getaddrinfo() can be quite slow for system with many interfaces. We should have some kernel sysctls to report IPv4/IPv6 status. Spotted by: melifaro MFC after: 1 week Notes: svn path=/head/; revision=267912
* Exclude IPv4 address from doing longest match.Hajimu UMEMOTO2014-06-231-1/+2
| | | | | | | | | It prevented DNS based load balancing. MFC after: 1 week Notes: svn path=/head/; revision=267800
* Use SOCK_CLOEXEC.Hajimu UMEMOTO2014-06-191-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=267640
* Retooling addrconfig() to exclude addresses on loopback interfacesHajimu UMEMOTO2014-06-181-29/+62
| | | | | | | | | | | | | | | | when looking for configured addresses. This change is based upon the code from the submitter, and made following changes: - Exclude addresses assigned on interfaces which are down, like NetBSD does. - Exclude addresses assigned on interfaces which are ifdisabled. PR: 190824 Submitted by: Justin McOmie MFC after: 1 week Notes: svn path=/head/; revision=267616
* Add support for UDP-Lite protocol (RFC 3828) to IPv4 and IPv6 stacks.Kevin Lo2014-04-071-0/+5
| | | | | | | | | | | Tested with vlc and a test suite [1]. [1] http://www.erg.abdn.ac.uk/~gerrit/udp-lite/files/udplite_linux.tar.gz Reviewed by: jhb, glebius, adrian Notes: svn path=/head/; revision=264212
* libc: Use SOCK_CLOEXEC for various internal file descriptors.Jilles Tjoelker2013-09-061-5/+7
| | | | | | | | | | This change avoids undesirably passing some internal file descriptors to a process created (fork+exec) by another thread. Kernel support for SOCK_CLOEXEC was added in r248534, March 19, 2013. Notes: svn path=/head/; revision=255328
* libc: Make various internal file descriptors from fopen() close-on-exec.Jilles Tjoelker2013-08-231-2/+2
| | | | Notes: svn path=/head/; revision=254700
* Return zero from get_addrselectpolicy() when no source-address-selectionMaksim Yevmenkin2012-07-181-0/+2
| | | | | | | | | policy is installed. MFC after: 1 week Notes: svn path=/head/; revision=238599
* libc: Remove some unused strings from getaddrinfo().Jilles Tjoelker2012-07-151-13/+12
| | | | Notes: svn path=/head/; revision=238504
* Fix two warnings about self-assignment in libc. These normally onlyDimitry Andric2012-06-061-1/+1
| | | | | | | | | | trigger with clang, when you either use -save-temps, or ccache. Reported by: Sevan / Venture37 <venture37@gmail.com> MFC after: 3 days Notes: svn path=/head/; revision=236695
* Eliminate two cases of unwanted strncpy(). The name is not requiredXin LI2012-04-021-2/+0
| | | | | | | | | | | by the current code, and the results would get overwritten anyway by subsequent memset(). Reviewed by: ume MFC after: 1 month Notes: svn path=/head/; revision=233770
* Handle the internal scope address representation of the KAME IPv6Hajimu UMEMOTO2012-01-071-1/+2
| | | | | | | | | | stack for the node-local multicast address. Spotted by: Rainer Bredehorn <Bredehorn__at__gmx.de> MFC after: 1 week Notes: svn path=/head/; revision=229766
* Query DNS only once per an address family.Hajimu UMEMOTO2009-03-291-86/+170
| | | | | | | | Obtained from: KAME MFC after: 2 weeks Notes: svn path=/head/; revision=190525
* Add support for SCTP to getaddrinfo(3).Hajimu UMEMOTO2009-03-251-7/+20
| | | | | | | | | | | | | | | | Now, getaddrinfo(3) returns two SOCK_STREAMs, IPPROTO_TCP and IPPROTO_SCTP. It confuses some programs. If getaddrinfo(3) returns IPPROTO_SCTP when SOCK_STREAM is specified by hints.ai_socktype, at least Apache doesn't work. So, I made getaddrinfo(3) to return IPPROTO_SCTP with SOCK_STREAM only when IPPROTO_SCTP is specified explicitly by hints.ai_protocol. PR: bin/128167 Submitted by: Bruce Cran <bruce__at__cran.org.uk> (partly) MFC after: 2 week Notes: svn path=/head/; revision=190416
* getaddrinfo(3) should accept numeric when ai_socktype is notHajimu UMEMOTO2009-03-241-1/+11
| | | | | | | | | | | specified in hint or hints is NULL. PR: bin/51827 Submitted by: Mark Andrews <marka__at__isc.org> MFC after: 1 week Notes: svn path=/head/; revision=190382
* Shutup warning for DNAME RR.Hajimu UMEMOTO2009-02-081-1/+2
| | | | | | | | | PR: bin/127591 Submitted by: "Eugene M. Kim" <20080111.freebsd.org__at__ab.ote.we.lv> MFC after: 1 week Notes: svn path=/head/; revision=188316
* Remove incomplete support of AI_ALL and AI_V4MAPPED.Hajimu UMEMOTO2008-02-031-21/+0
| | | | | | | Reported by: "Heiko Wundram (Beenic)" <wundram__at__beenic.net> Notes: svn path=/head/; revision=175955
* ensure the head entry of addrinfo chain has non-NULL ai_canonname to beJINMEI Tatuya2007-09-051-2/+19
| | | | | | | | | | | | compliant with RFC3493. PR: standards/114910 Approved by: ume (mentor) Approved by: re MFC after: 1 week Notes: svn path=/head/; revision=172052
* do not overload the port number on to the return value ofHajimu UMEMOTO2006-07-231-8/+9
| | | | | | | | | | str2number(). this could result in an unexpected code path. Obtained from: KAME MFC after: 1 week Notes: svn path=/head/; revision=160593
* remove obsolete comments.Hajimu UMEMOTO2006-07-221-8/+0
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=160577
* simplification in explore_numeric: unified the post-process withHajimu UMEMOTO2006-07-211-32/+22
| | | | | | | | | | GET_AI and GET_PORT. Commented on an impossible case. Obtained from: KAME MFC after: 1 week Notes: svn path=/head/; revision=160553
* RFC3493 requires use of inet_aton for AF_INET.Hajimu UMEMOTO2006-07-211-3/+7
| | | | | | | | Obtained from: KAME MFC after: 1 week Notes: svn path=/head/; revision=160552
* clean-up: rewrote explore_null and explore_numeric without using sentinel.Hajimu UMEMOTO2006-07-211-35/+20
| | | | | | | | | | | we do not need it since we make (at most) a single addrinfo entry in these cases. Obtained from: KAME MFC after: 1 week Notes: svn path=/head/; revision=160551
* - Extend the nsswitch to support Services, Protocols and RpcHajimu UMEMOTO2006-04-281-0/+197
| | | | | | | | | | | databases. - Make nsswitch support caching. Submitted by: Michael Bushkov <bushman__at__rsu.ru> Sponsored by: Google Summer of Code 2005 Notes: svn path=/head/; revision=158115
* fix indent.Hajimu UMEMOTO2006-04-011-9/+9
| | | | Notes: svn path=/head/; revision=157371
* If the query choked with EDNS0, retry without EDNS0.Hajimu UMEMOTO2006-03-281-8/+24
| | | | | | | Obtained from: res_nquery() of BIND9. Notes: svn path=/head/; revision=157203
* - Use ANSI C prototype.Hajimu UMEMOTO2006-03-251-104/+38
| | | | | | | - Remove trailing space. Notes: svn path=/head/; revision=157119
* When res_nquerydomain() returns SERVFAIL, we should try next domain.Hajimu UMEMOTO2006-03-241-1/+9
| | | | Notes: svn path=/head/; revision=157093
* When res_send() fails, we should reserve an error code.Hajimu UMEMOTO2006-03-241-2/+2
| | | | Notes: svn path=/head/; revision=157081