History log of /seL4-test-master/projects/musllibc/src/network/getaddrinfo.c
Revision Date Author Comments
# 06bcf9bc 24-Sep-2015 Rich Felker <dalias@aerifal.cx>

make getaddrinfo return error if both host and service name are null

this case is specified as a mandatory ("shall fail") error.

based on patch by Julien Ramseier.


# c63c98a6 07-Feb-2015 Rich Felker <dalias@aerifal.cx>

make getaddrinfo support SOCK_RAW and other socket types

all socket types are accepted at this point, but that may be changed
at a later time if the behavior is not meaningful for other types. as
before, omitting type (a value of 0) gives both UDP and TCP results,
and SOCK_DGRAM or SOCK_STREAM restricts to UDP or TCP, respectively.
for other socket types, the service name argument is required to be a
null pointer, and the protocol number provided by the caller is used.


# bdad2fef 04-Jun-2014 Rich Felker <dalias@aerifal.cx>

add support for ipv6 scope_id to getaddrinfo and getnameinfo

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.


# 6f409bff 31-May-2014 Rich Felker <dalias@aerifal.cx>

refactor getaddrinfo and add support for most remaining features

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.


# cabe9aa9 26-Nov-2013 Rich Felker <dalias@aerifal.cx>

reject invalid address families in getaddrinfo

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.


# 2b1f2f14 25-Nov-2013 Szabolcs Nagy <nsz@port70.net>

remove duplicate includes from dynlink.c, strfmon.c and getaddrinfo.c


# f5dfb45f 24-Jul-2013 Rich Felker <dalias@aerifal.cx>

make getaddrinfo with AF_UNSPEC and null host return both IPv4 and v6

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.


# c0193550 01-Feb-2013 Rich Felker <dalias@aerifal.cx>

fix blank ai_canonname from getaddrinfo for non-CNAMEs


# 4b49060d 22-Sep-2012 Rich Felker <dalias@aerifal.cx>

fix getaddrinfo to accept port 0 (zero)

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.


# 400c5e5c 06-Sep-2012 Rich Felker <dalias@aerifal.cx>

use restrict everywhere it's required by c99 and/or posix 2008

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.


# 845a5e69 22-Jul-2012 Rich Felker <dalias@aerifal.cx>

remove scanf dependency from getaddrinfo /etc/services support


# efe72c56 22-Jul-2012 Rich Felker <dalias@aerifal.cx>

getaddrinfo /etc/services lookup support


# 4f346b08 01-Apr-2012 Rich Felker <dalias@aerifal.cx>

improve name lookup performance in corner cases

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.


# f4e8e64b 31-Jul-2011 Rich Felker <dalias@aerifal.cx>

port numbers should always be interpreted as decimal

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.


# f1ac8a28 20-Apr-2011 Rich Felker <dalias@aerifal.cx>

disallow blank strings as service or host name


# e2cc0bee 08-Apr-2011 Rich Felker <dalias@aerifal.cx>

return the requested string as the "canonical name" for numeric addresses

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.


# 9ae8d5fc 25-Mar-2011 Rich Felker <dalias@aerifal.cx>

fix all implicit conversion between signed/unsigned pointers

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.


# 0b44a031 11-Feb-2011 Rich Felker <dalias@aerifal.cx>

initial check-in, version 0.5.0