about summary refs log tree commit diff
path: root/src/network/getaddrinfo.c
Commit message (Collapse)AuthorAgeFilesLines
* add support for ipv6 scope_id to getaddrinfo and getnameinfoRich Felker2014-06-041-0/+1
| | | | | | | | | | | | | | | | | | | | for all address types, a scope_id specified as a decimal value is accepted. for addresses with link-local scope, a string containing the interface name is also accepted. some changes are made to error handling to avoid unwanted fallbacks in the case where the scope_id is invalid: if an earlier name lookup backend fails with an error rather than simply "0 results", this failure now suppresses any later attempts with other backends. in getnameinfo, a light "itoa" type function is added for generating decimal scope_id results, and decimal port strings for services are also generated using this function now so as not to pull in the dependency on snprintf. in netdb.h, a definition for the NI_NUMERICSCOPE flag is added. this is required by POSIX (it was previously missing) and needed to allow callers to suppress interface-name lookups.
* refactor getaddrinfo and add support for most remaining featuresRich Felker2014-05-311-228/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this is the first phase of the "resolver overhaul" project. conceptually, the results of getaddrinfo are a direct product of a list of address results and a list of service results. the new code makes this explicit by computing these lists separately and combining the results. this adds support for services that have both tcp and udp versions, where the caller has not specified which it wants, and eliminates a number of duplicate code paths which were all producing the final output addrinfo structures, but in subtly different ways, making it difficult to implement any of the features which were missing. in addition to the above benefits, the refactoring allows for legacy functions like gethostbyname to be implemented without using the getaddrinfo function itself. such changes to the legacy functions have not yet been made, however. further improvements include matching of service alias names from /etc/services (previously only the primary name was supported), returning multiple results from /etc/hosts (previously only the first matching line was honored), and support for the AI_V4MAPPED and AI_ALL flags. features which remain unimplemented are IDN translations (encoding non-ASCII hostnames for DNS lookup) and the AI_ADDRCONFIG flag. at this point, the DNS-based name resolving code is still based on the old interfaces in __dns.c, albeit somewhat simpler in its use of them. there may be some dead code which could already be removed, but changes to this layer will be a later phase of the resolver overhaul.
* reject invalid address families in getaddrinfoRich Felker2013-11-271-0/+3
| | | | | | | subsequent code assumes the address family requested is either unspecified or one of IPv4/IPv6, and could malfunction if this constraint is not met, so other address families should be explicitly rejected.
* remove duplicate includes from dynlink.c, strfmon.c and getaddrinfo.cSzabolcs Nagy2013-11-251-3/+0
|
* make getaddrinfo with AF_UNSPEC and null host return both IPv4 and v6Rich Felker2013-07-241-14/+23
| | | | | | based on a patch by orc, with indexing and flow control cleaned up a little bit. this code is all going to be replaced at some point in the near future.
* fix blank ai_canonname from getaddrinfo for non-CNAMEsRich Felker2013-02-021-1/+1
|
* fix getaddrinfo to accept port 0 (zero)Rich Felker2012-09-221-2/+2
| | | | | | | | new behavior can be summarized as: inputs that parse completely as a decimal number are treated as one, and rejected only if the result is out of 16-bit range. inputs that do not parse as a decimal number (where strtoul leaves anything left over in the input) are searched in /etc/services.
* use restrict everywhere it's required by c99 and/or posix 2008Rich Felker2012-09-061-1/+1
| | | | | | | | to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
* remove scanf dependency from getaddrinfo /etc/services supportRich Felker2012-07-221-5/+4
|
* getaddrinfo /etc/services lookup supportRich Felker2012-07-221-3/+16
|
* improve name lookup performance in corner casesRich Felker2012-04-011-1/+1
| | | | | | | | | | | the buffer in getaddrinfo really only matters when /etc/hosts is huge, but in that case, the huge number of syscalls resulting from a tiny buffer would seriously impact the performance of every name lookup. the buffer in __dns.c has also been enlarged a bit so that typical resolv.conf files will fit fully in the buffer. there's no need to make it so large as to dominate the syscall overhead for large files, because resolv.conf should never be large.
* port numbers should always be interpreted as decimalRich Felker2011-08-011-1/+1
| | | | | | | | | | | per POSIX and RFC 3493: If the specified address family is AF_INET, AF_INET6, or AF_UNSPEC, the service can be specified as a string specifying a decimal port number. 021 is a valid decimal number, therefore, interpreting it as octal seems to be non-conformant.
* disallow blank strings as service or host nameRich Felker2011-04-201-0/+3
|
* return the requested string as the "canonical name" for numeric addressesRich Felker2011-04-081-0/+1
| | | | | | | | previously NULL was returned in ai_canonname, resulting in crashes in some callers. this behavior was incorrect. note however that the new behavior differs from glibc, which performs reverse dns lookups. POSIX is very clear that a reverse DNS lookup must not be performed for numeric addresses.
* fix all implicit conversion between signed/unsigned pointersRich Felker2011-03-251-1/+1
| | | | | | | sadly the C language does not specify any such implicit conversion, so this is not a matter of just fixing warnings (as gcc treats it) but actual errors. i would like to revisit a number of these changes and possibly revise the types used to reduce the number of casts required.
* initial check-in, version 0.5.0 v0.5.0Rich Felker2011-02-121-0/+224