about summary refs log tree commit diff
path: root/src/network
Commit message (Collapse)AuthorAgeFilesLines
* fix undefined strcpy call in inet_ntopRich Felker2013-07-251-1/+1
| | | | | source and dest arguments for strcpy cannot overlap, so memmove must be used here. the length is already known from the above loop.
* make inet_ntop format v4-mapped ipv6 addresses properlyRich Felker2013-07-251-8/+14
| | | | | | | | | | | | | | based on a patch by orc. POSIX actually fails to specify the format of the ntop conversion; presumably, any output that will correctly round-trip back via the (well-specified) pton operation is acceptable. the new behavior is much more convenient than the old, however. this patch also affects getnameinfo, which is implemented in terms of inet_ntop and which is the preferred interface for performing this conversion. I've also removed some inexplicable cruft (filling the buffer with 'x' before doing anything) whose origin I was unable to track down.
* 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 missing SOCK_CLOEXEC in various functions that use sockets internallyRich Felker2013-07-094-4/+4
|
* add stubs for additional legacy ether.h functionsRich Felker2013-07-011-0/+15
| | | | | | these would not be expensive to actually implement, but reading /etc/ethers does not sound like a particularly useful feature, so for now I'm leaving them as stubs.
* implement inet_lnaof, inet_netof, and inet_makeaddrRich Felker2013-06-255-39/+55
| | | | | | | | | also move all legacy inet_* functions into a single file to avoid wasting object file and compile time overhead on them. the added functions are legacy interfaces for working with classful ipv4 network addresses. they have no modern usefulness whatsoever, but some programs unconditionally use them anyway, and they're tiny.
* add ether_aton[_r] and ether_ntoa[_r] functionsRich Felker2013-06-251-0/+43
| | | | | | | based on patch by Strake with minor stylistic changes, and combined into a single file. this patch remained open for a long time due to some question as to whether ether_aton would be better implemented in terms of sscanf, and it's time something was committed, so here it is.
* getifaddrs: implement proper ipv6 netmasksrofl0r2013-04-091-2/+11
|
* getifaddrs: remove unused labelrofl0r2013-04-061-1/+0
|
* getifaddrs: use if_nameindex to enumerate interfacesrofl0r2013-04-051-23/+9
|
* getifaddrs: one less indent levelrofl0r2013-04-051-30/+28
|
* getifaddrs: less mallocrofl0r2013-04-051-55/+52
|
* add getifaddrsrofl0r2013-04-051-0/+191
| | | | | | supports ipv4 and ipv6, but not the "extended" usage where usage statistics and other info are assigned to ifa_data members of duplicate entries with AF_PACKET family.
* implement dn_skipname (legacy resolver function)Rich Felker2013-04-041-0/+12
|
* dynamically allocate storage for gethostby* buffersRich Felker2013-02-022-10/+32
| | | | | | | | | | this change shaves ~1k off libc.so bss size, and also avoids hard errors in the case where the static buffer was not large enough to hold the result. this whole framework is really ugly and might should be replaced or at least heavily overhauled when some changes/factorizations are made to getaddrinfo internals in the future.
* fix blank ai_canonname from getaddrinfo for non-CNAMEsRich Felker2013-02-021-1/+1
|
* fix memory leak due to double call to getaddrinfo in gethostbyname*Rich Felker2013-02-021-1/+0
|
* fix error returns in gethostby*_r functionsRich Felker2013-02-022-17/+10
| | | | they're supposed to return an error code rather than using errno.
* add inet_network (required for wine)rofl0r2012-12-191-0/+11
|
* improve SOCK_NONBLOCK/SOCK_CLOEXEC fallback codeRich Felker2012-11-051-1/+2
| | | | | | | | | | | | | | | | checking for EINVAL should be sufficient, but qemu user emulation returns EPROTONOSUPPORT in some of the failure cases, and it seems conceivable that other kernels doing linux-emulation could make the same mistake. since DNS lookups and other important code might break if the fallback does not get invoked, be extra careful and check for either error. note that it's important NOT to perform the fallback code on other errors such as resource-exhaustion cases, since the fallback is not atomic and will lead to file-descriptor leaks in multi-threaded programs that use exec. the fallback code is only "safe" to run when the initial failure is caused by the application's choice of arguments, not the system state.
* fix some more O_CLOEXEC/SOCK_CLOEXEC issuesRich Felker2012-09-291-3/+1
|
* move accept4, dup3, and pipe2 to non-linux-specific locationsRich Felker2012-09-291-0/+9
| | | | | these interfaces have been adopted by the Austin Group for inclusion in the next version of POSIX.
* emulate SOCK_CLOEXEC and SOCK_NONBLOCK for old (pre-2.6.27) kernelsRich Felker2012-09-291-1/+14
| | | | | | | | | | | | | | | also update syslog to use SOCK_CLOEXEC rather than separate fcntl step, to make it safe in multithreaded programs that run external programs. emulation is not atomic; it could be made atomic by holding a lock on forking during the operation, but this seems like overkill. my goal is not to achieve perfect behavior on old kernels (which have plenty of other imperfect behavior already) but to avoid catastrophic breakage in (1) syslog, which would give no output on old kernels with the change to use SOCK_CLOEXEC, and (2) programs built on a new kernel where configure scripts detected a working SOCK_CLOEXEC, which later get run on older kernels (they may otherwise fail to work completely).
* 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-069-11/+11
| | | | | | | | 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
|
* make getservby*_r return error code rather than -1 (and using errno)Rich Felker2012-07-222-19/+35
| | | | untested but should be correct..
* fix logic error for skipping failed interfaces in if_nameindexRich Felker2012-07-211-8/+7
|
* fix getservby*() with null pointer for protocol argumentRich Felker2012-07-142-0/+8
| | | | not sure this is the best fix but it should work
* workaround another sendmsg kernel bug on 64-bit machinesRich Felker2012-07-121-0/+13
| | | | | | | | | the kernel wrongly expects the cmsg length field to be size_t instead of socklen_t. in order to work around the issue, we have to impose a length limit and copy to a local buffer. the length limit should be more than sufficient for any real-world use; these headers are only used for passing file descriptors and permissions between processes over unix sockets.
* fix misplaced semicolon in preprocessor directive (#undef h_errno)Rich Felker2012-05-161-1/+1
|
* use __h_errno_location for h_errnoRich Felker2012-05-122-0/+9
| | | | | | we do not bother making h_errno thread-local since the only interfaces that use it are inherently non-thread-safe. but still use the potentially-thread-local ABI to access it just to avoid lock-in.
* improve name lookup performance in corner casesRich Felker2012-04-012-2/+2
| | | | | | | | | | | 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.
* fix for previous incorrect fix of cancellation in dns lookupsRich Felker2012-02-231-3/+4
| | | | | uninitialized file descriptor was being closed on return, causing stdin to be closed in many cases.
* fix default nameserver when resolv.conf doesn't existRich Felker2012-02-111-1/+2
|
* fix illegal goto out of cleanup context in dns lookupsRich Felker2012-02-111-3/+3
|
* make dns lookups (and thus getaddrinfo) cancellableRich Felker2011-09-211-4/+11
|
* use poll rather than select in dns lookups (also clock_gettime)Rich Felker2011-09-211-12/+10
| | | | | | | | | | if the file descriptor resource limit has been increased past FD_SETSIZE, this is actually a security issue; we could write past the end of the fd_set object. using poll makes it a non-issue, and simplifies the code at the same time. also, use clock_gettime instead of gettimeofday, for reduced bloat and better entropy.
* remove some stray trailing space charactersRich Felker2011-09-132-2/+2
|
* implement if_nameindex and if_freenameindexRich Felker2011-08-032-0/+65
|
* fix wrong messages in gai_strerrorRich Felker2011-08-011-0/+2
| | | | i had missed the fact that a couple values were unassigned...
* 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.
* "implement" getnetbyaddr and getnetbynameRich Felker2011-07-121-0/+12
| | | | | these are useless legacy functions but some old software contains cruft that expects them to exist...
* res_search symbol, aliased to res_query for now (better than nothing)Rich Felker2011-06-301-0/+3
|
* fix bug in ipv6 parsing that prevented parsing a lone "::"Rich Felker2011-04-251-4/+1
|
* ipv6 parsing code (formerly dummied-out)Rich Felker2011-04-252-8/+62
|
* fix bogus return values for inet_ptonRich Felker2011-04-211-2/+2
|
* disallow blank strings as service or host nameRich Felker2011-04-201-0/+3
|
* fix bugs in ipv4 parsingRich Felker2011-04-201-1/+2
|