summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/net.cc
Commit message (Collapse)AuthorAgeFilesLines
* Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout optioncygwin-2_5_2-releaseCorinna Vinschen2016-06-231-3/+0
| | | | | | | | | | | | | | Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause. Everything else stays under GPLv3+. New Linking Exception exempts resulting executables from LGPLv3 section 4. Add CONTRIBUTORS file to keep track of licensing. Remove 'Copyright Red Hat Inc' comments. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Throughout Cygwin, use u_intN_t or uintN_tCorinna Vinschen2016-03-241-28/+27
| | | | | | | | | | Don't use u_char, u_short, u_int or u_long in Cygwin, unless it refers to the Winsock types. Use u_intN_t in BSD-based sources, unsigned char where strings are concerned, uintN_t otherwise. Also: * net.cc: Fix comment, we're not using u_long anymore. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix return type of get_routedstCorinna Vinschen2016-03-241-1/+1
| | | | | | * net.cc (get_routedst): Correctly return in_addr_t. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Remove unused function convert_ifr_flagsCorinna Vinschen2016-03-241-14/+0
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* cygwin_getaddrinfo: workaround Winsock getaddrinfo issue with broken DNSCorinna Vinschen2016-03-141-1/+10
| | | | | | | | | | | | | | | | | | Add experimental code to workaround the issue described in the thread starting at https://cygwin.com/ml/cygwin/2015-07/msg00350.html There's a hint in https://communities.vmware.com/message/2577858#2577858 that this problem is related to using the AI_ALL flag. This patch checks if GetAddrInfoW returned with WSANO_RECOVERY and if the AI_ALL flag was set, it retries GetAddrInfo without the AI_ALL flag. * net.cc (cygwin_getaddrinfo): Add experimental code to retry GetAddrInfoW without AI_ALL flag if it returned with WSANO_RECOVERY. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* getifaddrs: Return pointer to extended interface info in ifa_data memberCorinna Vinschen2016-03-101-22/+23
| | | | | | | | | | | | | | | | According to https://cygwin.com/ml/cygwin/2016-03/msg00124.html it's a problem to collect friendlyname info using AF_INET6 sockets. Fix problem by exposing additional hardware info for all collected interfaces via the pointer in the ifaddrs::ifa_data member. * include/ifaddrs.h (struct ifaddrs_hwdata): Define as struct of not yet exposed members of struct ifall, defined in net.cc. * net.cc (struct ifall): Replace hardware dta members with struct ifaddrs_hwdata. Accommodate throughout. (get_ifs): Let ifaddrs ifa_data member point to ifall::ifa_hwdata member. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix length returned from sys_cp_wcstombs in case nwc > # of wcharsCorinna Vinschen2015-10-221-1/+1
| | | | | | | | | | * strfuncs.cc (sys_cp_wcstombs): Always return number of multibytes without trailing NUL as the documentation implies. Throughout Cygwin, fix usage to align to this pattern. * fhandler_process.cc (format_process_winexename): Drop trailing NUL and LF from output. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add sethostnameCorinna Vinschen2015-06-171-0/+14
| | | | | | | | | | | | * net.cc (sethostname): New function. * common.din (sethostname): Export * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2001. (CYGWIN_VERSION_DLL_MINOR): Set to 0. * new-features.xml (ov-new): Rename from ov-new1.7. (ov-new2.1): Add new section. Document sethostname. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Handle more Winsock error codes.Corinna Vinschen2015-06-151-0/+3
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* * net.cc: Define _NETIOAPI_H_ to accomodate newer w32api.Takashi Yano2015-05-271-1/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix buffer size error handling in gethostname.Renato Silva2015-04-231-1/+4
| | | | | | * net.cc (cygwin_gethostname): Fix buffer size error handling. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* net.cc: Remove extra braces.Alexey Pavlov2015-03-131-2/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* * net.cc (cygwin_inet_pton): Declare.Corinna Vinschen2015-01-231-7/+113
| | | | | | (gethostby_specials): New function. (gethostby_helper): Change returned addrtype in 4-to-6 case. (gethostbyname2): Call gethostby_specials.
* * common.din (sockatmark): Export.Corinna Vinschen2015-01-201-1/+14
| | | | | * net.cc (sockatmark): New function. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* * net.cc (fdsock): Change default values for socket buffers on 32 bitCorinna Vinschen2014-11-201-2/+9
| | | | to fix performance on 10Gb networks.
* * net.cc (cygwin_setsockopt): Drop redundant test for AF_LOCAL andCorinna Vinschen2014-10-131-3/+1
| | | | SOCK_STREAM in SO_PEERCRED case, as in the original patch.
* Add setsockopt(sd, SOL_SOCKET, SO_PEERCRED, NULL, 0) to disableCorinna Vinschen2014-10-111-0/+19
| | | | | | | | | | | | | | | initial handshake on AF_LOCAL sockets. * fhandler.h (class fhandler_socket): Add no_getpeereid status flag. (fhandler_socket::af_local_set_no_getpeereid): New prototype. * fhandler_socket.cc (fhandler_socket::af_local_connect): Skip handshake if no_getpeereid is set. Add debug output. (fhandler_socket::af_local_accept): Likewise. (fhandler_socket::af_local_set_no_getpeereid): New function. (fhandler_socket::af_local_copy): Copy no_getpeereid. (fhandler_socket::getpeereid): Fail if no_getpeereid is set. * net.cc (cygwin_setsockopt): Add SO_PEERCRED for AF_LOCAL/SOCK_STREAM sockets. Add comment to explain why we need it. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* * Throughout, use __try/__except/__endtry blocks, rather than myfaultCorinna Vinschen2014-08-221-854/+919
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | handler. * cygtls.cc (_cygtls::remove): Accommodate the fact that pathbufs has been moved from _local_storage to _cygtls. * cygtls.h (class tls_pathbuf): Add comment to hint to gendef usage of counters. Change type of counters to uint32_t for clarity. Remove _cygtls as friend class. (struct _local_storage): Move pathbufs from here... (struct _cygtls): ...to here, allowing to access it from _sigbe. (class san): Only define on 32 bit. Remove errno, _c_cnt and _w_cnt members. (san::setup): Drop parameter. Don't initialize removed members. (san::leave): Don't set removed members. (class myfault): Only define on 32 bit. (myfault::faulted): Only keep implementation not taking any parameter. Drop argument in call to sebastian.setup. (__try/__leave/__except/__endtry): Implement to support real SEH. For now stick to SJLJ on 32 bit. * dcrt0.cc (dll_crt0_0): Drop 64 bit call to exception::install_myfault_handler. * exception.h (exception_handler): Define with EXCEPTION_DISPOSITION as return type. (PDISPATCHER_CONTEXT): Define as void * on 32 bit. Define as pointer to _DISPATCHER_CONTEXT on 64 bit. (class exception): Define separately for 32 and 64 bit. (exception::myfault): Add handler for myfault SEH handling on 64 bit. (exception::exception): Fix mangled method name to account for change in type of last parameter. (exception::install_myfault_handler): Remove. * exceptions.cc (exception::myfault_handle): Remove. (exception::myfault): New SEH handler for 64 bit. * gendef (_sigbe): Set tls_pathbuf counters to 0 explicitely when returning to the caller. * ntdll.h: Move a comment to a better place. (struct _SCOPE_TABLE): Define on 64 bit. * thread.cc (verifyable_object_isvalid): Remove gcc 4.7 workaround. * tls_pbuf.cc (tls_pbuf): Fix to accommodate new place of pathbufs. (tls_pathbuf::destroy): Change type of loop variables to uint32_t. * tls_pbuf.h (class tmp_pathbuf): Change type of buffer counters to uint32_t. Accommodate new place of pathbufs. * tlsoffsets.h: Regenerate. * tlsoffsets64.h: Regenerate.
* * net.cc (if_freenameindex): Don't catch a SEGV from free to failCorinna Vinschen2014-08-211-3/+0
| | | | loudly on double free.
* * net.cc (cygwin_getaddrinfo): Fix value of hint->ai_addrlen on 64 bit.Corinna Vinschen2014-06-231-0/+10
| | | | Explain why.
* * net.cc (call_gaa): Fix setting pa_ret pointer in case of an errorCorinna Vinschen2014-05-191-6/+8
| | | | | | from GetAdaptersAddresses (CID 60218). (get_ifs): Add missing braces in AF_INET6 case which broke netmask computation. Break out of loop if prefix gets <= 0 (CID 59939).
* * net.cc (cygwin_getsockopt): Rearrange code slightly and handleCorinna Vinschen2014-05-051-24/+19
| | | | TCP_NODELAY just like SO_KEEPALIVE and SO_DONTROUTE.
* * fhandler_socket.cc: On x86_64, define u_long as __ms_u_long beforeCorinna Vinschen2014-04-241-0/+9
| | | | | | | | | | | including the windows headers. Explain why. (get_inet_addr): Convert ANY address to LOOPBACK address. Explain why. (fhandler_socket::evaluate_events): Forcibly set SO_ERROR socket option in case a connection attempt failed. Explain why. (fhandler_socket::ioctl): Drop x86_64 re-definition of u_long here. * fhandler_procnet.cc: On x86_64, define u_long as __ms_u_long before including the windows headers. Explain why. * net.cc: Ditto.
* * net.cc (cygwin_setsockopt): Ignore IPV6_TCLASS the same way as IP_TOS.Corinna Vinschen2014-04-161-1/+10
|
* * fhandler_disk_file.cc (fhandler_disk_file::fchown): Fix typo inCorinna Vinschen2014-02-061-2/+2
| | | | | | | | | | | comment. * mount.cc (mount_info::from_fstab): Use tmp_pathbuf rather than stack for big local buffer. * net.cc (cygwin_gethostname): Call GetComputerNameExA rather than GetComputerNameA if gethostname failed. * shared.cc (user_info::initialize): Fix formatting. * include/sys/file.h: Define flock and accompanying macros if not already defined in sys/_default_fcntl.h.
* Throughout, drop unnecessary explicit includes of windows header filesCorinna Vinschen2013-11-241-1/+0
| | | | | | | | | | | | included by default. * winlean.h: Add long comment to explain why we have to define certain symbols. (_NORMALIZE_): Define. (_WINNLS_): Drop definition and subsequent undef. (_WINNETWK_): Ditto. (_WINSVC_): Ditto. 2013-11-23 Eric Blake <eblake@redhat.com>
* * net.cc (cygwin_getaddrinfo): Fix a comment. Only memset whints ifCorinna Vinschen2013-11-191-7/+10
| | | | | | hints is NULL. Add a comment and set whints.ai_family explicitely to AF_UNSPEC to follow glibc man page closely. Check flags against whints for locality.
* * autoload.cc (IdnToAscii): Define.Corinna Vinschen2013-11-191-965/+223
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (IdnToUnicode): Define. (FreeAddrInfoW): Define. (GetAddrInfoW): Define. (GetNameInfoW): Define. * net.cc: Drop W. Richard STEVENS libgai implementation. (cygwin_freeaddrinfo): Move code from ipv4_freeaddrinfo here. Move definition up in file to avoid forward declaration in ga_duplist. (ga_dup): Take addrinfoW as input. Add parameters to get IDN flags and to set error value. Handle IDN flags and especially AI_CANONIDN. Convert input wchar_t ai_canonname string to multibyte for output. (ga_duplist): Add parameters to get IDN flags and to set error value and propagate to ga_dup. Call cygwin_freeaddrinfo. (gai_errmap): Add comments. Align error strings to GLibc. Add EAI_IDN_ENCODE entry. (get_ipv6_funcs): Remove. (load_ipv6_guard): Remove. (ipv6_inited): Remove. (load_ipv6): Remove. (load_ipv6_funcs): Remove. (cygwin_getaddrinfo): Drop calling load_ipv6. Handle AI_IDN* flags. Convert input strings to wchar_t and call GetAddrInfoW/FreeAddrInfoW. In case hints is NULL, set default ai_flags explicitely to AI_V4MAPPED | AI_ADDRCONFIG, as documented for Glibc. Only add AI_ALL if AI_ADDRCONFIG is not given. Unconditionally add Windows-specific AI_DISABLE_IDN_ENCODING to ai_flags to make IDN behaviour compatible to Glibc even on Windows 8 and later. (cygwin_getnameinfo): Drop calling load_ipv6. Handle NI_IDN* flags. Call GetNameInfoW and convert returned strings from wchar_t to multibyte. * include/netdb.h: Add comments to describe flags and error values. (AI_*): Define all flags using hex values for clearness. (AI_IDN): Define. (AI_CANONIDN): Define. (AI_IDN_ALLOW_UNASSIGNED): Define. (AI_IDN_USE_STD3_ASCII_RULES): Define. (NI_*): Define all flags using hex values for clearness. (NI_IDN): Define. (NI_IDN_ALLOW_UNASSIGNED): Define. (NI_IDN_USE_STD3_ASCII_RULES): Define. (EAI_IDN_ENCODE): Define.
* * devices.in (dev_storage): Map /dev/zero and /dev/full to \Device\Null.Corinna Vinschen2013-10-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * devices.cc: Regenerate. * dtable.h (struct dtable): Make fhandler_base friend, rather than fhandler_disk_file. * fhandler.cc (fhandler_base::open_with_arch): Create unique id. (fhandler_base::cleanup): Call del_my_locks. (fhandler_base::fcntl): Handle F_GETLK, F_SETLK and F_SETLKW. * fhandler.h (fhandler_base::get_dev): Return real device number. (fhandler_base::set_unique_id): New inline method. (fhandler_disk_file::lock): Drop declaration. (fhandler_disk_file::get_dev): New method, return pc.fs_serial_number. (fhandler_dev_zero::open): Drop declaration. * fhandler_disk_file.cc (fhandler_disk_file::close): Move del_my_locks call to fhandler_base::open_with_arch. (fhandler_disk_file::fcntl): Move handling of locking commands to fhandler_base::fcntl. (fhandler_base::open_fs): Drop call to NtAllocateLocallyUniqueId. * fhandler_zero.cc (fhandler_dev_zero::open): Remove so that default fhandler_base::open is used to open \Device\Null. * flock.cc (fixup_lockf_after_exec): Finding a single fhandler is enough here. (fhandler_base::lock): Replace fhandler_disk_file::lock. Refuse to lock nohandle devices. Handle read/write test using POSIX flags. Explain why. Never fail on SEEK_CUR or SEEK_END, rather assume position 0, just as Linux. * net.cc (fdsock): Create unique id.
* * net.cc (gen_old_if_name): New function to generate short interfaceCorinna Vinschen2013-06-131-2/+52
| | | | | names for old pre-1.7 applications. (get_ifs): Call gen_old_if_name for said old applications.
* * Merge in cygwin-64bit-branch.Corinna Vinschen2013-04-231-268/+103
|
* Throughout, update copyrights to reflect dates which correspond to main-branchChristopher Faylor2013-01-211-2/+2
| | | | checkins. Regularize copyright format.
* * fhandler_registry.cc: Drop Mingw.org considerations.Corinna Vinschen2012-11-261-63/+0
| | | | | | | | | | | * fhandler_serial.cc: Ditto. * fhandler_socket.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * net.cc: Ditto. * ntdll.h: Ditto. * sched.cc: Ditto. * sec_helper.cc: Ditto.
* * net.cc (get_adapters_addresses): Drop FIXME part of comment.Christopher Faylor2012-08-211-3/+1
|
* whitespace cleanupChristopher Faylor2012-08-161-1/+1
|
* Add files missing in previous checkinCorinna Vinschen2012-07-061-58/+43
|
* * Makefile.in: Add some more optimization flags for cygwait, malloc and ↵Christopher Faylor2012-07-021-0/+2
| | | | | | | | | | | | | | | | | | | | | path. Explain why -fomit-frame-pointer doesn't work right for passwd.o and path.o. Add -static to link command line for cygwin0.dll. * fhandler_disk_file.cc (fhandler_disk_file::facl): Reorganize slightly to silence compiler warning when compiling with -fstack-check. * net.cc (inet_ntop6): Initialize structure members to silence compiler warning when compiling with -fstack-check. * pseudo-reloc.cc (_pei386_runtime_relocator): Make this a C function. Detect NULL u. * winsup.h (_pei386_runtime_relocator): Declare this as extern "C". * lib/_cygwin_crt0_common.cc (_pei386_runtime_relocator): Call with NULL argument. * signal.cc (sigaction_worker): Eliminate last argument. Let callers report their own strace info. Regparmize. (sigaction): Reflect sigaction_worker changes. (siginterrupt): Ditto. * exceptions.cc: Update copyright.
* * net.cc (cygwin_recvfrom): Don't shortcircuit if len == 0. Add commentCorinna Vinschen2012-05-211-3/+15
| | | | | | to explain why. (cygwin_recv): Ditto. (cygwin_recvmsg): Ditto.
* * net.cc (get_adapters_addresses): Only create thread on affectedCorinna Vinschen2012-05-031-4/+8
| | | | | | | | | systems. Change comment acordingly. * wincap.h (wincaps::has_gaa_largeaddress_bug): New element. * wincap.cc: Implement above element throughout. (wincap_8): New globale wincaps to support Windows 8. (wincapc::init): Take Windows 8 into account. Set new has_gaa_largeaddress_bug member to false on 32 bit systems.
* * net.cc (call_gaa): New thread function to call GetAdaptersAddresses.Corinna Vinschen2012-03-081-15/+50
| | | | | (get_adapters_addresses): Call call_gaa. If necessary, call it as child thread. Explain why that's necessary.
* * cygtls.cc (dll_cmp): New comparison function for bsearch.Corinna Vinschen2012-02-271-12/+26
| | | | | | (well_known_dlls): New array containing well-known DLLs. (_cygtls::call2): Add code for BLODA detection. * net.cc (fdsock): Ditto.
* Clean up whitespace.Christopher Faylor2011-12-171-1/+1
|
* Throughout, remove extra space after function name from debugging output.Christopher Faylor2011-12-031-18/+18
| | | | | | | | | | | | | | | Throughout, change syscalls to report on return values using new %R format option. * smallprint.cc (__small_vsprintf): Add parsing for %R to report on return values and possible errno from syscalls. * errno.cc (errmap): Add PRIVILEGE_NOT_HELD. * fhandler_tty.cc (fhandler_pty_master::setup): When creating a thread use shorter name to reduce debuggging output. * select.cc (start_thread_pipe): Ditto. (start_thread_serial): Ditto. (start_thread_socket): Ditto. (start_thread_mailslot): Ditto. * sigproc.cc (talktome): Ditto.
* * net.cc (socketpair): Bind first socket to loopback only as well.Corinna Vinschen2011-10-051-1/+1
|
* * net.cc (cygwin_getsockopt): Drop erroneous double conversion of errorCorinna Vinschen2011-09-021-12/+3
| | | | code returned by SOL_SOCKET/SO_ERROR. Fix error handling.
* 2011-08-16 Pierre Humblet <Pierre.Humblet@ieee.org>Pierre Humblet2011-08-161-50/+17
| | | | | * net.cc (gethostby_helper): Remove DEBUGGING code from and streamline the second pass.
* * net.cc (socketpair): Release sb0 if there's no space left for sb1.Corinna Vinschen2011-08-041-0/+2
|
* Throughout change "WinSock" to "Winsock" in comments.Corinna Vinschen2011-07-291-5/+22
| | | | | | | | * fhandler_socket.cc (fhandler_socket::sendmsg): Add missing call to get_inet_addr to convert AF_LOCAL to AF_INET sockets. * net.cc (cygwin_socket): Workaround UDP Winsock problem. Add comment to explain why. * select.cc: Include winsock2.h rather than winsock.h.
* whitespace eliminationChristopher Faylor2011-06-061-6/+6
|
* * net.cc (fdsock): Drop setting uninterruptible_io to true.Corinna Vinschen2011-05-011-1/+0
|