diff --git a/COPYING b/COPYING index 1a88dcf..74fe22a 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Copyright (C) 1998-2018 Ivo Timmermans, Guus Sliepen and others. +Copyright (C) 1998-2010 Ivo Timmermans, Guus Sliepen and others. See the AUTHORS file for a complete list. This program is free software; you can redistribute it and/or modify it under diff --git a/ChangeLog b/ChangeLog index f2f43d9..859f691 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,2201 +1,12234 @@ -Version 1.0.35 October 05 2018 ------------------------------------------------------------------------- - -Guus Sliepen (12): - Prevent oracle attacks (CVE-2018-16737, CVE-2018-16738) - Prevent a MITM from forcing a NULL cipher for UDP (CVE-2018-16758) - Check the return value from snprintf(). - Check the return values from BN_hex2bn() and RAND_load_file(). - Fix all warnings when compiling with -Wall -W -pedantic. - Fix two small memory leaks. - Don't check for NULL-pointers before calling free(). - Update THANKS. - Fix checks for Cygwin-related macros. - Fix spelling errors. - Update README and links to required libraries. - Releasing 1.0.35. - -AMRI Amine (1): - Fixing typo - -Rafael Sadowski (1): - OpenBSD has a proper tap device. - -Version 1.0.34 June 12 2018 ------------------------------------------------------------------------- - -Guus Sliepen (10): - Add missing thanks to the NEWS message. - Fix building documentation when using OpenBSD's make. - Fix #ifdefs that were broken due to commit d178b58. - Don't use SOL_IP and SOL_IPV6. - Make systemd service file handling identical to tinc 1.1. - Rename distro/ to systemd/. - Document how to enable tinc at boot time using systemd. - Fix all spelling errors found by codespell. - Properly implement tinc.texi's dependency on tincinclude.texi. - Releasing 1.0.34. - -Maximilian Stein (1): - Fix SEGFAULT when trying to connect to IPv6 peer in non-IPv6 environment - -wangliushuai (1): - Remove redundant 'break'. - -Version 1.0.33 November 04 2017 ------------------------------------------------------------------------- - -Guus Sliepen (31): - Udpate THANKS. - Fix a potential memory leak. - Use AC_CONFIG_MACRO_DIR(). - Give absolute path for #include to AC_CHECK_HEADERS(). - Prepare for automatic code formatting using Artistic Style. - Never remove items from cmdline_conf. - Use stack-allocated strings for temporary filenames. - Fix a few minor memory leaks. - Remove unused/obsolete checks from configure.ac. - Use getcwd() instead of get_current_dir_name(). - Remove xmalloc.c, backport xalloc.h from tinc 1.1. - Update all header guards. - Convert sizeof foo to sizeof(foo). - Reformat all code using astyle. - Don't call ERR_remove_state(). - Unconditionally include stdbool.h and inttypes.h. - Remove more obsolete autoconf checks. - Remove obsolete m4/README. - Fix some "make distcheck" errors. - Add some information about the requirements of a chroot environment. - Handle tun/tap device returning EPERM or EBUSY. - Disable PMTU discovery when TCPOnly is used. - Fix all -Wall -W compiler warnings. - Realign comments. - Remove unused functions. - Ensure all parameters have names in header files. - Support autoconf's --runstatedir option. - Const correctness. - Fix compilation errors when --enable-uml is used. - Update THANKS. - Releasing 1.0.33. - -Rafael Sadowski (1): - fix tinc.conf for OpenBSD - -nemunaire (1): - Allow compilation from a build directory - -Version 1.0.32 September 02 2017 ------------------------------------------------------------------------- - -Guus Sliepen (13): - Don't dereference myself->incipher if it's NULL. - Merge remote-tracking branch 'VittGam/master' - Use /dev/udp instead of /dev/ip on Solaris. - Use getmsg()/putmsg() instead of read()/write() on Solaris. - Fix Solaris DeviceType = tap in router Mode. - Bind outgoing TCP sockets. - Move logging of "would block" messages to debug level 4. - Set KillMode=mixed in the systemd service file. - Don't forget about outgoing connections on host file read errors. - Fix Proxy = exec. - Set status.proxy_passed early for Proxy = exec. - Don't try to bind Proxy = exec sockets to an address. - Releasing 1.0.32. - -Vittorio Gambaletta (VittGam) (1): - route: Support ToS/DiffServ priority inheritance when routing IPv6 packets. - -Version 1.0.31 January 15 2017 ------------------------------------------------------------------------- - -Guus Sliepen (1): - Releasing 1.0.31. - -Élie Bouttier (1): - Remove ExecStop in tinc@.service - -Version 1.0.30 October 30 2016 ------------------------------------------------------------------------- - -Guus Sliepen (11): - Allow non-empty lines after status code from a HTTP proxy. - Fix proxy reply parsing broken by the previous commit. - Log only the first line of a proxy request rejection message. - Delay sending the real ID request until after a proxy request is granted. - Use AES256 and SHA256 by default, also for the meta-connections. - Enforce maximum amount of bytes sent/received on meta-connections. - Fix bit shifting arithmetic so the code actually does what the last commit message says. - Really fix byte budget calculation. - Use AES in CTR mode instead of OFB mode for meta-connections. - Use CFB mode for meta-connections to improve security. - Releasing 1.0.30. - -Version 1.0.29 October 09 2016 ------------------------------------------------------------------------- - -Guus Sliepen (11): - Preserve IPv6 scope_id in edges. - Ensure compatibility with OpenSSL 1.1.0. - Add -Wall to CFLAGS. - Check return value of RSA_generate_key_ex(). - Force nul-termination of strings after vsnprintf(). - Log warnings about dropped packets only with debug level 5 or higher. - Add a copy of ax_append_flag.m4. - Add ax_require_defined.m4. - Fix possibly unitialized variable. - Fix compiler warnings about format string errors on BSD. - Releasing 1.0.29. - -Version 1.0.28 April 10 2016 ------------------------------------------------------------------------- - -Guus Sliepen (8): - Fix compiling bsd/device.c on systems without utun. - Really remove use of __DATE__ and __TIME__ to facilitate reproducible builds. - Add systemd service files. - Update .gitignore. - Ensure the service files are in the tarball. - Explicitly mention that LibreSSL can be used as well. - Update links in the documentation. - Releasing 1.0.28. - -Version 1.0.27 April 10 2016 ------------------------------------------------------------------------- - -Guus Sliepen (26): - Add missing AM_PROG_CC_C_O to configure.ac. - Attribution for various contributors. - Update "now" after connect() when making outgoing connections. - Add ability to use proxies to connect to hostnames when there is no nameserver. - Only add a reflexive address when we're sure it's working. - Fix compatibility with TAP-Win32 9.0.0.21 and later. - Fix warnings from the Clang Static Analyzer. - Improve performance of edge updates. - Clarify that scripts are called synchronously. - Small fixes for the documentation. - Add warnings for bad combinations of Device and Interface. - Fix forwarding of edge updates. - Don't compile getopt*.c if the system provides getopt_long(). - Update .gitignore. - Update THANKS. - Use iface instead of interface. - Update copyright notices. - Remove use of __DATE__ and __TIME__ to facilitate reproducible builds. - Cast 0xff to char before comparing it to another char. - Get rid of a warning when compiling tinc using MinGW. - Every BSD flavor has a tap device nowadays. - Use devname() if available to support devfs cloning on BSD. - Use SIOCGIFADDR on BSDs that support it. - Enable silent builds by default. - Add support for OS X utun interfaces. - Releasing 1.0.27. - -Vittorio Gambaletta (VittGam) (6): - Fix DecrementTTL option. - Fix source IP address for ICMP unreachable packets generated by tinc. - Try to reply with node address only when decrementing the TTL. - Fix DecrementTTL option for packets destined to the local node. - s/broadcast_packet_helper/route_broadcast/ - Remove forward declaration for do_decrement_ttl. - -LunarShaddow (3): - fix typo - re-arrange include sequence to avoid a mingw introduced bug. - Proofing README. - -Florian Weik (1): - Fix NAME variable in subnet-* scripts for local subnets. - -Nathan Stratton Treadway (1): - Fix invalid checksum generation. - -Version 1.0.26 July 05 2015 ------------------------------------------------------------------------- - -Guus Sliepen (14): - Use VittGam's real name. - Attribution for Saverio Proto. - Always call res_init() before getaddrinfo(). - Fix --logfile without a filename on Windows. - Never call putenv() with data on the stack. - Return non-zero exit code when encountering configuration errors during startup. - Fix autoconf check for function attributes. - Fix spelling of FORTIFY_SOURCE. - Update copyright notices. - Attribution for various contributors. - Only check for -fno-strict-overflow if -fwrapv does not work. - Fix unputenv() on Windows. - Don't try to call res_init() if ./configure told us it doesn't exist. - Releasing 1.0.26. - -Jo-Philipp Wich (1): - fix musl compatibility - -Version 1.0.25 December 22 2014 ------------------------------------------------------------------------- - -Guus Sliepen (7): - Fix date of last NEWS entry. - Remember ToS/Diffserv priority for each socket individually. - Attribution for various contributors. - Automatically choose a tap device on Mac OS X when using switch Mode. - Update documentation for Mac OS X. - Check whether res_init() really lives in libresolv. - Releasing 1.0.25. - -Borg (3): - Fixed scripts calling under Win32. - Get MAC of TAP device. - Fixed tinc-up script calling on Win32. - -Alexis Hildebrandt (1): - Add support to link against libresolv Mac OS X - -Baptiste Jonglez (1): - Use the description from the 1.1 man page for the IndirectData option - -David Pflug (1): - Update README.android - -Jochen Voss (1): - Fix some typos in the manual. - -Tomislav Čohar (1): - Configure minimum reconnect timeouts. - -VittGam (1): - Support ToS/DiffServ priority handling for IPv6 meta and UDP connections. - -Version 1.0.24 May 11 2014 ------------------------------------------------------------------------- - -Guus Sliepen (13): - Remove useless variable 'hard' from try_harder(). - Merge pull request #14 from luckyhacky/master - Add an autoconf check for res_init(). - Nexthop calculation should always use the shortest path. - Fix issues found by Coverity. - Fix warnings found by GCC 4.9. - Fix a few more issues found by Coverity. - Fix a few more issues found by Coverity. - Drop h and hh length modifiers from printf format strings. - Fix a bug that could prevent tinc from starting correctly on Windows. - FIx the autoconf checks for res_init(). - Remove the warnings when IP_DONTFRAGMENT/IPV6-DONTFRAG is not supported. - Releasing 1.0.24. - -Steffan Karger (3): - Use constant time memcmp() when comparing packet HMACs. - Use cryptographically strong random when generating keys. - Check RAND_bytes() return value, fail when getting random fails. - -Armin Fisslthaler (1): - reload /etc/resolv.conf in SIGALRM handler - -Loic Dachary (1): - fix documentation typo - -luckyhacky (1): - update to openssl version 1.0.1g due to lack of heartbleed bug in prior version of openssl - -refs/tags/1.0.23-android-1 March 11 2014 ------------------------------------------------------------------------- - -Guus Sliepen (13): - Mention in the manual that multiple Address staments are allowed. - If no Port is specified, set myport to actual port of first listening socket. - Enable compiler hardening flags by default. - Update support for Solaris. - Include for PATH_MAX. - Stricter check for raw socket support. - Use hardcoded value for TUNNEWPPA if net/if_tun.h is missing on Solaris. - Fix incorrectly merged bits from 80cd2ff73071941a5356555b85a00ee90dfd0e16. - Don't enable -fstack-protector-all. - Remove or lower the priority of some debug messages. - Clarify StrictSubnets. - Attribution for various contributors. - Handle errors from TAP-Win32/64 adapter in a better way. - -Florent Clairambault (2): - Adding "conf.d" configuration dir support. - Adding some documentation around the /etc/tinc/$NET/conf.d directory. - -Vilbrekin (1): - Update android build instructions. Disable PIE as this is not supported on some devices. - -Version 1.0.23 October 19 2013 ------------------------------------------------------------------------- - -Guus Sliepen (9): - Check for writability when waiting for a socket to finish connecting. - Don't send PING requests on connections which are not active yet. - Fix segfault when Name = $HOST but $HOST is not set. - Fix typos in the documentation. - Modernize the build system. - Get rid of the splay tree implementation. - Add description of IffOneQueue and MaxTimeout to the info manual. - Clean up child processes from proxy type exec. - Releasing 1.0.23. - -Version 1.0.22 August 13 2013 ------------------------------------------------------------------------- - -Guus Sliepen (7): - Better optional argument handling. - Fix a typo. - Set $NAME when calling host-up/down and subnet-up/down scripts. - Don't use vasprintf() anymore on Windows. - Don't echo broadcast packets back when Broadcast = direct. - Update copyright notices. - Releasing 1.0.22. - -Etienne Dechamps (1): - Fix combination of Mode = router and DeviceType = tap on Linux. - -Version 1.0.21 April 22 2013 ------------------------------------------------------------------------- - -Guus Sliepen (2): - Drop packets forwarded via TCP if they are too big (CVE-2013-1428). - Releasing 1.0.21. - -Version 1.0.20 March 03 2013 ------------------------------------------------------------------------- - -Guus Sliepen (30): - Use /dev/tap0 by default on FreeBSD and NetBSD when using Mode = switch. - Document how to load the tap driver on FreeBSD. - Update THANKS file. - Also clarify hostnames=[yes|no] in tinc.conf(5). - Attribution for Vil Brekin and some code style cleanups. - Don't ignore Makefile.am. - Fix links in documenation. - Attribution for Martin Schürrer. - Add strict checks to hex to binary conversions. - Clear connection options and status fields in free_connection_partially(). - Fix warnings from cppcheck. - Clear Ethernet header when reading packets from a tun device. - Clear status and options fields of unreachable nodes. - Fix warnings from groff. - Using alloca() for a constant sized buffer is very silly. - Make sure PMTU discovery works in switch mode with VLAN tags. - Mention in the manual that support for LZO and zlib can be disabled. - Fix configure script help text for --enable options. - Don't take the address of a variable whose scope is about to disappear. - Send broadcast packets using a random socket, and properly support IPv6. - Remove text saying you must have one of PrivateKey or PrivateKeyFile in tinc.conf. - Fix support for tunemu on iOS devices. - Make sure PriorityInheritance also works in switch mode. - Detect increases in PMTU. - Fix a compiler warning. - Fix segmentation fault when trying to connect via a SOCKS5 proxy. - Don't send proxy requests for incoming connections. - Fix compiler warnings on Windows. - Fix detection of rejected SOCKS5 proxy requests. - Releasing 1.0.20. - -Vilbrekin (5): - Basic patch for android cross-compilation. - Replace hard-code with new ScriptsInterpreter configuration property. - Add basic .gitignore file, cleaning (most) files generated by autotools. - Use __ANDROID__ define rather than dirty hard-code to allow android NDK cross-compilation. - Android cross-compilation instructions. - -Martin Schürrer (1): - Output details of encryption errors - -Mesar Hameed (1): - Minor clarification, tinc.conf hostnames=[yes|no] variable only resolves names for logging purposes. - -Version 1.0.19 June 25 2012 ------------------------------------------------------------------------- - -Guus Sliepen (14): - Support :: in IPv6 Subnets. - Remove newline from log message. - Add support for systemd style socket activation. - Allow environment variables to be used for Name. - Allow broadcast packets to be sent directly instead of via the MST. - Add basic support for SOCKS 4 and HTTP CONNECT proxies. - Add support for SOCKS 5 proxies. - Add support for proxying through an external command. - Document new proxy types. - Small fixes in proxy code. - #include on Windows. - Fix compiler warnings. - Fix crash when using Broadcast = direct. - Releasing 1.0.19. - -Anthony G. Basile (1): - configure.in: fix AC_ARG_ENABLE and AC_ARG_WITH - -Michael Tokarev (1): - add (errnum) in front of windows error messages - -Version 1.0.18 March 25 2012 ------------------------------------------------------------------------- - -Guus Sliepen (13): - Always try next Address when an outgoing connection fails to authenticate. - Allow a port to be specified in BindToAddress statements. - Add support for multicast communication with UML/QEMU/KVM. - Set default value of DecrementTTL to "no". - Add #ifdefs in case not all platforms support IPv4 and IPv6 multicast. - Allow scoped addresses to be used for IPv6 multicast socket. - Fix compiler warnings. - Fix return value type of vde_send(). - Fix some more compiler warnings. - Document OpenBSD "ifconfig link0" and Linux "ip tuntap" commands. - Fix return type of vde_recv() as well. - Mark DecrementTTL option experimental. - Releasing 1.0.18. - -Version 1.0.17 March 10 2012 ------------------------------------------------------------------------- - -Guus Sliepen (32): - Prevent read_rsa_public_key() from returning an uninitialized RSA structure. - Return false instead of void when there is an error. - Fix compilation of VDE and UML interfaces. - Add vde/device.c to the tarball. - Fix a few small memory leaks. - Allow linking with multiple device drivers. - Set FD_CLOEXEC flag on all sockets. - Allow multiple BindToAddress statements. - Merge branch 'master' of black:tinc - Send packets back using the same socket as they were received on. - Allow setting DeviceType to tun or tap on Linux. - Merge branch 'master' of black:tinc - Only compile raw socket code when it is supported on that platform. - Decrement TTL of incoming packets. - Don't bind outgoing TCP sockets anymore. - Rename connection_t *broadcast to everyone. - Allow disabling of broadcast packets. - Move initialization of char *priority up to prevent freeing an uninitialized pointer. - Document the command line flag -o and provide --option as well. - Fix a bug that caused tinc to ignore all but the last listening socket. - Fix check for raw socket support. - Pass index into listen_socket[] to handle_incoming_vpn_data(). - Add LocalDiscovery option which tries to detect peers on the local network. - Don't send ICMP Time Exceeded messages for other Time Exceeded messages. - Stricter checks against routing loops. - Only use broadcast at the start of the PMTU discovery phase. - Only log errors sending UDP packets when debug level >= 5. - Accept Subnets passed with the -o option when StrictSubnets = yes. - Add missing ICMP6 message type definitions. - Make sure disabling old RSA keys works on Windows. - Update copyright notices. - Releasing 1.0.17. - -Nick Hibma (1): - Add missing ICMP message type definitions. - -Version 1.0.16 July 23 2011 ------------------------------------------------------------------------- - -Guus Sliepen (4): - Make code to detect two nodes with the same Name less triggerhappy. - Flush output buffer in send_tcppacket(). - Use usleep() instead of sleep(), MinGW complained. - Releasing 1.0.16. - -Version 1.0.15 June 24 2011 ------------------------------------------------------------------------- - -Guus Sliepen (9): - Reorder checks for libraries to allow ./configure LDFLAGS=-static. - Make return value of SetPriorityClass() behave the same as setpriority(). - Fix sparse warnings and add an extra sprinkling of const. - Remove newlines from log messages. - Remove a few unnecessary #includes. - Attribution for Loïc Grenié. - Improved --logfile option. - Remove redundant @CFLAGS@ from AM_CFLAGS. - Releasing 1.0.15. - -Loïc Grenié (1): - Nearly tickless tinc. - -Version 1.0.14 May 08 2011 ------------------------------------------------------------------------- - -Guus Sliepen (48): - Fix reading configuration files that do not end with a newline. Again. - Define WINVER before including any other header file on Windows. - Use intptr_t instead of long to store a pointer. - OpenSSL 1.0.0 compiled for 64 bit Windows requires linking with -lcrypt32. - Fix all warnings when compiling with mingw64. - Use strrchr() insteaad of rindex(). - Detect and prevent two nodes with the same Name being on the VPN simultaneously. - Use 64 bit counters to keep track of bytes sent/received from the virtual network interface. - Do not append an address to ANS_KEY messages if we don't know any address. - Merge local host configuration with server configuration. - Remove duplicate command-line option parsing. - Attribution for Julien Muchembled. - Attribution for Timothy Redaelli. - Ensure there is a newline character before a PEM key is written. - Abort disabling old PEM keys on I/O errors. - Remove unused variables. - Quit when there are too many consecutive errors on the tun/tap device. - Read error counter must be static. - Add short options -R and -U to the tincd(8) manpage. - Don't use strlen() on a NULL pointer. - Provide usleep() for Windows. - Use variable length arrays instead of alloca(). - Fix warning message when setting SO_RCVBUF or SO_SNDBUF fails. - Free replay window when freeing a node_t. - Fix variable length array declaration. - Attribution for Brandon Black. - Use setpriority() instead of nice() on UNIX-like systems. - Always send MTU probes at least once every PingInterval. - Close all filedescriptors in Solaris close_device(). - Limit field width when scanning PID file. - Replace bogus #else with #endif. - Remove unused variables. - Document the behavior of "-n." - Update the manual. - Update the NEWS. - Proper check and dropin replacement for usleep(). - Fix typo spotted by Andrew Scheller. - Add support for VDE through libvdeplug. - Fix spurious misidentification of incoming UDP packets. - Prevent anything from updating our own UDP address. - Do not set indirect flag on edges from nodes with multiple addresses. - Increase threshold for detecting two nodes with the same Name. - Always use the default signal handler for ABRT signals. - Check for EVP_EncryptInit_ex instead of SHA1_Version in OpenSSL. - Update THANKS and copyright information. - Ensure proper linking with OpenSSL with recent versions of MinGW. - Include when using intptr_t. - Releasing 1.0.14. - -Brandon L Black (4): - Experimental IFF_ONE_QUEUE support for Linux - Configurable SO_RCVBUF/SO_SNDBUF for the UDP socket - Configurable ReplayWindow size, zero disables - Improved handling of queue-jumping packets on receive - -Julien Muchembled (2): - New '-o' option to configure server or hosts from command line - Fix command-line '-o' option for host configuration - -Timothy Redaelli (2): - Fix warnings showed using -D_FORTIFY_SOURCE=2 - Fix warnings under BSD - -Michael Tokarev (1): - Treat netname="." in a special way. - -Rumko (1): - DragonFlyBSD support - -Version 1.0.13 April 11 2010 ------------------------------------------------------------------------- - -Guus Sliepen (20): - Clamp MSS to miminum MTU in both directions. - Simplify reading lines from configuration files. - Check for dirent.h. - Preload all Subnets in TunnelServer mode. - Add the StrictSubnets option. - Add the Forwarding option. - Add the DirectOnly option. - Fixes for the Forwarding option. - ConnectTo does not mean tinc does not listen for incoming connections anymore. - Log unauthorized Subnets when StrictSubnets is set. - Fix typo. - Convert Port to numeric form before sending it to other nodes. - Ensure ICMP_NET_ANO is defined. - Reload Subnets when getting a HUP signal and StrictSubnets is used. - Fix reloading Subnets when StrictSubnets is set. - Ensure subnet-up/down scripts are called after HUP when necessary. - Fixes for definitions under Windows. - Don't redefine MAX if it already exists. - Mark Forwarding and DirectOnly options as being experimental. - Releasing 1.0.13. - -Timothy Redaelli (2): - Add --disable-lzo configure option - Add --disable-zlib configure option - -Sven-Haegar Koch (1): - Never delete Subnets when StrictSubnets is set - -Version 1.0.12 February 03 2010 ------------------------------------------------------------------------- - -Guus Sliepen (21): - When learning MAC addresses, only check our own Subnets for previous entries. - Remove unused variable in lookup_subnet_*() functions. - Forget addresses of unreachable nodes. - Do not fragment packets smaller than RFC defined minimum MTUs. - Allow port to be specified in Address statements. - Use xstrdup() instead of xasprintf() to copy static strings. - Allow Port and PMTUDiscovery options in tinc.conf, always enable PMTUDiscovery by default. - Clamp MSS of IPv4 SYN packets. - Ping nodes immediately when receiving SIGALRM. - Optimise handling of select() returning <= 0. - Also clamp MSS of TCP over IPv6 packets. - Make MSS clamping configurable, but enabled by default. - Fix subnet-up/down scripts being called with an empty SUBNET. - Run subnet-up/down scripts for local MAC addresses as well. - Be liberal in accepting KEY_CHANGED/REQ_KEY/ANS_KEY requests. - Determine peer's reflexive address and port when exchanging keys. - Immediately exchange keys when establishing a meta connection. - Try to set DF bit on BSDs as well. - Update copyright notices. - Ensure peers with a meta connection always have our key. - Releasing 1.0.12. - -Version 1.0.11 November 01 2009 ------------------------------------------------------------------------- - -Guus Sliepen (16): - Fix a possible crash when sending the HUP signal. - Starting to work towards 1.0.11. - Handle weighted Subnets in switch and hub modes. - Clarify and increase level of log message about MTU probes to unreachable nodes. - Add dummy device. - Use uint32_t instead of long int for connection options. - Allow UDP packets with an address different from the corresponding TCP connection. - Always reply to MTU probes via UDP. - Make maxmtu equal to minmtu when fixing the path MTU to a node. - Forward packets to not directly reachable hosts via UDP if possible. - Use IP_DONTFRAGMENT instead of IP_MTU_DISCOVER on Windows. - Use WSAGetLastError() to determine cause of network errors on Windows. - Move socket error interpretation to utils.h. - Fast handoff of roaming MAC addresses. - Start a tinc service if it already exists. - Releasing 1.0.11. - -Michael Tokarev (1): - Remove localedir leftovers. - -Version 1.0.10 October 18 2009 ------------------------------------------------------------------------- - -Guus Sliepen (78): - Update documentation for git. - Consistently allocate device and iface variables on the heap. - Only send packets via UDP if UDP communication is possible. - Move free()s at the end om main() to the proper destructor functions. - Change flush_events() to expire_events(). - Add missing cleanup functions in close_network_connections(). - Use a global list to track outgoing connections. - Remove unused definitions from net.h. - Allow reading config files with CRLF endings on Unix systems. - Validate Name before using it in a filename when generating a keypair. - Disable old RSA keys when generating new ones. - Handle neighbor solicitation requests without link layer addresses. - Allow weight to be assigned to Subnets. - Update THANKS and copyright information. - Disable PMTUDiscovery in switch and hub modes. - Use a simple Random Early Drop algorithm in send_tcppacket(). - Handle UDP packets from different and ports than advertised. - If PMTUDiscovery is not set, do not forward packets via TCP unnecessarily. - Fix link to Mattias Nissler's tun/tap driver for MacOS/X. - Fix initialisation of packet decryption context broken by commit 3308d13e7e3bf20cfeaf6f2ab17228a9820cea66. - Use xrealloc instead of if(ptr) ptr = xmalloc(). - Add declaration for sockaddrcmp_noport(). - Use packet size before decompression to calculate path MTU. - Do not forward broadcast packets when TunnelServer is enabled. - Add ProcessPriority option. - Add some const where appropriate. - Properly set HMAC length for incoming packets. - Don't try to send MTU probes to unreachable nodes. - Remove pending MTU probe events when a node's reachability status changes. - Do not log errors when recvfrom() returns EAGAIN or EINTR. - Change level of some debug messages, zero pointer after freeing hostname. - Always remove a node from the UDP tree before freeing it. - Add xasprintf() and xvasprintf(). - Check the return value of fscanf() when reading a PID file. - Replace asprintf() by xasprintf(). - UNIX signal numbers start at 1. - Ensure tinc compiles with gcc -std=c99. - Convert bitfields to integers in a safe way. - Add the GPL license to the repository. - Another safe bitfield conversion. - Add support for iPhones and recent iPods. - Don't stat() on iPhone/iPod. - Put Subnet weight in a separate environment variable. - Allow PMTUDiscovery in switch and hub modes again. - Handle unicast packets larger than PMTU in switch mode. - Remove superfluous call to avl_delete(). - Apparently it's impolite to ask GCC to subtract two pointers. - Use only rand(), not random(). - Also do not use drand48(), it is not available on Windows. - Allow compiling for Windows XP and higher. - Remove dropin random() function, as it is not used anymore. - Use access() instead of stat() for checking whether scripts exist. - Raise default crypto algorithms to AES256 and SHA256. - Remove extra {. - Use a mutex to allow the TAP reader to process packets faster on Windows. - Raise default RSA key length to 2048 bits. - Send large packets we cannot handle properly via TCP. - Update copyright information. - Remove all occurences of $Id$. - Remove Ivo's old email addresses. - Update the address of the Free Software Foundation in all copyright headers. - K&R style braces. - Remove checkpoint tracing. - Drop support for localisation. - Add more authors to the copyright headers. - Update the NEWS. - Remove autogenerated files from EXTRA_DIST. - Don't disconnect clients in TunnelServer mode who send unauthorised ADD_SUBNETs. - Remove code duplication when checking ADD_EDGE/DEL_EDGE messages. - Revert "Raise default crypto algorithms to AES256 and SHA256." - Ensure that the texinfo manual can be converted to HTML. - Small updates to the documentation. - Use MTU probes to regularly ping other nodes over UDP. - Allow the cloning /dev/tap interface to be used on FreeBSD and NetBSD. - Remove debugging message when reading packets from a BSD device. - Include missing header. - Fix description of the WEIGHT environment variable. - Releasing 1.0.10. - -Michael Tokarev (17): - Allow tunnelserver to work with clients that have other peers. - Enable PMTUDiscovery only if BOTH sides wants it. - Rename setup_network_connections() and split out try_outgoing_connections() - Implement privilege dropping - bugfix: initialize pid (as read from pidfile) to zero - bugfix: move mlock to after detach() so it works for child, not parent - bugfix: chdir(/) after chroot - change error messages in droppriv code to match the rest - format 'not supported on this platform' error message - TunnelServer: Don't disconnect client on DEL_SUBNET too - ignore indirect edge registrations in tunnelserver mode - don't log every strange packet coming to the UDP port - Fix ans_key exchange in recent changes - tunnelserver: log which ADD_SUBNET was refused - cleanup setpriority thing to make it readable - try outgoing connections before chroot/drop_privs - Remove extra semicolon in my definition of setpriority() - -Florian Forster (2): - src/linux/device.c: Fix segfault when running without `--net'. - src/net_socket.c: Bind outgoing TCP sockets to `BindToAddress'. - -Borg (1): - Removed last gettext function. - -Version 1.0.9 December 26 2008 ------------------------------------------------------------------------- - -Guus Sliepen (18): - Handle SERVICE_CONTROL_INTERROGATE requests. Thanks to Carsten Ralle for noticing this. - Make sure the prefixlength of subnets is sane. - Fix reading configuration files that do not end with a newline. - Do not try to send REQ_KEY or ANS_KEY requests to unreachable nodes. - Prevent freeing a NULL pointer when a hostname is unresolvable. - Correct debug message. - Treat virtual network device as tap if Mode = switch or hub. - Use TUNIFHEAD by default on FreeBSD to make sure IPv6 works. - Make sure IPv6 sockets are IPv6 only. - Update Dutch translation. - Update copyright information. - Enable PMTU discovery by default. - Update documentation. - Update the manpage as well, and some whitespace to make its source more legible. - Handle broadcast and multicast packets in router mode. - Apply patch from Max Rijevski fixing a memory leak when closing connections. - Add missing parentheses in check for IPv4 multicast addresses. - Releasing 1.0.9. - -Version 1.0.8 May 16 2007 ------------------------------------------------------------------------- - -Guus Sliepen (8): - Apply patch from Scott Lamb preventing an infinite loop when sending SIGALRM. - Apply patch from Scott Lamb fixing some memory and resource leaks. - Close the proper filedescriptor (if it exists). - Apply patch from "dnk" making sockets non-blocking under Windows. - Make sure connection->name is never NULL. - Update dutch translation. - Don't free struct addrinfo too early. Spotted by Christian Cier-Zniewski. - Releasing 1.0.8. - -Version 1.0.7 January 05 2007 ------------------------------------------------------------------------- - -Guus Sliepen (7): - Use a ringbuffer in shared memory to transfer packets from the tapreader thread to the main thread. - Tapreader socket should be bound to localhost only. - Fix generic BSD tun device to write only the actual packet length. - rename() cannot replace existing files on Windows. - No things to do for the 1.0 branch except bugfixing. - Update copyright notices. - Releasing 1.0.7. - -Version 1.0.6 December 18 2006 ------------------------------------------------------------------------- - -Guus Sliepen (13): - Make sure resolved addressed for outgoing connections are freed, if there are any. - Search for lzo/lzo1x.h, lzo2/lzo1x.h and lzo1x.h. - When building the minimum spanning tree, make sure we start from a reachable node. - Use the correct next pointer. - Remove unnecessary stuff from configure.in. - Remove old Spanish translation. - Fix rule that creates html version of manpages. - Use standard autoconf macros instead of our own. - We do properly check for malloc and realloc. - Remove the test for linux/if_tun.h. - Do a simple test for linux/if_tun.h instead of no test at all. - Prevent compiler warnings about redefinition of EAI_FAMILY on FreeBSD 6.1. - Releasing 1.0.6. - -Version 1.0.5 November 14 2006 ------------------------------------------------------------------------- - -Guus Sliepen (32): - Prevent possible buffer overflows when using very large (>= 8192 bit) RSA keys. - Add alloca.h to the list of necessary header files. - Enable OpenSSL ENGINE, so crypto hardware gets used. Thanks to Andreas van Cranenburgh. - EVP_Cleanup() when quitting. - Apply patch from Scott Lamb unifying configuration of TCP socket options. - Apply patch from Scott Lamb adding an output buffer for the TCP sockets. - Make sure $NAME is set correctly when executing tinc-down script. - Missing #include. - Export flush_meta(). - Fix signedness compiler warnings. - Fix a bug in handling prefixlengths that are not a multiple of 4. - Update copyright notices, remove Ivo's email address. - Restore length of the original packet in send_udppacket(). - Use memcpy() to copy sockaddrs returned by getaddrinfo(). - Add generic host-up and host-down scripts. - Do not break strict aliasing of status_t structs. - Fix format string warnings. - Remove unused variables. - Remove unused parameter from maskcmp(). - Remove unused variable. - memcpy() addresses from packet headers before calling the lookup functions. - The "active" bit in node.status is not used. - Added graph dumping ability based on Markus Goetz's patch. - popen() requires pclose(). - Support and autodetect LZO version 2.0 and later. - Support and autodetect LZO version 2.0 and later. - Document GraphDumpFile option. - Update Dutch translation. - Nodes use events, so event system should be initialised first and destroyed last. - When deleting an entire tree, start at head, not at root. - EWOULDBLOCK does not exist on platforms without O_NONBLOCK - Releasing 1.0.5. - -Version 1.0.4 May 04 2005 ------------------------------------------------------------------------- - -Guus Sliepen (17): - Make sure broadcast packet reach the local network interface. - Fix splay tree code. - subnet-up/down hooks - subnet-up/down hooks, use list_t for the todo list. - Small fix. - Free memory used by connection_t after it is deleted from the connection tree. - Use the proper free function. - Correct size argument for strncat(). - Nodes should only be in the node_udp_tree if they are reachable. - Don't try to add a non-existing node back to the node_udp_tree. - Remove unused (and potentially segfaulting) net2str() call. - Be on the safe side with initialisation of c->name. - Searching through splay trees may change the tree variable. - Several splay tree fixes. - Describe subnet-up/down scripts in documentation. - Update copyright notices. - Releasing 1.0.4. - -Version 1.0.3 November 11 2004 ------------------------------------------------------------------------- - -Guus Sliepen (77): - Removed items in TODO list that are already implemented. Only two items - Applied patch from Jamie Briggs for bash2 conformance. - Added another semicolon for bash2 compliance (thanks to Jamie Briggs) - Adding even more stuff from the CABAL branch. - Synchronise HEAD with CABAL branch. - This will become 2.0. - Some device.c files weren't synchronised. - Makevars file was accidentily removed. - Forgot to synchronise po/ directory... - Add description of new authentication scheme. - Add Opaque option which prevent information from being forwarded to certain nodes. - Replace Opaque and Strict options with a TunnelServer option. - Complain if pid file cannot be created. - Read MaxTimeout from tinc.conf like the manpage says. - Missing space between words. - Don't retry if configuration is wrong from the beginning. - Fix proxy-neighborsolicitation. - Code beautification, start of multicast support. - Forget multicast. Always inline some function. - Let tinc figure out the exact MTU of the link. - More sensible name, and try to set PMTU discovery on IPv6 sockets as well. - Describe the TunnelServer and PMTUDiscovery options. - Better name, show probed MTU in dump. - Improvements for PMTU discovery and IPv4 packet fragmentation. - Missing definitions. - Small fixes for PMTU discovery. - Don't forget to update destination MAC address. - Small updates. - Remove autogen.sh, the autoreconf program does exactly that. - Replace cvs-clean with a much better svn-clean. - Remove CVS related cruft. - Eat trailing whitespace in config files. - Only read our public key if it wasn't already in the private key file. - Updating dutch translation. - Even better svn-clean command. - Applied Martin Kihlgren's IdentityGenerosity patch, - Fix declaration of update_node_address(). - Use Subversion to create ChangeLog, better svn-clean rule. - Revert Martin Kihlgren's patch, it doesn't work the way it should. - Move CABAL branch to its rightful place: the trunk. - Update copyrights, links, email addresses and let Subversion update $Id$ keywords. - Increase MTU by 4 bytes to allow VLAN tagged Ethernet frames in hub and switch mode. - Clean up environment after executing scripts. - Handle timeouts during connecting the same way as other errors. - Added UML network socket handling. - Don't set $INTERFACE automatically, don't quit on EINTR/EAGAIN. - Marking potential late packets was in the wrong place. - Remove duplicate #include "system.h" - Move all #ifdef HAVE_HEADER_H #include to have.h, - Fix several #includes. - strndupa() is too arcane for some environments. - Allow tinc to work with the latest TAP-Win32 driver. - Correct return value. - Don't let tinc service depend on NDIS component. - Support alternative tun/tap driver from http://www-user.rhrk.uni-kl.de/~nissler/tuntap/ - Generic device driver for *BSD and MacOS/X - static - Check for sys/uio.h, net/if_tun.h and net/if_tap.h - Don't include .svn directory in sample configuration. - Splay trees. - Hoopjumping to get the default directories in the manuals properly. - Update to make it compile again. - Fixed another bug in late packet handling. - Hopefully this really fixes late packet handling. - Missing check for NULL-pointer. - Use the generic BSD tun/tap code. - Fix order of arguments for tar. - Let compiler decide when to inline. - Support tunneling IPv6 on Solaris. - Add BlockingTCP option, useful when using TCPOnly on slow or congested links. - Update documentation. - Set BSD tuns to broadcast mode. On OpenBSD, this enables IPv6 on the tun device! - Remove duplication. - Updated dutch translation. - Short readme about how to compile tinc from a Subversion checkout. - Add more people who have contributed to tinc. - Releasing 1.0.3. - -Ivo Timmermans (52): - Check for __gmpz_powm for libgmp3. - Changed version number to 1.0pre3. - Autogenerated by gettextize. - Bring head revision up to date with cabal (try #3) - Add check for the syslog function - Generalized error handling functions - Add all the new files to the sources list for the utility library - New function: xalloc_and_zero() - Generalized list and hash handling functions - First try to create a graphical frontend for tinc configuration - Updating HEAD branch #1; removing obsolete files. - Updating HEAD branch #2; removing debian/ dir. - Updating HEAD branch #3; more obsolete files removed. - Updating HEAD branch #4; Merging CABAL -> HEAD. - Updating HEAD branch #5; Last files from CABAL. - Ok, I forgot these ;) - More updates - More... - Last bits (hopefully) - Main pokey interface files. - Pokey interface definition - Write src/pokey/Makefile - Also compile in pokey/ - Remove debug level declaration - Update copyright info - Remove debug_lvl - New logging system to replace syslog() calls with a generic function. - Rename log_message to log - Add syslog() wrapper - Add syslog wrapper - Some magic - Added priority definitions from syslog.h - log_default_hook was renamed to log_default - Added prototype for log_syslog - Use logging.h instead of syslog.h - Compile in logging.c - Things to ignore... - Use new logging system - Include logging.h - Renamed libvpn to libtinc - Rename libvpn to libtinc - ... - Print newline when writing to stderr - *** empty log message *** - Moving files, first attempt at gcrypt compatibility, more interface - Commit diff test - Another file moved; random interface stuff. - Callbacks - Moved event.c/h - test - test 2 - Hm. - -Wessel Dankers (5): - Initial revision. Lots of loose ends, not usable yet. - added bit on config file, split up sections, added Id: tag - Added extra bit about keys. - More about keys - This file is now only in the CABAL revision. - -cvs2svn (1): - This commit was generated by cvs2svn to compensate for changes in r1352, - -Version 1.0.2 November 08 2003 ------------------------------------------------------------------------- - -Guus Sliepen (47): - Simplify fake getname/addrinfo() functions, possibly fixing freeing a NULL pointer. - stat() batch files under Windows. - Don't getsockopt() SO_ERROR. We get the error from send()/recv() anyway. - Fix fake getnameinfo() and check more arguments. - Fix --logfile under Windows. - Use the event log under Windows. - Compilation fix. - Do what the SDK documentation tells. - If we're not in main_loop() and the service is stopped, exit immediately. - Allow tinc to handle unknown type addresses from other tinc daemons. - Don't overwrite the first " when installing a service. - Add checkpoints. - When purging nodes, only delete them if nobody references them anymore. - Remove debug message. - Add license exception from Markus Oberhumer. - Remove old edges from unreachable nodes to us. This prevents the hosts/NAME-up - We don't have to tell GCC how to cast. - Prevent multiple inclusions. - Remove pidfile when exitting. - Update translations. - Check for short packets from the tun/tap device and from other tinc daemons. - Generate keys with 0x10001 as public exponent, which has less prime factors - Better length checks. - Copy structs from packets to the stack before using them, to prevent - const - Ethernet protocol types. - Unused variable in struct. - Don't confuse users with "Address family not supported" warnings. - Use CPPFLAGS, LDFLAGS and LIBS as appropiate. - PIDs are of type pid_t, and use %ld when reading/writing them to the pidfile. - Make sure type of AF_UNKNOWN is sa_family_t. - Forgot to #include "xalloc.h" - Update missing definitions, structs describing headers get __packed__ attribute. - Missing declaration. - Set media status for newer TAP-Win32 driver. - Some platforms don't know sa_family_t or define it other than uint16_t. - Update documentation. - Fix ASCII art. - Check return value of EVP_* functions, and check if length before en/decryption - Check all EVP_ function calls. - Parentheses in the wrong spots. - Fix bug that could lead to an assertion failure in libcrypto when multiple - Small fixes in documentation. - Fix another bug in meta.c. - Update dutch translation. - Add missing definitions. - Release notes for 1.0.2 - -Version 1.0.1 August 14 2003 ------------------------------------------------------------------------- - -Guus Sliepen (24): - Windows uses backslashes... - Tell windows to be patient. - Remove unused stuff from doc/. - Correct error message when remote host closed connection. - Simplify execute_script(). It will probably work under Windows as well. - Allow empty lines in config files. - Make rule for sample-config.tar.gz. - Readd quotes. - Typo. - Better error messages under Windows. - Log error first, try to close later. - Quote when needed and don't try stuff that doesn't work under Windows. - Under Windows, the installation directory can be found in the registry. - Better error checking and reporting. - Small things. - Simpler checking of permissions on private RSA key and other fixes. - Check for fchmod(). - Only system() needs script name quoted. - Update documentation. - Add a description for the Service control panel. - Updated dutch translation. - Small fixes. - Fix permissions check for rsa_key.priv. - Update. - -Version 1.0 August 08 2003 ------------------------------------------------------------------------- - -Guus Sliepen (111): - Thank some more people. - Run graph() after edge_del() when updating an edge. - Add documentation for BindToAddress. - Fix PriorityInheritance. - PrivateKeyFile instead of PrivateKey. - Run graph algorithm when replacing a second connection from the same host - Add $NAME for tinc-up/down scripts. - - Fix indentation in some places. - Various fixes for autoconf and OpenSSL 0.9.7 and a missing header. - Make sure send_meta() writes everything. - Typo. - - Avoid memory leak caused by OpenSSL 0.9.7a. - - Speed up checksumming - Don't copy more than necessary. - Checksums must also work for uneven number of bytes. - HUP signal now closes connections to hosts if their host config file is - Better handling of late packets. - Make sure outgoing_t is completely freed. - - Per-node EVP_CIPHER_CTX to avoid initialisation overhead. - Small fixes to make LZO compression work. - Small fixes. - Fix links. - Fix warning and add missing checks for LZO library. - Call make_names() before doing anything else. - If we have a Linux tun/tap device and we are in router mode, open the device - AddressFamily is "any" by default. - Remove mymac stuff from device.c. - Fixes from Wessel Danker's libavl. - More braces to make gcc happy. - Update documentation. - Update dutch translation. - Typo and conversion to UTF-8. - There are two lzo compression levels. - Really make tinc default to any addressfamily. - This subtle pointer arithmetic thingy is (I'm very sure of it) the cause - - simplify configure.in - Check for IPv6 header files. - Define logger(), cleans up source code and allows us to write log entries - Sprinkling the source with static and attributes. - Provide all missing IPv6 definitions in lib/ipv6.h. - Actually add ipv6.h. - More missing definitions. - More missing IPv6 definitions and autoconf checks to make sure it compiles - Simplify logging, update copyrights and some minor cleanups. - Update copyrights. - Removing distribution specific files from CVS. - Format string checking for logger(). - Export mymac. - Make use of the CIPE driver. Woohoo, tinc for Windows! - Windows headers declare a struct interface somewhere. - Big header file cleanup: everything that has to do with standard system - Even more missing definitions. - Remove all #ifndefs from route.c - Update all device.c files. - Check for ethernet/ipv4/ipv6 related structures. - Use iface instead of interface because it might already be declared in - Oops. - No UNIX style permissions under Windows. - Be consistent. - Oops. - Check for sys/mman.h. - Use functions from logger.c - Copy cygwin driver to mingw directory. It doesn't work (yet). - Add section about configuring Cygwin and CIPE on Windows. - Option to specify pidfile location. - Use bools and enums where appropriate. - Run setup_device() after parsing configuration but before claiming we're ready. - Don't initialise a CIPHER_CTX if cipher == NULL. - Sprinkle around a lot of const and some C99 initialisers. - More generic handling of tap device under Windows. - More checks for missing functions. - Fix compile errors and warnings. - Update dutch translation and make sure all device drivers are included in - Update configure scripts. - Make sure it works. - Make sure (at least) the MinGW device driver works. - Native Windows support. - Cleanups. - Update documentation and remove stuff that's too outdated. - Remove doc/es/ and src/device.c from the distribution. - No C99 initialisers, gcc 2.95.3 doesn't like it. - Replacement for stdbool.h - Prevent definitions from messing up attributes. - Check if the compiler knows about the __malloc__ attribute. - Wrong argument. - Remove forgotten braces. - No easy way to properly detect header files... - Woops! - Wrong function... - Prevent system headers from including our own headers. - Allow whitespace in values. - Oops. - Windows has no symbolic links as we know it. - When compiling with MinGW, link with ws2_32. - Install tinc as a service under Windows (MinGW). Remove cleanup_and_exit(), - Error messages. - Cleanups and error messages. - Missing include. - Oops. - Updated dutch translation. - Explain how tinc detaches and how it is "killed" under Windows. - Typo and another thing to think about. - Clean up last part of main(). - Old gcc compilers don't like declarations in the middle of a function. - Cygwin needs windows.h. - Keep Windows happy. - Remove newlines from log messages. - Update dutch translation - Simplify translation - Use our own port when connecting to ourself. - Sync CABAL branch with release-1_0 branch. - -Ivo Timmermans (2): - Fix saving of debug level for startup level 0 - Call RSA_blinding_on(), as advised in the paper on - -Wessel Dankers (1): - its: Engels voor "van het" - 3e persoon enkelvoud, genitief, onzijdig - -Version 1.0pre8 September 16 2002 ------------------------------------------------------------------------- - -Guus Sliepen (73): - Support for MaxOS/X. - Add BindToAddress variable, similar to the late BindToIP. - Added Nick Patavalis for his RedHat package. - Informative log message if execl() failed. - Fix very stupid bug in node_del(), which might have caused corruption of - Only purge once when there are no more connections. - Support RSA_PUBKEYs (as opposed to RSAPublicKeys) so tinc accepts - Make it work correctly with NetBSD tun device. - Use correct includes on NetBSD. - Cleanup: - Use inttypes.h instead of stdint.h. - - netinet/* include files depend on netinet/in_systm.h. - Added Darwin (MacOS/X) tun device handling. - Use darwin/device.c when compiling on MacOS/X. - Include darwin/device.c in distribution. - Autoconf cleanup. Works for both 2.13 and 2.53, although running autoconf - Add configuration details for NetBSD and Darwin (MacOS/X). - Reset listen_sockets after SIGHUP. - Update comments about IPv6 autoconfiguration. - s/sliepen.warande.net/sliepen.eu.org/g - Fix for prefixlengths of 32 (IPv4) and 128 (IPv6) bits. - Allow list of environment variables to be passed to execute_script(). - Allow identical subnets from different owners. - Clear subnets before using them. - Started port to Cygwin. - Added stub device.c for Cygwin. - Include complete fake-getname/addrinfo from OpenSSH. - Allow tincd to be locked into main memory. - Don't bother to chown, and correctly document ConnectTo. - Added support for raw sockets. This can be used instead of tun/tap devices. - Gettext 1.11.5 compatibility. - Check for ranlib. - Replacement for the current routing algorithm. - Make sure setlocale() is available. - Drop graph and edge stuff. Use new node stuff instead. - A reachable node is always more preferable to an unreachable one... - Woops. - Reduce KEY_CHANGED traffic. - Prevent looping DEL_NODE/ADD_NODE messages after a node disconnects. - Don't forget to set prevhop to myself for new connections. - Just ignore wrong ADD_NODEs instead of replying with a DEL_NODE, in the - Revert to edge and graph stuff. This time, use a directed graph. - Small fixes. - Generalized request broadcasting/forwarding. - Updated dutch translation. - Small updates. - Run autopoint and libtoolize before creating initial makefiles. - Add missing headers. - Typo. - Only reset seqno's when a key is sent or received. - Remove global edge_tree. - edge_weight_compare() shouldn't rely on edge_compare(). - Reset the *correct* seqnos. - Fix MST algorithm. - Why don't these connection_t's get cleaned up? - Cleanups: - Switch to K&R style indentation. - Switch to K&R style indentation. - Remove redundant spaces. - Let GCC check format string and arguments of send_request(). - Fix compiler warnings. - Clean up after indent. - Link with libintl if necessary. - Fix placement of #include "config.h" - Make sure malloc() is declared. - What was I thinking? - MacOS/X needs #define _P1003_1B_VISIBLE in order to use mlockall(). - port_t isn't used anymore and conflicts with MacOS/X headers. - Small fixes so tinc compiles out of the box on SunOS 5.8 - Updated dutch translation. - Use /dev/net/tun as default for tun/tap device under Linux. - Update documentation. - Remarks about 1.0pre8 release. - -Ivo Timmermans (9): - Put #ifndef checks for HAVE_RAND_PSEUDO_BYTES in the correct places. - Typo - OSX support - getnameinfo fixes - Add /sw/{include,lib} to search paths if they exist - Include a few more header files - Include netbsd's device.c in make dist - Added Alessandro Gatti - Added AM_MAINTAINER_MODE - -Wessel Dankers (1): - This should work much better. - -Version 1.0pre7 April 09 2002 ------------------------------------------------------------------------- - -Guus Sliepen (9): - Make configure --help output look nicer. - Don't check_network_activity() if select() is interrupted by a signal. - check_rsa() is broken, I don't know why, just remove it for now. - Fix maskcheck() and maskcmp(). - Automake forgets about depcomp, remind it. - masklength is better known as prefixlength. - masklength is better known as prefixlength - Updated dutch translation. - Remarks about 1.0pre7 release. - -Version 1.0pre6 March 27 2002 ------------------------------------------------------------------------- - -Guus Sliepen (91): - Forgot to merge new files from pre5. - Last bits of the merger. - Sensible defaults for $INTERFACE. - - If no PrivateKeyFile is specified, /etc/tinc/netname/rsa_key.priv is assumed. - Small fix. - Added support for packet compression, thanks to Mark Glines. - Don't use sa_sigaction (which NetBSD doesn't like) at all if we don't use siginfo. - Get rid of sys/signal.h. - Added device.c for NetBSD, actually a copy of the OpenBSD one. - Add check for NetBSD. - - Non-blocking connect()s. - Fix segfault when receiving HUP signal. - Use AF_UNSPEC for listening sockets if AddressFamily = any. - Forward packets in router mode. - Fix maskcmp() and maskcpy(). - Cache results of lookup_subnet_...(). - Protocol now also exchanges cipher/digest/maclength/compression for the - Preserve inpkt->len, needed for broadcasts. - - Use gai_strerror() where appropriate - - Change SA_LEN to SALEN, former one is already defined on some platforms. - Tweaking IPv6 support. - Allow multiple listening sockets. - Fix send_request() bug. - Make BindToInterface work. - Fix listening sockets. - If "PriorityInheritance = yes" is specified in tinc.conf, the value of the - Create/bind TCP and UDP listening sockets in pairs. - Updated documentation. - Updated dutch translation. - - Global time_t now, so that we don't have to call time() too often. - Document and clean up MAC address expiry. - Woops. - Check if BindToDevice and PriorityInheritance are supported. - Fix forwarding of IPv6 packets. - po/POTFILES and po/Makefile should not be generated by configure. - Autodetect $MAKE/gmake/make. - Small fixes to improve portability. - Don't retry to make outgoing connections when exitting. - Cleanups, spelling fixes, allow symbol names for signals (-k option), - prune_connections() before build_fdset(). - Try to reply to neighbor solicitation requests. - New strategy: forward icmp6 neighbor solicitations to intended target. - Simplified implementation of Kruskal's minimum spanning tree algorithm. - Packet sequence number/authentication warnings only if debug_lvl >= 5. - Remove silly cache thingy. - Put #ifdef NEIGHBORSOL around corresponding code. - Revert changes to Kruskal's algo. - Neighbor solicitation requests now work (I think). - Oops, don't forget to actually put the checksum in the response packet. - Different way of detecting neighbor solicitation requests. - Typo. - Unmap v4mapped sockaddrs. - Only unmap IPv6 addresses. - #define s6_addr32, needed for FreeBSD. - Fix #define s6_addr32. - Remember sockaddrs of listening sockets, use appropriate one when sending - Cleanup. - Don't use s6_addr[16|32] anymore. - Updated dutch translation. - Updated SSSP algorithm to automatically detect indirect links (if a node uses - Put a break on requests that run around in circles. - - Added support for jumbograms. - Fix add_edge_h(). - Fix compiler warnings, strictly use long int and %lx for options. - send_ack() was broken. - free() request strings when deleting past requests from the tree. - Don't run graph algorithms if no edge is deleted in terminate_connection(). - Reset retry timeout when receiving the first PONG, not right after receiving the ACK. - Don't try to execute scripts unless they exist. - Execute hosts/name-up when a node becomes reachable, and hosts/name-down - Set $INTERFACE correctly when using ethertap while compiled with tun/tap support. - Updated dutch translation. - Respect type field. - OpenBSD tun device uses address family number instead of Ethernet type. - Configuration variables were still handled case sensitively. - Set myself->status.reachable. - Updated documentation. - Tell a little bit more about security. - Send REQ_KEY only once until ANS_KEY has arrived. - Fix execute_script(). - Small correction. - Merge do_prune() with build_fdset(). Probably fixes the invalid filedescriptor error. - Extend list_t with the number of elements in the list. - Limit the amount of packets in a queue to 8. - Small updates. - Remove cruft. - Recent automake uses $(AMTAR) instead of $(TAR) - Remove symlink to device.c when doing a make dist. - Fix format strings. - Update dutch translation. - Update with information about the pre6 release. - -Version 1.0pre5 February 10 2002 ------------------------------------------------------------------------- - -Guus Sliepen (109): - Small fixes to allow correct compilation under FreeBSD (tested with 4.3) - Make sure Solaris is happy too. - Fix subnet_lookup() for overlapping subnets. Needs rethinking. - Added proxy-arp support. No more ifconfig -arp needed. Works like a charm - - tinc can now act as a switch or a hub too (as opposed to a router only) - Changed some stuff to allow correct generation of po/Makefile after a - Updated dutch translation. - - This oneliner removes the need for ifconfig tap? hw ether fe:fd:0:0:0:0 - Fix bug where lookup_subnet_ipv4() could go into an infinite loop. - You can now put an option "Mode" in tinc.conf, and choose from: - Add missing? counting of total_socket_in. - Log and warn about duplicate subnet_add()'s for the same subnet. - Fixes to make switching work between hosts that have no meta-connection. - Save configure cache more often. - Changed drastically because it didn't work correctly: - Only reset seconds_till_retry when we activate the outgoing connection. - Woops - big bug in send_key_changed fixed. - - Solaris compile fixes - Check for and add -ldl. - Remove #warnings I used for debugging stuff. - Reinstated search for if_tun.h in kernel source tree, because apparently - Spanish translation removed. Nobody maintains it, and it is severely - ABOUT-NLS is created by autogen.sh. - Don't build Spanish translation. - Execute tinc-down BEFORE tap device is closed. This is a. more symmetric - es.po revived. - Also remove po/Makefile.in.in, which is generated by autogen.sh. - Log error if two hosts connect with same IP/port tuple. - Fix gcc 3.0 warnings. - Check for dlopen in standard libraries first (needed for DEC OSF). - It appears that autogen.sh doesn't like es.po if it isn't mentioned in - Update of RedHat build scripts. - Dutch translation updated. - More items marked as done. - Fix printf format bug. - Fix compiler warning. - Check for all potential duplicate entries in the id tree. - - Always use instead of just - Don't load table of verbose OpenSSL errormessages. - Correct inclusion of standard if_tun.h header file. - Split connection list into two lists: - Correctly use the active_tree. - Remove all unnecessary status.meta and status.active checks. - Added purge_tree for connection_t's which are no longer in the connection, - Updated terminate_connection() so you can choose if DEL_HOSTs should be - Always close all sockets in terminate_connection(). - Woohoo! tinc now compiles, runs and actually *works* on Solaris! - Started writing a document about how daemons connect to each other. - Described problem in more detail. - Small update. - Correctie. - Written down a possible solution. - Discuss how sending ADD_EDGEs would be better than sending ADD_HOSTs. - More on edges. - Don't use %m in fprintf(). - Write public key to rsa_key.pub instead of rsa_key.priv (if not host - The val variable in a config_t is never used as a long. - Explicitly log which type of tunnel device is used. - Don't send DEL_HOSTs when !status.meta - Fix signed comparison bug in lookup_subnet_ipv4(). - Remove IndirectData support for now, new implementation will be added - Revised reconnection mechanism, always try out all ConnectTo lines. - Optional signal number for -k option. - config_t* is a const parameter in get_config_val(). - - Try old TUN/TAP ioctl() request if the one from if_tun.h fails. - Not only keep track of nexthop, but also of lastbutonehop. If destination cl - Show next- and lastbutonehop when dumping connectionlist to syslog. - Try next connectto instead of the same over and over. - Fill in next- and lastbutonehop for myself. - - Renamed lastbutonehop to prevhop. - Fix bug where tinc would crash because of a portscan or a connection from a - - Use ping timeout mechanism to close connections that don't authenticate - Fix bug when dropping an old connection in favour of a new one from the - Updated dutch translation. - Started implementing doc/CONNECTIVITY. - Small corrections. - Further implementation of doc/CONNECTIVITY. connection.[ch] is now split into a - Removed everything from connection.c that has already been moved to node.c and - Revamp configuration handling: - More updates to new node/vertex/connection combo. - - Split tap device stuff out of net.[ch] - Added FreeBSD tap device handling. - Solaris tun device handling cleaned up a bit and added. - Forgot to remove some old #ifdef stuff. - Added OpenBSD tun device handling. Untested though. - Forgot the tun specific stuff. - Support new files (node/vertex/device.[ch]) and OpenBSD. - Big bad commit: - Make sure everything links. - Various small fixes to make tinc runnable again. - What was I thinking? s/vertex/edge/g. - - More s/vertex/edge/g - - More changes needed for Kruskal's algorithm - Working version of Kruskal's algorithm. The running time is very bad though. - Various fixes, tinc is now somewhat capable of actually working again. - More updates to protocol handlers and reimplemented terminate_connection(). - - Small fixes to graph algorithms - Don't forget to read public RSA key when making an outgoing connection. - Show cfg->variable instead of cfg->value when complaining about wrong type. - Avoid connecting to another node twice, and check name of outgoing connections. - Some very small fixes - Use PEM functions as suggested by OpenSSL docs. - Several bugfixes. - *** empty log message *** - Be liberal in what you accept: allow unknown edges to be deleted. - Correctly check if subnet owner exists. - Various fixes needed for Solaris. - More fixes for Solaris. - Merging of the entire pre5 branch. - -Ivo Timmermans (32): - New make target: `make release' - Changed version number to 1.0-cvs - Don't distribute autogen.sh in a release - Don't include the debian/ dir in a release - Small fix to make it compile again - Killing tincd with SIGINT causes it to toggle between the current - Check for getaddrinfo - Check for getnameinfo, gai_strerror, freeaddrinfo - Credit OpenSSH - Check for struct addrinfo - Deprecated get_config_ip and get_config_port - Use struct addrinfo in connection_t to hold all host data such as IP - Changed prototype for lookup_connection to use struct addrinfo - Changed lookup_connection to use struct addrinfo - Removed definitions of ipv4_t, ipv6_t, port_t - Obsoleted all IP types in favor of struct addrinfo - Changed to use struct addrinfo where needed. - get_config_{ip,port} removed. - Don't compile/link netutl.c. - Obsoleted. - Don't include netutl.h. - (re)added port to struct node_t - Added HAVE_STRUCT_ADDRINFO - Added dropin replacements for get*info and helper functions. - First part of rewriting things to use struct addrinfo. - lookup_node_udp changed. - Don't include netutl.h. - route_ipv4 and route_ipv6 replaced by route_ip. - get_config_subnet needs to be fixed. - Fixed silly typo: "np" instead of "no" - Don't include netutl.h. - Conversion to struct addrinfo is almost complete for this file. - -Wessel Dankers (1): - make is not always GNU make. - -Version 1.0pre4 May 25 2001 ------------------------------------------------------------------------- - -Guus Sliepen (97): - Porting to FreeBSD: - - Added balanced tree management stuff as well. (It is not finished yet.) - - Simplified do_detach - - Removed stray @INCLUDE@ (how did that get there?) - - Fixed searching - - Implemented deletions - - Fix tree head/tail upon insertion - - Fixed a lot of small things. Tested everything except deletions. - - Deletion also works now. - - Small fixes - - Integrate rbl trees into tinc. - - Proper initialization of rbltree structures. - - Various small fixes. - - More fixes. - - Check for NULL tree->delete callback - - Cleaned up and checked for some more NULL pointers in rbl.c - - Write pidfile AFTER detaching... - - No more %as. - - Work with the correct key buffer in ans_key_h - - More porting to FreeBSD and Solaris. - - Fixed all (except 2) compiler warnings gcc -Wall gave. - - #include instead of - - Don't link with -ldl anymore - Another big & bad commit: - - Added Armijn to the list - - Added daemon() replacement. - - Use only one socket for all UDP traffic (for compatibility) - - Don't even think about using sscanf with %as anymore - - AVL tree routines: faster than RBL, and also more stable. - - Doubled size of trace buffer for easier debugging. - - Let user choose whether keys are in the config files or separate - - Updated dutch translation. - - Check and follow symlinks in is_safe_path - - Changed license of AVL tree library to GPL. - - Updated manual pages. - - Updated texinfo manual. - - Typo. - - Changed list routines to give it the same look'n'feel as the rbl and - - Reinstated a queue for outgoing packets. - - Added header file for route.c. The routing routines in it are not used - - Description of protocol and authentication updated. - - It's 2001, all copyright notices are updated. - - Fixed IPv6 subnet lookup routine. - - Added indirectdata and tcponly functionality. - - Squashed another nasty bug. - - Sign was wrong in search_closest_smaller/greater - - Cleaned up subnet_t - - Only send out DEL_HOSTs for hosts with a meta connection - Added sample configuration directory. - - Copy entire sample-config directory to /etc/tinc/example upon installing. - - Allow ASN1 style keys to be in the config files. - FreeBSD compile fixes (thanks to XeF4) - Fix memory leak in avl_insert() if item was already inserted. - Updated dutch translation. - Removed another local definition of the variable "errno" - Added .cvsignore files to get rid of warnings and prevent autogenerated - Ignore file for src/ - - Updated CVS_CREATED to remove intl/ directory and some other - Added description of the proposed new authentication scheme. - Corrected check for errors after read() calls. - Add missing \n. - Free node->data and node, not node->data twice. - Copy packets before putting them in the queue. - Encrypt network packets in CBC mode instead of CFB mode. - Implemented new authentication scheme from doc/SECURITY2. - Added process.c to the translated files. - - Make sure METAKEY is smaller than the modulus of the RSA key - Don't forget to reconnect if outgoing connection fails during - - Fixed Interface option (untested) - Removed lots of compiler warnings. - Removed compiler warning. - Various small fixes. - Added explaination of our key exchange using RSA encryption. - - route.c is now used to determine destination - Updated translation. - Added a description of what is going on in net.c and route.c, and how - Fixed a race condition triggered by receive_meta() and the new - Fixed bug in setup_signals() that would make tinc die when unexpected - Ignore alarm signals if we do not need to respond to them. - Check indirectdata option before forwarding certain requests. - Depend on new ssl package and install alias for universal TUN/TAP module. - Correctly cycle through ConnectTo variables. - - s/ip_t/ipv4_t/g - - Make sure correct information is supplied for both old kernels (with - More revisions to the documentation: - Changed URL from kernelnotes.org to linuxdoc.org. - Add randomness to PING/PONG packets to prevent crypto attacks on quiet - Since this is incompatible with some earlier versions, PROT_CURRENT is - All features for 1.0 are implemented now, we just have to check the - Only send key_changed if it was previously requested. - Small fixes: - Small corrections to the manuals. - With recent kernels the tun device file is located in /dev/net. - TCPonly now works (in a relatively clean way too). - Merged PROTOCOL, NETWORK and SECURITY2 with the texinfo manual. - Documents are merged. Now we only need to check the ports and the TCPonly - Fix sample configuration to show keys in PEM format and correct tapdevice. - -Ivo Timmermans (88): - Add a check for openssl that accepts explicit file locations. - Identify version as 1.0pre4-cvs - Better checks for OpenSSL. I think it can now detect almost all conceivable installations. - Oops, small error. - Get rid of the annoying empty line - Also check for rand.h and err.h. If any of these files does not - Also check for sha.h. - Use the HAVE_OPENSSL_xxx_H defined from m4/openssl.m4 during - Let the output from an executed script in execute_script() go to - List management and manipulation routines. - Keep a list of running children, and in each loop in main_loop(), - Move all process-related functions into process.c. - New function: xmalloc_and_zero, which initialises the allocated memory - Delete struct ifr - Move more functions from tincd.c into process.c. - Use proper prototypes. - Added this release - More function and header checks - Also include process.h - Get rid of all libtool references at once. libtool was only used by - Honor the --localstatedir option to configure, instead of hardcoded /var. - Add more checks to ensure that filedescriptors are right in - Declare fd. - Do not use the C library's daemon() call. - Do not check for the daemon() system call - Do not attempt to retreive ChangeLog information only from the CABAL - Set localstatedir to /var - Use cvs2cl instead of rcs2log to generate the ChangeLog. - Set CFLAGS to -O2 -Wall when running configure - Alter CFLAGS, somehow INCLUDES doesn't propagate properly. Still - Set errno to 0 before trying to kill the other process. - Explain how to tell configure where OpenSSL lives. - Call autogen.sh instead of configure alone; and make cvs-clean instead - Add default tinc-up and tinc-down scripts for a Debian system. These - Updated Spanish translation, provided by Enrique Zanardi. - Give an error message if daemon() failed. - Check for the function strsignal, and define it to "" if it is not - Sort items to either 1.0 or future release goals. - Use sigaction to set signal handlers, the previous commit (1.1.2.16) - Save RSA public and private keys to a separate file, instead of - dropin.c/h contain a set of drop-in replacements for non-standard C - Check for get_current_dir_name. There is a replacement function in - Added a check for a scanf that knows about %as. - Implemented a readline() function that will read an entire line into a - xstrdup now takes a const pointer as an argument. - Use readline() in read_config_file() instead of fgets. - Also free the pointer returned by readline(). - Updated Dutch translation - Implemented is_safe_path, and extended ask_and_safe_open. - Read the PEM file pointed to by the configuration directive - The file is safe if it doesn't exist. - In readline(): initialise the line to zero length; - Better error checking when reading the RSA private key. - Avoid printing duplicate messages from read_rsa_keys - New function read_rsa_public_key(); - All full stops have two spaces after them. (Silly commit, I know.) - Tagged `Storing private key in separate file' as done. - readline() accepts two extra parameters, buf and buflen, to avoid - Use buffer instead of line in read_config_file(), line may be assigned - Stated that distributing executables linked with OpenSSL is permitted - Include COPYING.README in the distribution. - Added documentation merger - Sort configuration directives - Option -d accepts an argument to set the debug level immediately. - Massive long awaited documentation update. It's not finished yet, - Oops. I did some VERY wrong things with readline(). Fixed now. - Tiny bits of code beautifying - Install a file in /etc/modutils/tinc, containing all necessary aliases - Ported it back to /bin/sh. - Give a warning about having to re-create the keys - Re-introduced MyVirtualIP and VpnMask, as dummy options. - Various small changes. - Include autogen.sh (needed for the Debian package). - Forget router.c - Added lint target, requires lclint. - Fix error reporting of read_config - Set Architecture to `any' - Change version to 1.0pre4 - Second draft of the release notes - Merged documentation with various updates I had lying around - Get the Debian changelog up to date - Get the PO files up to date with the current source - Fixed some errors - Distribute the sample config as a .tar.gz - Unpack sample-config.tar.gz when installing - More files to ignore in CVS - tinc_TUNTAP now substitutes the values outside the AC_CACHE_CHECK - Authentication done - -Wessel Dankers (1): - Important bugfix in avl_insert_before() and avl_insert_after() - -Version 1.0pre3 November 09 2000 ------------------------------------------------------------------------- - -Guus Sliepen (119): - Debian init.d script automatically sets tap device's MTU to 1448 now. - First step for implementation of the "indirectdata" directive. This should - If we have "indirectdata" flag set, we only send data to our uplink. - Large cleanup: - Added CVS Id tags to header files. - - Log possible spoofing attacks. - Hostnames are back! - Hostlookup() is actually being called now. - - More verbose connection list - Fixes some hostlookups. Fixes indirectdata for real now (hopefully). - - Indirectdata finally REALLY REALLY works now! - - Moved all connection messages to debug level 1, without -d's only the - - Fixed KEY_CHANGED notification. A lot of notify_others() calls were - - Fixed indirectdata=no problem - - Improved handling of errors on connection attempts. - - Purge old connections that are ADD_HOSTed. - - Fixes a silly little insignificant buglet. - - Extra check op EINTR bij inlezen requests - - Fixed some spelling errors. - - Fixed missing " in nl.po - - Fixed a message in nl.po - - Added log message when SIGCHLD is received ("thanks" to Ivo van Dong) - - Updated Dutch translation. - - Removed all IP_ADDR_S macros, because gettext doesn't like them. Each - - New semantics for BASIC_INFO, ADD_HOST and DEL_HOST requests. This will - - Fixed memory leak. - - Removed segfault bug in conf.c (must have been there for ages!) - - Instead of logging an error when remote end closes the connection, - - Made tinc even more silent if no -d flag is given at all. - - Added documentation for the protocols (most important the meta protocol) - - Removed a single unused bit from status_bits_t. - - Updated PROTOCOL (a bit) - - Forgot to mention ourselves in the tincd manual page! :) - - Added Spanish translation from Enrique Zanardi. - - Updated THANKS file - - Delayed address resolving for ConnectTo lines in configuration file to - - Fixed typo. - - Added experimental hackish tunneling-over-TCP support. - - Lots o' buglets fixed (-Wall helps) - Fixed PACKET read loop. - Removed calling add_queue for tcponly packets. - - Added date/time of build and protocol number to --version output. - - Moved TCP packet reception to meta handler: less kludgy and less buggy! - - Reinstated O_NONBLOCK for meta socket - - Added two extra configuration options, Interface and InterfaceIP, to - Fixed all sprintf() spl01ts. - Ran update-po and updated dutch translation. - Commented on some size calculations. - Updated the manual: - Updated tinc.conf manual. - Fix rules (thanks to Laurence) - - Use strerror() instead of sys_errlist[] for increased portability - - New protocol. Will break everything else for now. - - Added more function skeletons for the new protocol. - - Lots of functions added for the new protocol. - - Some key exchange stuff. (Last commit before going to bed.) - - Fixed modulo in keylength check - - Lots of small changes. - Added document about the used cryptographic algorithms and the reasons - - Included authentication scheme from protocol.c - - Updated authentication scheme. - - Severe code reduction and simplification of challenge requests - - Removed options "string" stuff. It was a bad idea... - - Very detailed example of the authentication phase. - - Added meta.c which contains functions to send, receive and broadcast - - Added subnet handling code - Removing cipher directory (all will be covered by OpenSSL). - Big and bad commit of my current tree... - - Changed genauth to produce rsa keypairs instead of random passphrases. - - Generalized config file parsing to support multiple configuration trees. - - Fixing-things pass: every source file compiles into an object file now, - - Second fixing-things pass: it even links now. - - The daemon actually runs now (somewhat) - Corrected #ifdefs for tun/tap support. - - Fixing little things - - More fixing. Tinc daemons can now even create activated connections. - - Seed the PRNG using /dev/random before generating the keys. - - tinc now really does public/private key encryption! It even works, whee! - - Made Makefile.am stub for doc/es/ - - Removed last reference to genauth from Makefile.am - - Fixed all debug levels. - - route.c will contain the routing logic. - - Lots of little stuff modified - - Updated subnet list handling. Subnets are added to two lists now, the - - Lots of small fixes - - Fixed offsets when reading/writing from/to tap device - - Override destination ethernet address on incoming packets with - - Very big cleanup. - - Fixed ans_key_h - - Hit people who can't figure out subnet address/mask pairs with a - - Enforce correct order of authentication requests - - Moved connlist stuff to the proper header file. - - Updated dutch translation. - - Removed old encr stuff - - Small fixes - - Use CFB mode for encrypting packets: it works and we don't need padding. - - Finishing touch: encrypt the meta connections - - Small cleanups - - Fixed some spelling mistakes and terminology here and there. - - Update. - Removed config file parsing and interface setup. This will be handled by - - Removed unused MAC strip/add functions. - - Removed even more warnings. - - Resolve scriptname after fork() - - Removed manpage for no longer existing genauth. - - connlist.c added to translation - - Don't forget to set packet cipher for added hosts. - - Forward keys in hex notation, not as binary data. - - Check for packets that are looping back. - - Simplified ping mechanism. - - Prepended config_ to all configuration option names, because it confused - Changed execution of tinc-up: - - Open UDP connection for all known hosts. Comments please. - Porting to SunOS 5.8: - Porting to SunOS 5.8: - - Fixed --config - - Applied Jamie Brigg's patch (close sockets after error) - - Add Jamie :) - - Make checkpoint tracing a compile time option (off by default) - -Ivo Timmermans (77): - Alphabetized the list, added Lubom�r Bulej, removed Sander Smeenk and Tijs van Bakel, put merits after all names. - Don't touch VPNMASK if it's defined, otherwise use $MSK. - These files are created by gettextize (run by autogen.sh) (should have known that). - Include ../intl in the include path, and add @INTLLIBS@ to the list of libraries. - Merge changes from 1.6-1.8. - Configuration directive `IndirectData'. - Changed version number to 1.0pre3. - Version 1.0pre3. - Removed Free Software Foundation copyright, because Guus Sliepen contributed significantly. - Oops, and mention Guus too. - Include the Spanish translation in the distribution/build process. - (Quoting Laurence Lane:) - Also chomp $VPNMASK - Added a rule to create an rpm - Changed CVSROOT path in `make ChangeLog' - Link with OpenSSL crypto libraries instead of own blowfish library - Updated text, removed protocol flowchart - Include openssl/blowfish.h - Support for -lsocket and -lnsl on SunOS - Correct filenames for passphrases given in the example - Add Guus' name and shift out old protocol requests - Better checks for SunOS libraries - Added some structures and types that are needed for the overhaul. - New directive: Name. - First round of needed fixes after the overhaul - Second round of fixes - Added Spanish translation of the docs by Matias Carrasco - Many updates, parts rewritten, added, shuffled around. - Link with OpenSSL, forget libGMP - Updated new requirements, pointers to the manual - Don't look for GMP header files - Update Depends lines to reflect the dependencies on OpenSSL - Fix `Requirements'-section for GMP and OpenSSL libraries. - Add CVS id lines - Add checks for the presence of the universal tun/tap device driver. - Wrap the tun/tap code in #ifdef HAVE_TUNTAP - Linearized checks for if_tun.h - Really #include the if_tun.h files now - Output doc/es/Makefile - Process subdir es/ - Don't declare cp_file and cp_line in xmalloc() - Get the head revision up to date with cabal - Changed changelog - Include linux/sockios.h and net/if.h anyway, regardless of the value of HAVE_TUNTAP. - read_server_config: Check for result of read_config_file. - Oops, echelon change committed to cabal... :) - Skip the check for Linux kernel sources - This file is no longer needed. - - Synchronized changelog with the package's changelog. - Do not include $(top_srcdir)/cipher, it does no longer exist. - Added a perl example to turn an IP address into a MAC address. - Only check for linux/if_tun.h once - Changed `I' to `We' - small change, lots of difference :) - More exhaustive list of changes - perhaps it can be worded differently? - Change wsl to Wessel's name and email address in the ChangeLog creation - Mention fileutils, add a pointer to THANKS for more details - Changed a few messages wrt. system calls; updated and changed the Dutch translation a bit. - Don't include shlibs, as it no longer exists. - Oops, and include doc-base.tinc (new file). - - If necessary, patch po/Makefile.in from po-Makefile.in.in.diff to - Minor cosmetic change. - Save the environment on startup. - Run the scripts tinc-up and tinc-down from a separate function, which - Warnings removal pass: always include config.h first; add a few - Small change to the way the environment is copied. - Use putenv() instead of clumsy do-it-yourself in execute_script. - Do not include the passphrases directory - In execute_script: - Add route.c to the list of source files. - Updated Dutch translation - Build-depends on libtool - Build-Depends on gettext - Final release notes added, also edited release notes for 1.0pre2 to what the announcement on the mailing list looked like. - Wrapped text to 70 (72?) columns for easy reading - Bop version number to 1.0pre3-1 - Updates, updates - Add prototype for destroy_queue - -Wessel Dankers (3): - File added to CABAL (hopefully) - Grrr, recommit - Added architecture section, made a start with the kernel section. - -Version 1.0pre2 May 31 2000 ------------------------------------------------------------------------- - -Ivo Timmermans (56): - Deleted the protocol description. - Perl version of the system startup script. - Only print an error with send_termreq if debug_lvl is 2 or more. - Add check for mpz_powm in libgmp3. - Version 1.0pre1-0.1. - Changed version to 1.0pre2. - Give IP address instead of hex number when connecting tcp socket failed. - Add shlibs control file for the blowfish library. - Inserted useful content. - Add initscript, tincd->tinc. - Add description, better dependancies. - Mention both upstream authors. - tincd->tinc - .deb version number 1.0pre2-0.4. - Updated to newer version. - Exit with zero status if is empty. - Unlimited length in the config file, thanks to Cris van Pelt. - Depend on perl5. - *** empty log message *** - Look if the tap devices exist before bluntly remaking them. - Use the new VpnMask directive to add a route to the rest of the VPN. - This file is generated with dpkg-buildpackage. - Read /etc/tinc/nets.boot to find the networks that have to be started. - Create a default /etc/tinc/nets.boot after installation, containing all directories under /etc/tinc by default. - Version 1.0pre2-0.3 - Don't distribute the file files. - Find networks in instead of . - Include postinst in the distribution. - Errors will not terminate the script or result in a nonzero exit code. - Updated copyright notice. - Fixed typo. - Mask the vpn net with the vpn netmask, route would give an error if the netmask didn't match the net. - When VpnMask is not present in the config file, silently use $MSK as vpnmask. - Add an example of using VpnMask. - Use /etc/tinc/example as a base directory for an example. /etc/tinc/example/README points to /usr/share/doc/tinc/README.Debian. - Create an empty /etc/tinc/nets.boot. - Updated by Lubomir Bulej and Mads Kiilerich: it uses /etc/tinc/nets.boot and the VpnMask directive in the config files. - Internationalization of tinc. - Include intl/ directory in the list of subdirs. - Include system.h and ABOUT-NLS. - Update acconfig.h to include values for gettext inclusion. - Include GNU gettext checks. - Define LOCALEDIR in CFLAGS. - Dutch translation of tinc. - Bounds check for request id (between 0 and 255). - Updated changes list for version 1.0pre2. - Added new configuration directive `Hostnames', which controls the resolving of IP addresses to hostnames. - When a connection is terminated, all hosts that are still connected get notified of the lost connections. - In terminate_connection, only send a notification to hosts that are directly connected to us. (DEL_HOST gets forwarded automatically.) - Only accept an ADD_HOST request for a host that already exists in our conn_list if the nexthop field matches the sender. This is a workaround for older clients. - Include news for 1.0pre2. - Tell about /etc/tinc/nets.boot. - Updated Dutch translation. - Version 1.0pre2-1. - Handle locale settings. - Miscellaneous copyright updates. - -Guus Sliepen (16): - Proxymode removed. - Cleanups. - Changed ping behaviour (backwards compatible). If we don't have any data - Fixed typos. - Test for existence of configured tinc networks. This will also make - Stub for VpnMask config directive. - TODO file reinstated: - VpnMask truely works now. - Typo. - Fixed last typo. Init.d now uses ifconfig command to set both the tap's IP - Documentation updates. Removed all references to configuration variable - Fix for a DoS attack: - Fixed typos. When terminating a connection, it's status is not only set to - Made tinc persistent. If no outgoing connection can be established right - Terminate a connection on any error. Furthermore, disallow del_host, - Only activate a connection upon receiving it's public key if it's an - -Version 1.0pre1 May 08 2000 ------------------------------------------------------------------------- - -Ivo Timmermans (84): - Get rid of the message `zxnrbl\'. - Upon regeneration, free the old encryption key `securely\' by overwriting it. - Kill the parent after any error conditions in detach(). - Ignore SIGCHLD. - New option -D, don't detach. - Moved to version number 1.0. - Only one round of reading bits out of urandom; - Pass the requested size from xmalloc() and xrealloc() on to xalloc_fail_func() - Check for an illegal length of passphrase in read_passphrase(). - Check if stdout is a terminal, if so, print a verbose message. - Default passphrase length of 1024, added -h/--help options. - Submitted by Mads Kiilerich. - New manpage for genauth. - Updated manpages. - Address for bugreports changed to tinc@nl.linux.org. - Include the directory redhat in the build process. - Include genauth.8 in the distribution. - Submitted changes by Mads Kiilerich. - A short notice from Mads Kiilerich. - Keep make dist(dir) happy. - Added cvs-clean. - These files are not needed in release 1.0. - Don't compile in `idea'. - Don't include idea/idea.h. - Don't try to create cipher/idea/Makefile. - The shell script autogen.sh can create all these removed files, but be - s/Gnome/tinc/g - This file is obsolete, most of the ideas are already in echelon. - Remove check for bigendianness. - Don't define HAVE_NAMESPACES and HAVE_STL. - Use `make ChangeLog' to create this file from the CVS logs. - Remove test for GNOME. - Changes largely from Mads Kiilerich. - Added Mads Kiilerich, removed Guus Sliepen. - *** empty log message *** - Generate this Makefile.am from Makefile.am.in. - Contributed by Mads Kiilerich. - Spelling fixes. - Delete all the files that are created by autogen.sh on a `make cvs-clean'. - Propagate CFLAGS from configure to gcc. - Don't include TODO in the dist. - Remove ChangeLog with a `make cvs-clean'. - Initial CVS. - *** empty log message *** - Create a ChangeLog file, automake requires it. - *** empty log message *** - Debug level tweaking. - From Mads Kiilerich. - The make command is in /usr/bin. - Add an entry to dir. - Omit TODO. - Version to 1.0pre1; - Filled in the details, license from libblowfish copied. - Updated version number to 1.0. - Default config file name is tinc.conf, and pidfile is tinc.pid. - More updates wrt. the change from tincd->tinc. - Added `deb' target. - Filled up the protocol structs with unused bytes. - Got rid of the nasty hacks... and replaced it by another one. - Initially, the vpn_mask of a connection is 255.255.255.255 to avoid confusion with lookup_conn. - Replaced check for status.active by status.dataopen in check_network_activity. - New way of handling the meta protocol. - Read public keys the right way (tm). - Removed debug messages. - Read one less byte from an ANS_KEY request. - Send one less byte from an ANS_KEY request. - Protocol fix (ANS_KEY). This breaks 0.3.3 protocol compatibility. - Key forwarding, write one byte extra. - Committed by Lubom�r Bulej. - Updates by Mads Kiilerich. - Committed by Mads Kiilerich. - Fixed meta protocol. - More tincd->tinc updates. - Mentioned new metaprotocol. - Fix a typo, better handling of the info document. (from Mads Kiilerich) - Don't use error.h or error(), put #error in front of cpp errors. - getopt_long() support for platforms that don't have it. - Include stdio.h for fprintf. - More for getopt support. - Check for the existance of libdl. - Don't link in libdl. - Include sys/types.h. - Copied most of the code from the redhat script. - Added semicolons required by bash2 (Mads Kiilerich). - -Guus Sliepen (18): - Added extra checks for desynchronized connection lists. Hopefully this will - Bug found! Wrong pointer was used for handling multiple ADD_HOST requests - Added checkpoints to beginning and ending of every function. - Packet queues fixed. They caused the trouble when resending keys. - Fixed typo and removed some unnecessary variables. - When trying to talk to a host that is in the netmask of a tinc server but - Converted every &variable[0] to variable. - Cleanups: - Removed write_n() function. - Oops! Reference to write_n() removed and changed into neat write() call. - Meta protocol overhaul. Tinc is now incompatible with previous versions, - Fixed small mistake that would prevent forwarding requests. - Previous fix fixed. Meta protocol should be really flawless from now on! - Replaced sprintf() by safer snprintf(), removed possible buffer overflow - Outgoing packets now use network byte order in header. - Fixes typo and UDP network byte order. - Squashed gcc warning. - Added new config variable "ProxyMode". If enabled, all outgoing packets +commit f8d94f34fc5d7fe9ed4a076a2fd77eacbd83adca +Author: Guus Sliepen +Date: Sun Jul 17 20:09:08 2011 +0200 + Releasing 1.1pre2. + +commit c259d552fa89c3e4a962d9adf2b237f24bc077da +Author: Guus Sliepen +Date: Sun Jul 17 20:06:06 2011 +0200 + + Add missing newline. + +commit f6020a5224c9c4c17c11c5f9d2c8441638ac04fc +Author: Guus Sliepen +Date: Sun Jul 17 20:01:24 2011 +0200 + + Write loopback address instead of "any" address in pidfile. + +commit 25091454da21941dd92375ddbee7dd6151343058 +Author: Guus Sliepen +Date: Sun Jul 17 19:23:52 2011 +0200 + + "tincctl stop" now removes the tinc service on Windows. + +commit c6c989cfa175154f4cd3830c5a77fbd2071f52af +Author: Guus Sliepen +Date: Sun Jul 17 18:02:56 2011 +0200 + + Fix declaration of usleep(). + +commit 18e9839dc861c368141bbbc9a963f719a83eba3e +Author: Guus Sliepen +Date: Sun Jul 17 10:59:54 2011 +0200 + + Ensure symlinked files do not end up in the tarball. + +commit fa4a01e4a27dd4b3a57077acbd0e69f95d55944a +Author: Guus Sliepen +Date: Sat Jul 16 22:38:50 2011 +0200 + + Use const pointer to source in base64 and hex routines. + +commit 574b380dfc75ef13ee4accba1f2416165c58a5a2 +Author: Guus Sliepen +Date: Sat Jul 16 22:38:22 2011 +0200 + + Use usleep() instead of sleep(), MinGW complained. + +commit 8efc8dc961865ceddb74cb36f0b4a2ebde39cc55 +Author: Guus Sliepen +Date: Sat Jul 16 21:44:17 2011 +0200 + + Update info manual. + +commit cff27a258f3b3a97b5d2e309c264eceea41dff3a +Author: Guus Sliepen +Date: Sat Jul 16 20:21:44 2011 +0200 + + Use ECDSA to sign ECDH key exchange for UDP session keys. + + The ECDSA public keys will also be included in the ANS_KEY requests, + but are only used when no ECDSA public key is known yet. + +commit 03ac48ea19914e4162f17a2fb0f742b99ae32499 +Author: Guus Sliepen +Date: Sat Jul 16 15:21:37 2011 +0200 + + Use the same logic as tinc 1.0.x for detecting two nodes with the same Name. + +commit 2ba61742d4c2ab82525efb806dc654a6d95d335e +Author: Guus Sliepen +Date: Sat Jul 16 15:15:29 2011 +0200 + + Use the correct direction flag when setting cipher keys. + + The flag was set incorrectly, but for most ciphers this does not have + any effect. AES in any of the block modes is picky about it though. + +commit 303dd1e70219a7542921f6e63d9391ab326d434f +Author: Guus Sliepen +Date: Wed Jul 13 22:52:52 2011 +0200 + + Fix compiler warnings. + +commit 791c1898ea8f92b07f1d79e90540c257ac38298d +Author: Guus Sliepen +Date: Wed Jul 13 22:29:30 2011 +0200 + + Remove unnecessary variables and functions. + +commit fec279a9c54ec8a13bd1ba4c7bec0d2a15454992 +Author: Guus Sliepen +Date: Tue Jul 12 23:43:12 2011 +0200 + + Make use of the improved hex and base64 functions. + + Also, use base64 for all EC related data, it is shorter and easy to + distinguish from the legacy protocol. + +commit 06b8271ed5d56c9bd3de459d95907d0ef4f0ea3c +Author: Guus Sliepen +Date: Tue Jul 12 22:54:49 2011 +0200 + + Make hexadecimal and base64 routines behave the same. + + The length parameter for the encoding functions is the length of the + binary input, and for the decoding functions it is the maximum size of + the binary output. + + The return value is always the length of the resulting output, excluding + the terminating NULL character for the encoding routines. + + All functions can encode and decode in-place. The encoding functions + will always write a terminating NULL character, and the decoding + functions will stop at a NULL character. + +commit c108c79a22118ef7246a3d7b3bc20e205e11d179 +Author: Guus Sliepen +Date: Mon Jul 11 22:14:06 2011 +0200 + + Don't use wildcards in filenames in configure.in. + +commit bbeab00f46a6c856573fe0d2b9b85bce35728403 +Author: Guus Sliepen +Date: Mon Jul 11 21:54:01 2011 +0200 + + Require ExperimentalProtocol = yes for new features, update documentation. + +commit d1cd3c81455ecb32149cbaa424b7870075b2b2fc +Author: Guus Sliepen +Date: Sun Jul 10 22:46:43 2011 +0200 + + Close meta connection socket after cleaning up event structures. + + Epoll doesn't like it when an already closed filedescriptor is being + removed, so we defer closing the socket until after all else is cleaned + up. + +commit 30ef2a981e1d62692b3a2363e0b3a0e8711d9604 +Author: Guus Sliepen +Date: Sun Jul 10 22:34:17 2011 +0200 + + Automatically exchange ECDSA keys and upgrade to new authentication protocol. + + If we don't have ECDSA keys for the node we connect to, set protocol_minor + to 1, to indicate this to the other end. This will first complete the + old way of authentication with RSA keys, and will then exchange ECDSA keys. + The connection will be terminated right afterwards, and the next attempt + will use ECDSA keys. + +commit 027228debee2ea6f31cd176e456c13d626380066 +Author: Guus Sliepen +Date: Sun Jul 10 21:02:34 2011 +0200 + + Free ECDSA and RSA structures when freeing a connection_t. + +commit 73863fab8ae1ecd8307aaeef486919cc76b85d63 +Author: Guus Sliepen +Date: Fri Jul 8 18:17:34 2011 +0200 + + Hash input before signing it with ECDSA. + +commit 8132be8fbd6c45be309c63a117f418ad12ced094 +Author: Guus Sliepen +Date: Thu Jul 7 22:30:55 2011 +0200 + + Very primitive ECDSA signed ECDH key exchange for the meta protocol. + + Nonces and hash of the ID requests should be included in the seed for the PRF. + +commit 210b5ceeeebdf742a74dcf95a0a13d69623ee001 +Author: Guus Sliepen +Date: Thu Jul 7 22:28:25 2011 +0200 + + Read ECDSA keys. + +commit 03582eb669494cb778ebea7b0fe3b1b841335750 +Author: Guus Sliepen +Date: Thu Jul 7 22:27:17 2011 +0200 + + Implement ECDSA sign and verify operations. + + Very basic at the moment, doesn't hash the input first, + and uses OpenSSL's DER encoded signature as output. + +commit 86d83bd9bd69e2129f4e4e8397f1c7e223685e2f +Author: Guus Sliepen +Date: Tue Jul 5 21:29:31 2011 +0200 + + Bump minor protocol to indicate ECDH capability for UDP session keys. + +commit 9708bbfa8e3094de8932a30b1d24c661558d8a03 +Author: Guus Sliepen +Date: Tue Jul 5 21:19:48 2011 +0200 + + Add a minor number to the protocol version. + +commit b99656d84a88dad7935d5981fcdb43a5b2bfa417 +Author: Guus Sliepen +Date: Mon Jul 4 07:51:47 2011 +0200 + + Round up the size of the secret parts after splitting it in two. + +commit 95e1cc36d320b47408ac3ec6f89df54e55a010d4 +Author: Guus Sliepen +Date: Sun Jul 3 23:44:43 2011 +0200 + + Add ECDSA key import. + +commit 1e2d9b08991861c8770aa2c5a73d86dc02e3067d +Author: Guus Sliepen +Date: Sun Jul 3 23:33:56 2011 +0200 + + Finish base64 decoding routine. + +commit 80b81c00b129b006981b76bdb734df3296317d6f +Author: Guus Sliepen +Date: Sun Jul 3 22:25:29 2011 +0200 + + Have tincctl generate ECDSA keys. + + The generate-keys command now generates both an RSA and an ECDSA keypair, + but one can generate-rsa-keys or generate-ecdsa-keys to just generate one type. + +commit 8ace7f3e5771957fbdda8b817fa26951d9d62c28 +Author: Guus Sliepen +Date: Sun Jul 3 22:15:00 2011 +0200 + + Add ECDSA key generation. + +commit 1d92dd62a786ecabbc05dfba5195f3f08e0f9585 +Author: Guus Sliepen +Date: Sun Jul 3 22:13:58 2011 +0200 + + Base64 encoding and decoding functions. + +commit c385d115331845e8a844322e66571d74d833e822 +Author: Guus Sliepen +Date: Sun Jul 3 22:13:34 2011 +0200 + + Cleanups in ECDH code. + +commit 895f868714f9422a757a95650345e0c662d12b49 +Author: Guus Sliepen +Date: Sun Jul 3 21:21:37 2011 +0200 + + No need to keep around pointers to EC_GROUP. + +commit ac163120d7f0300c8d555f76ace3368ce2ffa655 +Author: Guus Sliepen +Date: Sun Jul 3 16:30:49 2011 +0200 + + Proper use of PRF. + +commit 82f00ea07bffc10985ccb1a15723e6daa0ab4969 +Author: Guus Sliepen +Date: Sun Jul 3 15:59:49 2011 +0200 + + Use PRF. + +commit feb3f22fffa2620b9b11a509ce51ff9fa3be9418 +Author: Guus Sliepen +Date: Sun Jul 3 15:26:58 2011 +0200 + + Add PRF to derive key material from the ECDH shared secret. + + It is modelled after the pseudorandom function from RFC4346 (TLS 1.1), the only + significant change is the use of SHA512 and Whirlpool instead of MD5 and SHA1. + +commit 8dfa072733feab737cabf69f000c70657719826a +Author: Guus Sliepen +Date: Sun Jul 3 13:17:28 2011 +0200 + + Support ECDH key exchange. + + REQ_KEY requests have an extra field indicating key exchange version. + If it is present and > 0, the sender supports ECDH. If the receiver also + does, then it will generate a new keypair and sends the public key in a + ANS_KEY request with "ECDH:" prefixed. The ans_key_h() function will + compute the shared secret, which, at the moment,is used as is to set the + cipher and HMAC keys. However, this must be changed to use a proper KDF. + In the future, the ECDH key exchange must also be signed. + +commit ee8a214318fd6dbe6bc5d6b510896f30d92d46c6 +Author: Guus Sliepen +Date: Mon Jun 27 21:52:23 2011 +0200 + + Preliminary implementation of Elliptic Curve Diffie-Hellman Ephemeral key exchange. + +commit 6c21b5716b8e9e5ff5def8070f92b76a0f353cb0 +Author: Guus Sliepen +Date: Sun Jun 26 13:15:44 2011 +0200 + + Add manpage for tinc-gui. + +commit 4c934d0903a32e71ae83ffdf344957bd06b7164d +Author: Guus Sliepen +Date: Sun Jun 26 13:14:48 2011 +0200 + + Remove debug messages that were printed to stdout. + +commit e73052b05444679d922dbdf3d0c507873110957e +Author: Guus Sliepen +Date: Sun Jun 26 12:59:11 2011 +0200 + + Update documentation to mention pidfiles instead of controlcookies. + +commit 8c953b1bfef3c6ebee7c537c2c2f144807d0311a +Author: Guus Sliepen +Date: Sun Jun 26 12:58:50 2011 +0200 + + Don't react to escape character in tincctl top. + + Not only the ESC key generates an escape character, but many other keys + do as well, such as arrow keys. + +commit 27e6a89b155b171b0b026d5e24ee0cc68f43d010 +Author: Guus Sliepen +Date: Sun Jun 26 12:51:25 2011 +0200 + + Use pidfile in tinc-gui as well. + +commit 660f530a6ff733f96f81eefa69b38e2ea685f890 +Author: Guus Sliepen +Date: Sat Jun 25 22:20:39 2011 +0200 + + Really stable sorting of tincctl top output. + +commit 810766e1394f18b8709e9f0c75a41a2c348e3fad +Author: Guus Sliepen +Date: Sat Jun 25 21:38:59 2011 +0200 + + Add +git to the version string. + +commit ab4d289fafd1d391583935ab4c306f1f508ea1d0 +Author: Guus Sliepen +Date: Sat Jun 25 21:35:27 2011 +0200 + + Make pid files backwards compatible and add address of listening socket. + + The pid is now written first, so that a version 1.0.x tincd can be used to stop + a running version 1.1 tincd. Getsockname() is used to determine the address of + the first listening socket, so that tincctl can connect to the local tincd even + if AddressFamily = ipv6, or if BindToAddress or BindToInterface is used. + +commit a05fa7f88264599a43f9e411287e018259dc22b1 +Author: Guus Sliepen +Date: Sat Jun 25 21:21:36 2011 +0200 + + Rename controlcookie file to pidfile. + +commit c64f64b875879591873d68faf2d3cd8e9d644101 +Author: Guus Sliepen +Date: Sat Jun 25 21:16:13 2011 +0200 + + Don't call exit_control() if we didn't do init_control(). + +commit 3b237afbda86bc95703ed25386cc9a26695d4602 +Author: Guus Sliepen +Date: Sat Jun 25 20:20:07 2011 +0200 + + Re-add support for SIGALRM. + +commit 386c1aff08a3ce6e295931e2fcf4bfc607053ff0 +Author: Guus Sliepen +Date: Sat Jun 25 17:39:02 2011 +0200 + + Merge Tinc.py into tinc-gui to simplify make install. + + Autoconf/automake's Python support is strange. + +commit c4c32f40599eb8e75b1160083020d924c5807ac8 +Author: Guus Sliepen +Date: Sat Jun 25 17:11:05 2011 +0200 + + Thank Scott Lamb, Sven-Haegar Koch and Loïc Grenié in the NEWS file. + +commit 8733110dec28967d67a3c00d00cdfa608dbeb9c4 +Author: Guus Sliepen +Date: Sat Jun 25 17:08:40 2011 +0200 + + Ensure the right files end up in the tarball after make dist. + +commit e4f65db89726ac06ba7e787d420db4422d9a6e98 +Author: Guus Sliepen +Date: Sat Jun 25 15:28:54 2011 +0200 + + Releasing 1.1pre1. + +commit 2c5ded652035bfaa204a7e1cc6766efb87135569 +Author: Guus Sliepen +Date: Sat Jun 25 15:28:13 2011 +0200 + + Ensure that the texinfo manual can be converted to HTML. + + Somehow commit 2c30af6c90926340a89748c63cc453b1c0b5a589 was not properly + merged. + +commit e8deda0b23463599a7533e82cf038a01062956a7 +Author: Guus Sliepen +Date: Sat Jun 25 14:52:47 2011 +0200 + + Update manpages and info manual. + +commit 47393b5de42120dfb7d01f8b77aff16ac68177ec +Author: Guus Sliepen +Date: Sat Jun 25 00:32:45 2011 +0200 + + Add Makefile.am in gui/. + + This ensures the gui source will be included in the tarball with make dist, + and will be installed with make install. + +commit 7944cce19e4de4207a4ef20569155118acebd406 +Author: Guus Sliepen +Date: Sat Jun 25 00:06:06 2011 +0200 + + Don't use AM_CONDITIONAL for CURSES. + + For some reason, this doesn't work when cross-compiling for Windows. + +commit 365f60f3f8a8ff85a616d5014d555b470740d395 +Author: Guus Sliepen +Date: Fri Jun 24 22:49:18 2011 +0200 + + Don't call event_del() from the mtuevent handler, always send_mtu_probe() in ans_key_h(). + +commit 1fe8ba2f06c39d7c8b81f0e451bdbac94ae9375f +Author: Guus Sliepen +Date: Fri Jun 24 22:10:03 2011 +0200 + + Delete mtuevent if it is not used. + + Keeping it around prevents ans_key_h() from restarting PMTU discovery. + +commit 79e9a4f743b7b59fed968575f6b36171cf4a0063 +Merge: fb5b260 05260f9 +Author: Guus Sliepen +Date: Fri Jun 24 21:40:55 2011 +0200 + + Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 + + Conflicts: + NEWS + README + configure.in + src/Makefile.am + +commit 05260f941c2a24eb3f09070a2550cf15e431266a +Author: Guus Sliepen +Date: Fri Jun 24 14:50:20 2011 +0200 + + Releasing 1.0.15. + +commit 3c0511984f0041f79e64bcc55d58680f86e8e408 +Author: Guus Sliepen +Date: Fri Jun 24 12:27:04 2011 +0200 + + Remove redundant @CFLAGS@ from AM_CFLAGS. + +commit fb5b260190b1c6d07ec822154094aee7416f292e +Author: Guus Sliepen +Date: Tue Jun 21 23:08:05 2011 +0200 + + No need to check for pselect() in tinc 1.1. + +commit 532557beeaa60d96ac423248ff62d2cc03205c22 +Author: Guus Sliepen +Date: Tue Jun 21 23:06:53 2011 +0200 + + Only log UDP address changes at the appropriate debug levels. + +commit 60ed7fe598ccf3ac11fab616c9c85492c576b722 +Author: Guus Sliepen +Date: Mon Jun 6 21:19:30 2011 +0200 + + Reopen log file after SIGHUP. + + This was missed by the previous merge. + +commit 33f241d97852d7a171f1aaf1bda7f66356ff889e +Merge: 601f3b2 4b3fd94 +Author: Guus Sliepen +Date: Mon Jun 6 20:42:15 2011 +0200 + + Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 + + Conflicts: + NEWS + configure.in + doc/tincd.8.in + lib/pidfile.c + lib/pidfile.h + lib/xalloc.h + lib/xmalloc.c + src/conf.c + src/conf.h + src/connection.c + src/connection.h + src/event.c + src/graph.c + src/graph.h + src/net.c + src/net.h + src/node.h + src/openssl/crypto.c + src/process.c + src/protocol.c + src/protocol_key.c + src/route.c + +commit 601f3b2dd746ff5726eca256861f2ecf662b3a55 +Author: Guus Sliepen +Date: Mon Jun 6 20:12:33 2011 +0200 + + Clean up digests when freeing a connection_t. + +commit 4b3fd94b1cc79c24c4092b6b10ed4627a2648d26 +Author: Guus Sliepen +Date: Mon Jun 6 16:26:11 2011 +0200 + + Improved --logfile option. + + Instead of UNIX time, the log messages now start with the time in RFC3339 + format, which human-readable and still easy for the computer to parse and sort. + The HUP signal will also cause the log file to be closed and reopened, which is + useful when log rotation is used. If there is an error while opening the log + file, this is logged to stderr. + +commit b3bbeab6e669795f6f5a6b98590da359178bfdce +Author: Guus Sliepen +Date: Sat Jun 4 11:27:54 2011 +0200 + + Attribution for Loïc Grenié. + +commit 50af33d01f425983dd2b1d7b61092a6325be3f41 +Author: Loïc Grenié +Date: Sat Jun 4 09:05:23 2011 +0200 + + Nearly tickless tinc. + + Use pselect instead of select in main_loop (if available). This lets + tincd sleeps as long as there is nothing to do. + +commit 8b3cc695b56d4ab5e51c7e194153894f920b307f +Author: Guus Sliepen +Date: Fri Jun 3 15:50:20 2011 +0200 + + Don't ignore SIGCHLD, system() needs it. + + But we do ignore SIGPIPE, and tinc 1.0.x signals that are no longer used + (SIGUSR1 and SIGUSR2), since the default handler of these signals is to + terminate tincd immediately. + +commit 5989a29d7b53b25e8ed2f60bc3a0e089e423c02c +Author: Guus Sliepen +Date: Fri Jun 3 00:46:56 2011 +0200 + + Fix format strings for Windows. + + Windows doesn't like %zd, so cast (s)size_t to int. Also, some shorts were + incorrectly printed with %d instead of %hd. + +commit 3ade33bfac11715190ed3e6cc3589d1a738ce257 +Author: Guus Sliepen +Date: Fri Jun 3 00:34:30 2011 +0200 + + Use send() when writing to sockets, and the return type is ssize_t. + +commit 5f4d57e846b566e80557c57a72e2bad562f66e7b +Author: Guus Sliepen +Date: Thu Jun 2 23:40:27 2011 +0200 + + Small fixes for Windows. + +commit 2adc789401153ffde847f76155e07665fbf909ac +Author: Guus Sliepen +Date: Thu Jun 2 22:14:53 2011 +0200 + + Even simpler signal handling. + +commit 2f42896789a1798e71374fa2ddf555fe2fa46c44 +Author: Guus Sliepen +Date: Thu Jun 2 21:29:11 2011 +0200 + + Remove debugging message that was accidentily left in. + +commit c6b0e102ad7caabae6876849c97f8acaecf5bc1a +Author: Guus Sliepen +Date: Thu Jun 2 21:16:57 2011 +0200 + + Don't treat packets coming in via TCP as having zero length. + +commit 80ca91769d48e546d3e4cde03c2eb2820c03acc4 +Author: Guus Sliepen +Date: Thu Jun 2 21:14:50 2011 +0200 + + Fix nodes joining the VPN after tincctl top started. + +commit 311f60f4f0bdf974d4890d7eb4a752299d1c9458 +Author: Guus Sliepen +Date: Thu Jun 2 20:48:18 2011 +0200 + + Make traffic statistics more readable with configurable scaling. + +commit a8f0d21330b40993d52421327b1aa33a6ea7acb7 +Author: Guus Sliepen +Date: Thu Jun 2 20:27:16 2011 +0200 + + More stable sorting in tincctl top. + + Although we use qsort(), which is not guaranteed to be stable, resorting the + previously sorted array is more stable than recreating and resorting the array + each time. + +commit 2bda2aa8855ff3ae42aba7aa86e1d7ff2b7a3b34 +Author: Guus Sliepen +Date: Thu Jun 2 18:22:26 2011 +0200 + + Fix some compiler and cppcheck warnings. + +commit 809dfd2f5b08ecbfe55d1a06d267abeef0044b0b +Author: Guus Sliepen +Date: Thu Jun 2 18:07:50 2011 +0200 + + Remove support for the Ethertap device. + +commit af2e0c9a32642065aedd2e67ca1f5791ca7a407d +Author: Guus Sliepen +Date: Thu Jun 2 17:57:53 2011 +0200 + + Remove unused functions and variables. + +commit 9eca49329db0c3b0a80114045cf214eaeaf3d5c2 +Author: Guus Sliepen +Date: Thu Jun 2 17:55:29 2011 +0200 + + Don't #include anymore. + +commit b7754e5aaa3cc453582d6c8c2e66483fdcd1ac0d +Author: Guus Sliepen +Date: Thu Jun 2 17:53:35 2011 +0200 + + Drop the GNU memcmp.c implementation. + +commit 25b467638a23ad03524719329027225ae1da75bc +Author: Guus Sliepen +Date: Thu Jun 2 17:45:06 2011 +0200 + + Drop the GNU malloc.c, realloc.c, and xmalloc.c. + + We live in the 21st century, and we require C99 semantics, so we do not need to + work around buggy libcs. The xmalloc() and related functions are now static + inline functions. + +commit e452a933f9c53fd58db9d932afd15319129dd988 +Author: Guus Sliepen +Date: Thu Jun 2 17:14:30 2011 +0200 + + Simplify signal handling. + + We don't override any signal handlers anymore except those for SIGPIPE and + SIGCHLD. Fatal signals (SIGSEGV, SIGBUS etc.) will terminate tincd and + optionally dump core. The previous behaviour was to terminate gracefully and + try to restart, but that usually failed and made any core dump useless. + +commit 4d440336c3ce68719e23b2fc51fac368e23352ad +Author: Guus Sliepen +Date: Sun May 29 22:34:19 2011 +0200 + + Remove outgoing event in free_connection(). + +commit d29bfc9a450b4758e44757a71675bac631dd3c55 +Author: Guus Sliepen +Date: Sun May 29 22:14:35 2011 +0200 + + Initialise priority field to zero for packets read from the VPN interface. + +commit 4c403840ffdeb2a2ff04c9b7780a407920b2b794 +Author: Guus Sliepen +Date: Sun May 29 22:12:37 2011 +0200 + + Cosmetic fix when pressing 's' in tincctl top. + +commit b3aeaf0f917a895332ff937c7ab64638eacc0eae +Author: Guus Sliepen +Date: Sun May 29 22:10:54 2011 +0200 + + Show hostname and port in error message when connecting to a running tincd. + +commit 04de15984f1479d0142bdfa5bd968274aea2209e +Author: Sven-Haegar Koch +Date: Sun May 29 21:53:21 2011 +0200 + + do_outgoing_connection() may delete a failed connection, and the structure + must not be accessed afterwards. + +commit 82109868b5acd55e452569c565ab6dc090ea1de0 +Author: Sven-Haegar Koch +Date: Sun May 29 21:35:31 2011 +0200 + + src/net_socket.c bind_to_address(): Use after free in error path. + +commit 5bc957074a35e58f49cbcf8d1fb5d6237d37363d +Author: Guus Sliepen +Date: Sun May 29 14:41:05 2011 +0200 + + Allow tincctl to connect to something besides localhost. + + This would allow tincctl to connect to a remote tincd, or to a local tincd that + isn't listening on localhost, for example if it is using the BindToInterface or + BindToAddress options. + +commit 64771f73ebbff04262defcde59263e98f89f0fa1 +Author: Guus Sliepen +Date: Sat May 28 23:46:56 2011 +0200 + + Remove a few unnecessary #includes. + + Some spotted by Michael Tokarev. + +commit 5cff8c47c1781a88123c128a4cec6cdd39925aa5 +Author: Guus Sliepen +Date: Sat May 28 23:42:18 2011 +0200 + + Remove newlines from log messages. + +commit 6d08eb1614b59d5f86a43edda9db06fca72b76cd +Author: Guus Sliepen +Date: Sat May 28 23:36:52 2011 +0200 + + Fix sparse warnings and add an extra sprinkling of const. + + This is more or less the equivalent of Sven-Haegar Koch's fixes in the 1.1 + branch. + +commit e6b21e1a510691a86dcc1ecdf71a80a7c62ff17f +Author: Sven-Haegar Koch +Date: Sat May 28 03:48:07 2011 +0200 + + fgets() returns NULL on error, not < 0 + +commit 434e57ae5ee79b3d990c4d75358047bad641998b +Author: Sven-Haegar Koch +Date: Sat May 28 03:46:39 2011 +0200 + + sparse fixup: warning: Using plain integer as NULL pointer + +commit f4010694b3b16453e5e6298c208910264e326978 +Author: Sven-Haegar Koch +Date: Sat May 28 03:57:20 2011 +0200 + + sparse fixup: warning: non-ANSI function declaration of function '...' + +commit d772289f6d6adfb8932658b533349d43f08ec326 +Author: Sven-Haegar Koch +Date: Sat May 28 03:56:06 2011 +0200 + + sparse fixup: warning: symbol '...' was not declared. Should it be static? + +commit 02e32cf61ee25d3d0e2fc1fef5cd98cbfa1c9a2f +Author: Sven-Haegar Koch +Date: Sat May 28 03:12:03 2011 +0200 + + sparse fixup: error: too many arguments for function send_key_changed + +commit b995243ac3d9605003996ba879808ddcbc77ae15 +Author: Sven-Haegar Koch +Date: Sat May 28 03:08:31 2011 +0200 + + sparse fixup: error: dubious one-bit signed bitfield + +commit bbd0025ae323e7141ba04a5371ec2f3f75f9b059 +Author: Sven-Haegar Koch +Date: Sat May 28 02:57:40 2011 +0200 + + Use same definition for xalloc_fail_func as is really used. + +commit 3fca2cad485ef70360bca085c5c4d052b6deb15b +Author: Sven-Haegar Koch +Date: Sat May 28 01:36:10 2011 +0200 + + Removed two newlines from the end of log messages which created empty lines. + +commit 9cce44dfe3401867f753778b73fd1e7ac1ee3122 +Author: Sven-Haegar Koch +Date: Sat May 28 01:33:45 2011 +0200 + + Fixed error logging on "Input buffer full" condition. + +commit 07ffb1a19859791d419b83a876ba552dadedbf46 +Author: Guus Sliepen +Date: Sun May 22 15:56:04 2011 +0200 + + Make return value of SetPriorityClass() behave the same as setpriority(). + +commit 453c44e7b27d4259461795ab4ec6ef264085dd28 +Author: Guus Sliepen +Date: Sun May 22 14:17:30 2011 +0200 + + Add the ability to dump all traffic going through route() over a control connection. + + One can get the packet stream in pcap format, which can be decoded using + tcpdump, for example: + + tincctl -n pcap | tcpdump -r - + +commit 54c900e961de6065f607f5661edeb7c84be29ea5 +Author: Guus Sliepen +Date: Sun May 22 14:02:27 2011 +0200 + + Reset tcplen after use. + +commit 8ddcad5fa1908727f68abb461b615c666616064f +Author: Guus Sliepen +Date: Sun May 22 13:15:27 2011 +0200 + + Check if an event is initialized before calling event_del(). + + Libevent prints a warning to stderr if we do that. + +commit 931e30f91a9241ab8aa705c911c92ba8943f80fd +Author: Guus Sliepen +Date: Sun May 22 13:15:05 2011 +0200 + + Always compact the buffer if it has reached MAXBUFSIZE. + +commit 90c7fafe594cf6d03c15a072a3d749f3e4d78482 +Author: Guus Sliepen +Date: Sun May 22 12:56:51 2011 +0200 + + Compact input buffer before trying to read instead of after. + + Also log an error when the input buffer contains more than MAXBUFSIZE bytes + already, instead of silently claiming the other side closed the connection. + +commit 8de8f1d9e2c2c02d4a14a5506e7d0d914dc328da +Author: Guus Sliepen +Date: Tue May 17 10:58:22 2011 +0200 + + Fix some compiler warnings. + +commit a80c18dd20e5303b26d5283e6cb5062a1812ddc3 +Author: Guus Sliepen +Date: Tue May 17 10:57:30 2011 +0200 + + Use GetItemCount() on ListCtrls instead of directly accessing ItemCount. + +commit f536504a7de90927b09d16f3bf0d3c6adead9955 +Author: Guus Sliepen +Date: Mon May 16 09:48:19 2011 +0200 + + Add top.h. + +commit e272fab858d5d3eeb43ff9f36268d25d3c6d32f1 +Author: Guus Sliepen +Date: Mon May 16 09:46:54 2011 +0200 + + Add tincctl.h. + +commit 6d97cb1e229c22d1d34aa9889aeaf17644ff06dc +Author: Guus Sliepen +Date: Sun May 15 16:30:13 2011 +0200 + + Nicer top command. + + - Configurable refresh interval. + - Switch between cumulative count or current rate. + - Configurable sorting. + +commit 4574b04f79d79d53492b7e0eb592d64ff9b2362b +Author: Guus Sliepen +Date: Sun May 15 16:29:54 2011 +0200 + + Allow inserting items in the middle of a list. + +commit 97355690b9cf8d8b56a316e01f73f8ff1fee68c8 +Author: Guus Sliepen +Date: Sun May 15 13:16:48 2011 +0200 + + Add a very primitive "top" command to tincctl. + +commit ec495b2f15fc5ae22136c226c7966caf51f643f8 +Author: Guus Sliepen +Date: Sun May 15 12:06:21 2011 +0200 + + Add an autoconf check for the curses library. + +commit 362d8a6358019cb97456c8133832f18798cea41f +Author: Guus Sliepen +Date: Sun May 15 11:59:13 2011 +0200 + + Dump traffic statistics over control sockets. + +commit f5843e7d649f4a7f72cb3fd356bc935457aa492f +Author: Guus Sliepen +Date: Sun May 15 00:42:29 2011 +0200 + + Add per-node traffic counters. + +commit ffa3a443b9f01d3ea0fcb3c4fc6928a5c695cf4a +Author: Guus Sliepen +Date: Sat May 14 22:30:23 2011 +0200 + + Several fixes for the buffer code. + +commit cdb793f687262b9f56823ca9046523a609a758af +Author: Guus Sliepen +Date: Sat May 14 19:20:56 2011 +0200 + + Remove use of bufferevent and eventbuffers, use our own buffering instead. + +commit f431fcb35f400be388a905ae0f7f50c1f5c4cd5d +Author: Guus Sliepen +Date: Sat May 14 19:15:04 2011 +0200 + + Add simple buffer management code. + + Libevent 2.0's buffer code is not completely backward compatible with 1.4's. + In order to not (mis)use it anymore, we implement it ourselves. The buffers + are automatically expanding when necessary. When consuming data from the + buffer, no memmove()s are performed. Only when adding to the buffer would + write past the end do we shift everything back to the start. + +commit 3794e551c7db9aa81405f65f7b04a9951c4120b2 +Author: Guus Sliepen +Date: Sat May 14 11:52:35 2011 +0200 + + Fix check for event initialization due to the merge. + +commit 03b7118139f57033659730afb740bf5cef7c961c +Author: Guus Sliepen +Date: Fri May 13 12:37:26 2011 +0200 + + Reorder checks for libraries to allow ./configure LDFLAGS=-static. + + OpenSSL depends on libdl and libz. When linking dynamically, libcrypto will + automatically link with the other two libraries. However, when linking + statically, these libraries need to be specified explicitly while linking. By + moving the autoconf checks for libdl and libz before those for libcrypto, we + ensure the latter test will be done with the proper libraries. + +commit ce8775000ab38229a78ecf3dc26bab008ca0f332 +Merge: 3f59a26 5686ad8 +Author: Guus Sliepen +Date: Mon May 9 21:35:14 2011 +0200 + + Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 + + Conflicts: + NEWS + README + configure.in + doc/tincd.8.in + lib/pidfile.c + src/bsd/device.c + src/dropin.h + src/net.c + src/net_packet.c + src/node.c + src/process.c + src/tincd.c + +commit 5686ad80b545afa3de9ed2f4176a5346e289aaa8 +Author: Guus Sliepen +Date: Sun May 8 23:17:46 2011 +0200 + + Releasing 1.0.14. + +commit 0d906489f2ce9faf81dc230f7db6ab5378573554 +Author: Guus Sliepen +Date: Sun May 8 23:12:44 2011 +0200 + + Include when using intptr_t. + +commit dc887f5011834d5a9a6ec5deb8781c6bfd88c474 +Author: Guus Sliepen +Date: Sun May 8 23:12:06 2011 +0200 + + Ensure proper linking with OpenSSL with recent versions of MinGW. + +commit 67766d65f06854ee894d784f638c5c9cd2b50bca +Author: Guus Sliepen +Date: Sun May 8 21:22:20 2011 +0200 + + Update THANKS and copyright information. + +commit 6e6b037ef4fd9877aeb1d947da7364409fa8cbb7 +Author: Guus Sliepen +Date: Sun May 8 21:06:06 2011 +0200 + + Check for EVP_EncryptInit_ex instead of SHA1_Version in OpenSSL. + + The latter function disappeared, and wasn't actually used in tinc, so now we + check on a function that we do use. + +commit 257cb6ac60bb0924720de9e252cdf7f4759bf741 +Author: Guus Sliepen +Date: Sun May 8 12:40:44 2011 +0200 + + Always use the default signal handler for ABRT signals. + + This will allow coredumps to be generated when tinc is daemonized. + Also add the -kABRT option. + +commit eacb5a28fb4c1515633f2b8a206e7067bc7b8f0c +Author: Guus Sliepen +Date: Sun May 8 12:16:26 2011 +0200 + + Increase threshold for detecting two nodes with the same Name. + + In commit 4a21aabada23d1d2c8a10f54dd7248171c4ec82f, code was added to detect + contradicting ADD_EDGE and DEL_EDGE messages being sent, which is an indication + of two nodes with the same Name connected to the same VPN. However, these + contradictory messages can also happen when there is a network partitioning. In + the former case a loop happens which causes many contradictory message, while + in the latter case only a few of those messages will be sent. So, now we + increase the threshold to at least 10 of both ADD_EDGE and DEL_EDGE messages. + +commit f11c6101f30df645223920bef3eb7592de9bcb79 +Author: Julien Muchembled +Date: Thu Apr 28 13:21:55 2011 +0200 + + Fix command-line '-o' option for host configuration + + This fixes a regression introduced by commit 667b1ba while refactoring option + parsing code. + +commit 0aa86d4b8b3010522e6de8842f5bd29004ba3df6 +Author: Guus Sliepen +Date: Wed Mar 9 09:34:56 2011 +0100 + + Do not set indirect flag on edges from nodes with multiple addresses. + + Since tinc now handles UDP packets with a different source address and port + than used for TCP connections, the heuristic to treat edges as indirect when + tinc could detect that multiple addresses were used does not make sense + anymore, and can actually reduce performance. + +commit 7cf68b5e35c002511cc7468967de6a75934cc998 +Author: Guus Sliepen +Date: Fri Feb 18 23:11:43 2011 +0100 + + Prevent anything from updating our own UDP address. + + Because we don't want to keep track of that, and this will cause the node + structure from being relinked into the node tree, which results in myself + pointing to an invalid address. + +commit cdbbbfabea173894bd2fb5f28135a04ddc5e3fd7 +Author: Guus Sliepen +Date: Fri Feb 18 23:02:11 2011 +0100 + + Fix spurious misidentification of incoming UDP packets. + + When a UDP packet was received with an unknown source address/port, and if it + failed a HMAC check against known keys, it could still incorrectly assign that + UDP address to another node. This would temporarily cause outgoing UDP packets + to go to the wrong destination address, until packets from the correct address + were received again. + +commit 046d83bf91e01bc7a32e66a02758caf228bc4601 +Author: Rumko +Date: Sat Feb 12 18:22:14 2011 +0100 + + DragonFlyBSD support + + * added DragonFly BSD support + * added a check for sys/resource.h (needed on DragonFly) + +commit f017c7f98f8f68d6ca50ebe247f4115aadd93635 +Author: Guus Sliepen +Date: Mon Feb 7 18:34:55 2011 +0100 + + Add support for VDE through libvdeplug. + + When compiled with vde/device.c, tinc will connect to a vde_switch instance + instead of using a tun/tap device. + +commit 8d18cc6c4e625625a2437d26c587f9f382a0c589 +Author: Guus Sliepen +Date: Sat Jan 29 10:49:44 2011 +0100 + + Fix typo spotted by Andrew Scheller. + +commit b3731c04097e66a6b8908bb893c5da831d89c04d +Author: Guus Sliepen +Date: Wed Jan 12 20:57:14 2011 +0100 + + Proper check and dropin replacement for usleep(). + +commit 4b8a5993036fccc2108fcc2550649d9b78fb1ab7 +Author: Guus Sliepen +Date: Sun Jan 2 17:25:24 2011 +0100 + + Update the NEWS. + +commit c228da54d47657811dfb679e7f138cbba58a9f67 +Author: Guus Sliepen +Date: Sun Jan 2 17:25:03 2011 +0100 + + Update the manual. + +commit 4575c6c7dffe228ce302776022a2075b7ef37ab0 +Author: Guus Sliepen +Date: Sun Jan 2 17:24:23 2011 +0100 + + Document the behavior of "-n." + +commit 6c05bf082b1ce9acfc0ebb5c6f32c2ece41c7f80 +Author: Guus Sliepen +Date: Sun Jan 2 16:59:42 2011 +0100 + + Remove unused variables. + +commit 6a51d89cf706bcefce1861a1a66d40ef7d7db43b +Author: Guus Sliepen +Date: Sun Jan 2 16:55:42 2011 +0100 + + Replace bogus #else with #endif. + + Found by cppcheck, which complained about lenin not being initialized, but the + real problem is that reading packets would fail when using code compiled with + --tunemu on a normal tun device. + +commit d7636352ce359e807b392a6e5ac0a6aeff4a63d2 +Author: Guus Sliepen +Date: Sun Jan 2 16:52:36 2011 +0100 + + Limit field width when scanning PID file. + + Cppcheck warns that scanf() might otherwise crash when presented with a huge, + bogus PID file. + +commit 3ce5e292da8bab3a1316faf1ca18625f05074467 +Author: Guus Sliepen +Date: Sun Jan 2 16:50:24 2011 +0100 + + Close all filedescriptors in Solaris close_device(). + +commit f99661a4ca5bacff47239ce7978b9c9948917c54 +Author: Guus Sliepen +Date: Sun Jan 2 15:02:23 2011 +0100 + + Always send MTU probes at least once every PingInterval. + + Before, if MTU probes failed, tinc would stop sending probes until the next + time keys were regenerated (by default, once every hour). Now it continues to + send them every PingInterval, so it recovers faster from temporary failures. + +commit cac0a5c651535e8317839b0deff1ee98086a8184 +Author: Guus Sliepen +Date: Sat Nov 20 14:31:11 2010 +0000 + + Use setpriority() instead of nice() on UNIX-like systems. + + The return value of nice() can not reliably indicate errors. The return value + of the setpriority() call is well-defined. + +commit 3f59a26d8098b8b0902b8746715508360b347f47 +Author: Guus Sliepen +Date: Fri Nov 19 12:26:20 2010 +0000 + + Do not try to dereference myself->connection->config_tree. + + This was a bug introduced due to an incomplete merge (commit + ff71f289022ccb91abc2726f16522d55b5ccf0f6). + +commit 886a6f61a1f4cc48a77b42d10f34f9126377d904 +Merge: 23dddc2 d91903e +Author: Guus Sliepen +Date: Fri Nov 19 12:22:48 2010 +0000 + + Merge branch 'master' into 1.1 + + Conflicts: + src/net_packet.c + src/openssl/rsagen.h + src/protocol_auth.c + src/protocol_key.c + +commit d91903ef3c2a1f4481ae8757bb2b14282f2b7e68 +Author: Guus Sliepen +Date: Tue Nov 16 17:28:41 2010 +0100 + + Attribution for Brandon Black. + +commit e764ff7be9949c91865aff72844357e76ae6dd78 +Author: Guus Sliepen +Date: Tue Nov 16 16:45:36 2010 +0100 + + Fix variable length array declaration. + +commit 5eb0440110f99f0a49838cc00a0686c7a7595663 +Author: Guus Sliepen +Date: Sat Nov 13 21:36:51 2010 +0100 + + Free replay window when freeing a node_t. + +commit a9445e38f25bd24eca289768fc46e44e36b842ac +Author: Guus Sliepen +Date: Sat Nov 13 21:34:59 2010 +0100 + + Fix warning message when setting SO_RCVBUF or SO_SNDBUF fails. + +commit 0d61d4ae1358553fc8dde350747542f137f5cb8b +Author: Brandon L Black +Date: Sat Nov 13 12:05:51 2010 -0600 + + Improved handling of queue-jumping packets on receive + +commit 23acc19bc090051156ad895caed61848f5afb144 +Author: Brandon L Black +Date: Sat Nov 13 12:05:50 2010 -0600 + + Configurable ReplayWindow size, zero disables + +commit 8dfe1b374e165ecba5d3ae324ee834d337476be8 +Author: Brandon L Black +Date: Sat Nov 13 12:05:49 2010 -0600 + + Configurable SO_RCVBUF/SO_SNDBUF for the UDP socket + +commit 3f410e2f8f7c365630f226adf4904935698f9e0d +Author: Brandon L Black +Date: Sat Nov 13 12:05:48 2010 -0600 + + Experimental IFF_ONE_QUEUE support for Linux + +commit 9e3ca397735077f85bbde48c36e1b3e0fa950988 +Author: Guus Sliepen +Date: Sat Nov 13 15:55:38 2010 +0100 + + Use variable length arrays instead of alloca(). + +commit e2e6ec8050274b0a8678d6fc263e7dc4ef66feae +Author: Guus Sliepen +Date: Sat Nov 13 15:50:39 2010 +0100 + + Provide usleep() for Windows. + +commit 23dddc25930bc9033e5a2ac659376032aff44d82 +Author: Guus Sliepen +Date: Sat Nov 13 15:46:19 2010 +0100 + + Link tincctl with dropin.o. + +commit a22041922f160667573e9a5ae3f4195e1668906a +Merge: 8b70c5b 930bf74 +Author: Guus Sliepen +Date: Fri Nov 12 16:15:29 2010 +0100 + + Merge branch 'master' into 1.1 + + Conflicts: + doc/tincd.8.in + lib/pidfile.c + src/graph.c + src/net.c + src/net.h + src/net_packet.c + src/net_setup.c + src/net_socket.c + src/netutl.c + src/node.c + src/node.h + src/protocol_auth.c + src/protocol_key.c + src/tincd.c + +commit 930bf74fbe5ce8363b6cc2ae3a3e960e910e0996 +Author: Guus Sliepen +Date: Fri Nov 12 11:38:05 2010 +0100 + + Don't use strlen() on a NULL pointer. + + A bug introduced in commit 667b1bac77b134cf32c98d5dc25619e8c3303f52 caused tinc + to crash on startup. + +commit a07aa92176571eb7f063708640d0d486280808ef +Author: Guus Sliepen +Date: Fri Nov 12 11:33:01 2010 +0100 + + Add short options -R and -U to the tincd(8) manpage. + +commit 66b7aea294896a99df289231143a506b422b994c +Author: Guus Sliepen +Date: Tue Nov 2 14:23:43 2010 +0100 + + Read error counter must be static. + +commit a91bf2dfcd0f5857905e59da7d944654e0875503 +Author: Guus Sliepen +Date: Tue Nov 2 14:18:35 2010 +0100 + + Quit when there are too many consecutive errors on the tun/tap device. + + Although transient errors sometimes happen on the tun/tap device (for example, + if the kernel is temporarily out of buffer space), there are situations where + the tun/tap device becomes permanently broken. Instead of endlessly spamming + the syslog, we now sleep an increasing amount of time between consecutive read + errors, and if reads still fail after 10 attempts (approximately 3 seconds), + tinc will quit. + +commit aca70cd3c3fe787e62c618849e43f67b3870ac20 +Author: Michael Tokarev +Date: Sun Oct 24 15:23:10 2010 +0400 + + Treat netname="." in a special way. + + Treat netname "." in a special way as if there was no netname + specified. Before, f.e. tincd -n. -k didn't work as it tried + to open /var/run/tinc-.pid. Now -n. works as if there was no + -n option is specified. + + Signed-Off-By: Michael Tokarev + +commit 5f729f76f5a63114df582fc29f4189140c1e5ead +Author: Guus Sliepen +Date: Fri Oct 22 22:46:44 2010 +0200 + + Remove unused variables. + + These were caused by commit 667b1bac77b134cf32c98d5dc25619e8c3303f52. + +commit 20ae7dd8c12390f7360eb28cc17e1b8a8a706b06 +Author: Guus Sliepen +Date: Fri Oct 22 22:43:50 2010 +0200 + + Abort disabling old PEM keys on I/O errors. + +commit a08462bf845973016e061b8ca1233142d80416f6 +Author: Guus Sliepen +Date: Fri Oct 22 22:42:21 2010 +0200 + + Ensure there is a newline character before a PEM key is written. + +commit c6ccbadfcf93a7bd4a88dee8ff146b4db7f85e71 +Author: Guus Sliepen +Date: Fri Oct 22 13:40:04 2010 +0200 + + Attribution for Timothy Redaelli. + +commit 1c2cd7ed273ee1538ff8a13d036c68aa9992c4aa +Author: Guus Sliepen +Date: Fri Oct 22 13:17:42 2010 +0200 + + Attribution for Julien Muchembled. + +commit 667b1bac77b134cf32c98d5dc25619e8c3303f52 +Author: Guus Sliepen +Date: Fri Oct 22 13:06:06 2010 +0200 + + Remove duplicate command-line option parsing. + + Also fix parsing of command-line host configuration options for the local node. + +commit ff71f289022ccb91abc2726f16522d55b5ccf0f6 +Author: Guus Sliepen +Date: Fri Oct 22 12:47:12 2010 +0200 + + Merge local host configuration with server configuration. + + With some exceptions, tinc only accepted host configuration options for the + local node from the corresponding host configuration file. Although this is + documented, many people expect that they can also put those options in + tinc.conf. Tinc now internally merges the contents of both tinc.conf and the + local host configuration file. + +commit 8c3105283ac53f8cc9cc4dde25957ec1cf6b53a0 +Author: Julien Muchembled +Date: Fri Sep 3 13:34:22 2010 +0200 + + New '-o' option to configure server or hosts from command line + + Options given on the command line have precedence over configuration from files. + + This can be useful, for example, for a roaming node, for which 'ConnectTo' and + .Address depends on its location. + +commit 4b6a9f1c1f645ce5989692655337d9e23ca28648 +Author: Guus Sliepen +Date: Fri Jun 4 16:03:19 2010 +0200 + + Do not append an address to ANS_KEY messages if we don't know any address. + + This would let tinc raise an exception when an ANS_KEY request crossed a + DEL_EDGE request for the node sending the key. + +commit 798fa2f04c52b0639713f74b1195847bec40c16a +Author: Guus Sliepen +Date: Fri Jun 4 15:04:08 2010 +0200 + + Use 64 bit counters to keep track of bytes sent/received from the virtual network interface. + +commit 4a21aabada23d1d2c8a10f54dd7248171c4ec82f +Author: Guus Sliepen +Date: Fri Jun 4 14:53:52 2010 +0200 + + Detect and prevent two nodes with the same Name being on the VPN simultaneously. + + In this situation, the two nodes will start fighting over the edges they announced. + When we have to contradict both ADD_EDGE and DEL_EDGE messages, we log a warning, + and with 25% chance per PingTimeout we quit. + +commit dbf3d168b720045328d476f3b9e5f5e45b4ab6de +Author: Guus Sliepen +Date: Fri May 7 12:24:49 2010 +0200 + + Use strrchr() insteaad of rindex(). + + The latter function is deprecated, some build environments do not support. + +commit eda71798749e8b0abf5e8b3cbc11da82aa607f00 +Author: Timothy Redaelli +Date: Tue May 4 15:43:48 2010 +0200 + + Fix warnings under BSD + +commit df985256a766ee90f2fa4269b95fa0565c969dda +Author: Timothy Redaelli +Date: Tue May 4 00:27:44 2010 +0200 + + Fix warnings showed using -D_FORTIFY_SOURCE=2 + +commit f5122ccecee095b9185b2324dea7bcd9655462ee +Author: Guus Sliepen +Date: Sat May 1 15:39:59 2010 +0200 + + Fix all warnings when compiling with mingw64. + +commit ef92a5725c47c6e8e801e07190dd7dd3f9cb3a17 +Author: Guus Sliepen +Date: Sat May 1 15:39:03 2010 +0200 + + OpenSSL 1.0.0 compiled for 64 bit Windows requires linking with -lcrypt32. + +commit 0fdd7da52077d77a11a3646eb3e7d5b6ffa178e8 +Author: Guus Sliepen +Date: Sat May 1 15:38:04 2010 +0200 + + Use intptr_t instead of long to store a pointer. + +commit c94ede3b8708cdf105a3fecfc119a558e1583f27 +Author: Guus Sliepen +Date: Sat May 1 15:37:11 2010 +0200 + + Define WINVER before including any other header file on Windows. + +commit 8b70c5be9bc762d81354f9cd77c3748a44a4956d +Author: Guus Sliepen +Date: Fri Apr 30 23:18:22 2010 +0200 + + Remove obsolete lib/ directory. + +commit ee427cac0d04c60d09cc235c04664eab8b0c6527 +Author: Guus Sliepen +Date: Fri Apr 30 23:13:02 2010 +0200 + + Do not try to free NULL pointers. + +commit 113458c2864ec8c046ab7d63ff1b417252c8e4df +Author: Guus Sliepen +Date: Fri Apr 30 23:11:48 2010 +0200 + + Use correct digest length when checking a received key. + +commit 76b41ba20dc9783ff0d21dd738739a81d62142e7 +Author: Guus Sliepen +Date: Sat Apr 17 12:33:36 2010 +0200 + + Add missing return statement. + +commit 2911af6e23d0dba6d771fcd590551a84bd9dc932 +Author: Guus Sliepen +Date: Sat Apr 17 12:33:15 2010 +0200 + + Fix merge of commit 4a0b9981513059755b9fd15b38fc198f46a0d6f2. + +commit 79e46d08a46f2fef2ee4e8eac7ba487007160564 +Merge: 4ce4af4 4766359 +Author: Guus Sliepen +Date: Sat Apr 17 12:21:53 2010 +0200 + + Merge branch 'master' into 1.1 + + Conflicts: + NEWS + README + configure.in + src/net.c + src/net.h + +commit 4ce4af4c712c80d08630767ec34787253da1021b +Author: Guus Sliepen +Date: Sat Apr 17 12:03:08 2010 +0200 + + Fix experimental GUI when reading hexadecimal values. + +commit 4766359e1426bdf1383c898d6103d8760e5e296d +Author: Guus Sliepen +Date: Sat Apr 17 12:01:38 2010 +0200 + + Fix reading configuration files that do not end with a newline. Again. + +commit 26b8cf8680ae68443dccac2adbc2361caafc3712 +Author: Guus Sliepen +Date: Sun Apr 11 20:40:20 2010 +0200 + + Releasing 1.0.13. + +commit 74653beb5bc510e60579058ee15c0f66350f5137 +Author: Guus Sliepen +Date: Sun Apr 11 19:47:44 2010 +0200 + + Mark Forwarding and DirectOnly options as being experimental. + +commit 0ddce6370d39eff162bd212a6e47fe3a8e96a09e +Author: Guus Sliepen +Date: Sun Apr 11 19:39:31 2010 +0200 + + Don't redefine MAX if it already exists. + +commit a9bbb3357a89e27185312fbce0ee134eda4eda90 +Author: Guus Sliepen +Date: Sun Apr 11 19:20:02 2010 +0200 + + Fixes for definitions under Windows. + +commit 4708f2c89edea4be2562256544cf35309cf1ea89 +Author: Guus Sliepen +Date: Sun Apr 11 18:34:50 2010 +0200 + + Ensure subnet-up/down scripts are called after HUP when necessary. + +commit 32f5524c4b52a2d3a96bc48ee2437f8b9b4dbe10 +Author: Guus Sliepen +Date: Sun Apr 11 04:35:16 2010 +0200 + + Fix reloading Subnets when StrictSubnets is set. + +commit 9f53ab209d8a6a7622a49ed03cef735b6e3f3eeb +Author: Guus Sliepen +Date: Sun Apr 11 00:50:42 2010 +0200 + + Reload Subnets when getting a HUP signal and StrictSubnets is used. + +commit d1cc637470edaed663e694fdeb290eb45cc9ecca +Author: Guus Sliepen +Date: Sat Apr 10 23:55:15 2010 +0200 + + Ensure ICMP_NET_ANO is defined. + +commit f75e71bc693847af71f61fb72cd788e3e47f9bd3 +Author: Guus Sliepen +Date: Sat Apr 3 09:46:45 2010 +0100 + + Convert Port to numeric form before sending it to other nodes. + + If one uses a symbolic name for the Port option, tinc will send that name + literally to other nodes. However, it is not guaranteed that all nodes have + the same contents in /etc/services, or have such a file at all. + +commit e49891e188f618a0e98f1d30bcbf240286e8ad5c +Author: Sven-Haegar Koch +Date: Wed Mar 31 03:56:53 2010 +0200 + + Fixed metadata protokoll corruption on forwarded requests + + When forwarding a metadata request through forward_request() we were + adding the required newline char to our buffer, but then sending the + data without it - this results in the forwarded request and the next one + to be garbled together. + + Additionally while at it add a warning comment that request string is + not zero terminated anymore after a call to the forward_request() + function - for now this is ok as it is not used by any caller after this. + +commit 0310deb225cad21c458fb32fd589027e3f844735 +Author: Sven-Haegar Koch +Date: Fri Mar 26 17:25:18 2010 +0100 + + Demote all LOG_EMERG to LOG_ERR, spamming all xterms is bad. + +commit d5654f568dcaf81341395b52b2711f68c0417ec6 +Author: Sven-Haegar Koch +Date: Fri Mar 26 16:54:13 2010 +0100 + + README.git: tinc 1.1 needs libevent + +commit 685509ffe10d1bf9c409e5ba90f46cd747f2d9cd +Author: Sven-Haegar Koch +Date: Sun Mar 28 17:51:26 2010 +0200 + + Function flush_meta() does not exist anymore. + +commit c6d2b9d734859ccbd9582b28351983a12b04abb0 +Author: Sven-Haegar Koch +Date: Fri Mar 26 17:07:30 2010 +0100 + + Add missing AC_CHECK_HEADERS([dirent.h]) to configure.in + +commit ffa1dc73dcd62a856325641972a13d398aa8121c +Author: Sven-Haegar Koch +Date: Fri Mar 26 17:18:04 2010 +0100 + + Fixed 1.0 miss-merges + +commit 103543aa2c15d9f1e2aa313a2e593a7524cce484 +Merge: 35b1c25 2923549 +Author: Sven-Haegar Koch +Date: Fri Mar 26 16:51:03 2010 +0100 + + Merge branch 'master' into 1.1 + + Conflicts: + NEWS + README + configure.in + have.h + src/conf.c + src/conf.h + src/net.c + src/net_packet.c + src/protocol_key.c + src/protocol_subnet.c + src/route.c + src/tincd.c + +commit 292354912f346fe467f557f0dc026b519997289c +Author: Sven-Haegar Koch +Date: Wed Mar 10 02:50:51 2010 +0100 + + Never delete Subnets when StrictSubnets is set + + If a node is unreachable, and not connected to an edge anymore, it gets + deleted. When this happens its subnets are also removed, which should + not happen with StrictSubnets=yes. + + Solution: + - do not remove subnets in src/net.c::purge(), we know that all subnets + in the list came from our hosts files. + I think here you got the check wrong by looking at the tunnelserver + code below it - with strictsubnets we still inform others but do not + remove the subnet from our data. + - do not remove nodes in net.c::purge() that still have subnets + attached. + +commit 146760bd35b351d58e817ce0e67f5c6f74750cd4 +Author: Guus Sliepen +Date: Wed Mar 10 16:07:01 2010 +0100 + + Fix typo. + +commit f2346771cf5b22092dd3f5af3674008aa1e878d1 +Author: Guus Sliepen +Date: Mon Mar 8 21:44:32 2010 +0100 + + Log unauthorized Subnets when StrictSubnets is set. + +commit ee64b8ef33b709fabfc1ed56762d5f52fc026e52 +Author: Guus Sliepen +Date: Mon Mar 8 17:54:57 2010 +0100 + + ConnectTo does not mean tinc does not listen for incoming connections anymore. + +commit 8ae54dc7c782bcc4b771ec0766fcf9eee115756e +Author: Guus Sliepen +Date: Tue Mar 2 23:27:50 2010 +0100 + + Fixes for the Forwarding option. + +commit 3e4829e78a3c7f7e19017d05611e5b69d5268119 +Author: Guus Sliepen +Date: Tue Mar 2 22:55:24 2010 +0100 + + Add the DirectOnly option. + + When this option is enabled, packets that cannot be sent directly to the destination node, + but which would have to be forwarded by an intermediate node, are dropped instead. + When combined with the IndirectData option, + packets for nodes for which we do not have a meta connection with are also dropped. + +commit 95a6974de173e0cb78611c6704ed09631d510dae +Author: Guus Sliepen +Date: Tue Mar 2 22:34:26 2010 +0100 + + Add the Forwarding option. + + This determines if and how incoming packets that are not meant for the local + node are forwarded. It can either be off, internal (tinc forwards them itself, + as in previous versions), or kernel (packets are always sent to the TUN/TAP + device, letting the kernel sort them out). + +commit 5038964032ef55913b2d4741c67bf191b2208abb +Author: Guus Sliepen +Date: Tue Mar 2 00:18:44 2010 +0100 + + Add the StrictSubnets option. + + When this option is enabled, tinc will not accept dynamic updates of Subnets + from other nodes, but will only use Subnets read from local host config files + to build its routing table. + +commit 9fed0ec34b9208611a7e96a595f23fa04e60a5c0 +Author: Guus Sliepen +Date: Mon Mar 1 23:44:56 2010 +0100 + + Preload all Subnets in TunnelServer mode. + + This simplifies the logic in protocol_subnet.c. + +commit d47ab576a25d91600acf7eecf376ed026bdc9c83 +Author: Guus Sliepen +Date: Mon Mar 1 23:44:46 2010 +0100 + + Check for dirent.h. + +commit 21f33b638291c2ffe7156e6c1e0df339f855d831 +Author: Guus Sliepen +Date: Mon Mar 1 23:35:02 2010 +0100 + + Simplify reading lines from configuration files. + + Instead of allocating storage for each line read, we now read into fixed-size + buffers on the stack. This fixes a case where a malformed configuration file + could crash tinc. + +commit 3cb91d75f874e3398c35cd4280c1e0a1ceeedabc +Author: Guus Sliepen +Date: Sun Feb 28 18:20:13 2010 +0100 + + Clamp MSS to miminum MTU in both directions. + + Clamp MSS of both incoming and outgoing packets, and use the minimum of the + PMTU of both directions when clamping. + +commit ddb8cb0779ed36d17ce186dd0bf67e9f0c860d28 +Author: Timothy Redaelli +Date: Wed Feb 10 14:52:15 2010 +0100 + + Add --disable-zlib configure option + +commit eeb505af36ba9496ad29b32cd0917afb8c6cd355 +Author: Timothy Redaelli +Date: Wed Feb 10 13:24:33 2010 +0100 + + Add --disable-lzo configure option + +commit f7b2a2ea43fca323f543e152e6a43a29a4eb6671 +Author: Guus Sliepen +Date: Wed Feb 3 22:49:48 2010 +0100 + + Releasing 1.0.12. + +commit cd0c2e86a403fc9aabecdc8d51413f94491b5494 +Author: Guus Sliepen +Date: Wed Feb 3 11:18:46 2010 +0100 + + Ensure peers with a meta connection always have our key. + + This keeps UDP probes going, which in turn keeps NAT mappings alive. + +commit 40d91ff619a6ea24a2a35c9d934bcc6bace27e24 +Author: Guus Sliepen +Date: Tue Feb 2 22:49:21 2010 +0100 + + Update copyright notices. + +commit 44f8f61396a92c899172a1863bbc9c705cbfa649 +Author: Guus Sliepen +Date: Tue Feb 2 22:22:27 2010 +0100 + + Try to set DF bit on BSDs as well. + + Every operating system seems to have its own, slightly different way to disable + packet fragmentation. Emit a compiler warning when no suitable way is found. + On OpenBSD, it seems impossible to do it for IPv4. + +commit ed14ef93b47622ba13099dfc6be5335222e987a6 +Author: Guus Sliepen +Date: Tue Feb 2 01:02:40 2010 +0100 + + Immediately exchange keys when establishing a meta connection. + + This in turn will trigger PMTU discovery, and ensures nodes know each others + reflexive UDP address and port. + +commit 4a0b9981513059755b9fd15b38fc198f46a0d6f2 +Author: Guus Sliepen +Date: Tue Feb 2 00:51:44 2010 +0100 + + Determine peer's reflexive address and port when exchanging keys. + + To help peers that are behind NAT connect to each other directly via UDP, they + need to know the exact external address and port that they use. Keys exchanged + between NATted peers necessarily go via a third node, which knows this address + and port, and can append this information to the keys, which is in turned used + by the peers. + + Since PMTU discovery will immediately trigger UDP communication from both sides + to each other, this should allow direct communication between peers behind + full, address-restricted and port-restricted cone NAT. + +commit d15099e0029578bfd24d6b464b941f4693280001 +Author: Guus Sliepen +Date: Sat Jan 23 18:48:01 2010 +0100 + + Be liberal in accepting KEY_CHANGED/REQ_KEY/ANS_KEY requests. + + When we got a key request for or from a node we don't know, we disconnected the + node that forwarded us that request. However, especially in TunnelServer mode, + disconnecting does not help. We now ignore such requests, but since there is no + way of telling the original sender that the request was dropped, we now retry + sending REQ_KEY requests when we don't get an ANS_KEY back. + +commit 469fa318bc817908af9a51e3a980ffc998fae6f2 +Author: Guus Sliepen +Date: Fri Jan 22 21:59:40 2010 +0100 + + Run subnet-up/down scripts for local MAC addresses as well. + +commit 5d194b9f8767390d9fb1170554a8b6928214957a +Author: Guus Sliepen +Date: Fri Jan 22 21:47:26 2010 +0100 + + Fix subnet-up/down scripts being called with an empty SUBNET. + + Commit 052ff8b2c598358d1c5febaa9f9f5fc5d384cfd3 contained a bug that causes + scripts to be called with an empty, or possibly corrupted SUBNET variable when + a Subnet is added or removed while the owner is still online. In router mode, + this normally does not happen, but in switch mode this is normal. + +commit b45511118421920771f5dcd5e4bafc04376e4450 +Author: Guus Sliepen +Date: Sat Jan 16 20:16:33 2010 +0100 + + Make MSS clamping configurable, but enabled by default. + + It can either be set globally in tinc.conf, or per-node in host config files. + +commit 95928f7c2910a7da01a89cdc63c86c4d87fac004 +Author: Guus Sliepen +Date: Sat Jan 16 19:32:33 2010 +0100 + + Also clamp MSS of TCP over IPv6 packets. + +commit b1945f70fe993ca447555a1e27f35638b0c1fd8b +Author: Guus Sliepen +Date: Fri Jan 15 23:41:14 2010 +0100 + + Optimise handling of select() returning <= 0. + + Before, we immediately retried select() if it returned -1 and errno is EAGAIN + or EINTR, and if it returned 0 it would check for network events even if we + know there are none. Now, if -1 or 0 is returned we skip checking network + events, but we do check for timer and signal events. + +commit 51099658c919794cde72ea1107b9d9b9c3cee926 +Author: Guus Sliepen +Date: Fri Jan 15 23:19:08 2010 +0100 + + Ping nodes immediately when receiving SIGALRM. + + One reason to send the ALRM signal is to let tinc immediately try to connect to + outgoing nodes, for example when PPP or DHCP configuration of the outgoing + interface finished. Conversely, when the outgoing interface goes down one can + now send this signal to let tinc quickly detect that links are down too. + +commit 2a538ed34332b3392f866d56accd9efecc9467ed +Author: Guus Sliepen +Date: Fri Jan 15 13:42:37 2010 +0100 + + Clamp MSS of IPv4 SYN packets. + + Some ISPs block the ICMP Fragmentation Needed packets that tinc sends. We + clamp the MSS of IPv4 SYN packets to prevent hosts behind those ISPs from + sending too large packets. + +commit 35b1c25093a478d20e01f0ff391c9cdc9c41c2b8 +Author: Guus Sliepen +Date: Thu Dec 31 13:19:13 2009 +0100 + + Move source from lib/ to src/. + + The utility functions in the lib/ directory do not really form a library. + Also, now that we build two binaries, tincctl does not need everything that was + in libvpn.a, so it is wasteful to link to it. + +commit 41497246eeccbcc417f93c2ae087e927751c6914 +Author: Guus Sliepen +Date: Thu Dec 31 13:09:14 2009 +0100 + + Remove unused AVL tree library. + +commit e4812ba9cc4262ec921944f02639ce55781d7497 +Author: Guus Sliepen +Date: Thu Dec 24 12:42:21 2009 +0100 + + Allow Port and PMTUDiscovery options in tinc.conf, always enable PMTUDiscovery by default. + +commit 7203d5fb07be2d3ae006c2b65d0be1e6533e1273 +Author: Guus Sliepen +Date: Wed Dec 23 19:51:55 2009 +0100 + + Use xstrdup() instead of xasprintf() to copy static strings. + +commit a9a803d5662832eb397837055a49fd94118eabf3 +Author: Guus Sliepen +Date: Wed Dec 23 19:49:38 2009 +0100 + + Allow port to be specified in Address statements. + + This allows one to connect to use more than one port number to connect to + another node. The syntax is now: + + Address = [] + +commit 43e34d8180c90682ed1601dec3de7f68ec96d65b +Author: Guus Sliepen +Date: Wed Dec 23 19:22:06 2009 +0100 + + Do not fragment packets smaller than RFC defined minimum MTUs. + + For IPv6, the minimum MTU is 1280 (RFC 2460), for IPv4 the minimum is actually + 68, but this is such a low limit that it will probably hurt performance, so we + do as if it is 576 (the minimum packet size hosts should be able to handle, RFC + 791). If we detect a path MTU smaller than those minima, and we have to handle + a packet that is bigger than the PMTU but smaller than those minima, we forward + them via TCP instead of fragmenting or returning ICMP packets. + +commit 36261650024ba8e18f9c77396f1d7a4e51f20602 +Author: Guus Sliepen +Date: Sat Dec 19 23:23:25 2009 +0100 + + Do not use hardcoded cipher block length when padding. + +commit f542ef8f9e645bf30e11e196dd768fac4f957eac +Author: Guus Sliepen +Date: Sat Dec 19 22:17:39 2009 +0100 + + Fix alignment of results of RSA operations when using libgcrypt. + + If the result of an RSA encryption or decryption operation can be represented + in less bytes than given, gcry_mpi_print() will not add leading zero bytes. Fix + this by adding those ourself. + +commit 4c68a8cb60eb0a4c05d9ce98963b930a976b55ee +Author: Guus Sliepen +Date: Sat Dec 19 20:53:48 2009 +0100 + + Do not consider unreachable nodes when trying to determine packet origin. + +commit 74e50d52e0e23c9dd1e21fb447f1e1a59d02d0b2 +Author: Guus Sliepen +Date: Sat Dec 19 20:52:19 2009 +0100 + + recv() and recvfrom() return int, do not prematurely cast the return value. + +commit 0bfd69a2736cb98470b47c1f6cba617b58bb86ef +Author: Guus Sliepen +Date: Sat Dec 19 20:26:30 2009 +0100 + + Fix reading raw RSA keys with libgcrypt. + +commit 0ff44fc2417217d542bf0e9a7ecfd20020893bc7 +Author: Guus Sliepen +Date: Sat Dec 19 20:10:38 2009 +0100 + + Reinitialise block cipher IV each time we encrypt a packet when using libgcrypt. + +commit 3c90be7678566203d38624c4a6fe3affaffbe5e3 +Author: Guus Sliepen +Date: Sat Dec 19 18:57:54 2009 +0100 + + Fix block cipher padding when using libgcrypt. + +commit c845bc109c85e6fb350096c63e13ef8e617ee29b +Author: Guus Sliepen +Date: Fri Dec 18 01:15:25 2009 +0100 + + Fix packet authentication. + + This wasn't working at all, since we didn't do HMAC but just a plain hash. + Also, verification of packets failed because it was checking the whole packet, + not the packet minus the HMAC. + +commit 10d609b1f0dd9eeb024cd40359683d48542aecbf +Author: Guus Sliepen +Date: Wed Dec 16 21:18:21 2009 +0100 + + Start of a GUI for tinc. + +commit 55ef2f806f9840103bceb472564a711b22e73d58 +Author: Guus Sliepen +Date: Wed Dec 16 21:16:56 2009 +0100 + + Allow connections to be closed. + + This only closes existing meta connections, it may not affect node + reachability. + +commit f12c36afd5293ddbecccf13f36edb8d36e56f040 +Author: Guus Sliepen +Date: Mon Dec 14 21:25:06 2009 +0100 + + Include missing header files and source directories. + +commit 2a410cd26d25cc01b96d255644df3ad138eae776 +Author: Guus Sliepen +Date: Mon Dec 14 21:20:56 2009 +0100 + + Do not include OpenSSL headers directly. + +commit 5d78e497f1c352c8d490eed1d44d128523a34572 +Author: Guus Sliepen +Date: Fri Dec 11 22:38:06 2009 +0100 + + Fix compiler warnings. + +commit d6c50eb73ad49bd2eac67214995dff76b7a20661 +Merge: fec1479 369fe1a +Author: Guus Sliepen +Date: Fri Dec 11 22:31:27 2009 +0100 + + Merge branch 'master' into 1.1 + + Conflicts: + src/subnet.c + +commit fec14791e869180bb7994ca38ca7006cc2e957fb +Author: Guus Sliepen +Date: Fri Dec 11 22:24:07 2009 +0100 + + Only call ioctlsocket() on Windows. + +commit 369fe1ab1cbfc3f8305de1faab2e30157378b044 +Author: Guus Sliepen +Date: Tue Dec 8 22:18:37 2009 +0000 + + Forget addresses of unreachable nodes. + + We clear the cached address used for UDP connections when a node becomes + unreachable. This also prevents host-up scripts from passing the old, cached + address from when the host becomes reachable again from a different address. + +commit 62f235e05c54e458724f437e519ed1b3e17835b1 +Author: Guus Sliepen +Date: Sat Nov 28 11:56:13 2009 +0000 + + Remove unused variable in lookup_subnet_*() functions. + +commit 92aefd25bf9e8e63f199cc252218f5c427f836b7 +Author: Guus Sliepen +Date: Sat Nov 28 11:52:23 2009 +0000 + + When learning MAC addresses, only check our own Subnets for previous entries. + + Before it would check all addresses, and not learn an address if another node + already claimed that address. This caused fast roaming to fail, the code from + commit 6f6f426b353596edca77829c0477268fc2fc1925 was never triggered. + +commit edebf579f2ea29e6e84360cb13731f5858a1555b +Author: Guus Sliepen +Date: Sat Nov 7 23:43:25 2009 +0100 + + Use the TCP socket infrastructure for control sockets. + + The control socket code was completely different from how meta connections are + handled, resulting in lots of extra code to handle requests. Also, not every + operating system has UNIX sockets, so we have to resort to another type of + sockets or pipes for those anyway. To reduce code duplication and make control + sockets work the same on all platforms, we now just connect to the TCP port + where tincd is already listening on. + + To authenticate, the program that wants to control a running tinc daemon must + send the contents of a cookie file. The cookie is a random 256 bits number that + is regenerated every time tincd starts. The cookie file should only be readable + by the same user that can start a tincd. + + Instead of the binary-ish protocol previously used, we now use an ASCII + protocol similar to that of the meta connections, but this can still change. + +commit c388527e341658dc915dd67c90bbc9b52b8539c0 +Author: Guus Sliepen +Date: Sat Nov 7 16:09:56 2009 +0100 + + Small fixes to get really working control sockets on Windows. + +commit 5c5548fc7185cc1462602dadcd39a53cef481d29 +Author: Guus Sliepen +Date: Sat Nov 7 14:35:48 2009 +0100 + + Better integration of libevent in build system. + + Since event.h is not part of tinc, we include it in have.h were all other + system header files are included. We also ensure -levent comes before -lgdi32 + when compiling with MinGW, apparently it doesn't work when the order is + reversed. + +commit 075264a9e18f9fd58cad044c064a91557e9ed429 +Author: Guus Sliepen +Date: Thu Nov 5 23:29:28 2009 +0100 + + Make sure the 1.1 branch compiles in a MinGW environment. + + UNIX domain sockets, of course, don't exist on Windows. For now, when compiling + tinc in a MinGW environment, try to use a TCP socket bound to localhost as an + alternative. + +commit 08615e420b2dd5054dd978bf53c88b8dde6e4788 +Author: Guus Sliepen +Date: Thu Nov 5 00:02:42 2009 +0100 + + Handle PKCS#5 padding in the gcrypt backend. + +commit d9b2ac6767f85927a26e2b95bba69c052ac503ac +Author: Guus Sliepen +Date: Thu Nov 5 00:01:25 2009 +0100 + + Handle truncated message authentication codes with gcrypt. + + Commit 4124b9682f8f890acb25d0c92f2583eef670274a did not update the gcrypt + backend. + +commit c4afc481541bff4db7f57c81796b7a5f61cdb1b5 +Author: Guus Sliepen +Date: Wed Nov 4 16:19:08 2009 +0100 + + Use %x instead of %lx where appropriate. + + Some conversions were not properly merged from the master branch. + +commit 37ccb325af5c7865eb16716780121a8a6dce8abd +Author: Guus Sliepen +Date: Wed Nov 4 16:18:08 2009 +0100 + + Don't enable device events when there is no valid filedescriptor. + +commit 108b238915c5f58b3d94ab433dc5d04e064c2b11 +Merge: 761517c 44834d0 +Author: Guus Sliepen +Date: Mon Nov 2 14:24:27 2009 +0100 + + Merge branch 'master' into 1.1 + + Conflicts: + NEWS + README + configure.in + doc/tinc.texi + doc/tincd.8.in + src/Makefile.am + src/connection.c + src/edge.c + src/meta.c + src/net.c + src/net.h + src/net_packet.c + src/net_setup.c + src/net_socket.c + src/node.c + src/openssl/rsagen.h + src/protocol_auth.c + src/protocol_edge.c + src/subnet.c + +commit 44834d030464bbe1f7733caba8d96c678f1d6cf2 +Author: Guus Sliepen +Date: Sun Nov 1 16:24:39 2009 +0100 + + Releasing 1.0.11. + +commit d331f04e4598824afc7de33ac1228cf441ae9872 +Author: Guus Sliepen +Date: Sun Nov 1 15:57:28 2009 +0100 + + Start a tinc service if it already exists. + +commit 6f6f426b353596edca77829c0477268fc2fc1925 +Author: Guus Sliepen +Date: Tue Oct 27 23:53:49 2009 +0100 + + Fast handoff of roaming MAC addresses. + + In switch mode, if a known MAC address is claimed by a second node before it + expired at the first node, it is likely that this is because a computer has + roamed from the LAN of the first node to that of the second node. To ensure + packets for that computer are routed to the second node, the first node should + delete its corresponding Subnet as soon as possible, without waiting for the + normal expiry timeout. + +commit e00b44cb98e4d50a0d426048ba01dbd80bcb5941 +Author: Guus Sliepen +Date: Sun Oct 25 01:40:07 2009 +0200 + + Move socket error interpretation to utils.h. + +commit c11dc8079b60d9f8c5b1c7e8fecd90d0fac5a20c +Author: Guus Sliepen +Date: Sun Oct 25 00:50:09 2009 +0200 + + Use WSAGetLastError() to determine cause of network errors on Windows. + + This reduces log spam and lets path MTU discovery work faster. + +commit 1bca167b7e24a9cb00ad6130c24f0bb60e208f1f +Author: Michael Tokarev +Date: Sun Oct 18 21:27:24 2009 +0400 + + Remove localedir leftovers. + +commit c3acae034c4da2d1c70f31b852b14ca098c0eeb9 +Author: Guus Sliepen +Date: Sat Oct 24 22:32:35 2009 +0200 + + Use IP_DONTFRAGMENT instead of IP_MTU_DISCOVER on Windows. + + This ensures the DF bit on outgoing UDP packets gets set on Windows when path + MTU discovery is enabled, reducing fragmentation. + +commit 242c4e2ca67d0b5c78dfe6e68a5ddcd27be1de99 +Author: Guus Sliepen +Date: Sat Oct 24 21:53:01 2009 +0200 + + Forward packets to not directly reachable hosts via UDP if possible. + + If MTU probing discovered a node was not reachable via UDP, packets for it were + forwarded to the next hop, but always via TCP, even if the next hop was + reachable via UDP. This is now fixed by retrying to send the packet using + send_packet() if the destination is not the same as the nexthop. + +commit d922db253cd098bc038449e5c591cc94c1019952 +Author: Guus Sliepen +Date: Sat Oct 24 21:35:40 2009 +0200 + + Make maxmtu equal to minmtu when fixing the path MTU to a node. + + This ensures MTU probes used to ping nodes are not too large, and prevents + restarting MTU probing unnecessarily. + +commit a8f7fccbc2b5f1c4c39fc2804abaa358b31a5080 +Author: Guus Sliepen +Date: Sat Oct 24 21:32:06 2009 +0200 + + Always reply to MTU probes via UDP. + + It could sometime happen that a node would return MTU probes via TCP, which + does not make a lot of sense. + +commit cddcdc9af34afb388a8e4bdfff6882f568b98313 +Author: Guus Sliepen +Date: Sat Oct 24 20:54:44 2009 +0200 + + Allow UDP packets with an address different from the corresponding TCP connection. + +commit 5cbddc68bade0d1f8ded1b784bb27bb44c5dc5dc +Author: Guus Sliepen +Date: Sat Oct 24 16:15:24 2009 +0200 + + Use uint32_t instead of long int for connection options. + + Options should have a fixed width anyway, but this also fixes a possible MinGW + compiler bug where %lx tries to print a 64 bit value, even though a long int is + only 32 bits. + +commit 468f393c4fabf9223a1bd15adfb3906cde90d547 +Author: Guus Sliepen +Date: Sat Oct 24 16:05:12 2009 +0200 + + Add dummy device. + +commit b6543af7626403516b5fc54c24b11d3a242a2992 +Author: Guus Sliepen +Date: Tue Oct 20 22:39:07 2009 +0200 + + Clarify and increase level of log message about MTU probes to unreachable nodes. + +commit 43a6e786648fb666a9b7be8f05c8a173031c9110 +Author: Guus Sliepen +Date: Tue Oct 20 22:33:16 2009 +0200 + + Handle weighted Subnets in switch and hub modes. + + We now handle MAC Subnets in exactly the same way as IPv4 and IPv6 Subnets. + This also fixes a problem that causes unncessary broadcasting of unicast + packets in VPNs where some daemons run 1.0.10 and some run other versions. + +commit 3a925479c2883a6a9711f7b6931863d7f2a2c09b +Author: Guus Sliepen +Date: Tue Oct 20 22:22:59 2009 +0200 + + Starting to work towards 1.0.11. + +commit 35af4051c3749cd2c2137a7eb57171a1fbb12af7 +Author: Guus Sliepen +Date: Tue Oct 20 22:14:47 2009 +0200 + + Fix a possible crash when sending the HUP signal. + + When the HUP signal is sent while some outgoing connections have not been made + yet, or are being retried, a NULL pointer could be dereferenced resulting in + tinc crashing. We fix this by more careful handling of outgoing_ts, and by + deleting all connections that have not been fully activated yet at the HUP + signal is received. + +commit 8c267d3d558ac97a4ce7381a37abb6cc4b46b133 +Author: Guus Sliepen +Date: Sun Oct 18 16:45:13 2009 +0200 + + Releasing 1.0.10. + +commit 3849de9a331ad132ed9d01c9f0cac47196624b3e +Author: Guus Sliepen +Date: Sun Oct 18 16:44:32 2009 +0200 + + Fix description of the WEIGHT environment variable. + +commit 87364c16564c897b1a2d306615804d68ea5a9ba1 +Author: Guus Sliepen +Date: Sun Oct 18 14:22:20 2009 +0200 + + Include missing header. + +commit c7fdc7d5b8d728c744b13a823e7eef9d2432c61e +Author: Guus Sliepen +Date: Mon Oct 12 23:51:57 2009 +0200 + + Remove debugging message when reading packets from a BSD device. + + This was inadvertently introduced by commit + 4a5d42178cc0954efba8b24058da9c70cc77c35a. + +commit ec4c8bcb18c1f463cf4544126e027fc8ec9b3a39 +Author: Guus Sliepen +Date: Mon Oct 12 22:14:47 2009 +0200 + + Allow the cloning /dev/tap interface to be used on FreeBSD and NetBSD. + + This device works like /dev/tun on Linux, automatically creating a new tap + interface when a program opens it. We now pass the actual name of the newly + created interface in $INTERFACE. + +commit 92b8abc921dd15b710f67335562210eb713fbb39 +Author: Guus Sliepen +Date: Sun Oct 11 18:57:58 2009 +0200 + + Use MTU probes to regularly ping other nodes over UDP. + + This keeps NAT mappings for UDP alive, and will also detect when a node is not + reachable via UDP anymore or if the path MTU is decreasing. Tinc will fall back + to TCP if the node has become unreachable. + + If UDP communication is impossible, we stop sending probes, but we retry if it + changes its keys. + + We also decouple the UDP and TCP ping mechanisms completely, to ensure tinc + properly detects failure of either method. + +commit 927064e5fd0ebf29a7ea768a7f9c4226da626a72 +Author: Guus Sliepen +Date: Sun Oct 11 15:46:52 2009 +0200 + + Small updates to the documentation. + + Mention that TCPOnly is not necessary anymore since tinc will autodetect + whether it can send via UDP or not. Also mention the WEIGHT environment + variable and the new default value (2048 bits) of RSA keys. + +commit 2c30af6c90926340a89748c63cc453b1c0b5a589 +Author: Guus Sliepen +Date: Sun Oct 11 14:20:14 2009 +0200 + + Ensure that the texinfo manual can be converted to HTML. + + The top node was made conditional with the @iftex command, since it should not + appear in PostScript and PDF output. However, it is still necessary for + texi2html, so we have to use @ifnottex instead. + + Texi2html also complains about the use of @cindex in the copyright statement, + so we remove that. + +commit a4f132770dc136d456c67b01d209e73f5f4d7a65 +Author: Guus Sliepen +Date: Sun Oct 11 13:56:04 2009 +0200 + + Revert "Raise default crypto algorithms to AES256 and SHA256." + + Although it would be better to have the new defaults, only the most recent + releases of most of the platforms supported by tinc come with a version of + OpenSSL that supports SHA256. To ensure people can compile tinc and that nodes + can interact with each other, we revert the default back to Blowfish and SHA1. + + This reverts commit 4bb3793e38b7c7f24dd308801e7f6dbb02cf02d2. + +commit 2762509be179dcb21d855f3d6f90d3ee686e3910 +Author: Guus Sliepen +Date: Sun Oct 11 13:54:05 2009 +0200 + + Remove code duplication when checking ADD_EDGE/DEL_EDGE messages. + +commit 5cddf5e52aeb20e50c887356ad23aec354e04151 +Author: Guus Sliepen +Date: Sun Oct 11 13:51:10 2009 +0200 + + Don't disconnect clients in TunnelServer mode who send unauthorised ADD_SUBNETs. + + So that we are liberal in what we accept. + +commit 430c90412c521c534113b3c4e5fc883e9b7ecff0 +Author: Borg +Date: Sat Oct 3 13:06:00 2009 +0200 + + Removed last gettext function. + +commit 3282375f4d64d9402141ac4bf142629ec2e1cd53 +Author: Guus Sliepen +Date: Tue Sep 29 16:25:20 2009 +0200 + + Remove autogenerated files from EXTRA_DIST. + + Apparently they were once necessary, but autoconf now includes them + automatically. Some of them are not used anymore, and this caused make dist to + fail. + +commit 761517c21c37a808a19b487aa116c3c19439feca +Author: Guus Sliepen +Date: Tue Sep 29 15:33:58 2009 +0200 + + Update FSF address in files not covered by the merge. + +commit 07a560eab66b575f382428a956550817697e25e2 +Author: Guus Sliepen +Date: Tue Sep 29 15:19:55 2009 +0200 + + Drop localisation and checkpoint tracing in files not covered by the merge. + +commit 7ea85043ac1fb2096baea44f6b0af27ac0d0b2cf +Merge: f1fec46 9a2b0f8 +Author: Guus Sliepen +Date: Tue Sep 29 14:55:29 2009 +0200 + + Merge branch 'master' into 1.1 + + Conflicts: + NEWS + configure.in + lib/Makefile.am + lib/pidfile.c + lib/pidfile.h + lib/utils.c + po/POTFILES.in + po/nl.po + src/Makefile.am + src/bsd/device.c + src/conf.c + src/connection.c + src/cygwin/device.c + src/edge.c + src/event.c + src/graph.c + src/linux/device.c + src/meta.c + src/mingw/device.c + src/net.c + src/net_packet.c + src/net_setup.c + src/net_socket.c + src/netutl.c + src/node.c + src/process.c + src/protocol.c + src/protocol_auth.c + src/protocol_edge.c + src/protocol_key.c + src/protocol_misc.c + src/protocol_subnet.c + src/raw_socket/device.c + src/route.c + src/solaris/device.c + src/subnet.c + src/tincd.c + src/uml_socket/device.c + +commit 9a2b0f88a9cae753ebc81c939d01403178b18a35 +Author: Guus Sliepen +Date: Sat Sep 26 12:51:52 2009 +0200 + + Update the NEWS. + +commit 46e481dc945c5572eb6091a3660f6bf258ee0cfa +Author: Guus Sliepen +Date: Fri Sep 25 21:14:56 2009 +0200 + + Add more authors to the copyright headers. + + Git's log and blame tools were used to find out which files had significant + contributions from authors who sent in patches that were applied before we used + git. + +commit 4c85542894f7fca823b119b05e07179deb24229a +Author: Guus Sliepen +Date: Fri Sep 25 00:54:07 2009 +0200 + + Drop support for localisation. + + Localised messages don't make much sense for a daemon, and there is only the + Dutch translation which costs time to maintain. + +commit a227843b739d279b63adcf3736ebb03d856080c4 +Author: Guus Sliepen +Date: Fri Sep 25 00:33:04 2009 +0200 + + Remove checkpoint tracing. + + This feature is not necessary anymore since we have tools like valgrind today + that can catch stack overflow errors before they make a backtrace in gdb + impossible. + +commit 5dde6461a321ee47b06e33f8203f2acf00a31a51 +Author: Guus Sliepen +Date: Fri Sep 25 00:14:03 2009 +0200 + + K&R style braces. + + This is essentially commit f02d3ed3e135b5326003e7f69f8331ff6a3cc219 from the + 1.1 branch, making it easier to merge between master and 1.1. + +commit ab7c61b06f6c6e991225f2fcc32d02b8e1084aee +Author: Guus Sliepen +Date: Fri Sep 25 00:01:00 2009 +0200 + + Update the address of the Free Software Foundation in all copyright headers. + +commit 0e6856b1379e278aa5ed116d0911851339a6064c +Author: Guus Sliepen +Date: Thu Sep 24 23:42:30 2009 +0200 + + Remove Ivo's old email addresses. + +commit c217d214f4f071c235bc7c463a1da6124e2570a6 +Author: Guus Sliepen +Date: Thu Sep 24 23:39:16 2009 +0200 + + Remove all occurences of $Id$. + +commit c23fcf555ee4b69f03b76a0ffb731c3a475a77e7 +Author: Guus Sliepen +Date: Thu Sep 24 23:29:46 2009 +0200 + + Update copyright information. + + - Update year numbers in copyright headers. + - Add copyright information for Michael Tokarev and Florian Forster to the + copyright headers of files to which they have contributed significantly. + - Mention Michael and Florian in AUTHORS. + - Mention that tinc is GPLv3 or later if compiled with the --enable-tunemu + flag. + +commit f1fec466e232c00c668422014029dce9114d3add +Author: Guus Sliepen +Date: Wed Sep 16 23:43:19 2009 +0200 + + Add a better autoconf check for libevent. + +commit 4bdf0e80ee4cd0d40eb6522dab05df9346a5b3d0 +Author: Guus Sliepen +Date: Wed Sep 16 20:28:30 2009 +0200 + + Replace asprintf()s not covered by the merge to xasprintf(). + +commit 1cbddbd573d786f6b2bf9812dda89d1ea5b7e021 +Author: Guus Sliepen +Date: Wed Sep 16 20:17:11 2009 +0200 + + Use correct format specifiers. + +commit 2f97bdb46b1ed0a669619e0b9acf76f43dfa648b +Author: Guus Sliepen +Date: Wed Sep 16 20:16:54 2009 +0200 + + Add missing #include. + +commit 075e6828a7533e7daa790225f17aa6bb39703278 +Merge: 9b129c0 b5ccce2 +Author: Guus Sliepen +Date: Wed Sep 16 19:55:47 2009 +0200 + + Merge branch 'master' into 1.1 + + Conflicts: + have.h + lib/dropin.c + lib/fake-getaddrinfo.c + lib/pidfile.c + src/Makefile.am + src/bsd/device.c + src/conf.c + src/connection.c + src/connection.h + src/graph.c + src/mingw/device.c + src/net.c + src/net_setup.c + src/node.c + src/protocol_key.c + src/protocol_misc.c + src/tincd.c + +commit b5ccce296848aab72d574ca3de14af5fdf3efa4d +Author: Guus Sliepen +Date: Tue Sep 15 23:22:13 2009 +0200 + + Send large packets we cannot handle properly via TCP. + + During the path MTU discovery phase, we might not know the maximum MTU yet, but + we do know a safe minimum. If we encounter a packet that is larger than that + the minimum, we now send it via TCP instead to ensure it arrives. We also + allow large packets that we cannot fragment or create ICMP replies for to be + sent via TCP. + +commit d273efb177738d429e3cef7d8db8ee5cc8dcada7 +Author: Guus Sliepen +Date: Tue Sep 15 23:04:52 2009 +0200 + + Raise default RSA key length to 2048 bits. + +commit b47c17bcdeb70b63ad9346dc97ba575597cbd803 +Author: Guus Sliepen +Date: Tue Sep 15 22:59:01 2009 +0200 + + Use a mutex to allow the TAP reader to process packets faster on Windows. + + The TAP-Win32 device is not a socket, and select() under Windows only works + with sockets. Tinc used a separate thread to read from the TAP-Win32 device, + and passed this via a local socket to the main thread which could then select() + from it. We now use a global mutex, which is only unlocked when the main thread + is waiting for select(), to allow the TAP reader thread to process packets + directly. + +commit 802a50ffcd5f39bfc6424ac841de4e41154092fc +Author: Guus Sliepen +Date: Tue Sep 15 22:58:16 2009 +0200 + + Remove extra {. + +commit 4bb3793e38b7c7f24dd308801e7f6dbb02cf02d2 +Author: Guus Sliepen +Date: Tue Sep 15 12:08:05 2009 +0200 + + Raise default crypto algorithms to AES256 and SHA256. + + In light of the recent improvements of attacks on SHA1, the default hash + algorithm in tinc is now SHA256. At the same time, the default symmetric + encryption algorithm has been changed to AES256. + +commit 633c0cf1b067d118d5453bc8522fab65ffc82d2c +Author: Guus Sliepen +Date: Tue Sep 15 00:36:07 2009 +0200 + + Use access() instead of stat() for checking whether scripts exist. + +commit 6f1e0ece4e61f30612ed84ca4640635a02892cc8 +Author: Guus Sliepen +Date: Tue Sep 15 00:28:20 2009 +0200 + + Remove dropin random() function, as it is not used anymore. + +commit fa9bedd47cf8c143e801889c78f0a0979ac4d2fc +Author: Guus Sliepen +Date: Tue Sep 15 00:24:31 2009 +0200 + + Allow compiling for Windows XP and higher. + + This allows us to use getaddrinfo(), getnameinfo() and related functions, which + allow tinc to make connections over existing IPv6 networks. These functions are + not available on Windows 2000 however. By default, support is enabled, but when + compiling for Windows 2000 the configure switch --with-windows2000 should be + used. + + Since getaddrinfo() et al. are not functions but macros on Windows, we have to + use AC_CHECK_DECLS() instead of AC_CHECK_FUNCS() in configure.in. + +commit f80bf14f28925df6eaa56f3ed77adaf418ab9890 +Author: Guus Sliepen +Date: Mon Sep 14 23:28:28 2009 +0200 + + Also do not use drand48(), it is not available on Windows. + +commit 35e87b903e08fc51975a8cc97f06251d5153a424 +Author: Guus Sliepen +Date: Mon Sep 14 23:06:00 2009 +0200 + + Use only rand(), not random(). + + We used both rand() and random() in our code. Since it returns an int, we have + to use %x in our format strings instead of %lx. This fixes a crash under + Windows when cross-compiling tinc with a recent version of MinGW. + +commit 75773efe2689d347a2f219c5f27e4a82eef1236b +Author: Guus Sliepen +Date: Sun Sep 13 14:08:59 2009 +0200 + + Apparently it's impolite to ask GCC to subtract two pointers. + + If two pointers do not belong to the same array, pointer subtraction gives + nonsensical results, depending on the level of optimisation and the + architecture one is compiling for. It is apparently not just subtracting the + pointer values and dividing by the size of the object, but uses some kind of + higher magic not intended for mere mortals. GCC will not warn about this at + all. Casting to void * is also a no-no, because then GCC does warn that strict + aliasing rules are being broken. The only safe way to query the ordering of two + pointers is to use the (in)equality operators. + + The unsafe implementation of connection_compare() has probably caused the "old + connection_t for ... still lingering" messages. Our implementation of AVL trees + is augmented with a doubly linked list, which is normally what is traversed. + Only when deleting an old connection the tree itself is traversed. + +commit 23e151aeed6b3ffe0fab10f51ffdb134deb7a852 +Author: Guus Sliepen +Date: Sun Sep 13 14:07:40 2009 +0200 + + Remove superfluous call to avl_delete(). + +commit 9915f2abbedb7f1aa2b9e2f81d52ddcfca60e82d +Author: Guus Sliepen +Date: Sat Sep 12 14:19:36 2009 +0200 + + Handle unicast packets larger than PMTU in switch mode. + + If PMTUDiscovery is enabled, and we see a unicast packet that is larger than + the path MTU in switch mode, treat it just like we would do in router mode. + +commit 7242868b64f9d6f62b6c5bbf1526eb632ed9a4d6 +Author: Guus Sliepen +Date: Sat Sep 12 13:40:32 2009 +0200 + + Allow PMTUDiscovery in switch and hub modes again. + + PMTUDiscovery was disabled in commit d5b56bbba56480b5565ffb38496175a7c1df60ac + because tinc did not handle packets larger than the path MTU in switch and hub + modes. We now allow it again in preparation of proper support, but default to + off. + +commit 052ff8b2c598358d1c5febaa9f9f5fc5d384cfd3 +Author: Guus Sliepen +Date: Sat Sep 12 13:34:11 2009 +0200 + + Put Subnet weight in a separate environment variable. + + Commit 5674bba5c54c1aee3a4ac5b3aba6b3ebded91bbc introduced weighted Subnets, + but the weight was included in the SUBNET variable passed to subnet-up/down + scripts. This makes it harder to use in those scripts. The weight is now + stripped from the SUBNET variable and put in the WEIGHT variabel. + +commit a60a0a1f1357508063ee565d672c39898a787e33 +Author: Guus Sliepen +Date: Thu Sep 10 19:51:08 2009 +0200 + + Don't stat() on iPhone/iPod. + + Grzegorz Dymarek noted that tinc segfaults at the stat() call in + execute_script() on the iPhone. We can omit the stat() call for the moment, + the subsequent call to system() will fail with just a warning. + +commit 4a5d42178cc0954efba8b24058da9c70cc77c35a +Author: Guus Sliepen +Date: Thu Sep 10 19:32:54 2009 +0200 + + Add support for iPhones and recent iPods. + + This is a slightly modified patch from Grzegorz Dymarek that allows tinc to use + the tunemu device, which allows tinc to be compiled for iPhones and recent + iPods. To enable support for tunemu, the --enable-tunemu option has to be used + when running the configure script. + +commit ff946d0423fe547ea42bb11acfb3035c3b8aee4e +Author: Guus Sliepen +Date: Wed Sep 9 14:51:36 2009 +0200 + + Another safe bitfield conversion. + +commit dd6226062c2356d2a3679e2c7972be71233cb9de +Author: Guus Sliepen +Date: Wed Sep 9 13:23:16 2009 +0200 + + Add the GPL license to the repository. + + Tinc is licensed under the GPL version 2 or later. To ensure autoconf does not + install the wrong license if COPYING is missing, we have to put the right one + in place. + +commit 81afa26e4ad53bea00da18a7666f63d33cf3f588 +Author: Guus Sliepen +Date: Wed Sep 9 12:04:08 2009 +0200 + + Convert bitfields to integers in a safe way. + + This is commit eb391c52eed46f3f03b404553df417851fc0cb90 redone, but without the + non-standard anonymous union. + +commit 9b394bc887695da6db74f4b9796b4823e553f8cc +Author: Guus Sliepen +Date: Tue Sep 8 21:45:24 2009 +0200 + + Ensure tinc compiles with gcc -std=c99. + + We use a lot of C99 features already, but also some extensions which are not in + the standard. + +commit f52ea0a7eb0383cc2a5f41db1bf24c39424fdb04 +Author: Guus Sliepen +Date: Tue Sep 8 18:21:52 2009 +0200 + + UNIX signal numbers start at 1. + +commit 73d77dd416b87b7c4e9b6aa450f64846235cd2b4 +Author: Guus Sliepen +Date: Tue Sep 8 18:18:36 2009 +0200 + + Replace asprintf() by xasprintf(). + +commit 3e55dc77f4ba19fd9e79f3d5ce9d28bb6b05019e +Author: Guus Sliepen +Date: Tue Sep 8 18:18:16 2009 +0200 + + Check the return value of fscanf() when reading a PID file. + +commit 5e0efd53e797a2b5468b91b41b6122f3b942efb2 +Author: Guus Sliepen +Date: Tue Sep 8 18:16:58 2009 +0200 + + Add xasprintf() and xvasprintf(). + + These functions wrap asprintf() and vasprintf(), and check the return value. If + the function failed, tinc will exit with an error message, similar to xmalloc() + and friends. + +commit 63fe89e9eb8ef9077bfe3cd416c86820715eb33b +Author: Michael Tokarev +Date: Sat Sep 5 17:24:41 2009 +0400 + + Remove extra semicolon in my definition of setpriority() + +commit 5a7fc58012da10b96073804994777255463d1b8d +Author: Guus Sliepen +Date: Tue Sep 8 16:35:28 2009 +0200 + + Always remove a node from the UDP tree before freeing it. + + Valgrind caught tinc reading free'd memory during a purge(). This was caused by + first removing it from the main node tree, which will already call free_node(), + and then removing it from the UDP tree. This might cause spurious segmentation + faults. + +commit de029ce46056e02908b5390da9b71a6a59133f26 +Author: Guus Sliepen +Date: Thu Jun 11 19:39:25 2009 +0200 + + Change level of some debug messages, zero pointer after freeing hostname. + +commit 66be914d35cb7e7ea4dd4aed68ae9e41addd9f70 +Author: Guus Sliepen +Date: Thu Jun 11 19:26:34 2009 +0200 + + Do not log errors when recvfrom() returns EAGAIN or EINTR. + + Although we select() before we call recvfrom(), it sometimes happens that + select() tells us we can read but a subsequent read fails anyway. This is + harmless. + +commit df4add94a4a6461758b218a9ad257efc735062fe +Author: Guus Sliepen +Date: Thu Jun 11 19:07:54 2009 +0200 + + Remove pending MTU probe events when a node's reachability status changes. + +commit 36f8e4da8b1708474505f5a1fa8cf1ba848921de +Author: Guus Sliepen +Date: Thu Jun 11 18:36:08 2009 +0200 + + Don't try to send MTU probes to unreachable nodes. + + If there is an outstanding MTU probe event for a node which is not reachable + anymore, a UDP packet would be sent to that node, which caused a key request to + be sent to that node, which triggered a NULL pointer dereference. Probes and + other UDP packets to unreachable nodes are now dropped. + +commit 9b129c07e273ae113f3c67a9feeee82e8146f3a1 +Author: Guus Sliepen +Date: Sat Jun 6 20:14:51 2009 +0200 + + Fix pointer arithmetic when creating and verifying message authentication codes. + +commit 4124b9682f8f890acb25d0c92f2583eef670274a +Author: Guus Sliepen +Date: Sat Jun 6 19:04:04 2009 +0200 + + Handle truncated message authentication codes. + +commit 5a132550deb58473285e5f91705d286aef47be71 +Merge: 08aabbf 591c38e +Author: Guus Sliepen +Date: Fri Jun 5 23:03:28 2009 +0200 + + Merge branch 'master' into 1.1 + + Conflicts: + doc/tincd.8.in + lib/pidfile.c + src/graph.c + src/net.c + src/net.h + src/net_packet.c + src/net_setup.c + src/net_socket.c + src/netutl.c + src/node.c + src/node.h + src/protocol_auth.c + src/protocol_key.c + src/tincd.c + +commit 261d1eac1c5bbe6c87aa707566f290e611169432 +Author: Guus Sliepen +Date: Fri Jun 5 16:14:31 2009 +0200 + + Properly set HMAC length for incoming packets. + +commit 591c38eb38dbf0851bdebdd50b08d1bcbf6d7b0f +Author: Michael Tokarev +Date: Fri Jun 5 13:33:58 2009 +0400 + + try outgoing connections before chroot/drop_privs + + When chrooted, we either need to force-initialize resolver + and/or nsswitch somehow (no clean way) or resolve all the + names we want before entering chroot jail. The latter + looks cleaner, easier and it is actually safe because + we still don't talk with the remote nodes there, only + initiating outgoing connections. + +commit a42a8dde45fe95aa3fd3f7f15a74c5166efe3633 +Author: Michael Tokarev +Date: Fri Jun 5 11:58:17 2009 +0400 + + cleanup setpriority thing to make it readable + +commit a5fb0d8c6c384b9ea1074fb469c0a3dd5b874e98 +Author: Guus Sliepen +Date: Thu May 28 23:18:22 2009 +0200 + + Add some const where appropriate. + +commit 41c10c5a966000531099c79d6006429253ff8fd6 +Author: Guus Sliepen +Date: Thu May 28 22:51:30 2009 +0200 + + Add ProcessPriority option. + + This option can be set to low, normal or high. On UNIX flavours, this changes + the nice value of the process by +10, 0 and -10 respectively. On Windows, it + sets the priority to BELOW_NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS and + HIGH_PRIORITY_CLASS respectively. + + A high priority might help to reduce latency and packet loss on the VPN. + +commit 41a05f59ba2c3eb5caab555f096ed1b9fbe69ee3 +Author: Florian Forster +Date: Wed May 27 14:20:24 2009 +0200 + + src/net_socket.c: Bind outgoing TCP sockets to `BindToAddress'. + + If a host has multiple addresses on an interface, the source address of the TCP + connection(s) was picked by the operating system while the UDP packets used a + bound socket, i. e. the source address was the address specified by the user. + This caused problems because the receiving code requires the TCP connection and + the UDP connection to originate from the same IP address. + + This patch adds support for the `BindToInterface' and `BindToAddress' options + to the setup of outgoing TCP connections. + + Tested with Debian Etch on x86 and Debian Lenny on x86_64. + + Signed-off-by: Florian Forster + +commit 6b415a1a7f5bad2fff7b133ef2a2febccb96d6e5 +Author: Florian Forster +Date: Wed May 27 09:27:44 2009 +0200 + + src/linux/device.c: Fix segfault when running without `--net'. + + If running without `--net', the (global) variable `netname' is NULL. This + creates a segmentation fault because this NULL-pointer is passed to strdup: + + Program terminated with signal 11, Segmentation fault. + #0 0xb7d30463 in strlen () from /lib/tls/i686/cmov/libc.so.6 + (gdb) bt + #0 0xb7d30463 in strlen () from /lib/tls/i686/cmov/libc.so.6 + #1 0xb7d30175 in strdup () from /lib/tls/i686/cmov/libc.so.6 + #2 0x0805bf47 in xstrdup (s=0x0) at xmalloc.c:118 <--- + #3 0x0805be33 in setup_device () at device.c:66 + #4 0x0805072e in setup_myself () at net_setup.c:432 + #5 0x08050db2 in setup_network () at net_setup.c:536 + #6 0x0805b27f in main (argc=Cannot access memory at address 0x0) at tincd.c:580 + + This patch fixes this by checking `netname' in `setup_device'. An alternative + would be to check for NULL-pointers in `xstrdup' and return NULL in this case. + + Signed-off-by: Florian Forster + +commit a8a65cee083a27afe42cab360596e1453e7141b9 +Author: Michael Tokarev +Date: Sun May 24 17:23:24 2009 +0400 + + tunnelserver: log which ADD_SUBNET was refused + + Add some logging about refused ADD_SUBNET + (it causes subsequent client disconnect so it's + important to know which subnet was at fault). + + Maybe we should just ignore it completely. + +commit 4e9e3ca89dba68cbacaaa15ddfb298b181a969da +Author: Guus Sliepen +Date: Mon May 25 15:04:33 2009 +0200 + + Do not forward broadcast packets when TunnelServer is enabled. + + First of all, the idea behind the TunnelServer option is to hide all other + nodes from each other, so we shouldn't forward broadcast packets from them + anyway. The other reason is that since edges from other nodes are ignored, the + calculated minimum spanning tree might not be correct, which can result in + routing loops. + +commit 7fc69bc73b15349dafc193a50464caeb2f978369 +Author: Guus Sliepen +Date: Mon May 25 12:19:37 2009 +0200 + + Use packet size before decompression to calculate path MTU. + + Since compression can either grow or shrink a packet, the size of an MTU probe + after decompression might not reflect the real path MTU. Now we use the size + before decompression, which is independent of the compression algorithm, and + substract a safety margin such that the calculated path MTU will be safe even + for packets which grow as much as possible after compression. + +commit 1b3add6c29f8eb424a62837e89fe7d384fc94a48 +Author: Guus Sliepen +Date: Mon May 25 12:19:08 2009 +0200 + + Add declaration for sockaddrcmp_noport(). + +commit ca5b67111e4d797d15623c2163f67fe489dc3bf2 +Author: Michael Tokarev +Date: Sun May 24 22:32:24 2009 +0400 + + Fix ans_key exchange in recent changes + + send_ans_key() was using the wrong in vs. outkeylength to + terminate the key being sent, so it was always empty. + +commit 7034338bc36d9ea96d152091b9d58c2afc3f0c20 +Author: Guus Sliepen +Date: Sun May 24 19:35:51 2009 +0200 + + Use xrealloc instead of if(ptr) ptr = xmalloc(). + +commit e012e752f4f1a2b06dfab4640bbbea8f084999ff +Author: Guus Sliepen +Date: Sun May 24 19:31:31 2009 +0200 + + Fix initialisation of packet decryption context broken by commit 3308d13e7e3bf20cfeaf6f2ab17228a9820cea66. + + Instead of a single, global decryption context, each node has its own context. + However, in send_ans_key(), the global context was initialised. This commit + fixes that and removes the global context completely. + + Also only set status.validkey after all checks have been evaluated. + +commit 0246939ce18e1af9660b782b6814be182a7af9da +Author: Michael Tokarev +Date: Fri May 22 01:10:16 2009 +0400 + + don't log every strange packet coming to the UDP port + + it's a sure way to fill up syslog. Only log those if + debug level is up to PROTOCOL + +commit 576899ef0dec3aaede9b8ac101d189798587a646 +Author: Guus Sliepen +Date: Sun May 24 17:13:00 2009 +0200 + + Fix link to Mattias Nissler's tun/tap driver for MacOS/X. + + Thanks to Martin Christof Kindsmüller for spotting. + +commit 2c67eafc6e6c5e210636c0d2bad15827bf2d7cf0 +Author: Guus Sliepen +Date: Sun May 24 15:58:47 2009 +0200 + + If PMTUDiscovery is not set, do not forward packets via TCP unnecessarily. + +commit 7e4d57adf54ce369e4111bde0ccd3ea4b9e853ee +Author: Michael Tokarev +Date: Fri May 22 01:01:35 2009 +0400 + + ignore indirect edge registrations in tunnelserver mode + + In tunnelserver mode we're not interested to hear about + our client edges, just like in case of subnets. Just + ignore all requests which are not about our node or the + client node. + + The fix is very similar to what was done for subnets. + + Note that we don't need to add the "unknown" nodes to + the list in tunnelserver mode too, so move allocation + of new nodes down the line. + +commit 3759aa5f7745709c43f81faa36510ff650b4bf99 +Author: Michael Tokarev +Date: Wed May 20 18:40:04 2009 +0400 + + TunnelServer: Don't disconnect client on DEL_SUBNET too + + Similar changes as was in 2327d3f6eb5982bcc922ff1ab1ec436ba6aeffdc + but for del_subnet_h(). + + Before, we vere returning false (and causing disconnect of the + client) in case of tunnelserver and the client sending DEL_SUBNET + for non-his subnet or for subnet which owner isn't in our connection + list. + + After the mentioned change to add_subnet_h() that routine does not + add such indirect owners to the connection list anymore, so that + was ok (owner == NULL and we return true). + + But if we too has a connection with the node about which the client + is sending DEL_SUBNET notification, say, because that client lost + connection with that other node, we'll disconnect this client from + us too, returning false for indirect DEL_SUBNET. + + Fix that by allowing and ignoring indirect DEL_SUBNET in tunnelserver + mode. + + Also rearranged the function a bit, to match add_subnet_h() (in + particular, syntax-check everything first, see if we've seen this + request before). + + And also fix some comments. + +commit 218adee785df7c79ac18395d056a2eb6d63c407f +Author: Michael Tokarev +Date: Mon May 18 17:34:30 2009 +0400 + + format 'not supported on this platform' error message + + Format it in a similar way in all places, to make translation happier. + No functional changes. + +commit 54cb6b1aecb06a1ca44a7a60c74dd0d65b0043dd +Author: Michael Tokarev +Date: Mon May 18 17:00:00 2009 +0400 + + change error messages in droppriv code to match the rest + + Change formatting of error messages about failed syscalls + to be the same as in other places in tincd. + + Also suggest a change in "$foo not supported on this platform" + message as it's now used more than once. + +commit d4f9863635d06665cfbd3c46dc482344de240e97 +Author: Michael Tokarev +Date: Mon May 18 16:53:08 2009 +0400 + + bugfix: chdir(/) after chroot + + Fix the famous chdir(".") vs chdir("/") after chroot(something). + +commit 6be5d4f5b67764115b37528d2fe01bd245b3cd3e +Author: Michael Tokarev +Date: Mon May 18 16:49:39 2009 +0400 + + bugfix: move mlock to after detach() so it works for child, not parent + + mlock()/mlockall() are not persistent across fork(), and it's + done in parent process before daemon() which does fork(). So + basically, current --mlock does nothing useful. + + Move mlock() to after detach() so it works for child process + instead of parent. + + Also, check if the platform supports mlock right when processing + options (since else we'll have to die after startup, not at + startup, the error message will be in log only). + +commit cdf7f13c31310da0c40819fd812e19519bf4318c +Author: Michael Tokarev +Date: Mon May 18 16:28:55 2009 +0400 + + bugfix: initialize pid (as read from pidfile) to zero + + If we didn't read any number from a pid file, we'll return + an unitialized variable to the caller, and it will treat + that garbage as a pid of a process (possible to kill). + + Fix that. + +commit ec316aa32e8567395a88c4583007f01ffae008ce +Author: Michael Tokarev +Date: Mon May 18 16:25:41 2009 +0400 + + Implement privilege dropping + + Add two options, -R/--chroot and -U/--user=user, to chroot to the + config directory (where tinc.conf is located) and to perform + setuid to the user specified, after all the initialization is done. + + What's left is handling of pid file since we can't remove it anymore. + +commit 6698f7c390a5ae2f262e30560d9df59f9d5c418d +Author: Michael Tokarev +Date: Mon May 18 16:25:10 2009 +0400 + + Rename setup_network_connections() and split out try_outgoing_connections() + + In preparation of chroot/setuid operations, split out call to + try_outgoing_connections() from setup_network_connections() + (which was the last call in setup_network_connections()). + This is because dropping privileges should be done in-between + setup_network_connections() and try_outgoing_connections(). + + This patch renames setup_network_connections() to setup_network() + and moves call to try_outgoing_connections() into main routine. + + No functional changes. + +commit 3308d13e7e3bf20cfeaf6f2ab17228a9820cea66 +Author: Guus Sliepen +Date: Fri Apr 3 01:05:23 2009 +0200 + + Handle UDP packets from different and ports than advertised. + + Previously, tinc used a fixed address and port for each node for UDP packet + exchange. The port was the one advertised by that node as its listening port. + However, due to NAT the port might be different. Now, tinc sends a different + session key to each node. This way, the sending node can be determined from + incoming packets by checking the MAC against all session keys. If a match is + found, the address and port for that node are updated. + +commit 08aabbf9317806bc50a9a6693ca866c8936ce26b +Merge: 551cd19 43fa728 +Author: Guus Sliepen +Date: Mon Mar 9 19:02:24 2009 +0100 + + Merge branch 'master' into 1.1 + + Conflicts: + NEWS + README + doc/tinc.conf.5.in + doc/tinc.texi + po/nl.po + src/conf.c + src/connection.c + src/event.c + src/graph.c + src/net.c + src/net_packet.c + src/net_socket.c + src/node.c + src/node.h + src/openssl/rsagen.h + src/protocol_auth.c + src/protocol_key.c + src/protocol_misc.c + src/subnet.c + src/subnet.h + src/tincd.c + +commit 43fa7283ac01f2ecc95381b519ef6b3342546f35 +Author: Guus Sliepen +Date: Mon Mar 9 14:04:31 2009 +0100 + + Use a simple Random Early Drop algorithm in send_tcppacket(). + +commit d5b56bbba56480b5565ffb38496175a7c1df60ac +Author: Guus Sliepen +Date: Mon Mar 9 13:48:54 2009 +0100 + + Disable PMTUDiscovery in switch and hub modes. + + In switch and hub modes, tinc does not generate ICMP packets in response to + packets that are larger than the path MTU. However, if PMTUDiscovery is + enabled, the IP_MTU_DISCOVER and IPV6_MTU_DISCOVER option is set on the UDP + sockets, which causes all UDP packets to be sent with the DF bit set, causing + large packets to be dropped, even if they would otherwise be routed fine. + +commit 78fc59e994c764d072bf0045177f690a378d1308 +Author: Guus Sliepen +Date: Thu Mar 5 14:12:36 2009 +0100 + + Update THANKS and copyright information. + +commit 5674bba5c54c1aee3a4ac5b3aba6b3ebded91bbc +Author: Guus Sliepen +Date: Thu Mar 5 13:34:13 2009 +0100 + + Allow weight to be assigned to Subnets. + + Tinc allows multiple nodes to own the same Subnet, but did not have a sensible + way to decide which one to send packets to. Tinc also did not check the + reachability of nodes when deciding where to route packets to, so it would not + automatically fail over to a reachable node. + + Tinc now assigns a weight to each Subnet. The default weight is 10, with lower + weights having higher priority. The Subnets are now internally sorted in the + same way as the kernel's routing table, and the Subnets are search linearly, + skipping those of unreachable nodes. A small cache of recently used addresses + is used to speed up the lookup functions. + +commit 76a1bcaffcf1f1abf81fdda379b703a004640cb4 +Author: Michael Tokarev +Date: Sat Feb 28 16:37:51 2009 +0300 + + Enable PMTUDiscovery only if BOTH sides wants it. + + Don't enable PMTUDiscovery if at least one side does not support it. + Before it was enabled if at least one side supported it, now both are required. + +commit 1c1a67fd93530b9d16538ab2897c3911d3b16574 +Author: Guus Sliepen +Date: Tue Feb 17 14:43:05 2009 +0100 + + Handle neighbor solicitation requests without link layer addresses. + + Apparently FreeBSD likes to send out neighbor solicitation requests, even on a + tun interface where this is completely pointless. These requests do not have an + option header containing a link layer address, so the proxy-neighborsol code + was treating these requests as invalid. We now handle such requests, and send + back equally pointless replies, also without a link layer address. This seems + to satisfy FreeBSD. + +commit 2327d3f6eb5982bcc922ff1ab1ec436ba6aeffdc +Author: Michael Tokarev +Date: Mon Feb 9 23:51:10 2009 +0100 + + Allow tunnelserver to work with clients that have other peers. + + In TunnelServer mode, tinc server disconnects any client if it announces + indirect subnets -- subnets that are not theirs (e.g. subnets for nodes + the CLIENT has connections now, even if those nodes are known to the server + too). Fix that by ignoring such (indirect) announces instead. + + While we're at it, move check for such indirect subnet registration to + before allocating new node structure, as in TunnelServer mode we don't + really need to know that other node. + +commit 23730375f27c32e0fe1a59c7a761dd85296a7a4a +Author: Guus Sliepen +Date: Tue Feb 3 14:54:45 2009 +0100 + + Disable old RSA keys when generating new ones. + + When generating an RSA keypair, the new public and private keys are appended to + files. However, when OpenSSL reads keys it only reads the first in a file, not + the last. Instead of printing an easily ignored warning, tinc now disables old + keys when appending new ones. + +commit 0d0dfd0852e9b2c9a7660880966a3c84790d5ea2 +Author: Guus Sliepen +Date: Tue Jan 20 14:21:50 2009 +0100 + + Validate Name before using it in a filename when generating a keypair. + +commit 0966cca8ab6dcde2747c717f21d73fd332e04242 +Author: Guus Sliepen +Date: Tue Jan 20 14:20:44 2009 +0100 + + Allow reading config files with CRLF endings on Unix systems. + +commit d1910ac198232573c1b18d8238a27bc29bc73f8a +Author: Guus Sliepen +Date: Tue Jan 20 13:19:31 2009 +0100 + + Remove unused definitions from net.h. + +commit 503c32eb0ef9d6329e931559082f4ddf6d487dc6 +Author: Guus Sliepen +Date: Tue Jan 20 13:12:41 2009 +0100 + + Use a global list to track outgoing connections. + + Previously an outgoing_t was maintained for each outgoing connection, + but the pointer to it was either stored in a connection_t or in an event_t. + This made it very hard to keep track of and to clean up. + + Now a list is created when tinc starts and reads all the ConnectTo variables, + and which is recreated when tinc receives a HUP signal. + +commit a7e793c94ec414eb71ec2aa3debc9e2e5ed5cfef +Author: Guus Sliepen +Date: Mon Jan 19 23:17:28 2009 +0100 + + Add missing cleanup functions in close_network_connections(). + +commit 116065afe352221ac6c2c8e34c109252004d6a59 +Author: Guus Sliepen +Date: Mon Jan 19 22:50:05 2009 +0100 + + Change flush_events() to expire_events(). + + The former function made a totally bogus shallow copy of the event_tree, called + the handler of each event and then deleted the whole tree. This should've + caused tinc to crash when an ALARM signal was sent more than once, but for some + reason it didn't. It also behaved incorrectly when a handler added a new event. + + The new function just moves the expiration time of all events to the past. + +commit a39a9506cd041a7092a98498b362eaacfd2f33c3 +Author: Guus Sliepen +Date: Fri Jan 9 12:36:06 2009 +0100 + + Move free()s at the end om main() to the proper destructor functions. + +commit 67df7fb7e1c9eefe4bbc920fdc68b595ef28abd9 +Author: Guus Sliepen +Date: Sat Jan 3 22:33:55 2009 +0100 + + Only send packets via UDP if UDP communication is possible. + + When no session key is known for a node, or when it is doing PMTU discovery but + no MTU probes have returned yet, packets are sent via TCP. Some logic is added + to make sure intermediate nodes continue forwarding via TCP. The per-node + packet queue is now no longer necessary and has been removed. + +commit b069da90d67b49dce041f513a3855b8da3d82f80 +Author: Guus Sliepen +Date: Sat Jan 3 22:06:10 2009 +0100 + + Consistently allocate device and iface variables on the heap. + + This fixes a segfault when no Device has been specified and tinc exits, and it + would try to free() a static string. Thanks to Borg for spottin. + +commit f81cea3bdc8683b27188cd8f24a2de906a29eb81 +Author: Guus Sliepen +Date: Sat Dec 27 11:09:43 2008 +0100 + + Update documentation for git. + +commit c81f90b91a054eeafcc3c8c45abc52045e4a8146 +Author: Guus Sliepen +Date: Fri Dec 26 13:47:34 2008 +0000 + + Releasing 1.0.9. + +commit a4d99ebf5042dedb609359cbbfc3fa4630b5fc70 +Author: Guus Sliepen +Date: Fri Dec 26 12:46:45 2008 +0000 + + Add missing parentheses in check for IPv4 multicast addresses. + +commit 099bc56f53e7d3cb7b799d26ff9535673ff03e1c +Author: Guus Sliepen +Date: Tue Dec 23 23:14:37 2008 +0000 + + Apply patch from Max Rijevski fixing a memory leak when closing connections. + It also cleans up more when stopping tinc, helping tools like valgrind. + +commit de032054dee67bcc406b4a15fb9e957a766d016a +Author: Guus Sliepen +Date: Tue Dec 23 22:31:38 2008 +0000 + + Handle broadcast and multicast packets in router mode. + Multicast packets are treated as broadcast packets. + Based on a patch from Max Rijevski. + +commit a5f899a9794f215e8174455ead04862a2c14a5b1 +Author: Guus Sliepen +Date: Mon Dec 22 21:49:23 2008 +0000 + + Update the manpage as well, and some whitespace to make its source more legible. + +commit e8f08ced76bf1b9a94dd0dc874ad22761ad8900b +Author: Guus Sliepen +Date: Mon Dec 22 21:29:21 2008 +0000 + + Update documentation. + - TCPOnly is not experimental. + - Do not mention old Linux kernels and Ethertap anymore. + - Document the DeviceType, PMTU and PMTUDiscovery options. + +commit 0e4d419aae8a82f2ae4552f755894a9bc70c83d2 +Author: Guus Sliepen +Date: Mon Dec 22 20:35:45 2008 +0000 + + Enable PMTU discovery by default. + +commit e9576632dc4b780b867044269d06cc50f76d8c05 +Author: Guus Sliepen +Date: Mon Dec 22 20:27:52 2008 +0000 + + Update copyright information. + +commit f50dc972cde2644588eabf35a2422fe0e372a024 +Author: Guus Sliepen +Date: Mon Dec 22 19:43:49 2008 +0000 + + Update Dutch translation. + +commit 26b490e86bc305b150200c0b08cd8e9c3bd605fb +Author: Guus Sliepen +Date: Mon Dec 22 19:40:40 2008 +0000 + + Make sure IPv6 sockets are IPv6 only. + This will get rid of the "Can't bind to 0.0.0.0 port 655/tcp: Address already + in use" message on Linux. + +commit c6830ba821e6387be961ca68b32992382a74a0e9 +Author: Guus Sliepen +Date: Mon Dec 22 19:33:37 2008 +0000 + + Use TUNIFHEAD by default on FreeBSD to make sure IPv6 works. + +commit a269ec4193900feee01ac83f0e18a6e2b98e751f +Author: Guus Sliepen +Date: Sun Dec 21 16:19:31 2008 +0000 + + Treat virtual network device as tap if Mode = switch or hub. + On OpenBSD, the link0 flag should still be set in tinc-up or by other means. + +commit 551cd19406a560d0d206bff5b4e9da064ec222b6 +Author: Guus Sliepen +Date: Sun Dec 14 12:47:26 2008 +0000 + + Move RSA key generation into the wrappers. + +commit 911c05f873ad967c40d04aa7347b1067fe62c055 +Author: Guus Sliepen +Date: Thu Dec 11 20:49:14 2008 +0000 + + Make sure IPv6 sockets are IPv6 only. + +commit 6e80da3370249caa1082c23c3ef55f338d1e9e74 +Author: Guus Sliepen +Date: Thu Dec 11 18:07:26 2008 +0000 + + Use Dijkstra's algorithm. Based on patches from Max Rijevskiy. + +commit 26a228e3025c3970fd461af777013e3807b0fc58 +Author: Guus Sliepen +Date: Thu Dec 11 18:05:59 2008 +0000 + + Remove wrong checks. + +commit 636200d1a2024982fe5b3062153daa72a8253015 +Author: Guus Sliepen +Date: Thu Dec 11 15:56:18 2008 +0000 + + Remove unnecessary parentheses from sizeof, apply sizeof to variables instead of types whereever possible. + +commit a9bdfb424e7a469d15156aa44bbe2fd0b8e28531 +Author: Guus Sliepen +Date: Thu Dec 11 15:42:46 2008 +0000 + + Fix compiler warnings. + +commit 76165488f8201a59e649b4eec02ee31398b3fb92 +Author: Guus Sliepen +Date: Thu Dec 11 15:21:40 2008 +0000 + + Backport fixes from trunk since revision 1555. + +commit 046158a216e78a0412186ec8463157f6bce45d5d +Author: Guus Sliepen +Date: Thu Dec 11 14:44:44 2008 +0000 + + Use the crypto wrappers again instead of calling OpenSSL directly. + This theoretically allows other cryptographic libraries to be used, + and it improves the readability of the code. + +commit 8c69f42d7d9b4d9d5f6b6656cfc1bf1e1abee854 +Author: Guus Sliepen +Date: Thu Dec 11 14:43:13 2008 +0000 + + Move AC_GNU_SOURCE up to make autoconf happy. + Also bump libgcrypt dependency to 1.4.0, because that version supports the OFB cipher mode. + +commit 8e8fe805c81d3edc974c12c468f793ea0c1e5ee7 +Author: Guus Sliepen +Date: Thu Dec 11 14:03:52 2008 +0000 + + Only show meta connection related debug messages when debug level >= 4 + +commit 40bebbb19fd69fa094e2f6c3c1474adc0105b048 +Author: Guus Sliepen +Date: Thu Dec 11 13:59:46 2008 +0000 + + Look in the configured sbin directory for the tincd binary. + +commit 38c2d6c1dae3f09c68baa37fd24caa2e0ec6d8ad +Author: Guus Sliepen +Date: Fri Dec 5 14:17:39 2008 +0000 + + Correct debug message. + +commit a36259435c17f76cf12476234a56f40fcd8faf41 +Author: Guus Sliepen +Date: Tue Nov 18 15:11:27 2008 +0000 + + Prevent freeing a NULL pointer when a hostname is unresolvable. + +commit 4a1740ede7c1992f7f3da5e197db9975c0344ac3 +Author: Guus Sliepen +Date: Sat Oct 25 19:54:00 2008 +0000 + + Do not try to send REQ_KEY or ANS_KEY requests to unreachable nodes. + +commit cb52aa06833a69e57b5e26337e51a4d375b6d8fb +Author: Guus Sliepen +Date: Sat Oct 25 18:10:08 2008 +0000 + + Fix reading configuration files that do not end with a newline. + +commit b2cee41b187d79c095914d1097b8ff34a0609ec3 +Author: Guus Sliepen +Date: Fri Dec 14 21:17:08 2007 +0000 + + Make sure the prefixlength of subnets is sane. + Thanks to Sven-Haegar Koch for spotting the bug and providing a fix. + +commit fe2f1fceb546ca4326435cac26bcf3f513e82b43 +Author: Scott Lamb +Date: Thu Nov 8 19:18:44 2007 +0000 + + Use a control socket directory to restrict access + + This provides reasonable security even on Solaris. The sysadmin is + responsible for securing the control socket's ancestors from the + grandparent on. + + We could add a cryptographic handshake later if desired. + +commit b1f8c65a2cfa307d9b8ed8cc3c8d4819f605e4f6 +Author: Scott Lamb +Date: Wed Nov 7 06:45:28 2007 +0000 + + Coding style corrections + +commit d82fcc88f355e3c8144478a860dfae0b299004a9 +Author: Scott Lamb +Date: Wed Nov 7 02:51:24 2007 +0000 + + Reload configuration through control socket + + I also kept the SIGHUP handler, which many people will expect to see. + The control socket is better, though - it will tell you if there is a + problem. + +commit f0a57eab4cfd64d4f8261b1885a2072177f9e76b +Author: Scott Lamb +Date: Wed Nov 7 02:50:58 2007 +0000 + + Retry connections through control socket + +commit a62a6825a8a69e279ee0688a4cd9e51fbc52054b +Author: Scott Lamb +Date: Wed Nov 7 02:50:27 2007 +0000 + + Alter debugging levels through control socket + +commit 1065879c8c6e8cdf8d3755024241f31eaabd4138 +Author: Scott Lamb +Date: Wed Nov 7 02:49:57 2007 +0000 + + Purge through the control socket + +commit 6eaefb4dbce240334e35f67d9f3db5d4f44e49c9 +Author: Scott Lamb +Date: Wed Nov 7 02:49:25 2007 +0000 + + Dump through control socket + + Note this removes SIGUSR1, SIGUSR2, and the graph dumping config option. + It seems cleaner to do everything through the control socket. + +commit 50ad3f2a895c38f8d546f87490ca96ab7d9e011e +Author: Scott Lamb +Date: Wed Nov 7 02:48:33 2007 +0000 + + Fancier protocol for control socket + + * pass error status back + * pass message boundaries + +commit b0b52991849073de059a188800d1b2f03663a188 +Author: Scott Lamb +Date: Wed Nov 7 02:48:15 2007 +0000 + + Fix reload crash + + sighup_handler was expecting the connection_tree to stay the same across + terminate_connection(), which hasn't been true since r1539. + +commit da81da064a093f94e460fc1c359b5cfab26d6b5b +Author: Scott Lamb +Date: Wed Nov 7 02:48:00 2007 +0000 + + Update documentation to match tincctl changes + + (Most of this was done in r1559, but it looks like tincctl.8.in got missed.) + +commit 40731d030fef793c6b6405efd9b3e64c26c00045 +Author: Scott Lamb +Date: Wed Nov 7 02:47:05 2007 +0000 + + Temporarily revert to old crypto code + + (The new code is still segfaulting for me, and I'd like to proceed with other + work.) + + This largely rolls back to the revision 1545 state of the existing code + (new crypto layer is still there with no callers), though I reintroduced + the segfault fix of revision 1562. + +commit 269892f70bf357de6ad66ca89daa34b225ee9e37 +Author: Guus Sliepen +Date: Sat Oct 20 11:21:44 2007 +0000 + + Prevent double free() of a used challenge nonce. + +commit b0709d2649ebd7ad01d6e24851dcdfc2707d09c5 +Author: Guus Sliepen +Date: Fri Oct 19 19:07:30 2007 +0000 + + Fix meta data segfault when receiving a partial command. + +commit 67d9a72ea2f10f1a2d2eb7c04a41183359d5e1cc +Author: Guus Sliepen +Date: Fri Oct 19 18:54:43 2007 +0000 + + Use a dummy function as the read callback for connection bufferevents. Should not be triggered. + +commit 54892b2e3efcbbbd65b26a32f487829bbb8d787c +Author: Guus Sliepen +Date: Fri Oct 19 18:53:48 2007 +0000 + + Fix connection weight estimation. + +commit 6c453769fd16125ec18e8e6d102a3eaa09d370c7 +Author: Guus Sliepen +Date: Tue Sep 4 15:06:35 2007 +0000 + + Apply patch from Scott Lamb: Update documentation to match tincctl changes + +commit 86358fabfedca395b60310799a648b4875596efb +Author: Guus Sliepen +Date: Tue Sep 4 14:58:52 2007 +0000 + + Small fixes to make gcrypt routines compile. + +commit f8733d1935ed83399c4851a31f4be710eb8c825f +Author: Guus Sliepen +Date: Tue Sep 4 14:58:11 2007 +0000 + + Fix formatting of --help output. + +commit 65375289dff849f00b3429dfe4be7e66efe48444 +Author: Guus Sliepen +Date: Tue Sep 4 14:57:37 2007 +0000 + + Only check for libgcrypt if --with-gcrypt is used. + +commit d7ca0300a3f004e9dc7d97ffb6fa6bdeda890fda +Author: Guus Sliepen +Date: Fri Aug 17 22:09:00 2007 +0000 + + Handle SERVICE_CONTROL_INTERROGATE requests. Thanks to Carsten Ralle for noticing this. + +commit 1fd1d5bd9330e02ab5dc32ad027f654ff2620099 +Author: Scott Lamb +Date: Fri Jul 20 20:10:46 2007 +0000 + + const correctness + + cipher_encrypt and cipher_decrypt should take "const void *" data + +commit 35d865a6348cd62d2992bb3d353e37471d902889 +Author: Scott Lamb +Date: Wed Jul 18 16:44:05 2007 +0000 + + Updated svn:ignores list for new symlinked sources and tincctl. + +commit dd299c06dccceeb9b4db09eee17268cf5631fa41 +Author: Scott Lamb +Date: Wed Jul 18 16:40:41 2007 +0000 + + Refresh po/POTFILES.in. + + In particular, remove lib/pidfile.c which was causing failures. Also sort + for diffability with "find . -type f -name '*.c' | cut -c3- | sort" output. + +commit 46018a1a16579ce00b02eb6a991a70615ab9bc3e +Author: Scott Lamb +Date: Wed Jul 18 16:40:29 2007 +0000 + + Revert to only requiring autoconf 2.59. + + The new autoconf macros introduced at the same time (AC_GNU_SOURCE, + AC_FUNC_MALLOC, AC_FUNC_REALLOC) exist in the autoconf 2.59 documentation, + and autoconf 2.59 appears to still work. This is more convenient, as RHEL 5 + ships with autoconf 2.59. + +commit 1b8f8918360b40a2749d40355266ed7dedbe41b5 +Author: Guus Sliepen +Date: Wed May 23 13:45:49 2007 +0000 + + Finish crypto wrapping. Also provide wrappers for OpenSSL. + Disable libgcrypt by default. Since it doesn't support the OFB cipher mode, + we can't use it in a backwards compatible way. + +commit f42e57f663a2663c830c4fb4c01927c2d3c89c09 +Author: Guus Sliepen +Date: Tue May 22 23:41:22 2007 +0000 + + Some more crypto wrapper functions are needed. + +commit 19413a8048fd851866c551ab8035f008f0c7e806 +Author: Guus Sliepen +Date: Tue May 22 21:44:17 2007 +0000 + + Make sure the crypto wrapper functions can actually be compiled. + +commit e8689a4753ca2b1665e131cc40217da6c033ebd3 +Author: Guus Sliepen +Date: Tue May 22 21:32:48 2007 +0000 + + Create wrappers for the cryptographic operations used in tinc. + Implement them using libgcrypt. + +commit 465837dd7f7b727d489b354e4b75489dd49fd6e3 +Author: Guus Sliepen +Date: Sun May 20 22:28:49 2007 +0000 + + Parse PEM RSA keys ourself, and use libgcrypt to do RSA encryption and decryption. + +commit fbf305c09d91bf34b1504b58d50392df2e6bcfba +Author: Guus Sliepen +Date: Sat May 19 22:23:02 2007 +0000 + + Use libevent for meta socket input/output buffering. + +commit 59108e4e4f7aa4632c510d16961edd8c551a6542 +Author: Guus Sliepen +Date: Sat May 19 16:21:52 2007 +0000 + + Use bufferevents to handle control socket buffering. + +commit 8c6131deda546452386f3703af968ee664cadfbd +Author: Guus Sliepen +Date: Sat May 19 15:21:26 2007 +0000 + + Implement "stop" command, and allow tincctl to retrieve a running tincd's PID. + +commit e9043e17c76f92b787c9ecdaf1a2ae7916f690a6 +Author: Guus Sliepen +Date: Sat May 19 14:55:35 2007 +0000 + + Move key generation to tincctl. + +commit bf8e3ce13dba6109757c14dc0013a315a75d2ba3 +Author: Guus Sliepen +Date: Sat May 19 14:13:21 2007 +0000 + + Remove pidfile in favour of control socket. + +commit bc0a24ec810cb911610ae7aafa245e47d1268cd2 +Author: Guus Sliepen +Date: Sat May 19 13:34:32 2007 +0000 + + Fix retrying outgoing connections. + +commit ce976717ea9756aa985699547fdbf132b694748d +Author: Guus Sliepen +Date: Sat May 19 12:07:30 2007 +0000 + + We can safely delete a connection_t in terminate_connection() now. + +commit 01f47c46af514a9d7f39c143e4558a8426a0d3eb +Author: Guus Sliepen +Date: Fri May 18 16:52:34 2007 +0000 + + Start of control socket implementation. + +commit 6ded8a3f089a22c98d2a06b960d65b44e60188d6 +Author: Guus Sliepen +Date: Fri May 18 11:54:16 2007 +0000 + + Update documentation. + +commit 86586594334e951a99845d92baed1966e394aafa +Author: Guus Sliepen +Date: Fri May 18 11:35:21 2007 +0000 + + Show branch version number. + +commit e37ef57a956507cc29e80930201731562b4266e5 +Author: Guus Sliepen +Date: Fri May 18 11:19:31 2007 +0000 + + More consistent variable naming. + +commit 29fbce4497357580fc0aa00f087e8f1a538a2a50 +Author: Guus Sliepen +Date: Fri May 18 10:29:10 2007 +0000 + + Detect duplicate outgoing connections. + +commit fb0cfccf7dc2240b576011edcf74fd5b058916cb +Author: Guus Sliepen +Date: Fri May 18 10:05:26 2007 +0000 + + Use splay trees instead of AVL trees. + +commit f02d3ed3e135b5326003e7f69f8331ff6a3cc219 +Author: Guus Sliepen +Date: Fri May 18 10:00:00 2007 +0000 + + K&R style braces + +commit 760dd966efe7dbff316a8c638e40dee162848256 +Author: Guus Sliepen +Date: Fri May 18 09:51:54 2007 +0000 + + Remove last references to the global variable "running". + +commit 3909b8e51b27b11c6d54541220cb7767bf25569c +Author: Guus Sliepen +Date: Fri May 18 09:43:52 2007 +0000 + + Remove the last bits of the legacy main_loop(). + +commit ddc6a81a854023e38b563f213aa9a449ee91add8 +Author: Guus Sliepen +Date: Fri May 18 09:34:06 2007 +0000 + + Remove global variable "now". + +commit 7e1117197ca4fc62af93fda50e28e0ff06cb736c +Author: Guus Sliepen +Date: Thu May 17 23:57:48 2007 +0000 + + Move key regeneration handling to net_setup.c. + +commit 563577a1479549fa0c20dcda45831a0fff8c7513 +Author: Guus Sliepen +Date: Thu May 17 23:33:07 2007 +0000 + + Use libevent to handle key expiration. + +commit 8852d4407d87cf5dcf2c212d352279015aa050c0 +Author: Guus Sliepen +Date: Thu May 17 23:24:40 2007 +0000 + + Use libevent to age learned MAC addresses. + +commit a530f94e7c4acd94d1cd568b384931eec6f60563 +Author: Guus Sliepen +Date: Thu May 17 23:14:42 2007 +0000 + + Use libevent to age past requests. + +commit aaf1851315023c2f960c58a0d977085a485298e7 +Author: Guus Sliepen +Date: Thu May 17 23:04:02 2007 +0000 + + Redo SIGALRM handling. + +commit 6d19ebd612e6387ba34419cce5cd4d5d861b9a9e +Author: Guus Sliepen +Date: Thu May 17 22:41:34 2007 +0000 + + Use libevent to handle all non-fatal signals. + +commit 531d5a904a3a91bca8b7d373fb6ab2869b31e7fa +Author: Guus Sliepen +Date: Thu May 17 22:17:24 2007 +0000 + + Properly use the timeout_initialized() macro. + +commit bf6490825eabdf4eda6e64f2e5fcd690db7b72ce +Author: Guus Sliepen +Date: Thu May 17 22:13:12 2007 +0000 + + Remove legacy event system. + +commit a67ab277c9fdbcfc8c0550e9046df2a00b5fed81 +Author: Guus Sliepen +Date: Thu May 17 22:09:55 2007 +0000 + + Use libevent for retrying outgoing connections. + +commit 3321591d93d00326eee01fa7c78fb0d56b3d0fba +Author: Guus Sliepen +Date: Thu May 17 22:01:07 2007 +0000 + + Use libevent to send MTU probes. + +commit ee7844905f63872e12cd12f5a3d1a62220594831 +Author: Guus Sliepen +Date: Thu May 17 21:47:27 2007 +0000 + + Configure events after obtaining a socket. + +commit 294ce72441e44c0561556c2984f0e26a74230347 +Author: Guus Sliepen +Date: Thu May 17 21:34:58 2007 +0000 + + Use libevent to handle HUP signal. + +commit 4d0621b1f39537699b0ec4655b0c6e6b84581c9a +Author: Guus Sliepen +Date: Thu May 17 21:14:30 2007 +0000 + + Use libevent to dump graphs when necessary. + event_add() can be called repeatedly, the second and later calls are ignored if + the event hasn't been removed yet. + +commit 0f6f54ff8aa96d981f68b5b71c7126b8fdbead6c +Author: Guus Sliepen +Date: Thu May 17 20:20:10 2007 +0000 + + Use a separate event structure to handle meta data writes. + Make meta socket events persistent. + +commit 17c8033029d50ce4a30b6e3585c0ee28ef45bc97 +Author: Guus Sliepen +Date: Thu May 17 19:52:12 2007 +0000 + + 128 listener sockets is way too much. + +commit d8dea8091fa2260071f775db58ba277d4ce44ea7 +Author: Guus Sliepen +Date: Thu May 17 19:51:26 2007 +0000 + + Properly delete listener socket events on shutdown. + +commit 6ea1dfc995f386b3a9406c7935642524dc755c51 +Author: Guus Sliepen +Date: Thu May 17 19:15:48 2007 +0000 + + Port fixes from release 1.0.8. + +commit cf2be574948fdd02db0503d9639d3b6e268dd4ff +Author: Guus Sliepen +Date: Wed May 16 17:16:09 2007 +0000 + + Releasing 1.0.8. + +commit 6af8900f8e1c7f2fe6a50a991ae6cbd0fd7edd43 +Author: Guus Sliepen +Date: Wed May 16 14:46:25 2007 +0000 + + Don't free struct addrinfo too early. Spotted by Christian Cier-Zniewski. + +commit 31a190dc7db21aa9bb97792563dd83e7c41b831c +Author: Guus Sliepen +Date: Wed May 16 14:42:41 2007 +0000 + + Update dutch translation. + +commit 480dd127c8a539036ff82a3810a0ad83136944f8 +Author: Guus Sliepen +Date: Wed May 16 14:42:08 2007 +0000 + + Make sure connection->name is never NULL. + +commit f0cf4991e2bd0e618c7020511fb12cb0b5c59a40 +Author: Guus Sliepen +Date: Mon May 14 09:21:09 2007 +0000 + + Apply patch from "dnk" making sockets non-blocking under Windows. + +commit 3730156165fd1aa7c8810cd8e390aba6a8badcfa +Author: Guus Sliepen +Date: Mon Mar 12 17:55:43 2007 +0000 + + Only free members of connection_t that have been allocated. + +commit 39f6d59b4b81dc2d754329e6c9f885e8211c5e70 +Author: Scott Lamb +Date: Tue Feb 27 08:13:41 2007 +0000 + + Lots of svn:ignore entries + +commit 38c25d62c2bc76908bd95fb21c8f5e39ad269884 +Author: Scott Lamb +Date: Tue Feb 27 01:57:01 2007 +0000 + + Convert to libevent. + + This is a quick initial conversion that doesn't yet show much advantage: + - We roll our own timeouts. + - We roll our own signal handling. + - We build up the meta connection fd events on each loop rather than + on state changes. + +commit 834290b00f859412ee48bef454a07083cb727130 +Author: Scott Lamb +Date: Tue Feb 27 01:30:57 2007 +0000 + + A couple missed tevent things. + (Sorry; had a couple changes queued.) + +commit 6362b12df725044f3404faceff113e469d8ac860 +Author: Scott Lamb +Date: Tue Feb 27 01:26:11 2007 +0000 + + Rename "event_t" to "tevent_t", along with associated functions. + This relieves some confusion and problems during the libevent transition. + In particular, "event_add" was defined by both. + (The 't' stands for 'timeout', 'tinc', 'temporary', or some such.) + +commit 54431094d95f3989084755fdb91883b24cf5a9f4 +Author: Guus Sliepen +Date: Sat Feb 24 22:50:42 2007 +0000 + + Created the 1.1 branch where large code changes can take place, + at the same time keeping compatibility with 1.0. + +commit ab6f76f6a9fc8028fff96322a52b770710ffa1a9 +Author: Guus Sliepen +Date: Wed Feb 14 09:32:16 2007 +0000 + + Close the proper filedescriptor (if it exists). + +commit 45fca3c723302868de3225e7509d2292008948f7 +Author: Guus Sliepen +Date: Wed Feb 14 09:21:34 2007 +0000 + + Apply patch from Scott Lamb fixing some memory and resource leaks. + +commit 6c6535a4161d04accb3a22c51477e9f92ae34086 +Author: Guus Sliepen +Date: Wed Feb 14 09:20:20 2007 +0000 + + Apply patch from Scott Lamb preventing an infinite loop when sending SIGALRM. + +commit 16c8b0e5bb7c05a0559b2d799a32204bfa0a0e3f +Author: Guus Sliepen +Date: Fri Jan 5 15:03:07 2007 +0000 + + Releasing 1.0.7. + +commit a1e72f84d08b76784c11ff723666ceeaef2756eb +Author: Guus Sliepen +Date: Fri Jan 5 13:18:36 2007 +0000 + + Update copyright notices. + +commit a22ef25f9b81993226a74b193377c7d6baf910ca +Author: Guus Sliepen +Date: Fri Jan 5 13:17:33 2007 +0000 + + No things to do for the 1.0 branch except bugfixing. + +commit d80cc7a5cc918a1dbf8dd789d2125f55c4949d27 +Author: Guus Sliepen +Date: Fri Jan 5 05:44:01 2007 +0000 + + rename() cannot replace existing files on Windows. + +commit 5214ece03009a916159c710cf436af1e92909f41 +Author: Guus Sliepen +Date: Fri Jan 5 04:49:02 2007 +0000 + + Fix generic BSD tun device to write only the actual packet length. + Due to a copy&paste bug, it tried to write a packet with the maximum size. + This was not a problem until the maximum size was increased to support VLANs. + +commit 40f02ff8eee359dc0ccc898f8da319f56af161ad +Author: Guus Sliepen +Date: Thu Jan 4 15:28:36 2007 +0000 + + Tapreader socket should be bound to localhost only. + +commit 03f3fc01e8d9402c4a14904fded883ff8cc574f6 +Author: Guus Sliepen +Date: Wed Jan 3 18:18:54 2007 +0000 + + Use a ringbuffer in shared memory to transfer packets from the tapreader thread to the main thread. + It's a wonder it ever worked before. The socket that is created is not of a + datagram type, therefore packet boundaries were not preserved, which becomes + a problem as soon as the TAP-Win32 device receives packets in fast succession. + +commit 52787a73b0211bcb4cb3cdd308b1a4c53a60f8ce +Author: Guus Sliepen +Date: Mon Dec 18 17:38:05 2006 +0000 + + Releasing 1.0.6. + +commit b32c22cf54e47677726d15a5fca7eecc2fa42754 +Author: Guus Sliepen +Date: Mon Dec 18 11:41:53 2006 +0000 + + Prevent compiler warnings about redefinition of EAI_FAMILY on FreeBSD 6.1. + +commit 855806b2f75fc1c566cfaac01c788cdc625b4687 +Author: Guus Sliepen +Date: Sat Dec 16 16:53:58 2006 +0000 + + Do a simple test for linux/if_tun.h instead of no test at all. + +commit 0322c0883b76257c0893aa75a510e264056ac15b +Author: Guus Sliepen +Date: Sat Dec 16 16:40:09 2006 +0000 + + Remove the test for linux/if_tun.h. + It has been available for years on any decent Linux distribution. + Although linux/if_tun.h is now required to compile tinc, + you can still run it on systems which only support Ethertap. + +commit b55813dc0b4a6a1f70c0f8d5f0512c8cebb4a5ba +Author: Guus Sliepen +Date: Sat Dec 16 16:34:04 2006 +0000 + + We do properly check for malloc and realloc. + +commit 5219ee25a248fe26055e54215c5027cbf8483439 +Author: Guus Sliepen +Date: Sat Dec 16 16:26:57 2006 +0000 + + Use standard autoconf macros instead of our own. + +commit 9d469a19691f9749b5d729a1ae903d7aa224a6e8 +Author: Guus Sliepen +Date: Sat Dec 16 16:26:08 2006 +0000 + + Fix rule that creates html version of manpages. + +commit dd03a003962788eb21910c3faabbda0e84eff5eb +Author: Guus Sliepen +Date: Fri Dec 15 20:44:33 2006 +0000 + + Remove old Spanish translation. + +commit 031e09f865e2c634f30fb0ed4e0b6a1f6df57588 +Author: Guus Sliepen +Date: Fri Dec 15 20:43:39 2006 +0000 + + Remove unnecessary stuff from configure.in. + +commit b834d67d7cc7d7f5d8b729b340ec0c809c7d54b6 +Author: Guus Sliepen +Date: Tue Dec 12 14:54:39 2006 +0000 + + Use the correct next pointer. + +commit 8b55dfacb199d152391aa5f7adbbbe35bceea7d7 +Author: Guus Sliepen +Date: Tue Dec 12 14:49:09 2006 +0000 + + When building the minimum spanning tree, make sure we start from a reachable node. + +commit 47d916ec5eb61fa396c0ec6962afed7885141478 +Author: Guus Sliepen +Date: Wed Nov 29 17:18:39 2006 +0000 + + Search for lzo/lzo1x.h, lzo2/lzo1x.h and lzo1x.h. + +commit 1bb5a284fec8c538f8ba243d4f9b2e46f68cd7e8 +Author: Guus Sliepen +Date: Wed Nov 29 16:57:46 2006 +0000 + + Make sure resolved addressed for outgoing connections are freed, if there are any. + +commit 5c69c390a17fc2b37218881e7285b639b79cfc5a +Author: Guus Sliepen +Date: Tue Nov 14 15:43:28 2006 +0000 + + Releasing 1.0.5. + +commit e5b1b5cefb82531e8a700c2ee251da1bb0a06fbf +Author: Guus Sliepen +Date: Tue Nov 14 12:28:04 2006 +0000 + + EWOULDBLOCK does not exist on platforms without O_NONBLOCK + +commit 3353ab37c2d6fb3652fbf7a85d85997be1c0c1b5 +Author: Guus Sliepen +Date: Sat Nov 11 22:45:45 2006 +0000 + + When deleting an entire tree, start at head, not at root. + +commit 0714ac6c59099a398e67770ad9c72fcec615812b +Author: Guus Sliepen +Date: Sat Nov 11 22:44:15 2006 +0000 + + Nodes use events, so event system should be initialised first and destroyed last. + +commit 35e4096120236db8d64a767f1ccdd6bf03a091fc +Author: Guus Sliepen +Date: Sat Nov 11 21:37:22 2006 +0000 + + Update Dutch translation. + +commit 315ef3e42bf16e03cfbea763442a52389a16b832 +Author: Guus Sliepen +Date: Sat Nov 11 20:37:58 2006 +0000 + + Document GraphDumpFile option. + +commit 8d393b30a922110ec77d5b243347416b50cd2160 +Author: Guus Sliepen +Date: Sat Nov 11 20:10:46 2006 +0000 + + Support and autodetect LZO version 2.0 and later. + +commit bdb3c24cea06e9557738b42e3c37cd036613b58d +Author: Guus Sliepen +Date: Sat Nov 11 20:06:14 2006 +0000 + + Support and autodetect LZO version 2.0 and later. + +commit 0d1ac68c59db87141616f69bcd3d79c705b1ecd0 +Author: Guus Sliepen +Date: Sat Nov 11 14:37:03 2006 +0000 + + popen() requires pclose(). + +commit 0200d3cd5d773d9b101c33264532d2a301c2af32 +Author: Guus Sliepen +Date: Sat Nov 11 14:11:16 2006 +0000 + + Added graph dumping ability based on Markus Goetz's patch. + +commit 1728d5b2c43b33700a9997f97fe8503ad1cf3585 +Author: Guus Sliepen +Date: Sat Nov 11 13:43:00 2006 +0000 + + The "active" bit in node.status is not used. + +commit 134dc8995b296b0bd8b346617c705204b0f3125c +Author: Guus Sliepen +Date: Wed Aug 9 22:31:10 2006 +0000 + + memcpy() addresses from packet headers before calling the lookup functions. + This probably fixes a problem on the ARM architecture that causes tinc to fail to lookup IPv4 addresses. + +commit 64e0519cb5042b251e7345f07429e8b82e2ac09b +Author: Guus Sliepen +Date: Tue Aug 8 13:50:58 2006 +0000 + + Remove unused variable. + +commit ddcf079cad3351f0823fc07af15787d02e5f1901 +Author: Guus Sliepen +Date: Tue Aug 8 13:44:37 2006 +0000 + + Remove unused parameter from maskcmp(). + +commit c620df3c1511643aa533ca31afc17db75b7255b8 +Author: Guus Sliepen +Date: Tue Aug 8 13:44:19 2006 +0000 + + Remove unused variables. + +commit 9fa27097dd82e20299f5277ecb4efffb4a99669c +Author: Guus Sliepen +Date: Tue Aug 8 13:29:17 2006 +0000 + + Fix format string warnings. + +commit eb391c52eed46f3f03b404553df417851fc0cb90 +Author: Guus Sliepen +Date: Tue Aug 8 13:21:08 2006 +0000 + + Do not break strict aliasing of status_t structs. + +commit 2077451e07f93edc520cf5bc31815624a2b03fdd +Author: Guus Sliepen +Date: Mon Jun 12 21:45:39 2006 +0000 + + Add generic host-up and host-down scripts. + Thanks to Menno Smits for a patch. + +commit f88c9942e1e3d4d463ec71ba5a60d045381bda8f +Author: Guus Sliepen +Date: Sun Jun 11 18:53:27 2006 +0000 + + Use memcpy() to copy sockaddrs returned by getaddrinfo(). + Thanks to Miles Nordin for spotting this. + +commit 412f3fb5101514d9a7d4d9e5729ee9c665a07cb6 +Author: Guus Sliepen +Date: Wed Apr 26 16:29:47 2006 +0000 + + Restore length of the original packet in send_udppacket(). + +commit de78d79db84c486afcc353884ec1770866beb653 +Author: Guus Sliepen +Date: Wed Apr 26 13:52:58 2006 +0000 + + Update copyright notices, remove Ivo's email address. + +commit 8ebb017a10cd85406ddf5ab60d8ef1f56df526ff +Author: Guus Sliepen +Date: Wed Apr 12 08:38:35 2006 +0000 + + Fix a bug in handling prefixlengths that are not a multiple of 4. + Thanks to Sven-Haegar Koch for spotting the bug and providing the fix. + +commit af95368c0f30955f0e13b587d5d6d4989fd5a83e +Author: Guus Sliepen +Date: Sun Mar 19 13:06:21 2006 +0000 + + Fix signedness compiler warnings. + +commit fb1cda2ca4ca74a85e88c39c11b97340e6495a08 +Author: Guus Sliepen +Date: Sun Mar 19 12:43:45 2006 +0000 + + Export flush_meta(). + +commit 098090468a9e1e8c5cdb0aeefa277329ff5f3406 +Author: Guus Sliepen +Date: Sun Mar 19 12:43:28 2006 +0000 + + Missing #include. + +commit a90f1b652c0fb52950f3b0783a7e2b7f2e0cf2db +Author: Guus Sliepen +Date: Mon Feb 6 12:30:51 2006 +0000 + + Make sure $NAME is set correctly when executing tinc-down script. + +commit 228e7a5c8f0e517dcede50f886965a44fca39853 +Author: Guus Sliepen +Date: Thu Jan 19 17:13:18 2006 +0000 + + Apply patch from Scott Lamb adding an output buffer for the TCP sockets. + This helps coalescing multiple send_meta() commands into one TCP packet. + Also limit the size of the output buffer before dropping PACKETs. + +commit a5a4d2b865879b8694760c0a5b5909c9a3675027 +Author: Guus Sliepen +Date: Fri Jan 13 11:21:59 2006 +0000 + + Apply patch from Scott Lamb unifying configuration of TCP socket options. + +commit e02f13cdb3133c33ac84d9582e2f47ca5ebd35bf +Author: Guus Sliepen +Date: Fri Jan 13 11:09:19 2006 +0000 + + EVP_Cleanup() when quitting. + +commit 0912260755021b9b836830dd99ae128c5fd912d9 +Author: Guus Sliepen +Date: Wed Nov 16 10:45:11 2005 +0000 + + Enable OpenSSL ENGINE, so crypto hardware gets used. Thanks to Andreas van Cranenburgh. + +commit 64e4c12778697f71ad3fcf33ee6cf1066322caa5 +Author: Guus Sliepen +Date: Fri Jun 3 10:56:02 2005 +0000 + + Add alloca.h to the list of necessary header files. + +commit e810545dc2ae158745624c1575b76c55f883c892 +Author: Guus Sliepen +Date: Fri Jun 3 10:16:03 2005 +0000 + + Prevent possible buffer overflows when using very large (>= 8192 bit) RSA keys. + Thanks to Tonnerre Lombard for noticing! + +commit 02746165a21a4a495d0069526c9a2355110a5784 +Author: Guus Sliepen +Date: Wed May 4 19:38:28 2005 +0000 + + Releasing 1.0.4. + +commit df3220a1549f992cbf4a9b6e67c1e67b69896c7d +Author: Guus Sliepen +Date: Wed May 4 18:09:30 2005 +0000 + + Update copyright notices. + +commit 54a30e30ad41d7c0e73fcc4e6ff23c3e85af75c4 +Author: Guus Sliepen +Date: Wed May 4 16:53:11 2005 +0000 + + Describe subnet-up/down scripts in documentation. + +commit bded1b74cc23c60e7319ed9e7465413b94a7914e +Author: Guus Sliepen +Date: Wed May 4 15:56:25 2005 +0000 + + Several splay tree fixes. + +commit faaaa1ef38dcdf19d5d5d73ab66806b15467c043 +Author: Guus Sliepen +Date: Wed May 4 15:52:55 2005 +0000 + + Searching through splay trees may change the tree variable. + +commit dc09f6fe896f5e35fffe8cc2004781b2e1b6fd5a +Author: Guus Sliepen +Date: Wed May 4 15:51:45 2005 +0000 + + Be on the safe side with initialisation of c->name. + +commit 92c4a28d7d43b68a324cf2eca741298ed6b692d6 +Author: Guus Sliepen +Date: Wed Apr 6 20:43:37 2005 +0000 + + Remove unused (and potentially segfaulting) net2str() call. + +commit 6363ed4d9c675b8b9301b694c4e4dd9c892e04e2 +Author: Guus Sliepen +Date: Thu Jan 20 15:14:25 2005 +0000 + + Don't try to add a non-existing node back to the node_udp_tree. + +commit 39fe3b445c2f20b325ee492dd1845877777b25c8 +Author: Guus Sliepen +Date: Tue Jan 4 22:19:56 2005 +0000 + + Nodes should only be in the node_udp_tree if they are reachable. + +commit fe0bfa3e65049d6e7cd46cf6caea7eb91b478008 +Author: Guus Sliepen +Date: Tue Jan 4 22:18:58 2005 +0000 + + Correct size argument for strncat(). + +commit 56c36a14d87b58c14dbc48df4d3d977207e2c06e +Author: Guus Sliepen +Date: Fri Dec 3 13:27:33 2004 +0000 + + Use the proper free function. + +commit 18c617ecf29b9dfb95227e764c76fff0f9d7af96 +Author: Guus Sliepen +Date: Fri Dec 3 13:22:18 2004 +0000 + + Free memory used by connection_t after it is deleted from the connection tree. + +commit 672ad5634cbedfbd6345e887935eed3e806f1e2d +Author: Guus Sliepen +Date: Wed Dec 1 21:26:51 2004 +0000 + + Small fix. + +commit 40b1692940a8d588c08fb6b8f24ded7c33b041b1 +Author: Guus Sliepen +Date: Wed Dec 1 20:06:39 2004 +0000 + + subnet-up/down hooks, use list_t for the todo list. + +commit c46f56a8b8bb865dd8951441b5acf4701b5b5b09 +Author: Guus Sliepen +Date: Wed Dec 1 20:06:05 2004 +0000 + + subnet-up/down hooks + +commit f08baa3072e7cd6cee7a2a7cde35b46c85363baf +Author: Guus Sliepen +Date: Thu Nov 18 20:34:48 2004 +0000 + + Fix splay tree code. + +commit 0077cfaae112b63d6af6aa1e5d079cebdde84b74 +Author: Guus Sliepen +Date: Tue Nov 16 19:02:54 2004 +0000 + + Make sure broadcast packet reach the local network interface. + +commit 79c48cfafd75dfc86a382f6454a9f009d3c099b6 +Author: Guus Sliepen +Date: Thu Nov 11 19:42:25 2004 +0000 + + Releasing 1.0.3. + +commit 2771691bfc85b2544b30ccaee8a709bd26c7e1ab +Author: Guus Sliepen +Date: Thu Nov 11 19:39:28 2004 +0000 + + Add more people who have contributed to tinc. + Remove details and sort on name; + the details were not always equally accurate and are hard to maintain. + +commit 4f3f6f07b234b4abd32bf3bae1be0551bc7dd9dc +Author: Guus Sliepen +Date: Thu Nov 11 11:17:04 2004 +0000 + + Short readme about how to compile tinc from a Subversion checkout. + +commit 704c3707c2c400b7e35ef4ac2c1d21e0f2de0187 +Author: Guus Sliepen +Date: Wed Nov 10 23:28:32 2004 +0000 + + Updated dutch translation. + +commit a20eb05714f828be7dc0f78c1a07f218a3482dff +Author: Guus Sliepen +Date: Wed Nov 10 23:21:41 2004 +0000 + + Remove duplication. + +commit d8fe2ecdd8dc5caf6f8d6acf2923a0baed64735f +Author: Guus Sliepen +Date: Wed Nov 10 23:20:59 2004 +0000 + + Set BSD tuns to broadcast mode. On OpenBSD, this enables IPv6 on the tun device! + +commit 2369b0ab09a008c519cd4307b634fd294c66014e +Author: Guus Sliepen +Date: Wed Nov 10 21:57:04 2004 +0000 + + Update documentation. + +commit 4fe7aff4d1b8605d4997b842481cc78bd062fe2a +Author: Guus Sliepen +Date: Wed Nov 10 21:56:31 2004 +0000 + + Add BlockingTCP option, useful when using TCPOnly on slow or congested links. + +commit 5bba3124c8c23568def7a4804651a53f3a6b4fd2 +Author: Guus Sliepen +Date: Wed Nov 10 21:14:08 2004 +0000 + + Support tunneling IPv6 on Solaris. + +commit d02d81ff9dbb12253957065752c56785aedccee3 +Author: Guus Sliepen +Date: Wed Nov 10 19:36:02 2004 +0000 + + Let compiler decide when to inline. + +commit db68db4b0e0f8b776f2d3dc938fb81dac975fdd8 +Author: Guus Sliepen +Date: Wed Nov 10 19:34:38 2004 +0000 + + Fix order of arguments for tar. + +commit 923abcfa35c7282251d507af83d6163df76c943b +Author: Guus Sliepen +Date: Wed Nov 10 18:11:44 2004 +0000 + + Use the generic BSD tun/tap code. + +commit e8b11b1cca11f7f50542a7b34f4251f43447db0d +Author: Guus Sliepen +Date: Wed Nov 10 18:10:59 2004 +0000 + + Missing check for NULL-pointer. + +commit ca7948fc06fd0495dc8104d7f55948f702ac09e2 +Author: Guus Sliepen +Date: Tue Nov 9 09:51:35 2004 +0000 + + Hopefully this really fixes late packet handling. + +commit f7b9761000000063bd00460af4b57117db7361e4 +Author: Guus Sliepen +Date: Mon Nov 8 22:30:13 2004 +0000 + + Fixed another bug in late packet handling. + +commit 14eab178295768311d4518289533005991add8ba +Author: Guus Sliepen +Date: Mon Nov 8 22:11:33 2004 +0000 + + Update to make it compile again. + +commit 804b2892a5e26a2dc46d19397cc8b321b43b8add +Author: Guus Sliepen +Date: Mon Nov 8 22:03:28 2004 +0000 + + Hoopjumping to get the default directories in the manuals properly. + +commit 719cb95ea4fa7a2e6f4291aed607323f290c7a91 +Author: Guus Sliepen +Date: Tue Nov 2 20:50:53 2004 +0000 + + Splay trees. + +commit 2af1538976c9c85c40becfdd8601b421ad2ab057 +Author: Guus Sliepen +Date: Mon Nov 1 17:05:09 2004 +0000 + + Don't include .svn directory in sample configuration. + +commit dced64c5c3625f6d2f0674e9fed14455aabc635e +Author: Guus Sliepen +Date: Mon Nov 1 17:04:28 2004 +0000 + + Check for sys/uio.h, net/if_tun.h and net/if_tap.h + +commit 1f00810da336f3b7132df17b7fe4625748ff4b63 +Author: Guus Sliepen +Date: Mon Nov 1 17:02:19 2004 +0000 + + static + +commit 82b29e9a3b1dc6b2104ab92ed78bf431a4e55649 +Author: Guus Sliepen +Date: Mon Nov 1 17:01:56 2004 +0000 + + Generic device driver for *BSD and MacOS/X + +commit 922e5b7beaad5bb3fcbfa6b8dd13c05bda29e5fa +Author: Guus Sliepen +Date: Mon Nov 1 15:18:53 2004 +0000 + + Support alternative tun/tap driver from http://www-user.rhrk.uni-kl.de/~nissler/tuntap/ + +commit faff6498821555e6afb3dc5e4e3b61d448a4fef1 +Author: Guus Sliepen +Date: Mon Nov 1 15:18:22 2004 +0000 + + Don't let tinc service depend on NDIS component. + +commit 396ac4be802f8b75c5a2ab5925925427c61c1da3 +Author: Guus Sliepen +Date: Mon Nov 1 15:16:12 2004 +0000 + + Correct return value. + +commit 58153cca98fd43c37ae52d3cf69474c3d736c431 +Author: Guus Sliepen +Date: Fri Oct 1 18:26:15 2004 +0000 + + Allow tinc to work with the latest TAP-Win32 driver. + +commit 6411e0d8bda8abc2cef87ca852255502f9bb03d0 +Author: Guus Sliepen +Date: Fri Oct 1 18:24:41 2004 +0000 + + strndupa() is too arcane for some environments. + +commit b0a80007e8945a11d7ce25aab096c5ee58ce0ad5 +Author: Guus Sliepen +Date: Fri Oct 1 18:23:08 2004 +0000 + + Fix several #includes. + +commit 2c40495747945bc497dac65b734a4995ab3400a3 +Author: Guus Sliepen +Date: Fri Oct 1 18:22:06 2004 +0000 + + Move all #ifdef HAVE_HEADER_H #include to have.h, + this allows for simplification of configure.in. + +commit 7717cb0c54cc1b736b9f210b180c3cb3f4663ded +Author: Guus Sliepen +Date: Mon Sep 20 20:56:14 2004 +0000 + + Remove duplicate #include "system.h" + +commit 5373129344d349ff6aeb2b3d21f947f5ecbbcfaf +Author: Guus Sliepen +Date: Mon Sep 20 20:55:49 2004 +0000 + + Marking potential late packets was in the wrong place. + +commit c44f69a30243a94ab93bd15915dbfa71db698bde +Author: Guus Sliepen +Date: Sat Jul 17 12:04:30 2004 +0000 + + Don't set $INTERFACE automatically, don't quit on EINTR/EAGAIN. + +commit dcec713675b604f5ef82e64d0671727e3f5ea518 +Author: Guus Sliepen +Date: Sat Jul 17 00:09:14 2004 +0000 + + Added UML network socket handling. + Now you can use tinc instead of uml_switch. + +commit fe84fafcb684391739a1b3366705c58683210392 +Author: Guus Sliepen +Date: Mon Jun 21 14:37:52 2004 +0000 + + Handle timeouts during connecting the same way as other errors. + +commit e5e0dd7534be5fb96032fb733ca36a09cb067f17 +Author: Guus Sliepen +Date: Mon Jun 14 14:32:10 2004 +0000 + + Clean up environment after executing scripts. + +commit 9e44f116bf0f72d1dd4f099440a351dbe0a74573 +Author: Guus Sliepen +Date: Thu Apr 15 14:09:56 2004 +0000 + + Increase MTU by 4 bytes to allow VLAN tagged Ethernet frames in hub and switch mode. + +commit 7926a156e5b118d06295228e57de0cc9de0433b4 +Author: Guus Sliepen +Date: Sun Mar 21 14:21:22 2004 +0000 + + Update copyrights, links, email addresses and let Subversion update $Id$ keywords. + +commit 42e01abd54bd36ee84a45a2b646cfa27034de8d1 +Merge: 5ca64f8 af86a32 +Author: Guus Sliepen +Date: Sun Mar 21 13:22:24 2004 +0000 + + Move CABAL branch to its rightful place: the trunk. + +commit af86a3226ea42375644b3f99c182c778d327de1e +Author: Guus Sliepen +Date: Sat Mar 20 22:23:42 2004 +0000 + + Revert Martin Kihlgren's patch, it doesn't work the way it should. + +commit 27c304940a5dbe83fb0f655c5c43150bafed3b63 +Author: Guus Sliepen +Date: Sat Mar 20 15:40:26 2004 +0000 + + Use Subversion to create ChangeLog, better svn-clean rule. + +commit 8df22248293a8cd5e6056415b6e08740e40aa2bc +Author: Guus Sliepen +Date: Sat Mar 20 15:33:07 2004 +0000 + + Fix declaration of update_node_address(). + +commit 56aad1bb486675ff9aba31418708cc179eea0381 +Author: Guus Sliepen +Date: Sat Mar 20 15:28:55 2004 +0000 + + Applied Martin Kihlgren's IdentityGenerosity patch, + simplified and renamed to StrictSource. + +commit 8c189c2a9b77fb326ab5f27a05bf2601e16af017 +Author: Guus Sliepen +Date: Mon Mar 15 19:09:52 2004 +0000 + + Even better svn-clean command. + +commit b05df3fcbfb8dbef4c87691d118c5b68aeb79e4a +Author: Guus Sliepen +Date: Mon Mar 15 18:36:14 2004 +0000 + + Updating dutch translation. + +commit a92c471a2bc0773a7473ef0361d1a51fafee50d4 +Author: Guus Sliepen +Date: Mon Mar 15 18:15:02 2004 +0000 + + Only read our public key if it wasn't already in the private key file. + +commit a67a21ef3c17d32af95373e921138429a7fc507e +Author: Guus Sliepen +Date: Mon Mar 15 18:05:41 2004 +0000 + + Eat trailing whitespace in config files. + +commit 4350704d6578656af98195b26006c6b6d6a798e3 +Author: Guus Sliepen +Date: Mon Mar 15 17:54:19 2004 +0000 + + Remove CVS related cruft. + +commit 538595f7350ba6c7d11aba7d9f481ea1641e1857 +Author: Guus Sliepen +Date: Mon Mar 15 17:53:17 2004 +0000 + + Replace cvs-clean with a much better svn-clean. + +commit 5ca64f89be71131e77a29661827dc8866a5f278c +Author: cvs2svn +Date: Sat Jan 10 23:21:36 2004 +0000 + + This commit was generated by cvs2svn to compensate for changes in r1352, + which included commits to RCS files with non-trunk default branches. + +commit fcd836c609568fab323f4af6dd525de957a6f4cc +Author: Guus Sliepen +Date: Sat Jan 10 23:21:36 2004 +0000 + + Remove autogen.sh, the autoreconf program does exactly that. + Update everything for the latest autoconf and automake versions. + +commit f2aa7466e6db9777090583ef26d923fc0a4fcea8 +Author: Guus Sliepen +Date: Sat Jan 10 23:19:20 2004 +0000 + + Small updates. + +commit 519d63bedbdcc533dd7839aae02b4d7bc2debfb0 +Author: Guus Sliepen +Date: Sat Dec 27 16:32:52 2003 +0000 + + Don't forget to update destination MAC address. + +commit aebc97a77f37ec63fbd36721f9b284c975e54270 +Author: Guus Sliepen +Date: Wed Dec 24 10:48:15 2003 +0000 + + Small fixes for PMTU discovery. + +commit 2c7ce7de12d16cb407fd40224b6cb802528ee942 +Author: Guus Sliepen +Date: Mon Dec 22 11:05:23 2003 +0000 + + Missing definitions. + +commit 35399784b695c9ac692beba7be7930ee9f24412f +Author: Guus Sliepen +Date: Mon Dec 22 11:04:17 2003 +0000 + + Improvements for PMTU discovery and IPv4 packet fragmentation. + +commit 6d41b429a26dd1acaa7c56b2124f2daf55b5b97c +Author: Guus Sliepen +Date: Sat Dec 20 21:25:17 2003 +0000 + + Better name, show probed MTU in dump. + +commit af490a745d4ddc8994ceca546b5f9139f6a6ebe2 +Author: Guus Sliepen +Date: Sat Dec 20 21:20:10 2003 +0000 + + Describe the TunnelServer and PMTUDiscovery options. + +commit 9bab08e972ae0ca4b904a659d9aed46aaa9b5dd5 +Author: Guus Sliepen +Date: Sat Dec 20 21:09:33 2003 +0000 + + More sensible name, and try to set PMTU discovery on IPv6 sockets as well. + +commit 6b12bea62fe2e4bd8b5b6bd0e5ca7f53318705db +Author: Guus Sliepen +Date: Sat Dec 20 19:47:53 2003 +0000 + + Let tinc figure out the exact MTU of the link. + +commit e8fbef5de653e4df35eee49aae6e1ac92d6466e6 +Author: Guus Sliepen +Date: Sat Dec 13 21:50:26 2003 +0000 + + Forget multicast. Always inline some function. + +commit 5a1406adefd8b51981af0da5ac0ebec830eb43b4 +Author: Guus Sliepen +Date: Fri Dec 12 19:52:25 2003 +0000 + + Code beautification, start of multicast support. + +commit 354b7ab20e04736b368985a9e9dfd54ff5b7584e +Author: Guus Sliepen +Date: Mon Dec 8 12:00:40 2003 +0000 + + Fix proxy-neighborsolicitation. + +commit 331cef948db4b3cca245ab62cb0fafb5b1e5ebb3 +Author: Guus Sliepen +Date: Sun Dec 7 14:31:09 2003 +0000 + + Don't retry if configuration is wrong from the beginning. + +commit a3cd273751fdcef90a43108a5d2e669877b0bccb +Author: Guus Sliepen +Date: Sun Dec 7 14:29:02 2003 +0000 + + Missing space between words. + +commit 25447b384173cc3c99660c784fd784c787917e80 +Author: Guus Sliepen +Date: Sun Dec 7 14:28:39 2003 +0000 + + Read MaxTimeout from tinc.conf like the manpage says. + +commit 0b5e6cf04ec0c7e3c54c74a54a32b30e6e3c1f83 +Author: Guus Sliepen +Date: Thu Nov 27 23:24:59 2003 +0000 + + Complain if pid file cannot be created. + +commit e3220cacb5bc79fc56167e61b7a342f88a33a479 +Author: Guus Sliepen +Date: Mon Nov 17 15:30:18 2003 +0000 + + Replace Opaque and Strict options with a TunnelServer option. + +commit 0e59fb022c6c015a5be7ed70e0378cb011be98b5 +Author: Guus Sliepen +Date: Mon Nov 10 22:31:53 2003 +0000 + + Add Opaque option which prevent information from being forwarded to certain nodes. + +commit a8f415e67fd316d929f9b9e6661e0d3d66fc197b +Author: Guus Sliepen +Date: Sat Nov 8 15:29:40 2003 +0000 + + Release notes for 1.0.2 + +commit 507a83c74635955f803bb26c450f3e83dd4809f9 +Author: Guus Sliepen +Date: Sat Nov 8 15:09:03 2003 +0000 + + Add missing definitions. + +commit 0271de0e80459bdebcac50d38c053d4aaf657e9a +Author: Guus Sliepen +Date: Sat Nov 8 12:56:24 2003 +0000 + + Update dutch translation. + +commit d35a510fff65a7a3318036f27c11b956526b26f6 +Author: Guus Sliepen +Date: Sun Oct 12 11:40:00 2003 +0000 + + Fix another bug in meta.c. + +commit e88ea7277a97d46fa2c3ba1896cf0d0c62bdf128 +Author: Guus Sliepen +Date: Sat Oct 11 14:42:30 2003 +0000 + + Small fixes in documentation. + +commit ffb7327c20952cefcb5578e40f9802295172c5c2 +Author: Guus Sliepen +Date: Sat Oct 11 14:18:52 2003 +0000 + + Fix bug that could lead to an assertion failure in libcrypto when multiple + requests arrive and TCP packets are heavily fragmented. + +commit 258b7ce220607bb3f2a24bb7cab5fcd19e82314a +Author: Guus Sliepen +Date: Sat Oct 11 12:28:48 2003 +0000 + + Parentheses in the wrong spots. + +commit a1ab57e2755df6c1a8fab95a0886fea368200b96 +Author: Guus Sliepen +Date: Sat Oct 11 12:16:13 2003 +0000 + + Check all EVP_ function calls. + +commit b0dd705a264f0f72a7afba6de85200598cbe083b +Author: Guus Sliepen +Date: Fri Oct 10 16:24:24 2003 +0000 + + Check return value of EVP_* functions, and check if length before en/decryption + matches that after in meta.c. + +commit 9d2bf718f233672c11a9740ed2a1539eaab1509b +Author: Guus Sliepen +Date: Fri Oct 10 16:23:30 2003 +0000 + + Fix ASCII art. + +commit e33307fc9f5354933554d26de618db1b08fc04c0 +Author: Guus Sliepen +Date: Thu Oct 9 21:33:15 2003 +0000 + + Update documentation. + +commit 98edfb14fcc7167d24d440ed2772d0755daac3b7 +Author: Guus Sliepen +Date: Wed Oct 8 12:09:37 2003 +0000 + + Some platforms don't know sa_family_t or define it other than uint16_t. + +commit f2ebdf75806d8c04138db0eb30727f846541ed75 +Author: Guus Sliepen +Date: Wed Oct 8 11:37:53 2003 +0000 + + Set media status for newer TAP-Win32 driver. + +commit acf5f9c968d17ad3e31129d2184309de06d72eed +Author: Guus Sliepen +Date: Wed Oct 8 11:37:20 2003 +0000 + + Missing declaration. + +commit 1d7706a8506d8073def0965da809960c6ad8bf9a +Author: Guus Sliepen +Date: Wed Oct 8 11:34:55 2003 +0000 + + Update missing definitions, structs describing headers get __packed__ attribute. + +commit 5b556c0971e847580b85268e57f0b29dbde5499c +Author: Guus Sliepen +Date: Wed Oct 8 11:33:54 2003 +0000 + + Forgot to #include "xalloc.h" + +commit ad39db95fecf760297b4e320ef2f6d6d9fdad605 +Author: Guus Sliepen +Date: Mon Oct 6 16:49:42 2003 +0000 + + Make sure type of AF_UNKNOWN is sa_family_t. + +commit 5900c07fab39d2833ea66429ad652ca49a91a508 +Author: Guus Sliepen +Date: Mon Oct 6 16:13:08 2003 +0000 + + PIDs are of type pid_t, and use %ld when reading/writing them to the pidfile. + +commit e898b930dcd0694a49dc8cdcf373e0fc125c9fde +Author: Guus Sliepen +Date: Mon Oct 6 16:05:30 2003 +0000 + + Use CPPFLAGS, LDFLAGS and LIBS as appropiate. + +commit 6350334aa44f85e737c1eb0b55e0392766aa1e84 +Author: Guus Sliepen +Date: Mon Oct 6 14:41:45 2003 +0000 + + Don't confuse users with "Address family not supported" warnings. + +commit 0842998c0bd46855d198923acc2c13cff7430ffe +Author: Guus Sliepen +Date: Mon Oct 6 14:33:04 2003 +0000 + + Unused variable in struct. + +commit 77cb10dac0abbfa4389a7588f51797152d91ac22 +Author: Guus Sliepen +Date: Mon Oct 6 14:16:51 2003 +0000 + + Ethernet protocol types. + +commit c97b8827ed34284535706e8017c962ff8f3a4383 +Author: Guus Sliepen +Date: Mon Oct 6 13:57:12 2003 +0000 + + const + +commit 60943122f7b3a5896ce64c9000e119931484c12c +Author: Guus Sliepen +Date: Mon Oct 6 13:49:57 2003 +0000 + + Copy structs from packets to the stack before using them, to prevent + alignment issues. + +commit 5713fb07b3e831b78d8841d56a53c2a2698fe738 +Author: Guus Sliepen +Date: Wed Oct 1 09:43:01 2003 +0000 + + Add description of new authentication scheme. + +commit acbb9d6692614539260749c7b763eca5a6f81f07 +Author: Guus Sliepen +Date: Wed Oct 1 09:14:01 2003 +0000 + + Better length checks. + +commit eeb97e3ef4eb9089851f7b71d5393df24313c993 +Author: Guus Sliepen +Date: Thu Sep 25 10:34:16 2003 +0000 + + Generate keys with 0x10001 as public exponent, which has less prime factors + than 0xFFFF. + +commit 288d956728ab4d4aabe9bc59b87991420dbda151 +Author: Guus Sliepen +Date: Tue Sep 23 20:59:01 2003 +0000 + + Check for short packets from the tun/tap device and from other tinc daemons. + +commit 4e80612ac0f38daa0f2280c293427c7f25dac278 +Author: Guus Sliepen +Date: Tue Sep 9 15:47:59 2003 +0000 + + Update translations. + +commit cbf5a741aa2af937b3db606f0894990703f77bcb +Author: Guus Sliepen +Date: Mon Sep 8 21:52:47 2003 +0000 + + Remove pidfile when exitting. + +commit 0dba26267c76982a422984b61a3196ed2cd2b04a +Author: Guus Sliepen +Date: Wed Sep 3 16:20:33 2003 +0000 + + Prevent multiple inclusions. + +commit 6c5f3d8b74ffea1522a727ef189a5ba65a939e07 +Author: Guus Sliepen +Date: Thu Aug 28 21:05:11 2003 +0000 + + We don't have to tell GCC how to cast. + +commit 762cc2d2797d62ab593ea64d8ceeb4fe96be2a0d +Author: Guus Sliepen +Date: Thu Aug 28 15:27:12 2003 +0000 + + Remove old edges from unreachable nodes to us. This prevents the hosts/NAME-up + script from being called twice in some situations. + +commit a6dc69e7f30522bf885714f6b663960b6fbfff6a +Author: Guus Sliepen +Date: Wed Aug 27 13:58:29 2003 +0000 + + Forgot to synchronise po/ directory... + +commit 62349da6f2617c7250a77af6610344ec0dbfc4f2 +Author: Guus Sliepen +Date: Wed Aug 27 13:57:04 2003 +0000 + + Makevars file was accidentily removed. + +commit dc3b7d47f3297e22161787a1d6e06205140cf0fb +Author: Guus Sliepen +Date: Wed Aug 27 13:47:52 2003 +0000 + + Some device.c files weren't synchronised. + +commit 9e81a6ab5f50df4f5ca36d5303b91a8d5a0e753e +Author: Guus Sliepen +Date: Sun Aug 24 20:50:30 2003 +0000 + + This will become 2.0. + +commit 013a2e159e42c46808ea8d0b6abd57525db30a50 +Author: Guus Sliepen +Date: Sun Aug 24 20:38:31 2003 +0000 + + Synchronise HEAD with CABAL branch. + +commit ffb55e6904426a31c03b56c3bd87bb60db0624c6 +Author: Guus Sliepen +Date: Fri Aug 22 21:32:45 2003 +0000 + + Add license exception from Markus Oberhumer. + +commit 3e0b28b0c4d874934dde7b487a56cfacc956e3b4 +Author: Guus Sliepen +Date: Fri Aug 22 15:07:57 2003 +0000 + + Remove debug message. + +commit 89c9f3ed8fddb316d0f9ef7de30bdc76fba39e41 +Author: Guus Sliepen +Date: Fri Aug 22 15:04:26 2003 +0000 + + When purging nodes, only delete them if nobody references them anymore. + +commit 22dd23b650eb9b760bc68ab3a9227caf3b449140 +Author: Guus Sliepen +Date: Fri Aug 22 15:03:59 2003 +0000 + + Add checkpoints. + +commit 570e7e9c615388cfba263c7a7c66cbc3d092d6e7 +Author: Guus Sliepen +Date: Fri Aug 22 15:05:01 2003 +0000 + + Don't overwrite the first " when installing a service. + +commit 72bdc05cb7e246e56ed21a25256d441c45fccca8 +Author: Guus Sliepen +Date: Fri Aug 22 11:18:42 2003 +0000 + + Allow tinc to handle unknown type addresses from other tinc daemons. + +commit 5ac4179df66747a7013a10d576c23531d2b4fc58 +Author: Guus Sliepen +Date: Sun Aug 17 12:05:08 2003 +0000 + + If we're not in main_loop() and the service is stopped, exit immediately. + +commit 46cfe6199449a86eb58abaeac45b4021ffa7e178 +Author: Guus Sliepen +Date: Sun Aug 17 12:04:35 2003 +0000 + + Do what the SDK documentation tells. + +commit 107448698fc078bbd4cdbacdfbf51298ddc9ea65 +Author: Guus Sliepen +Date: Sun Aug 17 12:03:40 2003 +0000 + + Compilation fix. + +commit 3112e6a863b4421eb1a0b32632b86c55e47f989e +Author: Guus Sliepen +Date: Sun Aug 17 09:04:00 2003 +0000 + + Use the event log under Windows. + +commit 5e7c52610f8c8b9c38e437ef166a08372d5b8a61 +Author: Guus Sliepen +Date: Sun Aug 17 09:03:30 2003 +0000 + + Fix --logfile under Windows. + +commit 2236e05e518c9e317d82c027596bea5228725214 +Author: Guus Sliepen +Date: Sun Aug 17 08:32:39 2003 +0000 + + Fix fake getnameinfo() and check more arguments. + +commit f4e80cc5e0d1689bcdd828ac7f158bd634b7dd20 +Author: Guus Sliepen +Date: Sat Aug 16 12:40:01 2003 +0000 + + Don't getsockopt() SO_ERROR. We get the error from send()/recv() anyway. + +commit fd40130eb6bbba34176d34936a01bb6a6f9121d4 +Author: Guus Sliepen +Date: Sat Aug 16 12:11:11 2003 +0000 + + stat() batch files under Windows. + +commit 03995ca52ee31ed505902a3c8c3d1119988c8497 +Author: Guus Sliepen +Date: Sat Aug 16 12:10:28 2003 +0000 + + Simplify fake getname/addrinfo() functions, possibly fixing freeing a NULL pointer. + +commit dbfd6f284e0ff0aa04e6d6e62b902966912da516 +Author: Guus Sliepen +Date: Thu Aug 14 14:32:34 2003 +0000 + + Update. + +commit 7ed25590257b6ed33dfa879d187a09b0d790794f +Author: Guus Sliepen +Date: Thu Aug 14 14:21:35 2003 +0000 + + Fix permissions check for rsa_key.priv. + +commit 1f2670aab295dfd09c8c655611d2a5b820cb00fc +Author: Guus Sliepen +Date: Tue Aug 12 14:48:13 2003 +0000 + + Small fixes. + +commit b038e8db376969e70f1315840428b8a14ec8420f +Author: Guus Sliepen +Date: Tue Aug 12 12:35:53 2003 +0000 + + Updated dutch translation. + +commit ae070b917066f612e9aba8611c7a5da88e19a51a +Author: Guus Sliepen +Date: Sun Aug 10 13:35:05 2003 +0000 + + Add a description for the Service control panel. + +commit 9b579eb9ffdc1fd4a3d0cacb0728ec0796526bc5 +Author: Guus Sliepen +Date: Sat Aug 9 00:53:22 2003 +0000 + + Update documentation. + +commit 7eed829d288d0fdec2f31709a18ec420e489c2e4 +Author: Guus Sliepen +Date: Fri Aug 8 22:45:46 2003 +0000 + + Only system() needs script name quoted. + +commit 91f65c277483b47343b1b64d0f4edd497a8045a3 +Author: Guus Sliepen +Date: Fri Aug 8 22:13:50 2003 +0000 + + Check for fchmod(). + +commit 9bde92ce97d5503ff2d31dcc6f0648902580ec14 +Author: Guus Sliepen +Date: Fri Aug 8 22:11:54 2003 +0000 + + Simpler checking of permissions on private RSA key and other fixes. + +commit 96f5d98fc299a53fcdad304a56eb3a77a2c229e7 +Author: Guus Sliepen +Date: Fri Aug 8 19:56:11 2003 +0000 + + Small things. + +commit ef65a64443f740e3b22d9e903f764d9a58ce0ff0 +Author: Guus Sliepen +Date: Fri Aug 8 19:49:47 2003 +0000 + + Better error checking and reporting. + +commit bb2f18a3fc8acb7802f30e06153def30eb97a994 +Author: Guus Sliepen +Date: Fri Aug 8 19:45:21 2003 +0000 + + Under Windows, the installation directory can be found in the registry. + +commit 7f05445047c6479b81b7d393543ff73a95ee0dc8 +Author: Guus Sliepen +Date: Fri Aug 8 19:43:47 2003 +0000 + + Quote when needed and don't try stuff that doesn't work under Windows. + +commit b4c913aaa926d80a72aeb97459f84f992b65d1ed +Author: Guus Sliepen +Date: Fri Aug 8 19:42:35 2003 +0000 + + Log error first, try to close later. + +commit b0825f36b7b5dade1693fdbddfec7eef3f5ed86f +Author: Guus Sliepen +Date: Fri Aug 8 19:39:41 2003 +0000 + + Better error messages under Windows. + +commit 6f3099595530280028f6ec3d0b310df523e75f98 +Author: Guus Sliepen +Date: Fri Aug 8 17:20:12 2003 +0000 + + Typo. + +commit 691907caaeb348dee3dbe8a85f3590241f2cc992 +Author: Guus Sliepen +Date: Fri Aug 8 17:17:13 2003 +0000 + + Readd quotes. + +commit f956a28147ec8596c9a51b0c1535bb4b8c87692c +Author: Guus Sliepen +Date: Fri Aug 8 16:49:29 2003 +0000 + + Make rule for sample-config.tar.gz. + +commit 7e74e00d167da659ba6c3db3e8822008d27c081b +Author: Guus Sliepen +Date: Fri Aug 8 14:59:27 2003 +0000 + + Allow empty lines in config files. + +commit 863349638beb1eaab09e2a3d537c20a7913aef30 +Author: Guus Sliepen +Date: Fri Aug 8 14:48:33 2003 +0000 + + Simplify execute_script(). It will probably work under Windows as well. + +commit deba3ed900eb4453d27412606cecfaf89b5a5643 +Author: Guus Sliepen +Date: Fri Aug 8 14:24:09 2003 +0000 + + Correct error message when remote host closed connection. + +commit 0c2256670fc0822cc5a86bca754186c50f943a1c +Author: Guus Sliepen +Date: Fri Aug 8 14:07:12 2003 +0000 + + Remove unused stuff from doc/. + Let configure update pathnames in documentation. + +commit 070aee3be16b8d8078b049c5bb43dce7b18123df +Author: Guus Sliepen +Date: Fri Aug 8 12:55:05 2003 +0000 + + Tell windows to be patient. + +commit adb68b9c2aa7ad72dd5c38b95c083c47599cb65a +Author: Guus Sliepen +Date: Fri Aug 8 12:24:52 2003 +0000 + + Windows uses backslashes... + +commit ef091d1ddb1f7ab5244db96841274dc769e85167 +Author: Guus Sliepen +Date: Fri Aug 8 11:45:37 2003 +0000 + + Sync CABAL branch with release-1_0 branch. + +commit 5193a14ddea4c20ffc708dc629a2f91f1e4ccea3 +Author: Guus Sliepen +Date: Sun Aug 3 21:45:41 2003 +0000 + + Use our own port when connecting to ourself. + +commit 62a7fa9a7bfd1cd1592fd7c381ea28aac0ed7936 +Author: Guus Sliepen +Date: Sun Aug 3 21:45:13 2003 +0000 + + Simplify translation + +commit 98f97da9d7d80b528d9a2b2f03f710cdd2b293d0 +Author: Guus Sliepen +Date: Sun Aug 3 21:43:19 2003 +0000 + + Update dutch translation + +commit e220187f484f3549df3ad3a04939b9a38051d1a0 +Author: Guus Sliepen +Date: Sun Aug 3 12:38:43 2003 +0000 + + Remove newlines from log messages. + +commit 3671ed806d7371fb6b14a5909451b20e54a1b14a +Author: Guus Sliepen +Date: Sun Aug 3 12:38:18 2003 +0000 + + Keep Windows happy. + +commit 7bed2a7099fc7359f6ec24e5f2d7050c7d63b6ac +Author: Guus Sliepen +Date: Sun Aug 3 12:37:55 2003 +0000 + + Cygwin needs windows.h. + +commit fa9c00733e4b793691bf5a068ff7f2f391854fb4 +Author: Guus Sliepen +Date: Sun Aug 3 09:55:20 2003 +0000 + + Old gcc compilers don't like declarations in the middle of a function. + +commit a65011b3c54cd4ddc66f20909ca0e495de0d6eb0 +Author: Guus Sliepen +Date: Sun Aug 3 09:08:52 2003 +0000 + + Clean up last part of main(). + +commit e20ac7b52da8e3f7da292836c6e2551fc9f64617 +Author: Guus Sliepen +Date: Sat Aug 2 22:01:50 2003 +0000 + + Typo and another thing to think about. + +commit 92938c07b17fdd30f4e7f9ae1b884b05c7aa312c +Author: Guus Sliepen +Date: Sat Aug 2 21:55:12 2003 +0000 + + Explain how tinc detaches and how it is "killed" under Windows. + +commit 8a1969bc8319761e3821fc76a7c2f7037ffb8850 +Author: Guus Sliepen +Date: Sat Aug 2 21:39:11 2003 +0000 + + Updated dutch translation. + +commit f605ec47bed26362e24ffacf71c7ae5aeed3c230 +Author: Guus Sliepen +Date: Sat Aug 2 21:34:10 2003 +0000 + + Oops. + +commit e6e32814584f82ee61f658a71cb435bbb491bd39 +Author: Guus Sliepen +Date: Sat Aug 2 21:33:52 2003 +0000 + + Missing include. + +commit c044d12dfd54c033bc5ad9fbf9f889724762f76c +Author: Guus Sliepen +Date: Sat Aug 2 21:33:19 2003 +0000 + + Cleanups and error messages. + +commit 3fd96ebec7e44a0a7288c60da1cdec2d4fe03e8c +Author: Guus Sliepen +Date: Sat Aug 2 21:01:50 2003 +0000 + + Error messages. + +commit f08fc359a0b7f638e73a8f866119b016b7dff8de +Author: Guus Sliepen +Date: Sat Aug 2 20:50:38 2003 +0000 + + Install tinc as a service under Windows (MinGW). Remove cleanup_and_exit(), + either exit() directly on errors or let main_loop() shutdown gracefully. + +commit 7c34122af7ed4667748ceae4966bd5b519ac8ad7 +Author: Guus Sliepen +Date: Sat Aug 2 16:05:33 2003 +0000 + + When compiling with MinGW, link with ws2_32. + +commit 9a491a10eee55b243dd1030ee9016ec510908a10 +Author: Guus Sliepen +Date: Sat Aug 2 15:32:57 2003 +0000 + + Windows has no symbolic links as we know it. + +commit 9c2d5d9f9212dee5ee988f4824e5e4afedb7a2dd +Author: Guus Sliepen +Date: Sat Aug 2 15:29:06 2003 +0000 + + Oops. + +commit c7bf64c7946ece3e1a6a7cdd7bce00045bddb9cd +Author: Guus Sliepen +Date: Sat Aug 2 15:27:24 2003 +0000 + + Allow whitespace in values. + +commit b79e55b183898911e2c2b7b151b281aef8d474e1 +Author: Guus Sliepen +Date: Sat Aug 2 15:13:08 2003 +0000 + + Prevent system headers from including our own headers. + +commit 998ac634d456567e7caf99fe879d4ef1602f36bf +Author: Guus Sliepen +Date: Fri Aug 1 08:18:22 2003 +0000 + + Wrong function... + +commit 2531ff59b73af3a6de85fdc33d744758a6ab9449 +Author: Guus Sliepen +Date: Thu Jul 31 14:24:19 2003 +0000 + + Woops! + +commit 1fe56637874a1e93882a2ca6ffb8c50a773f80e4 +Author: Guus Sliepen +Date: Thu Jul 31 13:18:34 2003 +0000 + + No easy way to properly detect header files... + +commit 8eca27e863d9cb139a1e4039f63aaac3c9afc3c6 +Author: Guus Sliepen +Date: Thu Jul 31 11:31:51 2003 +0000 + + Remove forgotten braces. + +commit 5c29d066688691dd1664597ba1c76195634f06c0 +Author: Guus Sliepen +Date: Thu Jul 31 11:20:32 2003 +0000 + + Wrong argument. + +commit da3078c63a3b658573f6e2f986f69ed4d7993b3a +Author: Guus Sliepen +Date: Thu Jul 31 11:17:39 2003 +0000 + + Check if the compiler knows about the __malloc__ attribute. + +commit d798b8b3d832f8c69769e08cfd64a4d8355faf0e +Author: Guus Sliepen +Date: Wed Jul 30 21:52:41 2003 +0000 + + Prevent definitions from messing up attributes. + +commit 2edc764a333764e7e5c4d3420131c13e9c81ecf7 +Author: Guus Sliepen +Date: Wed Jul 30 16:00:59 2003 +0000 + + Replacement for stdbool.h + +commit fcbe29bc4cc67530581a36cf1a3a1445c741b8e5 +Author: Guus Sliepen +Date: Wed Jul 30 11:50:45 2003 +0000 + + No C99 initialisers, gcc 2.95.3 doesn't like it. + Also make sure getopt.h is included. + +commit de223b51b94c58d1674f1ef56e9d485ff48d366d +Author: Guus Sliepen +Date: Wed Jul 30 09:45:21 2003 +0000 + + Remove doc/es/ and src/device.c from the distribution. + +commit 63568bb6bca20b4d2b2068a6367084a273eabac8 +Author: Guus Sliepen +Date: Wed Jul 30 09:22:29 2003 +0000 + + Update documentation and remove stuff that's too outdated. + +commit 2ed154e73192d5e162544bc570abbb3a1df3ec83 +Author: Guus Sliepen +Date: Tue Jul 29 23:21:01 2003 +0000 + + Cleanups. + +commit 721e4caee0f7c6e003c297c95fb6d93bd4102219 +Author: Guus Sliepen +Date: Tue Jul 29 22:59:01 2003 +0000 + + Native Windows support. + +commit 586f15ed20682413d1bddbb4518dd2714c96b255 +Author: Guus Sliepen +Date: Tue Jul 29 12:38:49 2003 +0000 + + Make sure (at least) the MinGW device driver works. + +commit 6f7cce69479f9b2796d81f458bf836287b74462e +Author: Guus Sliepen +Date: Tue Jul 29 12:18:35 2003 +0000 + + Make sure it works. + +commit 4370b98bb1dfa9eb1e400549cb6fcb6711aa1b29 +Author: Guus Sliepen +Date: Tue Jul 29 11:50:39 2003 +0000 + + Update configure scripts. + +commit ae50b0077e27c4c4d81a98da46c66865ffa069be +Author: Guus Sliepen +Date: Tue Jul 29 11:06:23 2003 +0000 + + Update dutch translation and make sure all device drivers are included in + the translation and distribution. + +commit 714fb32d0377ed9f5643ed8f0bd914843d12266b +Author: Guus Sliepen +Date: Tue Jul 29 10:50:15 2003 +0000 + + Fix compile errors and warnings. + +commit 0e945413315c9d15a3eb013fa3731dd978a8c7b8 +Author: Guus Sliepen +Date: Mon Jul 28 22:06:09 2003 +0000 + + More checks for missing functions. + +commit c15e8a96bf7e45adf750b7a36b0e8446ea049468 +Author: Guus Sliepen +Date: Mon Jul 28 21:54:03 2003 +0000 + + More generic handling of tap device under Windows. + +commit 83263b74460656ba557fd9bb84dc27258549e9cd +Author: Guus Sliepen +Date: Thu Jul 24 12:08:16 2003 +0000 + + Sprinkle around a lot of const and some C99 initialisers. + +commit 5cb147135184e3748c6f5e6e6203d22ab9f904f8 +Author: Guus Sliepen +Date: Wed Jul 23 22:17:31 2003 +0000 + + Don't initialise a CIPHER_CTX if cipher == NULL. + +commit 4aadb9500d9198f9c271deb048a2d36000bfae34 +Author: Guus Sliepen +Date: Tue Jul 22 21:13:23 2003 +0000 + + Run setup_device() after parsing configuration but before claiming we're ready. + +commit eefa28059ab989c915a7d95fb4ae728abd7ce713 +Author: Guus Sliepen +Date: Tue Jul 22 20:55:21 2003 +0000 + + Use bools and enums where appropriate. + +commit 471308e1636e7a06e1d9ebc98e82b1c0c5150dde +Author: Guus Sliepen +Date: Tue Jul 22 12:58:34 2003 +0000 + + Option to specify pidfile location. + +commit c96900f378966ca1be96ddb1c43f855c74083b70 +Author: Guus Sliepen +Date: Mon Jul 21 19:58:58 2003 +0000 + + Add section about configuring Cygwin and CIPE on Windows. + +commit bad82522ecfc1f3c72c600cbca6e8fa7e950c3bf +Author: Guus Sliepen +Date: Mon Jul 21 15:51:00 2003 +0000 + + Copy cygwin driver to mingw directory. It doesn't work (yet). + +commit e169244e4b10dbcc1910c0f7fd811304d5b1a5a5 +Author: Guus Sliepen +Date: Mon Jul 21 14:47:43 2003 +0000 + + Use functions from logger.c + +commit 2f2defc4525befd5b5cb69d03b7887db35e9e46c +Author: Guus Sliepen +Date: Mon Jul 21 13:18:44 2003 +0000 + + Check for sys/mman.h. + +commit 64fd25aa6b794bb1d957b50d48705f30ed47c878 +Author: Guus Sliepen +Date: Mon Jul 21 13:15:36 2003 +0000 + + Oops. + +commit c1e8152f4fe5e4557784d8411e50006d461b8786 +Author: Guus Sliepen +Date: Mon Jul 21 13:14:02 2003 +0000 + + Be consistent. + +commit b657f0519456d05bcea5742017165793f79e56df +Author: Guus Sliepen +Date: Fri Jul 18 14:10:27 2003 +0000 + + No UNIX style permissions under Windows. + +commit 38aa0319ef79124e59b587e6d55f37a79a9d847c +Author: Guus Sliepen +Date: Fri Jul 18 14:09:47 2003 +0000 + + Oops. + +commit 123bb765d10453fdccbe363a02e3042c588729cc +Author: Guus Sliepen +Date: Fri Jul 18 13:45:06 2003 +0000 + + Use iface instead of interface because it might already be declared in + system header files. + +commit 96ee04b678143defa1040f2defdd3424efedea11 +Author: Guus Sliepen +Date: Fri Jul 18 13:42:35 2003 +0000 + + Check for ethernet/ipv4/ipv6 related structures. + +commit 00ddbf5723511d80fbd2522fc503bd409dc6189a +Author: Guus Sliepen +Date: Fri Jul 18 13:41:37 2003 +0000 + + Update all device.c files. + +commit 271d3537fed28b3e76cf0e76082b44c8771ac5da +Author: Guus Sliepen +Date: Fri Jul 18 12:21:03 2003 +0000 + + Remove all #ifndefs from route.c + +commit b0a4f7b5551cae6fb5af2eb4bcb0dfb3443f7d89 +Author: Guus Sliepen +Date: Fri Jul 18 12:16:24 2003 +0000 + + Even more missing definitions. + +commit e449d94caef963809d417f16497f6f978e10d731 +Author: Guus Sliepen +Date: Thu Jul 17 15:06:27 2003 +0000 + + Big header file cleanup: everything that has to do with standard system + libraries is moved to system.h. + +commit 47721be760c495ec13d68181bc03b151ffc1399c +Author: Guus Sliepen +Date: Tue Jul 15 16:38:18 2003 +0000 + + Windows headers declare a struct interface somewhere. + +commit 4c52febc57f2e34f5a187f0e57782903fe1eb95e +Author: Guus Sliepen +Date: Tue Jul 15 16:27:39 2003 +0000 + + Make use of the CIPE driver. Woohoo, tinc for Windows! + +commit d26a4af4561ce4236b8224919cf4f3636f57b4c1 +Author: Guus Sliepen +Date: Tue Jul 15 16:26:18 2003 +0000 + + Export mymac. + +commit 784db4e70d2573468c82ff5dfee723b77a20322f +Author: Guus Sliepen +Date: Sat Jul 12 20:24:04 2003 +0000 + + Format string checking for logger(). + +commit a438ac911e7e60e54d7d1fc4f84373fab7e055af +Author: Guus Sliepen +Date: Sat Jul 12 20:19:22 2003 +0000 + + Removing distribution specific files from CVS. + +commit 085d33e6265e139bb08cdfda3d7498993190d187 +Author: Guus Sliepen +Date: Sat Jul 12 17:48:38 2003 +0000 + + Update copyrights. + +commit 5db596c6844169f1eb5f804b72abe99d067aaa5a +Author: Guus Sliepen +Date: Sat Jul 12 17:41:48 2003 +0000 + + Simplify logging, update copyrights and some minor cleanups. + +commit 2a7f11c0e90f5f0465bbc3c75de715454066ff72 +Author: Guus Sliepen +Date: Fri Jul 11 16:13:00 2003 +0000 + + More missing IPv6 definitions and autoconf checks to make sure it compiles + under Solaris 2.6. + +commit 71f8124ea49f2a0e00e0cedbb1b76e49e9f1425d +Author: Guus Sliepen +Date: Mon Jul 7 11:50:52 2003 +0000 + + More missing definitions. + +commit a88f1edf297152580a7729c6f3d274ba2bff7360 +Author: Guus Sliepen +Date: Mon Jul 7 11:13:31 2003 +0000 + + Actually add ipv6.h. + +commit 30c0381d71d333a99f6c83ff9d03ef4a0857f423 +Author: Guus Sliepen +Date: Mon Jul 7 11:11:33 2003 +0000 + + Provide all missing IPv6 definitions in lib/ipv6.h. + +commit 1401faf608e1c8af0d0754e545b0ec79d2bd5d93 +Author: Guus Sliepen +Date: Sun Jul 6 23:16:29 2003 +0000 + + Sprinkling the source with static and attributes. + +commit 0b9175e998c2180e5d73ef3d644a49d620c68cad +Author: Guus Sliepen +Date: Sun Jul 6 22:11:37 2003 +0000 + + Define logger(), cleans up source code and allows us to write log entries + to a separate file. + +commit 868104703003605711582c984b57f8933bf361ee +Author: Guus Sliepen +Date: Sun Jul 6 17:49:49 2003 +0000 + + Check for IPv6 header files. + +commit 81f5713ab71944d51703653eab7f364fba0c482e +Author: Guus Sliepen +Date: Sun Jul 6 17:15:25 2003 +0000 + + - simplify configure.in + - drop support for OpenSSL < 0.9.7 + - add some missing definitions/includes + +commit 6c7172d694dcb80e538518282b6c4bd51818f1d2 +Author: Guus Sliepen +Date: Wed Jun 25 20:55:05 2003 +0000 + + This subtle pointer arithmetic thingy is (I'm very sure of it) the cause + of the lingering connections problem. Hopefully it is fixed now... + +commit 9528a63c35da77ba5b825068aeffbc5587816dd5 +Author: Guus Sliepen +Date: Wed Jun 25 20:52:59 2003 +0000 + + Really make tinc default to any addressfamily. + +commit 8bfa554af97ee0694919b9f5b78ada89c6af62f5 +Author: Guus Sliepen +Date: Thu Jun 12 11:08:40 2003 +0000 + + There are two lzo compression levels. + +commit c3593491d44e8e8f239bb297f5d5f6541d581b78 +Author: Guus Sliepen +Date: Wed Jun 11 20:36:36 2003 +0000 + + Typo and conversion to UTF-8. + +commit 636e650261712e3687048fe19987fd50ce84b093 +Author: Guus Sliepen +Date: Wed Jun 11 20:19:46 2003 +0000 + + Update dutch translation. + +commit 9279b3c69982b066e2aaea4e444892b51332881a +Author: Guus Sliepen +Date: Wed Jun 11 20:18:48 2003 +0000 + + Update documentation. + +commit 0a9aef2da749f7b7d1ca183daad88f6433579b9f +Author: Guus Sliepen +Date: Wed Jun 11 19:40:43 2003 +0000 + + More braces to make gcc happy. + +commit cf63cbef2bcb6a1f21ded439cbb09842581b9020 +Author: Guus Sliepen +Date: Wed Jun 11 19:39:02 2003 +0000 + + Fixes from Wessel Danker's libavl. + +commit 12de5a8eedd985f4732e88de6185f77a8244612c +Author: Guus Sliepen +Date: Wed Jun 11 19:28:38 2003 +0000 + + Remove mymac stuff from device.c. + +commit 31f17d43346a9175aec7c29ce41c71b1d08f725e +Author: Guus Sliepen +Date: Wed Jun 11 19:27:35 2003 +0000 + + AddressFamily is "any" by default. + +commit 451800eda87e886021fabd1888e486c51e97902a +Author: Guus Sliepen +Date: Wed Jun 11 19:09:52 2003 +0000 + + If we have a Linux tun/tap device and we are in router mode, open the device + in tun mode. + +commit 9e02a3d5631b687833e4cdcde18cda66e38138fc +Author: Guus Sliepen +Date: Wed Jun 11 19:07:56 2003 +0000 + + Call make_names() before doing anything else. + +commit 4b0e5a03fe89529ebe5d471a82c29c153a12116b +Author: Guus Sliepen +Date: Sat Jun 7 13:18:32 2003 +0000 + + Fix warning and add missing checks for LZO library. + +commit f238c209f4a0ced889b8fb443753ed2cdb3548b3 +Author: Guus Sliepen +Date: Sat May 17 22:12:52 2003 +0000 + + Fix links. + +commit 249933350bda2c3fa09c7ce8eb36bf84ee30a1cb +Author: Guus Sliepen +Date: Wed May 7 11:21:58 2003 +0000 + + Small fixes. + +commit 6ba4e2da55001e17aec6a7ee71002130555ff439 +Author: Guus Sliepen +Date: Tue May 6 23:14:45 2003 +0000 + + Small fixes to make LZO compression work. + +commit c70f52087bf6f7514684bbc859b83aec2ca17ae4 +Author: Guus Sliepen +Date: Tue May 6 21:13:18 2003 +0000 + + - Per-node EVP_CIPHER_CTX to avoid initialisation overhead. + - LZO compression, thanks to Teemu Kiviniemi. + - Updated dutch translation. + +commit 1ad2394b8468593030653bbfd0dee879fb711432 +Author: Guus Sliepen +Date: Sat Apr 19 11:12:45 2003 +0000 + + Make sure outgoing_t is completely freed. + +commit bc9e78250ef6fb5169d03565b7d8d9caf309eb98 +Author: Guus Sliepen +Date: Fri Apr 18 21:18:36 2003 +0000 + + Better handling of late packets. + +commit 51a1bcf00143319c74ffb58a66a19c41be422c21 +Author: Guus Sliepen +Date: Thu Apr 3 11:43:17 2003 +0000 + + HUP signal now closes connections to hosts if their host config file is + gone or changed. The tinc.conf file is reread for changes in the ConnectTo + lines. + +commit 8285827da127e38728b60b5c5484e5cdabff2f21 +Author: Guus Sliepen +Date: Sat Mar 29 22:11:22 2003 +0000 + + Checksums must also work for uneven number of bytes. + +commit c3ad3731a8dfa34535a156a7cfdb4e18afaa8bce +Author: Guus Sliepen +Date: Sat Mar 29 21:58:35 2003 +0000 + + Don't copy more than necessary. + +commit 7d21a8d1c7fd8909fe02385dbb4717c074db4648 +Author: Guus Sliepen +Date: Sat Mar 29 21:51:21 2003 +0000 + + - Speed up checksumming + - If a destination is not found in the subnet list or the destination node + is unreachable, respond with an appropiate ICMP message. + +commit 9792ba2cac35cb50cc99b72dd4cb9d3ef350dbd4 +Author: Guus Sliepen +Date: Fri Mar 28 13:41:49 2003 +0000 + + - Avoid memory leak caused by OpenSSL 0.9.7a. + - Disable RSA_blinding_on() because it segfaults. + +commit 69158563e9f790777eb27aeb8484a86d12385af4 +Author: Guus Sliepen +Date: Wed Mar 19 11:45:05 2003 +0000 + + Typo. + +commit 88ae2e9e0c1eb62d9b74c4b38d9c0e93557fed9f +Author: Guus Sliepen +Date: Wed Mar 19 11:43:42 2003 +0000 + + Make sure send_meta() writes everything. + +commit 2fff0a91a7e3e5f44e97255b6dd5807656b255a8 +Author: Ivo Timmermans +Date: Fri Mar 14 09:43:10 2003 +0000 + + Call RSA_blinding_on(), as advised in the paper on + http://crypto.stanford.edu/~dabo/abstracts/ssl-timing.html + to offer some resistance against timing attacks. + +commit 1783a3aaa9b692ab64260a9c2adf588ed6083a1c +Author: Guus Sliepen +Date: Fri Jan 17 00:43:58 2003 +0000 + + Various fixes for autoconf and OpenSSL 0.9.7 and a missing header. + +commit c08858baa91a00e38c0f5482dbb0817dbd0361f1 +Author: Guus Sliepen +Date: Fri Jan 17 00:37:20 2003 +0000 + + - Fix indentation in some places. + - Optimise select loop. + - Remove unused function setup_outgoing_socket(). + - Clear EVP_CIPHER_CTX structures before using them. + +commit 38f562fdfcacb50d34b9a48bfaea7faa132f493a +Author: Guus Sliepen +Date: Tue Jan 14 12:53:59 2003 +0000 + + Add $NAME for tinc-up/down scripts. + +commit 44b87ddb7ac90be13ef3e3d5118acaa158184853 +Author: Guus Sliepen +Date: Sun Jan 12 17:02:23 2003 +0000 + + Run graph algorithm when replacing a second connection from the same host + replaces an older one. + +commit 4c88ff86bcd32735d4768ef3464812cd77c500be +Author: Guus Sliepen +Date: Fri Dec 27 19:32:33 2002 +0000 + + PrivateKeyFile instead of PrivateKey. + +commit 5b2a62ebb6317cd88e491ee958c54670f381aee8 +Author: Guus Sliepen +Date: Thu Nov 14 22:09:03 2002 +0000 + + Fix PriorityInheritance. + +commit 07db46a44feb283c1c17bcce918ab49274a3b11f +Author: Guus Sliepen +Date: Mon Oct 7 07:32:31 2002 +0000 + + Add documentation for BindToAddress. + +commit e310cc82d3f9c9bdb3b827daa149861a41e2e00a +Author: Ivo Timmermans +Date: Mon Sep 30 19:04:37 2002 +0000 + + Fix saving of debug level for startup level 0 + +commit 006591efe5b3e6c64040d267f8c0477468abf2bf +Author: Guus Sliepen +Date: Tue Sep 24 11:43:34 2002 +0000 + + Run graph() after edge_del() when updating an edge. + +commit 6904e0469ef52aa6100f0185d579bc205bd07be8 +Author: Wessel Dankers +Date: Mon Sep 16 14:08:04 2002 +0000 + + its: Engels voor "van het" - 3e persoon enkelvoud, genitief, onzijdig + it's: Engels voor "het is". Dus niet "van het". + +commit 4f3395ee4dad3cdd23706af180ebddfa5e576012 +Author: Guus Sliepen +Date: Sun Sep 15 22:37:59 2002 +0000 + + Thank some more people. + +commit b216297a004f083336c633aaccecb4ab175360b3 +Author: Guus Sliepen +Date: Sun Sep 15 22:34:25 2002 +0000 + + Remarks about 1.0pre8 release. + +commit 1dcbdf48eb4a642e4d70a9e67aaca78deacf352d +Author: Guus Sliepen +Date: Sun Sep 15 22:19:38 2002 +0000 + + Update documentation. + +commit bf3a11898898c0618cd1b2e7a792b7d7fe56aecb +Author: Guus Sliepen +Date: Sun Sep 15 22:19:19 2002 +0000 + + Use /dev/net/tun as default for tun/tap device under Linux. + +commit 7d76ceaebd5180f4ef37086980c799199eb7de16 +Author: Guus Sliepen +Date: Sun Sep 15 17:40:00 2002 +0000 + + Updated dutch translation. + +commit 5eca9520d93bced1275d45e5e2a933d69354cd6d +Author: Guus Sliepen +Date: Sun Sep 15 14:55:54 2002 +0000 + + Small fixes so tinc compiles out of the box on SunOS 5.8 + +commit 8d472a415e9c5fdb878386005d29cdfd97b8a404 +Author: Guus Sliepen +Date: Sun Sep 15 12:26:24 2002 +0000 + + port_t isn't used anymore and conflicts with MacOS/X headers. + +commit 38c80bdd46fab68c686a293e2820041291972f3a +Author: Guus Sliepen +Date: Sun Sep 15 12:26:04 2002 +0000 + + MacOS/X needs #define _P1003_1B_VISIBLE in order to use mlockall(). + +commit 3e3b4a3190cf950c265a8c62d577812a22b11dcc +Author: Guus Sliepen +Date: Wed Sep 11 22:25:58 2002 +0000 + + What was I thinking? + +commit f6905582d0e70ac5b44369780aaa921d9c721197 +Author: Guus Sliepen +Date: Tue Sep 10 22:13:22 2002 +0000 + + Make sure malloc() is declared. + +commit eaf1208e9d5c5a15e4b23de936830520bf3b5685 +Author: Guus Sliepen +Date: Tue Sep 10 22:13:01 2002 +0000 + + Fix placement of #include "config.h" + +commit dd888ca685176128bf41034208f3dbb220f9d832 +Author: Guus Sliepen +Date: Tue Sep 10 21:46:05 2002 +0000 + + Link with libintl if necessary. + +commit c01f78ed3603eecaec8e3649a3bfb3de9742fd24 +Author: Guus Sliepen +Date: Tue Sep 10 21:29:42 2002 +0000 + + Clean up after indent. + +commit 161f917dd03c174742fb8c6722f430a93b506cb1 +Author: Guus Sliepen +Date: Tue Sep 10 09:40:25 2002 +0000 + + Fix compiler warnings. + +commit 3bc554347560a9c24e68bb2c7c7749be07bbec3d +Author: Guus Sliepen +Date: Mon Sep 9 22:41:56 2002 +0000 + + Let GCC check format string and arguments of send_request(). + +commit 6f9f6779e6bd1dd7bb795b42dad550863a386ca8 +Author: Guus Sliepen +Date: Mon Sep 9 22:33:31 2002 +0000 + + Remove redundant spaces. + +commit 9f38e394636a177c00a4545de2a99c661de36386 +Author: Guus Sliepen +Date: Mon Sep 9 21:49:16 2002 +0000 + + Switch to K&R style indentation. + +commit f75dcef72a81a337e847adf0bae54198894f65b9 +Author: Guus Sliepen +Date: Mon Sep 9 21:25:28 2002 +0000 + + Switch to K&R style indentation. + +commit 5fc1ed17f41f0c535cf57a4b7e00cd6d45759503 +Author: Guus Sliepen +Date: Mon Sep 9 19:40:12 2002 +0000 + + Cleanups: + - Convert cp to cp(); so that automatic indenters work. + - Convert constructions like if(x == NULL) to if(!x). + - Move all assignments out of conditions. + +commit 5638b9830f9cfe43f545c37cfd7ccf1d4b4bfcc6 +Author: Guus Sliepen +Date: Fri Sep 6 21:22:35 2002 +0000 + + Why don't these connection_t's get cleaned up? + +commit a8ddba42b99d7694359f1387235596b84d297b9e +Author: Guus Sliepen +Date: Fri Sep 6 21:02:36 2002 +0000 + + Fix MST algorithm. + +commit 66741978e16cc407e5c760621c34d1aabb753cd2 +Author: Guus Sliepen +Date: Fri Sep 6 14:31:12 2002 +0000 + + Reset the *correct* seqnos. + +commit d5b61fc0cd249fd2b2751a1ff77b321323a17beb +Author: Guus Sliepen +Date: Fri Sep 6 12:19:16 2002 +0000 + + edge_weight_compare() shouldn't rely on edge_compare(). + +commit fc7116a32b798589e7731db9f9db66345c8c3e01 +Author: Ivo Timmermans +Date: Fri Sep 6 11:08:21 2002 +0000 + + Added AM_MAINTAINER_MODE + +commit fbf8a47879671541939cfdc6beb93b02b9eee303 +Author: Guus Sliepen +Date: Fri Sep 6 10:23:52 2002 +0000 + + Remove global edge_tree. + +commit 641705df90b4c41e7f5083f6cd601cbbfb1c2c85 +Author: Guus Sliepen +Date: Fri Sep 6 09:48:39 2002 +0000 + + Only reset seqno's when a key is sent or received. + +commit e4d85a6557ee45870bee0c5a16807e48b7a3c243 +Author: Guus Sliepen +Date: Wed Sep 4 23:11:58 2002 +0000 + + Typo. + +commit b4f87952bf2d37524c705b32864f802144f94d68 +Author: Guus Sliepen +Date: Wed Sep 4 23:05:49 2002 +0000 + + Add missing headers. + +commit b18bd211bec84a804f58da5f2d2908e54de3fe40 +Author: Guus Sliepen +Date: Wed Sep 4 23:04:52 2002 +0000 + + Run autopoint and libtoolize before creating initial makefiles. + +commit 6fdaa8e1caff4edb44a105b03c79403b743e9bd2 +Author: Guus Sliepen +Date: Wed Sep 4 19:57:53 2002 +0000 + + Small updates. + +commit d4277e9ee8affa59ac9b3475245360bd14af1fa8 +Author: Guus Sliepen +Date: Wed Sep 4 16:36:03 2002 +0000 + + Updated dutch translation. + +commit 8b2b67e26c5b971761f5015764d5e188f6343bc4 +Author: Guus Sliepen +Date: Wed Sep 4 16:26:45 2002 +0000 + + Generalized request broadcasting/forwarding. + +commit 431fa10b37e78172a03c952e28a0364cc0e438f0 +Author: Guus Sliepen +Date: Wed Sep 4 14:17:28 2002 +0000 + + Small fixes. + +commit 82ebfc923ddb050c88bdf5d65ac943a15ca8748a +Author: Guus Sliepen +Date: Wed Sep 4 13:48:52 2002 +0000 + + Revert to edge and graph stuff. This time, use a directed graph. + +commit 973530db628fb91106d6fb7a17151e1d036e40a2 +Author: Guus Sliepen +Date: Wed Sep 4 08:48:03 2002 +0000 + + Just ignore wrong ADD_NODEs instead of replying with a DEL_NODE, in the + hope other DEL_NODEs will catch up eventually. + +commit 2af0bcc8fd39ca34a7ff856d539cdf38728a8c25 +Author: Guus Sliepen +Date: Wed Sep 4 08:36:34 2002 +0000 + + Don't forget to set prevhop to myself for new connections. + +commit 698d6ddac6ab32d5a4b802941b02232793442684 +Author: Guus Sliepen +Date: Wed Sep 4 08:33:08 2002 +0000 + + Prevent looping DEL_NODE/ADD_NODE messages after a node disconnects. + +commit 4a7c2026aec6966f934b60d75bc472d28f8587d8 +Author: Guus Sliepen +Date: Wed Sep 4 08:02:33 2002 +0000 + + Reduce KEY_CHANGED traffic. + +commit ddb96301a39dd3dac8d3df4e2e189b13b75e0b6e +Author: Guus Sliepen +Date: Tue Sep 3 22:49:55 2002 +0000 + + Woops. + +commit b5bb06200eda170c9836e1b4474d6f5b920c2151 +Author: Guus Sliepen +Date: Tue Sep 3 22:37:49 2002 +0000 + + A reachable node is always more preferable to an unreachable one... + +commit d134c4542d4e890e1c1007f32b866742319853c5 +Author: Guus Sliepen +Date: Tue Sep 3 20:43:26 2002 +0000 + + Drop graph and edge stuff. Use new node stuff instead. + +commit 856de4c5fe8acd779aa9277d4554e34ff3625e97 +Author: Guus Sliepen +Date: Tue Sep 3 20:42:05 2002 +0000 + + Make sure setlocale() is available. + +commit 2cb21f8810a6e0241a80623e991c8308b603ae95 +Author: Guus Sliepen +Date: Mon Sep 2 22:40:42 2002 +0000 + + Replacement for the current routing algorithm. + +commit f2c2443bbcfd5e09518bd87f3fd8d4a727d73ae2 +Author: Guus Sliepen +Date: Sat Aug 24 12:54:55 2002 +0000 + + Check for ranlib. + +commit 912e7e968f4888d62b3c620893a70e825599973b +Author: Guus Sliepen +Date: Sat Aug 24 12:11:40 2002 +0000 + + Gettext 1.11.5 compatibility. + +commit 18948c5784bfedf0dd5a371e41bc2cceee76d92e +Author: Guus Sliepen +Date: Thu Jul 18 14:30:45 2002 +0000 + + Added support for raw sockets. This can be used instead of tun/tap devices. + +commit 9f370893fafaeacdd78f5488cfa8b76fdee0d224 +Author: Guus Sliepen +Date: Tue Jul 16 13:18:27 2002 +0000 + + Don't bother to chown, and correctly document ConnectTo. + +commit 227ccd3a8a5602e4c31add8da1bfd8b35c6a801f +Author: Guus Sliepen +Date: Tue Jul 16 13:12:49 2002 +0000 + + Allow tincd to be locked into main memory. + +commit c4cd19935763b379e730a6fdf53dc1ca98d0b938 +Author: Guus Sliepen +Date: Fri Jul 12 11:45:21 2002 +0000 + + Include complete fake-getname/addrinfo from OpenSSH. + +commit afabbd6b9020dd6555a7ecd320a7b3e96119d538 +Author: Guus Sliepen +Date: Thu Jul 11 12:57:06 2002 +0000 + + Added stub device.c for Cygwin. + +commit 8949404db08f4ab594e60778bb76a9061426d7cc +Author: Guus Sliepen +Date: Thu Jul 11 12:55:58 2002 +0000 + + Started port to Cygwin. + +commit c98db1b861d62430e23f26b0da18e7b3ec875767 +Author: Guus Sliepen +Date: Thu Jul 11 12:42:43 2002 +0000 + + Clear subnets before using them. + +commit 8dd09568f1604f1ac8cc0d8d5120d986f5654900 +Author: Guus Sliepen +Date: Wed Jul 10 11:32:33 2002 +0000 + + Allow identical subnets from different owners. + +commit 36cbaa32f480b481bf2ee99fd4835586a02ebc60 +Author: Guus Sliepen +Date: Wed Jul 10 11:27:06 2002 +0000 + + Allow list of environment variables to be passed to execute_script(). + When executing host-up/down scripts, include the address and port of the + remote host. + +commit a1bd878e11ae7e66e7e9a4040c3b19f9b7bc50f4 +Author: Guus Sliepen +Date: Fri Jun 21 17:49:48 2002 +0000 + + Fix for prefixlengths of 32 (IPv4) and 128 (IPv6) bits. + +commit 627f7c22b447bd464b536cd016278545674df93d +Author: Guus Sliepen +Date: Fri Jun 21 10:11:37 2002 +0000 + + s/sliepen.warande.net/sliepen.eu.org/g + s/itimmermans@bigfoot.com/ivo@o2w.nl/g + +commit faabd163adf89bd0580cd40b8735ef8d9028a942 +Author: Guus Sliepen +Date: Fri Jun 14 11:51:29 2002 +0000 + + Update comments about IPv6 autoconfiguration. + +commit 940fcb6701d055f49530f12c93371f0280efce80 +Author: Guus Sliepen +Date: Thu Jun 13 16:12:40 2002 +0000 + + Reset listen_sockets after SIGHUP. + +commit 3a3adf5b690e9be1390a5df3caee6af64b25838f +Author: Guus Sliepen +Date: Wed Jun 12 13:45:23 2002 +0000 + + Add configuration details for NetBSD and Darwin (MacOS/X). + +commit 8988b127e18435054e48cbcca8ac712ddda3d6d2 +Author: Guus Sliepen +Date: Tue Jun 11 11:03:17 2002 +0000 + + Autoconf cleanup. Works for both 2.13 and 2.53, although running autoconf + 2.53 still gives some errors. + +commit de6835a9dd1891b6435c128cc6c2293950a4d7a7 +Author: Guus Sliepen +Date: Mon Jun 10 15:08:23 2002 +0000 + + Include darwin/device.c in distribution. + +commit 40ac473cb10f9c6a59739ce70032b746d8e0bf68 +Author: Guus Sliepen +Date: Mon Jun 10 14:35:18 2002 +0000 + + Use darwin/device.c when compiling on MacOS/X. + +commit 69b758879ee6d322e89143141b98d52167845c26 +Author: Guus Sliepen +Date: Mon Jun 10 14:33:40 2002 +0000 + + Added Darwin (MacOS/X) tun device handling. + +commit bd72e14138185f342885c0ed1c0f2c5dbf571132 +Author: Ivo Timmermans +Date: Sun Jun 9 16:23:12 2002 +0000 + + Added Alessandro Gatti + +commit 944df3eeee50972fcac84cfc8eefb36033bf04ad +Author: Ivo Timmermans +Date: Sun Jun 9 16:19:20 2002 +0000 + + Include netbsd's device.c in make dist + +commit 7608136a8dae24f2df30eac8644efd0d7cd57dc9 +Author: Ivo Timmermans +Date: Sun Jun 9 16:12:04 2002 +0000 + + Include a few more header files + +commit cd3601c5df57c7544ece00bf79e82b36499a26ff +Author: Ivo Timmermans +Date: Sun Jun 9 15:58:05 2002 +0000 + + Add /sw/{include,lib} to search paths if they exist + +commit 548551fd05f58863dfbbaaf147febfab0a22889b +Author: Ivo Timmermans +Date: Sun Jun 9 15:50:12 2002 +0000 + + getnameinfo fixes + +commit 9d769e0bf2ce266e8533e5e7c16bf07e44a9be34 +Author: Ivo Timmermans +Date: Sun Jun 9 15:26:10 2002 +0000 + + OSX support + +commit 78e88521845ae3bdd963ae5a414cb9c251963fa2 +Author: Guus Sliepen +Date: Sat Jun 8 14:08:57 2002 +0000 + + - netinet/* include files depend on netinet/in_systm.h. + - Squash bashism in configure.in. + +commit e47e51e9d17416e2b614287d14a5518881decd44 +Author: Guus Sliepen +Date: Sat Jun 8 13:46:43 2002 +0000 + + Use inttypes.h instead of stdint.h. + +commit 116ba3b3da73fb857cf75b5c92c6aacd70d94dd9 +Author: Guus Sliepen +Date: Sat Jun 8 12:57:10 2002 +0000 + + Cleanup: + - Remove checks for specific OS's, instead check for #defines/#includes. + - Use uint??_t where appropriate. + - Mask handling functions use void pointers to get rid of silly casts. + +commit d333fca4d611b85dd922ddf35bd9eddcb8095c85 +Author: Wessel Dankers +Date: Fri Jun 7 11:14:05 2002 +0000 + + This should work much better. + +commit 14e570f5eeff631c1312b11fcc5d22230ec27aff +Author: Guus Sliepen +Date: Wed Jun 5 00:25:55 2002 +0000 + + Use correct includes on NetBSD. + +commit 5886b6a10d0d2edf20ff53c4926ec4e41a36b8c0 +Author: Guus Sliepen +Date: Wed Jun 5 00:20:40 2002 +0000 + + Make it work correctly with NetBSD tun device. + +commit 4856d8e1f8398780a49545f35ba9b5746c9fc060 +Author: Guus Sliepen +Date: Sun Jun 2 16:06:33 2002 +0000 + + Support RSA_PUBKEYs (as opposed to RSAPublicKeys) so tinc accepts + public keys generated by the OpenSSL command line tools. + +commit efa5148bc76effb440d807d653dda02de050fde0 +Author: Ivo Timmermans +Date: Tue May 7 14:48:41 2002 +0000 + + Hm. + +commit 151ab8c9708534e012447688ed44d711d5b5fa2d +Author: Ivo Timmermans +Date: Thu May 2 13:23:58 2002 +0000 + + test 2 + +commit be04387a0c868b22ee4427822573df8b3b479bbe +Author: Ivo Timmermans +Date: Thu May 2 13:22:44 2002 +0000 + + test + +commit a9bb66367df82d062175f2b9b4bf236d77ae3ff1 +Author: Ivo Timmermans +Date: Thu May 2 13:11:55 2002 +0000 + + Moved event.c/h + +commit 474aab6325bf94724874cb74a9b56d9da739e1b8 +Author: Ivo Timmermans +Date: Thu May 2 11:52:28 2002 +0000 + + Callbacks + +commit 4c1a4e8a790584e4c7d5c0f2485706f4c01e1911 +Author: Ivo Timmermans +Date: Thu May 2 11:50:07 2002 +0000 + + Another file moved; random interface stuff. + +commit 2be8e69ca16e1558463c39c48af76d3d4a4674b7 +Author: Guus Sliepen +Date: Wed May 1 09:15:58 2002 +0000 + + Only purge once when there are no more connections. + +commit a77b35e748b7cf4cf7ac31750cefab7b2b0325f5 +Author: Ivo Timmermans +Date: Mon Apr 29 20:19:42 2002 +0000 + + Commit diff test + +commit 7caa253df4a34e594438e3fbe80c2bddab9a2b4a +Author: Guus Sliepen +Date: Mon Apr 29 20:05:07 2002 +0000 + + Fix very stupid bug in node_del(), which might have caused corruption of + subnets. + +commit 04d33be4bd102de67bb6dba5c449e12fea0db4d2 +Author: Ivo Timmermans +Date: Sun Apr 28 12:46:26 2002 +0000 + + Moving files, first attempt at gcrypt compatibility, more interface + abstraction + +commit b0a676988a8da3120e64ef0e1a4ea4c28b1511e1 +Author: Ivo Timmermans +Date: Sun Apr 28 12:43:40 2002 +0000 + + *** empty log message *** + +commit 67a6d7bcc4891c627663c639c0e02315bd4cf437 +Author: Guus Sliepen +Date: Sat Apr 27 11:40:45 2002 +0000 + + Informative log message if execl() failed. + +commit e6a67fc439fc3b46157647bed1af59b7519adb80 +Author: Ivo Timmermans +Date: Fri Apr 26 18:13:00 2002 +0000 + + Typo + +commit 01747d73a217f7ddf2107b086476702a9d04d683 +Author: Guus Sliepen +Date: Thu Apr 25 19:17:24 2002 +0000 + + Added Nick Patavalis for his RedHat package. + +commit b6ad4ce35a4434c209ee26015f15a18180987bac +Author: Guus Sliepen +Date: Tue Apr 23 07:49:38 2002 +0000 + + Add BindToAddress variable, similar to the late BindToIP. + +commit 40c2e36a96a3f5c34d4851b30f3561123f3906b5 +Author: Guus Sliepen +Date: Fri Apr 19 14:06:40 2002 +0000 + + Support for MaxOS/X. + +commit 97d492d9e23f43fe4c8a5ca8c95747088cf32f98 +Author: Ivo Timmermans +Date: Thu Apr 18 20:09:05 2002 +0000 + + Put #ifndef checks for HAVE_RAND_PSEUDO_BYTES in the correct places. + +commit fa8faff84bbbeb818adaea80d7bf9e12e0074978 +Author: Ivo Timmermans +Date: Sat Apr 13 18:01:58 2002 +0000 + + Print newline when writing to stderr + +commit fbebc5b65606119c01e9e1e3fcc7b2cc4cfd1daf +Author: Ivo Timmermans +Date: Sat Apr 13 11:24:25 2002 +0000 + + ... + +commit 7c75090025a4b06290663e0033a62414f3368f7c +Author: Ivo Timmermans +Date: Sat Apr 13 11:23:46 2002 +0000 + + Rename libvpn to libtinc + +commit 55385cacbfb0c743fc518e54854e24b7b05a623c +Author: Ivo Timmermans +Date: Sat Apr 13 11:23:19 2002 +0000 + + Renamed libvpn to libtinc + +commit 2389dcd573d909f21c8ec2d349b079075af6c7d3 +Author: Ivo Timmermans +Date: Sat Apr 13 11:21:58 2002 +0000 + + Include logging.h + +commit 246ce12c92ccc7badbb8c8c9a88fa03a7de9811f +Author: Ivo Timmermans +Date: Sat Apr 13 11:21:01 2002 +0000 + + Use new logging system + +commit a5b3ec41214ac8aea9b82734f92b5953e04a0c09 +Author: Ivo Timmermans +Date: Sat Apr 13 11:15:43 2002 +0000 + + Things to ignore... + +commit e239504524589a0f1549ca174f927afd07d563ba +Author: Ivo Timmermans +Date: Sat Apr 13 11:14:50 2002 +0000 + + Compile in logging.c + +commit e26dd564163fca001ab1694a51e7412f9ac970de +Author: Ivo Timmermans +Date: Sat Apr 13 11:08:31 2002 +0000 + + Use logging.h instead of syslog.h + +commit 72cd8938e2c759905666ea7d2c90dc1f0b2e2cd5 +Author: Ivo Timmermans +Date: Sat Apr 13 11:00:41 2002 +0000 + + Added prototype for log_syslog + +commit 48b80c93d30d5fae4273b0b496252bbc884abe53 +Author: Ivo Timmermans +Date: Sat Apr 13 10:55:42 2002 +0000 + + log_default_hook was renamed to log_default + +commit b63c3a1f0002675b6bedbd0b235e0ad0a708d4e3 +Author: Ivo Timmermans +Date: Sat Apr 13 10:50:48 2002 +0000 + + Added priority definitions from syslog.h + +commit 490b13edcfcae0422b6bd77fdb2a7f0181b14307 +Author: Ivo Timmermans +Date: Sat Apr 13 10:45:56 2002 +0000 + + Some magic + +commit 738389581b1ba29a181f639f3d20e3e24ff546f5 +Author: Ivo Timmermans +Date: Sat Apr 13 10:43:10 2002 +0000 + + Add syslog wrapper + +commit efa59f7cf4d416c8416866baeaa72cba7e936568 +Author: Ivo Timmermans +Date: Sat Apr 13 10:40:09 2002 +0000 + + Add syslog() wrapper + +commit 8822481d7b11db72d5400717d6b491b5f36bcb1f +Author: Ivo Timmermans +Date: Sat Apr 13 10:29:07 2002 +0000 + + Rename log_message to log + +commit cc603e2765f17555ecdc2b74c27ebf96e6691bf6 +Author: Ivo Timmermans +Date: Sat Apr 13 10:25:38 2002 +0000 + + New logging system to replace syslog() calls with a generic function. + +commit 131327a729216de8ae86da0c3c4d65d409741b7b +Author: Ivo Timmermans +Date: Sat Apr 13 10:04:46 2002 +0000 + + Remove debug_lvl + +commit e3c51b61caabc1a55772f7a52e75aab642c200ed +Author: Ivo Timmermans +Date: Sat Apr 13 10:02:48 2002 +0000 + + Update copyright info + +commit 9e8468f54aa5ecdb8b63c60449791427b59a474d +Author: Ivo Timmermans +Date: Sat Apr 13 10:02:16 2002 +0000 + + Remove debug level declaration + +commit 9f2c50e159caea1884c6a7aaa33f8098539ae0f5 +Author: Guus Sliepen +Date: Fri Apr 12 08:25:01 2002 +0000 + + Adding even more stuff from the CABAL branch. + +commit 191dcd5add0afba8b5d3aaa1e188c562c621712e +Author: Ivo Timmermans +Date: Thu Apr 11 20:18:02 2002 +0000 + + Also compile in pokey/ + +commit 39e93f473d34d6cdf6f4a7f0390a3b50cbd7b564 +Author: Ivo Timmermans +Date: Thu Apr 11 20:17:33 2002 +0000 + + Write src/pokey/Makefile + +commit c351b9e25b9f7b168a47fd8e6b60c66377e1824c +Author: Ivo Timmermans +Date: Thu Apr 11 14:27:35 2002 +0000 + + Pokey interface definition + +commit 17b308f0f0879c01f6864265af2e63595e965993 +Author: Ivo Timmermans +Date: Thu Apr 11 14:23:56 2002 +0000 + + Main pokey interface files. + +commit b5b38381c643632aa88c677236cace8c60e8344e +Author: Ivo Timmermans +Date: Tue Apr 9 16:11:48 2002 +0000 + + Last bits (hopefully) + +commit 77dd7b55801a3c7c2c6221664204ffdd7b83836a +Author: Ivo Timmermans +Date: Tue Apr 9 15:51:26 2002 +0000 + + More... + +commit 58c1df4028429ed6de4dad9455e3c92928450ffe +Author: Ivo Timmermans +Date: Tue Apr 9 15:48:54 2002 +0000 + + More updates + +commit 86dc60b9808d3aac70eccda80607a91ffd2e5292 +Author: Ivo Timmermans +Date: Tue Apr 9 15:32:14 2002 +0000 + + Ok, I forgot these ;) + +commit af23dfa5efb82b35eb00b94bda56390c9e2aac6f +Author: Ivo Timmermans +Date: Tue Apr 9 15:28:45 2002 +0000 + + Updating HEAD branch #5; Last files from CABAL. + +commit 462ab530e546f5732dfd51134751da6f6910d679 +Author: Ivo Timmermans +Date: Tue Apr 9 15:26:01 2002 +0000 + + Updating HEAD branch #4; Merging CABAL -> HEAD. + +commit e64ef59df44d39c76c00dee22841bbcce7c24e47 +Author: Ivo Timmermans +Date: Tue Apr 9 15:07:27 2002 +0000 + + Updating HEAD branch #3; more obsolete files removed. + +commit db59cbfa47aa152bcfa807754189aa18f28cb569 +Author: Ivo Timmermans +Date: Tue Apr 9 14:58:14 2002 +0000 + + Updating HEAD branch #2; removing debian/ dir. + +commit 50f2afec7e6dab3d809fc1b82820d1069205b69b +Author: Ivo Timmermans +Date: Tue Apr 9 14:54:37 2002 +0000 + + Updating HEAD branch #1; removing obsolete files. + +commit e69d2258032362c85c5936a5c137c70227e59332 +Author: Guus Sliepen +Date: Tue Apr 9 11:44:47 2002 +0000 + + Remarks about 1.0pre7 release. + +commit f2a3fcbdda250e5982c3ef36808568f996f8fff1 +Author: Guus Sliepen +Date: Tue Apr 9 11:43:45 2002 +0000 + + Updated dutch translation. + +commit b1322d244ff24e900f2298b8aa775d825c8ab00b +Author: Guus Sliepen +Date: Tue Apr 9 11:43:29 2002 +0000 + + masklength is better known as prefixlength + +commit 5df8a8cb3f4a0d2290f6677b44bbcaaf27a60bbc +Author: Guus Sliepen +Date: Tue Apr 9 11:42:48 2002 +0000 + + masklength is better known as prefixlength. + +commit 630dd023b990e076fdab890ff90783dc1ac7c13f +Author: Guus Sliepen +Date: Mon Apr 8 13:27:09 2002 +0000 + + Automake forgets about depcomp, remind it. + +commit ad6b1203490699ecc708290b2af1a45e134a5e20 +Author: Guus Sliepen +Date: Fri Apr 5 09:11:38 2002 +0000 + + Fix maskcheck() and maskcmp(). + +commit d8c249008a0b2abd44e652ed70e69b3dbc05b9d8 +Author: Guus Sliepen +Date: Mon Apr 1 21:28:39 2002 +0000 + + check_rsa() is broken, I don't know why, just remove it for now. + +commit 438419734ebee38dc3f7390e5c8ae8e6ca2cb6cf +Author: Guus Sliepen +Date: Mon Apr 1 21:28:05 2002 +0000 + + Don't check_network_activity() if select() is interrupted by a signal. + +commit 3d8a373bb3a788efffc555122b9d0569b96c5944 +Author: Guus Sliepen +Date: Wed Mar 27 19:43:50 2002 +0000 + + Make configure --help output look nicer. + +commit 9a03e7fa3d52ea062b4a3ff88b5d87ee95d24772 +Author: Guus Sliepen +Date: Wed Mar 27 16:26:26 2002 +0000 + + Update with information about the pre6 release. + +commit 33d3bad87d5f3e00e3ed81b75bca2ef21fd6e983 +Author: Guus Sliepen +Date: Wed Mar 27 16:00:49 2002 +0000 + + Update dutch translation. + +commit 0fe3dc38ed0527a5cfda9218114c8ee10422086b +Author: Guus Sliepen +Date: Wed Mar 27 16:00:38 2002 +0000 + + Fix format strings. + +commit 420f46acb0551a290b3263e39347b694286b2fa4 +Author: Guus Sliepen +Date: Wed Mar 27 15:47:06 2002 +0000 + + Remove symlink to device.c when doing a make dist. + +commit a5d8be8b1a9978d58c251d1020bb730bb1dc8ea1 +Author: Guus Sliepen +Date: Wed Mar 27 15:35:07 2002 +0000 + + Recent automake uses $(AMTAR) instead of $(TAR) + +commit c6d2f6c620beae387e8f9fc995ed7c8e8a5bc3dc +Author: Guus Sliepen +Date: Wed Mar 27 15:26:44 2002 +0000 + + Remove cruft. + +commit efd29fde85481e080a676f2ba780a528a90a9925 +Author: Guus Sliepen +Date: Wed Mar 27 15:26:29 2002 +0000 + + Small updates. + +commit 5eba1e1f6feadb3f7efb1261bd65e1e9e40b7f2b +Author: Guus Sliepen +Date: Wed Mar 27 15:01:37 2002 +0000 + + Limit the amount of packets in a queue to 8. + +commit 61cb593e670107ca3041f582c5486c243d5eda9e +Author: Guus Sliepen +Date: Wed Mar 27 15:01:16 2002 +0000 + + Extend list_t with the number of elements in the list. + +commit 0e7136027ce05bfeca977f2f64f3b228ea4fda87 +Author: Guus Sliepen +Date: Wed Mar 27 14:02:36 2002 +0000 + + Merge do_prune() with build_fdset(). Probably fixes the invalid filedescriptor error. + +commit e2238047d39eacc69da5732937021c38171ec7b9 +Author: Guus Sliepen +Date: Tue Mar 26 13:19:56 2002 +0000 + + Small correction. + +commit 7d07df71f9b82afdcf23494867bb8899198a6223 +Author: Guus Sliepen +Date: Tue Mar 26 12:00:38 2002 +0000 + + Fix execute_script(). + +commit 2de5e0eef911b9ff723d562ef9c62d833f3cdc45 +Author: Guus Sliepen +Date: Mon Mar 25 15:51:58 2002 +0000 + + Send REQ_KEY only once until ANS_KEY has arrived. + +commit a0c1696515fabd2183da7d8d83fd68410d2ec834 +Author: Guus Sliepen +Date: Mon Mar 25 15:12:09 2002 +0000 + + Tell a little bit more about security. + +commit 89a2f761a6d8ae4912c2dd2e9178589001487ef5 +Author: Guus Sliepen +Date: Mon Mar 25 15:01:32 2002 +0000 + + Updated documentation. + +commit 33d8747021d57c5827c6a755739756f95c7527c8 +Author: Guus Sliepen +Date: Mon Mar 25 13:54:49 2002 +0000 + + Set myself->status.reachable. + +commit 2749b997df33749f13d05e294db0e1e327e81d12 +Author: Guus Sliepen +Date: Sun Mar 24 17:14:01 2002 +0000 + + Configuration variables were still handled case sensitively. + +commit c73bdd6bc8e213b7e27848b97307228c01570a1d +Author: Guus Sliepen +Date: Sun Mar 24 17:08:38 2002 +0000 + + OpenBSD tun device uses address family number instead of Ethernet type. + +commit 8379c14b7f7a9b1400dd3776fc21dc9ccddd991d +Author: Guus Sliepen +Date: Sun Mar 24 16:50:58 2002 +0000 + + Respect type field. + +commit ad4f5cbc5fbce23893b7d42669ba907f18cc8ff4 +Author: Guus Sliepen +Date: Sun Mar 24 16:40:14 2002 +0000 + + Updated dutch translation. + +commit 4252ae83a43ea81382ce71ba614e2d1655f2e189 +Author: Guus Sliepen +Date: Sun Mar 24 16:36:56 2002 +0000 + + Set $INTERFACE correctly when using ethertap while compiled with tun/tap support. + +commit d699f3079c658e05f928c358d110d1d27849ea71 +Author: Guus Sliepen +Date: Sun Mar 24 16:28:27 2002 +0000 + + Execute hosts/name-up when a node becomes reachable, and hosts/name-down + when it becomes unreachable. + +commit 6ad5dd1a9adb1c1322ceb44d6f0fd160229e72ff +Author: Guus Sliepen +Date: Sun Mar 24 16:22:59 2002 +0000 + + Don't try to execute scripts unless they exist. + +commit 594d5b5d15551bd802c43926c7cb8863b7531654 +Author: Guus Sliepen +Date: Sat Mar 23 20:21:10 2002 +0000 + + Reset retry timeout when receiving the first PONG, not right after receiving the ACK. + +commit cbd8133ab4a2ea8a0c46224a5f1ae79e92819e5f +Author: Guus Sliepen +Date: Sat Mar 23 20:13:56 2002 +0000 + + Don't run graph algorithms if no edge is deleted in terminate_connection(). + +commit 6aee1ad021092d37538e15da22367789a4d4a763 +Author: Guus Sliepen +Date: Sat Mar 23 20:12:29 2002 +0000 + + free() request strings when deleting past requests from the tree. + +commit ccea26e0044ea59a9722385c9d69b1bc703e884f +Author: Guus Sliepen +Date: Sat Mar 23 20:01:05 2002 +0000 + + send_ack() was broken. + +commit 3c5655f59e85d312d11fa04489123e604920f95b +Author: Guus Sliepen +Date: Fri Mar 22 13:31:18 2002 +0000 + + Fix compiler warnings, strictly use long int and %lx for options. + +commit d6b70ed6f8b7ed65f64193fcfcdb6c8f4625e03c +Author: Guus Sliepen +Date: Fri Mar 22 12:41:54 2002 +0000 + + Fix add_edge_h(). + +commit 52e7699273a3009fe4d91e608522401076922785 +Author: Guus Sliepen +Date: Fri Mar 22 11:43:48 2002 +0000 + + - Added support for jumbograms. + - Remove tcpaddress from edges, it is not used at all. + - Last bits of code to prevent looping requests. + +commit 9da5390666ad532825d820b3554da3f39d3bc511 +Author: Guus Sliepen +Date: Thu Mar 21 23:11:53 2002 +0000 + + Put a break on requests that run around in circles. + +commit f48f8f4fedba365ceea30e1133bf1c560e9a522a +Author: Guus Sliepen +Date: Tue Mar 19 22:48:25 2002 +0000 + + Updated SSSP algorithm to automatically detect indirect links (if a node uses + different addresses for connections to other nodes). + +commit 5a88a27742d305be48498a297b90ee3fbdd935bf +Author: Guus Sliepen +Date: Tue Mar 19 00:08:34 2002 +0000 + + Updated dutch translation. + +commit 5c2d74de86d1acb3774a20357ad815d000f8a7f6 +Author: Guus Sliepen +Date: Tue Mar 19 00:08:23 2002 +0000 + + Don't use s6_addr[16|32] anymore. + +commit 9d99a789c38e8a1694537e427e8d4313c948b02b +Author: Guus Sliepen +Date: Tue Mar 19 00:07:09 2002 +0000 + + Cleanup. + +commit 305505f5ec4bb738f175cd897fa409f08d2971a3 +Author: Guus Sliepen +Date: Mon Mar 18 22:47:20 2002 +0000 + + Remember sockaddrs of listening sockets, use appropriate one when sending + UDP packets. + +commit 106fc2b769a635142bf5f9233a2f03e3a0f26b7f +Author: Guus Sliepen +Date: Mon Mar 18 14:39:37 2002 +0000 + + Fix #define s6_addr32. + +commit 813c369a8faca94fc38bc66afafad063fa00f928 +Author: Guus Sliepen +Date: Mon Mar 18 14:19:02 2002 +0000 + + #define s6_addr32, needed for FreeBSD. + +commit b2579385de427c3c03d28520d3a93bd5f9bc9488 +Author: Guus Sliepen +Date: Sun Mar 17 16:08:39 2002 +0000 + + Only unmap IPv6 addresses. + +commit 8b84c44175fedb81ca38107e0067ddea750add00 +Author: Guus Sliepen +Date: Sun Mar 17 15:59:29 2002 +0000 + + Unmap v4mapped sockaddrs. + +commit 07e37f8da03fa315be39623e62d8acba617aa226 +Author: Guus Sliepen +Date: Fri Mar 15 15:50:14 2002 +0000 + + Typo. + +commit e0dee537705cdbd005f6ab1fbef5ac71dc8411c0 +Author: Guus Sliepen +Date: Fri Mar 15 15:40:40 2002 +0000 + + Different way of detecting neighbor solicitation requests. + +commit 0e93f0aa02274481c16fc9f30b795d4f063bd1c3 +Author: Guus Sliepen +Date: Fri Mar 15 15:08:21 2002 +0000 + + Oops, don't forget to actually put the checksum in the response packet. + +commit e1de9ca990ea638c7e297c5335be415e44c250c1 +Author: Guus Sliepen +Date: Fri Mar 15 14:41:57 2002 +0000 + + Neighbor solicitation requests now work (I think). + +commit 4b3aef9e6992ca78f1b17b179a3051d3fec0473d +Author: Guus Sliepen +Date: Tue Mar 12 16:30:15 2002 +0000 + + Revert changes to Kruskal's algo. + +commit f219f156cf13fd30369d7cd4632c406ffd6ff628 +Author: Guus Sliepen +Date: Tue Mar 12 14:25:04 2002 +0000 + + Put #ifdef NEIGHBORSOL around corresponding code. + +commit ecad9e9289162faec7b678be54178d22876b5d90 +Author: Guus Sliepen +Date: Tue Mar 12 14:20:44 2002 +0000 + + Remove silly cache thingy. + +commit d6c2c4f2b7a94ef6a4db0de134d015bc8d21ffb1 +Author: Guus Sliepen +Date: Tue Mar 12 14:19:51 2002 +0000 + + Packet sequence number/authentication warnings only if debug_lvl >= 5. + +commit 2e7db2a6936a77baa0a81eb566674bd76d204951 +Author: Guus Sliepen +Date: Tue Mar 12 13:42:23 2002 +0000 + + Simplified implementation of Kruskal's minimum spanning tree algorithm. + +commit d2e0ed533c8aa3c6ab538d87e004108c631cb0be +Author: Guus Sliepen +Date: Mon Mar 11 13:56:00 2002 +0000 + + New strategy: forward icmp6 neighbor solicitations to intended target. + +commit 46fa10cec7b6bf26773f5e86e7b8118d9075e807 +Author: Guus Sliepen +Date: Mon Mar 11 13:14:53 2002 +0000 + + Try to reply to neighbor solicitation requests. + +commit c2713ba7a5ff12e270d66a5d3188a3640873830e +Author: Guus Sliepen +Date: Mon Mar 11 11:45:12 2002 +0000 + + prune_connections() before build_fdset(). + +commit 4fda4560bbdd41e217ce0e1a90ba98c79e4f3519 +Author: Guus Sliepen +Date: Mon Mar 11 11:23:04 2002 +0000 + + Cleanups, spelling fixes, allow symbol names for signals (-k option), + don't remove pidfile if other tincd is still running. + +commit 5ffeb13d65313d5a191a605690a4f8fdf1604b48 +Author: Guus Sliepen +Date: Sun Mar 10 16:09:15 2002 +0000 + + Don't retry to make outgoing connections when exitting. + +commit 3cbe67a8de1da7bd042474de4d16cb4f7e9822ab +Author: Guus Sliepen +Date: Sun Mar 10 15:40:27 2002 +0000 + + Small fixes to improve portability. + +commit 9de7470bfdabacec5f3769bf5cfa97ef4e481ba0 +Author: Guus Sliepen +Date: Sun Mar 10 14:07:08 2002 +0000 + + Autodetect $MAKE/gmake/make. + +commit 0c34478cc03167208c84f3d6d2ed6e53172b4711 +Author: Guus Sliepen +Date: Sun Mar 10 14:05:35 2002 +0000 + + po/POTFILES and po/Makefile should not be generated by configure. + +commit 024ab44d98883d78cefe2c622cec9831c7f19c13 +Author: Guus Sliepen +Date: Sun Mar 10 14:04:48 2002 +0000 + + Fix forwarding of IPv6 packets. + +commit 0c16add71c6432c882c6d8f538a4b2db0026ec24 +Author: Guus Sliepen +Date: Fri Mar 1 15:14:29 2002 +0000 + + Check if BindToDevice and PriorityInheritance are supported. + +commit 7d5741859e681e6b0d0e32b978da6f309c456729 +Author: Guus Sliepen +Date: Fri Mar 1 14:33:48 2002 +0000 + + Woops. + +commit ab90fa9bd1a653a330be7ef11293000721a0e7b4 +Author: Guus Sliepen +Date: Fri Mar 1 14:25:10 2002 +0000 + + Document and clean up MAC address expiry. + +commit 14979f835df4214a7c2510852f7ffedc9e08c2c0 +Author: Guus Sliepen +Date: Fri Mar 1 14:09:31 2002 +0000 + + - Global time_t now, so that we don't have to call time() too often. + - MAC addresses expire after a time configurable by MACExpire (default 600 + seconds) + +commit 7496ecc45ab6205bcce4e576c23b9afb52004e39 +Author: Guus Sliepen +Date: Fri Mar 1 13:38:15 2002 +0000 + + Updated dutch translation. + +commit 0c879b8eeed3477b0f1cdd2f232e67e38bd9bce6 +Author: Guus Sliepen +Date: Fri Mar 1 13:38:02 2002 +0000 + + Updated documentation. + +commit f93b1334e087dd7af1b87f475b2d398fdd4d56ab +Author: Guus Sliepen +Date: Fri Mar 1 13:18:54 2002 +0000 + + Create/bind TCP and UDP listening sockets in pairs. + +commit c2b738e7b51fbec2b11fbbf030b9a5a36df55fc4 +Author: Guus Sliepen +Date: Fri Mar 1 12:26:56 2002 +0000 + + If "PriorityInheritance = yes" is specified in tinc.conf, the value of the + TOS field of the tunneled packets will be passed on to the UDP packets tinc + sends out. + +commit 80ea653e8d8050878380fbc1446571cbaf578297 +Author: Guus Sliepen +Date: Fri Mar 1 12:25:58 2002 +0000 + + Fix listening sockets. + +commit 7f58ed7685f9fcd5271359a8c896670a835e1f95 +Author: Guus Sliepen +Date: Fri Mar 1 11:18:34 2002 +0000 + + Make BindToInterface work. + +commit 17bc5220c332fdd083fd47fc600010f85171adc7 +Author: Guus Sliepen +Date: Wed Feb 27 22:37:55 2002 +0000 + + Fix send_request() bug. + +commit 50403909b6bf6536924d4693bb1f32c248f17fda +Author: Guus Sliepen +Date: Tue Feb 26 23:26:41 2002 +0000 + + Allow multiple listening sockets. + +commit 2ac7be0d51a112108dc6c2b1c6f46da022f72f40 +Author: Guus Sliepen +Date: Tue Feb 26 22:47:51 2002 +0000 + + Tweaking IPv6 support. + +commit 23fda5688e8a109f8a50511538b14e4fbe4f738c +Author: Guus Sliepen +Date: Wed Feb 20 22:37:38 2002 +0000 + + - Change SA_LEN to SALEN, former one is already defined on some platforms. + - Use SALEN everywhere appropriate. + +commit dbc5b5bb5eb3096ad930aa6b590deaba2a103dfc +Author: Guus Sliepen +Date: Wed Feb 20 22:15:32 2002 +0000 + + - Use gai_strerror() where appropriate + - Clear hints before using them with getaddrinfo() + - Use sa_len on platforms that support them + +commit 28cc9a6488f78c72152251f6fa2ee84d417223e8 +Author: Guus Sliepen +Date: Wed Feb 20 19:31:15 2002 +0000 + + Preserve inpkt->len, needed for broadcasts. + +commit c6d01588312bec7691e72b42cf20c59ffe2749c2 +Author: Guus Sliepen +Date: Wed Feb 20 19:25:09 2002 +0000 + + Protocol now also exchanges cipher/digest/maclength/compression for the + meta connection. + +commit 626d5956d2bb0660ba315fba77da6cec9776fd3b +Author: Guus Sliepen +Date: Wed Feb 20 17:16:15 2002 +0000 + + Cache results of lookup_subnet_...(). + +commit e8e69460a7090aaf6ecda8970d3060695de81b00 +Author: Guus Sliepen +Date: Wed Feb 20 17:15:33 2002 +0000 + + Fix maskcmp() and maskcpy(). + +commit ed509312906625acee4007da6262de3898846888 +Author: Guus Sliepen +Date: Wed Feb 20 16:04:59 2002 +0000 + + Forward packets in router mode. + +commit 8c91fac31570594b6249d632cefe768f33c54b19 +Author: Guus Sliepen +Date: Wed Feb 20 16:04:39 2002 +0000 + + Use AF_UNSPEC for listening sockets if AddressFamily = any. + +commit 76f01453dfa157b0070751b1025e55a1e36ebdca +Author: Guus Sliepen +Date: Wed Feb 20 16:04:07 2002 +0000 + + Fix segfault when receiving HUP signal. + +commit c2b9c06062d36bde859b630b99a08c7b7428e721 +Author: Guus Sliepen +Date: Mon Feb 18 16:25:19 2002 +0000 + + - Non-blocking connect()s. + - Socket handling revamped to use sockaddr_t. + - tinc can now tunnel over IPv6. + - Handle all addresses and subnets in network byte order. + Only convert them when they need to be printed. + - IPv6 subnets bigger than /128 now work. + - Use %s and strerror(errno) instead of %m. + +commit fc674eaae14ed2e07abc0df1285b1bd70e0d27cc +Author: Guus Sliepen +Date: Tue Feb 12 14:42:37 2002 +0000 + + Add check for NetBSD. + +commit 2fb8a62edef7cb0988e44f92c3948cde6f34875e +Author: Guus Sliepen +Date: Tue Feb 12 14:40:12 2002 +0000 + + Added device.c for NetBSD, actually a copy of the OpenBSD one. + +commit f64b41a73b3b432aae17ba990414e0be2f61ce62 +Author: Guus Sliepen +Date: Tue Feb 12 14:36:45 2002 +0000 + + Get rid of sys/signal.h. + +commit dd611fb4f91b9b17c20c458694d2765b22814c5f +Author: Guus Sliepen +Date: Tue Feb 12 14:29:00 2002 +0000 + + Don't use sa_sigaction (which NetBSD doesn't like) at all if we don't use siginfo. + +commit d9a62c6354d1e2ad78ee8c610518ae9f9ab012d1 +Author: Guus Sliepen +Date: Mon Feb 11 15:59:18 2002 +0000 + + Added support for packet compression, thanks to Mark Glines. + Add "Compression = " to the host config files, where level can be + 0 (off), or any integer between 1 (fast) and 9 (best). + +commit 94b171b3051b999e619ae19e1c9c29d356606788 +Author: Guus Sliepen +Date: Mon Feb 11 14:20:46 2002 +0000 + + Small fix. + +commit 1708997bc8ab55122f9de9cc8b81397d3a003ea9 +Author: Guus Sliepen +Date: Mon Feb 11 14:20:21 2002 +0000 + + - If no PrivateKeyFile is specified, /etc/tinc/netname/rsa_key.priv is assumed. + - Check RSA key before using it. + +commit 1c34ba7fb8580949f3bd3a0d804747bbaea28e36 +Author: Guus Sliepen +Date: Mon Feb 11 12:33:01 2002 +0000 + + Sensible defaults for $INTERFACE. + +commit 24cc2a9065a4e962fb05addac47322930099a4b5 +Author: Guus Sliepen +Date: Mon Feb 11 10:16:18 2002 +0000 + + Last bits of the merger. + +commit 5bf4b88666ecafe190e8ed71d6c14c9de8d16e1f +Author: Guus Sliepen +Date: Mon Feb 11 10:05:58 2002 +0000 + + Forgot to merge new files from pre5. + +commit f0aa9641e82fb6e09c1e485366d14dddaa7f7c36 +Author: Guus Sliepen +Date: Sun Feb 10 21:57:54 2002 +0000 + + Merging of the entire pre5 branch. + +commit c2752b961c9262386b940c2c053b9909bee22859 +Author: Ivo Timmermans +Date: Fri Nov 16 22:41:38 2001 +0000 + + Conversion to struct addrinfo is almost complete for this file. + +commit 4f47da5b87ef7da608c7e44026122f3d95deb2eb +Author: Ivo Timmermans +Date: Fri Nov 16 22:40:26 2001 +0000 + + Don't include netutl.h. + +commit a59bbc72317c9cd97243a9cbf49db01ff249eb1e +Author: Ivo Timmermans +Date: Fri Nov 16 22:31:41 2001 +0000 + + Fixed silly typo: "np" instead of "no" + +commit bf664c054fdabc30679367a752a27bb769655e4d +Author: Ivo Timmermans +Date: Fri Nov 16 22:31:15 2001 +0000 + + get_config_subnet needs to be fixed. + +commit 9b2b3747340173590b8f6f5fbdd060b42985f026 +Author: Ivo Timmermans +Date: Fri Nov 16 17:40:50 2001 +0000 + + route_ipv4 and route_ipv6 replaced by route_ip. + +commit a4938b22e7502579ce44cac42410111db11256eb +Author: Ivo Timmermans +Date: Fri Nov 16 17:39:59 2001 +0000 + + Don't include netutl.h. + +commit ccda709f8243949a3c0ffcc6133d8d8fc5125f2e +Author: Ivo Timmermans +Date: Fri Nov 16 17:39:38 2001 +0000 + + lookup_node_udp changed. + +commit 836766d4c5bc47682ab69c57337157c879517670 +Author: Ivo Timmermans +Date: Fri Nov 16 17:38:39 2001 +0000 + + First part of rewriting things to use struct addrinfo. + +commit 2ec5b5f8621d9fb91181ab155084daa1bb2d1a54 +Author: Ivo Timmermans +Date: Fri Nov 16 17:37:08 2001 +0000 + + Added dropin replacements for get*info and helper functions. + +commit aabe59f6305cdd46220e95d8927a1636d4b4819d +Author: Ivo Timmermans +Date: Fri Nov 16 16:16:33 2001 +0000 + + Added HAVE_STRUCT_ADDRINFO + +commit 251f87c842b62cf770129d8a953fb06ef5d0e466 +Author: Ivo Timmermans +Date: Fri Nov 16 15:56:44 2001 +0000 + + (re)added port to struct node_t + +commit 6cf744e4b29cfe3b135b6553851816802ba3d8a8 +Author: Ivo Timmermans +Date: Fri Nov 16 12:22:02 2001 +0000 + + Don't include netutl.h. + +commit a79252af4383b8cd71cf0d13f1ae040d518517bf +Author: Ivo Timmermans +Date: Fri Nov 16 12:21:22 2001 +0000 + + Obsoleted. + +commit 331d9402e892b4baa9cadbbb364073ae10b58d99 +Author: Ivo Timmermans +Date: Fri Nov 16 12:16:28 2001 +0000 + + Don't compile/link netutl.c. + +commit f95e6ca8f6976d7a15f4623e25c85e1c7f82c04b +Author: Ivo Timmermans +Date: Fri Nov 16 12:14:20 2001 +0000 + + get_config_{ip,port} removed. + +commit 31db57bb4a00f5ca3743b89f8bb2fbd39919bf28 +Author: Ivo Timmermans +Date: Fri Nov 16 12:13:34 2001 +0000 + + Changed to use struct addrinfo where needed. + +commit f1b20b3ded5b360e426e094cf79df3bf97f350b4 +Author: Ivo Timmermans +Date: Fri Nov 16 12:10:54 2001 +0000 + + Obsoleted all IP types in favor of struct addrinfo + +commit fb6dc0b0890ebae2471e00e7a3e1d86c1fc3d646 +Author: Ivo Timmermans +Date: Fri Nov 16 12:08:38 2001 +0000 + + Removed definitions of ipv4_t, ipv6_t, port_t + +commit 3ef15f2554d1819d6c7d2573dac6039f2e76b638 +Author: Ivo Timmermans +Date: Fri Nov 16 12:02:17 2001 +0000 + + Changed lookup_connection to use struct addrinfo + +commit 74e1299fb58025f7506c7e2608c353a76f98d8df +Author: Ivo Timmermans +Date: Fri Nov 16 12:01:48 2001 +0000 + + Changed prototype for lookup_connection to use struct addrinfo + +commit 51b72b75f254c956b62be9dfca642145b199415f +Author: Ivo Timmermans +Date: Fri Nov 16 00:23:28 2001 +0000 + + Use struct addrinfo in connection_t to hold all host data such as IP + address and port + +commit 72395f989cb44132d7c756c91b3a6d8ba63517e5 +Author: Ivo Timmermans +Date: Fri Nov 16 00:13:08 2001 +0000 + + Deprecated get_config_ip and get_config_port + +commit 93cd0e33defba46f8e51d9a98a94599ceb0d521c +Author: Ivo Timmermans +Date: Thu Nov 15 23:49:46 2001 +0000 + + Check for struct addrinfo + +commit b16bf68a6dc27b364cb76156a7be0208594f1e94 +Author: Ivo Timmermans +Date: Thu Nov 15 23:28:58 2001 +0000 + + Credit OpenSSH + +commit 18269cfbe831902b97a6171ba0346fd323583e48 +Author: Ivo Timmermans +Date: Thu Nov 15 23:26:27 2001 +0000 + + Check for getnameinfo, gai_strerror, freeaddrinfo + +commit ae11e7c3d71893c5200b12682839538a52df37b8 +Author: Ivo Timmermans +Date: Thu Nov 15 23:05:34 2001 +0000 + + Check for getaddrinfo + +commit e06415e3d9d08cd33c5983a2c49c4101377160c2 +Author: Guus Sliepen +Date: Mon Nov 5 19:09:08 2001 +0000 + + More fixes for Solaris. + +commit 25a804c94ef0dbc4e5582ea6d8459d5f9a3fe06c +Author: Guus Sliepen +Date: Mon Nov 5 19:06:07 2001 +0000 + + Various fixes needed for Solaris. + +commit b2d5002ff1ccd44fbf3a94e4c41909ab6141f3bb +Author: Guus Sliepen +Date: Sun Nov 4 23:48:27 2001 +0000 + + Correctly check if subnet owner exists. + +commit ede6671c1354eeab86936efda32f6cdb3b3fd8d5 +Author: Guus Sliepen +Date: Sun Nov 4 23:29:50 2001 +0000 + + Be liberal in what you accept: allow unknown edges to be deleted. + +commit cf0e133e191cb40954bf5b6ee0a579442fe4b60b +Author: Guus Sliepen +Date: Sat Nov 3 22:53:02 2001 +0000 + + *** empty log message *** + +commit e5047d2835f0828a9c334cc3d928c2322abfefb7 +Author: Guus Sliepen +Date: Sat Nov 3 21:22:02 2001 +0000 + + Several bugfixes. + +commit 8910cbd67e13450e93816ecafa0cc5be5e4c2378 +Author: Guus Sliepen +Date: Sat Nov 3 21:21:04 2001 +0000 + + Use PEM functions as suggested by OpenSSL docs. + +commit 8e74c5bee48f2ef363193044d5309a65e91c70d8 +Author: Guus Sliepen +Date: Wed Oct 31 20:37:54 2001 +0000 + + Some very small fixes + +commit ffb88ff6410f33de92db108bd1e0c3a915368214 +Author: Guus Sliepen +Date: Wed Oct 31 20:22:52 2001 +0000 + + Avoid connecting to another node twice, and check name of outgoing connections. + +commit 6d333ad680465c26953ad4c8ca9140e27da868c5 +Author: Guus Sliepen +Date: Wed Oct 31 20:07:17 2001 +0000 + + Show cfg->variable instead of cfg->value when complaining about wrong type. + +commit 54b756f7dfb71c5622b7738fd449e126da959864 +Author: Guus Sliepen +Date: Wed Oct 31 20:02:06 2001 +0000 + + Don't forget to read public RSA key when making an outgoing connection. + +commit c0a3f67a5d66088aaf526f1461986f9e86d5dd1f +Author: Guus Sliepen +Date: Wed Oct 31 12:50:24 2001 +0000 + + - Small fixes to graph algorithms + - More control over tap device, ability to set interface name to something + other than the netname. + - Export NETNAME, DEVICE and INTERFACE environment variables to scripts. + +commit 2165931c62f0433fd97bd3ac6aefea3627218946 +Author: Guus Sliepen +Date: Tue Oct 30 16:34:32 2001 +0000 + + More updates to protocol handlers and reimplemented terminate_connection(). + +commit 87ad5c97a9a73a65050ad7adce34503f856d8665 +Author: Guus Sliepen +Date: Tue Oct 30 12:59:12 2001 +0000 + + Various fixes, tinc is now somewhat capable of actually working again. + +commit cc9473d8c6467e9eaa82fe8a639d8edba232ee76 +Author: Guus Sliepen +Date: Mon Oct 29 13:14:57 2001 +0000 + + Working version of Kruskal's algorithm. The running time is very bad though. + +commit b6298e2c082035b8238ea08673ced15d0fb7b89a +Author: Guus Sliepen +Date: Sun Oct 28 22:42:49 2001 +0000 + + - More changes needed for Kruskal's algorithm + - Implemented a breadth-first search algorithm as a cheap substitution for a + single-source shortest path algorithm. + +commit 66067cc9c1347fb2de35660d531fdd4be8aede6a +Author: Guus Sliepen +Date: Sun Oct 28 10:16:18 2001 +0000 + + - More s/vertex/edge/g + - Implementation of Kruskal's minimum spanning tree algorithm. + +commit 94497336efc1cc60561575e74d420e9e8e8c657e +Author: Guus Sliepen +Date: Sun Oct 28 08:41:19 2001 +0000 + + What was I thinking? s/vertex/edge/g. + +commit b98d9787fdde54f33dcdb376e1e018cd418aff8d +Author: Guus Sliepen +Date: Sat Oct 27 15:19:13 2001 +0000 + + Various small fixes to make tinc runnable again. + +commit ac066bb057dcb187bf91670793ba5e6ca456e052 +Author: Guus Sliepen +Date: Sat Oct 27 13:13:35 2001 +0000 + + Make sure everything links. + +commit 82e383710980534d38bb9a8ef22f20677cd85861 +Author: Guus Sliepen +Date: Sat Oct 27 12:13:17 2001 +0000 + + Big bad commit: + - Transition to new node/vertex/connection structures + - Use new configuration handling everywhere + - Linux tun/tap device handling cleanup + - Start of IPv6 support in route.c + + It compiles, but it won't link. + +commit 1935c44a1e8ab7c31c836f90215e3c5b5f8dd776 +Author: Guus Sliepen +Date: Sat Oct 13 13:53:07 2001 +0000 + + Support new files (node/vertex/device.[ch]) and OpenBSD. + +commit 26e517dd37e995fe9db518f7ebeff023fc73ff1b +Author: Guus Sliepen +Date: Fri Oct 12 15:52:03 2001 +0000 + + Forgot the tun specific stuff. + +commit ad61c20f42d2bee5cc7976bec4370cf4747b42c3 +Author: Guus Sliepen +Date: Fri Oct 12 15:49:11 2001 +0000 + + Added OpenBSD tun device handling. Untested though. + +commit 0c6321a67f92981d3adbaf4f5c2b9867c7968964 +Author: Guus Sliepen +Date: Fri Oct 12 15:38:35 2001 +0000 + + Forgot to remove some old #ifdef stuff. + +commit 6014c7e6374089bfccea7467c2c7f4b23fefa265 +Author: Guus Sliepen +Date: Fri Oct 12 15:33:21 2001 +0000 + + Solaris tun device handling cleaned up a bit and added. + +commit 623c7ee0308aede8eada552d6ae33710ae24d176 +Author: Guus Sliepen +Date: Fri Oct 12 15:22:59 2001 +0000 + + Added FreeBSD tap device handling. + +commit ec34f25228d7a0007ce6bcb1e97f263868e9129d +Author: Guus Sliepen +Date: Fri Oct 12 15:16:03 2001 +0000 + + - Split tap device stuff out of net.[ch] + - Each OS gets it's own device.c to get rid of evil #ifdefs. + - Cleaned up Linux ethertap and tun/tap handling. + +commit 0bbace18e96cd6fc32dfa23ffd55f73ff96e8c6f +Author: Guus Sliepen +Date: Wed Oct 10 20:35:10 2001 +0000 + + More updates to new node/vertex/connection combo. + +commit ea607d2d9292d3969f9d164b432dc64a33c2dade +Author: Guus Sliepen +Date: Wed Oct 10 20:34:27 2001 +0000 + + Revamp configuration handling: + - Store everything in AVL trees (fast lookup) + - No need for hazahaza anymore + - Parse values when needed + - This simplifies a lot of config variable lookups. + +commit 5904806dc80830d4eddca857a41db2fc25598201 +Author: Guus Sliepen +Date: Wed Oct 10 09:42:29 2001 +0000 + + Removed everything from connection.c that has already been moved to node.c and + vertex.c. + +commit ec0c16b9b63f361b11a757ee1641d562e4811f93 +Author: Guus Sliepen +Date: Wed Oct 10 08:49:47 2001 +0000 + + Further implementation of doc/CONNECTIVITY. connection.[ch] is now split into a + node, vertex and connection part. + +commit 75e1ae3a287642ca4281792c94ecd07332f39c08 +Author: Wessel Dankers +Date: Tue Oct 9 19:41:56 2001 +0000 + + make is not always GNU make. + +commit f22b9417510cca258785f8958c8dfed90e26d81b +Author: Guus Sliepen +Date: Tue Oct 9 19:37:10 2001 +0000 + + Small corrections. + +commit 49a2cd806c73cff1ab6a712a996c7f7d4e1f32c0 +Author: Guus Sliepen +Date: Tue Oct 9 19:30:30 2001 +0000 + + Started implementing doc/CONNECTIVITY. + +commit 5926c82b9a29031a8c619432869d1549b51b62a0 +Author: Guus Sliepen +Date: Mon Oct 8 15:47:30 2001 +0000 + + Updated dutch translation. + +commit fcc3ded75fe9f831aeb8678ee5e3926bf4168906 +Author: Guus Sliepen +Date: Mon Oct 8 15:37:14 2001 +0000 + + Fix bug when dropping an old connection in favour of a new one from the + same host. + +commit 1ef90a87fd9fd53c25a43455ffaac5274a63dc08 +Author: Guus Sliepen +Date: Mon Oct 8 13:37:30 2001 +0000 + + - Use ping timeout mechanism to close connections that don't authenticate + in time. + - Fix potential segmentation fault in check_dead_connections(). + +commit ce9fd32c04adf83cbaf668ee42a29575ba256002 +Author: Guus Sliepen +Date: Mon Oct 8 11:59:08 2001 +0000 + + Fix bug where tinc would crash because of a portscan or a connection from a + tinc daemon with a different version. + +commit 21027b1d5702c331b1ebb262bb149c75be1f24b1 +Author: Guus Sliepen +Date: Mon Oct 8 11:47:55 2001 +0000 + + - Renamed lastbutonehop to prevhop. + - Added connection_t *via to connection_t, this keeps record of where + to send UDP packets to. + +commit 18d1233c40a5705e9123edd6f4c6764a5178003b +Author: Guus Sliepen +Date: Tue Sep 25 13:39:11 2001 +0000 + + Fill in next- and lastbutonehop for myself. + +commit ec100a58b44e412a3d2606e5213af9ec5f30235b +Author: Guus Sliepen +Date: Tue Sep 25 13:35:45 2001 +0000 + + Try next connectto instead of the same over and over. + +commit 4d3de3b6a9b55bc783c649ff33e5415b0c7b5f25 +Author: Guus Sliepen +Date: Mon Sep 24 14:16:29 2001 +0000 + + Show next- and lastbutonehop when dumping connectionlist to syslog. + +commit 24a2c7e51a0b080c4bdb55f697b3f0458ebc3fb1 +Author: Guus Sliepen +Date: Mon Sep 24 14:12:00 2001 +0000 + + Not only keep track of nexthop, but also of lastbutonehop. If destination cl + wants indirectdata, send it to the lastbutonehop instead, unless it too has + requested so, and so on. + +commit 154733927af0b27cdadb83f03b845301ce8bfbfd +Author: Guus Sliepen +Date: Mon Sep 24 13:31:15 2001 +0000 + + - Try old TUN/TAP ioctl() request if the one from if_tun.h fails. + - Be more verbose about the kind of tap device used. + +commit 950c934e0bda28e5952d699d6008ee783d81982b +Author: Ivo Timmermans +Date: Wed Sep 5 18:38:09 2001 +0000 + + Killing tincd with SIGINT causes it to toggle between the current + debug level and level 5. Useful to debug a running tincd. + +commit a54ec980e047d13ecff7f1f337aa2665072febfd +Author: Guus Sliepen +Date: Sat Sep 1 12:46:49 2001 +0000 + + config_t* is a const parameter in get_config_val(). + +commit 68e23b1c9e69b2a218b3be821ad1ba3b3b6a64f2 +Author: Guus Sliepen +Date: Sat Sep 1 12:36:53 2001 +0000 + + Optional signal number for -k option. + +commit 8ed27d40f358581d021319cc26313c9f6ddf9a71 +Author: Guus Sliepen +Date: Sat Sep 1 12:36:06 2001 +0000 + + Revised reconnection mechanism, always try out all ConnectTo lines. + +commit ef1facc60709e9474197aa3fde9d517dfd96dc87 +Author: Guus Sliepen +Date: Sat Sep 1 12:02:39 2001 +0000 + + Remove IndirectData support for now, new implementation will be added + later. + +commit 8b5e4211304aaa5d39bc95f04398bd5ecaa887d8 +Author: Guus Sliepen +Date: Tue Aug 28 20:52:39 2001 +0000 + + Fix signed comparison bug in lookup_subnet_ipv4(). + +commit e1184ad15d6b2e7d58bdcb4489026dd0a35b4e5f +Author: Guus Sliepen +Date: Fri Aug 17 18:14:04 2001 +0000 + + Don't send DEL_HOSTs when !status.meta + +commit 30d22474ccc8da9a5685a90e0b2304ec627475af +Author: Guus Sliepen +Date: Tue Jul 24 20:14:30 2001 +0000 + + Explicitly log which type of tunnel device is used. + +commit 7e86cf91e3399905e19882bcf2d5677d7986aca5 +Author: Guus Sliepen +Date: Tue Jul 24 20:13:42 2001 +0000 + + The val variable in a config_t is never used as a long. + +commit 43923d2b106bfbe9300cc8e364cf098444cd649e +Author: Guus Sliepen +Date: Tue Jul 24 20:04:22 2001 +0000 + + Write public key to rsa_key.pub instead of rsa_key.priv (if not host + configuration file is found). + +commit 44e9d6a2872fac55f7eb701ba576ed9f39a22e08 +Author: Guus Sliepen +Date: Tue Jul 24 20:03:40 2001 +0000 + + Don't use %m in fprintf(). + +commit cbd03caece25d45015a4526b94b04a34ab87b0f2 +Author: Guus Sliepen +Date: Tue Jul 24 08:51:36 2001 +0000 + + More on edges. + +commit 3cd238f4e338f257ff61d58a9979b54344ee462f +Author: Guus Sliepen +Date: Mon Jul 23 22:06:22 2001 +0000 + + Discuss how sending ADD_EDGEs would be better than sending ADD_HOSTs. + +commit 5333cada0dfc4dfc3be728e6c78d8d42dc2ace52 +Author: Guus Sliepen +Date: Sun Jul 22 17:41:52 2001 +0000 + + Written down a possible solution. + +commit 995ab86fce506e9fabcf5a9ead7d43b30f12ab09 +Author: Guus Sliepen +Date: Sun Jul 22 15:25:13 2001 +0000 + + Correctie. + +commit d7b4de0e73baf664964f6daaf63526606b6a890b +Author: Guus Sliepen +Date: Sun Jul 22 14:58:18 2001 +0000 + + Small update. + +commit 71b9041f484128219f81cbf4f22a4e11388f879d +Author: Guus Sliepen +Date: Sun Jul 22 14:46:11 2001 +0000 + + Described problem in more detail. + +commit c1a98cd37ea20f6020487b2a5586e6de432398e7 +Author: Guus Sliepen +Date: Sun Jul 22 14:04:38 2001 +0000 + + Started writing a document about how daemons connect to each other. + +commit fcbe215d64d7e2f3b159fff6422d750417877ac4 +Author: Guus Sliepen +Date: Sat Jul 21 20:21:25 2001 +0000 + + Woohoo! tinc now compiles, runs and actually *works* on Solaris! + Tested on a SparcStation 20MP running Solaris 7. (Thanks, jiggel!) + +commit 533ee1206fb6433a1f0e616db999b3655addfaf2 +Author: Guus Sliepen +Date: Sat Jul 21 15:46:34 2001 +0000 + + Always close all sockets in terminate_connection(). + +commit acb853205d6d582d919c59879393b301ad4f4fde +Author: Guus Sliepen +Date: Sat Jul 21 15:34:18 2001 +0000 + + Updated terminate_connection() so you can choose if DEL_HOSTs should be + sent or not. + +commit 12f6b80429bc05a828051d72cc46f173e4657180 +Author: Guus Sliepen +Date: Fri Jul 20 20:25:10 2001 +0000 + + Added purge_tree for connection_t's which are no longer in the connection, + active or id trees, but which may still be referenced. This tree is flushed + when it is safe, this replaces purge_connection_tree(). + + Also lots of bugfixes related to the new trees. + +commit 37ed4265fa73d4c06c74362514d78c92029b2f05 +Author: Guus Sliepen +Date: Fri Jul 20 13:54:19 2001 +0000 + + Remove all unnecessary status.meta and status.active checks. + +commit 5e2ded68bfc7b3a1bfa600c1ce46144eb50e57a2 +Author: Guus Sliepen +Date: Thu Jul 19 12:29:40 2001 +0000 + + Correctly use the active_tree. + +commit 319e0cb48eb00565a11c85b901f54141f8160334 +Author: Guus Sliepen +Date: Sun Jul 15 18:07:31 2001 +0000 + + Split connection list into two lists: + - one list to handle all incoming/outgoing TCP connections + - another list to handle all UDP connections + + This will prevent race conditions. + +commit b3074590b184c141419cf4926820dc0d78380535 +Author: Guus Sliepen +Date: Sun Jul 15 14:21:12 2001 +0000 + + Correct inclusion of standard if_tun.h header file. + +commit 5dc4ade0b9c127a3c144d9c59894bf13527fe060 +Author: Guus Sliepen +Date: Wed Jul 4 08:43:32 2001 +0000 + + Don't load table of verbose OpenSSL errormessages. + +commit 1e2bdc2b6d28c76c63fc9fd36169b90fa0994388 +Author: Guus Sliepen +Date: Wed Jul 4 08:41:36 2001 +0000 + + - Always use instead of just + - Check if RAND_pseudo_bytes() exists, otherwise just use RAND_bytes() + +commit 6bd93e4c064578b545cb6dcaa28fffb229c929ff +Author: Guus Sliepen +Date: Sun Jul 1 21:42:13 2001 +0000 + + Check for all potential duplicate entries in the id tree. + +commit 9645cabc8e8364ed4df187fab8065b0991afa6af +Author: Guus Sliepen +Date: Sun Jul 1 09:21:14 2001 +0000 + + Fix compiler warning. + +commit 6365d0627b9b1e9a31371ec891db0d2cfb4d6ed4 +Author: Guus Sliepen +Date: Sun Jul 1 09:21:01 2001 +0000 + + Fix printf format bug. + +commit 33d6de0cd5c05cbf37211924a45e4231fec3a416 +Author: Guus Sliepen +Date: Sun Jul 1 09:06:17 2001 +0000 + + More items marked as done. + +commit a111593a082ff1df26f54168ab00f83ab3a1ab49 +Author: Guus Sliepen +Date: Fri Jun 29 15:38:40 2001 +0000 + + Dutch translation updated. + +commit 748dabdbe93f7439ed7eddf491a556279250e7ac +Author: Guus Sliepen +Date: Fri Jun 29 15:33:18 2001 +0000 + + Update of RedHat build scripts. + +commit 343c8fb6388ffd4f5c41cebd666aa8a045b20bdd +Author: Guus Sliepen +Date: Fri Jun 29 15:32:26 2001 +0000 + + It appears that autogen.sh doesn't like es.po if it isn't mentioned in + the makefile/configure scripts. + +commit 9391efe4e88077723840a7c085388ba2765ca17c +Author: Guus Sliepen +Date: Fri Jun 29 14:15:46 2001 +0000 + + Check for dlopen in standard libraries first (needed for DEC OSF). + +commit c9591bd1de1abcfe10459bd8c8cdd81a7b441ec0 +Author: Guus Sliepen +Date: Fri Jun 29 13:09:55 2001 +0000 + + Fix gcc 3.0 warnings. + +commit 402b85c48284a06fbfc56aca102b33be3a4260b0 +Author: Guus Sliepen +Date: Fri Jun 29 13:09:32 2001 +0000 + + Log error if two hosts connect with same IP/port tuple. + +commit 0d3bd912acdb00dc0a8015e337f981c942aa21bc +Author: Guus Sliepen +Date: Fri Jun 29 11:09:13 2001 +0000 + + Also remove po/Makefile.in.in, which is generated by autogen.sh. + +commit 67c16924c10b25d37957843a69d993b934dd1776 +Author: Guus Sliepen +Date: Fri Jun 29 11:03:27 2001 +0000 + + es.po revived. + +commit 5d3450357482176ce92ed4832ec944519d197744 +Author: Guus Sliepen +Date: Fri Jun 29 10:30:18 2001 +0000 + + Execute tinc-down BEFORE tap device is closed. This is a. more symmetric + (tinc-up is started after tap device is opened) and b. is needed for + tun/tap device, where the interface does not exist anymore after the + device file is closed. + +commit 6666acd0012c82c0bb4d1abae87332cec3dda77a +Author: Guus Sliepen +Date: Fri Jun 29 10:27:57 2001 +0000 + + Don't build Spanish translation. + +commit 77f635e871060f63c3e62fcf879d184326c690a4 +Author: Guus Sliepen +Date: Fri Jun 29 10:27:33 2001 +0000 + + ABOUT-NLS is created by autogen.sh. + +commit 333be8fbb8790237577761e580126a6d757a46e4 +Author: Guus Sliepen +Date: Fri Jun 29 10:23:46 2001 +0000 + + Spanish translation removed. Nobody maintains it, and it is severely + outdated. + +commit 3503ba995012f658f087a196dad0cb9fd45eff3b +Author: Ivo Timmermans +Date: Tue Jun 26 22:00:57 2001 +0000 + + Small fix to make it compile again + +commit 7fc068fe5421f7ec556b0b7db6f814e18b3326a4 +Author: Guus Sliepen +Date: Thu Jun 21 18:28:52 2001 +0000 + + Reinstated search for if_tun.h in kernel source tree, because apparently + /usr/include/linux does not always have the same contents as the include + files from the currently running kernel. + +commit 9e96840da810437c45af1c4b139578f7d74d65db +Author: Guus Sliepen +Date: Thu Jun 21 16:37:47 2001 +0000 + + Remove #warnings I used for debugging stuff. + +commit b1e97ece9c495ac67e54b8c2675b1eacc645eb1c +Author: Guus Sliepen +Date: Thu Jun 21 16:37:05 2001 +0000 + + Check for and add -ldl. + +commit 04ec0b82ab9c6a2662300a9257a5aff1c4dd56e7 +Author: Guus Sliepen +Date: Thu Jun 21 16:16:32 2001 +0000 + + - Solaris compile fixes + - Set mymac to broadcast MAC so that ifconfig hw ether <...> is really not + needed anymore. + - Forwarding of indirect packets when in switch mode (because the kernel + will not do it for us then). + +commit 353a9230bb70b70028f2dc6c651a28e30b13dc63 +Author: Ivo Timmermans +Date: Wed Jun 20 21:32:40 2001 +0000 + + Don't include the debian/ dir in a release + +commit 9a0a50cd3cf2570b39e00edf1a92123acbac41b4 +Author: Guus Sliepen +Date: Sat Jun 9 10:00:34 2001 +0000 + + Woops - big bug in send_key_changed fixed. + +commit ba918dce287788aaf6a90b3c7a9f349b197068d6 +Author: Guus Sliepen +Date: Fri Jun 8 18:02:10 2001 +0000 + + Only reset seconds_till_retry when we activate the outgoing connection. + +commit c5c02a0861bf540e07fe64704cb97aae29c4cacf +Author: Guus Sliepen +Date: Thu Jun 7 07:51:04 2001 +0000 + + Changed drastically because it didn't work correctly: + - Don't cache the --with-openssl-* option arguments + - Only search for openssl/*.h, the openssl include files include other + files only from an openssl/ directory too + - Set CPPFLAGS before AC_CHECK_HEADERS + +commit 053e78654097cf353aa59b4d34e608726edd5dad +Author: Guus Sliepen +Date: Thu Jun 7 07:48:11 2001 +0000 + + Save configure cache more often. + +commit 96ef7becdd71fc63c3489e3696117c1f137eade5 +Author: Guus Sliepen +Date: Wed Jun 6 19:12:38 2001 +0000 + + Fixes to make switching work between hosts that have no meta-connection. + +commit ce6c8e6d089abac81520c517185c6ef81b09f051 +Author: Guus Sliepen +Date: Wed Jun 6 19:11:16 2001 +0000 + + Log and warn about duplicate subnet_add()'s for the same subnet. + +commit 9cd9b0392388e24ade19a43206221081b61806e7 +Author: Guus Sliepen +Date: Tue Jun 5 19:45:47 2001 +0000 + + Add missing? counting of total_socket_in. + +commit 7bd7f5b4363f222340e5c058c243d31c576fba88 +Author: Guus Sliepen +Date: Tue Jun 5 19:39:54 2001 +0000 + + You can now put an option "Mode" in tinc.conf, and choose from: + + - Mode = router (default, work like tinc has always worked) + - Mode = switch (work like a switch) + - Mode = hub (work like a hub, broadcasting everything) + +commit edd6734faa37d043b8a2cc75b125db3b1c2130fa +Author: Guus Sliepen +Date: Tue Jun 5 18:07:14 2001 +0000 + + Fix bug where lookup_subnet_ipv4() could go into an infinite loop. + +commit fa376fbd4e5151ae43e86441a1e99073eeaf46a5 +Author: Guus Sliepen +Date: Tue Jun 5 16:31:59 2001 +0000 + + - This oneliner removes the need for ifconfig tap? hw ether fe:fd:0:0:0:0 + +commit 7a736d47b264065371f35cd9da64485d798cbc80 +Author: Guus Sliepen +Date: Tue Jun 5 16:15:48 2001 +0000 + + Updated dutch translation. + +commit 92924e8482f000eb33130ce9feadc08450ff349d +Author: Guus Sliepen +Date: Tue Jun 5 16:13:41 2001 +0000 + + Changed some stuff to allow correct generation of po/Makefile after a + make cvs-clean. + +commit 4f9dad0972ac0f665a1b6050b059bd52f93e6221 +Author: Guus Sliepen +Date: Tue Jun 5 16:09:55 2001 +0000 + + - tinc can now act as a switch or a hub too (as opposed to a router only) + - cleaner initialisation of "UNKNOWN" and "MYSELF" names + +commit 428482d86f860d1fb09de722c1b6576ec2eef1ce +Author: Guus Sliepen +Date: Mon Jun 4 11:14:35 2001 +0000 + + Added proxy-arp support. No more ifconfig -arp needed. Works like a charm + under FreeBSD now :). + +commit 0a3c8cefd4a154948799baaaa246cf0eba050eff +Author: Guus Sliepen +Date: Fri Jun 1 08:02:09 2001 +0000 + + Fix subnet_lookup() for overlapping subnets. Needs rethinking. + +commit 7db1b999c82611d6c68a5d79b4754db19669d5c6 +Author: Guus Sliepen +Date: Mon May 28 08:56:57 2001 +0000 + + Make sure Solaris is happy too. + +commit 65247c063b36a76dd68156fe17b017c7460d982f +Author: Guus Sliepen +Date: Mon May 28 08:21:43 2001 +0000 + + Small fixes to allow correct compilation under FreeBSD (tested with 4.3) + +commit 4e959ee40542733e647c36831c1fc87ed8098233 +Author: Ivo Timmermans +Date: Sat May 26 09:35:28 2001 +0000 + + Don't distribute autogen.sh in a release + +commit 514f8f579d5c0608aee8ca4a43d7414ecee5c11c +Author: Ivo Timmermans +Date: Sat May 26 09:35:00 2001 +0000 + + Changed version number to 1.0-cvs + +commit 20c2b62b1802390c0f5a1757641a0a1cea8103a8 +Author: Ivo Timmermans +Date: Sat May 26 09:34:11 2001 +0000 + + New make target: `make release' + +commit 8d307c2fbf2c20eb53909f74c81e03db838fb55e +Author: Guus Sliepen +Date: Fri May 25 18:57:37 2001 +0000 + + Fix sample configuration to show keys in PEM format and correct tapdevice. + +commit e12d41f39d8dd1cd30058d08effd2e5b66cdd4fd +Author: Guus Sliepen +Date: Fri May 25 13:24:34 2001 +0000 + + Documents are merged. Now we only need to check the ports and the TCPonly + and IndirectData options. + +commit f0c64a3dac3b0469ea05fa5d44a1e7bdbfa64900 +Author: Guus Sliepen +Date: Fri May 25 12:45:37 2001 +0000 + + Merged PROTOCOL, NETWORK and SECURITY2 with the texinfo manual. + +commit fcf869cd4250a240ea8d443f70fa373e4fbacf07 +Author: Guus Sliepen +Date: Fri May 25 11:54:28 2001 +0000 + + TCPonly now works (in a relatively clean way too). + +commit a5e2ae6b2b2e1629cf05bb2a57df75f13c0f120a +Author: Guus Sliepen +Date: Fri May 25 10:08:11 2001 +0000 + + With recent kernels the tun device file is located in /dev/net. + +commit 6e09c2a99c8ac3c1391f4f2eee16d6c235c10e90 +Author: Guus Sliepen +Date: Fri May 25 10:06:13 2001 +0000 + + Small corrections to the manuals. + +commit 4dee76522e177dcb4af5d6d844a5f3b74070e4b7 +Author: Guus Sliepen +Date: Fri May 25 08:36:11 2001 +0000 + + Small fixes: + + - Fix compiler warnings (one was a real (but harmless) bug) + - Don't send PING packets if there is UDP traffic + - Correctly terminate strings containing salt for PING/PONG packets + +commit bfc5d6014e3c1563f7b6a2f10698e9ba23ba3e96 +Author: Guus Sliepen +Date: Thu May 24 21:52:26 2001 +0000 + + Only send key_changed if it was previously requested. + +commit 1a248fd5bd5aa24fa0f6a2c395f05dd569f0898d +Author: Guus Sliepen +Date: Thu May 24 21:32:30 2001 +0000 + + All features for 1.0 are implemented now, we just have to check the + FreeBSD and Solaris ports and merge some docs. + +commit 58893f0875369aafff8481825af271683c975a2a +Author: Guus Sliepen +Date: Thu May 24 21:30:36 2001 +0000 + + Since this is incompatible with some earlier versions, PROT_CURRENT is + increased. + +commit d1b597758eab68bb80d97855f25cb6dda55eeb0b +Author: Guus Sliepen +Date: Thu May 24 21:29:09 2001 +0000 + + Add randomness to PING/PONG packets to prevent crypto attacks on quiet + tunnels. + +commit 4493b0650bd487990ca9d2802496ad0ee7c06247 +Author: Guus Sliepen +Date: Thu May 24 20:40:13 2001 +0000 + + Changed URL from kernelnotes.org to linuxdoc.org. + +commit 3360c6270bcc19a8b3d81da185266fc33b5c5421 +Author: Guus Sliepen +Date: Thu May 24 20:24:12 2001 +0000 + + More revisions to the documentation: + + - Removed cruft + - Reordered some sections to make it more logical for the beginner + - Added small examples and hints about configuration files + +commit 6f7f8659a2048fd6d616f4286ccdd0e661084493 +Author: Guus Sliepen +Date: Sat May 19 15:50:51 2001 +0000 + + - Make sure correct information is supplied for both old kernels (with + ethertap) and for new kernels (with TUN/TAP driver). + - Revised example configuration and made it conform to latest (CVS) version of + tinc. + +commit e4f3d93ec62871d1ae11b460627aef0da1b23cd2 +Author: Guus Sliepen +Date: Mon May 7 19:08:46 2001 +0000 + + - s/ip_t/ipv4_t/g + - Add "salt" to the beginning of UDP packets. Replaces length field which + is not useful anyway. + +commit a26081467c197cc6b26a0c36c4508361b242fc85 +Author: Guus Sliepen +Date: Fri May 4 18:45:02 2001 +0000 + + Correctly cycle through ConnectTo variables. + +commit 80b4a851a6b62cbbf503c2225f93305966f058c0 +Author: Guus Sliepen +Date: Fri Apr 13 10:30:04 2001 +0000 + + Depend on new ssl package and install alias for universal TUN/TAP module. + +commit 156ec676525ed789364b7a77926dd0717d0cf5d7 +Author: Guus Sliepen +Date: Tue Mar 13 21:33:31 2001 +0000 + + Check indirectdata option before forwarding certain requests. + +commit c426e981eeaed3fa4801221720ee8f74d40e9223 +Author: Guus Sliepen +Date: Tue Mar 13 21:32:24 2001 +0000 + + Ignore alarm signals if we do not need to respond to them. + +commit b413257e10ae0645da43583dd8f84a1f74df5bd7 +Author: Guus Sliepen +Date: Tue Mar 13 09:55:14 2001 +0000 + + Fixed bug in setup_signals() that would make tinc die when unexpected + signals were caught. + +commit f1a082823c48d00171b814f7e14e07e6dd4632fb +Author: Guus Sliepen +Date: Mon Mar 12 23:58:19 2001 +0000 + + Fixed a race condition triggered by receive_meta() and the new + authentication scheme. + +commit f4887b981f109fc4264f50170b2d12c4033bf5e9 +Author: Guus Sliepen +Date: Sun Mar 4 14:00:24 2001 +0000 + + Added a description of what is going on in net.c and route.c, and how + packets flow through tinc. + +commit 9d5c9bf6ba74e4e8bbd12b97fdda6c665155fec6 +Author: Guus Sliepen +Date: Sun Mar 4 13:59:53 2001 +0000 + + Updated translation. + +commit 34f9e6cf2d6d2b81eb63f9f28963b447a2157740 +Author: Guus Sliepen +Date: Sun Mar 4 13:59:32 2001 +0000 + + - route.c is now used to determine destination + - flags are removed, since they were not used at all. Use options instead. + - indirectdata works now, tcponly almost... + - made functions that don't return useful information void + +commit d2a54597e029f9d4f7bd29837be1be33909d78b1 +Author: Guus Sliepen +Date: Fri Mar 2 11:25:56 2001 +0000 + + Added explaination of our key exchange using RSA encryption. + +commit 125c4978812cffa5154ce5378a276f43f78417d8 +Author: Guus Sliepen +Date: Thu Mar 1 21:32:04 2001 +0000 + + Various small fixes. + +commit 099cc867c1a0831add7f1b4046f22ad6bfa5a1ef +Author: Guus Sliepen +Date: Tue Feb 27 16:50:29 2001 +0000 + + Removed compiler warning. + +commit 4fa12eb85d72f039df5004abc201f01f5573c2e4 +Author: Guus Sliepen +Date: Tue Feb 27 16:37:31 2001 +0000 + + Removed lots of compiler warnings. + +commit 173d606514d82fc5ae7895a178238d0abcaf6606 +Author: Guus Sliepen +Date: Tue Feb 27 16:17:04 2001 +0000 + + - Fixed Interface option (untested) + - Removed error handling for non-critical socket options + - Added TCP_NODELAY and IPTOS_LOWDELAY options for meta sockets. + +commit fb4ba9b265666d9949b03209a3ff52ff1263226b +Author: Ivo Timmermans +Date: Tue Feb 27 16:15:14 2001 +0000 + + Authentication done + +commit 24fa68585923d2b52718390f3f38d1aaacef12f0 +Author: Guus Sliepen +Date: Tue Feb 27 15:33:39 2001 +0000 + + Don't forget to reconnect if outgoing connection fails during + authentication. + +commit 34b7a876c3583f7a34585cff6a694bc9e35cdc87 +Author: Guus Sliepen +Date: Mon Feb 26 11:37:20 2001 +0000 + + - Make sure METAKEY is smaller than the modulus of the RSA key + - Get symmetric key from the least significant bytes of the RSA message + +commit 4b0ad4d97abd3643c44f45841d52f3000a34ba60 +Author: Guus Sliepen +Date: Sun Feb 25 20:17:46 2001 +0000 + + Added process.c to the translated files. + +commit 82455be966027a087a2ac23e3464594c81d7b111 +Author: Guus Sliepen +Date: Sun Feb 25 19:09:45 2001 +0000 + + Implemented new authentication scheme from doc/SECURITY2. + +commit 54881faf6fdbf04fb5ee56b7809439fbc50c65cb +Author: Guus Sliepen +Date: Sun Feb 25 16:34:19 2001 +0000 + + Encrypt network packets in CBC mode instead of CFB mode. + (This breaks compatibility with all previous versions!) + +commit 9de5787574b21e94c80ddc60def2b3e514aff755 +Author: Guus Sliepen +Date: Sun Feb 25 16:04:00 2001 +0000 + + Copy packets before putting them in the queue. + +commit 38adc479a44b64afcb220cd757f77ab105cb9bcd +Author: Guus Sliepen +Date: Sun Feb 25 15:34:50 2001 +0000 + + Free node->data and node, not node->data twice. + +commit e250d64300cea2a83059866e7cbabcb33684160e +Author: Guus Sliepen +Date: Sun Feb 25 14:51:42 2001 +0000 + + Add missing \n. + +commit 153fc35e57c0104aa4ea9103bcdbca3665e4934c +Author: Guus Sliepen +Date: Sun Feb 25 11:09:29 2001 +0000 + + Corrected check for errors after read() calls. + +commit 0b0c2a372ff5d11f73af172e07a93b2656374a42 +Author: Wessel Dankers +Date: Tue Feb 20 21:53:18 2001 +0000 + + Important bugfix in avl_insert_before() and avl_insert_after() + +commit 11f8465dd9a4f81b43a31f1cb6a7fc2d76bb7838 +Author: Ivo Timmermans +Date: Sun Feb 18 02:13:26 2001 +0000 + + tinc_TUNTAP now substitutes the values outside the AC_CACHE_CHECK + block. configure should now correctly set HAVE_TUNTAP. + +commit bb0870498037565209e24fbb2ffa07b815350a0b +Author: Guus Sliepen +Date: Tue Feb 13 09:54:29 2001 +0000 + + Added description of the proposed new authentication scheme. + +commit cebb6efeb0f39bf05ca7836b7a393c8385b49335 +Author: Ivo Timmermans +Date: Sun Feb 11 11:55:28 2001 +0000 + + More files to ignore in CVS + +commit 603781831f251d2e8111e8282d8e624b8e40b175 +Author: Guus Sliepen +Date: Sun Feb 11 11:50:09 2001 +0000 + + - Updated CVS_CREATED to remove intl/ directory and some other + autogenerated files. + - Checked if all INCLUDES/LIBS/etc directives inherit the global variables. + +commit 88dfdc9dbac3f5d0aa70b77509b4a87513433987 +Author: Guus Sliepen +Date: Sun Feb 11 11:46:14 2001 +0000 + + Ignore file for src/ + +commit ef0fc4f687fc25e97551e589941d6a2a2d8ade42 +Author: Guus Sliepen +Date: Sun Feb 11 11:44:32 2001 +0000 + + Added .cvsignore files to get rid of warnings and prevent autogenerated + files from being added accidentaly. + +commit f1cb3d8fa5f69840f353ca5a62f363dad47eb46f +Author: Guus Sliepen +Date: Tue Feb 6 10:42:27 2001 +0000 + + Removed another local definition of the variable "errno" + +commit 0f715887c617723e4b450083f8b77641f8b62e80 +Author: Guus Sliepen +Date: Tue Feb 6 10:13:44 2001 +0000 + + Updated dutch translation. + +commit 4bc394a3e29f2f90434bbbfc9f23d5587398471b +Author: Guus Sliepen +Date: Tue Feb 6 10:13:22 2001 +0000 + + Fix memory leak in avl_insert() if item was already inserted. + +commit f777c1807d663eaef3e36c395094451214886898 +Author: Guus Sliepen +Date: Tue Feb 6 10:12:51 2001 +0000 + + FreeBSD compile fixes (thanks to XeF4) + +commit bb4457d6caf6e424aeaf9b09222d4e62cab939da +Author: Ivo Timmermans +Date: Thu Jan 18 13:02:34 2001 +0000 + + Unpack sample-config.tar.gz when installing + +commit fe61e1ffef186aa509a50be3be83955fe1cbb514 +Author: Ivo Timmermans +Date: Thu Jan 18 13:01:42 2001 +0000 + + Distribute the sample config as a .tar.gz + +commit a73ec9caa45bda7738376a610030c8ba9b934445 +Author: Ivo Timmermans +Date: Thu Jan 18 13:00:57 2001 +0000 + + Fixed some errors + +commit b33c5f6640e63cc4cd35285367bcb2827b732229 +Author: Ivo Timmermans +Date: Wed Jan 17 16:24:24 2001 +0000 + + First try to create a graphical frontend for tinc configuration + +commit 6bc77a7710adcbc33331c45e1b6adf7089a42075 +Author: Ivo Timmermans +Date: Wed Jan 17 01:48:44 2001 +0000 + + Get the PO files up to date with the current source + +commit 664f7e5c0b9056d88e2b63b3626ea33c4894387b +Author: Ivo Timmermans +Date: Wed Jan 17 01:47:39 2001 +0000 + + Get the Debian changelog up to date + +commit 1d898e00a964ef922617683a1d29ff24e56ed8ff +Author: Ivo Timmermans +Date: Wed Jan 17 01:40:46 2001 +0000 + + Merged documentation with various updates I had lying around + +commit 457c6fa7b63a7f2971314d8d63af71c880ec6f53 +Author: Ivo Timmermans +Date: Wed Jan 17 01:34:08 2001 +0000 + + Second draft of the release notes + +commit b236ddb1df16f8eb025d485b75153c4f25f4afc6 +Author: Ivo Timmermans +Date: Wed Jan 17 01:31:56 2001 +0000 + + Change version to 1.0pre4 + +commit a893b05cb017c04871c2faf4099f104985f4ad75 +Author: Ivo Timmermans +Date: Wed Jan 17 01:30:32 2001 +0000 + + Set Architecture to `any' + +commit 54e19d34663cfe4af05e9e1dac94f76e39858f18 +Author: Ivo Timmermans +Date: Wed Jan 17 01:30:05 2001 +0000 + + Fix error reporting of read_config + +commit a56df1e06be3f47a775919e564c147687e961b5d +Author: Guus Sliepen +Date: Sat Jan 13 16:36:23 2001 +0000 + + - Allow ASN1 style keys to be in the config files. + Note: tinc ignores private key in the main config file, tinc.conf, + because it should really be in a separate file. + - When generating new keys, check if name is known and by default append + the public key to the host configuration file (otherwise rsa_key.pub). + +commit 44c85ab07ed07165b80140da4e2910ca51fa8887 +Author: Guus Sliepen +Date: Sat Jan 13 14:56:46 2001 +0000 + + - Copy entire sample-config directory to /etc/tinc/example upon installing. + +commit b195e8815f0abb2c5527119221886b524d719019 +Author: Guus Sliepen +Date: Sat Jan 13 14:38:18 2001 +0000 + + Added sample configuration directory. + +commit d646f4e094b63720f97bfd37bb3489bd9d6231a0 +Author: Guus Sliepen +Date: Thu Jan 11 11:19:08 2001 +0000 + + - Only send out DEL_HOSTs for hosts with a meta connection + +commit c8beaf35ee923c209ee23bedcb3dc892d2c2dae3 +Author: Guus Sliepen +Date: Mon Jan 8 21:32:30 2001 +0000 + + - Cleaned up subnet_t + +commit e5e1c20a99b0d72792f28e9a075a9f4a7e8b2c95 +Author: Guus Sliepen +Date: Mon Jan 8 21:32:00 2001 +0000 + + - Sign was wrong in search_closest_smaller/greater + +commit 11f3e9d138daf6b726631cc124b14d66dfa4d1f7 +Author: Guus Sliepen +Date: Mon Jan 8 20:35:30 2001 +0000 + + - Squashed another nasty bug. + +commit 447a43d63960802a7a29201c512246be11eb9c94 +Author: Guus Sliepen +Date: Sun Jan 7 20:19:35 2001 +0000 + + - Added indirectdata and tcponly functionality. + +commit 7cd2baedc6027ef6a5b941342bc6d3931d7220ba +Author: Guus Sliepen +Date: Sun Jan 7 20:19:08 2001 +0000 + + - Fixed IPv6 subnet lookup routine. + +commit d3f889c8076dff9c00ebfe1459cb36425f8da41d +Author: Guus Sliepen +Date: Sun Jan 7 17:09:07 2001 +0000 + + - It's 2001, all copyright notices are updated. + +commit 96b6f958bc733c3963dd164caacd42513be47a86 +Author: Guus Sliepen +Date: Sun Jan 7 17:08:03 2001 +0000 + + - Description of protocol and authentication updated. + +commit 7109526c6789c73a18bbe6b228ca35f0374c8d36 +Author: Guus Sliepen +Date: Sun Jan 7 15:27:30 2001 +0000 + + - Added header file for route.c. The routing routines in it are not used + yet, but have a look at the source for the ideas behind it. + +commit 07a08f5539f441e66946d1db1711dc584f8621c4 +Author: Guus Sliepen +Date: Sun Jan 7 15:25:49 2001 +0000 + + - Reinstated a queue for outgoing packets. + +commit 049ff67817e0db5afbba30930531d8ea3f7f2d18 +Author: Guus Sliepen +Date: Sun Jan 7 15:24:52 2001 +0000 + + - Changed list routines to give it the same look'n'feel as the rbl and + avl tree library. + +commit 8b4bc5b3a7e31c198c001610c99c2993e1612376 +Author: Guus Sliepen +Date: Sat Jan 6 20:43:03 2001 +0000 + + - Typo. + +commit 3d7289cf743f89cab4c71815482a4837a21f6703 +Author: Guus Sliepen +Date: Sat Jan 6 20:02:21 2001 +0000 + + - Updated texinfo manual. + +commit 0d99ae59bd7c640d396ce978045f0911567fb9bf +Author: Guus Sliepen +Date: Sat Jan 6 18:44:55 2001 +0000 + + - Updated manual pages. + +commit 90bf1b21fa7e94d73719da0593e7c0356d05e18f +Author: Guus Sliepen +Date: Sat Jan 6 18:21:17 2001 +0000 + + - Changed license of AVL tree library to GPL. + +commit f7bb205022e02c02c02733cd43544c231373115d +Author: Guus Sliepen +Date: Sat Jan 6 18:03:41 2001 +0000 + + - Check and follow symlinks in is_safe_path + - By default write keys to tinc config directory + - Small fix in protocol.c + +commit 1398edec37336853bfca6ea3dcca7c402f102ea2 +Author: Guus Sliepen +Date: Sat Jan 6 16:51:14 2001 +0000 + + - Updated dutch translation. + +commit e924096f62655d711cd2d114a8d1ef0fecbb593b +Author: Guus Sliepen +Date: Fri Jan 5 23:53:53 2001 +0000 + + - Let user choose whether keys are in the config files or separate + - Use AVL trees instead of RBL trees + - Fixed a lot of annoying subtle bugs! Thanks to gdb... + +commit 052fbc0bdf36e0dbe2a0867ce770d426c9a44841 +Author: Guus Sliepen +Date: Fri Jan 5 23:51:41 2001 +0000 + + - Doubled size of trace buffer for easier debugging. + +commit 77509da76c61b881c9967bfb7cdafeaf6b56eb6d +Author: Guus Sliepen +Date: Fri Jan 5 23:50:56 2001 +0000 + + - AVL tree routines: faster than RBL, and also more stable. + +commit e1707f7739f450c729e26b921e459d5da07602f9 +Author: Guus Sliepen +Date: Fri Dec 22 21:34:24 2000 +0000 + + - Don't even think about using sscanf with %as anymore + - Allow keys to be inside the config files or in a seperate file + - Small fixes + +commit ecae72de94222302aa326888f70cfacdbd775b23 +Author: Ivo Timmermans +Date: Fri Dec 22 17:15:26 2000 +0000 + + Added lint target, requires lclint. + +commit c5fac35c6ce9b9fcc47508810d69aeab83d08c25 +Author: Ivo Timmermans +Date: Fri Dec 22 17:10:25 2000 +0000 + + Forget router.c + +commit 37544990e96fe5ea161e644f6417f505d666cd00 +Author: Ivo Timmermans +Date: Fri Dec 22 16:59:16 2000 +0000 + + Include autogen.sh (needed for the Debian package). + +commit 8a4daf4ea7758270a47a358f43ad97a64eb1c3ff +Author: Ivo Timmermans +Date: Fri Dec 22 16:54:56 2000 +0000 + + Various small changes. + +commit e469fca4d78e9d23698fe1e6b29b232198cc499e +Author: Ivo Timmermans +Date: Wed Dec 6 13:33:49 2000 +0000 + + Re-introduced MyVirtualIP and VpnMask, as dummy options. + +commit e50e4a54d6b40b988041a7e9bfdfbf708657f3a5 +Author: Ivo Timmermans +Date: Tue Dec 5 09:04:32 2000 +0000 + + Give a warning about having to re-create the keys + +commit 4610d98c04641fce65747e07d65cbdd03fb6fe30 +Author: Ivo Timmermans +Date: Tue Dec 5 09:03:41 2000 +0000 + + Ported it back to /bin/sh. + +commit 1e38dcc3fa6c0da2fdb21f83a588338fa8a41818 +Author: Ivo Timmermans +Date: Tue Dec 5 09:03:19 2000 +0000 + + Install a file in /etc/modutils/tinc, containing all necessary aliases + and options for kernel modules. + +commit 6327f32f43dc9109fad9952fd50a23876d0acaf0 +Author: Ivo Timmermans +Date: Tue Dec 5 08:59:30 2000 +0000 + + Tiny bits of code beautifying + +commit 9267bed9f516244b00d5c86c8dae44b7eb78a96c +Author: Ivo Timmermans +Date: Tue Dec 5 08:56:44 2000 +0000 + + Oops. I did some VERY wrong things with readline(). Fixed now. + +commit 6ddc9109d7313503895227c7876309b36681393d +Author: Ivo Timmermans +Date: Tue Dec 5 08:54:22 2000 +0000 + + Massive long awaited documentation update. It's not finished yet, + most notably the example configuration is still old. + +commit bc22ee16e6903d2caf9d22afa85020d1e3e10b56 +Author: Ivo Timmermans +Date: Sun Dec 3 12:23:06 2000 +0000 + + Option -d accepts an argument to set the debug level immediately. + +commit 01d23601a273d128ebfd13c2ffa10892e9b13094 +Author: Ivo Timmermans +Date: Sun Dec 3 12:22:19 2000 +0000 + + Sort configuration directives + +commit d6b77e18b58ad8f9bcd9b60864b95cd2a74482c5 +Author: Ivo Timmermans +Date: Sun Dec 3 12:21:20 2000 +0000 + + Added documentation merger + +commit e985f6d3cdbebdeb17333bbd3d3c20d4618128cf +Author: Ivo Timmermans +Date: Fri Dec 1 13:46:26 2000 +0000 + + Include COPYING.README in the distribution. + +commit 94192b3db10fe51ce45fa569ec068423a4491b0b +Author: Ivo Timmermans +Date: Fri Dec 1 13:45:46 2000 +0000 + + Stated that distributing executables linked with OpenSSL is permitted + provided that all other requirements of the GPL are complied with. + +commit 52575a573c1d87ee125a54a2e0b4044698904cae +Author: Ivo Timmermans +Date: Fri Dec 1 12:38:42 2000 +0000 + + Use buffer instead of line in read_config_file(), line may be assigned + NULL, so buffer always holds the pointer to the allocated space. + +commit ab33c1aa6081f07333bf1de00e4036dd2b4628a6 +Author: Ivo Timmermans +Date: Fri Dec 1 12:36:36 2000 +0000 + + readline() accepts two extra parameters, buf and buflen, to avoid + mallocing and freeing for every line that is read. + +commit 6c56a8416eded8f19076a619a27ad7b153dd91f3 +Author: Ivo Timmermans +Date: Thu Nov 30 23:44:07 2000 +0000 + + Tagged `Storing private key in separate file' as done. + +commit 8fe83e98da043e930a88ddd6b2de6c14aa791335 +Author: Ivo Timmermans +Date: Thu Nov 30 23:39:55 2000 +0000 + + All full stops have two spaces after them. (Silly commit, I know.) + +commit a0f7af3ed79c55d9680cbb0a569b3c8987581d43 +Author: Ivo Timmermans +Date: Thu Nov 30 23:18:21 2000 +0000 + + New function read_rsa_public_key(); + In net.c/setup_myself deleted old code to read the public key (which + is now implicitly read in together with the private key). + +commit 28deaeac14d619efb9830d03fd61dc7cca70a701 +Author: Ivo Timmermans +Date: Thu Nov 30 22:48:48 2000 +0000 + + Avoid printing duplicate messages from read_rsa_keys + +commit 2293304748f7e4e9a18ee848b8264bdecebae37f +Author: Ivo Timmermans +Date: Thu Nov 30 22:33:16 2000 +0000 + + Better error checking when reading the RSA private key. + +commit bf4e969899bb6cdeb05570d96a567c2833ac83bd +Author: Ivo Timmermans +Date: Thu Nov 30 22:32:14 2000 +0000 + + In readline(): initialise the line to zero length; + In read_config_file(): Test for EOF, and print the variable name that + caused an error. + +commit 113198d9c0b3be9904057673cfed165406803f86 +Author: Ivo Timmermans +Date: Thu Nov 30 21:11:03 2000 +0000 + + The file is safe if it doesn't exist. + +commit 09260b43d1ff037c22f86c82a6af830e9a6d6ae5 +Author: Ivo Timmermans +Date: Thu Nov 30 20:08:41 2000 +0000 + + Read the PEM file pointed to by the configuration directive + PrivateKey. This means thatt he meaning of this variable has changed, + it no longer should contain the private key directly. + + WARNING: This code is untested. + +commit 8ccb1ede92fbd55481fa2317c2450bb9dd94a180 +Author: Ivo Timmermans +Date: Thu Nov 30 00:24:13 2000 +0000 + + Implemented is_safe_path, and extended ask_and_safe_open. + + is_safe_path needs more work before it is useable. + +commit 75e3c296b4fa1eb02df2f5f84a1280e791f88603 +Author: Ivo Timmermans +Date: Wed Nov 29 15:22:04 2000 +0000 + + Updated Dutch translation + +commit d36da1948abdd27e9d0740c2baceb0bd155c18c6 +Author: Ivo Timmermans +Date: Wed Nov 29 14:30:07 2000 +0000 + + Also free the pointer returned by readline(). + +commit 9e55426d72fd77fda891edd0023dab2f9909639e +Author: Ivo Timmermans +Date: Wed Nov 29 14:27:24 2000 +0000 + + Use readline() in read_config_file() instead of fgets. + +commit 8ea23d9ec3f2fe0c113eac5caafb7c2bd03f3016 +Author: Ivo Timmermans +Date: Wed Nov 29 14:23:08 2000 +0000 + + xstrdup now takes a const pointer as an argument. + +commit 54ef13bf75a7a1e787716ce395ffe847fa74673f +Author: Ivo Timmermans +Date: Wed Nov 29 14:24:40 2000 +0000 + + Implemented a readline() function that will read an entire line into a + dynamically allocated buffer; + + Ask for a file name in ask_and_safe_open(). + +commit 9175d2048382c617a639fd3d437a9e06baa66d0f +Author: Ivo Timmermans +Date: Wed Nov 29 01:37:50 2000 +0000 + + Added a check for a scanf that knows about %as. + +commit 1ca04711aeab615161746c6bbb5d137388c73263 +Author: Ivo Timmermans +Date: Wed Nov 29 00:33:15 2000 +0000 + + Check for get_current_dir_name. There is a replacement function in + dropin.c. + +commit c94f7637427f4c89d56c41fe4c75f2970b664a63 +Author: Ivo Timmermans +Date: Tue Nov 28 23:23:41 2000 +0000 + + dropin.c/h contain a set of drop-in replacements for non-standard C + library functions (read: GNU extensions). + +commit 3ff76eb10acc55b6f269c1075de6bbaa5bc83516 +Author: Ivo Timmermans +Date: Tue Nov 28 23:12:57 2000 +0000 + + Save RSA public and private keys to a separate file, instead of + wanting to copy them into a configuration file. + +commit 4c502b005bfd24821e817c134e8a442a5f4606de +Author: Ivo Timmermans +Date: Tue Nov 28 08:59:27 2000 +0000 + + Use sigaction to set signal handlers, the previous commit (1.1.2.16) + already contained a large portion of what should have gone in this + one. + +commit e44dc004b3d1ce8f857971f479c917931eda7091 +Author: Ivo Timmermans +Date: Mon Nov 27 20:52:55 2000 +0000 + + Sort items to either 1.0 or future release goals. + +commit 699f3b4c93482055c0832c9a6b76dc0294967003 +Author: Ivo Timmermans +Date: Sun Nov 26 22:46:53 2000 +0000 + + Check for the function strsignal, and define it to "" if it is not + available. + +commit 67a4abda707b28b9c77cb35ff1e800e6a5b0991c +Author: Ivo Timmermans +Date: Sun Nov 26 22:42:34 2000 +0000 + + Give an error message if daemon() failed. + +commit 702e55306dfebe5c6f9a6587ed029c3bc3efbe8f +Author: Ivo Timmermans +Date: Sun Nov 26 22:32:52 2000 +0000 + + Updated Spanish translation, provided by Enrique Zanardi. + +commit 1eedf54681d4556c6874f7baee8e810cab867756 +Author: Guus Sliepen +Date: Sat Nov 25 13:33:33 2000 +0000 + + - Use only one socket for all UDP traffic (for compatibility) + - Write pidfile again after detaching + - Check OS (for handling FreeBSD/Solaris tun/tap stuff) + +commit 0806605ce383b7e89fa26eda56f8a5f3bbed9dd3 +Author: Guus Sliepen +Date: Fri Nov 24 23:30:50 2000 +0000 + + - Added daemon() replacement. + +commit cfb828784ebbcf4b3e40eb9bb351b6ed10a84b35 +Author: Guus Sliepen +Date: Fri Nov 24 23:14:52 2000 +0000 + + - Added Armijn to the list + +commit cf49b2c0647554613874cce495e4a7937a9f7863 +Author: Guus Sliepen +Date: Fri Nov 24 23:13:07 2000 +0000 + + Another big & bad commit: + - Added some extra search functions to rbl routines + - Fix subnet_lookup() + - Reorder some syslog messages to make more sense + - daemon() is back + - Don't let scripts execute in parallel (gives race conditions, and + anyway something MIGHT just be configured which is necessary for further + execution of tinc itself) + - Accidently merged check_child() with execute_script(). + - Small fixes + +commit 97c54ffb35312caf38034952b9ed2733f7e374f9 +Author: Ivo Timmermans +Date: Fri Nov 24 16:52:57 2000 +0000 + + Add default tinc-up and tinc-down scripts for a Debian system. These + do not yet work, it's just old code from init.d. + +commit b42c9abafdc102db0641f3d444bdb30fbc29140a +Author: Ivo Timmermans +Date: Fri Nov 24 14:15:20 2000 +0000 + + Call autogen.sh instead of configure alone; and make cvs-clean instead + of distclean. This way you can just cvs checkout && dpkg-buildpackage + in one go. + +commit edb9b4cad09855a9bb3c57c5d4b1b174fde1de6c +Author: Ivo Timmermans +Date: Fri Nov 24 14:13:51 2000 +0000 + + Explain how to tell configure where OpenSSL lives. + +commit 4cb4a7d298d560593f84d974bf77d0ee8a911a50 +Author: Ivo Timmermans +Date: Fri Nov 24 14:13:06 2000 +0000 + + Set errno to 0 before trying to kill the other process. + +commit ef88db63120503a8c9d34d86073795c99dedc3a9 +Author: Ivo Timmermans +Date: Fri Nov 24 14:12:31 2000 +0000 + + Alter CFLAGS, somehow INCLUDES doesn't propagate properly. Still + doesn't work exactly like it should, but getting there. + +commit b17822840150f5ba8cfb8e5a44fc10d66bd15a97 +Author: Ivo Timmermans +Date: Fri Nov 24 14:04:49 2000 +0000 + + Set CFLAGS to -O2 -Wall when running configure + +commit eb36b0c1ef7b5ed8ff59c3b41cbb361ed37d5f01 +Author: Ivo Timmermans +Date: Fri Nov 24 14:00:32 2000 +0000 + + Use cvs2cl instead of rcs2log to generate the ChangeLog. + +commit 2f37f2bd8ab6b89eb6b6c2b4bdd6ffe449b1aa98 +Author: Ivo Timmermans +Date: Fri Nov 24 14:03:13 2000 +0000 + + Set localstatedir to /var + +commit 31aa4298463498cbb755db747e901e4269cd1ef6 +Author: Ivo Timmermans +Date: Fri Nov 24 13:33:48 2000 +0000 + + Do not attempt to retreive ChangeLog information only from the CABAL + tag, it doesn't work anyway. + +commit f2dd7bb42c1f4bfa708f542e430f4a56fd43e74f +Author: Ivo Timmermans +Date: Fri Nov 24 13:32:26 2000 +0000 + + Do not check for the daemon() system call + +commit b0ff879e7c68edd447328f3d806c1ad9e336fece +Author: Ivo Timmermans +Date: Fri Nov 24 12:44:39 2000 +0000 + + Do not use the C library's daemon() call. + +commit cebcf78b9a24f70902009bea23514e55d84b096a +Author: Guus Sliepen +Date: Thu Nov 23 09:30:33 2000 +0000 + + - Don't link with -ldl anymore + - Let's not use bash' built-in pwd function anymore... it does not follow + symlinks. + +commit 7aa7895629d72391eccfcb23f3cb6290a9e3abc3 +Author: Guus Sliepen +Date: Wed Nov 22 23:09:38 2000 +0000 + + - #include instead of + +commit dac256505e1af78505c9f905bd55c11d4b87345c +Author: Guus Sliepen +Date: Wed Nov 22 22:18:03 2000 +0000 + + - Fixed all (except 2) compiler warnings gcc -Wall gave. + +commit 6f373e690236334d8f8333710b61f97ccad54bf1 +Author: Guus Sliepen +Date: Wed Nov 22 22:05:37 2000 +0000 + + - More porting to FreeBSD and Solaris. + +commit 5971e352dae2cf189f1cbdeacffa4ccdd1e98304 +Author: Guus Sliepen +Date: Wed Nov 22 20:25:27 2000 +0000 + + - Work with the correct key buffer in ans_key_h + +commit a07602c4fddfca9894f1d738959ae359695f5bf9 +Author: Guus Sliepen +Date: Wed Nov 22 19:55:53 2000 +0000 + + - No more %as. + +commit 394ed3fb174bb629bfb4b441fe58842562f955de +Author: Guus Sliepen +Date: Wed Nov 22 19:14:09 2000 +0000 + + - Write pidfile AFTER detaching... + - Minor cleanups + +commit f8b4a000d008082e5c7e511a49318b8dea8fd08d +Author: Guus Sliepen +Date: Wed Nov 22 18:54:08 2000 +0000 + + - Cleaned up and checked for some more NULL pointers in rbl.c + - Two connection lists: one for incoming connections, sorted on ip/port, + one for connections whose identity we know, sorted on id ofcourse... + +commit 785684f0ec5c9250788b4b32c0eab3f358c9db61 +Author: Ivo Timmermans +Date: Wed Nov 22 17:49:16 2000 +0000 + + Declare fd. + +commit e42255ae1374fe65e92de72de4508a84bdb91fa1 +Author: Ivo Timmermans +Date: Wed Nov 22 17:48:15 2000 +0000 + + Add more checks to ensure that filedescriptors are right in + _execute_script(). + +commit 2ed68134047a19e708c2a2af32c58968835a7043 +Author: Ivo Timmermans +Date: Wed Nov 22 16:19:07 2000 +0000 + + Honor the --localstatedir option to configure, instead of hardcoded /var. + +commit 9e9e1925b901dff87518f0e1534a33e48eab8303 +Author: Guus Sliepen +Date: Tue Nov 21 09:13:59 2000 +0000 + + - Check for NULL tree->delete callback + - Add xstrdup() function + +commit da9a1e8084a9b73306bdbc541ee8af938c3e7754 +Author: Guus Sliepen +Date: Mon Nov 20 23:29:47 2000 +0000 + + - More fixes. + +commit 3a6200c1e39b61b249db3d1f9bcffa77351863bd +Author: Guus Sliepen +Date: Mon Nov 20 22:13:14 2000 +0000 + + - Various small fixes. + +commit 06afd357b0cf4aab778b1ccabbd1be61a9500d10 +Author: Ivo Timmermans +Date: Mon Nov 20 19:56:01 2000 +0000 + + Get rid of all libtool references at once. libtool was only used by + libblowfish, which was superseded by openssl. + +commit 1857b3c97c261dda9978a67d07b315bb3ca68841 +Author: Guus Sliepen +Date: Mon Nov 20 19:41:13 2000 +0000 + + - Proper initialization of rbltree structures. + +commit 408ca91766088b6c2d38e198b0692bf394b41248 +Author: Guus Sliepen +Date: Mon Nov 20 19:12:17 2000 +0000 + + - Integrate rbl trees into tinc. + +commit 9024e01ce649b89d304a4aa5b1d6ef0b56b5a12c +Author: Ivo Timmermans +Date: Mon Nov 20 18:06:17 2000 +0000 + + Also include process.h + +commit 3cc063d23a6e3a23fd01f03b0bc99825c2b13e16 +Author: Ivo Timmermans +Date: Mon Nov 20 18:05:34 2000 +0000 + + More function and header checks + +commit 59aa15d3d1db4e948113f202dd2183f4bb23970d +Author: Ivo Timmermans +Date: Mon Nov 20 18:02:15 2000 +0000 + + Added this release + +commit 8f273f0ee265c75dd8eea65b2f1cd60a79691cd6 +Author: Guus Sliepen +Date: Sun Nov 19 22:12:46 2000 +0000 + + - Small fixes + +commit cc7c078774db955cece9b263022e6c1ca955fc10 +Author: Guus Sliepen +Date: Sun Nov 19 11:05:59 2000 +0000 + + - Deletion also works now. + +commit 3526f1e151b7a189f075d88c9d88cacaece31d02 +Author: Guus Sliepen +Date: Sun Nov 19 02:04:29 2000 +0000 + + - Fixed a lot of small things. Tested everything except deletions. + +commit 4f68e5b6133480478edba0959cb87d4eb149a8e7 +Author: Guus Sliepen +Date: Sat Nov 18 23:22:44 2000 +0000 + + - Fix tree head/tail upon insertion + +commit 880cd6f1a94ef76ebebc5bd96dd26d62e3d829f4 +Author: Guus Sliepen +Date: Sat Nov 18 23:21:01 2000 +0000 + + - Implemented deletions + - Added rbl_foreach() function + +commit 00e5d572621ad5f0263999dbfbfcb11e023bf48b +Author: Guus Sliepen +Date: Sat Nov 18 18:14:57 2000 +0000 + + - Fixed searching + - Insertion implemented + +commit 7fcc0c6415488ed6ce0089a67ab7cfdd5d0d83ca +Author: Guus Sliepen +Date: Fri Nov 17 10:03:02 2000 +0000 + + - Removed stray @INCLUDE@ (how did that get there?) + - Use 0 instead of FALSE + +commit 44cbd13e5248880b074b5068df14a4634204a1d3 +Author: Guus Sliepen +Date: Fri Nov 17 00:56:49 2000 +0000 + + - Simplified do_detach + +commit 2626c641aa714a8d776f1bb16340586d935aa6b1 +Author: Ivo Timmermans +Date: Thu Nov 16 22:13:09 2000 +0000 + + Use proper prototypes. + +commit 5d1145f2c4b3b8261ca0aa0e89a2daf321640f0b +Author: Ivo Timmermans +Date: Thu Nov 16 22:12:23 2000 +0000 + + Move more functions from tincd.c into process.c. + +commit 485f7a5043a4b3345bd02e5063502603550b4c76 +Author: Ivo Timmermans +Date: Thu Nov 16 22:11:40 2000 +0000 + + Delete struct ifr + +commit 30f34015ee11bbe1106c07e381288a702f12dac5 +Author: Ivo Timmermans +Date: Thu Nov 16 18:06:39 2000 +0000 + + New function: xmalloc_and_zero, which initialises the allocated memory + to all zeroes. + +commit 2764532ea72200d0a27ad2d79e6e299c00c62404 +Author: Ivo Timmermans +Date: Thu Nov 16 17:54:29 2000 +0000 + + Move all process-related functions into process.c. + +commit aa755206da4bcce3261ecd5dbfa41570a0155c73 +Author: Guus Sliepen +Date: Thu Nov 16 09:18:38 2000 +0000 + + - Added balanced tree management stuff as well. (It is not finished yet.) + +commit 7f87c3d9134612041d56180ea7fc3e6c37991f6b +Author: Ivo Timmermans +Date: Wed Nov 15 22:07:36 2000 +0000 + + Keep a list of running children, and in each loop in main_loop(), + check if one has exited. + +commit d9ce5a7f3f5eddb193b6a9b5974c7c49eac41ea1 +Author: Ivo Timmermans +Date: Wed Nov 15 22:04:48 2000 +0000 + + List management and manipulation routines. + +commit e118ba0a648000c48d6a401c9b9249a844d6dbcf +Author: Guus Sliepen +Date: Wed Nov 15 13:33:27 2000 +0000 + + Porting to FreeBSD: + - Reorganized and added some #includes + +commit 596e248bc588323cc7ee751286dbcaf677b5c653 +Author: Ivo Timmermans +Date: Wed Nov 15 01:28:21 2000 +0000 + + Let the output from an executed script in execute_script() go to + syslog, with proper error detection. + +commit bb2495e569fb161b42efd633eb1c471b8222b1fb +Author: Ivo Timmermans +Date: Wed Nov 15 01:06:13 2000 +0000 + + Use the HAVE_OPENSSL_xxx_H defined from m4/openssl.m4 during + configure. + +commit 6fb4a5b6be5628ece9b391b46e7858fdf5957a80 +Author: Ivo Timmermans +Date: Wed Nov 15 01:02:30 2000 +0000 + + Also check for sha.h. + +commit 8eb60d0ccde2f1de6fd917db7300e537f271783e +Author: Ivo Timmermans +Date: Wed Nov 15 00:57:26 2000 +0000 + + Also check for rand.h and err.h. If any of these files does not + exist, try the next alternative path. + +commit c5c8e99afd3fae3868f20b5c7a4f8754498b39ad +Author: Ivo Timmermans +Date: Tue Nov 14 23:18:19 2000 +0000 + + Get rid of the annoying empty line + +commit c467ee02d3ef8bed7ec2cc52cb1527ec60cdc93a +Author: Ivo Timmermans +Date: Tue Nov 14 23:02:08 2000 +0000 + + Oops, small error. + +commit 9ddb37cee0f754ef88a55f692a508010fe18c782 +Author: Ivo Timmermans +Date: Tue Nov 14 22:57:19 2000 +0000 + + Better checks for OpenSSL. I think it can now detect almost all conceivable installations. + +commit 72c3776d6ac103fa25d216c42847ecba3a4f58e5 +Author: Ivo Timmermans +Date: Mon Nov 13 22:29:22 2000 +0000 + + Identify version as 1.0pre4-cvs + +commit 5344832be1126967ff340cf6bd270a377bb8e487 +Author: Ivo Timmermans +Date: Mon Nov 13 22:01:27 2000 +0000 + + Add a check for openssl that accepts explicit file locations. + +commit 5b74909ea070fbd482340dc42193e33366a9dddb +Author: Ivo Timmermans +Date: Thu Nov 9 21:33:18 2000 +0000 + + Add prototype for destroy_queue + +commit 6e27618708233998db7e5886ed9afaa21bb9d938 +Author: Ivo Timmermans +Date: Thu Nov 9 21:29:58 2000 +0000 + + Updates, updates + +commit a91eae538d9cff8aed399a175c0bbc7d744cd22a +Author: Ivo Timmermans +Date: Thu Nov 9 20:59:35 2000 +0000 + + Bop version number to 1.0pre3-1 + +commit e65a93053cca3f8aebf63094cf160835c3108e25 +Author: Ivo Timmermans +Date: Thu Nov 9 20:42:16 2000 +0000 + + Wrapped text to 70 (72?) columns for easy reading + +commit 4310b17be9cefcc1814ddef471e4c5cd8f9f867e +Author: Ivo Timmermans +Date: Thu Nov 9 20:41:13 2000 +0000 + + Final release notes added, also edited release notes for 1.0pre2 to what the announcement on the mailing list looked like. + +commit 16847ea255fa8a7c0ed922af80a2f36b7bdf4b3b +Author: Guus Sliepen +Date: Wed Nov 8 20:52:37 2000 +0000 + + - Make checkpoint tracing a compile time option (off by default) + +commit 55d7b5a2bb1df6f55f0a93e9cfed77c1da337588 +Author: Guus Sliepen +Date: Wed Nov 8 18:05:06 2000 +0000 + + - Add Jamie :) + +commit 5055e1dedc9fe984c497448c1b2ffc4afdf18aa3 +Author: Guus Sliepen +Date: Wed Nov 8 17:56:34 2000 +0000 + + - Applied Jamie Brigg's patch (close sockets after error) + +commit 74326df7adc514798565df0a8719421adbb5fef3 +Author: Guus Sliepen +Date: Wed Nov 8 00:20:06 2000 +0000 + + - Fixed --config + - Show warning when both netname and config directory are given. + +commit f8f1007bf469d44480d95d0d78ddc156d00e059f +Author: Guus Sliepen +Date: Wed Nov 8 00:10:50 2000 +0000 + + Porting to SunOS 5.8: + - More #includes Linux doesn't seem to need + - Don't do unsetenv() on SunOS + - Use a replacement asprintf() in case the OS doesn't support it + It now compiles properly under SunOS. + +commit 56bd0864e4c5680fee59af48228b1ec3fb97b57b +Author: Guus Sliepen +Date: Tue Nov 7 22:33:33 2000 +0000 + + Porting to SunOS 5.8: + - Include all header files necessary + - Check for flock() function + +commit 7d0f82bd4b7044a5151835e25e830fd28dfaaebd +Author: Guus Sliepen +Date: Tue Nov 7 22:02:14 2000 +0000 + + - Open UDP connection for all known hosts. Comments please. + +commit f95cc86d0c14ca4c47e5459af4bb6d1170baa9f5 +Author: Guus Sliepen +Date: Tue Nov 7 21:43:28 2000 +0000 + + Changed execution of tinc-up: + - Do not free() strings that have been putenv()d, see man page of the + latter. + - Do not set IFNAME anymore, it appears that the ioctl to get the name of + the interface does not work at all. Since it is set to NETNAME in case + of tun/tap and it is known beforehand in case of ethertap, there is no + need for it anyway... (though it would've simplified things). + +commit efc3a2a466937da942afc84dde080ba8b1731140 +Author: Ivo Timmermans +Date: Sun Nov 5 02:19:58 2000 +0000 + + Build-Depends on gettext + +commit 698191fd2f512f3618e2d60592fcd57cd750b965 +Author: Guus Sliepen +Date: Sat Nov 4 22:57:33 2000 +0000 + + - Prepended config_ to all configuration option names, because it confused + everything (including myself). + - Use connection oriented UDP sockets for both incoming and outgoing + packets. + +commit afc05797077641baa33b024ffeaafd6cad3ff7a7 +Author: Guus Sliepen +Date: Sat Nov 4 20:44:28 2000 +0000 + + - Simplified ping mechanism. + +commit 2191d894bfd615e8fa7857d031ea630edc12a854 +Author: Ivo Timmermans +Date: Sat Nov 4 17:29:45 2000 +0000 + + Build-depends on libtool + +commit 5019dd879177b5ab9413e5c0aa72a15d0e585acf +Author: Guus Sliepen +Date: Sat Nov 4 17:09:10 2000 +0000 + + - Check for packets that are looping back. + +commit 20dd5aff4d2898d8b59f371671cc110b870fa09c +Author: Ivo Timmermans +Date: Sat Nov 4 17:04:17 2000 +0000 + + Updated Dutch translation + +commit 3f177e9bf02b6121055414a2cc7fd3f4cff01cba +Author: Ivo Timmermans +Date: Sat Nov 4 17:01:55 2000 +0000 + + Add route.c to the list of source files. + +commit ac47586552710425417ed80878f8f853c313b421 +Author: Guus Sliepen +Date: Sat Nov 4 16:54:21 2000 +0000 + + - Forward keys in hex notation, not as binary data. + +commit 3f8f067e8b559366b9b41dee6a4312702c82042f +Author: Guus Sliepen +Date: Sat Nov 4 16:39:19 2000 +0000 + + - Don't forget to set packet cipher for added hosts. + +commit 433858d410c1fedf8d2a5f2b4ecd7c980dd79dd2 +Author: Guus Sliepen +Date: Sat Nov 4 15:34:07 2000 +0000 + + - connlist.c added to translation + +commit 15246df85d6171c92478541a835effb96d6085c4 +Author: Ivo Timmermans +Date: Sat Nov 4 15:32:05 2000 +0000 + + In execute_script: + - add an environment variable NETNAME. + - chdir to the configuration directory before execing the script. + +commit 69618c01385eb7226cd6eab0918d1f30b0ed6c66 +Author: Ivo Timmermans +Date: Sat Nov 4 15:18:58 2000 +0000 + + Do not include the passphrases directory + +commit 417f36a07990ff9bc7de7d4e63e57146bef0dd75 +Author: Guus Sliepen +Date: Sat Nov 4 15:17:02 2000 +0000 + + - Removed manpage for no longer existing genauth. + +commit 3d7189a444fe3efed58dc93a071129007041aebf +Author: Guus Sliepen +Date: Sat Nov 4 14:52:40 2000 +0000 + + - Resolve scriptname after fork() + +commit d38772ebc42f5ad1d946ee89d955f5d43bb2fe8c +Author: Ivo Timmermans +Date: Sat Nov 4 14:16:46 2000 +0000 + + Use putenv() instead of clumsy do-it-yourself in execute_script. + +commit f83803c1bf6557d5af93982e7cd987e151eba401 +Author: Ivo Timmermans +Date: Sat Nov 4 13:25:15 2000 +0000 + + Small change to the way the environment is copied. + +commit ed0bf283e37642f9f7673f664713a16d916bd70f +Author: Guus Sliepen +Date: Sat Nov 4 11:49:58 2000 +0000 + + - Removed even more warnings. + +commit dc699f8b1265deb7606d553e36326527dbd29746 +Author: Guus Sliepen +Date: Sat Nov 4 10:37:27 2000 +0000 + + - Removed unused MAC strip/add functions. + +commit 5065ea32c32e27478d93c00a1bba0c812b7a2b8c +Author: Ivo Timmermans +Date: Fri Nov 3 22:35:12 2000 +0000 + + Warnings removal pass: always include config.h first; add a few + prototypes in the header files. + + This also fixes a few lint errors/warnings. + +commit 73aa7fbf7e1b623398d1bc1493f567ce4d846f22 +Author: Ivo Timmermans +Date: Fri Nov 3 22:33:16 2000 +0000 + + Run the scripts tinc-up and tinc-down from a separate function, which + sets the environment as it should be and checks for errors. + +commit 4ad1e382d6f10acf94ce59d85b80925cee7553a6 +Author: Ivo Timmermans +Date: Fri Nov 3 22:31:55 2000 +0000 + + Save the environment on startup. + +commit 7612c6da3890ce5a0730e4dfde9d5ba07bdbf5b3 +Author: Ivo Timmermans +Date: Thu Nov 2 23:02:49 2000 +0000 + + Minor cosmetic change. + +commit 6a10e42f734e8bec9848a11e73bc2a8211a9f401 +Author: Ivo Timmermans +Date: Thu Nov 2 22:51:16 2000 +0000 + + - If necessary, patch po/Makefile.in from po-Makefile.in.in.diff to + get DESTDIR installation (required to get locales installed + correctly). + - Use dh_perl to get accurate perl dependencies. + +commit ef12849c1a03b3aaf85dd46786d6631f66b104bd +Author: Ivo Timmermans +Date: Thu Nov 2 22:11:18 2000 +0000 + + Oops, and include doc-base.tinc (new file). + +commit 5672ddd6cb9116420a1904f7741fdbed89c2ec54 +Author: Ivo Timmermans +Date: Thu Nov 2 22:10:09 2000 +0000 + + Don't include shlibs, as it no longer exists. + +commit 013fcb0e9f9c0222f4f63ddf42a2f25bfc4a5546 +Author: Ivo Timmermans +Date: Thu Nov 2 22:05:36 2000 +0000 + + Changed a few messages wrt. system calls; updated and changed the Dutch translation a bit. + +commit c444305c0bb965aa515a503406844ceeb483c285 +Author: Ivo Timmermans +Date: Thu Nov 2 21:43:03 2000 +0000 + + Mention fileutils, add a pointer to THANKS for more details + +commit 84c842def74c5d0e9c4a69e4f584fe9eb66eb728 +Author: Ivo Timmermans +Date: Thu Nov 2 21:41:53 2000 +0000 + + Change wsl to Wessel's name and email address in the ChangeLog creation + +commit 5b6815751e581bedd64bfc63aea5b42c746bbceb +Author: Ivo Timmermans +Date: Thu Nov 2 21:40:33 2000 +0000 + + More exhaustive list of changes - perhaps it can be worded differently? + +commit e954fc8f0c731e7116fd27f38c176b83cca519f7 +Author: Ivo Timmermans +Date: Thu Nov 2 21:39:57 2000 +0000 + + Changed `I' to `We' - small change, lots of difference :) + +commit 3db3a41667f90ce74bfd0197fc867cc71a087e50 +Author: Ivo Timmermans +Date: Thu Nov 2 21:38:55 2000 +0000 + + Only check for linux/if_tun.h once + +commit 1b11bcb0128ca65580cbf28ffb16078c81e6d678 +Author: Ivo Timmermans +Date: Thu Nov 2 21:34:45 2000 +0000 + + Added a perl example to turn an IP address into a MAC address. + +commit cadf81fe67aed424504758865c2ea2bb263c76fb +Author: Ivo Timmermans +Date: Thu Nov 2 21:26:51 2000 +0000 + + Do not include $(top_srcdir)/cipher, it does no longer exist. + +commit fd32d771a84765281ea4ab8a5d9dbf5cebfa2911 +Author: Ivo Timmermans +Date: Thu Nov 2 20:29:03 2000 +0000 + + - Synchronized changelog with the package's changelog. + - Changed maintainer email address. + - New file doc-base.tinc. + - Better Build-Depends and Depends lines. + +commit a13d9c9da7434154b33e666c2236844011b87d46 +Author: Ivo Timmermans +Date: Thu Nov 2 20:25:35 2000 +0000 + + This file is no longer needed. + +commit 59528ec892e8b9a599f2b39bf432a3d842e963fe +Author: Guus Sliepen +Date: Tue Oct 31 16:22:49 2000 +0000 + + Removed config file parsing and interface setup. This will be handled by + the tinc-up and tinc-down scripts from now on. + +commit af565d00220b7536b9987c48e2a71459b45027b4 +Author: Guus Sliepen +Date: Tue Oct 31 16:10:17 2000 +0000 + + - Update. + +commit b4c1d4e2d3287acd7ca438455c64e50a2828ad24 +Author: Guus Sliepen +Date: Mon Oct 30 10:19:06 2000 +0000 + + - Fixed some spelling mistakes and terminology here and there. + +commit 4811afa073c871f2a52dfd5139bd0171046365eb +Author: Guus Sliepen +Date: Mon Oct 30 00:22:54 2000 +0000 + + - Small cleanups + - Updated dutch translation + - Updated man pages + +commit b7d4d4c17712e0bb9ee8bd497a2f525b79d5f40d +Author: Guus Sliepen +Date: Sun Oct 29 22:55:15 2000 +0000 + + - Finishing touch: encrypt the meta connections + +commit ec12269355f7979fdc0783dc15d109832f1e83cd +Author: Guus Sliepen +Date: Sun Oct 29 22:10:44 2000 +0000 + + - Use CFB mode for encrypting packets: it works and we don't need padding. + +commit cea3d8f3056d3c6aaaef473443240b8470c8ea2d +Author: Guus Sliepen +Date: Sun Oct 29 10:39:08 2000 +0000 + + - Small fixes + - Do proper key exchange + - Encrypt packets - it works, but there is something wrong with the MAC + header after decryption... + +commit 8fa9bc017d89b53798903df3fa98311067d4de90 +Author: Guus Sliepen +Date: Sun Oct 29 09:19:27 2000 +0000 + + - Removed old encr stuff + +commit a26d371d0df3bee1bdc6e9d7046e949ee29e6de7 +Author: Guus Sliepen +Date: Sun Oct 29 02:07:41 2000 +0000 + + - Updated dutch translation. + - Shutdown properly. + +commit e8391bd49975aa29fa62d6ae1d2d2ee398e0eb3e +Author: Guus Sliepen +Date: Sun Oct 29 01:27:23 2000 +0000 + + - Moved connlist stuff to the proper header file. + +commit 2689690dc37c384c4a022d03ab80f2cfb7fb9553 +Author: Guus Sliepen +Date: Sun Oct 29 01:08:09 2000 +0000 + + - Enforce correct order of authentication requests + +commit 3b9802a542f1fa439321d3386763ec33989194b5 +Author: Guus Sliepen +Date: Sun Oct 29 00:46:43 2000 +0000 + + - Hit people who can't figure out subnet address/mask pairs with a + (clue)bat. + +commit 7398002ade1397bd857953f009f4aed65ffc9218 +Author: Guus Sliepen +Date: Sun Oct 29 00:24:31 2000 +0000 + + - Fixed ans_key_h + - Removed tapsubnet configuration option. + +commit 35932fe6c8cb481eb687f98424776ce429570c21 +Author: Guus Sliepen +Date: Sun Oct 29 00:02:20 2000 +0000 + + - Very big cleanup. + +commit db21f015161aac244ec5600c4d0ff685549892c2 +Author: Guus Sliepen +Date: Sat Oct 28 21:52:22 2000 +0000 + + - Override destination ethernet address on incoming packets with + FE:FD:00:00:00:00 + +commit 8738c007b15eea024bc4ca6ee0f972b2f5bf259f +Author: Guus Sliepen +Date: Sat Oct 28 21:25:21 2000 +0000 + + - Fixed offsets when reading/writing from/to tap device + +commit f25868fd2b58bc0b350a5cfaf342480f28f804cf +Author: Guus Sliepen +Date: Sat Oct 28 21:05:20 2000 +0000 + + - Lots of small fixes + - Exchange subnets on acknowledgement of connection + - Do proper lookup when incoming packets from tap + - off-by-a small number-error when reading/sending tap packets + +commit ba6b8005ebe3a53877590c242ff581dc5dee5eae +Author: Ivo Timmermans +Date: Sat Oct 28 19:34:53 2000 +0000 + + Skip the check for Linux kernel sources + +commit d47d5932a3bbc4940aa6453ebfe617ef330783c8 +Author: Guus Sliepen +Date: Sat Oct 28 16:41:40 2000 +0000 + + - Updated subnet list handling. Subnets are added to two lists now, the + owner's list and a global list. It is all fucked up but it probably + works anyway, good enough for pre3 :). + +commit 9c2f805255fa36b05e8fe9391f639581d938b653 +Author: Guus Sliepen +Date: Tue Oct 24 15:46:18 2000 +0000 + + - Lots of little stuff modified + - Succesfully reads in subnets from host config file now and adds them to + the list. + +commit 60401d99b18ae01d91ca65faf8d2b32fac2b4474 +Author: Ivo Timmermans +Date: Mon Oct 23 21:56:56 2000 +0000 + + Oops, echelon change committed to cabal... :) + +commit c46e84837d1c84a8590e0e3507227670368884a7 +Author: Guus Sliepen +Date: Mon Oct 23 13:52:54 2000 +0000 + + - route.c will contain the routing logic. + +commit 76d794eaf7c1664a47f4d0080fcd80e4a551740b +Author: Ivo Timmermans +Date: Sun Oct 22 13:47:41 2000 +0000 + + read_server_config: Check for result of read_config_file. + +commit 56d8e862409ae91c63a27968b01a48a94aafb205 +Author: Ivo Timmermans +Date: Sun Oct 22 13:37:15 2000 +0000 + + Include linux/sockios.h and net/if.h anyway, regardless of the value of HAVE_TUNTAP. + +commit 52b842f8076d507d3a6ea07045d085ae21d1aa10 +Author: Guus Sliepen +Date: Sat Oct 21 11:52:08 2000 +0000 + + - Fixed all debug levels. + - Seed PRNG before generating a challenge + - Strange thing in challenge decryption: it fails if first bit is set!? + +commit 73f7efddd723b25c1477ec1139dc7211307ff660 +Author: Guus Sliepen +Date: Fri Oct 20 19:46:58 2000 +0000 + + - Removed last reference to genauth from Makefile.am + - Tinc spawns tinc-up and tinc-down scripts which can be used to configure + the network device. The environment variable IFNAME is set to the name + of the interface. + +commit fba19c30c92d39e74f5fd5594053793b036f30f4 +Author: Guus Sliepen +Date: Fri Oct 20 16:49:20 2000 +0000 + + - Made Makefile.am stub for doc/es/ + - Merged genauth into tincd + - Updated dutch translation + +commit 97ec5685b92ea727fe8f8b4bb8cf289a20f8580b +Author: Ivo Timmermans +Date: Fri Oct 20 16:44:32 2000 +0000 + + Generalized list and hash handling functions + +commit 699e159a7a1711034f1d16d68ad1974a82e12dfc +Author: Ivo Timmermans +Date: Fri Oct 20 16:43:13 2000 +0000 + + New function: xalloc_and_zero() + +commit 4059151732afb7d8fb52121d80e54f2ee325d30e +Author: Ivo Timmermans +Date: Fri Oct 20 16:42:22 2000 +0000 + + Add all the new files to the sources list for the utility library + +commit 9f64499e40a95a8c05c82924219517aa017fc411 +Author: Guus Sliepen +Date: Fri Oct 20 15:34:38 2000 +0000 + + - tinc now really does public/private key encryption! It even works, whee! + +commit 71f05ff8956cb2e62181fcef763709b0de8faa68 +Author: Ivo Timmermans +Date: Thu Oct 19 20:56:49 2000 +0000 + + Generalized error handling functions + +commit 95f4e8620ef8e2cdec1cc3b2ccb8cc8e3ce94e40 +Author: Ivo Timmermans +Date: Thu Oct 19 20:39:04 2000 +0000 + + Add check for the syslog function + +commit 430e14162918864f9f18aad0ec0badc1ccc3e01f +Author: Ivo Timmermans +Date: Thu Oct 19 17:29:22 2000 +0000 + + Changed changelog + +commit d5fd1344e668da0bc8536e798f347041d5377843 +Author: Guus Sliepen +Date: Thu Oct 19 14:42:00 2000 +0000 + + - Seed the PRNG using /dev/random before generating the keys. + +commit 30df5e95dbe585c6076d743d3771a42ad7c78590 +Author: Ivo Timmermans +Date: Wed Oct 18 20:12:10 2000 +0000 + + Bring head revision up to date with cabal (try #3) + +commit 571cfb5846c710a0a3cdbdddce8936f6b34f1cf1 +Author: Ivo Timmermans +Date: Wed Oct 18 19:44:11 2000 +0000 + + Get the head revision up to date with cabal + +commit e75315dae609f32041ca5ed939fd2a1b69d32d3e +Author: Ivo Timmermans +Date: Tue Oct 17 10:15:20 2000 +0000 + + Don't declare cp_file and cp_line in xmalloc() + +commit 31c543ad0fa1d19667a03a9bd183c668def23da0 +Author: Ivo Timmermans +Date: Tue Oct 17 10:14:25 2000 +0000 + + Process subdir es/ + +commit 20301888b7a0a206119d2cfc48ccf1a667bb4add +Author: Guus Sliepen +Date: Mon Oct 16 19:04:47 2000 +0000 + + - More fixing. Tinc daemons can now even create activated connections. + +commit bb3d18d56fa0dd2bc5146d0a0044b6ef0880bdb4 +Author: Guus Sliepen +Date: Mon Oct 16 16:33:30 2000 +0000 + + - Fixing little things + - Two tinc daemons can connect to eachother now (but they disconnect right + after the ACKs). + +commit 6e32b870ee127555888a115163922362c99009f9 +Author: Ivo Timmermans +Date: Mon Oct 16 11:35:10 2000 +0000 + + Output doc/es/Makefile + +commit baeac83bf465a47d46082e1de40ea14dcf1d39af +Author: Guus Sliepen +Date: Sun Oct 15 20:30:39 2000 +0000 + + Corrected #ifdefs for tun/tap support. + +commit 782171fd2c59b7cc5568d2d4b33ce041834710ec +Author: Ivo Timmermans +Date: Sun Oct 15 20:21:27 2000 +0000 + + Really #include the if_tun.h files now + +commit 8a54c51238672abd7a72c1dbdc7d17b9956a0d35 +Author: Ivo Timmermans +Date: Sun Oct 15 20:13:55 2000 +0000 + + Linearized checks for if_tun.h + +commit e5130495d7d4083d58ab76c26001aa27f5fc13db +Author: Ivo Timmermans +Date: Sun Oct 15 19:53:15 2000 +0000 + + Wrap the tun/tap code in #ifdef HAVE_TUNTAP + +commit 3b455b8f318528206b08121f5ce93d16e4ea01df +Author: Ivo Timmermans +Date: Sun Oct 15 17:26:31 2000 +0000 + + Add checks for the presence of the universal tun/tap device driver. + +commit 85adeef21275633b78a234b2660cbe3bc9dd2c33 +Author: Guus Sliepen +Date: Sun Oct 15 00:59:37 2000 +0000 + + - The daemon actually runs now (somewhat) + - Added support for tun/tap driver (autodetect!) + - More sophisticated checkpoint functionality + - Updated dutch translation + +commit 97ce045189e330e121873d1b4be1959c60062cbb +Author: Ivo Timmermans +Date: Sat Oct 14 22:22:06 2000 +0000 + + Add CVS id lines + +commit 2e159d0139e77041ad82e96bf0abef6aaf64a258 +Author: Ivo Timmermans +Date: Sat Oct 14 22:17:29 2000 +0000 + + Fix `Requirements'-section for GMP and OpenSSL libraries. + +commit 1d5bb49f261b4346b5a440ae6bbf58fe391ea46e +Author: Ivo Timmermans +Date: Sat Oct 14 22:00:09 2000 +0000 + + Update Depends lines to reflect the dependencies on OpenSSL + +commit e9635ae38e0e2e3eb92568a1e234f8348856dd69 +Author: Guus Sliepen +Date: Sat Oct 14 17:04:16 2000 +0000 + + - Second fixing-things pass: it even links now. + - Lots of FIXME comments added to the source code. + +commit 6a8c2e346e6125e58aab428e6730c18a949abe12 +Author: Ivo Timmermans +Date: Fri Oct 13 23:34:56 2000 +0000 + + Don't look for GMP header files + +commit f18e30dab3c208fd353af11e365791035534f444 +Author: Ivo Timmermans +Date: Fri Oct 13 23:30:11 2000 +0000 + + Updated new requirements, pointers to the manual + +commit a96f2f0fc8a02593d4cda5976df3c76fc5c99eae +Author: Ivo Timmermans +Date: Fri Oct 13 23:29:35 2000 +0000 + + Link with OpenSSL, forget libGMP + +commit 183a8edd22ba4bc682392c73ae02fc9e121eda68 +Author: Guus Sliepen +Date: Wed Oct 11 22:01:02 2000 +0000 + + - Fixing-things pass: every source file compiles into an object file now, + but linking tincd does not work yet (must link with openssl libs and + define some missing functions). + +commit 6e39481d8f2406e60b5e329ace08b5a005d5cc43 +Author: Guus Sliepen +Date: Wed Oct 11 13:42:52 2000 +0000 + + - Generalized config file parsing to support multiple configuration trees. + +commit 451e9e3e7a968151de541de68603a01f0922b415 +Author: Guus Sliepen +Date: Wed Oct 11 12:07:27 2000 +0000 + + - Changed genauth to produce rsa keypairs instead of random passphrases. + +commit 950fb8e916b0e248dcaa72c96859acd6046683aa +Author: Guus Sliepen +Date: Wed Oct 11 10:35:17 2000 +0000 + + Big and bad commit of my current tree... + - Added seperate file for connection list handling + - Updating everything to use connlist, meta and subnet files + - Removed dependency on libgmp + - Lots of other stuff... + +commit 73d0dcfcc1019ee745a422982b4e3ede9d59dd91 +Author: Guus Sliepen +Date: Wed Oct 4 15:09:57 2000 +0000 + + Removing cipher directory (all will be covered by OpenSSL). + +commit 2228b16159a7aff64e6559ee1635716154e67fe6 +Author: Guus Sliepen +Date: Sun Oct 1 03:21:49 2000 +0000 + + - Added subnet handling code + - Other small changes to header files + +commit 676b1c0ea111406eb94a74ae12878dfd5ad9f56d +Author: Ivo Timmermans +Date: Wed Sep 27 20:32:29 2000 +0000 + + Many updates, parts rewritten, added, shuffled around. + +commit c78a204f06182f50b0812c8e4fef6163e82097bf +Author: Guus Sliepen +Date: Tue Sep 26 14:06:11 2000 +0000 + + - Added meta.c which contains functions to send, receive and broadcast + metadata. It will also handle encryption and decryption, and possibly + compression and checksumming. + - Moved request dispatcher to protocol.c. + +commit 2c412009e5805f04c650889b19fcb38531f2aa50 +Author: Guus Sliepen +Date: Mon Sep 25 20:08:50 2000 +0000 + + - Very detailed example of the authentication phase. + +commit 361690b18c1f5464db7b9cef235c648784780dfb +Author: Guus Sliepen +Date: Fri Sep 22 16:20:07 2000 +0000 + + - Removed options "string" stuff. It was a bad idea... + - free() everything that is allocated. + +commit 5afc1e98f436c4a2ed5da4b64293275b09632c79 +Author: Guus Sliepen +Date: Fri Sep 22 15:06:28 2000 +0000 + + - Severe code reduction and simplification of challenge requests + - "Finished" [add|del]_subnet_h + - Added lots of sanity checks to [add|del]_host_h + +commit 5d0b3516d5e8a46ca2268bdb32657b72295501ec +Author: Guus Sliepen +Date: Sun Sep 17 21:42:05 2000 +0000 + + - Updated authentication scheme. + - Removed all trailing spaces from all lines. + - Added things to add_ and del_subnet_h. + +commit 84f210edd9e72a65ca8b034a0d3bbc12e506c580 +Author: Guus Sliepen +Date: Sun Sep 17 20:11:59 2000 +0000 + + - Included authentication scheme from protocol.c + - Added a few comments about the symmetric cipher. + +commit 2863134a4113b7805a662f45a21a1be0ae9606cb +Author: Guus Sliepen +Date: Sun Sep 17 19:57:39 2000 +0000 + + Added document about the used cryptographic algorithms and the reasons + behind them. Feel very free to comment on this! + +commit 33a5b4547141c11b5128d9f4863fcf6cf8e33452 +Author: Ivo Timmermans +Date: Sun Sep 17 10:28:57 2000 +0000 + + Added Spanish translation of the docs by Matias Carrasco + +commit 7f3ab38c222809b15da2fe8dd655d35432eaafe0 +Author: Ivo Timmermans +Date: Fri Sep 15 12:58:40 2000 +0000 + + Second round of fixes + +commit ed397b6ac676329b237e219c806143cccf456b3c +Author: Ivo Timmermans +Date: Thu Sep 14 21:51:21 2000 +0000 + + First round of needed fixes after the overhaul + +commit 296171d115614d61480d896cd77898f5393c191d +Author: Ivo Timmermans +Date: Thu Sep 14 14:34:38 2000 +0000 + + New directive: Name. + +commit d335c6d0d7328fd86154dc60b22deb7953ab0228 +Author: Ivo Timmermans +Date: Thu Sep 14 14:32:34 2000 +0000 + + Added some structures and types that are needed for the overhaul. + +commit c04c84c98055c6b9e9e7890d3992648a3b715a1a +Author: Guus Sliepen +Date: Thu Sep 14 11:54:51 2000 +0000 + + - Lots of small changes. + +commit cd6695df82c55454a3f5b644f5c20a8ed31e7c97 +Author: Ivo Timmermans +Date: Mon Sep 11 11:40:46 2000 +0000 + + Better checks for SunOS libraries + +commit 9c75350ac6c14886195b6d368af2f118fd5d60e0 +Author: Guus Sliepen +Date: Mon Sep 11 10:05:35 2000 +0000 + + - Fixed modulo in keylength check + - Updated header file to reflect new protocol code + +commit 76b5f255c6cb0c5dfb5a870c371ec6f7c7879bb2 +Author: Guus Sliepen +Date: Sun Sep 10 23:11:37 2000 +0000 + + - Some key exchange stuff. (Last commit before going to bed.) + +commit 675ed08a71ec28d8ae99e10e993d5c7cb717f017 +Author: Guus Sliepen +Date: Sun Sep 10 22:49:46 2000 +0000 + + - Lots of functions added for the new protocol. + +commit 9926dae4646a96ee647a2ca7d728e91600dd1cca +Author: Ivo Timmermans +Date: Sun Sep 10 21:57:11 2000 +0000 + + Add Guus' name and shift out old protocol requests + +commit 74157d3f4501f4d1ec913a986b7167d2b847e41e +Author: Ivo Timmermans +Date: Sun Sep 10 18:37:46 2000 +0000 + + Correct filenames for passphrases given in the example + +commit 6b9ec9ed1e818d5e50dda4418ffb4d02c898bcba +Author: Guus Sliepen +Date: Sun Sep 10 16:15:35 2000 +0000 + + - Added more function skeletons for the new protocol. + +commit 28cc30159565a7eda4f66215a5994d84b46b47ad +Author: Guus Sliepen +Date: Sun Sep 10 15:18:03 2000 +0000 + + - New protocol. Will break everything else for now. + +commit 7884d3ecaf78006b3f288d99f10ef541fc97087e +Author: Ivo Timmermans +Date: Sun Sep 10 15:16:07 2000 +0000 + + Support for -lsocket and -lnsl on SunOS + +commit 14554e6f421e881b01be20879e9279545f375154 +Author: Ivo Timmermans +Date: Sun Sep 10 15:15:38 2000 +0000 + + Include openssl/blowfish.h + +commit 45ea3ca432a031ff1b8072d934709aadaae12534 +Author: Ivo Timmermans +Date: Sun Sep 10 15:07:41 2000 +0000 + + Updated text, removed protocol flowchart + +commit ae17572e6b94c6e7a2123ddeb45bf66d389ac7a0 +Author: Ivo Timmermans +Date: Sun Sep 10 15:05:45 2000 +0000 + + Link with OpenSSL crypto libraries instead of own blowfish library + +commit 4dde583bc91985c3ff19ac1d1f1bc791b50658ff +Author: Guus Sliepen +Date: Wed Sep 6 11:49:05 2000 +0000 + + - Use strerror() instead of sys_errlist[] for increased portability + (Needed for SunOS) + +commit 66e535a729dd5a9e45600ab74dc19c2b4062ee96 +Author: Ivo Timmermans +Date: Sun Aug 27 11:05:47 2000 +0000 + + Changed CVSROOT path in `make ChangeLog' + +commit 39e159fbe6bbffb3229542258f956fc412bd871c +Author: Guus Sliepen +Date: Tue Aug 22 14:55:04 2000 +0000 + + Fix rules (thanks to Laurence) + +commit 47992fe59f4c1b4116e4872d59251b143edc6763 +Author: Ivo Timmermans +Date: Mon Aug 21 20:35:47 2000 +0000 + + Added a rule to create an rpm + +commit d9af4f32330a495789d8eecdabbbb49928f074a7 +Author: Guus Sliepen +Date: Mon Aug 21 12:50:15 2000 +0000 + + Updated tinc.conf manual. + +commit 94a32c4b2d2ff5d4bb1376fe5ec96c6dec55f630 +Author: Ivo Timmermans +Date: Sun Aug 20 23:08:17 2000 +0000 + + Also chomp $VPNMASK + +commit 861e808fef1f6796d837215f9ad135fb4cb50f5c +Author: Ivo Timmermans +Date: Sun Aug 20 23:07:18 2000 +0000 + + (Quoting Laurence Lane:) + + The prefix is correctly set for /usr, but is + overridden with the current make install. DESTDIR is the clean way to + relocate the installation into the debian/tmp build dir. + +commit d3f41b803bf3c38910f24f1f268f182466723149 +Author: Guus Sliepen +Date: Fri Aug 18 14:45:38 2000 +0000 + + Updated the manual: + - incorporated comments from Stefan Hartsuiker + - updated configuration variables section + - added some text about key types + +commit 5c78e158d414595ab32399645678a43bb4469be6 +Author: Guus Sliepen +Date: Fri Aug 18 11:17:09 2000 +0000 + + Commented on some size calculations. + +commit d2c062a0a440d2871939b4ffdc2dbb137a4d45e7 +Author: Guus Sliepen +Date: Thu Aug 17 17:22:01 2000 +0000 + + Ran update-po and updated dutch translation. + +commit 3831f51a53088bfcc1d148fd54b3083afe7fde32 +Author: Guus Sliepen +Date: Thu Aug 17 16:51:08 2000 +0000 + + Fixed all sprintf() spl01ts. + +commit 9acd4379f705edc8b736e21b9011434e63f7dd95 +Author: Guus Sliepen +Date: Wed Aug 9 14:02:16 2000 +0000 + + - Added two extra configuration options, Interface and InterfaceIP, to + bind the listen socket to a network device or a specific IP. + +commit f6d79366b3efaef0a458717aac5e6754630dd434 +Author: Guus Sliepen +Date: Wed Aug 9 09:34:21 2000 +0000 + + - Reinstated O_NONBLOCK for meta socket + - Set SO_KEEPALIVE on meta socket + +commit 3cfc9424f255c26f2a7775b6fa059f1e3e47a76e +Author: Guus Sliepen +Date: Tue Aug 8 17:07:48 2000 +0000 + + - Moved TCP packet reception to meta handler: less kludgy and less buggy! + +commit e092d15be17db1d69c37f2aba46c66e03631c099 +Author: Guus Sliepen +Date: Tue Aug 8 14:54:57 2000 +0000 + + - Added date/time of build and protocol number to --version output. + +commit ff87f385c3a81499eff6b848aed8548cf6e5132e +Author: Guus Sliepen +Date: Tue Aug 8 13:47:57 2000 +0000 + + Removed calling add_queue for tcponly packets. + +commit ac73c72488dd8b33464fac1f392e89df48f7a23b +Author: Guus Sliepen +Date: Tue Aug 8 08:48:50 2000 +0000 + + Fixed PACKET read loop. + +commit b6997b0050e78a2f2e517beba3ff01d9232b3d1f +Author: Guus Sliepen +Date: Mon Aug 7 16:27:29 2000 +0000 + + - Lots o' buglets fixed (-Wall helps) + - Made TCPonly work :) + +commit fdc6a2f106315cd9ed22943d8c0bd279631e66b4 +Author: Guus Sliepen +Date: Mon Aug 7 14:52:16 2000 +0000 + + - Added experimental hackish tunneling-over-TCP support. + Just use TCPonly = true in the configuration file. + +commit 42455e97a057fb4386f9d8fb2f8963b2ec6ddf24 +Author: Guus Sliepen +Date: Sun Jul 2 13:40:57 2000 +0000 + + - Fixed typo. + +commit b1ecbf977722ec473fc8007acd39eb0de581de1a +Author: Guus Sliepen +Date: Sun Jul 2 13:36:18 2000 +0000 + + - Delayed address resolving for ConnectTo lines in configuration file to + allow DynDNS to work without restarting tincd. + +commit 6642ec2ea4e97a2fb3e737653ab1b9351ac759e9 +Author: Guus Sliepen +Date: Sun Jul 2 12:48:04 2000 +0000 + + - Updated THANKS file + +commit e0de803c7e80621600409a0c760241a3d97617bd +Author: Ivo Timmermans +Date: Sun Jul 2 12:41:03 2000 +0000 + + Include the Spanish translation in the distribution/build process. + +commit 721d85f77277813345bdb63a610e984cec996613 +Author: Guus Sliepen +Date: Sun Jul 2 12:35:28 2000 +0000 + + - Added Spanish translation from Enrique Zanardi. + +commit e821a22876d15c921a4c1fbc0f792d83e90916f6 +Author: Guus Sliepen +Date: Sat Jul 1 14:40:56 2000 +0000 + + - Forgot to mention ourselves in the tincd manual page! :) + +commit 09f4ec190119298187cec09dd5049af8fd8bad94 +Author: Guus Sliepen +Date: Sat Jul 1 14:32:24 2000 +0000 + + - Updated PROTOCOL (a bit) + - Included a real tincd.8 describing the options, signals, debug levels + and files used by tincd. + +commit d3ea434b3684093d6d160b8077c1f51a50ac7f61 +Author: Ivo Timmermans +Date: Sat Jul 1 10:39:28 2000 +0000 + + Autogenerated by gettextize. + +commit 1b28f88808b9ac3193cf9a0db7a81a89eed8b4ef +Author: Guus Sliepen +Date: Sat Jul 1 07:49:21 2000 +0000 + + - Removed a single unused bit from status_bits_t. + +commit 7fdc881b86fe379216f09dd5703bb88d398c87a8 +Author: Wessel Dankers +Date: Sat Jul 1 07:29:32 2000 +0000 + + Added architecture section, made a start with the kernel section. + ToDo: install tinc myself to see if everything is as I say =) + +commit 8ec648abf438bb5fcfe84e3a1c6a31192dc32b2e +Author: Guus Sliepen +Date: Fri Jun 30 22:38:58 2000 +0000 + + - Added documentation for the protocols (most important the meta protocol) + used by tinc. + +commit ce72275a4342ff4e21d21bb740ee88dca1ddb5f1 +Author: Wessel Dankers +Date: Fri Jun 30 21:16:52 2000 +0000 + + Grrr, recommit + +commit bbbdda255d6e7a8730906a1b6c2bfdd2ce1b94cf +Author: Wessel Dankers +Date: Fri Jun 30 21:11:34 2000 +0000 + + This file is now only in the CABAL revision. + +commit 28a140668f892873b01afe104d21db4adb8fd8c7 +Author: Wessel Dankers +Date: Fri Jun 30 21:09:32 2000 +0000 + + More about keys + +commit 1a1ebefd572c18d6af187750847b024ce07551ae +Author: Guus Sliepen +Date: Fri Jun 30 21:03:51 2000 +0000 + + - Made tinc even more silent if no -d flag is given at all. + +commit 79ad21c392e56cad2556e7693b9639d8e2346a59 +Author: Wessel Dankers +Date: Fri Jun 30 20:57:30 2000 +0000 + + Added extra bit about keys. + +commit 8309e9b869c25677d674f5cecb8b7ac5469d1758 +Author: Wessel Dankers +Date: Fri Jun 30 20:50:47 2000 +0000 + + File added to CABAL (hopefully) + +commit 5cd0f940c7334959534d3ab4e1f3c7cac67ee38a +Author: Wessel Dankers +Date: Fri Jun 30 20:42:07 2000 +0000 + + added bit on config file, split up sections, added Id: tag + +commit 6f5aac4e39cd6fb2fb76c0121de3f3782f72f18e +Author: Wessel Dankers +Date: Fri Jun 30 20:16:15 2000 +0000 + + Initial revision. Lots of loose ends, not usable yet. + +commit c5737583c8a5d099a71174e1eb997e0972ae03e9 +Author: Guus Sliepen +Date: Fri Jun 30 12:41:06 2000 +0000 + + - Instead of logging an error when remote end closes the connection, + we print a nice message if appropiate debug level is set. + - If we get ADD_HOSTs or DEL_HOSTs for ourself, then connection lists + are really messed up. We restart, and hope our problems go away. + +commit 24874d0806bac5d75663ea9de67a71171bfc97b6 +Author: Guus Sliepen +Date: Fri Jun 30 11:45:16 2000 +0000 + + - Removed segfault bug in conf.c (must have been there for ages!) + - Made main_loop() signal proof + - #defined MAXTIMEOUT (15 minutes) + - If something really really bad happens, close all connections, wait + for MAXTIMEOUT seconds, and then restart tinc + +commit 0f9ad1f047efec53590dc43f07d225e5f20456cb +Author: Guus Sliepen +Date: Thu Jun 29 19:47:04 2000 +0000 + + - Fixed memory leak. + - Implemented SIGHUP configuration file reloading. + - Other small changes. + +commit 18c85caac36f7236454deef11b9eba74328dbd96 +Author: Guus Sliepen +Date: Thu Jun 29 17:09:08 2000 +0000 + + - New semantics for BASIC_INFO, ADD_HOST and DEL_HOST requests. This will + improve connection list consistency, ensures the tree property, and + allows for recovery from situations where track of connections is lost. + +commit e8e7379311ca3bf6e1fdd7d0f477a43e510e2317 +Author: Guus Sliepen +Date: Thu Jun 29 13:04:15 2000 +0000 + + - Removed all IP_ADDR_S macros, because gettext doesn't like them. Each + connection now has two hostnames: real_hostname (replacing the old), + and vpn_hostname. In those places where hostnames really aren't usefull + IP_ADDR_S has been replaced by %d.%d.%d.%d. + +commit e0ddb638d1fb7abf19969ac887f3b7a2bd8225c1 +Author: Guus Sliepen +Date: Thu Jun 29 07:11:23 2000 +0000 + + - Updated Dutch translation. + +commit 0a155580a3d55633bbc3a1e7dcbe8906f41913be +Author: Ivo Timmermans +Date: Wed Jun 28 21:06:40 2000 +0000 + + Oops, and mention Guus too. + +commit f2c9e7f3bbada3fbfe80f622ebc06540afb60c21 +Author: Ivo Timmermans +Date: Wed Jun 28 21:01:45 2000 +0000 + + Removed Free Software Foundation copyright, because Guus Sliepen contributed significantly. + +commit 3df9b89204626afdd514d5b7323801af76a5cd26 +Author: Guus Sliepen +Date: Wed Jun 28 14:34:40 2000 +0000 + + - Added log message when SIGCHLD is received ("thanks" to Ivo van Dong) + +commit 8c6c60adf3d5942c6368bafe9a4d4377ffad1abe +Author: Guus Sliepen +Date: Wed Jun 28 13:41:02 2000 +0000 + + - Fixed a message in nl.po + - Woops, we forgot to send our connection list to our uplink when we + connect to it... Fixed. + +commit 63c5192d570e2ba5952b4e5a807e4ab4d6fdad76 +Author: Guus Sliepen +Date: Wed Jun 28 11:39:40 2000 +0000 + + - Fixed missing " in nl.po + +commit ea40d3f1a05e9edf4ccfb77f4e9e0f8355e94a83 +Author: Guus Sliepen +Date: Wed Jun 28 11:38:01 2000 +0000 + + - Fixed some spelling errors. + - Paar zpelvautjes gerepareerd, en de Nederlandse vertaling weer bij de + tijd gebracht. + +commit dba2995db73313b1c0a56ce13395dac0bc7571a5 +Author: Guus Sliepen +Date: Wed Jun 28 10:11:10 2000 +0000 + + - Extra check op EINTR bij inlezen requests + +commit 4ee53e7dac93d1edad8664edffdfaf142438b85d +Author: Guus Sliepen +Date: Tue Jun 27 21:05:07 2000 +0000 + + - Fixes a silly little insignificant buglet. + +commit 070ad08118a33755835b31174e2b04e84f75556e +Author: Guus Sliepen +Date: Tue Jun 27 20:55:12 2000 +0000 + + - Purge old connections that are ADD_HOSTed. + +commit 4aeaea5e590fbd38aebbfacf2672304d04ba4ad1 +Author: Guus Sliepen +Date: Tue Jun 27 20:10:48 2000 +0000 + + - Improved handling of errors on connection attempts. + +commit 45a28b1e893d4da9d7977945a35ec6a8e4554830 +Author: Guus Sliepen +Date: Tue Jun 27 15:08:58 2000 +0000 + + - Fixed indirectdata=no problem + - Added support for multiple ConnectTo lines in tinc.conf. + +commit 4faed1b8546563def6a426c563cec2a26d927eda +Author: Guus Sliepen +Date: Tue Jun 27 12:58:04 2000 +0000 + + - Fixed KEY_CHANGED notification. A lot of notify_others() calls were + wrong (first two arguments swapped). Should probably be doublechecked. + - Don't retry to connect to hosts with different protocol versions. + +commit 04cb206298df033d254ca007205d13f9a670c402 +Author: Guus Sliepen +Date: Mon Jun 26 20:30:21 2000 +0000 + + - Moved all connection messages to debug level 1, without -d's only the + startup message will be logged. + - Fixed DEL_HOST rebound. + +commit 783c8298610d5670f6e118f49bd3d1fdfa61ae1d +Author: Guus Sliepen +Date: Mon Jun 26 19:39:34 2000 +0000 + + - Indirectdata finally REALLY REALLY works now! + - More precise debug messages + +commit b3681ebf6c255daf082ed254282cbf493af8fa93 +Author: Guus Sliepen +Date: Mon Jun 26 17:20:58 2000 +0000 + + Fixes some hostlookups. Fixes indirectdata for real now (hopefully). + +commit 03af6d8c8056d0b7006f7d8fb19bb33d303ac8f9 +Author: Ivo Timmermans +Date: Sun Jun 25 20:52:29 2000 +0000 + + Version 1.0pre3. + +commit a473ece8a0d83be5f7992888a6a3ff938dc4fb72 +Author: Guus Sliepen +Date: Sun Jun 25 16:39:17 2000 +0000 + + - More verbose connection list + - Added "myself" as hostname when logging indirect ADD_HOSTs + +commit f1f901112e44beaecd3037dae27407ea83edd86e +Author: Guus Sliepen +Date: Sun Jun 25 16:20:27 2000 +0000 + + Hostlookup() is actually being called now. + +commit 54079bdf03e74c686f556f86082b9d14b5be227c +Author: Guus Sliepen +Date: Sun Jun 25 16:01:12 2000 +0000 + + Hostnames are back! + +commit e4b586ed070908f866a450292f9759004e6affa8 +Author: Guus Sliepen +Date: Sun Jun 25 15:45:09 2000 +0000 + + - Log possible spoofing attacks. + - Don't broadcast DEL_HOSTs for hosts that haven't been activated yet. + - If a host sends a TERMREQ, deactivate them. + +commit 9a1103a7be86de3da5548fd6446e6e4fe554cc08 +Author: Ivo Timmermans +Date: Sun Jun 25 15:42:40 2000 +0000 + + Changed version number to 1.0pre3. + +commit d8d2b83350e890adae9c9cede6e21ea4169abe00 +Author: Ivo Timmermans +Date: Sun Jun 25 15:42:40 2000 +0000 + + Changed version number to 1.0pre3. + +commit 7648bc606596851942dd6437ddaa93f53ab20f09 +Author: Guus Sliepen +Date: Sun Jun 25 15:22:16 2000 +0000 + + Added CVS Id tags to header files. + +commit 7f7e158aae8df5c65211bcfa82516e7c243cdd2e +Author: Guus Sliepen +Date: Sun Jun 25 15:16:12 2000 +0000 + + Large cleanup: + - Removed hostname lookup (it blocks, and you can always do it yourself) + - Reorganized debug levels (after hints from Axel M�ller): + 0 Startup message and errors + 1 Connection logging + 2 Meta protocol information + 3 Verbose meta protocol (includes copy of transmitted requests) + 4 Packet information (logs transmission/errors of UDP packets) + 5 Verbose packet information (every single byte, not implemented yet + to protect ourselves from filling up /var/log directories) + - Made log messages more consistent + +commit 3c54a513b0c0a3acac60e03403ab4abfa0688c62 +Author: Guus Sliepen +Date: Sat Jun 24 12:35:42 2000 +0000 + + If we have "indirectdata" flag set, we only send data to our uplink. + +commit d8e2f7104c3203edbf23d2349656c765a4310dee +Author: Guus Sliepen +Date: Fri Jun 23 19:27:03 2000 +0000 + + First step for implementation of the "indirectdata" directive. This should + allow _leaf_ tincds to be behind firewalls. + The protocol has changed and is INCOMPATIBLE with previous versions. The + PROT_CURRENT value has been incremented. + +commit 33c3a25a66251606cbf20d3bd5b392d8837116e3 +Author: Ivo Timmermans +Date: Sat Jun 17 20:55:54 2000 +0000 + + Configuration directive `IndirectData'. + +commit 1c8adb5e1f12894fc9a478fbf29678fb662e03ab +Author: Ivo Timmermans +Date: Sat Jun 17 20:30:44 2000 +0000 + + Merge changes from 1.6-1.8. + +commit 0d167e1f5d8778674a9a77b2256050e3afe2896e +Author: Guus Sliepen +Date: Sat Jun 17 08:30:45 2000 +0000 + + Added another semicolon for bash2 compliance (thanks to Jamie Briggs) + +commit 00f316810aa808368cdff620b1a1efdd1fcade20 +Author: Guus Sliepen +Date: Fri Jun 16 05:44:26 2000 +0000 + + Applied patch from Jamie Briggs for bash2 conformance. + +commit ef294a69678bc7cba6d2ee0be96f683249672222 +Author: Ivo Timmermans +Date: Tue Jun 6 10:24:33 2000 +0000 + + Include ../intl in the include path, and add @INTLLIBS@ to the list of libraries. + +commit 66e98068051bc52fa064650710260f89c09f8cfd +Author: Ivo Timmermans +Date: Sun Jun 4 12:14:31 2000 +0000 + + These files are created by gettextize (run by autogen.sh) (should have known that). + +commit d1d4a524dee9d75b067ac8e25770557cf22f4afe +Author: Ivo Timmermans +Date: Sun Jun 4 11:50:46 2000 +0000 + + Check for __gmpz_powm for libgmp3. + +commit 377c4df245ceb8c19cabfe6d7a7c76841c07ba52 +Author: Ivo Timmermans +Date: Sat Jun 3 23:32:03 2000 +0000 + + Don't touch VPNMASK if it's defined, otherwise use $MSK. + +commit 9193aee8159ce53b349557ba1ad8ed23111042bb +Author: Guus Sliepen +Date: Sat Jun 3 08:27:16 2000 +0000 + + Removed items in TODO list that are already implemented. Only two items + left. + +commit 5796d2f5b7310fa8841f76bbc7bbcf2385d960c3 +Author: Ivo Timmermans +Date: Fri Jun 2 17:30:33 2000 +0000 + + Alphabetized the list, added Lubom�r Bulej, removed Sander Smeenk and Tijs van Bakel, put merits after all names. + +commit 18b3084d2525c59f62b75346fa657ccce6459712 +Author: Guus Sliepen +Date: Thu Jun 1 20:21:27 2000 +0000 + + Debian init.d script automatically sets tap device's MTU to 1448 now. + +commit 77be52422d8c28735f787b1c233b4cec73d4db56 +Author: Ivo Timmermans +Date: Wed May 31 18:23:06 2000 +0000 + + Miscellaneous copyright updates. + +commit 8cb4bb619d777022a55255c5fa17a1a55a270ff3 +Author: Ivo Timmermans +Date: Wed May 31 18:21:27 2000 +0000 + + Handle locale settings. + +commit f20df109a638ac3a86efa70fac39e1dae8e87208 +Author: Ivo Timmermans +Date: Wed May 31 18:19:33 2000 +0000 + + Version 1.0pre2-1. + +commit 4ae74c50b7faadf31086bc61af0f8158a465e521 +Author: Ivo Timmermans +Date: Wed May 31 18:18:21 2000 +0000 + + Updated Dutch translation. + +commit 7037286586151e28b7c5f1fe09dd6c5faca18cdc +Author: Ivo Timmermans +Date: Wed May 31 18:17:45 2000 +0000 + + Tell about /etc/tinc/nets.boot. + +commit 65a9eedb05387b8cf77dbbbc56347b44a28de624 +Author: Ivo Timmermans +Date: Wed May 31 18:17:27 2000 +0000 + + Include news for 1.0pre2. + +commit 17fa07510ad74d0f96f9700538d32eb8e7b2a0ce +Author: Ivo Timmermans +Date: Tue May 30 21:36:16 2000 +0000 + + Only accept an ADD_HOST request for a host that already exists in our conn_list if the nexthop field matches the sender. This is a workaround for older clients. + +commit e7f22d2f5f0a5fcd52da7512ab734b0ba52c623f +Author: Ivo Timmermans +Date: Tue May 30 12:38:15 2000 +0000 + + In terminate_connection, only send a notification to hosts that are directly connected to us. (DEL_HOST gets forwarded automatically.) + +commit 2fdda8e4fa6c6ace5f7e9421f0644a3ffec388c9 +Author: Ivo Timmermans +Date: Tue May 30 12:31:41 2000 +0000 + + When a connection is terminated, all hosts that are still connected get notified of the lost connections. + +commit f826301889e1fa1a22770919f0385c3ca04c740a +Author: Ivo Timmermans +Date: Tue May 30 11:18:12 2000 +0000 + + Added new configuration directive `Hostnames', which controls the resolving of IP addresses to hostnames. + +commit a7ad161d2b115b6a2a69c5dc8ddd33008d3562d0 +Author: Guus Sliepen +Date: Mon May 29 23:40:05 2000 +0000 + + Only activate a connection upon receiving it's public key if it's an + incoming connection. When it's outgoing, we need to receive an ack first. + +commit 5654e156a31d05ac3026790f7749d0401b2eaabc +Author: Ivo Timmermans +Date: Mon May 29 22:27:15 2000 +0000 + + Updated changes list for version 1.0pre2. + +commit a822c7466aa91a819c498336f91c63d224c3af11 +Author: Ivo Timmermans +Date: Mon May 29 22:20:04 2000 +0000 + + Bounds check for request id (between 0 and 255). + +commit 0f2cf48d304e20abb9b3cded2aaa693828c9d412 +Author: Ivo Timmermans +Date: Mon May 29 22:15:38 2000 +0000 + + Dutch translation of tinc. + +commit 386a62ff57f283b415fd757a8c4645b24c3bd3bb +Author: Ivo Timmermans +Date: Mon May 29 21:40:51 2000 +0000 + + Define LOCALEDIR in CFLAGS. + +commit 4cd009f774e4c50cdacc06d351cac19ca3247b6b +Author: Ivo Timmermans +Date: Mon May 29 21:40:20 2000 +0000 + + Include GNU gettext checks. + +commit 5814939c9d0e801bdbed6c96092fd90b6dcd859c +Author: Ivo Timmermans +Date: Mon May 29 21:38:02 2000 +0000 + + Update acconfig.h to include values for gettext inclusion. + +commit b200b0d812763563dbe09e5da116c55e45f89e4f +Author: Ivo Timmermans +Date: Mon May 29 21:36:28 2000 +0000 + + Include system.h and ABOUT-NLS. + +commit b9ea0633c7243de552d581f4486902c67aefd695 +Author: Ivo Timmermans +Date: Mon May 29 21:04:55 2000 +0000 + + Include intl/ directory in the list of subdirs. + +commit 9fd02ffcb0cacf3de26e876de5f30510bff137a3 +Author: Ivo Timmermans +Date: Mon May 29 21:01:26 2000 +0000 + + Internationalization of tinc. + +commit 61e71ab74ad9b5edb044b84ccf1111a33eb468cb +Author: Guus Sliepen +Date: Sat May 27 20:23:01 2000 +0000 + + Terminate a connection on any error. Furthermore, disallow del_host, + add_host and other important requests until remote host has properly + authenticated itself. + +commit cc01b18bc6d0bfb12e6770fc0a007c278f355d9e +Author: Guus Sliepen +Date: Sat May 27 19:44:04 2000 +0000 + + Made tinc persistent. If no outgoing connection can be established right + after the start of the daemon, it won't quit anymore but will retry in 5 + minutes. Also, 5 minutes is now the maximum time to wait for a retry. + +commit 028659bfbf164cb7a72831506896e291010b251f +Author: Guus Sliepen +Date: Sat May 27 19:23:20 2000 +0000 + + Fixed typos. When terminating a connection, it's status is not only set to + remove=1 but also active=0. + +commit e4ff969a9868ecc25a85daab620f97227de8d493 +Author: Guus Sliepen +Date: Sat May 27 19:04:12 2000 +0000 + + Fix for a DoS attack: + A remote user could telnet to the tinc daemon and type only this line: + 61 6 00000000/00000000:28f + This would deny any packets to be sent to other tinc networks (except + for to the hosts that run tincd's themselves). Solution is to skip + hosts in lookup_conn() that have not been activated yet. + Fixed potential conn_list table corruption: + If a new connection is accepted but a connection with the same subnet + would already exist in the connection list, the OLD connection is + terminated. + +commit 4d71de15e8abd137702a5dc04a743d246c3f1110 +Author: Guus Sliepen +Date: Sat May 27 13:21:20 2000 +0000 + + Documentation updates. Removed all references to configuration variable + "AllowConnect", since it is NOT used in tinc. Added information about + "VpnMask". Elaborated a bit about "private" and "virtual" networks. + +commit 85e3c1f2716c622ca8cada83d833703bf8a3ecc6 +Author: Ivo Timmermans +Date: Fri May 26 11:25:59 2000 +0000 + + Updated by Lubomir Bulej and Mads Kiilerich: it uses /etc/tinc/nets.boot and the VpnMask directive in the config files. + +commit 3a6ffe6895b681377a9553c01e3777f499b90d4a +Author: Ivo Timmermans +Date: Sun May 21 23:01:28 2000 +0000 + + Create an empty /etc/tinc/nets.boot. + +commit b9a86ec70ed4ffe5009c4979454f0d99c8559b45 +Author: Ivo Timmermans +Date: Sun May 21 22:40:41 2000 +0000 + + Use /etc/tinc/example as a base directory for an example. /etc/tinc/example/README points to /usr/share/doc/tinc/README.Debian. + +commit 63847abdfdad03a69bfd967929336e113cdeb09e +Author: Ivo Timmermans +Date: Sun May 21 22:38:01 2000 +0000 + + Add an example of using VpnMask. + +commit 2469acc0900edeb8f1e3263fbf58bf74639c1b12 +Author: Ivo Timmermans +Date: Sun May 21 22:27:31 2000 +0000 + + When VpnMask is not present in the config file, silently use $MSK as vpnmask. + +commit 73b3e7ce03cacb644a8101610933b221fdf432d6 +Author: Guus Sliepen +Date: Sun May 21 22:21:38 2000 +0000 + + Fixed last typo. Init.d now uses ifconfig command to set both the tap's IP + address as well as the correct route. Furthermore, if no VpnMask is given, + a default of 255.255.0.0 is chosen and a warning issued. + +commit 2ad4f1cc5b6013be2deee82b0cb3f731adb51616 +Author: Guus Sliepen +Date: Sun May 21 22:08:21 2000 +0000 + + Typo. + +commit e25fc3a3dc4bc407bd0645fb9891ac127a83f468 +Author: Guus Sliepen +Date: Sun May 21 22:04:56 2000 +0000 + + VpnMask truely works now. + +commit 9ec4decec17f95cc7d5be66cc18bb040cce84d47 +Author: Ivo Timmermans +Date: Fri May 19 01:17:32 2000 +0000 + + Mask the vpn net with the vpn netmask, route would give an error if the netmask didn't match the net. + +commit 20e404ab5716b06b53a4a5443f8098f227770907 +Author: Ivo Timmermans +Date: Fri May 19 00:58:01 2000 +0000 + + Fixed typo. + +commit 44af1094be90878bd6fc09c40882cf2463046908 +Author: Ivo Timmermans +Date: Fri May 19 00:33:44 2000 +0000 + + Updated copyright notice. + +commit 01352f4c525862f05988ed8687f26210c5ba10a2 +Author: Ivo Timmermans +Date: Fri May 19 00:15:37 2000 +0000 + + Errors will not terminate the script or result in a nonzero exit code. + +commit 4ef2a8cfdb13c7eb2d811fc8c9f04df8970293c5 +Author: Ivo Timmermans +Date: Fri May 19 00:14:34 2000 +0000 + + Include postinst in the distribution. + +commit 59ca017df4c9d0f7861693b4d2ec4b7dc8c98b1e +Author: Ivo Timmermans +Date: Fri May 19 00:09:20 2000 +0000 + + Find networks in instead of . + +commit 0354962c9885f04801d8469214c172cc012cdcec +Author: Ivo Timmermans +Date: Thu May 18 23:33:44 2000 +0000 + + Don't distribute the file files. + +commit b56705e18ceec9234578d7ac12939f7c59cff066 +Author: Ivo Timmermans +Date: Thu May 18 23:28:51 2000 +0000 + + Version 1.0pre2-0.3 + +commit cbf6efb617f45ffc608fe5f61d09abdd85f444ad +Author: Ivo Timmermans +Date: Thu May 18 23:18:54 2000 +0000 + + Create a default /etc/tinc/nets.boot after installation, containing all directories under /etc/tinc by default. + +commit e7d583adfaa50370d20f4cfe88ba5b6da399911d +Author: Ivo Timmermans +Date: Thu May 18 23:09:31 2000 +0000 + + Read /etc/tinc/nets.boot to find the networks that have to be started. + +commit 8d4ab991b8c35382c9cd46dd65af873d9d08f63f +Author: Ivo Timmermans +Date: Wed May 17 23:13:51 2000 +0000 + + This file is generated with dpkg-buildpackage. + +commit ffc79bcd20b2b8085c906a446318817808bc36ae +Author: Guus Sliepen +Date: Tue May 16 16:07:15 2000 +0000 + + TODO file reinstated: + - Append your name to items if you're working on them. + - Remove them if you fixed the problem/implemented that feature. + - Add any (suspected) bugs. + +commit cdab82d6fb7d7d32194cb2162a814fbc89b7db4c +Author: Ivo Timmermans +Date: Tue May 16 14:34:44 2000 +0000 + + Use the new VpnMask directive to add a route to the rest of the VPN. + +commit 85963f4c857abc2d9a4c5a3245cc11257140b9a6 +Author: Guus Sliepen +Date: Tue May 16 13:09:15 2000 +0000 + + Stub for VpnMask config directive. + +commit 30aff5ea2aebcfc0e97e60e73ed3edc2363634a0 +Author: Ivo Timmermans +Date: Tue May 16 13:03:32 2000 +0000 + + Look if the tap devices exist before bluntly remaking them. + +commit 0761eed64c4d6d2b8e9fa6a335ccdca8ea4b95db +Author: Ivo Timmermans +Date: Tue May 16 07:56:05 2000 +0000 + + *** empty log message *** + +commit 0a2e2b0c8d20baf22b550f735b1fe63b0a1d377a +Author: Ivo Timmermans +Date: Mon May 15 19:48:46 2000 +0000 + + Depend on perl5. + +commit 7e817fcf0fdd25aae58259930006c61048b017cd +Author: Ivo Timmermans +Date: Mon May 15 18:28:45 2000 +0000 + + Unlimited length in the config file, thanks to Cris van Pelt. + +commit b18af982af810ff4c050891ad2026960c43620a0 +Author: Ivo Timmermans +Date: Mon May 15 17:15:52 2000 +0000 + + Exit with zero status if is empty. + +commit 4711a87922c84241e9bb312755d7b943ea8ae4b6 +Author: Ivo Timmermans +Date: Mon May 15 15:54:37 2000 +0000 + + Updated to newer version. + +commit a0c4e7fe6d46988f3fb1100ef00db7b747c86f72 +Author: Guus Sliepen +Date: Mon May 15 09:41:34 2000 +0000 + + Test for existence of configured tinc networks. This will also make + first install of tinc possible without errors. + +commit 265bda08cd00feebb68243d4079854916b03638e +Author: Ivo Timmermans +Date: Sun May 14 23:03:37 2000 +0000 + + .deb version number 1.0pre2-0.4. + +commit 7a450d704b5a242f8bf9129af60593c90c63df5a +Author: Ivo Timmermans +Date: Sun May 14 23:00:44 2000 +0000 + + tincd->tinc + Delete libblowfish.y not be in the .deb. + +commit 7fbfa990fcd38b8241281ce6f1a4e2992239986f +Author: Ivo Timmermans +Date: Sun May 14 22:59:47 2000 +0000 + + Mention both upstream authors. + +commit f7b04ea142623a43413f74e19b1b6a9a247647ff +Author: Ivo Timmermans +Date: Sun May 14 22:59:19 2000 +0000 + + Add description, better dependancies. + +commit 9f07fe55dc4930920b9a5909d7057ca7bc16bad9 +Author: Ivo Timmermans +Date: Sun May 14 22:58:47 2000 +0000 + + Add initscript, tincd->tinc. + +commit df10baa50c3b421b03ac9eeaed4a4a19a47f611e +Author: Ivo Timmermans +Date: Sun May 14 21:18:10 2000 +0000 + + Inserted useful content. + +commit 6c722da77cc9185e48e22818ef88f2a88cf2efc7 +Author: Ivo Timmermans +Date: Sun May 14 21:14:23 2000 +0000 + + Add shlibs control file for the blowfish library. + +commit 803f908078e87f433727a3ddf2d61734e1ed9233 +Author: Ivo Timmermans +Date: Sun May 14 21:07:16 2000 +0000 + + Give IP address instead of hex number when connecting tcp socket failed. + +commit 4b1a1c2123626b50bd1a5382867986260440e9e7 +Author: Ivo Timmermans +Date: Sun May 14 21:04:53 2000 +0000 + + Changed version to 1.0pre2. + +commit ca900d388b996c629f0c87c7a62efb52bd219065 +Author: Ivo Timmermans +Date: Sun May 14 20:58:34 2000 +0000 + + Version 1.0pre1-0.1. + +commit 7d433ebd7610e0ff7e7b4c59979c446c0a1dfd03 +Author: Ivo Timmermans +Date: Sun May 14 20:56:41 2000 +0000 + + Add check for mpz_powm in libgmp3. + +commit de09916eadd4c558937d1a6367f5319ca26ed07c +Author: Ivo Timmermans +Date: Sun May 14 13:50:10 2000 +0000 + + Only print an error with send_termreq if debug_lvl is 2 or more. + +commit 9d023b1f2e7750f4a0e506c0f61498a44c0b95a8 +Author: Guus Sliepen +Date: Sun May 14 13:06:52 2000 +0000 + + Fixed typos. + +commit e20e143f1e99bdc0a7d92e97da1bd0dc40e8a83b +Author: Guus Sliepen +Date: Sun May 14 13:02:20 2000 +0000 + + Changed ping behaviour (backwards compatible). If we don't have any data + to send, we don't need to check if the connection is still alive. + Furthermore, if we receive any kind of data from the other end, we know + it's alive, so we don't need to check it either. So, PING requests are + only sent if we send packets but there is no response. + +commit ee96ccabbbf0180d5631d3c22838456f28ee9c15 +Author: Guus Sliepen +Date: Sun May 14 12:22:42 2000 +0000 + + Cleanups. + +commit 8caa1b9d750bb7467d1c3330780b05ac2bbf9883 +Author: Guus Sliepen +Date: Sun May 14 11:39:18 2000 +0000 + + Proxymode removed. + +commit 269067bb22e8f80deb43d3ac903f4e0d67af63d2 +Author: Ivo Timmermans +Date: Sat May 13 00:54:27 2000 +0000 + + Perl version of the system startup script. + +commit 12adf1af548b7d2f2baa4be16d2df956048b7855 +Author: Ivo Timmermans +Date: Fri May 12 13:31:00 2000 +0000 + + Deleted the protocol description. + +commit d0ba34ccae02d07051bc3f7012a6c116cfb3b653 +Author: Guus Sliepen +Date: Mon May 8 18:44:15 2000 +0000 + + Added new config variable "ProxyMode". If enabled, all outgoing packets + are sent to the uplink (ConnectTo), which will have to forward them for + us (kernel should do that). This is for people behind firewalls. + +commit 92387475ace9b06af39987c71ac563cf29427009 +Author: Ivo Timmermans +Date: Fri May 5 10:48:54 2000 +0000 + + Added semicolons required by bash2 (Mads Kiilerich). + +commit bce2179fe350bf34cde0caab97f72c0930539840 +Author: Ivo Timmermans +Date: Thu May 4 23:26:24 2000 +0000 + + Copied most of the code from the redhat script. + +commit 74b0cbecce5194dc5c594cc4e2aa3e97c14ea6c1 +Author: Ivo Timmermans +Date: Thu May 4 23:17:02 2000 +0000 + + Include sys/types.h. + +commit 2f7e532d703bbf6997ae04658379df0b0d844f62 +Author: Ivo Timmermans +Date: Thu May 4 23:16:43 2000 +0000 + + Don't link in libdl. + +commit d4ef7ea0e79ee0d2b7063893f7af5ece886d838b +Author: Ivo Timmermans +Date: Thu May 4 00:01:05 2000 +0000 + + Check for the existance of libdl. + +commit 87ccd613cab1947878ef60e3c927f717df089233 +Author: Ivo Timmermans +Date: Thu May 4 00:00:50 2000 +0000 + + More for getopt support. + +commit 6182664859383a86a47846cafdc1f6fcd73b5a76 +Author: Ivo Timmermans +Date: Thu May 4 00:00:06 2000 +0000 + + Include stdio.h for fprintf. + +commit 88a8826cf72297a784d597ba5a2b47058e1faf72 +Author: Ivo Timmermans +Date: Wed May 3 23:47:06 2000 +0000 + + getopt_long() support for platforms that don't have it. + +commit 3d218a31145cf6a4c625ed287cdf3f99e4fd9a03 +Author: Ivo Timmermans +Date: Wed May 3 23:00:38 2000 +0000 + + Don't use error.h or error(), put #error in front of cpp errors. + +commit a083b1cf305f3d241f2f4b36968a5b1ed9117612 +Author: Guus Sliepen +Date: Wed May 3 18:02:15 2000 +0000 + + Squashed gcc warning. + +commit 78532475238b23eb52ac88d905fbf966d97a79d2 +Author: Guus Sliepen +Date: Wed May 3 17:59:07 2000 +0000 + + Fixes typo and UDP network byte order. + +commit 505b5ec2cd9d6cf3dc655284a8c4041ce8527a07 +Author: Guus Sliepen +Date: Wed May 3 15:37:32 2000 +0000 + + Outgoing packets now use network byte order in header. + +commit 2bc7a0c92831802eec167ad193515962a63690dd +Author: Ivo Timmermans +Date: Wed May 3 15:01:54 2000 +0000 + + Fix a typo, better handling of the info document. (from Mads Kiilerich) + +commit 89610e3fbada1dee79769b8146a500c8357fd81d +Author: Guus Sliepen +Date: Tue May 2 10:16:50 2000 +0000 + + Replaced sprintf() by safer snprintf(), removed possible buffer overflow + by one byte. + +commit aeccaca829842910b4a5c8a5fa61e1738492bea6 +Author: Guus Sliepen +Date: Tue May 2 09:55:34 2000 +0000 + + Previous fix fixed. Meta protocol should be really flawless from now on! + +commit 989d7edc07fd407e7f7838b45986f4e37359ef97 +Author: Guus Sliepen +Date: Tue May 2 09:10:33 2000 +0000 + + Fixed small mistake that would prevent forwarding requests. + +commit 069c146656b8f952e465492c53ab5b514e959565 +Author: Ivo Timmermans +Date: Mon May 1 22:00:02 2000 +0000 + + Mentioned new metaprotocol. + +commit bd0325655867b1dff740d52d0505773bba0606a6 +Author: Ivo Timmermans +Date: Mon May 1 21:47:12 2000 +0000 + + More tincd->tinc updates. + +commit a9247e6f2c57bda9dc62ed050f41048847109e83 +Author: Ivo Timmermans +Date: Mon May 1 21:31:59 2000 +0000 + + Fixed meta protocol. + +commit 9ea27f76fab3663c9c83a7fe7de95f74cbfd59be +Author: Ivo Timmermans +Date: Mon May 1 21:31:17 2000 +0000 + + Committed by Mads Kiilerich. + +commit a92604fa5dffef589fc3042c5ae09ae8878e8cff +Author: Ivo Timmermans +Date: Mon May 1 19:17:09 2000 +0000 + + Updates by Mads Kiilerich. + +commit ca6abd41ea0cdf2ca6491c3945fb3c62fd40ab98 +Author: Guus Sliepen +Date: Mon May 1 18:07:12 2000 +0000 + + Meta protocol overhaul. Tinc is now incompatible with previous versions, + furthermore this version does NOT work yet because of a problem with + sending keys (these should be converted to base36 or something like that). + It is possible to telnet to the tinc daemon now and type some commands + by hand though :). + +commit 3219be5770716bdb0c8b6e9e4c674a447c5085f2 +Author: Ivo Timmermans +Date: Mon May 1 16:28:28 2000 +0000 + + Committed by Lubom�r Bulej. + +commit 33cfdf43f4309c17d6df811b3c5d0af3a1c8679f +Author: Ivo Timmermans +Date: Sun Apr 30 20:48:48 2000 +0000 + + Key forwarding, write one byte extra. + +commit 75d351eaf1264cfb7aa47166469e8ec722712a89 +Author: Ivo Timmermans +Date: Sun Apr 30 19:49:49 2000 +0000 + + Protocol fix (ANS_KEY). This breaks 0.3.3 protocol compatibility. + +commit b4290c3f4360f3cf01bb44957da0d8a20eac75f3 +Author: Ivo Timmermans +Date: Sun Apr 30 19:03:00 2000 +0000 + + Send one less byte from an ANS_KEY request. + +commit d878230ebef5f1a14a23c266dc425666d9e805eb +Author: Ivo Timmermans +Date: Sun Apr 30 18:57:16 2000 +0000 + + Read one less byte from an ANS_KEY request. + +commit 789a4c4f400de31d43b9c5f349f1de417443074a +Author: Ivo Timmermans +Date: Sun Apr 30 16:34:31 2000 +0000 + + Removed debug messages. + +commit eb1c9814e6b2a5206be1fadf19e0dc779690a69e +Author: Ivo Timmermans +Date: Sun Apr 30 16:31:23 2000 +0000 + + Read public keys the right way (tm). + +commit ca73b722cbad5a08ec9bb5026ed5129da9a24bd8 +Author: Ivo Timmermans +Date: Sun Apr 30 16:11:05 2000 +0000 + + New way of handling the meta protocol. + +commit cd12345032e8547a50a1f7450814364f39f0c4ec +Author: Ivo Timmermans +Date: Sun Apr 30 13:23:53 2000 +0000 + + Replaced check for status.active by status.dataopen in check_network_activity. + +commit 4b076ee87fcf8aaf1d9a2bd3c27524b4e3840167 +Author: Ivo Timmermans +Date: Sun Apr 30 01:16:51 2000 +0000 + + Initially, the vpn_mask of a connection is 255.255.255.255 to avoid confusion with lookup_conn. + +commit 1c007c0627ad5e71b8218fcb086240970e955c87 +Author: Ivo Timmermans +Date: Sun Apr 30 01:15:47 2000 +0000 + + Got rid of the nasty hacks... and replaced it by another one. + +commit c02745991422ac3d8097b126e8b256a9b33ad24b +Author: Ivo Timmermans +Date: Sat Apr 29 20:39:36 2000 +0000 + + Filled up the protocol structs with unused bytes. + +commit d3e8e8ca54928e48400584d8a70c42bbf4ae6aeb +Author: Ivo Timmermans +Date: Sat Apr 29 20:38:23 2000 +0000 + + Added `deb' target. + +commit 4dbf7022a25e678969856a38501318db4d420936 +Author: Ivo Timmermans +Date: Sat Apr 29 13:56:06 2000 +0000 + + More updates wrt. the change from tincd->tinc. + +commit 23715510149179089952eef0a2d6f87571ac0e7e +Author: Guus Sliepen +Date: Fri Apr 28 11:33:25 2000 +0000 + + Oops! Reference to write_n() removed and changed into neat write() call. + +commit bb8fff92e1bc594a085c2cbd12b215d334695feb +Author: Guus Sliepen +Date: Thu Apr 27 20:57:18 2000 +0000 + + Removed write_n() function. + +commit 4fec0cc45774ba313d1823cc64c3afdda3204a2e +Author: Ivo Timmermans +Date: Thu Apr 27 13:47:51 2000 +0000 + + Default config file name is tinc.conf, and pidfile is tinc.pid. + +commit eebb708cb29a121ea8d58bb6ca6caf41dea3c3b4 +Author: Ivo Timmermans +Date: Thu Apr 27 00:07:17 2000 +0000 + + Updated version number to 1.0. + +commit 5797d3fcb1ff56ad3ff577f7eb988b70f9d4d709 +Author: Ivo Timmermans +Date: Thu Apr 27 00:01:00 2000 +0000 + + Filled in the details, license from libblowfish copied. + +commit a3ccc15ac0979c4103f98e740b525634e8e17a0a +Author: Ivo Timmermans +Date: Wed Apr 26 23:56:22 2000 +0000 + + Version to 1.0pre1; + Create Makefile and build in debian/. + +commit d928703db1c4aa6caa6e4fbb0894037b10dce820 +Author: Ivo Timmermans +Date: Wed Apr 26 23:23:01 2000 +0000 + + Omit TODO. + +commit d0ea9c8ff287e879e531af9f1b52529421c0512f +Author: Ivo Timmermans +Date: Wed Apr 26 22:42:15 2000 +0000 + + Add an entry to dir. + +commit e5a7291543d41d435cc0fae56e52dc62a119a225 +Author: Ivo Timmermans +Date: Wed Apr 26 22:01:01 2000 +0000 + + The make command is in /usr/bin. + +commit 44f9449888344866406c75b178eff83b392b3530 +Author: Guus Sliepen +Date: Wed Apr 26 17:42:55 2000 +0000 + + Cleanups: + - Changed recv/send calls into read/write calls for streams + - Made all sizeof() functions use a variable name instead of type + +commit fca84d8a7d116c62423faf88e841daf1bee714e1 +Author: Ivo Timmermans +Date: Wed Apr 26 14:54:43 2000 +0000 + + From Mads Kiilerich. + +commit 8efe4874dabdfdf03a747ea98cf38b11cb591ef5 +Author: Guus Sliepen +Date: Tue Apr 25 22:15:28 2000 +0000 + + Converted every &variable[0] to variable. + +commit 643d8712eb2f82bde21f206306cdb6491eee7e08 +Author: Ivo Timmermans +Date: Tue Apr 25 22:00:49 2000 +0000 + + Debug level tweaking. + +commit 468f1d2efcce53937b7f5e0540269ae18f29ebac +Author: Guus Sliepen +Date: Tue Apr 25 20:50:59 2000 +0000 + + When trying to talk to a host that is in the netmask of a tinc server but + not the tinc server itself, and no keys have been exchanged yet, the key + request would be directed to the host instead of the server. Fixed. + +commit 6461a4b607f5e422b5809acb772e4bfe810b5570 +Author: Ivo Timmermans +Date: Tue Apr 25 20:42:54 2000 +0000 + + *** empty log message *** + +commit dad90e82d3c7af95820b1c04903bed7074e2b175 +Author: Guus Sliepen +Date: Tue Apr 25 20:17:44 2000 +0000 + + Fixed typo and removed some unnecessary variables. + +commit 5b7242285795f5143770b663055b87ebb5dd15b8 +Author: Guus Sliepen +Date: Tue Apr 25 20:10:37 2000 +0000 + + Packet queues fixed. They caused the trouble when resending keys. + +commit 04db888b1a94a7d63fdf9800cfd722aa9c16cd26 +Author: Ivo Timmermans +Date: Tue Apr 25 19:23:23 2000 +0000 + + Create a ChangeLog file, automake requires it. + +commit c78b76c53f516cf944ee738fad3e7d4607f282ab +Author: Ivo Timmermans +Date: Tue Apr 25 19:21:19 2000 +0000 + + *** empty log message *** + +commit 45b275e2542b4e8e7deac9e5e9eeddacfdbce90f +Author: Ivo Timmermans +Date: Tue Apr 25 19:11:02 2000 +0000 + + Initial CVS. + +commit 3a3356865267ff4c1e4f7d73f6d1486952d641b5 +Author: Guus Sliepen +Date: Tue Apr 25 18:57:23 2000 +0000 + + Added checkpoints to beginning and ending of every function. + +commit b6bdb9079a9e80b77443efe6c8b6da19e57e8505 +Author: Ivo Timmermans +Date: Tue Apr 25 17:38:54 2000 +0000 + + Remove ChangeLog with a `make cvs-clean'. + +commit ca373c61944a7bd2fe26faf081edea136104d326 +Author: Ivo Timmermans +Date: Tue Apr 25 17:35:45 2000 +0000 + + Don't include TODO in the dist. + +commit e1e590fe9a8c5c767933c68979418911f36d3a89 +Author: Ivo Timmermans +Date: Tue Apr 25 15:08:10 2000 +0000 + + Propagate CFLAGS from configure to gcc. + +commit 8a90de94a1b0e6cdaf51559d44f04a75d5f9ab0e +Author: Ivo Timmermans +Date: Tue Apr 25 15:07:21 2000 +0000 + + Delete all the files that are created by autogen.sh on a `make cvs-clean'. + +commit 24ee68b683de9937e917898075c62ff5f43ee46a +Author: Ivo Timmermans +Date: Tue Apr 25 10:40:08 2000 +0000 + + Spelling fixes. + +commit 4d85552c5bf134ada1d1083ec86dabbe41497c4a +Author: Ivo Timmermans +Date: Tue Apr 25 10:27:44 2000 +0000 + + Contributed by Mads Kiilerich. + +commit 94921d6e57e01b378ab8b1d8ea9cf3da9511fbef +Author: Ivo Timmermans +Date: Tue Apr 25 10:22:26 2000 +0000 + + Generate this Makefile.am from Makefile.am.in. + +commit 8c2b6537d32720b38554815181009c3098423414 +Author: Ivo Timmermans +Date: Tue Apr 25 09:43:50 2000 +0000 + + *** empty log message *** + +commit 03fa76dbf9965cc174eebe8a152307b8fbb63079 +Author: Ivo Timmermans +Date: Tue Apr 25 09:42:52 2000 +0000 + + Added Mads Kiilerich, removed Guus Sliepen. + +commit 7c665712d69d5a502d4c2f098ad85df3b17bfb92 +Author: Ivo Timmermans +Date: Tue Apr 25 01:45:34 2000 +0000 + + Changes largely from Mads Kiilerich. + Removed section about encryption. + +commit ce98ee1ed4121fbbf5d0e13e158511064ced6b16 +Author: Ivo Timmermans +Date: Tue Apr 25 01:26:35 2000 +0000 + + Remove test for GNOME. + +commit 6c99feb3e3cf6d69bcf52ae87b6c64ddbf3ffca5 +Author: Ivo Timmermans +Date: Tue Apr 25 01:25:18 2000 +0000 + + Use `make ChangeLog' to create this file from the CVS logs. + +commit f9eef5210dbc9c0fe54637cc4c3c0be134a51409 +Author: Ivo Timmermans +Date: Tue Apr 25 01:23:31 2000 +0000 + + Don't define HAVE_NAMESPACES and HAVE_STL. + +commit ea9d2f379a170077f93569a957c713452768d0a4 +Author: Ivo Timmermans +Date: Tue Apr 25 01:22:01 2000 +0000 + + Remove check for bigendianness. + +commit 18b204d17a054e991d90b7c4047ea106df64cdaf +Author: Ivo Timmermans +Date: Tue Apr 25 01:15:28 2000 +0000 + + This file is obsolete, most of the ideas are already in echelon. + +commit 62d5384ee01ae818906f2f8ba1456372a13a2420 +Author: Ivo Timmermans +Date: Tue Apr 25 01:10:38 2000 +0000 + + s/Gnome/tinc/g + +commit f0101589959496593db672c6a35704ea5fb33238 +Author: Ivo Timmermans +Date: Tue Apr 25 00:50:48 2000 +0000 + + The shell script autogen.sh can create all these removed files, but be + sure to have autoconf, automake, libtool and more installed. + +commit 6990a7455521665d3b67518e3f2297968108190b +Author: Ivo Timmermans +Date: Tue Apr 25 00:11:33 2000 +0000 + + Don't try to create cipher/idea/Makefile. + +commit cfecc82c9a3f5e8c4648eec058da2c6427cd76af +Author: Ivo Timmermans +Date: Mon Apr 24 21:12:32 2000 +0000 + + Don't include idea/idea.h. + +commit 63540ceff5c7bb7c76d96a4cef4ba803ce915ce1 +Author: Ivo Timmermans +Date: Mon Apr 24 21:10:33 2000 +0000 + + Don't compile in `idea'. + +commit 74315f4218ba50cc5ba32b6ecc8e8afa2b5cd704 +Author: Ivo Timmermans +Date: Mon Apr 24 20:57:22 2000 +0000 + + These files are not needed in release 1.0. + +commit 16d581be68bb52c08569e34e8a6b87f66b87e8ee +Author: Guus Sliepen +Date: Mon Apr 24 09:39:50 2000 +0000 + + Bug found! Wrong pointer was used for handling multiple ADD_HOST requests + at once. (See line 606.) + +commit f6802d349d946090bf9d1b6c761077c80065afa5 +Author: Guus Sliepen +Date: Mon Apr 24 08:32:57 2000 +0000 + + Added extra checks for desynchronized connection lists. Hopefully this will + fix those strange segmentation faults. + +commit 10749179127c681ce040fcf612038174b2bd474a +Author: Ivo Timmermans +Date: Thu Apr 20 22:50:48 2000 +0000 + + Added cvs-clean. + +commit c92701fcf007b67725d82a23ffaef3e6e5c2b0e1 +Author: Ivo Timmermans +Date: Thu Apr 20 19:14:09 2000 +0000 + + Keep make dist(dir) happy. + +commit 7db17968fc84127212ebba0fbccec1e75ced2bdc +Author: Ivo Timmermans +Date: Tue Apr 18 20:44:29 2000 +0000 + + A short notice from Mads Kiilerich. + +commit 2c5a555d7aefcf5699c68cb5d5f00f604b2542c7 +Author: Ivo Timmermans +Date: Tue Apr 18 20:43:24 2000 +0000 + + Submitted changes by Mads Kiilerich. + +commit 375b668dbc1e0268b49ea12901da72bbf5247ce5 +Author: Ivo Timmermans +Date: Tue Apr 18 20:30:20 2000 +0000 + + Include genauth.8 in the distribution. + +commit 57d8c30e4cbecea3b4216e4e650c4c0a3e160ed2 +Author: Ivo Timmermans +Date: Tue Apr 18 20:26:49 2000 +0000 + + Include the directory redhat in the build process. + +commit 0b02ebc4d98182cf79c670e7e556ac7f4f859b75 +Author: Ivo Timmermans +Date: Tue Apr 18 16:04:10 2000 +0000 + + Address for bugreports changed to tinc@nl.linux.org. + +commit 8770211c84cfb69f71bd204926593900d74ab579 +Author: Ivo Timmermans +Date: Tue Apr 18 15:59:42 2000 +0000 + + Updated manpages. + +commit 8cdb84951019feb6d4954cd11eb9663c5b9ce363 +Author: Ivo Timmermans +Date: Tue Apr 18 15:59:22 2000 +0000 + + New manpage for genauth. + +commit d11cfcec74e25ee2b88acea62ca5ef973ab7204b +Author: Ivo Timmermans +Date: Tue Apr 18 15:09:11 2000 +0000 + + Submitted by Mads Kiilerich. + +commit 93287d2b2c77d4b9e3f85f36ef4f9230fe3bf9b3 +Author: Ivo Timmermans +Date: Mon Apr 17 17:04:33 2000 +0000 + + Default passphrase length of 1024, added -h/--help options. + +commit 9c2ac77594d83a810c53faf6979e0b76006ecd0e +Author: Ivo Timmermans +Date: Mon Apr 17 16:59:42 2000 +0000 + + Check if stdout is a terminal, if so, print a verbose message. + +commit c9246896901ff1ebad91ac399a4ea79fad941f75 +Author: Ivo Timmermans +Date: Mon Apr 17 16:52:58 2000 +0000 + + Check for an illegal length of passphrase in read_passphrase(). + +commit baebae274913d912d76ba1d545f337dfb945fc5c +Author: Ivo Timmermans +Date: Mon Apr 17 16:23:29 2000 +0000 + + Pass the requested size from xmalloc() and xrealloc() on to xalloc_fail_func() + +commit 210a92cae90deb5b4a410b1b7d5c625c5c5f2ffb +Author: Ivo Timmermans +Date: Mon Apr 17 15:38:47 2000 +0000 + + Only one round of reading bits out of urandom; + Reading `bytes' bytes out of it; + Print a newline after completion. + +commit 5b44b91eb408d76af646b031da2364a769b44771 +Author: Ivo Timmermans +Date: Wed Apr 12 16:22:39 2000 +0000 + + Moved to version number 1.0. + +commit 18e044bde3b508c991910218989b4bacc3a4934e +Author: Ivo Timmermans +Date: Thu Apr 6 18:28:29 2000 +0000 + + New option -D, don't detach. + +commit 523c80c4e35b7ff8ad94b41a6071dbe2b8ff6ec7 +Author: Ivo Timmermans +Date: Tue Mar 28 19:16:27 2000 +0000 + + Ignore SIGCHLD. + +commit f2076e3e7031ac8ad87eb6aab0cea40f379dd0c6 +Author: Ivo Timmermans +Date: Tue Mar 28 19:09:52 2000 +0000 + + Kill the parent after any error conditions in detach(). + +commit 98de35c742498878a27fb29becd3b7154525a60f +Author: Ivo Timmermans +Date: Mon Mar 27 22:59:16 2000 +0000 + + Upon regeneration, free the old encryption key `securely\' by overwriting it. + +commit b50523dc44bbb32f03d24573e195c071cbff3fc4 +Author: Ivo Timmermans +Date: Mon Mar 27 22:30:27 2000 +0000 + + Get rid of the message `zxnrbl\'. + +commit 1243156a5e03a666b36bc4400f1402243a85c9a7 +Author: Ivo Timmermans +Date: Sun Mar 26 00:33:07 2000 +0000 + + Initial revision diff --git a/INSTALL b/INSTALL index 8865734..7d1c323 100644 --- a/INSTALL +++ b/INSTALL @@ -1,8 +1,8 @@ Installation Instructions ************************* - Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software -Foundation, Inc. +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008, 2009 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -12,96 +12,97 @@ without warranty of any kind. Basic Installation ================== - Briefly, the shell command './configure && make && make install' -should configure, build, and install this package. The following -more-detailed instructions are generic; see the 'README' file for + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this -'INSTALL' file but do not implement all of the features documented +`INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. - The 'configure' shell script attempts to guess correct values for + The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses -those values to create a 'Makefile' in each directory of the package. -It may also create one or more '.h' files containing system-dependent -definitions. Finally, it creates a shell script 'config.status' that +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a -file 'config.log' containing compiler output (useful mainly for -debugging 'configure'). +file `config.log' containing compiler output (useful mainly for +debugging `configure'). - It can also use an optional file (typically called 'config.cache' and -enabled with '--cache-file=config.cache' or simply '-C') that saves the -results of its tests to speed up reconfiguring. Caching is disabled by -default to prevent problems with accidental use of stale cache files. + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. If you need to do unusual things to compile the package, please try -to figure out how 'configure' could check whether to do them, and mail -diffs or instructions to the address given in the 'README' so they can +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at -some point 'config.cache' contains results you don't want to keep, you +some point `config.cache' contains results you don't want to keep, you may remove or edit it. - The file 'configure.ac' (or 'configure.in') is used to create -'configure' by a program called 'autoconf'. You need 'configure.ac' if -you want to change it or regenerate 'configure' using a newer version of -'autoconf'. + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. The simplest way to compile this package is: - 1. 'cd' to the directory containing the package's source code and type - './configure' to configure the package for your system. + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. - Running 'configure' might take a while. While running, it prints + Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. - 2. Type 'make' to compile the package. + 2. Type `make' to compile the package. - 3. Optionally, type 'make check' to run any self-tests that come with + 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. - 4. Type 'make install' to install the programs and any data files and + 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular - user, and only the 'make install' phase executed with root + user, and only the `make install' phase executed with root privileges. - 5. Optionally, type 'make installcheck' to repeat any self-tests, but + 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a - regular user, particularly if the prior 'make install' required + regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the - source code directory by typing 'make clean'. To also remove the - files that 'configure' created (so you can compile the package for - a different kind of computer), type 'make distclean'. There is - also a 'make maintainer-clean' target, but that is intended mainly + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. - 7. Often, you can also type 'make uninstall' to remove the installed + 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. - 8. Some packages, particularly those that use Automake, provide 'make + 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other - targets like 'make install' and 'make uninstall' work correctly. + targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that -the 'configure' script does not know about. Run './configure --help' +the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. - You can give 'configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here is -an example: + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix @@ -112,21 +113,21 @@ Compiling For Multiple Architectures You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU 'make'. 'cd' to the +own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run -the 'configure' script. 'configure' automatically checks for the source -code in the directory that 'configure' is in and in '..'. This is known -as a "VPATH" build. +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. - With a non-GNU 'make', it is safer to compile the package for one + With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have -installed the package for one architecture, use 'make distclean' before +installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple '-arch' options to the -compiler but only a single '-arch' option to the preprocessor. Like +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ @@ -135,104 +136,100 @@ this: This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results -using the 'lipo' tool if you have problems. +using the `lipo' tool if you have problems. Installation Names ================== - By default, 'make install' installs the package's commands under -'/usr/local/bin', include files under '/usr/local/include', etc. You -can specify an installation prefix other than '/usr/local' by giving -'configure' the option '--prefix=PREFIX', where PREFIX must be an + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you -pass the option '--exec-prefix=PREFIX' to 'configure', the package uses +pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give -options like '--bindir=DIR' to specify different values for particular -kinds of files. Run 'configure --help' for a list of the directories -you can set and what kinds of files go in them. In general, the default -for these options is expressed in terms of '${prefix}', so that -specifying just '--prefix' will affect all of the other directory +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the -correct locations to 'configure'; however, many packages provide one or +correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the -'make install' command line to change installation locations without +`make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each -affected directory. For example, 'make install +affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of -'${prefix}'. Any directories that were specified during 'configure', -but not in terms of '${prefix}', must each be overridden at install time -for the entire installation to be relocated. The approach of makefile -variable overrides for each directory variable is required by the GNU -Coding Standards, and ideally causes no recompilation. However, some -platforms have known limitations with the semantics of shared libraries -that end up requiring recompilation when using this method, particularly -noticeable in packages that use GNU Libtool. +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. - The second method involves providing the 'DESTDIR' variable. For -example, 'make install DESTDIR=/alternate/directory' will prepend -'/alternate/directory' before all installation names. The approach of -'DESTDIR' overrides is not required by the GNU Coding Standards, and + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even -when some directory options were not specified in terms of '${prefix}' -at 'configure' time. +when some directory options were not specified in terms of `${prefix}' +at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving 'configure' the -option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - Some packages pay attention to '--enable-FEATURE' options to -'configure', where FEATURE indicates an optional part of the package. -They may also pay attention to '--with-PACKAGE' options, where PACKAGE -is something like 'gnu-as' or 'x' (for the X Window System). The -'README' should mention any '--enable-' and '--with-' options that the + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the package recognizes. - For packages that use the X Window System, 'configure' can usually + For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, -you can use the 'configure' options '--x-includes=DIR' and -'--x-libraries=DIR' to specify their locations. +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the -execution of 'make' will be. For these packages, running './configure +execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be -overridden with 'make V=1'; while running './configure +overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be -overridden with 'make V=0'. +overridden with `make V=0'. Particular systems ================== - On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC -is not installed, it is recommended to use the following options in + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. - HP-UX 'make' updates targets which have the same time stamps as their -prerequisites, which makes it generally unusable when shipped generated -files such as 'configure' are involved. Use GNU 'make' instead. - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its '' header file. The option '-nodtk' can be used as a -workaround. If GNU CC is not installed, it is therefore recommended to -try +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try ./configure CC="cc" @@ -240,26 +237,26 @@ and if that doesn't work, try ./configure CC="cc -nodtk" - On Solaris, don't put '/usr/ucb' early in your 'PATH'. This + On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of -these programs are available in '/usr/bin'. So, if you need '/usr/ucb' -in your 'PATH', put it _after_ '/usr/bin'. +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. - On Haiku, software installed for all users goes in '/boot/common', -not '/usr/local'. It is recommended to use the following options: + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== - There may be some features 'configure' cannot figure out + There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the -_same_ architectures, 'configure' can figure that out, but if it prints +_same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the -'--build=TYPE' option. TYPE can either be a short name for the system -type, such as 'sun4', or a canonical name which has the form: +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM @@ -268,101 +265,101 @@ where SYSTEM can have one of these forms: OS KERNEL-OS - See the file 'config.sub' for the possible values of each field. If -'config.sub' isn't included in this package, then this package doesn't + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should -use the option '--target=TYPE' to select the type of system they will +use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will -eventually be run) with '--host=TYPE'. +eventually be run) with `--host=TYPE'. Sharing Defaults ================ - If you want to set default values for 'configure' scripts to share, -you can create a site shell script called 'config.site' that gives -default values for variables like 'CC', 'cache_file', and 'prefix'. -'configure' looks for 'PREFIX/share/config.site' if it exists, then -'PREFIX/etc/config.site' if it exists. Or, you can set the -'CONFIG_SITE' environment variable to the location of the site script. -A warning: not all 'configure' scripts look for a site script. + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the -environment passed to 'configure'. However, some packages may run +environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set -them in the 'configure' command line, using 'VAR=value'. For example: +them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc -causes the specified 'gcc' to be used as the C compiler (unless it is +causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). -Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an -Autoconf limitation. Until the limitation is lifted, you can use this -workaround: +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: - CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash -'configure' Invocation +`configure' Invocation ====================== - 'configure' recognizes the following options to control how it + `configure' recognizes the following options to control how it operates. -'--help' -'-h' - Print a summary of all of the options to 'configure', and exit. +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. -'--help=short' -'--help=recursive' +`--help=short' +`--help=recursive' Print a summary of the options unique to this package's - 'configure', and exit. The 'short' variant lists options used only - in the top level, while the 'recursive' variant lists options also - present in any nested packages. + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. -'--version' -'-V' - Print the version of Autoconf used to generate the 'configure' +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' script, and exit. -'--cache-file=FILE' +`--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, - traditionally 'config.cache'. FILE defaults to '/dev/null' to + traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. -'--config-cache' -'-C' - Alias for '--cache-file=config.cache'. +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. -'--quiet' -'--silent' -'-q' +`--quiet' +`--silent' +`-q' Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to '/dev/null' (any error + suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). -'--srcdir=DIR' +`--srcdir=DIR' Look for the package's source code in directory DIR. Usually - 'configure' can determine that directory automatically. + `configure' can determine that directory automatically. -'--prefix=DIR' - Use DIR as the installation prefix. *note Installation Names:: for - more details, including other options available for fine-tuning the - installation locations. +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. -'--no-create' -'-n' +`--no-create' +`-n' Run the configure checks, but stop before creating any output files. -'configure' also accepts some other, not widely useful, options. Run -'configure --help' for more details. +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am index 8e43fe5..e37864d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,14 +2,26 @@ AUTOMAKE_OPTIONS = gnu -SUBDIRS = src doc systemd +SUBDIRS = m4 src doc gui ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = COPYING.README README.android +EXTRA_DIST = have.h system.h COPYING.README ChangeLog: git log > ChangeLog -astyle: - astyle --options=.astylerc -nQ src/*.[ch] src/*/*.[ch] +deb: + dpkg-buildpackage -rfakeroot + +rpm: dist + cp $(distdir).tar.gz /usr/src/redhat/SOURCES/ + cp redhat/tinc.spec /usr/src/redhat/SOURCES/ + cd /usr/src/redhat/SOURCES/ && rpm -bb tinc.spec + +release: + rm -f ChangeLog + $(MAKE) ChangeLog + echo "Please edit the NEWS file now..." + /usr/bin/editor NEWS + $(MAKE) dist diff --git a/Makefile.in b/Makefile.in index 526846b..baa5005 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. - +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -14,61 +15,6 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -88,95 +34,47 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ + THANKS config.guess config.sub depcomp install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ - $(top_srcdir)/m4/ax_append_flag.m4 \ - $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ - $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_check_link_flag.m4 \ - $(top_srcdir)/m4/ax_require_defined.m4 $(top_srcdir)/m4/lzo.m4 \ - $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/zlib.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/m4/curses.m4 $(top_srcdir)/m4/libevent.m4 \ + $(top_srcdir)/m4/lzo.m4 $(top_srcdir)/m4/openssl.m4 \ + $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ - $(am__configure_deps) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = SOURCES = DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - cscope distdir distdir-am dist dist-all distcheck -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ - $(LISP)config.h.in -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags -CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \ - COPYING ChangeLog INSTALL NEWS README THANKS compile \ - config.guess config.sub install-sh missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ - if test -d "$(distdir)"; then \ - find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -rf "$(distdir)" \ - || { sleep 5 && rm -rf "$(distdir)"; }; \ - else :; fi -am__post_remove_distdir = $(am__remove_distdir) + { test ! -d "$(distdir)" \ + || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr "$(distdir)"; }; } am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ @@ -204,14 +102,10 @@ am__relativize = \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best -DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print -am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ - | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -221,6 +115,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -230,15 +125,21 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ +INCLUDES = @INCLUDES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ @@ -250,6 +151,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -296,27 +198,25 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemd_path = @systemd_path@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = gnu -SUBDIRS = src doc systemd +SUBDIRS = m4 src doc gui ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = COPYING.README README.android +EXTRA_DIST = have.h system.h COPYING.README all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: -am--refresh: Makefile +am--refresh: @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -329,33 +229,36 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile +.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 - @test -f $@ || rm -f stamp-h1 - @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ + else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h -$(srcdir)/config.h.in: $(am__configure_deps) +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ @@ -364,25 +267,22 @@ distclean-hdr: -rm -f config.h stamp-h1 # This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ + list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ @@ -397,12 +297,57 @@ $(am__recursive_targets): $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ @@ -418,7 +363,12 @@ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ - $(am__define_uniq_tagged_files); \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -430,11 +380,15 @@ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $$unique; \ fi; \ fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique @@ -443,42 +397,11 @@ GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" -cscope: cscope.files - test ! -s cscope.files \ - || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) -clean-cscope: - -rm -f cscope.files -cscope.files: clean-cscope cscopelist -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -rm -f cscope.out cscope.in.out cscope.po.out cscope.files -distdir: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) distdir-am - -distdir-am: $(DISTFILES) - @case `sed 15q $(srcdir)/NEWS` in \ - *"$(VERSION)"*) : ;; \ - *) \ - echo "NEWS not updated; not releasing" 1>&2; \ - exit 1;; \ - esac +distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -512,10 +435,13 @@ distdir-am: $(DISTFILES) done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ @@ -543,43 +469,37 @@ distdir-am: $(DISTFILES) ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz - $(am__post_remove_distdir) + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 - $(am__post_remove_distdir) + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) -dist-lzip: distdir - tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz - $(am__post_remove_distdir) +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) dist-xz: distdir - tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz - $(am__post_remove_distdir) + tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz + $(am__remove_distdir) dist-tarZ: distdir - @echo WARNING: "Support for distribution archives compressed with" \ - "legacy program 'compress' is deprecated." >&2 - @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__post_remove_distdir) + $(am__remove_distdir) dist-shar: distdir - @echo WARNING: "Support for shar distribution archives is" \ - "deprecated." >&2 - @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz - $(am__post_remove_distdir) + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) - $(am__post_remove_distdir) + $(am__remove_distdir) -dist dist-all: - $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' - $(am__post_remove_distdir) +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another @@ -587,33 +507,31 @@ dist dist-all: distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.lz*) \ - lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ + *.tar.lzma*) \ + lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac - chmod -R a-w $(distdir) - chmod u+w $(distdir) - mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build/sub \ - && ../../configure \ - $(AM_DISTCHECK_CONFIGURE_FLAGS) \ + && $(am__cd) $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ - --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ @@ -636,21 +554,13 @@ distcheck: dist && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 - $(am__post_remove_distdir) + $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: - @test -n '$(distuninstallcheck_dir)' || { \ - echo 'ERROR: trying to run $@ with an empty' \ - '$$(distuninstallcheck_dir)' >&2; \ - exit 1; \ - }; \ - $(am__cd) '$(distuninstallcheck_dir)' || { \ - echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ - exit 1; \ - }; \ - test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ + @$(am__cd) '$(distuninstallcheck_dir)' \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ @@ -681,15 +591,10 @@ install-am: all-am installcheck: installcheck-recursive install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: @@ -770,32 +675,42 @@ ps-am: uninstall-am: -.MAKE: $(am__recursive_targets) all install-am install-strip +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ + ctags-recursive install-am install-strip tags-recursive -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ - am--refresh check check-am clean clean-cscope clean-generic \ - cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ - dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ - distcheck distclean distclean-generic distclean-hdr \ - distclean-tags distcleancheck distdir distuninstallcheck dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs installdirs-am \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am - -.PRECIOUS: Makefile +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am am--refresh check check-am clean clean-generic \ + ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ + dist-lzma dist-shar dist-tarZ dist-xz dist-zip distcheck \ + distclean distclean-generic distclean-hdr distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am ChangeLog: git log > ChangeLog -astyle: - astyle --options=.astylerc -nQ src/*.[ch] src/*/*.[ch] +deb: + dpkg-buildpackage -rfakeroot + +rpm: dist + cp $(distdir).tar.gz /usr/src/redhat/SOURCES/ + cp redhat/tinc.spec /usr/src/redhat/SOURCES/ + cd /usr/src/redhat/SOURCES/ && rpm -bb tinc.spec + +release: + rm -f ChangeLog + $(MAKE) ChangeLog + echo "Please edit the NEWS file now..." + /usr/bin/editor NEWS + $(MAKE) dist # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/NEWS b/NEWS index 4a342f7..679040b 100644 --- a/NEWS +++ b/NEWS @@ -1,238 +1,32 @@ -Version 1.0.35 October 5 2018 +Version 1.1pre2 Juli 17 2011 - * Prevent oracle attacks (CVE-2018-16737, CVE-2018-16738). - * Prevent a MITM from forcing a NULL cipher for UDP (CVE-2018-16758). + * .cookie files are renamed to .pid files, which are compatible with 1.0.x. -Version 1.0.34 June 12 2018 + * Experimental protocol enhancements that can be enabled with the option + ExperimentalProtocol = yes: - * Fix a potential segmentation fault when connecting to an IPv6 peer via a - proxy. - * Minor improvements to the build system. - * Make the systemd service file identical to the one from the 1.1 branch. - * Fix a potential problem causing IPv4 sockets to not work on macOS. + * Ephemeral ECDH key exchange will be used for both the meta protocol and + UDP session keys. + * Key exchanges are signed with ECDSA. + * ECDSA public keys are automatically exchanged after RSA authentication if + nodes do not know each other's ECDSA public key yet. -Thanks to Maximilian Stein and Wang Liu Shuai for their contributions to this -version of tinc. +Version 1.1pre1 June 25 2011 -Version 1.0.33 November 4 2017 + * Control interface allows control of a running tinc daemon. Used by: + * tincctl, a commandline utility + * tinc-gui, a preliminary GUI implemented in Python/wxWidgets - * Allow compilation from a build directory. - * Source code cleanups. - * Fix some options specified on the command line not surviving a HUP signal. - * Handle tun/tap device returning EPERM or EBUSY. - * Disable PMTUDiscovery when TCPOnly is used. - * Support the --runstatedir option of the autoconf 2.70. + * Code cleanups and reorganization. -Thanks to Rafael Sadowski and Pierre-Olivier Mercier for their contributions to -this version of tinc. + * Repleacable cryptography backend, currently supports OpenSSL and libgcrypt. -Version 1.0.32 September 2 2017 + * Use libevent to handle I/O events and timeouts. - * Fix segmentation fault when using Cipher = none. - * Fix Proxy = exec. - * Support PriorityInheritance for IPv6 packets. - * Fixes for Solaris tun/tap support. - * Bind outgoing TCP sockets when ListenAddress is used. + * Use splay trees instead of AVL trees to manage internal datastructures. -Thanks to Vittorio Gambaletta for his contribution to this version of tinc. - -Version 1.0.31 January 15 2017 - - * Remove ExecStop in tinc@.service. - -Thanks to Élie Bouttier for his contribution to this version of tinc. - -Version 1.0.30 October 30 2016 - - * Fix troubles connecting to some HTTP proxies. - - * Add mitigations for the Sweet32 attack when using a 64-bit block cipher. - - * Use AES256 and SHA256 as the default encryption and digest algorithms. - -Version 1.0.29 October 9 2016 - - * Fix UDP communication with peers with link-local IPv6 addresses. - - * Ensure compatibility with OpenSSL 1.1.0. - - * Ensure autoreconf can be run without requiring autoconf-archive. - - * Log warnings about dropped packets only at debug level 5. - -Version 1.0.28 April 10 2016 - - * Fix compilation on BSD platforms. - - * Add systemd service files. - -Version 1.0.27 April 10 2016 - - * When using Proxy, let the proxy resolve hostnames if tinc can't. - - * Fixes and improvements of the DecrementTTL option. - - * Fixed the $NAME variable in subnet-up/down scripts for the local Subnets. - - * Fixed potentially wrong checksum generation when clamping the MSS. - - * Properly choose between the system's or our own copy of getopt. - - * Fixed compiling tinc for Cygwin with MinGW installed. - - * Added support for OS X utun interfaces. - - * Documentation updates and minor fixes. - -Thanks to Vittorio Gambaletta, LunarShaddow, Florian Weik and Nathan Stratton -Treadway for their contributions to this version of tinc. - -Version 1.0.26 July 5 2015 - - * Tinc now forces glibc to reload /etc/resolv.conf for every hostname lookup. - - * Fixed --logfile without a filename on Windows. - - * Ensure tinc can be compiled when using musl libc. - -Thanks to Jo-Philipp Wich for his contribution to this version of tinc. - -Version 1.0.25 December 22 2014 - - * Documentation updates. - - * Support linking against -lresolv on Mac OS X. - - * Fix scripts on Windows when using the ScriptsInterpreter option. - - * Allow a minimum reconnect timeout to be specified. - - * Support PriorityInheritance on IPv6 sockets. - -Thanks to David Pflug, Baptiste Jonglez, Alexis Hildebrandt, Borg, Jochen Voss, -Tomislav Čohar and VittGam for their contributions to this version of tinc. - -Version 1.0.24 May 11 2014 - - * Various compiler hardening flags are enabled by default. - - * Updated support for Solaris, allowing switch mode on Solaris 11. - - * Configuration will now also be read from a conf.d directory. - - * Various updates to the documentation. - - * Tinc now forces glibc to reload /etc/resolv.conf after it receives SIGALRM. - - * Fixed a potential routing loop when IndirectData or TCPOnly is used and - broadcast packets are being sent. - - * Improved security with constant time memcmp and stricter use of OpenSSL's - RNG functions. - - * Fixed all issues found by Coverity. - -Thanks to Florent Clairambault, Vilbrekin, luckyhacky, Armin Fisslthaler, Loïc -Dachary and Steffan Karger for their contributions to this version of tinc. - -Version 1.0.23 October 19 2013 - - * Start authentication immediately on outgoing connections (useful for sslh). - - * Fixed segfault when Name = $HOST but $HOST is not set. - - * Updated the build system and the documentation. - - * Clean up child processes left over from Proxy = exec. - -Version 1.0.22 August 13 2013 - - * Fixed the combination of Mode = router and DeviceType = tap. - - * The $NAME variable is now set in subnet-up/down scripts. - - * Tinc now gives an error when unknown options are given on the command line. - - * Tinc now correctly handles a space between a short command line option and - an optional argument. - -Thanks to Etienne Dechamps for his contribution to this version of tinc. - -Version 1.0.21 April 22 2013 - - * Drop packets forwarded via TCP if they are too big (CVE-2013-1428). - -Thanks to Martin Schobert for auditing tinc and reporting this vulnerability. - -Version 1.0.20 March 03 2013 - - * Use /dev/tap0 by default on FreeBSD and NetBSD when using switch mode. - - * Minor improvements and clarifications in the documentation. - - * Allow tinc to be cross-compiled with Android's NDK. - - * The discovered PMTU is now also applied to VLAN tagged traffic. - - * The LocalDiscovery option now makes use of all addresses tinc is bound to. - - * Fixed support for tunemu on iOS devices. - - * The PriorityInheritance option now also works with switch mode. - - * Fixed tinc crashing when using a SOCKS5 proxy. - -Thanks to Mesar Hameed, Vilbrekin and Martin Schürrer for their contributions -to this version of tinc. - -Version 1.0.19 June 25 2012 - - * Allow :: notation in IPv6 Subnets. - - * Add support for systemd style socket activation. - - * Allow environment variables to be used for the Name option. - - * Add basic support for SOCKS proxies, HTTP proxies, and proxying through an - external command. - -Thanks to Anthony G. Basile and Michael Tokarev for their contributions to -this version of tinc. - -Version 1.0.18 March 25 2012 - - * Fixed IPv6 in switch mode by turning off DecrementTTL by default. - - * Allow a port number to be specified in BindToAddress, which also allows tinc - to listen on multiple ports. - - * Add support for multicast communication with UML/QEMU/KVM. - -Version 1.0.17 March 10 2012 - - * The DeviceType option can now be used to select dummy, raw socket, UML and - VDE devices without needing to recompile tinc. - - * Allow multiple BindToAddress statements. - - * Decrement TTL value of IPv4 and IPv6 packets. - - * Add LocalDiscovery option allowing tinc to detect peers that are behind the - same NAT. - - * Accept Subnets passed with the -o option when StrictSubnets = yes. - - * Disabling old RSA keys when generating new ones now also works properly on - Windows. - -Thanks to Nick Hibma for his contribution to this version of tinc. - -Version 1.0.16 July 23 2011 - - * Fixed a performance issue with TCP communication under Windows. - - * Fixed code that, during network outages, would cause tinc to exit when it - thought two nodes with identical Names were on the VPN. + Thanks to Scott Lamb and Sven-Haegar Koch for their contributions to this + version of tinc. Version 1.0.15 June 24 2011 @@ -242,6 +36,8 @@ Version 1.0.15 June 24 2011 * Fixed ProcessPriority option under Windows. + Thanks to Loïc Grenié for his contribution to this version of tinc. + Version 1.0.14 May 8 2011 * Fixed reading configuration files that do not end with a newline. Again. @@ -357,7 +153,7 @@ Version 1.0.9 Dec 26 2008 * Enable path MTU discovery by default. - * Fixed a memory leak that occurred when connections were closed. + * Fixed a memory leak that occured when connections were closed. Thanks to Max Rijevski for his contributions to this version of tinc. diff --git a/README b/README index f47cc29..09f6e6e 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ -This is the README file for tinc version 1.0.35. Installation +This is the README file for tinc version 1.1pre2. Installation instructions may be found in the INSTALL file. -tinc is Copyright (C) 1998-2018 by: +tinc is Copyright (C) 1998-2011 by: Ivo Timmermans, Guus Sliepen , @@ -15,74 +15,51 @@ the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING for more details. +This is a pre-release +--------------------- + +Please note that this is NOT a stable release. Until version 1.1.0 is released, +please use one of the 1.0.x versions if you need a stable version of tinc. + +Although tinc 1.1 will be protocol compatible with tinc 1.0.x, the +functionality of the tincctl program may still change, and the control socket +protocol is not fixed yet. + + Security statement ------------------ -In August 2000, we discovered the existence of a security hole in all versions -of tinc up to and including 1.0pre2. This had to do with the way we exchanged -keys. Since then, we have been working on a new authentication scheme to make -tinc as secure as possible. The current version uses the OpenSSL library and -uses strong authentication with RSA keys. - -On the 29th of December 2001, Jerome Etienne posted a security analysis of tinc -1.0pre4. Due to a lack of sequence numbers and a message authentication code -for each packet, an attacker could possibly disrupt certain network services or -launch a denial of service attack by replaying intercepted packets. The current -version adds sequence numbers and message authentication codes to prevent such -attacks. - -On September the 15th of 2003, Peter Gutmann contacted us and showed us a -writeup describing various security issues in several VPN daemons. He showed -that tinc lacks perfect forward security, the connection authentication could -be done more properly, that the sequence number we use as an IV is not the best -practice and that the default length of the HMAC for packets is too short in -his opinion. We do not know of a way to exploit these weaknesses, but these -issues are being addressed in the tinc 1.1 branch. - -The Sweet32 attack affects versions of tinc prior to 1.0.30. - -On September 6th, 2018, Michael Yonly contacted us and provided -proof-of-concept code that allowed a remote attacker to create an -authenticated, one-way connection with a node, and also that there was a -possibility for a man-in-the-middle to force UDP packets from a node to be sent -in plaintext. The first issue was trivial to exploit on tinc versions prior to -1.0.30, but the changes in 1.0.30 to mitigate the Sweet32 attack made this -weakness much harder to exploit. These issues have been fixed in tinc 1.0.35. -The new protocol in the tinc 1.1 branch is not susceptible to these issues. - -Cryptography is a hard thing to get right. We cannot make any -guarantees. Time, review and feedback are the only things that can -prove the security of any cryptographic product. If you wish to review -tinc or give us feedback, you are strongly encouraged to do so. +This version uses an experimental and unfinished cryptographic protocol. Use +it at your own risk. Compatibility ------------- -Version 1.0.35 is compatible with 1.0pre8, 1.0 and later, but not with older -versions of tinc. Note that since version 1.0.30, tinc requires all nodes in -the VPN to be compiled with a version of LibreSSL or OpenSSL that supports the -AES256 and SHA256 algorithms. +Version 1.1pre2 is compatible with 1.0pre8, 1.0 and later, but not with older +versions of tinc. + +When the ExperimentalProtocol option is used, tinc is still compatible with +1.0.X and 1.1pre2 itself, but not with any other 1.1preX version. Requirements ------------ -The OpenSSL library is used for all cryptographic functions. You can find it at -https://www.openssl.org/. You will need version 1.0.1 or later with support for -AES256 and SHA256 enabled. If this library is not installed on your system, the -configure script will fail. The manual in doc/tinc.texi contains more detailed -information on how to install this library. Alternatively, you may also use the -LibreSSL library. +Either OpenSSL (http://www.openssl.org/) or libgcrypt +(http://www.gnupg.org/download/#libgcrypt). -The zlib library is used for optional compression. You can -find it at https://zlib.net/. Because of a possible exploit in -earlier versions we recommend that you download version 1.1.4 or later. +The zlib library is used for optional compression. You can find it at +http://www.gzip.org/zlib/. -The LZO library is also used for optional compression. You can -find it at https://www.oberhumer.com/opensource/lzo/. +The lzo library is also used for optional compression. You can find it at +http://www.oberhumer.com/opensource/lzo/. -In order to compile tinc, you will need a C99 compliant compiler. +Since 1.1, the libevent library is used for the main event loop. You can find +it at http://monkey.org/~provos/libevent/. + +In order to compile tinc, you will need a GNU C compiler environment. Please +ensure you have the latest stable versions of all the required libraries. Features @@ -112,14 +89,14 @@ Linux, FreeBSD and Windows. The algorithms used for encryption and generating message authentication codes can now be changed in the configuration files. All cipher and digest algorithms supported by OpenSSL can be used. Useful ciphers are "blowfish" (default), -"bf-ofb", "des", "des3", et cetera. Useful digests are "sha1" (default), "md5", -et cetera. +"bf-ofb", "des", "des3", etcetera. Useful digests are "sha1" (default), "md5", +etcetera. Support for routing IPv6 packets has been added. Just add Subnet lines with IPv6 addresses (without using :: abbreviations) and use ifconfig or ip (from the iproute package) to give the virtual network interface corresponding IPv6 -addresses. tinc does not provide autoconfiguration for IPv6 hosts. Consider -using radvd or zebra if you need it. +addresses. tinc does not provide autoconfiguration for IPv6 hosts, if you need +it use radvd or zebra. It is also possible to make tunnels to other tinc daemons over IPv6 networks, if the operating system supports IPv6. tinc will automatically use both IPv6 @@ -127,7 +104,7 @@ and IPv4 when available, but this can be changed by adding the option "AddressFamily = ipv4" or "AddressFamily = ipv6" to the tinc.conf file. Normally, when started tinc will detach and run in the background. In a native -Windows environment this means tinc will install itself as a service, which will +Windows environment this means tinc will intall itself as a service, which will restart after reboots. To prevent tinc from detaching or running as a service, use the -D option. diff --git a/README.android b/README.android deleted file mode 100644 index 7925bdb..0000000 --- a/README.android +++ /dev/null @@ -1,25 +0,0 @@ -Quick how-to cross compile tinc for android (done from $HOME/android/): - -- Download android NDK and setup local ARM toolchain: -wget http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86.tar.bz2 -tar xfj android-ndk-r9d-linux-x86.tar.bz2 -./android-ndk-r9d/build/tools/make-standalone-toolchain.sh --platform=android-5 --install-dir=/tmp/my-android-toolchain - -- Download and cross-compile openSSL for ARM: -wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz -tar xfz openssl-1.0.1h.tar.gz -cd openssl-1.0.1h -./Configure dist -make CC=/tmp/my-android-toolchain/bin/arm-linux-androideabi-gcc AR="/tmp/my-android-toolchain/bin/arm-linux-androideabi-ar r" RANLIB=/tmp/my-android-toolchain/bin/arm-linux-androideabi-ranlib -cd - - -- Clone and cross-compile tinc: -git clone git://tinc-vpn.org/tinc -cd tinc -autoreconf -fsi -CC=/tmp/my-android-toolchain/bin/arm-linux-androideabi-gcc ./configure --host=arm-linux --disable-lzo --with-openssl-lib=$HOME/android/openssl-1.0.1g --with-openssl-include=$HOME/android/openssl-1.0.1g/include/ --disable-hardening -make -j5 - -- Strip tincd binary to make it smaller -/tmp/my-android-toolchain/bin/arm-linux-androideabi-strip src/tincd - diff --git a/THANKS b/THANKS index d6f4af7..4a6eae2 100644 --- a/THANKS +++ b/THANKS @@ -1,120 +1,49 @@ We would like to thank the following people for their contributions to tinc: * Alexander Reil and Gemeinde Berg -* Alexander Ried -* Alexis Hildebrandt * Allesandro Gatti * Andreas van Cranenburgh -* Andrew Hahn -* Anthony G. Basile * Armijn Hemel -* Armin Fisslthaler -* Aron Cowan -* Ashish Bajaj -* Baptiste Jonglez -* Borg * Brandon Black -* Cheng LI * Cris van Pelt -* Darius Jahandarie -* Dato Simó -* David Pflug * Delf Eldkraft -* Dennis Joachimsthaler * dnk -* Élie Bouttier * Enrique Zanardi -* Erik Tews -* Etienne Dechamps -* Florent Clairambault -* Florian Forster -* Florian Klink -* Florian Weik * Flynn Marquardt -* Franz Pletz -* Gary Kessler and Claudia Gonzalez * Grzegorz Dymarek -* Gusariev Oleksandr * Hans Bayle -* Harvest * Ivo van Dong -* Ivo Smits -* James Cook * James MacLean * Jamie Briggs * Jason Harper -* Jason Livesay -* Jasper Krijgsman -* Jelle de Jong -* Jeroen Domburg * Jeroen Ubbink * Jerome Etienne -* Jo-Philipp Wich -* Jochen Voss * Julien Muchembled -* Lavrans Laading -* Loïc Dachary * Loïc Grenié * Lubomír Bulej -* luckyhacky -* LunarShaddow * Mads Kiilerich * Marc A. Lehmann * Mark Glines -* Mark Petryk * Markus Goetz * Martin Kihlgren -* Martin Schobert -* Martin Schürrer -* Martin Weinelt * Matias Carrasco * Max Rijevski * Menno Smits -* Mesar Hameed * Michael Tokarev -* Michael Yonli * Miles Nordin -* Nathan Stratton Treadway -* Murat Donmez -* Nick Hibma * Nick Patavalis * Paul Littlefield -* Philipp Babel -* Pierre Emeriaud -* Pierre-Olivier Mercier -* Rafael Sadowski -* Rafał Leśniak -* Rhosyn Celyn * Robert van der Meulen * Rumko -* Ryan Miller -* Sam Bryan -* Samuel Thibault -* Saverio Proto * Scott Lamb -* Steffan Karger -* Stig Fagrell * Sven-Haegar Koch * Teemu Kiviniemi -* Thomas Tsiakalakis * Timothy Redaelli -* Tomasz Fortuna -* Tomislav Čohar -* Tommy Arnkværn * Tonnerre Lombard -* Ulrich Seifert -* Vil Brekin -* Vittorio Gambaletta -* Wendy Willard * Wessel Dankers -* William A. Kennington III -* William McArthur * Wouter van Heyst -* xentec -* 戴 鸣 -And everyone we forgot (if we did, please let us know). Thank you! +And everyone we forgot. Thank you! ---- -Ivo Timmermans, -Guus Sliepen. +Ivo Timmermans +Guus Sliepen diff --git a/aclocal.m4 b/aclocal.m4 index 06685b5..3e5708a 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.16.1 -*- Autoconf -*- - -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -11,16 +11,139 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. -m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, +[m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically 'autoreconf'.])]) +To do so, use the procedure documented by the package, typically `autoreconf'.])]) -# Copyright (C) 2002-2018 Free Software Foundation, Inc. +dnl Autoconf macros for libgcrypt +dnl Copyright (C) 2002, 2004 Free Software Foundation, Inc. +dnl +dnl This file is free software; as a special exception the author gives +dnl unlimited permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl +dnl This file is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + +dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION, +dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) +dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS. +dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed +dnl with the API version to also check the API compatibility. Example: +dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed +dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using +dnl this features allows to prevent build against newer versions of libgcrypt +dnl with a changed API. +dnl +AC_DEFUN([AM_PATH_LIBGCRYPT], +[ AC_ARG_WITH(libgcrypt-prefix, + AC_HELP_STRING([--with-libgcrypt-prefix=PFX], + [prefix where LIBGCRYPT is installed (optional)]), + libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="") + if test x$libgcrypt_config_prefix != x ; then + if test x${LIBGCRYPT_CONFIG+set} != xset ; then + LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config + fi + fi + + AC_PATH_TOOL(LIBGCRYPT_CONFIG, libgcrypt-config, no) + tmp=ifelse([$1], ,1:1.2.0,$1) + if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then + req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` + min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` + else + req_libgcrypt_api=0 + min_libgcrypt_version="$tmp" + fi + + AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version) + ok=no + if test "$LIBGCRYPT_CONFIG" != "no" ; then + req_major=`echo $min_libgcrypt_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` + req_minor=`echo $min_libgcrypt_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` + req_micro=`echo $min_libgcrypt_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` + libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` + major=`echo $libgcrypt_config_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` + minor=`echo $libgcrypt_config_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` + micro=`echo $libgcrypt_config_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` + if test "$major" -gt "$req_major"; then + ok=yes + else + if test "$major" -eq "$req_major"; then + if test "$minor" -gt "$req_minor"; then + ok=yes + else + if test "$minor" -eq "$req_minor"; then + if test "$micro" -ge "$req_micro"; then + ok=yes + fi + fi + fi + fi + fi + fi + if test $ok = yes; then + AC_MSG_RESULT([yes ($libgcrypt_config_version)]) + else + AC_MSG_RESULT(no) + fi + if test $ok = yes; then + # If we have a recent libgcrypt, we should also check that the + # API is compatible + if test "$req_libgcrypt_api" -gt 0 ; then + tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` + if test "$tmp" -gt 0 ; then + AC_MSG_CHECKING([LIBGCRYPT API version]) + if test "$req_libgcrypt_api" -eq "$tmp" ; then + AC_MSG_RESULT([okay]) + else + ok=no + AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp]) + fi + fi + fi + fi + if test $ok = yes; then + LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` + LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` + ifelse([$2], , :, [$2]) + if test x"$host" != x ; then + libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none` + if test x"$libgcrypt_config_host" != xnone ; then + if test x"$libgcrypt_config_host" != x"$host" ; then + AC_MSG_WARN([[ +*** +*** The config script $LIBGCRYPT_CONFIG was +*** built for $libgcrypt_config_host and thus may not match the +*** used host $host. +*** You may want to use the configure option --with-libgcrypt-prefix +*** to specify a matching config script. +***]]) + fi + fi + fi + else + LIBGCRYPT_CFLAGS="" + LIBGCRYPT_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(LIBGCRYPT_CFLAGS) + AC_SUBST(LIBGCRYPT_LIBS) +]) + +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -32,10 +155,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.16' +[am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.16.1], [], +m4_if([$1], [1.11.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,22 +174,22 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.16.1])dnl +[AM_AUTOMAKE_VERSION([1.11.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to -# '$srcdir', '$srcdir/..', or '$srcdir/../..'. +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and @@ -85,7 +208,7 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is '.', but things will broke when you +# harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, @@ -103,26 +226,30 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], -[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl -# Expand $ac_aux_dir to an absolute path. -am_aux_dir=`cd "$ac_aux_dir" && pwd` +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2018 Free Software Foundation, Inc. +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 9 + # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ([2.52])dnl - m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl @@ -141,14 +268,16 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 10 -# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing @@ -158,7 +287,7 @@ fi])]) # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". +# NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was @@ -171,13 +300,12 @@ AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl -m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], - [$1], [CXX], [depcc="$CXX" am_compiler_list=], - [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], - [$1], [UPC], [depcc="$UPC" am_compiler_list=], - [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], @@ -185,9 +313,8 @@ AC_CACHE_CHECK([dependency style of $depcc], # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -226,16 +353,16 @@ AC_CACHE_CHECK([dependency style of $depcc], : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - # We check with '-c' and '-o' for the sake of the "dashmstdout" + # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in @@ -244,16 +371,16 @@ AC_CACHE_CHECK([dependency style of $depcc], test "$am__universal" = false || continue ;; nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} @@ -301,7 +428,7 @@ AM_CONDITIONAL([am__fastdep$1], [ # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl @@ -311,75 +438,81 @@ AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE([dependency-tracking], [dnl -AS_HELP_STRING( - [--enable-dependency-tracking], - [do not reject slow dependency extractors]) -AS_HELP_STRING( - [--disable-dependency-tracking], - [speeds up one-time build])]) +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' - am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -AC_SUBST([am__nodep])dnl -_AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +#serial 5 + # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ - # Older Autoconf quotes --file arguments for eval, but not when files + # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. - # TODO: see whether this extra hack can be removed once we start - # requiring Autoconf 2.70 or later. - AS_CASE([$CONFIG_FILES], - [*\'*], [eval set x "$CONFIG_FILES"], - [*], [set x $CONFIG_FILES]) + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac shift - # Used to flag and report bootstrapping failures. - am_rc=0 - for am_mf + for mf do # Strip MF so we end up with the name of the file. - am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile which includes - # dependency-tracking related rules and includes. - # Grep'ing the whole file directly is not great: AIX grep has a line + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. - sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ - || continue - am_dirpart=`AS_DIRNAME(["$am_mf"])` - am_filepart=`AS_BASENAME(["$am_mf"])` - AM_RUN_LOG([cd "$am_dirpart" \ - && sed -e '/# am--include-marker/d' "$am_filepart" \ - | $MAKE -f - am--depfiles]) || am_rc=$? + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done done - if test $am_rc -ne 0; then - AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments - for automatic dependency tracking. Try re-running configure with the - '--disable-dependency-tracking' option to at least be able to build - the package (albeit without support for automatic dependency tracking).]) - fi - AS_UNSET([am_dirpart]) - AS_UNSET([am_filepart]) - AS_UNSET([am_mf]) - AS_UNSET([am_rc]) - rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS @@ -388,31 +521,29 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # -# This code is only required when automatic dependency tracking is enabled. -# This creates each '.Po' and '.Plo' makefile fragment that we'll need in -# order to bootstrap the dependency handling code. +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 16 + # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. -dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. -m4_define([AC_PROG_CC], -m4_defn([AC_PROG_CC]) -[_AM_PROG_CC_C_O -]) - # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- @@ -425,7 +556,7 @@ m4_defn([AC_PROG_CC]) # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.65])dnl +[AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl @@ -454,42 +585,33 @@ AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], -[AC_DIAGNOSE([obsolete], - [$0: two- and three-arguments forms are deprecated.]) -m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), - [ok:ok],, +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) - AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) -AM_MISSING_PROG([AUTOCONF], [autoconf]) -AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) -AM_MISSING_PROG([AUTOHEADER], [autoheader]) -AM_MISSING_PROG([MAKEINFO], [makeinfo]) +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# We need awk for the "check" target (and possibly the TAP driver). The -# system "awk" is bad on some platforms. +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl @@ -498,82 +620,34 @@ _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES([CC])], - [m4_define([AC_PROG_CC], - m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES([CXX])], - [m4_define([AC_PROG_CXX], - m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES([OBJC])], - [m4_define([AC_PROG_OBJC], - m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], - [_AM_DEPENDENCIES([OBJCXX])], - [m4_define([AC_PROG_OBJCXX], - m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) -AC_REQUIRE([AM_SILENT_RULES])dnl -dnl The testsuite driver may need to know about EXEEXT, so add the -dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This -dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl - -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. - -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) - fi -fi -dnl The trailing newline in this macro's definition is deliberate, for -dnl backward compatibility and to allow trailing 'dnl'-style comments -dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) -dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. @@ -595,7 +669,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -606,7 +680,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh+set}" != xset; then +if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -614,14 +688,16 @@ if test x"${install_sh+set}" != xset; then install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi -AC_SUBST([install_sh])]) +AC_SUBST(install_sh)]) -# Copyright (C) 2003-2018 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 2 + # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], @@ -635,57 +711,109 @@ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) -# Check to see how 'make' treats includes. -*- Autoconf -*- +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 5 + +# AM_MAINTAINER_MODE([DEFAULT-MODE]) +# ---------------------------------- +# Control maintainer-specific portions of Makefiles. +# Default is to disable them, unless `enable' is passed literally. +# For symmetry, `disable' may be passed as well. Anyway, the user +# can override the default with the --enable/--disable switch. +AC_DEFUN([AM_MAINTAINER_MODE], +[m4_case(m4_default([$1], [disable]), + [enable], [m4_define([am_maintainer_other], [disable])], + [disable], [m4_define([am_maintainer_other], [enable])], + [m4_define([am_maintainer_other], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) +AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) + dnl maintainer-mode's default is 'disable' unless 'enable' is passed + AC_ARG_ENABLE([maintainer-mode], +[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST([MAINT])dnl +] +) + +AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + # AM_MAKE_INCLUDE() # ----------------- -# Check whether make has an 'include' directive that can support all -# the idioms we need for our automatic dependency tracking code. +# Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], -[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) -cat > confinc.mk << 'END' +[am_make=${MAKE-make} +cat > confinc << 'END' am__doit: - @echo this is the am__doit target >confinc.out + @echo this is the am__doit target .PHONY: am__doit END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= -# BSD make does it like this. -echo '.include "confinc.mk" # ignored' > confmf.BSD -# Other make implementations (GNU, Solaris 10, AIX) do it like this. -echo 'include confinc.mk # ignored' > confmf.GNU -_am_result=no -for s in GNU BSD; do - AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) - AS_CASE([$?:`cat confinc.out 2>/dev/null`], - ['0:this is the am__doit target'], - [AS_CASE([$s], - [BSD], [am__include='.include' am__quote='"'], - [am__include='include' am__quote=''])]) - if test "$am__include" != "#"; then - _am_result="yes ($s style)" - break - fi -done -rm -f confinc.* confmf.* -AC_MSG_RESULT([${_am_result}]) -AC_SUBST([am__include])]) -AC_SUBST([am__quote])]) +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2018 Free Software Foundation, Inc. +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 6 + # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], @@ -693,10 +821,11 @@ AC_DEFUN([AM_MISSING_PROG], $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) + # AM_MISSING_HAS_RUN # ------------------ -# Define MISSING if not defined so far and test if it is modern enough. -# If it is, set am_missing_run to use it, otherwise, to nothing. +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl @@ -709,35 +838,63 @@ if test x"${MISSING+set}" != xset; then esac fi # Use eval to expand $SHELL -if eval "$MISSING --is-lightweight"; then - am_missing_run="$MISSING " +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " else am_missing_run= - AC_MSG_WARN(['missing' script is too old or missing]) + AC_MSG_WARN([`missing' script is too old or missing]) fi ]) -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) -# -------------------- +# ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) -# ------------------------ +# ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) @@ -748,82 +905,24 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2018 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_PROG_CC_C_O -# --------------- -# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC -# to automatically call this. -AC_DEFUN([_AM_PROG_CC_C_O], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([compile])dnl -AC_LANG_PUSH([C])dnl -AC_CACHE_CHECK( - [whether $CC understands -c and -o together], - [am_cv_prog_cc_c_o], - [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i]) -if test "$am_cv_prog_cc_c_o" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -AC_LANG_POP([C])]) - -# For backward compatibility. -AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) - -# Copyright (C) 2001-2018 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_RUN_LOG(COMMAND) -# ------------------- -# Run COMMAND, save the exit status in ac_status, and log it. -# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) -AC_DEFUN([AM_RUN_LOG], -[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD - ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - (exit $ac_status); }]) - # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 5 + # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -834,40 +933,32 @@ case `pwd` in esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac -# Do 'set' in a subshell so we don't clobber the current shell's +# Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken - alias in your environment]) - fi - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done test "$[2]" = conftest.file ) then @@ -877,85 +968,9 @@ else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi -AC_MSG_RESULT([yes]) -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi -AC_CONFIG_COMMANDS_PRE( - [AC_MSG_CHECKING([that generated files are newer than configure]) - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - AC_MSG_RESULT([done])]) -rm -f conftest.file -]) +AC_MSG_RESULT(yes)]) -# Copyright (C) 2009-2018 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_SILENT_RULES([DEFAULT]) -# -------------------------- -# Enable less verbose build rules; with the default set to DEFAULT -# ("yes" being less verbose, "no" or empty being verbose). -AC_DEFUN([AM_SILENT_RULES], -[AC_ARG_ENABLE([silent-rules], [dnl -AS_HELP_STRING( - [--enable-silent-rules], - [less verbose build output (undo: "make V=1")]) -AS_HELP_STRING( - [--disable-silent-rules], - [verbose build output (undo: "make V=0")])dnl -]) -case $enable_silent_rules in @%:@ ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; -esac -dnl -dnl A few 'make' implementations (e.g., NonStop OS and NextStep) -dnl do not support nested variable expansions. -dnl See automake bug#9928 and bug#10237. -am_make=${MAKE-make} -AC_CACHE_CHECK([whether $am_make supports nested variables], - [am_cv_make_support_nested_variables], - [if AS_ECHO([['TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi]) -if test $am_cv_make_support_nested_variables = yes; then - dnl Using '$V' instead of '$(V)' breaks IRIX make. - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AC_SUBST([AM_V])dnl -AM_SUBST_NOTMAKE([AM_V])dnl -AC_SUBST([AM_DEFAULT_V])dnl -AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl -AC_SUBST([AM_DEFAULT_VERBOSITY])dnl -AM_BACKSLASH='\' -AC_SUBST([AM_BACKSLASH])dnl -_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl -]) - -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -963,32 +978,34 @@ _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl # AM_PROG_INSTALL_STRIP # --------------------- -# One issue with vendor 'install' (even GNU) is that you can't +# One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in "make install-strip", and initialize +# always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2018 Free Software Foundation, Inc. +# Copyright (C) 2006, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 2 + # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. @@ -996,22 +1013,24 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])]) AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) -# -------------------------- +# --------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2018 Free Software Foundation, Inc. +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# serial 2 + # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. -# FORMAT should be one of 'v7', 'ustar', or 'pax'. +# FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory @@ -1021,124 +1040,82 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar -# AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AC_SUBST([AMTAR], ['$${TAR-tar}']) - -# We'll loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' - +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac - [m4_case([$1], - [ustar], - [# The POSIX 1988 'ustar' format is defined with fixed-size fields. - # There is notably a 21 bits limit for the UID and the GID. In fact, - # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 - # and bug#13588). - am_max_uid=2097151 # 2^21 - 1 - am_max_gid=$am_max_uid - # The $UID and $GID variables are not portable, so we need to resort - # to the POSIX-mandated id(1) utility. Errors in the 'id' calls - # below are definitely unexpected, so allow the users to see them - # (that is, avoid stderr redirection). - am_uid=`id -u || echo unknown` - am_gid=`id -g || echo unknown` - AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) - if test $am_uid -le $am_max_uid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi - AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) - if test $am_gid -le $am_max_gid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi], + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break - [pax], - [], - - [m4_fatal([Unknown tar format])]) - - AC_MSG_CHECKING([how to create a $1 tar archive]) - - # Go ahead even if we have the value already cached. We do so because we - # need to set the values for the 'am__tar' and 'am__untar' variables. - _am_tools=${am_cv_prog_tar_$1-$_am_tools} - - for _am_tool in $_am_tools; do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break - - # tar/untar a dummy directory, and stop if the command works. - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi - done + # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir - AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) - AC_MSG_RESULT([$am_cv_prog_tar_$1])]) - +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/attribute.m4]) -m4_include([m4/ax_append_flag.m4]) -m4_include([m4/ax_cflags_warn_all.m4]) -m4_include([m4/ax_check_compile_flag.m4]) -m4_include([m4/ax_check_link_flag.m4]) -m4_include([m4/ax_require_defined.m4]) +m4_include([m4/curses.m4]) +m4_include([m4/libevent.m4]) m4_include([m4/lzo.m4]) m4_include([m4/openssl.m4]) m4_include([m4/zlib.m4]) diff --git a/compile b/compile deleted file mode 100755 index 99e5052..0000000 --- a/compile +++ /dev/null @@ -1,348 +0,0 @@ -#! /bin/sh -# Wrapper for compilers which do not understand '-c -o'. - -scriptversion=2018-03-07.03; # UTC - -# Copyright (C) 1999-2018 Free Software Foundation, Inc. -# Written by Tom Tromey . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -nl=' -' - -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent tools from complaining about whitespace usage. -IFS=" "" $nl" - -file_conv= - -# func_file_conv build_file lazy -# Convert a $build file to $host form and store it in $file -# Currently only supports Windows hosts. If the determined conversion -# type is listed in (the comma separated) LAZY, no conversion will -# take place. -func_file_conv () -{ - file=$1 - case $file in - / | /[!/]*) # absolute file, and not a UNC file - if test -z "$file_conv"; then - # lazily determine how to convert abs files - case `uname -s` in - MINGW*) - file_conv=mingw - ;; - CYGWIN*) - file_conv=cygwin - ;; - *) - file_conv=wine - ;; - esac - fi - case $file_conv/,$2, in - *,$file_conv,*) - ;; - mingw/*) - file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` - ;; - cygwin/*) - file=`cygpath -m "$file" || echo "$file"` - ;; - wine/*) - file=`winepath -w "$file" || echo "$file"` - ;; - esac - ;; - esac -} - -# func_cl_dashL linkdir -# Make cl look for libraries in LINKDIR -func_cl_dashL () -{ - func_file_conv "$1" - if test -z "$lib_path"; then - lib_path=$file - else - lib_path="$lib_path;$file" - fi - linker_opts="$linker_opts -LIBPATH:$file" -} - -# func_cl_dashl library -# Do a library search-path lookup for cl -func_cl_dashl () -{ - lib=$1 - found=no - save_IFS=$IFS - IFS=';' - for dir in $lib_path $LIB - do - IFS=$save_IFS - if $shared && test -f "$dir/$lib.dll.lib"; then - found=yes - lib=$dir/$lib.dll.lib - break - fi - if test -f "$dir/$lib.lib"; then - found=yes - lib=$dir/$lib.lib - break - fi - if test -f "$dir/lib$lib.a"; then - found=yes - lib=$dir/lib$lib.a - break - fi - done - IFS=$save_IFS - - if test "$found" != yes; then - lib=$lib.lib - fi -} - -# func_cl_wrapper cl arg... -# Adjust compile command to suit cl -func_cl_wrapper () -{ - # Assume a capable shell - lib_path= - shared=: - linker_opts= - for arg - do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as 'compile cc -o foo foo.c'. - eat=1 - case $2 in - *.o | *.[oO][bB][jJ]) - func_file_conv "$2" - set x "$@" -Fo"$file" - shift - ;; - *) - func_file_conv "$2" - set x "$@" -Fe"$file" - shift - ;; - esac - ;; - -I) - eat=1 - func_file_conv "$2" mingw - set x "$@" -I"$file" - shift - ;; - -I*) - func_file_conv "${1#-I}" mingw - set x "$@" -I"$file" - shift - ;; - -l) - eat=1 - func_cl_dashl "$2" - set x "$@" "$lib" - shift - ;; - -l*) - func_cl_dashl "${1#-l}" - set x "$@" "$lib" - shift - ;; - -L) - eat=1 - func_cl_dashL "$2" - ;; - -L*) - func_cl_dashL "${1#-L}" - ;; - -static) - shared=false - ;; - -Wl,*) - arg=${1#-Wl,} - save_ifs="$IFS"; IFS=',' - for flag in $arg; do - IFS="$save_ifs" - linker_opts="$linker_opts $flag" - done - IFS="$save_ifs" - ;; - -Xlinker) - eat=1 - linker_opts="$linker_opts $2" - ;; - -*) - set x "$@" "$1" - shift - ;; - *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) - func_file_conv "$1" - set x "$@" -Tp"$file" - shift - ;; - *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) - func_file_conv "$1" mingw - set x "$@" "$file" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift - done - if test -n "$linker_opts"; then - linker_opts="-link$linker_opts" - fi - exec "$@" $linker_opts - exit 1 -} - -eat= - -case $1 in - '') - echo "$0: No command. Try '$0 --help' for more information." 1>&2 - exit 1; - ;; - -h | --h*) - cat <<\EOF -Usage: compile [--help] [--version] PROGRAM [ARGS] - -Wrapper for compilers which do not understand '-c -o'. -Remove '-o dest.o' from ARGS, run PROGRAM with the remaining -arguments, and rename the output as expected. - -If you are trying to build a whole package this is not the -right script to run: please start by reading the file 'INSTALL'. - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "compile $scriptversion" - exit $? - ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ - icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) - func_cl_wrapper "$@" # Doesn't return... - ;; -esac - -ofile= -cfile= - -for arg -do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as 'compile cc -o foo foo.c'. - # So we strip '-o arg' only if arg is an object. - eat=1 - case $2 in - *.o | *.obj) - ofile=$2 - ;; - *) - set x "$@" -o "$2" - shift - ;; - esac - ;; - *.c) - cfile=$1 - set x "$@" "$1" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift -done - -if test -z "$ofile" || test -z "$cfile"; then - # If no '-o' option was seen then we might have been invoked from a - # pattern rule where we don't need one. That is ok -- this is a - # normal compilation that the losing compiler can handle. If no - # '.c' file was seen then we are probably linking. That is also - # ok. - exec "$@" -fi - -# Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` - -# Create the lock directory. -# Note: use '[/\\:.-]' here to ensure that we don't use the same name -# that we are using for the .o file. Also, base the name on the expected -# object file name, since that is what matters with a parallel build. -lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d -while true; do - if mkdir "$lockdir" >/dev/null 2>&1; then - break - fi - sleep 1 -done -# FIXME: race condition here if user kills between mkdir and trap. -trap "rmdir '$lockdir'; exit 1" 1 2 15 - -# Run the compile. -"$@" -ret=$? - -if test -f "$cofile"; then - test "$cofile" = "$ofile" || mv "$cofile" "$ofile" -elif test -f "${cofile}bj"; then - test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" -fi - -rmdir "$lockdir" -exit $ret - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'before-save-hook 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" -# time-stamp-end: "; # UTC" -# End: diff --git a/config.guess b/config.guess index f50dcdb..40eaed4 100755 --- a/config.guess +++ b/config.guess @@ -1,12 +1,14 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2018 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011 Free Software Foundation, Inc. -timestamp='2018-02-24' +timestamp='2011-05-11' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -15,22 +17,26 @@ timestamp='2018-02-24' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner. Please send patches (context +# diff format) to and include a ChangeLog +# entry. # -# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess -# -# Please send patches to . - +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` @@ -39,7 +45,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Options: +Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +56,9 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2018 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free +Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -107,9 +115,9 @@ trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > "$dummy.c" ; + ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do - if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; @@ -132,40 +140,12 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "$UNAME_SYSTEM" in -Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu - - eval "$set_cc_for_build" - cat <<-EOF > "$dummy.c" - #include - #if defined(__UCLIBC__) - LIBC=uclibc - #elif defined(__dietlibc__) - LIBC=dietlibc - #else - LIBC=gnu - #endif - EOF - eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" - - # If ldd exists, use it to detect musl libc. - if command -v ldd >/dev/null && \ - ldd --version 2>&1 | grep -q ^musl - then - LIBC=musl - fi - ;; -esac - # Note: order is significant - the case branches are not exclusive. -case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -175,31 +155,21 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - "/sbin/$sysctl" 2>/dev/null || \ - "/usr/sbin/$sysctl" 2>/dev/null || \ - echo unknown)` - case "$UNAME_MACHINE_ARCH" in + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; - earmv*) - arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` - machine="${arch}${endian}"-unknown - ;; - *) machine="$UNAME_MACHINE_ARCH"-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently (or will in the future) and ABI. - case "$UNAME_MACHINE_ARCH" in - earm*) - os=netbsdelf - ;; + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval "$set_cc_for_build" + eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -214,67 +184,40 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in os=netbsd ;; esac - # Determine ABI tags. - case "$UNAME_MACHINE_ARCH" in - earm*) - expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` - ;; - esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "$UNAME_VERSION" in + case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) - release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "$machine-${os}${release}${abi}" - exit ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" + echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" - exit ;; - *:LibertyBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" - exit ;; - *:MidnightBSD:*:*) - echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) - echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) - echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd"$UNAME_RELEASE" + echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) - echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; - *:Sortix:*:*) - echo "$UNAME_MACHINE"-unknown-sortix - exit ;; - *:Redox:*:*) - echo "$UNAME_MACHINE"-unknown-redox - exit ;; - mips:OSF1:*.*) - echo mips-dec-osf1 - exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -291,54 +234,63 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE=alpha ;; + UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") - UNAME_MACHINE=alpha ;; + UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") - UNAME_MACHINE=alpha ;; + UNAME_MACHINE="alpha" ;; "EV5 (21164)") - UNAME_MACHINE=alphaev5 ;; + UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") - UNAME_MACHINE=alphaev56 ;; + UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") - UNAME_MACHINE=alphapca56 ;; + UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") - UNAME_MACHINE=alphapca57 ;; + UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") - UNAME_MACHINE=alphaev6 ;; + UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") - UNAME_MACHINE=alphaev67 ;; + UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") - UNAME_MACHINE=alphaev68 ;; + UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") - UNAME_MACHINE=alphaev68 ;; + UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") - UNAME_MACHINE=alphaev68 ;; + UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE=alphaev69 ;; + UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") - UNAME_MACHINE=alphaev7 ;; + UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") - UNAME_MACHINE=alphaev79 ;; + UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo "$UNAME_MACHINE"-unknown-amigaos + echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo "$UNAME_MACHINE"-unknown-morphos + echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -350,9 +302,9 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix"$UNAME_RELEASE" + echo arm-acorn-riscix${UNAME_RELEASE} exit ;; - arm*:riscos:*:*|arm*:RISCOS:*:*) + arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -377,38 +329,38 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux"$UNAME_RELEASE" + echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval "$set_cc_for_build" - SUN_ARCH=i386 + eval $set_cc_for_build + SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH=x86_64 + SUN_ARCH="x86_64" fi fi - echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -417,25 +369,25 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos"$UNAME_RELEASE" + echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos"$UNAME_RELEASE" + echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) - echo sparc-sun-sunos"$UNAME_RELEASE" + echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos"$UNAME_RELEASE" + echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -446,44 +398,44 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" + echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" + echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" + echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint"$UNAME_RELEASE" + echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint"$UNAME_RELEASE" + echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint"$UNAME_RELEASE" + echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) - echo m68k-apple-machten"$UNAME_RELEASE" + echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten"$UNAME_RELEASE" + echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix"$UNAME_RELEASE" + echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix"$UNAME_RELEASE" + echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix"$UNAME_RELEASE" + echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval "$set_cc_for_build" - sed 's/^ //' << EOF > "$dummy.c" + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -492,23 +444,23 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o "$dummy" "$dummy.c" && - dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`"$dummy" "$dummyarg"` && + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos"$UNAME_RELEASE" + echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -534,17 +486,17 @@ EOF AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then - if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ - [ "$TARGET_BINARY_INTERFACE"x = x ] + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] then - echo m88k-dg-dgux"$UNAME_RELEASE" + echo m88k-dg-dgux${UNAME_RELEASE} else - echo m88k-dg-dguxbcs"$UNAME_RELEASE" + echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else - echo i586-dg-dgux"$UNAME_RELEASE" + echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -561,7 +513,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id @@ -573,14 +525,14 @@ EOF if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi - echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval "$set_cc_for_build" - sed 's/^ //' << EOF > "$dummy.c" + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c #include main() @@ -591,7 +543,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else @@ -605,27 +557,26 @@ EOF exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | - awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` else - IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi - echo "$IBM_ARCH"-ibm-aix"$IBM_REV" + echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -640,28 +591,28 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` - case "$UNAME_MACHINE" in - 9000/31?) HP_ARCH=m68000 ;; - 9000/[34]??) HP_ARCH=m68k ;; + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "$sc_cpu_version" in - 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 - 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "$sc_kernel_bits" in - 32) HP_ARCH=hppa2.0n ;; - 64) HP_ARCH=hppa2.0w ;; - '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi - if [ "$HP_ARCH" = "" ]; then - eval "$set_cc_for_build" - sed 's/^ //' << EOF > "$dummy.c" + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include @@ -694,13 +645,13 @@ EOF exit (0); } EOF - (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ "$HP_ARCH" = hppa2.0w ] + if [ ${HP_ARCH} = "hppa2.0w" ] then - eval "$set_cc_for_build" + eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -711,23 +662,23 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH=hppa2.0w + HP_ARCH="hppa2.0w" else - HP_ARCH=hppa64 + HP_ARCH="hppa64" fi fi - echo "$HP_ARCH"-hp-hpux"$HPUX_REV" + echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux"$HPUX_REV" + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) - eval "$set_cc_for_build" - sed 's/^ //' << EOF > "$dummy.c" + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c #include int main () @@ -752,11 +703,11 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -765,7 +716,7 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) @@ -773,9 +724,9 @@ EOF exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo "$UNAME_MACHINE"-unknown-osf1mk + echo ${UNAME_MACHINE}-unknown-osf1mk else - echo "$UNAME_MACHINE"-unknown-osf1 + echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -800,109 +751,115 @@ EOF echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` - FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi"$UNAME_RELEASE" + echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) - echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case "$UNAME_PROCESSOR" in + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; amd64) - UNAME_PROCESSOR=x86_64 ;; - i386) - UNAME_PROCESSOR=i586 ;; + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac - echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo "$UNAME_MACHINE"-pc-cygwin - exit ;; - *:MINGW64*:*) - echo "$UNAME_MACHINE"-pc-mingw64 + echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) - echo "$UNAME_MACHINE"-pc-mingw32 + echo ${UNAME_MACHINE}-pc-mingw32 exit ;; - *:MSYS*:*) - echo "$UNAME_MACHINE"-pc-msys + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) - echo "$UNAME_MACHINE"-pc-pw32 + echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) - case "$UNAME_MACHINE" in + case ${UNAME_MACHINE} in x86) - echo i586-pc-interix"$UNAME_RELEASE" + echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix"$UNAME_RELEASE" + echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) - echo ia64-unknown-interix"$UNAME_RELEASE" + echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; i*:UWIN*:*) - echo "$UNAME_MACHINE"-pc-uwin + echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system - echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) - echo "$UNAME_MACHINE"-pc-minix - exit ;; - aarch64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-pc-minix exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -915,64 +872,60 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) - eval "$set_cc_for_build" + eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi + echo ${UNAME_MACHINE}-unknown-linux-gnueabi else - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf + echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) - echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) - echo "$UNAME_MACHINE"-axis-linux-"$LIBC" - exit ;; - e2k:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - hexagon:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo frv-unknown-linux-gnu exit ;; i*86:Linux:*:*) - echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + LIBC=gnu + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - k1om:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval "$set_cc_for_build" - sed 's/^ //' << EOF > "$dummy.c" + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el @@ -986,74 +939,55 @@ EOF #endif #endif EOF - eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" - test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; - mips64el:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - openrisc*:Linux:*:*) - echo or1k-unknown-linux-"$LIBC" - exit ;; - or32:Linux:*:* | or1k*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + or32:Linux:*:*) + echo or32-unknown-linux-gnu exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-"$LIBC" + echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-"$LIBC" + echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; - PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; - *) echo hppa-unknown-linux-"$LIBC" ;; + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-"$LIBC" + echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-"$LIBC" - exit ;; - ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-"$LIBC" - exit ;; - ppcle:Linux:*:*) - echo powerpcle-unknown-linux-"$LIBC" - exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" + echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-tilera-linux-gnu exit ;; vax:Linux:*:*) - echo "$UNAME_MACHINE"-dec-linux-"$LIBC" + echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) - if objdump -f /bin/sh | grep -q elf32-x86-64; then - echo "$UNAME_MACHINE"-pc-linux-"$LIBC"x32 - else - echo "$UNAME_MACHINE"-pc-linux-"$LIBC" - fi + echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1067,34 +1001,34 @@ EOF # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo "$UNAME_MACHINE"-pc-os2-emx + echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo "$UNAME_MACHINE"-unknown-stop + echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) - echo "$UNAME_MACHINE"-unknown-atheos + echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) - echo "$UNAME_MACHINE"-pc-syllable + echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos"$UNAME_RELEASE" + echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) - echo "$UNAME_MACHINE"-pc-msdosdjgpp + echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; - i*86:*:4.*:*) - UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else - echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) @@ -1104,12 +1038,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1119,9 +1053,9 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else - echo "$UNAME_MACHINE"-pc-sysv32 + echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) @@ -1129,7 +1063,7 @@ EOF # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configure will decide that + # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; @@ -1141,9 +1075,9 @@ EOF exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1163,9 +1097,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1174,28 +1108,28 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos"$UNAME_RELEASE" + echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos"$UNAME_RELEASE" + echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos"$UNAME_RELEASE" + echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos"$UNAME_RELEASE" + echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv"$UNAME_RELEASE" + echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1206,7 +1140,7 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo "$UNAME_MACHINE"-sni-sysv4 + echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi @@ -1226,23 +1160,23 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo "$UNAME_MACHINE"-stratus-vos + echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux"$UNAME_RELEASE" + echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv"$UNAME_RELEASE" + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv"$UNAME_RELEASE" + echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. @@ -1257,97 +1191,66 @@ EOF BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux"$UNAME_RELEASE" + echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux"$UNAME_RELEASE" + echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux"$UNAME_RELEASE" + echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux"$UNAME_RELEASE" + echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux"$UNAME_RELEASE" + echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux"$UNAME_RELEASE" - exit ;; - SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux"$UNAME_RELEASE" + echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody"$UNAME_RELEASE" + echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) - echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval "$set_cc_for_build" - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc - fi - if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc - if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_PPC >/dev/null - then - UNAME_PROCESSOR=powerpc - fi - fi - elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 - fi - echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" + case $UNAME_PROCESSOR in + i386) + eval $set_cc_for_build + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + UNAME_PROCESSOR="x86_64" + fi + fi ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = x86; then + if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-*:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk"$UNAME_RELEASE" + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} exit ;; - NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk"$UNAME_RELEASE" + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} exit ;; - NSR-*:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk"$UNAME_RELEASE" - exit ;; - NSV-*:NONSTOP_KERNEL:*:*) - echo nsv-tandem-nsk"$UNAME_RELEASE" - exit ;; - NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk"$UNAME_RELEASE" + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1356,18 +1259,18 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = 386; then + if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo "$UNAME_MACHINE"-unknown-plan9 + echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1388,14 +1291,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux"$UNAME_RELEASE" + echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) - echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "$UNAME_MACHINE" in + case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1404,48 +1307,182 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) - echo "$UNAME_MACHINE"-pc-rdos + echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) - echo "$UNAME_MACHINE"-pc-aros - exit ;; - x86_64:VMkernel:*:*) - echo "$UNAME_MACHINE"-unknown-esx - exit ;; - amd64:Isilon\ OneFS:*:*) - echo x86_64-unknown-onefs + echo ${UNAME_MACHINE}-pc-aros exit ;; esac -echo "$0: unable to guess system type" >&2 +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 -case "$UNAME_MACHINE:$UNAME_SYSTEM" in - mips:Linux | mips64:Linux) - # If we got here on MIPS GNU/Linux, output extra information. - cat >&2 <$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif -NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize -the system type. Please install a C compiler and try again. +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} EOF - ;; -esac + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi cat >&2 < in order to provide the needed +information to handle your system. config.guess timestamp = $timestamp @@ -1464,16 +1501,16 @@ hostinfo = `(hostinfo) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = "$UNAME_MACHINE" -UNAME_RELEASE = "$UNAME_RELEASE" -UNAME_SYSTEM = "$UNAME_SYSTEM" -UNAME_VERSION = "$UNAME_VERSION" +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: -# eval: (add-hook 'write-file-functions 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/config.h.in b/config.h.in index cc68348..3d4493a 100644 --- a/config.h.in +++ b/config.h.in @@ -1,4 +1,4 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ +/* config.h.in. Generated from configure.in by autoheader. */ /* Support for jumbograms (packets up to 9000 bytes) */ #undef ENABLE_JUMBOGRAMS @@ -6,27 +6,21 @@ /* Support for tunemu */ #undef ENABLE_TUNEMU -/* Support for UML */ -#undef ENABLE_UML - -/* Support for VDE */ -#undef ENABLE_VDE - /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H -/* Define to 1 if you have the header file. */ -#undef HAVE_ARPA_NAMESER_H - /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF -/* Define to 1 if you have the `BN_GENCB_new' function. */ -#undef HAVE_BN_GENCB_NEW - /* Unknown BSD variant */ #undef HAVE_BSD +/* have curses support */ +#undef HAVE_CURSES + +/* Define to 1 if you have the header file. */ +#undef HAVE_CURSES_H + /* Cygwin */ #undef HAVE_CYGWIN @@ -36,10 +30,6 @@ /* Darwin (MacOS/X) */ #undef HAVE_DARWIN -/* Define to 1 if you have the declaration of `EVP_aes_256_cfb', and to 0 if - you don't. */ -#undef HAVE_DECL_EVP_AES_256_CFB - /* Define to 1 if you have the declaration of `freeaddrinfo', and to 0 if you don't. */ #undef HAVE_DECL_FREEADDRINFO @@ -56,25 +46,14 @@ don't. */ #undef HAVE_DECL_GETNAMEINFO -/* Define to 1 if you have the declaration of `OpenSSL_add_all_algorithms', - and to 0 if you don't. */ -#undef HAVE_DECL_OPENSSL_ADD_ALL_ALGORITHMS - -/* Define to 1 if you have the declaration of `res_init', and to 0 if you - don't. */ -#undef HAVE_DECL_RES_INIT - -/* Define to 1 if you have the `devname' function. */ -#undef HAVE_DEVNAME - /* Define to 1 if you have the header file. */ #undef HAVE_DIRENT_H /* DragonFly */ #undef HAVE_DRAGONFLY -/* Define to 1 if you have the `EVP_CIPHER_CTX_new' function. */ -#undef HAVE_EVP_CIPHER_CTX_NEW +/* Define to 1 if you have the header file. */ +#undef HAVE_EVENT_H /* Define to 1 if you have the `EVP_EncryptInit_ex' function. */ #undef HAVE_EVP_ENCRYPTINIT_EX @@ -82,9 +61,6 @@ /* Define to 1 if you have the `fchmod' function. */ #undef HAVE_FCHMOD -/* Define to 1 if you have the `fdevname' function. */ -#undef HAVE_FDEVNAME - /* Define to 1 if you have the `flock' function. */ #undef HAVE_FLOCK @@ -94,30 +70,24 @@ /* FreeBSD */ #undef HAVE_FREEBSD -/* Define to 1 if you have the header file. */ -#undef HAVE_GETOPT_H - -/* getopt_long() */ -#undef HAVE_GETOPT_LONG +/* Define to 1 if you have the `ftime' function. */ +#undef HAVE_FTIME /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY +/* Define to 1 if you have the `get_current_dir_name' function. */ +#undef HAVE_GET_CURRENT_DIR_NAME + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL -/* Define to 1 if you have the `resolv' library (-lresolv). */ -#undef HAVE_LIBRESOLV - /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET -/* Define to 1 if you have the header file. */ -#undef HAVE_LIBVDEPLUG_DYN_H - /* Linux */ #undef HAVE_LINUX @@ -178,9 +148,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_H -/* Define to 1 if you have the header file. */ -#undef HAVE_NETPACKET_PACKET_H - /* Define to 1 if you have the header file. */ #undef HAVE_NET_ETHERNET_H @@ -199,9 +166,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_TYPES_H -/* Define to 1 if you have the header file. */ -#undef HAVE_NET_IF_UTUN_H - /* Define to 1 if you have the header file. */ #undef HAVE_NET_TAP_IF_TAP_H @@ -232,20 +196,17 @@ /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_SHA_H -/* Define to 1 if you have the `pselect' function. */ -#undef HAVE_PSELECT - /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV -/* Define to 1 if you have the `RAND_bytes' function. */ -#undef HAVE_RAND_BYTES +/* Define to 1 if you have the `random' function. */ +#undef HAVE_RANDOM -/* Define to 1 if you have the header file. */ -#undef HAVE_RESOLV_H +/* Define to 1 if you have the `RAND_pseudo_bytes' function. */ +#undef HAVE_RAND_PSEUDO_BYTES -/* Define to 1 if you have the `RSA_set0_key' function. */ -#undef HAVE_RSA_SET0_KEY +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT /* Define to 1 if the system has the type `socklen_t'. */ #undef HAVE_SOCKLEN_T @@ -253,12 +214,21 @@ /* Solaris/SunOS */ #undef HAVE_SOLARIS +/* Define to 1 if you have the header file. */ +#undef HAVE_STDBOOL_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H @@ -268,6 +238,9 @@ /* Define to 1 if you have the `strsignal' function. */ #undef HAVE_STRSIGNAL +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + /* Define to 1 if the system has the type `struct addrinfo'. */ #undef HAVE_STRUCT_ADDRINFO @@ -343,9 +316,18 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UIO_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_UN_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_WAIT_H +/* Define to 1 if you have the `time' function. */ +#undef HAVE_TIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_TIME_H + /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H @@ -358,6 +340,9 @@ /* Define to 1 if you have the `vsyslog' function. */ #undef HAVE_VSYSLOG +/* Define to 1 if you have the `writev' function. */ +#undef HAVE_WRITEV + /* have zlib compression support */ #undef HAVE_ZLIB @@ -394,6 +379,12 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE @@ -438,5 +429,15 @@ /* Defined if the __malloc__ attribute is not supported. */ #undef __malloc__ +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + /* Define to `int' if does not define. */ #undef pid_t + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* Define to empty if the keyword `volatile' does not work. Warning: valid + code using `volatile' can become incorrect without. Disable with care. */ +#undef volatile diff --git a/config.sub b/config.sub index 1d8e98b..30fdca8 100755 --- a/config.sub +++ b/config.sub @@ -1,31 +1,38 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2018 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011 Free Software Foundation, Inc. -timestamp='2018-02-22' +timestamp='2011-03-23' -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that -# program. This Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). +# the same distribution terms that you use for the rest of that program. -# Please send patches to . +# Please send patches to . Submit a context +# diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -33,7 +40,7 @@ timestamp='2018-02-22' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -53,11 +60,12 @@ timestamp='2018-02-22' me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS Canonicalize a configuration name. -Options: +Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -67,7 +75,9 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2018 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free +Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -94,7 +104,7 @@ while test $# -gt 0 ; do *local*) # First pass through any local machine types. - echo "$1" + echo $1 exit ;; * ) @@ -112,24 +122,20 @@ esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ + linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os - basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) - basic_machine=`echo "$1" | sed 's/-[^-]*$//'` - if [ "$basic_machine" != "$1" ] - then os=`echo "$1" | sed 's/.*-/-/'` + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac @@ -148,7 +154,7 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) + -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; @@ -178,56 +184,53 @@ case $os in ;; -sco6) os=-sco5v6 - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) - basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) - basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos @@ -244,29 +247,20 @@ case $basic_machine in # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ - | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ - | c4x | c8051 | clipper \ + | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ + | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia16 | ia64 \ + | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -280,39 +274,34 @@ case $basic_machine in | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ + | nios | nios2 \ | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pj | pjl \ + | open8 \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ + | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | wasm32 \ + | v850 | v850e \ + | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown @@ -326,14 +315,12 @@ case $basic_machine in c6x) basic_machine=tic6x-unknown ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + m6811 | m68hc11 | m6812 | m68hc12 | picochip) + # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown @@ -342,10 +329,7 @@ case $basic_machine in strongarm | thumb | xscale) basic_machine=arm-unknown ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; + xscaleeb) basic_machine=armeb-unknown ;; @@ -362,38 +346,31 @@ case $basic_machine in ;; # Object if more than one company name word. *-*-*) - echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ - | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ + | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ + | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -407,43 +384,34 @@ case $basic_machine in | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ - | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ + | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ + | tile-* | tilegx-* \ | tron-* \ | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | wasm32-* \ + | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -457,7 +425,7 @@ case $basic_machine in # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) - basic_machine=i386-pc + basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) @@ -491,7 +459,7 @@ case $basic_machine in basic_machine=x86_64-pc ;; amd64-*) - basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl @@ -520,9 +488,6 @@ case $basic_machine in basic_machine=i386-pc os=-aros ;; - asmjs) - basic_machine=asmjs-unknown - ;; aux) basic_machine=m68k-apple os=-aux @@ -536,7 +501,7 @@ case $basic_machine in os=-linux ;; blackfin-*) - basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) @@ -544,13 +509,13 @@ case $basic_machine in os=-cnk ;; c54x-*) - basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) - basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) - basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray @@ -639,18 +604,10 @@ case $basic_machine in basic_machine=rs6000-bull os=-bosx ;; - dpx2*) + dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=$os"spe" - ;; ebmon29k) basic_machine=a29k-amd os=-ebmon @@ -740,6 +697,9 @@ case $basic_machine in hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; + hppa-next) + os=-nextstep3 + ;; hppaosf) basic_machine=hppa1.1-hp os=-osf @@ -751,27 +711,28 @@ case $basic_machine in i370-ibm* | ibm*) basic_machine=i370-ibm ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; - vsta) + i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; @@ -789,17 +750,17 @@ case $basic_machine in basic_machine=m68k-isi os=-sysv ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` - ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) - basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; + m88k-omron*) + basic_machine=m88k-omron + ;; magnum | m3230) basic_machine=mips-mips os=-sysv @@ -808,15 +769,11 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; - microblaze*) + microblaze) basic_machine=microblaze-xilinx ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; mingw32) - basic_machine=i686-pc + basic_machine=i386-pc os=-mingw32 ;; mingw32ce) @@ -831,10 +788,10 @@ case $basic_machine in os=-mint ;; mips3*-*) - basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) - basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k @@ -844,29 +801,17 @@ case $basic_machine in basic_machine=powerpc-unknown os=-morphos ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) - basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -895,7 +840,7 @@ case $basic_machine in basic_machine=v70-nec os=-sysv ;; - next | m*-next) + next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) @@ -940,12 +885,6 @@ case $basic_machine in nsr-tandem) basic_machine=nsr-tandem ;; - nsv-tandem) - basic_machine=nsv-tandem - ;; - nsx-tandem) - basic_machine=nsx-tandem - ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf @@ -978,7 +917,7 @@ case $basic_machine in os=-linux ;; parisc-*) - basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) @@ -994,7 +933,7 @@ case $basic_machine in basic_machine=i386-pc ;; pc98-*) - basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc @@ -1009,16 +948,16 @@ case $basic_machine in basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) - basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould @@ -1028,23 +967,23 @@ case $basic_machine in ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) - basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle) + ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; - ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little) + ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm @@ -1053,11 +992,7 @@ case $basic_machine in basic_machine=i586-unknown os=-pw32 ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) + rdos) basic_machine=i386-pc os=-rdos ;; @@ -1098,10 +1033,17 @@ case $basic_machine in sequent) basic_machine=i386-sequent ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; sh5el) basic_machine=sh5le-unknown ;; - simso-wrs) + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; @@ -1120,7 +1062,7 @@ case $basic_machine in os=-sysv4 ;; strongarm-* | thumb-*) - basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun @@ -1178,8 +1120,13 @@ case $basic_machine in basic_machine=t90-cray os=-unicos ;; + # This must be matched before tile*. + tilegx*) + basic_machine=tilegx-unknown + os=-linux-gnu + ;; tile*) - basic_machine=$basic_machine-unknown + basic_machine=tile-unknown os=-linux-gnu ;; tx39) @@ -1242,9 +1189,6 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; - x64) - basic_machine=x86_64-pc - ;; xbox) basic_machine=i686-pc os=-mingw32 @@ -1253,12 +1197,20 @@ case $basic_machine in basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) - basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; none) basic_machine=none-none os=-none @@ -1287,6 +1239,10 @@ case $basic_machine in vax) basic_machine=vax-dec ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; pdp11) basic_machine=pdp11-dec ;; @@ -1296,6 +1252,9 @@ case $basic_machine in sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; cydra) basic_machine=cydra-cydrome ;; @@ -1315,7 +1274,7 @@ case $basic_machine in # Make sure to match an already-canonicalized machine name. ;; *) - echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac @@ -1323,10 +1282,10 @@ esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) - basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) - basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; @@ -1337,8 +1296,8 @@ esac if [ x"$os" != x"" ] then case $os in - # First match some system type aliases that might get confused - # with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux @@ -1349,48 +1308,45 @@ case $os in -solaris) os=-solaris2 ;; + -svr4*) + os=-sysv4 + ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # es1800 is here to avoid being matched by es* (a different OS) - -es1800*) - os=-ose - ;; - # Now accept the basic system types. + # First accept the basic system types. # The portable systems comes first. - # Each alternative MUST end in a * to match a version number. + # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ + | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* | -cloudabi* | -sortix* \ + | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -windiss* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ - | -midnightbsd*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1407,12 +1363,12 @@ case $os in -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; - -sim | -xray | -os68k* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* \ + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) - os=`echo "$os" | sed -e 's|mac|macos|'` + os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc @@ -1421,10 +1377,10 @@ case $os in os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) - os=`echo "$os" | sed -e 's|sunos5|solaris2|'` + os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) - os=`echo "$os" | sed -e 's|sunos6|solaris3|'` + os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition @@ -1435,6 +1391,12 @@ case $os in -wince*) os=-wince ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; -utek*) os=-bsd ;; @@ -1459,7 +1421,7 @@ case $os in -nova*) os=-rtmk-nova ;; - -ns2) + -ns2 ) os=-nextstep2 ;; -nsk*) @@ -1481,7 +1443,7 @@ case $os in -oss*) os=-sysv3 ;; - -svr4*) + -svr4) os=-sysv4 ;; -svr3) @@ -1496,38 +1458,35 @@ case $os in -ose*) os=-ose ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; - -pikeos*) - # Until real need of OS specific support for - # particular features comes up, bare metal - # configurations are quite functional. - case $basic_machine in - arm*) - os=-eabi - ;; - *) - os=-elf - ;; - esac - ;; -nacl*) ;; - -ios) - ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac @@ -1562,12 +1521,6 @@ case $basic_machine in c4x-* | tic4x-*) os=-coff ;; - c8051-*) - os=-elf - ;; - hexagon-*) - os=-elf - ;; tic54x-*) os=-coff ;; @@ -1595,6 +1548,9 @@ case $basic_machine in ;; m68000-sun) os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 ;; m68*-cisco) os=-aout @@ -1617,12 +1573,12 @@ case $basic_machine in sparc-* | *-sun) os=-sunos4.1.1 ;; - pru-*) - os=-elf - ;; *-be) os=-beos ;; + *-haiku) + os=-haiku + ;; *-ibm) os=-aix ;; @@ -1662,7 +1618,7 @@ case $basic_machine in m88k-omron*) os=-luna ;; - *-next) + *-next ) os=-nextstep ;; *-sequent) @@ -1677,6 +1633,9 @@ case $basic_machine in i370-*) os=-mvs ;; + *-next) + os=-nextstep3 + ;; *-gould) os=-sysv ;; @@ -1786,15 +1745,15 @@ case $basic_machine in vendor=stratus ;; esac - basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo "$basic_machine$os" +echo $basic_machine$os exit # Local variables: -# eval: (add-hook 'write-file-functions 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/configure b/configure index 26dd965..a87b0e9 100755 --- a/configure +++ b/configure @@ -1,9 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for tinc 1.0.35. +# Generated by GNU Autoconf 2.68. # # -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -132,31 +134,6 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -190,8 +167,7 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" +test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -236,25 +212,21 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -356,14 +328,6 @@ $as_echo X"$as_dir" | } # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -485,10 +449,6 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -523,16 +483,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' + as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -544,8 +504,28 @@ else as_mkdir_p=false fi -as_test_x='test -x' -as_executable_p=as_fn_executable_p +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -575,12 +555,12 @@ MFLAGS= MAKEFLAGS= # Identity of this package. -PACKAGE_NAME='tinc' -PACKAGE_TARNAME='tinc' -PACKAGE_VERSION='1.0.35' -PACKAGE_STRING='tinc 1.0.35' -PACKAGE_BUGREPORT='' -PACKAGE_URL='' +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= +PACKAGE_URL= ac_unique_file="src/tincd.c" # Factoring default headers for most tests. @@ -623,27 +603,13 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS -GETOPT_FALSE -GETOPT_TRUE -WITH_SYSTEMD_FALSE -WITH_SYSTEMD_TRUE +INCLUDES +LIBGCRYPT_LIBS +LIBGCRYPT_CFLAGS +LIBGCRYPT_CONFIG +CURSES_LIBS TUNEMU_FALSE TUNEMU_TRUE -VDE_FALSE -VDE_TRUE -UML_FALSE -UML_TRUE -CYGWIN_FALSE -CYGWIN_TRUE -MINGW_FALSE -MINGW_TRUE -SOLARIS_FALSE -SOLARIS_TRUE -BSD_FALSE -BSD_TRUE -LINUX_FALSE -LINUX_TRUE -systemd_path host_os host_vendor host_cpu @@ -652,29 +618,20 @@ build_os build_vendor build_cpu build -EGREP -GREP -CPP +RANLIB +LN_S +MAINT +MAINTAINER_MODE_FALSE +MAINTAINER_MODE_TRUE am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE -am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE +am__quote am__include DEPDIR -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -AM_BACKSLASH -AM_DEFAULT_VERBOSITY -AM_DEFAULT_V -AM_V am__untar am__tar AMTAR @@ -698,6 +655,16 @@ am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM +EGREP +GREP +CPP +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC target_alias host_alias build_alias @@ -717,7 +684,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -736,19 +702,22 @@ PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR -SHELL -am__quote' +SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking -enable_silent_rules enable_dependency_tracking -enable_uml -enable_vde +enable_maintainer_mode enable_tunemu with_windows2000 -with_systemd -enable_hardening +with_libgcrypt +enable_curses +with_curses +with_curses_include +with_curses_lib +with_libevent +with_libevent_include +with_libevent_lib enable_zlib with_zlib with_zlib_include @@ -757,6 +726,7 @@ enable_lzo with_lzo with_lzo_include with_lzo_lib +with_libgcrypt_prefix with_openssl with_openssl_include with_openssl_lib @@ -809,10 +779,9 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +docdir='${datarootdir}/doc/${PACKAGE}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' @@ -1062,15 +1031,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1208,7 +1168,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1236,6 +1196,8 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1321,7 +1283,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures tinc 1.0.35 to adapt to many kinds of systems. +\`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1361,7 +1323,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1370,7 +1331,7 @@ Fine tuning of the installation directories: --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/tinc] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] @@ -1391,25 +1352,19 @@ _ACEOF fi if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of tinc 1.0.35:";; - esac + cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-silent-rules less verbose build output (undo: "make V=1") - --disable-silent-rules verbose build output (undo: "make V=0") - --enable-dependency-tracking - do not reject slow dependency extractors - --disable-dependency-tracking - speeds up one-time build - --enable-uml enable support for User Mode Linux - --enable-vde enable support for Virtual Distributed Ethernet + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer --enable-tunemu enable support for the tunemu driver - --disable-hardening disable compiler and linker hardening flags + --disable-curses disable curses support --disable-zlib disable zlib compression support --disable-lzo disable lzo compression support --enable-jumbograms enable support for jumbograms (packets up to 9000 @@ -1420,18 +1375,28 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-windows2000 compile with support for Windows 2000. This disables support for tunneling over existing IPv6 networks. - --with-systemd[=DIR] install systemd service files [to DIR if specified] + --with-libgcrypt enable use of libgcrypt instead of OpenSSL] + --with-curses=DIR curses base directory, or: + --with-curses-include=DIR + curses headers directory + --with-curses-lib=DIR curses library directory + --with-libevent=DIR libevent base directory, or: + --with-libevent-include=DIR + libevent headers directory + --with-libevent-lib=DIR libevent library directory --with-zlib=DIR zlib base directory, or: --with-zlib-include=DIR zlib headers directory --with-zlib-lib=DIR zlib library directory --with-lzo=DIR lzo base directory, or: --with-lzo-include=DIR lzo headers directory --with-lzo-lib=DIR lzo library directory - --with-openssl=DIR LibreSSL/OpenSSL base directory, or: + --with-libgcrypt-prefix=PFX + prefix where LIBGCRYPT is installed (optional) + --with-openssl=DIR OpenSSL base directory, or: --with-openssl-include=DIR - LibreSSL/OpenSSL headers directory (without trailing + OpenSSL headers directory (without trailing /openssl) - --with-openssl-lib=DIR LibreSSL/OpenSSL library directory + --with-openssl-lib=DIR OpenSSL library directory Some influential environment variables: CC C compiler command @@ -1509,10 +1474,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -tinc configure 1.0.35 -generated by GNU Autoconf 2.69 +configure +generated by GNU Autoconf 2.68 -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1758,52 +1723,6 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_header_compile -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache @@ -1858,6 +1777,52 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_type +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -1974,8 +1939,8 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by tinc $as_me 1.0.35, which was -generated by GNU Autoconf 2.69. Invocation command line was +It was created by $as_me, which was +generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2323,723 +2288,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -am__api_version='1.16' - -ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if ${ac_cv_path_install+:} false; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - - done -IFS=$as_save_IFS - -rm -rf conftest.one conftest.two conftest.dir - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 -$as_echo_n "checking whether build environment is sane... " >&6; } -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; -esac -case $srcdir in - *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; -esac - -# Do 'set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error $? "ls -t appears to fail. Make sure there is not a broken - alias in your environment" "$LINENO" 5 - fi - if test "$2" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - test "$2" = conftest.file - ) -then - # Ok. - : -else - as_fn_error $? "newly created file is older than distributed files! -Check your system clock" "$LINENO" 5 -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi - -rm -f conftest.file - -test "$program_prefix" != NONE && - program_transform_name="s&^&$program_prefix&;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s&\$&$program_suffix&;$program_transform_name" -# Double any \ or $. -# By default was `s,x,x', remove it if useless. -ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' -program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` - -# Expand $ac_aux_dir to an absolute path. -am_aux_dir=`cd "$ac_aux_dir" && pwd` - -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --is-lightweight"; then - am_missing_run="$MISSING " -else - am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} -fi - -if test x"${install_sh+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi - -# Installed binaries are usually stripped using 'strip' when the user -# run "make install-strip". However 'strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the 'STRIP' environment variable to overrule this program. -if test "$cross_compiling" != no; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 -$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } -if test -z "$MKDIR_P"; then - if ${ac_cv_path_mkdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in mkdir gmkdir; do - for ac_exec_ext in '' $ac_executable_extensions; do - as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue - case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( - 'mkdir (GNU coreutils) '* | \ - 'mkdir (coreutils) '* | \ - 'mkdir (fileutils) '4.1*) - ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext - break 3;; - esac - done - done - done -IFS=$as_save_IFS - -fi - - test -d ./--version && rmdir ./--version - if test "${ac_cv_path_mkdir+set}" = set; then - MKDIR_P="$ac_cv_path_mkdir -p" - else - # As a last resort, use the slow shell script. Don't cache a - # value for MKDIR_P within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - MKDIR_P="$ac_install_sh -d" - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 -$as_echo "$MKDIR_P" >&6; } - -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -$as_echo "$AWK" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AWK" && break -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - -rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null - -# Check whether --enable-silent-rules was given. -if test "${enable_silent_rules+set}" = set; then : - enableval=$enable_silent_rules; -fi - -case $enable_silent_rules in # ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=1;; -esac -am_make=${MAKE-make} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 -$as_echo_n "checking whether $am_make supports nested variables... " >&6; } -if ${am_cv_make_support_nested_variables+:} false; then : - $as_echo_n "(cached) " >&6 -else - if $as_echo 'TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 -$as_echo "$am_cv_make_support_nested_variables" >&6; } -if test $am_cv_make_support_nested_variables = yes; then - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AM_BACKSLASH='\' - -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - am__isrc=' -I$(srcdir)' - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi - - -# Define the identity of the package. - PACKAGE='tinc' - VERSION='1.0.35' - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - -# Some tools Automake needs. - -ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} - - -AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} - - -AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} - - -AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} - - -MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -mkdir_p='$(MKDIR_P)' - -# We need awk for the "check" target (and possibly the TAP driver). The -# system "awk" is bad on some platforms. -# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AMTAR='$${TAR-tar}' - - -# We'll loop over all known methods to create a tar archive until one works. -_am_tools='gnutar pax cpio none' - -am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' - - - - - - -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. - -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 - fi -fi - -ac_config_headers="$ac_config_headers config.h" - - -# Check whether --enable-silent-rules was given. -if test "${enable_silent_rules+set}" = set; then : - enableval=$enable_silent_rules; -fi - -case $enable_silent_rules in # ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=0;; -esac -am_make=${MAKE-make} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 -$as_echo_n "checking whether $am_make supports nested variables... " >&6; } -if ${am_cv_make_support_nested_variables+:} false; then : - $as_echo_n "(cached) " >&6 -else - if $as_echo 'TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 -$as_echo "$am_cv_make_support_nested_variables" >&6; } -if test $am_cv_make_support_nested_variables = yes; then - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AM_BACKSLASH='\' - - -# Enable GNU extensions. -# Define this here, not in acconfig's @TOP@ section, since definitions -# in the latter don't make it into the configure-time tests. -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 -$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } -cat > confinc.mk << 'END' -am__doit: - @echo this is the am__doit target >confinc.out -.PHONY: am__doit -END -am__include="#" -am__quote= -# BSD make does it like this. -echo '.include "confinc.mk" # ignored' > confmf.BSD -# Other make implementations (GNU, Solaris 10, AIX) do it like this. -echo 'include confinc.mk # ignored' > confmf.GNU -_am_result=no -for s in GNU BSD; do - { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 - (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - case $?:`cat confinc.out 2>/dev/null` in #( - '0:this is the am__doit target') : - case $s in #( - BSD) : - am__include='.include' am__quote='"' ;; #( - *) : - am__include='include' am__quote='' ;; -esac ;; #( - *) : - ;; -esac - if test "$am__include" != "#"; then - _am_result="yes ($s style)" - break - fi -done -rm -f confinc.* confmf.* -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 -$as_echo "${_am_result}" >&6; } - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : - enableval=$enable_dependency_tracking; -fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' -fi - if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -3062,7 +2310,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3102,7 +2350,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3155,7 +2403,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3196,7 +2444,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3254,7 +2502,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3298,7 +2546,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3744,7 +2992,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -struct stat; +#include +#include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3829,193 +3078,6 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 -$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } -if ${am_cv_prog_cc_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 - ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 -$as_echo "$am_cv_prog_cc_c_o" >&6; } -if test "$am_cv_prog_cc_c_o" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -depcc="$CC" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CC_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi - - ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -4171,7 +3233,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -4237,7 +3299,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4444,8 +3506,8 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# define __EXTENSIONS__ 1 - $ac_includes_default +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -4476,6 +3538,732 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } +am__api_version='1.11' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken +alias in your environment" "$LINENO" 5 + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error $? "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if ${ac_cv_path_mkdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE=tinc + VERSION=1.1pre2 + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CC_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + + +ac_config_headers="$ac_config_headers config.h" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 +$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } + # Check whether --enable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then : + enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 +$as_echo "$USE_MAINTAINER_MODE" >&6; } + if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + + MAINT=$MAINTAINER_MODE_TRUE + + + +# Enable GNU extensions. +# Define this here, not in acconfig's @TOP@ section, since definitions +# in the latter don't make it into the configure-time tests. + $as_echo "#define __USE_BSD 1" >>confdefs.h @@ -4626,7 +4414,7 @@ main () return 0; } _ACEOF -for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 +for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -xc99=all -qlanglvl=extc99 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : @@ -4795,7 +4583,108 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi @@ -4873,66 +4762,66 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac case $host_os in *linux*) - linux=true $as_echo "#define HAVE_LINUX 1" >>confdefs.h + rm -f src/device.c; ln -sf linux/device.c src/device.c ;; *freebsd*) - bsd=true $as_echo "#define HAVE_FREEBSD 1" >>confdefs.h + rm -f src/device.c; ln -sf bsd/device.c src/device.c ;; *darwin*) - bsd=true $as_echo "#define HAVE_DARWIN 1" >>confdefs.h + rm -f src/device.c; ln -sf bsd/device.c src/device.c ;; *solaris*) - solaris=true $as_echo "#define HAVE_SOLARIS 1" >>confdefs.h + rm -f src/device.c; ln -sf solaris/device.c src/device.c ;; *openbsd*) - bsd=true $as_echo "#define HAVE_OPENBSD 1" >>confdefs.h + rm -f src/device.c; ln -sf bsd/device.c src/device.c ;; *netbsd*) - bsd=true $as_echo "#define HAVE_NETBSD 1" >>confdefs.h + rm -f src/device.c; ln -sf bsd/device.c src/device.c ;; *dragonfly*) - bsd=true $as_echo "#define HAVE_DRAGONFLY 1" >>confdefs.h + rm -f src/device.c; ln -sf bsd/device.c src/device.c ;; *bsd*) - bsd=true { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"Unknown BSD variant" >&5 $as_echo "$as_me: WARNING: \"Unknown BSD variant" >&2;} $as_echo "#define HAVE_BSD 1" >>confdefs.h + rm -f src/device.c; ln -sf bsd/device.c src/device.c ;; *cygwin*) - cygwin=true $as_echo "#define HAVE_CYGWIN 1" >>confdefs.h + rm -f src/device.c; ln -sf cygwin/device.c src/device.c ;; *mingw*) - mingw=true $as_echo "#define HAVE_MINGW 1" >>confdefs.h + rm -f src/device.c; cp -f src/mingw/device.c src/device.c LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32" ;; *) @@ -4940,70 +4829,13 @@ $as_echo "#define HAVE_MINGW 1" >>confdefs.h ;; esac -# Check whether --enable-uml was given. -if test "${enable_uml+set}" = set; then : - enableval=$enable_uml; if test "x$enable_uml" = "xyes"; then : - -$as_echo "#define ENABLE_UML 1" >>confdefs.h - - uml=true - -else - uml=false -fi - -else - uml=false - -fi - - -# Check whether --enable-vde was given. -if test "${enable_vde+set}" = set; then : - enableval=$enable_vde; if test "x$enable_vde" = "xyes"; then : - for ac_header in libvdeplug_dyn.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "libvdeplug_dyn.h" "ac_cv_header_libvdeplug_dyn_h" "$ac_includes_default" -if test "x$ac_cv_header_libvdeplug_dyn_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBVDEPLUG_DYN_H 1 -_ACEOF - -else - as_fn_error $? "VDE plug header files not found." "$LINENO" 5; break -fi - -done - - -$as_echo "#define ENABLE_VDE 1" >>confdefs.h - - vde=true - -else - vde=false -fi - -else - vde=false - -fi - - # Check whether --enable-tunemu was given. if test "${enable_tunemu+set}" = set; then : - enableval=$enable_tunemu; if test "x$enable_tunemu" = "xyes"; then : - + enableval=$enable_tunemu; $as_echo "#define ENABLE_TUNEMU 1" >>confdefs.h - tunemu=true + tunemu=true -else - tunemu=false -fi - -else - tunemu=false fi @@ -5011,93 +4843,13 @@ fi # Check whether --with-windows2000 was given. if test "${with_windows2000+set}" = set; then : - withval=$with_windows2000; if test "x$with_windows2000" = "xyes"; then : - + withval=$with_windows2000; $as_echo "#define WITH_WINDOWS2000 1" >>confdefs.h -fi - fi - -# Check whether --with-systemd was given. -if test "${with_systemd+set}" = set; then : - withval=$with_systemd; systemd=true; systemd_path="$with_systemd" -else - systemd=false - -fi - - -if test "x$with_systemd" = "xyes"; then : - systemd_path="\${libdir}/systemd/system" -else - if test "x$with_systemd" = "xno"; then : - systemd=false -fi -fi - -systemd_path=$systemd_path - - - if test "$linux" = true; then - LINUX_TRUE= - LINUX_FALSE='#' -else - LINUX_TRUE='#' - LINUX_FALSE= -fi - - if test "$bsd" = true; then - BSD_TRUE= - BSD_FALSE='#' -else - BSD_TRUE='#' - BSD_FALSE= -fi - - if test "$solaris" = true; then - SOLARIS_TRUE= - SOLARIS_FALSE='#' -else - SOLARIS_TRUE='#' - SOLARIS_FALSE= -fi - - if test "$mingw" = true; then - MINGW_TRUE= - MINGW_FALSE='#' -else - MINGW_TRUE='#' - MINGW_FALSE= -fi - - if test "$cygwin" = true; then - CYGWIN_TRUE= - CYGWIN_FALSE='#' -else - CYGWIN_TRUE='#' - CYGWIN_FALSE= -fi - - if test "$uml" = true; then - UML_TRUE= - UML_FALSE='#' -else - UML_TRUE='#' - UML_FALSE= -fi - - if test "$vde" = true; then - VDE_TRUE= - VDE_FALSE='#' -else - VDE_TRUE='#' - VDE_FALSE= -fi - if test "$tunemu" = true; then TUNEMU_TRUE= TUNEMU_FALSE='#' @@ -5106,14 +4858,6 @@ else TUNEMU_FALSE= fi - if test "$systemd" = true; then - WITH_SYSTEMD_TRUE= - WITH_SYSTEMD_FALSE='#' -else - WITH_SYSTEMD_TRUE='#' - WITH_SYSTEMD_FALSE= -fi - cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -5209,23 +4953,17 @@ if test -d /sw/lib ; then fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for maximum warnings" >&5 -$as_echo_n "checking CFLAGS for maximum warnings... " >&6; } -if ${ac_cv_cflags_warn_all+:} false; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else - ac_cv_cflags_warn_all="no, unknown" -ac_save_CFLAGS="$CFLAGS" -for ac_arg in "-warn all % -warn all" "-pedantic % -Wall" "-xstrconst % -v" "-std1 % -verbose -w0 -warnprotos" "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" "-ansi -ansiE % -fullwarn" "+ESlit % +w1" "-Xc % -pvctl,fullmsg" "-h conform % -h msglevel 2" # -do CFLAGS="$ac_save_CFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include +#include +#include +#include int main () @@ -5236,390 +4974,98 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_cflags_warn_all=`echo $ac_arg | sed -e 's,.*% *,,'` ; break + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -CFLAGS="$ac_save_CFLAGS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags_warn_all" >&5 -$as_echo "$ac_cv_cflags_warn_all" >&6; } - - -case ".$ac_cv_cflags_warn_all" in - .ok|.ok,*) ;; - .|.no|.no,*) ;; - *) if ${CFLAGS+:} false; then : - case " $CFLAGS " in - *" $ac_cv_cflags_warn_all "*) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$ac_cv_cflags_warn_all"; } >&5 - (: CFLAGS already contains $ac_cv_cflags_warn_all) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - ;; - *) - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$ac_cv_cflags_warn_all\""; } >&5 - (: CFLAGS="$CFLAGS $ac_cv_cflags_warn_all") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - CFLAGS="$CFLAGS $ac_cv_cflags_warn_all" - ;; - esac -else - CFLAGS="$ac_cv_cflags_warn_all" -fi - ;; -esac - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -# Check whether --enable-hardening was given. -if test "${enable_hardening+set}" = set; then : - enableval=$enable_hardening; -fi - -if test "x$enable_hardening" != "xno"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -DFORTIFY_SOURCE=2" >&5 -$as_echo_n "checking whether C compiler accepts -DFORTIFY_SOURCE=2... " >&6; } -if ${ax_cv_check_cflags___DFORTIFY_SOURCE_2+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS -DFORTIFY_SOURCE=2" +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include -int -main () -{ - - ; - return 0; -} _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ax_cv_check_cflags___DFORTIFY_SOURCE_2=yes +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + else - ax_cv_check_cflags___DFORTIFY_SOURCE_2=no + ac_cv_header_stdc=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags +rm -f conftest* + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___DFORTIFY_SOURCE_2" >&5 -$as_echo "$ax_cv_check_cflags___DFORTIFY_SOURCE_2" >&6; } -if test x"$ax_cv_check_cflags___DFORTIFY_SOURCE_2" = xyes; then : - CPPFLAGS="$CPPFLAGS -DFORTIFY_SOURCE=2" + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : : -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fwrapv" >&5 -$as_echo_n "checking whether C compiler accepts -fwrapv... " >&6; } -if ${ax_cv_check_cflags___fwrapv+:} false; then : - $as_echo_n "(cached) " >&6 else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS -fwrapv" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { - - ; + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ax_cv_check_cflags___fwrapv=yes +if ac_fn_c_try_run "$LINENO"; then : + else - ax_cv_check_cflags___fwrapv=no + ac_cv_header_stdc=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fwrapv" >&5 -$as_echo "$ax_cv_check_cflags___fwrapv" >&6; } -if test x"$ax_cv_check_cflags___fwrapv" = xyes; then : - CPPFLAGS="$CPPFLAGS -fwrapv" -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fno-strict-overflow" >&5 -$as_echo_n "checking whether C compiler accepts -fno-strict-overflow... " >&6; } -if ${ax_cv_check_cflags___fno_strict_overflow+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS -fno-strict-overflow" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ax_cv_check_cflags___fno_strict_overflow=yes -else - ax_cv_check_cflags___fno_strict_overflow=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fno_strict_overflow" >&5 -$as_echo "$ax_cv_check_cflags___fno_strict_overflow" >&6; } -if test x"$ax_cv_check_cflags___fno_strict_overflow" = xyes; then : - CPPFLAGS="$CPPFLAGS -fno-strict-overflow" -else - : +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi - - case $host_os in - *mingw*) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,--dynamicbase" >&5 -$as_echo_n "checking whether the linker accepts -Wl,--dynamicbase... " >&6; } -if ${ax_cv_check_ldflags___Wl___dynamicbase+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS -Wl,--dynamicbase" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ax_cv_check_ldflags___Wl___dynamicbase=yes -else - ax_cv_check_ldflags___Wl___dynamicbase=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl___dynamicbase" >&5 -$as_echo "$ax_cv_check_ldflags___Wl___dynamicbase" >&6; } -if test x"$ax_cv_check_ldflags___Wl___dynamicbase" = xyes; then : - LDFLAGS="$LDFLAGS -Wl,--dynamicbase" -else - : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,--nxcompat" >&5 -$as_echo_n "checking whether the linker accepts -Wl,--nxcompat... " >&6; } -if ${ax_cv_check_ldflags___Wl___nxcompat+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS -Wl,--nxcompat" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ax_cv_check_ldflags___Wl___nxcompat=yes -else - ax_cv_check_ldflags___Wl___nxcompat=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl___nxcompat" >&5 -$as_echo "$ax_cv_check_ldflags___Wl___nxcompat" >&6; } -if test x"$ax_cv_check_ldflags___Wl___nxcompat" = xyes; then : - LDFLAGS="$LDFLAGS -Wl,--nxcompat" -else - : -fi - - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fPIE" >&5 -$as_echo_n "checking whether C compiler accepts -fPIE... " >&6; } -if ${ax_cv_check_cflags___fPIE+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS -fPIE" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ax_cv_check_cflags___fPIE=yes -else - ax_cv_check_cflags___fPIE=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fPIE" >&5 -$as_echo "$ax_cv_check_cflags___fPIE" >&6; } -if test x"$ax_cv_check_cflags___fPIE" = xyes; then : - CPPFLAGS="$CPPFLAGS -fPIE" -else - : -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -pie" >&5 -$as_echo_n "checking whether the linker accepts -pie... " >&6; } -if ${ax_cv_check_ldflags___pie+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS -pie" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ax_cv_check_ldflags___pie=yes -else - ax_cv_check_ldflags___pie=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___pie" >&5 -$as_echo "$ax_cv_check_ldflags___pie" >&6; } -if test x"$ax_cv_check_ldflags___pie" = xyes; then : - LDFLAGS="$LDFLAGS -pie" -else - : -fi - - ;; - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,-z,relro" >&5 -$as_echo_n "checking whether the linker accepts -Wl,-z,relro... " >&6; } -if ${ax_cv_check_ldflags___Wl__z_relro+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS -Wl,-z,relro" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ax_cv_check_ldflags___Wl__z_relro=yes -else - ax_cv_check_ldflags___Wl__z_relro=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl__z_relro" >&5 -$as_echo "$ax_cv_check_ldflags___Wl__z_relro" >&6; } -if test x"$ax_cv_check_ldflags___Wl__z_relro" = xyes; then : - LDFLAGS="$LDFLAGS -Wl,-z,relro" -else - : -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,-z,now" >&5 -$as_echo_n "checking whether the linker accepts -Wl,-z,now... " >&6; } -if ${ax_cv_check_ldflags___Wl__z_now+:} false; then : - $as_echo_n "(cached) " >&6 -else - - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS -Wl,-z,now" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ax_cv_check_ldflags___Wl__z_now=yes -else - ax_cv_check_ldflags___Wl__z_now=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$ax_check_save_flags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl__z_now" >&5 -$as_echo "$ax_cv_check_ldflags___Wl__z_now" >&6; } -if test x"$ax_cv_check_ldflags___Wl__z_now" = xyes; then : - LDFLAGS="$LDFLAGS -Wl,-z,now" -else - : -fi - - - -fi; - - - -for ac_header in syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/wait.h netdb.h arpa/inet.h arpa/nameser.h dirent.h getopt.h +for ac_header in stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -5632,10 +5078,10 @@ fi done -for ac_header in net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/if_utun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h netpacket/packet.h +for ac_header in net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h time.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include \"have.h\" " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : @@ -5647,10 +5093,10 @@ fi done -for ac_header in netinet/if_ether.h netinet/ip.h netinet/ip6.h resolv.h +for ac_header in netinet/if_ether.h netinet/ip.h netinet/ip6.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include \"have.h\" " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : @@ -5665,7 +5111,7 @@ done for ac_header in netinet/tcp.h netinet/ip_icmp.h netinet/icmp6.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include \"have.h\" " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : @@ -5678,6 +5124,120 @@ fi done +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 +$as_echo_n "checking for an ANSI C-conforming const... " >&6; } +if ${ac_cv_c_const+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_const=yes +else + ac_cv_c_const=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 +$as_echo "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +$as_echo "#define const /**/" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5 +$as_echo_n "checking for working volatile... " >&6; } +if ${ac_cv_c_volatile+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + +volatile int x; +int * volatile y = (int *) 0; +return !x && !y; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_volatile=yes +else + ac_cv_c_volatile=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5 +$as_echo "$ac_cv_c_volatile" >&6; } +if test $ac_cv_c_volatile = no; then + +$as_echo "#define volatile /**/" >>confdefs.h + +fi + ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = xyes; then : @@ -5687,6 +5247,87 @@ cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF +fi + +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 +$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } +if ${ac_cv_header_time+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_time=yes +else + ac_cv_header_time=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 +$as_echo "$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 +$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } +if ${ac_cv_struct_tm+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +struct tm tm; + int *p = &tm.tm_sec; + return !p; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_struct_tm=time.h +else + ac_cv_struct_tm=sys/time.h +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 +$as_echo "$ac_cv_struct_tm" >&6; } +if test $ac_cv_struct_tm = sys/time.h; then + +$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h + fi @@ -5701,8 +5342,8 @@ else CFLAGS="$CFLAGS -Wall -Werror" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -void *test(void) __attribute__ ((__malloc__)); - void *test(void) { return (void *)0; } +void test(void) __attribute__ ((__malloc__)); + void test(void) { return; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5725,7 +5366,7 @@ $as_echo "#define __malloc__ /**/" >>confdefs.h fi -ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include \"have.h\" " if test "x$ac_cv_type_socklen_t" = xyes; then : @@ -5736,7 +5377,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct ether_header" "ac_cv_type_struct_ether_header" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct ether_header" "ac_cv_type_struct_ether_header" "#include \"have.h\" " if test "x$ac_cv_type_struct_ether_header" = xyes; then : @@ -5747,7 +5388,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct arphdr" "ac_cv_type_struct_arphdr" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct arphdr" "ac_cv_type_struct_arphdr" "#include \"have.h\" " if test "x$ac_cv_type_struct_arphdr" = xyes; then : @@ -5758,7 +5399,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct ether_arp" "ac_cv_type_struct_ether_arp" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct ether_arp" "ac_cv_type_struct_ether_arp" "#include \"have.h\" " if test "x$ac_cv_type_struct_ether_arp" = xyes; then : @@ -5769,7 +5410,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct in_addr" "ac_cv_type_struct_in_addr" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct in_addr" "ac_cv_type_struct_in_addr" "#include \"have.h\" " if test "x$ac_cv_type_struct_in_addr" = xyes; then : @@ -5780,7 +5421,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct addrinfo" "ac_cv_type_struct_addrinfo" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct addrinfo" "ac_cv_type_struct_addrinfo" "#include \"have.h\" " if test "x$ac_cv_type_struct_addrinfo" = xyes; then : @@ -5791,7 +5432,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct ip" "ac_cv_type_struct_ip" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct ip" "ac_cv_type_struct_ip" "#include \"have.h\" " if test "x$ac_cv_type_struct_ip" = xyes; then : @@ -5802,7 +5443,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct icmp" "ac_cv_type_struct_icmp" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct icmp" "ac_cv_type_struct_icmp" "#include \"have.h\" " if test "x$ac_cv_type_struct_icmp" = xyes; then : @@ -5813,7 +5454,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct in6_addr" "ac_cv_type_struct_in6_addr" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct in6_addr" "ac_cv_type_struct_in6_addr" "#include \"have.h\" " if test "x$ac_cv_type_struct_in6_addr" = xyes; then : @@ -5824,7 +5465,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct sockaddr_in6" "ac_cv_type_struct_sockaddr_in6" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct sockaddr_in6" "ac_cv_type_struct_sockaddr_in6" "#include \"have.h\" " if test "x$ac_cv_type_struct_sockaddr_in6" = xyes; then : @@ -5835,7 +5476,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct ip6_hdr" "ac_cv_type_struct_ip6_hdr" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct ip6_hdr" "ac_cv_type_struct_ip6_hdr" "#include \"have.h\" " if test "x$ac_cv_type_struct_ip6_hdr" = xyes; then : @@ -5846,7 +5487,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct icmp6_hdr" "ac_cv_type_struct_icmp6_hdr" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct icmp6_hdr" "ac_cv_type_struct_icmp6_hdr" "#include \"have.h\" " if test "x$ac_cv_type_struct_icmp6_hdr" = xyes; then : @@ -5857,7 +5498,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct nd_neighbor_solicit" "ac_cv_type_struct_nd_neighbor_solicit" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct nd_neighbor_solicit" "ac_cv_type_struct_nd_neighbor_solicit" "#include \"have.h\" " if test "x$ac_cv_type_struct_nd_neighbor_solicit" = xyes; then : @@ -5868,7 +5509,7 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "struct nd_opt_hdr" "ac_cv_type_struct_nd_opt_hdr" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_type "$LINENO" "struct nd_opt_hdr" "ac_cv_type_struct_nd_opt_hdr" "#include \"have.h\" " if test "x$ac_cv_type_struct_nd_opt_hdr" = xyes; then : @@ -5914,7 +5555,7 @@ cat >>confdefs.h <<_ACEOF _ACEOF -for ac_func in asprintf daemon fchmod flock fork gettimeofday mlockall pselect putenv strsignal system unsetenv usleep vsyslog devname fdevname +for ac_func in asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol system time usleep unsetenv vsyslog writev do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -5927,24 +5568,6 @@ fi done -ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long" -if test "x$ac_cv_func_getopt_long" = xyes; then : - getopt=true; -$as_echo "#define HAVE_GETOPT_LONG 1" >>confdefs.h - -else - getopt=false -fi - - if test "$getopt" = true; then - GETOPT_TRUE= - GETOPT_FALSE='#' -else - GETOPT_TRUE='#' - GETOPT_FALSE= -fi - - ac_fn_c_check_func "$LINENO" "socket" "ac_cv_func_socket" if test "x$ac_cv_func_socket" = xyes; then : @@ -6053,7 +5676,7 @@ fi fi -ac_fn_c_check_decl "$LINENO" "freeaddrinfo" "ac_cv_have_decl_freeaddrinfo" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_decl "$LINENO" "freeaddrinfo" "ac_cv_have_decl_freeaddrinfo" "#include \"have.h\" " if test "x$ac_cv_have_decl_freeaddrinfo" = xyes; then : @@ -6065,7 +5688,7 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_FREEADDRINFO $ac_have_decl _ACEOF -ac_fn_c_check_decl "$LINENO" "gai_strerror" "ac_cv_have_decl_gai_strerror" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_decl "$LINENO" "gai_strerror" "ac_cv_have_decl_gai_strerror" "#include \"have.h\" " if test "x$ac_cv_have_decl_gai_strerror" = xyes; then : @@ -6077,7 +5700,7 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_GAI_STRERROR $ac_have_decl _ACEOF -ac_fn_c_check_decl "$LINENO" "getaddrinfo" "ac_cv_have_decl_getaddrinfo" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_decl "$LINENO" "getaddrinfo" "ac_cv_have_decl_getaddrinfo" "#include \"have.h\" " if test "x$ac_cv_have_decl_getaddrinfo" = xyes; then : @@ -6089,7 +5712,7 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_GETADDRINFO $ac_have_decl _ACEOF -ac_fn_c_check_decl "$LINENO" "getnameinfo" "ac_cv_have_decl_getnameinfo" "#include \"$srcdir/src/have.h\" +ac_fn_c_check_decl "$LINENO" "getnameinfo" "ac_cv_have_decl_getnameinfo" "#include \"have.h\" " if test "x$ac_cv_have_decl_getnameinfo" = xyes; then : @@ -6103,69 +5726,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF -ac_fn_c_check_decl "$LINENO" "res_init" "ac_cv_have_decl_res_init" " - #include - #include - -" -if test "x$ac_cv_have_decl_res_init" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_RES_INIT $ac_have_decl -_ACEOF -if test $ac_have_decl = 1; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for res_init in -lresolv" >&5 -$as_echo_n "checking for res_init in -lresolv... " >&6; } -if ${ac_cv_lib_resolv_res_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lresolv $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char res_init (); -int -main () -{ -return res_init (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_resolv_res_init=yes -else - ac_cv_lib_resolv_res_init=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_res_init" >&5 -$as_echo "$ac_cv_lib_resolv_res_init" >&6; } -if test "x$ac_cv_lib_resolv_res_init" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBRESOLV 1 -_ACEOF - - LIBS="-lresolv $LIBS" - -fi - -fi - - cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -6254,6 +5814,206 @@ rm -f confcache +# Check whether --with-libgcrypt was given. +if test "${with_libgcrypt+set}" = set; then : + withval=$with_libgcrypt; +fi + + + + # Check whether --enable-curses was given. +if test "${enable_curses+set}" = set; then : + enableval=$enable_curses; +fi + + if test "x$enable_curses" != "xno"; then : + + +$as_echo "#define HAVE_CURSES 1" >>confdefs.h + + curses=true + +# Check whether --with-curses was given. +if test "${with_curses+set}" = set; then : + withval=$with_curses; curses="$withval" + CPPFLAGS="$CPPFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib" + +fi + + + +# Check whether --with-curses-include was given. +if test "${with_curses_include+set}" = set; then : + withval=$with_curses_include; curses_include="$withval" + CPPFLAGS="$CPPFLAGS -I$withval" + +fi + + + +# Check whether --with-curses-lib was given. +if test "${with_curses_lib+set}" = set; then : + withval=$with_curses_lib; curses_lib="$withval" + LDFLAGS="$LDFLAGS -L$withval" + +fi + + + for ac_header in curses.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_curses_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_CURSES_H 1 +_ACEOF + +else + as_fn_error $? "\"curses header files not found.\"" "$LINENO" 5; break + +fi + +done + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lcurses" >&5 +$as_echo_n "checking for initscr in -lcurses... " >&6; } +if ${ac_cv_lib_curses_initscr+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcurses $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char initscr (); +int +main () +{ +return initscr (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_curses_initscr=yes +else + ac_cv_lib_curses_initscr=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_initscr" >&5 +$as_echo "$ac_cv_lib_curses_initscr" >&6; } +if test "x$ac_cv_lib_curses_initscr" = xyes; then : + CURSES_LIBS="-lcurses" +else + as_fn_error $? "\"curses libraries not found.\"" "$LINENO" 5 + +fi + + +fi + + + + + +# Check whether --with-libevent was given. +if test "${with_libevent+set}" = set; then : + withval=$with_libevent; libevent="$withval" + CPPFLAGS="$CPPFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib" + +fi + + + +# Check whether --with-libevent-include was given. +if test "${with_libevent_include+set}" = set; then : + withval=$with_libevent_include; libevent_include="$withval" + CPPFLAGS="$CPPFLAGS -I$withval" + +fi + + + +# Check whether --with-libevent-lib was given. +if test "${with_libevent_lib+set}" = set; then : + withval=$with_libevent_lib; libevent_lib="$withval" + LDFLAGS="$LDFLAGS -L$withval" + +fi + + + for ac_header in event.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "event.h" "ac_cv_header_event_h" "$ac_includes_default" +if test "x$ac_cv_header_event_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_EVENT_H 1 +_ACEOF + +else + as_fn_error $? "\"libevent header files not found.\"" "$LINENO" 5; break + +fi + +done + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for event_init in -levent" >&5 +$as_echo_n "checking for event_init in -levent... " >&6; } +if ${ac_cv_lib_event_event_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-levent $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char event_init (); +int +main () +{ +return event_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_event_event_init=yes +else + ac_cv_lib_event_event_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_event_event_init" >&5 +$as_echo "$ac_cv_lib_event_event_init" >&6; } +if test "x$ac_cv_lib_event_event_init" = xyes; then : + LIBS="-levent $LIBS" +else + as_fn_error $? "\"libevent libraries not found.\"" "$LINENO" 5 + +fi + + + # Check whether --enable-zlib was given. if test "${enable_zlib+set}" = set; then : enableval=$enable_zlib; @@ -6532,6 +6292,225 @@ done fi +if test "$with_libgcrypt" = yes; then + +# Check whether --with-libgcrypt-prefix was given. +if test "${with_libgcrypt_prefix+set}" = set; then : + withval=$with_libgcrypt_prefix; libgcrypt_config_prefix="$withval" +else + libgcrypt_config_prefix="" +fi + + if test x$libgcrypt_config_prefix != x ; then + if test x${LIBGCRYPT_CONFIG+set} != xset ; then + LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config + fi + fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}libgcrypt-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}libgcrypt-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_LIBGCRYPT_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $LIBGCRYPT_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_LIBGCRYPT_CONFIG="$LIBGCRYPT_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_LIBGCRYPT_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +LIBGCRYPT_CONFIG=$ac_cv_path_LIBGCRYPT_CONFIG +if test -n "$LIBGCRYPT_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBGCRYPT_CONFIG" >&5 +$as_echo "$LIBGCRYPT_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_LIBGCRYPT_CONFIG"; then + ac_pt_LIBGCRYPT_CONFIG=$LIBGCRYPT_CONFIG + # Extract the first word of "libgcrypt-config", so it can be a program name with args. +set dummy libgcrypt-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_LIBGCRYPT_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_LIBGCRYPT_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_LIBGCRYPT_CONFIG="$ac_pt_LIBGCRYPT_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_ac_pt_LIBGCRYPT_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_LIBGCRYPT_CONFIG=$ac_cv_path_ac_pt_LIBGCRYPT_CONFIG +if test -n "$ac_pt_LIBGCRYPT_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_LIBGCRYPT_CONFIG" >&5 +$as_echo "$ac_pt_LIBGCRYPT_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_LIBGCRYPT_CONFIG" = x; then + LIBGCRYPT_CONFIG="no" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + LIBGCRYPT_CONFIG=$ac_pt_LIBGCRYPT_CONFIG + fi +else + LIBGCRYPT_CONFIG="$ac_cv_path_LIBGCRYPT_CONFIG" +fi + + tmp=1.4.0 + if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then + req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` + min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` + else + req_libgcrypt_api=0 + min_libgcrypt_version="$tmp" + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBGCRYPT - version >= $min_libgcrypt_version" >&5 +$as_echo_n "checking for LIBGCRYPT - version >= $min_libgcrypt_version... " >&6; } + ok=no + if test "$LIBGCRYPT_CONFIG" != "no" ; then + req_major=`echo $min_libgcrypt_version | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'` + req_minor=`echo $min_libgcrypt_version | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'` + req_micro=`echo $min_libgcrypt_version | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'` + libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` + major=`echo $libgcrypt_config_version | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'` + minor=`echo $libgcrypt_config_version | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'` + micro=`echo $libgcrypt_config_version | \ + sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'` + if test "$major" -gt "$req_major"; then + ok=yes + else + if test "$major" -eq "$req_major"; then + if test "$minor" -gt "$req_minor"; then + ok=yes + else + if test "$minor" -eq "$req_minor"; then + if test "$micro" -ge "$req_micro"; then + ok=yes + fi + fi + fi + fi + fi + fi + if test $ok = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($libgcrypt_config_version)" >&5 +$as_echo "yes ($libgcrypt_config_version)" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + if test $ok = yes; then + # If we have a recent libgcrypt, we should also check that the + # API is compatible + if test "$req_libgcrypt_api" -gt 0 ; then + tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` + if test "$tmp" -gt 0 ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking LIBGCRYPT API version" >&5 +$as_echo_n "checking LIBGCRYPT API version... " >&6; } + if test "$req_libgcrypt_api" -eq "$tmp" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: okay" >&5 +$as_echo "okay" >&6; } + else + ok=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: does not match. want=$req_libgcrypt_api got=$tmp" >&5 +$as_echo "does not match. want=$req_libgcrypt_api got=$tmp" >&6; } + fi + fi + fi + fi + if test $ok = yes; then + LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` + LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` + : + if test x"$host" != x ; then + libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none` + if test x"$libgcrypt_config_host" != xnone ; then + if test x"$libgcrypt_config_host" != x"$host" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: +*** +*** The config script $LIBGCRYPT_CONFIG was +*** built for $libgcrypt_config_host and thus may not match the +*** used host $host. +*** You may want to use the configure option --with-libgcrypt-prefix +*** to specify a matching config script. +***" >&5 +$as_echo "$as_me: WARNING: +*** +*** The config script $LIBGCRYPT_CONFIG was +*** built for $libgcrypt_config_host and thus may not match the +*** used host $host. +*** You may want to use the configure option --with-libgcrypt-prefix +*** to specify a matching config script. +***" >&2;} + fi + fi + fi + else + LIBGCRYPT_CFLAGS="" + LIBGCRYPT_LIBS="" + : + fi + + + + ln -sf gcrypt/cipher.c gcrypt/cipher.h gcrypt/crypto.c gcrypt/crypto.h gcrypt/digest.c gcrypt/digest.h gcrypt/ecdh.c gcrypt/ecdh.h gcrypt/ecdsa.c gcrypt/ecdsa.h gcrypt/ecdsagen.c gcrypt/ecdsagen.h gcrypt/prf.c gcrypt/prf.h gcrypt/rsa.c gcrypt/rsa.h gcrypt/rsagen.c gcrypt/rsagen.h src/ +else + case $host_os in *mingw*) ;; @@ -6579,7 +6558,7 @@ $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : LIBS="$LIBS -ldl" else - as_fn_error $? "LibreSSL/OpenSSL depends on libdl." "$LINENO" 5; break + as_fn_error $? "OpenSSL depends on libdl." "$LINENO" 5; break fi @@ -6627,7 +6606,7 @@ if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : _ACEOF else - as_fn_error $? "LibreSSL/OpenSSL header files not found." "$LINENO" 5; break + as_fn_error $? "OpenSSL header files not found." "$LINENO" 5; break fi @@ -6673,12 +6652,12 @@ $as_echo "$ac_cv_lib_crypto_EVP_EncryptInit_ex" >&6; } if test "x$ac_cv_lib_crypto_EVP_EncryptInit_ex" = xyes; then : LIBS="-lcrypto $LIBS" else - as_fn_error $? "LibreSSL/OpenSSL libraries not found." "$LINENO" 5 + as_fn_error $? "OpenSSL libraries not found." "$LINENO" 5 fi - for ac_func in RAND_bytes EVP_EncryptInit_ex EVP_CIPHER_CTX_new + for ac_func in RAND_pseudo_bytes EVP_EncryptInit_ex do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -6688,7 +6667,7 @@ if eval test \"x\$"$as_ac_var"\" = x"yes"; then : _ACEOF else - as_fn_error $? "Missing LibreSSL/OpenSSL functionality, make sure you have installed the latest version." "$LINENO" 5; break + as_fn_error $? "Missing OpenSSL functionality, make sure you have installed the latest version." "$LINENO" 5; break fi done @@ -6697,70 +6676,28 @@ done " if test "x$ac_cv_have_decl_OpenSSL_add_all_algorithms" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_OPENSSL_ADD_ALL_ALGORITHMS $ac_have_decl -_ACEOF -if test $ac_have_decl = 1; then : else - as_fn_error $? "Missing LibreSSL/OpenSSL functionality, make sure you have installed the latest version." "$LINENO" 5; break -fi -ac_fn_c_check_decl "$LINENO" "EVP_aes_256_cfb" "ac_cv_have_decl_EVP_aes_256_cfb" "#include - -" -if test "x$ac_cv_have_decl_EVP_aes_256_cfb" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_EVP_AES_256_CFB $ac_have_decl -_ACEOF -if test $ac_have_decl = 1; then : - -else - as_fn_error $? "Missing LibreSSL/OpenSSL functionality, make sure you have installed the latest version." "$LINENO" 5; break + as_fn_error $? "Missing OpenSSL functionality, make sure you have installed the latest version." "$LINENO" 5; break fi - for ac_func in BN_GENCB_new RSA_set0_key -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - + ln -sf openssl/cipher.c openssl/cipher.h openssl/crypto.c openssl/crypto.h openssl/digest.c openssl/digest.h openssl/ecdh.c openssl/ecdh.h openssl/ecdsa.c openssl/ecdsa.h openssl/ecdsagen.c openssl/ecdsagen.h openssl/prf.c openssl/prf.h openssl/rsa.c openssl/rsa.h openssl/rsagen.c openssl/rsagen.h src/ fi -done - # Check whether --enable-jumbograms was given. if test "${enable_jumbograms+set}" = set; then : - enableval=$enable_jumbograms; if test "x$enable_jumbograms" = "xyes"; then : - + enableval=$enable_jumbograms; $as_echo "#define ENABLE_JUMBOGRAMS 1" >>confdefs.h -fi - fi -if test "x$runstatedir" = "x"; then - runstatedir='${localstatedir}/run' -fi -ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile systemd/Makefile" +ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile m4/Makefile gui/Makefile" cat >confcache <<\_ACEOF @@ -6872,22 +6809,6 @@ LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 -$as_echo_n "checking that generated files are newer than configure... " >&6; } - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 -$as_echo "done" >&6; } - if test -n "$EXEEXT"; then - am__EXEEXT_TRUE= - am__EXEEXT_FALSE='#' -else - am__EXEEXT_TRUE='#' - am__EXEEXT_FALSE= -fi - if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -6896,46 +6817,22 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${LINUX_TRUE}" && test -z "${LINUX_FALSE}"; then - as_fn_error $? "conditional \"LINUX\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= fi -if test -z "${BSD_TRUE}" && test -z "${BSD_FALSE}"; then - as_fn_error $? "conditional \"BSD\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${SOLARIS_TRUE}" && test -z "${SOLARIS_FALSE}"; then - as_fn_error $? "conditional \"SOLARIS\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${MINGW_TRUE}" && test -z "${MINGW_FALSE}"; then - as_fn_error $? "conditional \"MINGW\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${CYGWIN_TRUE}" && test -z "${CYGWIN_FALSE}"; then - as_fn_error $? "conditional \"CYGWIN\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${UML_TRUE}" && test -z "${UML_FALSE}"; then - as_fn_error $? "conditional \"UML\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${VDE_TRUE}" && test -z "${VDE_FALSE}"; then - as_fn_error $? "conditional \"VDE\" was never defined. + +if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then + as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${TUNEMU_TRUE}" && test -z "${TUNEMU_FALSE}"; then as_fn_error $? "conditional \"TUNEMU\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${WITH_SYSTEMD_TRUE}" && test -z "${WITH_SYSTEMD_FALSE}"; then - as_fn_error $? "conditional \"WITH_SYSTEMD\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${GETOPT_TRUE}" && test -z "${GETOPT_FALSE}"; then - as_fn_error $? "conditional \"GETOPT\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 @@ -7234,16 +7131,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. + # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' + as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi else - as_ln_s='cp -pR' + as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -7303,16 +7200,28 @@ else as_mkdir_p=false fi - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -7333,8 +7242,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by tinc $as_me 1.0.35, which was -generated by GNU Autoconf 2.69. Invocation command line was +This file was extended by $as_me, which was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -7399,11 +7308,11 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -tinc config.status 1.0.35 -configured by $0, generated by GNU Autoconf 2.69, +config.status +configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -7494,7 +7403,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' @@ -7518,7 +7427,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # -AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF @@ -7528,12 +7437,13 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 for ac_config_target in $ac_config_targets do case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; - "systemd/Makefile") CONFIG_FILES="$CONFIG_FILES systemd/Makefile" ;; + "m4/Makefile") CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;; + "gui/Makefile") CONFIG_FILES="$CONFIG_FILES gui/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac @@ -8130,38 +8040,32 @@ $as_echo "$as_me: executing $ac_file commands" >&6;} case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { - # Older Autoconf quotes --file arguments for eval, but not when files + # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. - # TODO: see whether this extra hack can be removed once we start - # requiring Autoconf 2.70 or later. - case $CONFIG_FILES in #( - *\'*) : - eval set x "$CONFIG_FILES" ;; #( - *) : - set x $CONFIG_FILES ;; #( - *) : - ;; -esac + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac shift - # Used to flag and report bootstrapping failures. - am_rc=0 - for am_mf + for mf do # Strip MF so we end up with the name of the file. - am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile which includes - # dependency-tracking related rules and includes. - # Grep'ing the whole file directly is not great: AIX grep has a line + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. - sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ - || continue - am_dirpart=`$as_dirname -- "$am_mf" || -$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$am_mf" : 'X\(//\)[^/]' \| \ - X"$am_mf" : 'X\(//\)$' \| \ - X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$am_mf" | + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -8179,48 +8083,55 @@ $as_echo X"$am_mf" | q } s/.*/./; q'` - am_filepart=`$as_basename -- "$am_mf" || -$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ - X"$am_mf" : 'X\(//\)$' \| \ - X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$am_mf" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } - /^X\/\(\/\/\)$/{ + /^X\(\/\/\)[^/].*/{ s//\1/ q } - /^X\/\(\/\).*/{ + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` - { echo "$as_me:$LINENO: cd "$am_dirpart" \ - && sed -e '/# am--include-marker/d' "$am_filepart" \ - | $MAKE -f - am--depfiles" >&5 - (cd "$am_dirpart" \ - && sed -e '/# am--include-marker/d' "$am_filepart" \ - | $MAKE -f - am--depfiles) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } || am_rc=$? + as_dir=$dirpart/$fdir; as_fn_mkdir_p + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done done - if test $am_rc -ne 0; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "Something went wrong bootstrapping makefile fragments - for automatic dependency tracking. Try re-running configure with the - '--disable-dependency-tracking' option to at least be able to build - the package (albeit without support for automatic dependency tracking). -See \`config.log' for more details" "$LINENO" 5; } - fi - { am_dirpart=; unset am_dirpart;} - { am_filepart=; unset am_filepart;} - { am_mf=; unset am_mf;} - { am_rc=; unset am_rc;} - rm -f conftest-deps.mk } ;; diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 6de0313..0000000 --- a/configure.ac +++ /dev/null @@ -1,247 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.61) -AC_INIT([tinc], [1.0.35]) -AC_CONFIG_SRCDIR([src/tincd.c]) -AM_INIT_AUTOMAKE([1.11 check-news std-options subdir-objects nostdinc silent-rules -Wall]) -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_MACRO_DIR([m4]) -AM_SILENT_RULES([yes]) - -# Enable GNU extensions. -# Define this here, not in acconfig's @TOP@ section, since definitions -# in the latter don't make it into the configure-time tests. -AC_GNU_SOURCE -AC_DEFINE([__USE_BSD], 1, [Enable BSD extensions]) - -dnl Checks for programs. -AC_PROG_CC_C99 -AC_PROG_CPP -AC_PROG_INSTALL - -AM_PROG_CC_C_O - -dnl Check and set OS - -AC_CANONICAL_HOST - -case $host_os in - *linux*) - linux=true - AC_DEFINE(HAVE_LINUX, 1, [Linux]) - ;; - *freebsd*) - bsd=true - AC_DEFINE(HAVE_FREEBSD, 1, [FreeBSD]) - ;; - *darwin*) - bsd=true - AC_DEFINE(HAVE_DARWIN, 1, [Darwin (MacOS/X)]) - ;; - *solaris*) - solaris=true - AC_DEFINE(HAVE_SOLARIS, 1, [Solaris/SunOS]) - ;; - *openbsd*) - bsd=true - AC_DEFINE(HAVE_OPENBSD, 1, [OpenBSD]) - ;; - *netbsd*) - bsd=true - AC_DEFINE(HAVE_NETBSD, 1, [NetBSD]) - ;; - *dragonfly*) - bsd=true - AC_DEFINE(HAVE_DRAGONFLY, 1, [DragonFly]) - ;; - *bsd*) - bsd=true - AC_MSG_WARN("Unknown BSD variant, tinc might not compile or work!") - AC_DEFINE(HAVE_BSD, 1, [Unknown BSD variant]) - ;; - *cygwin*) - cygwin=true - AC_DEFINE(HAVE_CYGWIN, 1, [Cygwin]) - ;; - *mingw*) - mingw=true - AC_DEFINE(HAVE_MINGW, 1, [MinGW]) - LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32" - ;; - *) - AC_MSG_ERROR("Unknown operating system.") - ;; -esac - -AC_ARG_ENABLE(uml, - AS_HELP_STRING([--enable-uml], [enable support for User Mode Linux]), - [ AS_IF([test "x$enable_uml" = "xyes"], - [ AC_DEFINE(ENABLE_UML, 1, [Support for UML]) - uml=true - ], - [uml=false]) - ], - [uml=false] -) - -AC_ARG_ENABLE(vde, - AS_HELP_STRING([--enable-vde], [enable support for Virtual Distributed Ethernet]), - [ AS_IF([test "x$enable_vde" = "xyes"], - [ AC_CHECK_HEADERS(libvdeplug_dyn.h, [], [AC_MSG_ERROR([VDE plug header files not found.]); break]) - AC_DEFINE(ENABLE_VDE, 1, [Support for VDE]) - vde=true - ], - [vde=false]) - ], - [vde=false] -) - -AC_ARG_ENABLE(tunemu, - AS_HELP_STRING([--enable-tunemu], [enable support for the tunemu driver]), - [ AS_IF([test "x$enable_tunemu" = "xyes"], - [ AC_DEFINE(ENABLE_TUNEMU, 1, [Support for tunemu]) - tunemu=true - ], - [tunemu=false]) - ], - [tunemu=false] -) - -AC_ARG_WITH(windows2000, - AS_HELP_STRING([--with-windows2000], [compile with support for Windows 2000. This disables support for tunneling over existing IPv6 networks.]), - [ AS_IF([test "x$with_windows2000" = "xyes"], - [AC_DEFINE(WITH_WINDOWS2000, 1, [Compile with support for Windows 2000])]) - ] -) - -AC_ARG_WITH(systemd, - AS_HELP_STRING([--with-systemd@<:@=DIR@:>@], [install systemd service files @<:@to DIR if specified@:>@]), - [ systemd=true; systemd_path="$with_systemd" ], - [ systemd=false ] -) - -AS_IF([test "x$with_systemd" = "xyes"], [systemd_path="\${libdir}/systemd/system"], - [AS_IF([test "x$with_systemd" = "xno"], [systemd=false])]) - -AC_SUBST(systemd_path, $systemd_path) - -AM_CONDITIONAL(LINUX, test "$linux" = true) -AM_CONDITIONAL(BSD, test "$bsd" = true) -AM_CONDITIONAL(SOLARIS, test "$solaris" = true) -AM_CONDITIONAL(MINGW, test "$mingw" = true) -AM_CONDITIONAL(CYGWIN, test "$cygwin" = true) -AM_CONDITIONAL(UML, test "$uml" = true) -AM_CONDITIONAL(VDE, test "$vde" = true) -AM_CONDITIONAL(TUNEMU, test "$tunemu" = true) -AM_CONDITIONAL(WITH_SYSTEMD, test "$systemd" = true) - -AC_CACHE_SAVE - -if test -d /sw/include ; then - CPPFLAGS="$CPPFLAGS -I/sw/include" -fi -if test -d /sw/lib ; then - LIBS="$LIBS -L/sw/lib" -fi - -dnl Compiler hardening flags -dnl No -fstack-protector-all because it doesn't work on all platforms or architectures. - -AX_CFLAGS_WARN_ALL(CFLAGS) - -AC_ARG_ENABLE([hardening], AS_HELP_STRING([--disable-hardening], [disable compiler and linker hardening flags])) -AS_IF([test "x$enable_hardening" != "xno"], - [AX_CHECK_COMPILE_FLAG([-DFORTIFY_SOURCE=2], [CPPFLAGS="$CPPFLAGS -DFORTIFY_SOURCE=2"]) - AX_CHECK_COMPILE_FLAG([-fwrapv], [CPPFLAGS="$CPPFLAGS -fwrapv"], - AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CPPFLAGS="$CPPFLAGS -fno-strict-overflow"])) - case $host_os in - *mingw*) - AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"]) - AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"]) - ;; - *) - AX_CHECK_COMPILE_FLAG([-fPIE], [CPPFLAGS="$CPPFLAGS -fPIE"]) - AX_CHECK_LINK_FLAG([-pie], [LDFLAGS="$LDFLAGS -pie"]) - ;; - esac - AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"]) - AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"]) - ] -); - -dnl Checks for libraries. - -dnl Checks for header files. -dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies. - -AC_CHECK_HEADERS([syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/wait.h netdb.h arpa/inet.h arpa/nameser.h dirent.h getopt.h]) -AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/if_utun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h netpacket/packet.h], - [], [], [#include "$srcdir/src/have.h"] -) -AC_CHECK_HEADERS([netinet/if_ether.h netinet/ip.h netinet/ip6.h resolv.h], - [], [], [#include "$srcdir/src/have.h"] -) -AC_CHECK_HEADERS([netinet/tcp.h netinet/ip_icmp.h netinet/icmp6.h], - [], [], [#include "$srcdir/src/have.h"] -) - -dnl Checks for typedefs, structures, and compiler characteristics. -AC_TYPE_PID_T - -tinc_ATTRIBUTE(__malloc__) - -AC_CHECK_TYPES([socklen_t, struct ether_header, struct arphdr, struct ether_arp, struct in_addr, struct addrinfo, struct ip, struct icmp, struct in6_addr, struct sockaddr_in6, struct ip6_hdr, struct icmp6_hdr, struct nd_neighbor_solicit, struct nd_opt_hdr], , , - [#include "$srcdir/src/have.h"] -) - -dnl Checks for library functions. -AC_TYPE_SIGNAL -AC_CHECK_FUNCS([asprintf daemon fchmod flock fork gettimeofday mlockall pselect putenv strsignal system unsetenv usleep vsyslog devname fdevname], - [], [], [#include "$srcdir/src/have.h"] -) - -AC_CHECK_FUNC(getopt_long, [getopt=true; AC_DEFINE(HAVE_GETOPT_LONG, 1, [getopt_long()])], [getopt=false]) -AM_CONDITIONAL(GETOPT, test "$getopt" = true) - -dnl Support for SunOS - -AC_CHECK_FUNC(socket, [], [ - AC_CHECK_LIB(socket, connect) -]) -AC_CHECK_FUNC(gethostbyname, [], [ - AC_CHECK_LIB(nsl, gethostbyname) -]) - -AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo], - [], [], [#include "$srcdir/src/have.h"] -) - -AC_CHECK_DECLS([res_init], [AC_CHECK_LIB(resolv, res_init)], [], [ - #include - #include -]) - -AC_CACHE_SAVE - -dnl These are defined in files in m4/ - -tinc_ZLIB -tinc_LZO -tinc_OPENSSL - -dnl Check if support for jumbograms is requested -AC_ARG_ENABLE(jumbograms, - AS_HELP_STRING([--enable-jumbograms], [enable support for jumbograms (packets up to 9000 bytes)]), - [ AS_IF([test "x$enable_jumbograms" = "xyes"], - [ AC_DEFINE(ENABLE_JUMBOGRAMS, 1, [Support for jumbograms (packets up to 9000 bytes)]) ]) - ] -) - -dnl Ensure runstatedir is set if we are using a version of autoconf that does not suppport it -if test "x$runstatedir" = "x"; then - AC_SUBST([runstatedir], ['${localstatedir}/run']) -fi - -AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile systemd/Makefile]) - -AC_OUTPUT diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..2e519b0 --- /dev/null +++ b/configure.in @@ -0,0 +1,177 @@ +dnl Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT +AC_CONFIG_SRCDIR([src/tincd.c]) +AC_GNU_SOURCE +AM_INIT_AUTOMAKE(tinc, 1.1pre2) +AC_CONFIG_HEADERS([config.h]) +AM_MAINTAINER_MODE + +# Enable GNU extensions. +# Define this here, not in acconfig's @TOP@ section, since definitions +# in the latter don't make it into the configure-time tests. +AC_GNU_SOURCE +AC_DEFINE([__USE_BSD], 1, [Enable BSD extensions]) + +dnl Checks for programs. +AC_PROG_CC_C99 +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_RANLIB + +dnl Check and set OS + +AC_CANONICAL_HOST + +case $host_os in + *linux*) + AC_DEFINE(HAVE_LINUX, 1, [Linux]) + [ rm -f src/device.c; ln -sf linux/device.c src/device.c ] + ;; + *freebsd*) + AC_DEFINE(HAVE_FREEBSD, 1, [FreeBSD]) + [ rm -f src/device.c; ln -sf bsd/device.c src/device.c ] + ;; + *darwin*) + AC_DEFINE(HAVE_DARWIN, 1, [Darwin (MacOS/X)]) + [ rm -f src/device.c; ln -sf bsd/device.c src/device.c ] + ;; + *solaris*) + AC_DEFINE(HAVE_SOLARIS, 1, [Solaris/SunOS]) + [ rm -f src/device.c; ln -sf solaris/device.c src/device.c ] + ;; + *openbsd*) + AC_DEFINE(HAVE_OPENBSD, 1, [OpenBSD]) + [ rm -f src/device.c; ln -sf bsd/device.c src/device.c ] + ;; + *netbsd*) + AC_DEFINE(HAVE_NETBSD, 1, [NetBSD]) + [ rm -f src/device.c; ln -sf bsd/device.c src/device.c ] + ;; + *dragonfly*) + AC_DEFINE(HAVE_DRAGONFLY, 1, [DragonFly]) + [ rm -f src/device.c; ln -sf bsd/device.c src/device.c ] + ;; + *bsd*) + AC_MSG_WARN("Unknown BSD variant, tinc might not compile or work!") + AC_DEFINE(HAVE_BSD, 1, [Unknown BSD variant]) + [ rm -f src/device.c; ln -sf bsd/device.c src/device.c ] + ;; + *cygwin*) + AC_DEFINE(HAVE_CYGWIN, 1, [Cygwin]) + [ rm -f src/device.c; ln -sf cygwin/device.c src/device.c ] + ;; + *mingw*) + AC_DEFINE(HAVE_MINGW, 1, [MinGW]) + [ rm -f src/device.c; cp -f src/mingw/device.c src/device.c ] + LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32" + ;; + *) + AC_MSG_ERROR("Unknown operating system.") + ;; +esac + +AC_ARG_ENABLE(tunemu, + AS_HELP_STRING([--enable-tunemu], [enable support for the tunemu driver]), + [ AC_DEFINE(ENABLE_TUNEMU, 1, [Support for tunemu]) + tunemu=true + ] +) + +AC_ARG_WITH(windows2000, + AS_HELP_STRING([--with-windows2000], [compile with support for Windows 2000. This disables support for tunneling over existing IPv6 networks.]), + [AC_DEFINE(WITH_WINDOWS2000, 1, [Compile with support for Windows 2000])] +) + +AM_CONDITIONAL(TUNEMU, test "$tunemu" = true) + +AC_CACHE_SAVE + +if test -d /sw/include ; then + CPPFLAGS="$CPPFLAGS -I/sw/include" +fi +if test -d /sw/lib ; then + LIBS="$LIBS -L/sw/lib" +fi + +dnl Checks for header files. +dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies. + +AC_HEADER_STDC +AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h]) +AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h time.h], + [], [], [#include "have.h"] +) +AC_CHECK_HEADERS([netinet/if_ether.h netinet/ip.h netinet/ip6.h], + [], [], [#include "have.h"] +) +AC_CHECK_HEADERS([netinet/tcp.h netinet/ip_icmp.h netinet/icmp6.h], + [], [], [#include "have.h"] +) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_VOLATILE +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_HEADER_TIME +AC_STRUCT_TM + +tinc_ATTRIBUTE(__malloc__) + +AC_CHECK_TYPES([socklen_t, struct ether_header, struct arphdr, struct ether_arp, struct in_addr, struct addrinfo, struct ip, struct icmp, struct in6_addr, struct sockaddr_in6, struct ip6_hdr, struct icmp6_hdr, struct nd_neighbor_solicit, struct nd_opt_hdr], , , + [#include "have.h"] +) + +dnl Checks for library functions. +AC_TYPE_SIGNAL +AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol system time usleep unsetenv vsyslog writev], + [], [], [#include "have.h"] +) + +dnl Support for SunOS + +AC_CHECK_FUNC(socket, [], [ + AC_CHECK_LIB(socket, connect) +]) +AC_CHECK_FUNC(gethostbyname, [], [ + AC_CHECK_LIB(nsl, gethostbyname) +]) + +AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo], + [], [], [#include "have.h"] +) + +AC_CACHE_SAVE + +dnl These are defined in files in m4/ + +AC_ARG_WITH(libgcrypt, AC_HELP_STRING([--with-libgcrypt], [enable use of libgcrypt instead of OpenSSL])], []) + +tinc_CURSES +tinc_LIBEVENT +tinc_ZLIB +tinc_LZO + +if test "$with_libgcrypt" = yes; then + AM_PATH_LIBGCRYPT([1.4.0], [], []) + ln -sf gcrypt/cipher.c gcrypt/cipher.h gcrypt/crypto.c gcrypt/crypto.h gcrypt/digest.c gcrypt/digest.h gcrypt/ecdh.c gcrypt/ecdh.h gcrypt/ecdsa.c gcrypt/ecdsa.h gcrypt/ecdsagen.c gcrypt/ecdsagen.h gcrypt/prf.c gcrypt/prf.h gcrypt/rsa.c gcrypt/rsa.h gcrypt/rsagen.c gcrypt/rsagen.h src/ +else + tinc_OPENSSL + ln -sf openssl/cipher.c openssl/cipher.h openssl/crypto.c openssl/crypto.h openssl/digest.c openssl/digest.h openssl/ecdh.c openssl/ecdh.h openssl/ecdsa.c openssl/ecdsa.h openssl/ecdsagen.c openssl/ecdsagen.h openssl/prf.c openssl/prf.h openssl/rsa.c openssl/rsa.h openssl/rsagen.c openssl/rsagen.h src/ +fi + + +dnl Check if support for jumbograms is requested +AC_ARG_ENABLE(jumbograms, + AS_HELP_STRING([--enable-jumbograms], [enable support for jumbograms (packets up to 9000 bytes)]), + [ AC_DEFINE(ENABLE_JUMBOGRAMS, 1, [Support for jumbograms (packets up to 9000 bytes)]) ] +) + +AC_SUBST(INCLUDES) + +AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile gui/Makefile]) + +AC_OUTPUT diff --git a/debian/NEWS b/debian/NEWS index b3eb367..1e7095f 100644 --- a/debian/NEWS +++ b/debian/NEWS @@ -1,14 +1,11 @@ -tinc (1.0.27-1) unstable; urgency=medium +tinc (1.1~pre2-1) experimental; urgency=low - This package now provides native systemd service files, allowing multiple - instances of tinc to be managed. Existing networks listed in - /etc/tinc/nets.boot will be converted to service instances once during this - upgrade. Afterwards, you can enable and disable networks using: - - systemctl enable tinc@ - systemctl disable tinc@ - - If you do not have systemd installed, the SysV init script will continue to - work as usual. For more information, see README.Debian. + * tinc-1.1 has separate control utility, tincctl, which is now used + to start/stop tinc instances, to reload configuration, to get + various information about running tincd (including dump of nodes + and connections) and so on. tincd still reacts to some signals + as before, but this usage is deprecated. In particular, -k + option is now gone. Also, node/connection/etc dumps are + produced on tincctl stdout, not into syslog. - -- Guus Sliepen Sun, 10 Apr 2016 01:33:55 +0200 + -- Michael Tokarev Sun, 07 Aug 2011 13:16:17 +0400 diff --git a/debian/README.Debian b/debian/README.Debian index d911295..08b14d9 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -1,54 +1,17 @@ tinc for Debian ---------------- +---------------------- The manual for tinc is also available as info pages, type `info tinc' to read it. -There are several ways in which tinc may be automatically started at boot: - -Systemd -------- - -Since 1.0.27-1, the tinc package comes with native systemd service files. -To enable and start a net, call: - -systemctl enable tinc@ -systemctl start tinc@ - -This will cause a tincd to be started which uses the configuration from -/etc/tinc/, and also makes sure that it will be started next time your -system boots. - -Apart from controlling individual instances, you can also start/stop/reload all -enabled instances simultaneously by omitting @, for example: - -systemctl reload tinc - -Note that when you have systemd installed on your system, the file -/etc/tinc/nets.boot will not be used anymore to automatically start tinc -daemons. If the variable EXTRA is defined in /etc/default/tinc, it will be -passed on to tinc. The variable LIMITS is however not used. - -The service files that come with this package start tinc unconditionally. -However, tinc does support socket activation. If you wish to write a socket -unit for tinc, use the ListenStream option to specify on which port(s) and -address(es) tinc should listen. - -SysVinit --------- - The system startup script for tinc, /etc/init.d/tinc, uses the file -/etc/tinc/nets.boot to find out which networks have to be started. Use one -netname per line. Lines starting with a # are ignored. +/etc/tinc/nets.boot to find out which networks have to be started. -/etc/network/interfaces ------------------------ - -You can create a stanza in /etc/network/interfaces, and add a line with -"tinc-net ". This will cause a tincd to be started which uses the -configuration from /etc/tinc/. You can use an inet static (with -address and netmask options) or inet dhcp stanza, in which case the ifup will -configure the VPN interface and you do not need to have a tinc-up script. +Alternatively, you can create a stanza in /etc/network/interfaces, and add a +line with "tinc-net ". This will cause a tincd to be started which +uses the configuration from /etc/tinc/. You can use an inet static +(with address and netmask options) or inet dhcp stanza, in which case the ifup +will configure the VPN interface and you do not need to have a tinc-up script. The following options are also recognized and map directly to the corresponding command line options for tincd: @@ -57,7 +20,6 @@ tinc-config tinc-debug tinc-mlock yes tinc-logfile -tinc-pidfile tinc-chroot yes tinc-user @@ -70,11 +32,10 @@ iface vpn inet static tinc-debug 1 tinc-mlock yes tinc-user nobody - tinc-pidfile /tmp/tinc.pid This will start a tinc daemon that reads its configuration from /etc/tinc/myvpn, logs at debug level 1, locks itself in RAM, runs as user nobody, and creates a network interface called "vpn". Ifup then sets the address and netmask on that interface. - -- Guus Sliepen , Sun, 10 April 2016, 01:38:08 +0200 + -- Guus Sliepen , Fri, 24 June 2011, 18:10:53 +0200 diff --git a/debian/changelog b/debian/changelog index a98443c..6727d50 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,200 +1,12 @@ -tinc (1.0.35-2) unstable; urgency=medium +tinc (1.1~pre2-1) experimental; urgency=low - * Bump Standards-Version and Build-Depend on debhelper-compat (= 12). - * Remove calls to dh_installinit and dh_systemd_start from debian/rules, - compat level 12 does the right thing by default. - * Ensure we clean up doc/tinc.info. + * first cut of 1.1-tobe. + Rewrote control scripts et al to use tincctl. + * build-depend on libssl >>1.0.0 to get proper EC support + * remove crypto-related symlinks from src/ in clean -- + probably should go into upstream makefile instead - -- Guus Sliepen Mon, 28 Jan 2019 21:54:45 +0100 - -tinc (1.0.35-1) unstable; urgency=medium - - * New upstream release. - - Includes fixes for CVE-2018-16737, CVE-2018-16738, CVE-2018-16758. - - -- Guus Sliepen Mon, 08 Oct 2018 16:09:06 +0200 - -tinc (1.0.34-1) unstable; urgency=medium - - [ Guus Sliepen ] - * New upstream release. - - Fixes a potential segmentation fault when connecting to an IPv6 - peer via a proxy. Closes: #887401 - * Add support for the $EXTRA variable in /etc/default/tinc when using - systemd. Closes: #887116 - - [ Benda Xu ] - * Prevent possible incorrect IPv6 checksums due to function inlining. - Closes: #891400 - - -- Guus Sliepen Tue, 12 Jun 2018 23:00:49 +0200 - -tinc (1.0.33-1) unstable; urgency=medium - - * New upstream release. - * Test for /etc/default/tinc before trying to source it. Closes: #777262 - * Use --runstatedir=/run. - - -- Guus Sliepen Sat, 04 Nov 2017 16:22:06 +0100 - -tinc (1.0.32-1) unstable; urgency=medium - - * New upstream release. - * Add a note to new nets.boot files that it is not used with systemd. - Closes: #841052 - * In the post-down script, read the pid file only once. Closes: #832784 - * Explicitly use /bin/sleep from coreutils. Closes: #772379 - * Bump Standards-Version. - - -- Guus Sliepen Tue, 05 Sep 2017 20:23:36 +0200 - -tinc (1.0.31-1) unstable; urgency=medium - - * New upstream release. - * Bump Standards-Version. - * Bump debian/compat. - * Add missing Depends: lsb-base. - - -- Guus Sliepen Sun, 15 Jan 2017 16:20:40 +0100 - -tinc (1.0.29-2) unstable; urgency=medium - - * Rebuild with libssl-dev from unstable. - - -- Guus Sliepen Thu, 27 Oct 2016 13:09:46 +0200 - -tinc (1.0.29-1) unstable; urgency=medium - - * New upstream release. - * Bump debian/compat. - - -- Guus Sliepen Mon, 10 Oct 2016 22:30:25 +0200 - -tinc (1.0.28-1) unstable; urgency=medium - - * New upstream release. - - Fixes FTBFS on kfreebsd. - * Systemd service files are now provided by upstream. - - -- Guus Sliepen Sun, 10 Apr 2016 15:44:28 +0200 - -tinc (1.0.27-2) unstable; urgency=medium - - * Fix tinc@.service. - - -- Guus Sliepen Sun, 10 Apr 2016 12:45:33 +0200 - -tinc (1.0.27-1) unstable; urgency=medium - - * New upstream release. - * Bump Standards-Version. - * Add native systemd unit files. - * Automatically convert networks listed in nets.boot to systemd service - instances on upgrade. - - -- Guus Sliepen Sun, 10 Apr 2016 01:39:16 +0200 - -tinc (1.0.26-1) unstable; urgency=medium - - * New upstream release. - * Use the contents, not the presence, of the pidfile to check that tincd is - shut down properly. Closes: #774682 - * Bump Standards-Version. - - -- Guus Sliepen Sun, 05 Jul 2015 17:23:08 +0200 - -tinc (1.0.24-2) unstable; urgency=medium - - * Improve the init script: stopping tinc now waits for the process to - terminate. If that doesn't happen in 5 seconds, it will send the TERM - signal again (which helps if tinc is waiting for a script to finish - executing). It now also detects whether the process mentioned in the PID - file is actually running, and if not it will exit early and without - warnings. Closes: #748107 - - -- Guus Sliepen Wed, 14 May 2014 21:44:16 +0200 - -tinc (1.0.24-1) unstable; urgency=medium - - [ Guus Sliepen ] - * New upstream release - * Add a debian/watch file. - * Bump Standards-Version. - - [ Gian Piero Carrubba ] - * Allow resource limits to be set in /etc/default/tinc. - Closes: #690685, #704702 - - -- Guus Sliepen Sun, 11 May 2014 21:17:13 +0200 - -tinc (1.0.23-2) unstable; urgency=low - - * Use if-statements instead of && in shell scripts. Closes: #731279 - The && operator does not clear the error status, and if the next statement - in a shell script does not change the error status it would cause the - script to prematurely exit. Thanks to Peter Reinholdtsen for spotting it. - * Use absolute path to tincd in the if-post-down script. - - -- Guus Sliepen Thu, 05 Dec 2013 09:41:13 +0000 - -tinc (1.0.23-1) unstable; urgency=low - - * New upstream release. - - -- Guus Sliepen Sat, 19 Oct 2013 21:06:05 +0200 - -tinc (1.0.22-1) unstable; urgency=low - - * New upstream release. - - Handles whitespace between command line flags and optional arguments. - Closes: #710267 - * Bump Standards-Version. - * Source /lib/lsb/init-functions in the init.d script. - * Don't use texi2html anymore, use automake's install-html target which uses - makeinfo. - - -- Guus Sliepen Wed, 14 Aug 2013 15:34:29 +0200 - -tinc (1.0.21-1) unstable; urgency=low - - * New upstream release. - - Includes fix for CVE-2013-1428. - - -- Guus Sliepen Sun, 05 May 2013 10:42:33 +0200 - -tinc (1.0.19-3) unstable; urgency=high - - * Drop packets forwarded via TCP if they are too big (CVE-2013-1428). - - -- Guus Sliepen Fri, 12 Apr 2013 22:52:10 +0200 - -tinc (1.0.19-2) unstable; urgency=low - - * Fix behaviour of tinc-pidfile. Closes: #679130 - * Enable parallel building in debian/rules. - - -- Guus Sliepen Tue, 26 Jun 2012 18:28:34 +0200 - -tinc (1.0.19-1) unstable; urgency=low - - * New upstream release. - * Bump debian/compat so tinc gets built with hardening flags. - * Allow tinc-pidfile in /etc/network/interfaces. - - -- Guus Sliepen Mon, 25 Jun 2012 20:29:22 +0200 - -tinc (1.0.18-1) unstable; urgency=low - - * New upstream release. - - -- Guus Sliepen Sun, 25 Mar 2012 18:52:15 +0200 - -tinc (1.0.17-1) unstable; urgency=low - - * New upstream release. - * Enable support for UML and VDE. - - -- Guus Sliepen Sat, 10 Mar 2012 14:50:00 +0100 + -- Michael Tokarev Sun, 07 Aug 2011 12:57:15 +0400 tinc (1.0.16-1) unstable; urgency=low diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control index 3efe26a..9f9999a 100644 --- a/debian/control +++ b/debian/control @@ -2,15 +2,13 @@ Source: tinc Section: net Priority: optional Maintainer: Guus Sliepen -Standards-Version: 4.3.0 -Build-Depends: libssl-dev, debhelper-compat (= 12), gettext, texinfo, zlib1g-dev, liblzo2-dev, libvdeplug-dev +Standards-Version: 3.9.2 +Build-Depends: libssl-dev (>>1.0.0), debhelper (>= 7.0.50~), gettext, texi2html, texinfo, zlib1g-dev, liblzo2-dev Homepage: http://www.tinc-vpn.org/ -Rules-Requires-Root: no Package: tinc Architecture: any -Pre-Depends: ${misc:Pre-Depends} -Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base (>= 3.0-6) +Depends: ${shlibs:Depends}, ${misc:Depends} Description: Virtual Private Network daemon tinc is a daemon with which you can create a virtual private network (VPN). One daemon can handle multiple connections, so you can diff --git a/debian/doc-base.tinc b/debian/doc-base.tinc index a37f46a..3fea71b 100644 --- a/debian/doc-base.tinc +++ b/debian/doc-base.tinc @@ -6,5 +6,5 @@ Abstract: This manual describes how to set up a Virtual Private Section: System/Security Format: HTML -Files: /usr/share/doc/tinc/tinc.html/* -Index: /usr/share/doc/tinc/tinc.html/index.html +Files: /usr/share/doc/tinc/tinc*.html +Index: /usr/share/doc/tinc/tinc_toc.html diff --git a/debian/patches/fix-incorrect-icmpv6-checksum b/debian/patches/fix-incorrect-icmpv6-checksum deleted file mode 100644 index 4448b88..0000000 --- a/debian/patches/fix-incorrect-icmpv6-checksum +++ /dev/null @@ -1,65 +0,0 @@ -Package: tinc -Version: 1.0.33-1 -Severity: important - -Dear Guus, - -I have been using tinc since 2009 and it is great! - -When PMTUDiscovery=yes and Mode=switch, and if ipv6 is used inside -tinc, the ICMPv6 "Packet Too Big" packets have incorrect checksums. -It can be reproduced by `ping6 -s 1800` and `tcpdump -i -`. Consequently, the host ignores the tinc-generated -ICMPv6 packets, PMTUDiscovery does not work and the connections freeze -when data flows are big. - -I find the bug is gone if the function "inet_checksum" in route.c is -not inlined, either by compiling tinc with "-O2 --fno-inline-functions", or apply a patch such as, - -diff --git a/src/route.c b/src/route.c -index ff82c06e..cd55383a 100644 ---- a/src/route.c -+++ b/src/route.c -@@ -60,7 +60,7 @@ static const size_t opt_size = sizeof(struct nd_opt_hdr); - - /* RFC 1071 */ - --static uint16_t inet_checksum(void *data, int len, uint16_t prevsum) { -+__attribute__ ((noinline)) static uint16_t inet_checksum(void *data, int len, uint16_t prevsum) { - uint16_t *p = data; - uint32_t checksum = prevsum ^ 0xFFFF; - - - -I have tested with gcc-7.3.0 and gcc-5.4.0. They behaved the same. I -am not good at assembly to find out what really happened, but it is -for sure that inet_checksum does not work as expected if compiled -inline. - -Thanks! - -Yours, -Benda - --- System Information: -Debian Release: buster/sid - APT prefers unstable - APT policy: (500, 'unstable') -Architecture: amd64 (x86_64) - -Kernel: Linux 4.9.0-5-amd64 (SMP w/8 CPU cores) -Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8), LANGUAGE=en_US:en (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8) -Shell: /bin/sh linked to /bin/dash -Init: sysvinit (via /sbin/init) - -Versions of packages tinc depends on: -ii libc6 2.26-2 -ii liblzo2-2 2.08-1.2+b2 -ii libssl1.1 1.1.0g-2 -ii lsb-base 9.20170808 -ii zlib1g 1:1.2.8.dfsg-5 - -tinc recommends no packages. - -tinc suggests no packages. diff --git a/debian/patches/series b/debian/patches/series deleted file mode 100644 index a4c8974..0000000 --- a/debian/patches/series +++ /dev/null @@ -1,2 +0,0 @@ -fix-incorrect-icmpv6-checksum -support-etc-defaults-tinc diff --git a/debian/patches/support-etc-defaults-tinc b/debian/patches/support-etc-defaults-tinc deleted file mode 100644 index 80b3d86..0000000 --- a/debian/patches/support-etc-defaults-tinc +++ /dev/null @@ -1,12 +0,0 @@ ---- a/systemd/tinc@.service.in -+++ b/systemd/tinc@.service.in -@@ -9,7 +9,8 @@ - [Service] - Type=simple - WorkingDirectory=@sysconfdir@/tinc/%i --ExecStart=@sbindir@/tincd -n %i -D -+EnvironmentFile=/etc/default/tinc -+ExecStart=@sbindir@/tincd -n %i -D $EXTRA - ExecReload=@sbindir@/tincd -n %i -kHUP - KillMode=mixed - Restart=on-failure diff --git a/debian/postinst b/debian/postinst index c4f5d53..62aea7e 100644 --- a/debian/postinst +++ b/debian/postinst @@ -7,15 +7,14 @@ set -e case "$1" in configure) if [ ! -e /dev/.devfsd ] ; then if [ ! -e /dev/.devfs ] ; then - if [ ! -e /dev/net/tun ] ; then if [ ! -e /dev/tun ] ; then if [ -e /dev/MAKEDEV ]; then + if [ ! -e /dev/net/tun ] ; then if [ ! -e /dev/tun ] ; then echo "Creating tun device..." cd /dev && ./MAKEDEV net/tun 2>/dev/null || ./MAKEDEV tun 2>/dev/null || echo "Failed to create tun device." - fi; fi; fi + fi; fi fi; fi if [ ! -e $NETSFILE ] ; then - echo "## This file contains all names of the networks to be started on system startup when using sysvinit." > $NETSFILE - echo "## If you are using systemd, use systemctl enable tinc@netname to enable individual networks." >> $NETSFILE + echo "## This file contains all names of the networks to be started on system startup." > $NETSFILE fi ;; diff --git a/debian/preinst b/debian/preinst deleted file mode 100644 index 721a2bd..0000000 --- a/debian/preinst +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -NETSFILE="/etc/tinc/nets.boot" -SYSTEM="/lib/systemd/system" -WANTS="/etc/systemd/system/multi-user.target.wants" - -set -e - -case "$1" in - upgrade) - if dpkg --compare-versions "$2" '<<' "1.0.27-1"; then - if [ -f "$NETSFILE" ]; then - echo -n "Creating systemd service instances from nets.boot:" - mkdir -p "$WANTS" - egrep '^[ ]*[a-zA-Z0-9_-]+' $NETSFILE | while read net args; do - echo -n " $net" - ln -s "$SYSTEM/tinc@.service" "$WANTS/tinc@$net.service" 2>/dev/null || true - done - echo "." - fi - fi - ;; - - *) - ;; -esac - -#DEBHELPER# diff --git a/debian/rules b/debian/rules index 43828fa..194d4d8 100755 --- a/debian/rules +++ b/debian/rules @@ -1,16 +1,34 @@ #!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 %: - dh $@ + dh $@ + +override_dh_auto_build: + dh_auto_build + cd doc && $(MAKE) texi2html + +override_dh_auto_install: + dh_auto_install + # Guess where texi2html installed its output today... + [ -f doc/tinc/tinc.html ] \ + && mv doc/tinc/*.html debian/tinc/usr/share/doc/tinc/ \ + || mv doc/*.html debian/tinc/usr/share/doc/tinc/ + # Remove info dir file + rm -f debian/tinc/usr/share/info/dir + +override_dh_installinit: + dh_installinit -R override_dh_clean: dh_clean - rm -f doc/tinc.info - -override_dh_auto_configure: - dh_auto_configure -- --enable-uml --enable-vde --with-systemd=/lib/systemd/system --runstatedir=/run - -override_dh_auto_install: - dh_auto_install -- install-html - # Remove info dir file - rm -f debian/tinc/usr/share/info/dir + rm -f src/device.c + rm -f src/rsa.[ch] src/rsagen.[ch] src/prf.[ch] src/ecdh.[ch] src/ecdsa.[ch] src/ecdsagen.[ch] src/digest.[ch] src/crypto.[ch] src/cipher.[ch] diff --git a/debian/tinc.default b/debian/tinc.default index bca2432..9806969 100644 --- a/debian/tinc.default +++ b/debian/tinc.default @@ -1,7 +1,2 @@ # Extra options to be passed to tincd. # EXTRA="-d" - -# Limits to be configured for the tincd process. Please read your shell -# (pointed by /bin/sh) documentation for ulimit. You probably want to raise the -# max locked memory value if using both --mlock and --user flags. -# LIMITS="-l 1024" diff --git a/debian/tinc.dirs b/debian/tinc.dirs index 1eae2e2..a056c9a 100644 --- a/debian/tinc.dirs +++ b/debian/tinc.dirs @@ -2,6 +2,5 @@ usr/sbin usr/share etc etc/init.d -usr/share/locale usr/share/doc/tinc etc/tinc diff --git a/debian/tinc.files b/debian/tinc.files index 3d376cc..b48b571 100644 --- a/debian/tinc.files +++ b/debian/tinc.files @@ -1,6 +1,6 @@ usr/sbin/tincd +usr/sbin/tincctl usr/share/man etc usr/share/doc/tinc -usr/share/locale usr/share/info diff --git a/debian/tinc.if-post-down b/debian/tinc.if-post-down index e173476..b461f22 100755 --- a/debian/tinc.if-post-down +++ b/debian/tinc.if-post-down @@ -2,40 +2,18 @@ set -e -if [ "$METHOD" = loopback -o -z "$IF_TINC_NET" ]; then - exit 0 +if [ "$IF_TINC_NET" ] ; then + tincctl -n "$IF_TINC_NET" stop + sleep 0.1 + i=0; + while [ -f "/var/run/tinc.$IF_TINC_NET.pid" ] ; do + if [ $i = '30' ] ; then + echo 'Failed to stop tinc daemon!' + exit 1 + fi + sleep 0.1 + i=$(($i+1)) + done fi -# Determine location of the PID file - -EXTRA="" -if [ -n "$IF_TINC_PIDFILE" ]; then - EXTRA="--pidfile=$IF_TINC_PIDFILE" -else - IF_TINC_PIDFILE=/var/run/tinc.$IF_TINC_NET.pid -fi - -# Stop the tinc daemon - -read pid rest < $IF_TINC_PIDFILE 2>/dev/null - -/usr/sbin/tincd -n "$IF_TINC_NET" -k $EXTRA - -# Wait for it to shut down properly - -/bin/sleep 0.1 -i=0; -while [ -f $IF_TINC_PIDFILE ] ; do - if [ ! -e "/proc/$pid" ] ; then - exit 0 - fi - - if [ $i = '30' ] ; then - echo 'Failed to stop tinc daemon!' - exit 1 - fi - /bin/sleep 0.1 - i=$(($i+1)) -done - exit 0 diff --git a/debian/tinc.if-pre-up b/debian/tinc.if-pre-up index 68a3b53..e0e5a45 100755 --- a/debian/tinc.if-pre-up +++ b/debian/tinc.if-pre-up @@ -2,29 +2,11 @@ set -e -if [ "$METHOD" = loopback -o -z "$IF_TINC_NET" ]; then - exit 0 -fi +[ -z "$IF_TINC_NET" ] && exit 0 # Read options from /etc/default -[ -r /etc/default/tinc ] && . /etc/default/tinc - -# Set process limits - -setlimits() { - while [ $# -gt 0 ]; do - parm=$1 ; shift - if [ -n "$1" -a "${1#-}" = "$1" ]; then - value=$1 ; shift - ulimit $parm $value - else - ulimit $parm - fi - done -} - -test -n "$LIMITS" && setlimits $LIMITS +. /etc/default/tinc # Read options from /etc/network/interfaces @@ -32,38 +14,23 @@ test -n "$LIMITS" && setlimits $LIMITS [ -n "$IF_TINC_DEBUG" ] && EXTRA="$EXTRA -d$IF_TINC_DEBUG" [ -n "$IF_TINC_MLOCK" ] && EXTRA="$EXTRA --mlock" [ -n "$IF_TINC_LOGFILE" ] && EXTRA="$EXTRA --logfile=$IF_TINC_LOGFILE" -[ -n "$IF_TINC_PIDFILE" ] && EXTRA="$EXTRA --pidfile=$IF_TINC_PIDFILE" || IF_TINC_PIDFILE=/var/run/tinc.$IF_TINC_NET.pid [ -n "$IF_TINC_CHROOT" ] && EXTRA="$EXTRA --chroot" [ -n "$IF_TINC_USER" ] && EXTRA="$EXTRA --user=$IF_TINC_USER" - # Start tinc daemon /usr/sbin/tincd -n "$IF_TINC_NET" -o "Interface=$IFACE" $EXTRA # Wait for it to come up properly -/bin/sleep 0.1 +sleep 0.1 i=0; -while [ ! -f $IF_TINC_PIDFILE ] ; do +while [ ! -f "/var/run/tinc.$IF_TINC_NET.pid" ] ; do if [ $i = '30' ] ; then echo 'Failed to start tinc daemon!' exit 1 fi - /bin/sleep 0.1 - i=$(($i+1)) -done - -while read pid rest < $IF_TINC_PIDFILE ; do - if [ -e "/proc/$pid" ] ; then - exit 0 - fi - - if [ $i = '30' ] ; then - echo 'Failed to start tinc daemon!' - exit 1 - fi - /bin/sleep 0.1 + sleep 0.1 i=$(($i+1)) done diff --git a/debian/tinc.if-up b/debian/tinc.if-up index 364f88f..e77c9ba 100755 --- a/debian/tinc.if-up +++ b/debian/tinc.if-up @@ -2,8 +2,7 @@ set -e -if [ "$METHOD" = loopback -o -n "$IF_TINC_NET" ]; then - exit 0 -fi +[ "$METHOD" = loopback ] && exit 0 +[ -n "$IF_TINC_NET" ] && exit 0 -invoke-rc.d tinc alarm || exit 0 +invoke-rc.d tinc retry diff --git a/debian/tinc.init b/debian/tinc.init index 44ff4cf..68ce332 100644 --- a/debian/tinc.init +++ b/debian/tinc.init @@ -18,9 +18,8 @@ # # Based on Lubomir Bulej's Redhat init script. -. /lib/lsb/init-functions - DAEMON="/usr/sbin/tincd" +CONTROL="/usr/sbin/tincctl" NAME="tinc" DESC="tinc daemons" TCONF="/etc/tinc" @@ -41,7 +40,10 @@ foreach_net() { shift egrep '^[ ]*[a-zA-Z0-9_-]+' $NETSFILE | while read net args; do echo -n " $net" - "$@" $net $args + case "$1" in + start) $CONTROL -n $net start -- $EXTRA $args ;; + *) $CONTROL -n $net $1 ;; + esac done echo "." } @@ -49,72 +51,13 @@ foreach_net() { signal_running() { for i in /var/run/tinc.*pid; do if [ -f "$i" ]; then - head -1 $i | while read pid; do + head -1 $i | while read pid junk; do kill -$1 $pid done fi done } -setlimits() { - while [ $# -gt 0 ]; do - parm=$1 ; shift - if [ -n "$1" -a "${1#-}" = "$1" ]; then - value=$1 ; shift - ulimit $parm $value - else - ulimit $parm - fi - done -} - -test -n "$LIMITS" && setlimits $LIMITS - -start() { - $DAEMON $EXTRA -n "$@" -} - -stop() { - [ -f /var/run/tinc.$1.pid ] || return - read pid rest /dev/null || return - - $DAEMON -n $1 -k || return - - i=0; - /bin/sleep 0.5 - - # Wait for the pidfile to disappear - while [ -f /var/run/tinc.$1.pid ]; do - # And check that there is an actual process running - kill -0 "$pid" 2>/dev/null || return - - if [ $i = '10' ] ; then - # It's still alive, kill it again and give up - $DAEMON -n $1 -k && /bin/sleep 0.5 - break - else - echo -n "." - i=$(($i+1)) - fi - - /bin/sleep 0.5 - done -} - -reload() { - $DAEMON -n $1 -kHUP -} - -alarm() { - $DAEMON -n $1 -kALRM -} - -restart() { - stop "$@" - start "$@" -} - case "$1" in start) foreach_net "Starting $DESC:" start @@ -128,11 +71,15 @@ case "$1" in restart) foreach_net "Restarting $DESC:" restart ;; - alarm) + force-restart) + $0 stop + $0 start + ;; + retry) signal_running ALRM ;; *) - echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload|alarm}" + echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload|retry}" exit 1 ;; esac diff --git a/debian/upstream/signing-key.asc b/debian/upstream/signing-key.asc deleted file mode 100644 index a79b551..0000000 --- a/debian/upstream/signing-key.asc +++ /dev/null @@ -1,70 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1 - -mQINBEVZzTABEADawFv/ibQ48uA1eRhL07vdM36Pcq2HDyuyNA+vYEalNH4jLmha -nGPvDALWwX0DXIWDAG8zeTj8s8zliLIjuPS4WRI2YdKIvWeG9fEvpKSXVWa42ica -dpzn/H2aBd4Ax6rQaiTXKOvxANAp2Veb+73ssPV5AL00uGTpzhh98xQzfFQCZ9ZL -YSVPqbMed5oCt/4jM9FBO2CuBtkfiO0dVVYtW7FAVjcIlE2NaZol/KGvz7wsS+yA -dE42W0l5MdQueLmTF4AIUSSTyPFGMQoyqh+MPif73Y589IGcW6GdfKYWnVDo6Trh -HOhcEky+uTYKb6NL0vrJgUiYVMzAOXFDdJni1eQGO6EfZRNYtTga3alWq/jVelK7 -BID5JyNbkrTAqdPnhJGivVyk8gGX3+Hng8rkXTfWhp6yAYau1QfBm0F2tIQmpL1C -+7DoLvFErboQf685jXJBjzyvsJxB2ZLH1OOw6mNL0hy2LFkIyGza/bktY2em4apo -KWV5AM5LpyW6THH1oDS7706xFNkf4IFhKE0hKPzBiRnMDjRtMI131lkc5+P8Lqf5 -jLTCFUgbEhU6Dz2YjhHAumVm0NWJETUpFDtVvMrqk+mp5xldUOWRNlYQC5aQOyda -eHOlNzB/BFbPhKMWI/zWlEH6f0t6WjHb4iwpWO47511aVNHF59aPzbAHxwARAQAB -tC9UaW5jIERldmVsb3BtZW50IFRlYW0gPHRpbmMtZGV2ZWxAdGluYy12cG4ub3Jn -PokCNgQTAQIAIAUCRVnNMAIbAwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEEpg -hLnA1x9KxOAQAMPhO2WTXv9AaGQBQhyyoGseKoSfcRjtI9YEfE0OInQQ2E+SPYF/ -dkfeLGAUqa4foTYQlMqfw70vBhTdVCb7HLTGn6/ICFUtDwakUQCgUQGlUVQiondA -8W6jj+QWrh5BQhHuXy2nCVaKnksu0/xQPsJotghxuYqaot3iJ4qVw9iT/Yeo9irH -Ffftqu0OVCdQ5zQuFNI9YCv/C83L59ecH7bOzYz2efTyobvxrhmgQtgOQwCWOE09 -Kr3veM9KLG33YoXlqv8QN/3CwtsJvSwfhj+R2JowZC7RqHe/yznRzmRMsgbrolxi -uiJLonGxcNNkD7WhXi7/zL4A/JaC27XrFf1MPLv8aiTwnOIfrXd5jawpauUOZOXK -UjIZHlIqviB0r5s7A+AFeHW38Tp9VzNuQ7aEl5bHbSXV+s7DTAwGb279z0AVaJ3h -5hWFxupw7UoGdzROwCBYzeX3sioAL6QvkXua8X6zOH45VEiSwrRX3Hlx/MLo7Z4g -PWgFLf6WviHQXCG834To1XIwUk9RgNsL7OzGjtaCuRymADImKMNwierq2zTfoRFQ -v9onIadIMF1fsc70hiBG9yAi36MEuk4VxG8Jc3PQQfSFm4RWazv1k3E0AAIob2Ek -DLVjvLO62Navo/OQ6D7yyiX0qes5S7/k3F1h8+87eRn3yxZE2kbxPg8KuQENBEVZ -zYYBCACoYgExmMKEtABL3pir/IXI4exR/45hkP6txFIrkVQb8DGJ9H39kiDr4gtj -F+pvcgMpec35S3m4fJ7WhDNvbDB4ZvONc1NMKs9cqDXfB+TLWPm4W+SkcKUrs+nK -i8l7ieggTALJcvRoLTX2EFmUFrD6y870W3rK2SfC/0VJX8Ou5cPbwCeueExjo5x0 -3gNfu0jWUS0cyA9y+1rVVekrLuJY/+SI4jv3gdzrYbxD0f6dpbpC37QHoJdd0KGF -acPtT2azjY+HxW10EA3Aw9oZWFXnb1nFg2RbDpkaGLmLbaXweltLyw154UmCXxym -PXPqi9bSfEkj0GiYrapk4mW114u9ABEBAAGJA0QEGAECAA8FAkVZzYcCGwIFCQHh -M4ABKQkQSmCEucDXH0rAXSAEGQECAAYFAkVZzYcACgkQ017duBDeLmmu3wf/TFZM -tLKxiyQPtGSTE3eULPdWCEMDZXdSPTY0QHM7Zvh+qn1ei+iFpD0549MYnBEAwDIV -4o62Nrcg8IPu0CEkZIAn2JiFFGYvMGk91awZGV1GS3umd7Dt349E1oKDPZVzRn+j -QIKarXxxabRmx2s/dZZgSs/eguWTboBFmvls9tVfe8x/xPvcHFmqHVUoGKEJy6Tm -no+s4yNjpc5wAaRml+GYf1tK9WMFuZn79qKxkYv4WI96dXR0FL59YbFRkkaI+1/b -G31MvWTqVjY1nJGslByFPUUB8Ca1djtp1gx6NXnOYr3V5MEDfdbjjPu79No+/y6M -tIua5yNtSRlk2nKhIqo3D/sGQ/uHijiMRAtoLhiyqYMc9W9vx/KOoCUHoMJqE39a -Eputvgwwo0rwgSmNfB1dzneFojBdJ47WBSHC8NKtkpJj6mzvvlaI9jmEpK54x3nl -OmBj3X/xaepoRGAtrmgTBP4A9hSjrTMGu/tUQjlX+Xcr6n3g7GSVe5FpUyIMPXEU -+JZDTiEUyn1OdzfNGmnWP+KJX5pQVq4czf5XK6otLZJELDVw/Hbjnjmdz5WOKgEH -jSof3WPeMBgPAcd/cMAZeiGtWM1UpJBHqEXTkthmrpmtRftJKDbooNM9d5OwKiT+ -I3vNBv/plMSr8NDjhTWC+ihrN6RBj1vaqpDgGpucPhoO2hwNqWuI4q5WUKtCyw6J -An7ErNaH4c0nVaZq6kJ8Vxdt+LpKYmOsJ8y9xtl6StcrkKNn+6ZfCfee7DEo2bvb -scfpqJqqOqb5KOagTpYs8mo6yQ3leRvFtoeBOQHVQzct23EwOMxbDyeunT50a1eH -MZTEWuIiuCUudM81QXU46oIcaAtj8tpG0Tmnku9g27EjwxUt+8kVmhlPHMb2TdoF -k5d0ce+JuxIG5+i+t8sUCorMc8zfp4g1bxZeMOcPnfyO3bSW11EVcN7ZxHlFC+XE -YOByP50CM3P8lItPlQ+WpY9kYWjiwu9kVPaGQ16G47nspngJInU5dhka3KJGtIZe -q7kBDQRFWc3GAQgAz/JUs24niKsd0ZtOjUWd4R4y0gjS0kC/vvLL2gbXYkA9tcjG -5iEvVWJY34QsudX0v1ULsVnJ89X/gsk8hAhAia1TQm+0Qq+MSxEaQkMSaOO8N70U -XzgH1dielvpea20WO4MyWQuRIJ0K2nsGmEPnt6ZP7fK8HVHFNggP/mQ6LMu1reAF -gvb8cEtjb9B5QaCUEoLjsbsuo+vLW7AWy4GfIRNESHw2Qt08AUaGrihpu6zi7N2b -QkHHJtqa63GzYJ+kYzAVvrFJXdwL/TRXLBzv+6yyvYSIHi8uB6/o6CZN6hpjfpME -ph+oYPqXeNOyMd1E9Kg8ymcPrNyQKfE3WnCRXQARAQABiQIlBBgBAgAPBQJFWc3H -AhsMBQkB4TOAAAoJEEpghLnA1x9KXYMP/3D9JYti6C8DWuX2hWv+2SUbLcMa5u1e -ETewIo5S3mqGWSaxX4YLPVRkZ1lOLmFysOLimf0thYm7IsatLcWmBdYUpK92ilvr -Sk2sKlhrOoBXEX/79Kz+Aj5PjeyiQxgQ7Ba/afwhU6aTqs2Dp1T0YNu2eBvV+1QH -lZnW2Wh96zzwc0dJUuY9eBk5Fgpu08Wce7o6jxFPtVyAaQa0zcNAmw2TSY7wbunJ -WTl9OgATAyqVCuhWW7AnPcSqkH8lQigSc00wfqJKOD2Us0FqN6UKDCZTyQkdP6hx -G+3aUkkvGSOxy7u9bVWmrikuJMoiIY/CH/m+GcJJATVibI7t5MhhtBGySKc3PAwc -58sVe9AnbDvs84efrNP59j2KG2KKqcqjTGAmKyJnG3N50xJGakDIsqfneIRNWpEE -pOOPaOqR4qnPAS9OSt9A3hqBpWPjQcScd6AuO+J2PE5y23pTnb9PtLBQb5e4VFiv -N54u8j4bU2CO0SC2isZ3CR68dPHthWsxt4XbjhgktjbpQRQ8L2EDBQ8oE13GOrOw -P8x4Q0eC5uzkXNyRqzKOsxlZEuc+75aDDd3M2GDw08FG7GI1p/L+NgenwT+9TmFX -2hOKVrjgyx+fPut1t5DJJubDWXGOK33qvrL7HTCEv1zz7LNbbPwwNHK4lfMAWuJW -D9wc3Y9Se/P/ -=5MAs ------END PGP PUBLIC KEY BLOCK----- diff --git a/debian/watch b/debian/watch deleted file mode 100644 index f29609e..0000000 --- a/debian/watch +++ /dev/null @@ -1,2 +0,0 @@ -version=3 -opts=pgpsigurlmangle=s/$/.sig/ http://www.tinc-vpn.org/packages/tinc-(1\.0\.\d+)\.tar\.gz diff --git a/depcomp b/depcomp index 65cbf70..df8eea7 100755 --- a/depcomp +++ b/depcomp @@ -1,9 +1,10 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2018-03-07.03; # UTC +scriptversion=2009-04-28.21; # UTC -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free +# Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +17,7 @@ scriptversion=2018-03-07.03; # UTC # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,9 +28,9 @@ scriptversion=2018-03-07.03; # UTC case $1 in '') - echo "$0: No command. Try '$0 --help' for more information." 1>&2 - exit 1; - ;; + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] @@ -39,11 +40,11 @@ as side-effects. Environment variables: depmode Dependency tracking mode. - source Source file read by 'PROGRAMS ARGS'. - object Object file output by 'PROGRAMS ARGS'. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. - tmpdepfile Temporary file to use when outputting dependencies. + tmpdepfile Temporary file to use when outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to . @@ -56,66 +57,6 @@ EOF ;; esac -# Get the directory component of the given path, and save it in the -# global variables '$dir'. Note that this directory component will -# be either empty or ending with a '/' character. This is deliberate. -set_dir_from () -{ - case $1 in - */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; - *) dir=;; - esac -} - -# Get the suffix-stripped basename of the given path, and save it the -# global variable '$base'. -set_base_from () -{ - base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` -} - -# If no dependency file was actually created by the compiler invocation, -# we still have to create a dummy depfile, to avoid errors with the -# Makefile "include basename.Plo" scheme. -make_dummy_depfile () -{ - echo "#dummy" > "$depfile" -} - -# Factor out some common post-processing of the generated depfile. -# Requires the auxiliary global variable '$tmpdepfile' to be set. -aix_post_process_depfile () -{ - # If the compiler actually managed to produce a dependency file, - # post-process it. - if test -f "$tmpdepfile"; then - # Each line is of the form 'foo.o: dependency.h'. - # Do two passes, one to just change these to - # $object: dependency.h - # and one to simply output - # dependency.h: - # which is needed to avoid the deleted-header problem. - { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" - sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" - } > "$depfile" - rm -f "$tmpdepfile" - else - make_dummy_depfile - fi -} - -# A tabulation character. -tab=' ' -# A newline character. -nl=' -' -# Character ranges might be problematic outside the C locale. -# These definitions help. -upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ -lower=abcdefghijklmnopqrstuvwxyz -digits=0123456789 -alpha=${upper}${lower} - if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 @@ -128,9 +69,6 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" -# Avoid interferences from the environment. -gccflag= dashmflag= - # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case @@ -142,32 +80,18 @@ if test "$depmode" = hp; then fi if test "$depmode" = dashXmstdout; then - # This is just like dashmstdout with a different argument. - dashmflag=-xM - depmode=dashmstdout + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then - # This is just like msvisualcpp but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvisualcpp -fi - -if test "$depmode" = msvc7msys; then - # This is just like msvc7 but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvc7 -fi - -if test "$depmode" = xlc; then - # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. - gccflag=-qmakedep=gcc,-MF - depmode=gcc + # This is just like msvisualcpp but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u="sed s,\\\\\\\\,/,g" + depmode=msvisualcpp fi case "$depmode" in @@ -190,7 +114,8 @@ gcc3) done "$@" stat=$? - if test $stat -ne 0; then + if test $stat -eq 0; then : + else rm -f "$tmpdepfile" exit $stat fi @@ -198,17 +123,13 @@ gcc3) ;; gcc) -## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. -## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. -## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). Also, it might not be -## supported by the other compilers which use the 'gcc' depmode. +## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then @@ -216,31 +137,31 @@ gcc) fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? - if test $stat -ne 0; then + if test $stat -eq 0; then : + else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" - # The second -e expression handles DOS-style file names with drive - # letters. + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the "deleted header file" problem. +## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. -## Some versions of gcc put a space before the ':'. On the theory + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as -## well. hp depmode also adds that space, but also prefixes the VPATH -## to the object. Take care to not repeat it in the output. +## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; @@ -258,7 +179,8 @@ sgi) "$@" -MDupdate "$tmpdepfile" fi stat=$? - if test $stat -ne 0; then + if test $stat -eq 0; then : + else rm -f "$tmpdepfile" exit $stat fi @@ -266,41 +188,43 @@ sgi) if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" + # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like '#:fec' to the end of the + # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ - | tr "$nl" ' ' >> "$depfile" + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> "$depfile" echo >> "$depfile" + # The second pass generates a dummy entry for each header file. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> "$depfile" + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" else - make_dummy_depfile + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; -xlc) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts '$object:' at the + # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. - set_dir_from "$object" - set_base_from "$object" + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u @@ -313,7 +237,9 @@ aix) "$@" -M fi stat=$? - if test $stat -ne 0; then + + if test $stat -eq 0; then : + else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi @@ -322,100 +248,44 @@ aix) do test -f "$tmpdepfile" && break done - aix_post_process_depfile - ;; - -tcc) - # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 - # FIXME: That version still under development at the moment of writing. - # Make that this statement remains true also for stable, released - # versions. - # It will wrap lines (doesn't matter whether long or short) with a - # trailing '\', as in: - # - # foo.o : \ - # foo.c \ - # foo.h \ - # - # It will put a trailing '\' even on the last line, and will use leading - # spaces rather than leading tabs (at least since its commit 0394caf7 - # "Emit spaces for -MD"). - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat + if test -f "$tmpdepfile"; then + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" fi - rm -f "$depfile" - # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. - # We have to change lines of the first kind to '$object: \'. - sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" - # And for each line of the second kind, we have to emit a 'dep.h:' - # dummy dependency, to avoid the deleted-header problem. - sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; -## The order of this option in the case statement is important, since the -## shell code in configure will try each of these formats in the order -## listed in this file. A plain '-MD' option would be understood by many -## compilers, so we must ensure this comes after the gcc and icc options. -pgcc) - # Portland's C compiler understands '-MD'. - # Will always output deps to 'file.d' where file is the root name of the - # source file under compilation, even if file resides in a subdirectory. - # The object file name does not affect the name of the '.d' file. - # pgcc 10.2 will output +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using '\' : + # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... - set_dir_from "$object" - # Use the source, not the object, to determine the base name, since - # that's sadly what pgcc will do too. - set_base_from "$source" - tmpdepfile=$base.d - # For projects that build the same source file twice into different object - # files, the pgcc approach of using the *source* file root name can cause - # problems in parallel builds. Use a locking strategy to avoid stomping on - # the same $tmpdepfile. - lockdir=$base.d-lock - trap " - echo '$0: caught signal, cleaning up...' >&2 - rmdir '$lockdir' - exit 1 - " 1 2 13 15 - numtries=100 - i=$numtries - while test $i -gt 0; do - # mkdir is a portable test-and-set. - if mkdir "$lockdir" 2>/dev/null; then - # This process acquired the lock. - "$@" -MD - stat=$? - # Release the lock. - rmdir "$lockdir" - break - else - # If the lock is being held by a different process, wait - # until the winning process is done or we timeout. - while test -d "$lockdir" && test $i -gt 0; do - sleep 1 - i=`expr $i - 1` - done - fi - i=`expr $i - 1` - done - trap - 1 2 13 15 - if test $i -le 0; then - echo "$0: failed to acquire lock after $numtries attempts" >&2 - echo "$0: check lockdir '$lockdir'" >&2 - exit 1 - fi - - if test $stat -ne 0; then + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else rm -f "$tmpdepfile" exit $stat fi @@ -427,8 +297,8 @@ pgcc) sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. - sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ - | sed -e 's/$/ :/' >> "$depfile" + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; @@ -439,8 +309,9 @@ hp2) # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. - set_dir_from "$object" - set_base_from "$object" + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d @@ -451,7 +322,8 @@ hp2) "$@" +Maked fi stat=$? - if test $stat -ne 0; then + if test $stat -eq 0; then : + else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi @@ -461,107 +333,77 @@ hp2) test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" - # Add 'dependent.h:' lines. + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. sed -ne '2,${ - s/^ *// - s/ \\*$// - s/$/:/ - p - }' "$tmpdepfile" >> "$depfile" + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" else - make_dummy_depfile + echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in 'foo.d' instead, so we check for that too. - # Subdirectories are respected. - set_dir_from "$object" - set_base_from "$object" + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - # Libtool generates 2 separate objects for the 2 libraries. These - # two compilations output dependencies in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir$base.o.d # libtool 1.5 - tmpdepfile2=$dir.libs/$base.o.d # Likewise. - tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - "$@" -MD - fi + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mechanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - # Same post-processing that is required for AIX mode. - aix_post_process_depfile - ;; - -msvc7) - if test "$libtool" = yes; then - showIncludes=-Wc,-showIncludes - else - showIncludes=-showIncludes - fi - "$@" $showIncludes > "$tmpdepfile" - stat=$? - grep -v '^Note: including file: ' "$tmpdepfile" - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - # The first sed program below extracts the file names and escapes - # backslashes for cygpath. The second sed program outputs the file - # name when reading, but also accumulates all include files in the - # hold buffer in order to output them again at the end. This only - # works with sed implementations that can handle large buffers. - sed < "$tmpdepfile" -n ' -/^Note: including file: *\(.*\)/ { - s//\1/ - s/\\/\\\\/g - p -}' | $cygpath_u | sort -u | sed -n ' -s/ /\\ /g -s/\(.*\)/'"$tab"'\1 \\/p -s/.\(.*\) \\/\1:/ -H -$ { - s/.*/'"$tab"'/ - G - p -}' >> "$depfile" - echo >> "$depfile" # make sure the fragment doesn't end with a backslash - rm -f "$tmpdepfile" - ;; - -msvc7msys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; #nosideeffect) # This comment above is used by automake to tell side-effect @@ -580,7 +422,7 @@ dashmstdout) shift fi - # Remove '-o $object'. + # Remove `-o $object'. IFS=" " for arg do @@ -600,18 +442,18 @@ dashmstdout) done test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for ':' + # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: - # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | - sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this sed invocation - # correctly. Breaking it into two sed invocations is a workaround. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; @@ -661,15 +503,12 @@ makedepend) touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" - # makedepend may prepend the VPATH from the source file name to the object. - # No need to regex-escape $object, excess matching of '.' is harmless. - sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process the last invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed '1,2d' "$tmpdepfile" \ - | tr ' ' "$nl" \ - | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; @@ -686,7 +525,7 @@ cpp) shift fi - # Remove '-o $object'. + # Remove `-o $object'. IFS=" " for arg do @@ -705,10 +544,10 @@ cpp) esac done - "$@" -E \ - | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - | sed '$ s: \\$::' > "$tmpdepfile" + "$@" -E | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" @@ -740,23 +579,23 @@ msvisualcpp) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; + set fnord "$@" + shift + shift + ;; *) - set fnord "$@" "$arg" - shift - shift - ;; + set fnord "$@" "$arg" + shift + shift + ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" - echo "$tab" >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; @@ -783,9 +622,9 @@ exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff --git a/doc/Makefile.am b/doc/Makefile.am index 29d6ffd..8f0305e 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,35 +1,58 @@ ## Process this file with automake to get Makefile.in info_TEXINFOS = tinc.texi -tinc_TEXINFOS = tincinclude.texi -man_MANS = tincd.8 tinc.conf.5 +man_MANS = tincd.8 tincctl.8 tinc.conf.5 tinc-gui.8 -EXTRA_DIST = tincinclude.texi.in tincd.8.in tinc.conf.5.in sample-config +EXTRA_DIST = tincinclude.texi.in tincd.8.in tincctl.8.in tinc.conf.5.in tinc-gui.8.in sample-config.tar.gz -CLEANFILES = *.html tincd.8 tinc.conf.5 tincinclude.texi +CLEANFILES = *.html tinc.info tincd.8 tincctl.8 tinc.conf.5 tinc-gui.8 tincinclude.texi + +# Use `ginstall' in the definition of man_MANS to avoid +# confusion with the `install' target. The install rule transforms `ginstall' +# to install before applying any user-specified name transformations. +transform = s/ginstall/install/; @program_transform_name@ + +# For additional rules usually of interest only to the maintainer, +# see GNUmakefile and Makefile.maint. + +sample-config.tar.gz: sample-config + GZIP=$(GZIP_ENV) $(AMTAR) chozf sample-config.tar.gz --exclude .svn sample-config texi2html: tinc.texi - $(AM_V_GEN)texi2html -split=chapter $< + texi2html -split=chapter tinc.texi tincd.8.html: tincd.8 - $(AM_V_GEN)w3mman2html $< > $@ + w3mman2html $< > $@ + +tincctl.8.html: tincctl.8 + w3mman2html $< > $@ + +tinc-gui.8.html: tinc-gui.8 + w3mman2html $< > $@ tinc.conf.5.html: tinc.conf.5 - $(AM_V_GEN)w3mman2html $< > $@ + w3mman2html $< > $@ substitute = sed \ -e s,'@PACKAGE\@',"$(PACKAGE)",g \ -e s,'@VERSION\@',"$(VERSION)",g \ -e s,'@sysconfdir\@',"$(sysconfdir)",g \ - -e s,'@runstatedir\@',"$(runstatedir)",g \ -e s,'@localstatedir\@',"$(localstatedir)",g -tincd.8: $(srcdir)/tincd.8.in - $(AM_V_GEN)$(substitute) $(srcdir)/tincd.8.in > $@ +tincd.8: tincd.8.in + $(substitute) $< > $@ -tinc.conf.5: $(srcdir)/tinc.conf.5.in - $(AM_V_GEN)$(substitute) $(srcdir)/tinc.conf.5.in > $@ +tincctl.8: tincctl.8.in + $(substitute) $< > $@ -tincinclude.texi: $(srcdir)/tincinclude.texi.in - $(AM_V_GEN)$(substitute) $(srcdir)/tincinclude.texi.in > $@ +tinc-gui.8: tinc-gui.8.in + $(substitute) $< > $@ + +tinc.conf.5: tinc.conf.5.in + $(substitute) $< > $@ + +tincinclude.texi: tincinclude.texi.in + $(substitute) $< > $@ + +tinc.texi: tincinclude.texi diff --git a/doc/Makefile.in b/doc/Makefile.in index 86497e4..b80f326 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. - +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -14,61 +15,6 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -78,7 +24,6 @@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : @@ -88,65 +33,21 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = doc +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in texinfo.tex ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ - $(top_srcdir)/m4/ax_append_flag.m4 \ - $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ - $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_check_link_flag.m4 \ - $(top_srcdir)/m4/ax_require_defined.m4 $(top_srcdir)/m4/lzo.m4 \ - $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/zlib.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/m4/curses.m4 $(top_srcdir)/m4/libevent.m4 \ + $(top_srcdir)/m4/lzo.m4 $(top_srcdir)/m4/openssl.m4 \ + $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = SOURCES = DIST_SOURCES = -AM_V_DVIPS = $(am__v_DVIPS_@AM_V@) -am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@) -am__v_DVIPS_0 = @echo " DVIPS " $@; -am__v_DVIPS_1 = -AM_V_MAKEINFO = $(am__v_MAKEINFO_@AM_V@) -am__v_MAKEINFO_ = $(am__v_MAKEINFO_@AM_DEFAULT_V@) -am__v_MAKEINFO_0 = @echo " MAKEINFO" $@; -am__v_MAKEINFO_1 = -AM_V_INFOHTML = $(am__v_INFOHTML_@AM_V@) -am__v_INFOHTML_ = $(am__v_INFOHTML_@AM_DEFAULT_V@) -am__v_INFOHTML_0 = @echo " INFOHTML" $@; -am__v_INFOHTML_1 = -AM_V_TEXI2DVI = $(am__v_TEXI2DVI_@AM_V@) -am__v_TEXI2DVI_ = $(am__v_TEXI2DVI_@AM_DEFAULT_V@) -am__v_TEXI2DVI_0 = @echo " TEXI2DVI" $@; -am__v_TEXI2DVI_1 = -AM_V_TEXI2PDF = $(am__v_TEXI2PDF_@AM_V@) -am__v_TEXI2PDF_ = $(am__v_TEXI2PDF_@AM_DEFAULT_V@) -am__v_TEXI2PDF_0 = @echo " TEXI2PDF" $@; -am__v_TEXI2PDF_1 = -AM_V_texinfo = $(am__v_texinfo_@AM_V@) -am__v_texinfo_ = $(am__v_texinfo_@AM_DEFAULT_V@) -am__v_texinfo_0 = -q -am__v_texinfo_1 = -AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) -am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@) -am__v_texidevnull_0 = > /dev/null -am__v_texidevnull_1 = -INFO_DEPS = $(srcdir)/tinc.info +INFO_DEPS = tinc.info am__TEXINFO_TEX_DIR = $(srcdir) DVIS = tinc.dvi PDFS = tinc.pdf @@ -158,11 +59,6 @@ TEXI2PDF = $(TEXI2DVI) --pdf --batch MAKEINFOHTML = $(MAKEINFO) --html AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) DVIPS = dvips -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac am__installdirs = "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man5dir)" \ "$(DESTDIR)$(man8dir)" am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; @@ -186,22 +82,18 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } man5dir = $(mandir)/man5 man8dir = $(mandir)/man8 NROFF = nroff MANS = $(man_MANS) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -am__DIST_COMMON = $(srcdir)/Makefile.in $(tinc_TEXINFOS) texinfo.tex DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +# Use `ginstall' in the definition of man_MANS to avoid +# confusion with the `install' target. The install rule transforms `ginstall' +# to install before applying any user-specified name transformations. +transform = s/ginstall/install/; @program_transform_name@ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -211,6 +103,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -220,15 +113,21 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ +INCLUDES = @INCLUDES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ @@ -240,6 +139,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -286,33 +186,29 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemd_path = @systemd_path@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ info_TEXINFOS = tinc.texi -tinc_TEXINFOS = tincinclude.texi -man_MANS = tincd.8 tinc.conf.5 -EXTRA_DIST = tincinclude.texi.in tincd.8.in tinc.conf.5.in sample-config -CLEANFILES = *.html tincd.8 tinc.conf.5 tincinclude.texi +man_MANS = tincd.8 tincctl.8 tinc.conf.5 tinc-gui.8 +EXTRA_DIST = tincinclude.texi.in tincd.8.in tincctl.8.in tinc.conf.5.in tinc-gui.8.in sample-config.tar.gz +CLEANFILES = *.html tinc.info tincd.8 tincctl.8 tinc.conf.5 tinc-gui.8 tincinclude.texi substitute = sed \ -e s,'@PACKAGE\@',"$(PACKAGE)",g \ -e s,'@VERSION\@',"$(VERSION)",g \ -e s,'@sysconfdir\@',"$(sysconfdir)",g \ - -e s,'@runstatedir\@',"$(runstatedir)",g \ -e s,'@localstatedir\@',"$(localstatedir)",g all: all-am .SUFFIXES: -.SUFFIXES: .dvi .html .info .pdf .ps .texi -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) +.SUFFIXES: .dvi .ps +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -324,74 +220,69 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu doc/Makefile +.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -.texi.info: - $(AM_V_MAKEINFO)restore=: && backupdir="$(am__leading_dot)am$$$$" && \ - am__cwd=`pwd` && $(am__cd) $(srcdir) && \ +tinc.info: tinc.texi + restore=: && backupdir="$(am__leading_dot)am$$$$" && \ rm -rf $$backupdir && mkdir $$backupdir && \ if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \ if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \ done; \ else :; fi && \ - cd "$$am__cwd"; \ if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ - -o $@ $<; \ + -o $@ `test -f 'tinc.texi' || echo '$(srcdir)/'`tinc.texi; \ then \ rc=0; \ - $(am__cd) $(srcdir); \ else \ rc=$$?; \ - $(am__cd) $(srcdir) && \ $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \ fi; \ rm -rf $$backupdir; exit $$rc -.texi.dvi: - $(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ +tinc.dvi: tinc.texi + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ - $(TEXI2DVI) $(AM_V_texinfo) --build-dir=$(@:.dvi=.t2d) -o $@ $(AM_V_texidevnull) \ - $< + $(TEXI2DVI) -o $@ `test -f 'tinc.texi' || echo '$(srcdir)/'`tinc.texi -.texi.pdf: - $(AM_V_TEXI2PDF)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ +tinc.pdf: tinc.texi + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ - $(TEXI2PDF) $(AM_V_texinfo) --build-dir=$(@:.pdf=.t2p) -o $@ $(AM_V_texidevnull) \ - $< + $(TEXI2PDF) -o $@ `test -f 'tinc.texi' || echo '$(srcdir)/'`tinc.texi -.texi.html: - $(AM_V_MAKEINFO)rm -rf $(@:.html=.htp) - $(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ - -o $(@:.html=.htp) $<; \ +tinc.html: tinc.texi + rm -rf $(@:.html=.htp) + if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + -o $(@:.html=.htp) `test -f 'tinc.texi' || echo '$(srcdir)/'`tinc.texi; \ then \ - rm -rf $@ && mv $(@:.html=.htp) $@; \ + rm -rf $@; \ + if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ + mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \ else \ - rm -rf $(@:.html=.htp); exit 1; \ + if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ + rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \ + exit 1; \ fi -$(srcdir)/tinc.info: tinc.texi $(tinc_TEXINFOS) -tinc.dvi: tinc.texi $(tinc_TEXINFOS) -tinc.pdf: tinc.texi $(tinc_TEXINFOS) -tinc.html: tinc.texi $(tinc_TEXINFOS) .dvi.ps: - $(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ - $(DVIPS) $(AM_V_texinfo) -o $@ $< + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + $(DVIPS) -o $@ $< uninstall-dvi-am: @$(NORMAL_UNINSTALL) @@ -413,7 +304,9 @@ uninstall-html-am: uninstall-info-am: @$(PRE_UNINSTALL) - @if test -d '$(DESTDIR)$(infodir)' && $(am__can_run_installinfo); then \ + @if test -d '$(DESTDIR)$(infodir)' && \ + (install-info --version && \ + install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ @@ -470,7 +363,9 @@ dist-info: $(INFO_DEPS) done mostlyclean-aminfo: - -rm -rf tinc.t2d tinc.t2p + -rm -rf tinc.aux tinc.cp tinc.cps tinc.fn tinc.fns tinc.ky tinc.kys \ + tinc.log tinc.pg tinc.pgs tinc.tmp tinc.toc tinc.tp tinc.tps \ + tinc.vr tinc.vrs clean-aminfo: -test -z "tinc.dvi tinc.pdf tinc.ps tinc.html" \ @@ -484,18 +379,11 @@ maintainer-clean-aminfo: done install-man5: $(man_MANS) @$(NORMAL_INSTALL) - @list1=''; \ - list2='$(man_MANS)'; \ - test -n "$(man5dir)" \ - && test -n "`echo $$list1$$list2`" \ - || exit 0; \ - echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \ - { for i in $$list1; do echo "$$i"; done; \ - if test -n "$$list2"; then \ - for i in $$list2; do echo "$$i"; done \ - | sed -n '/\.5[a-z]*$$/p'; \ - fi; \ + test -z "$(man5dir)" || $(MKDIR_P) "$(DESTDIR)$(man5dir)" + @list=''; test -n "$(man5dir)" || exit 0; \ + { for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.5[a-z]*$$/p'; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ @@ -524,21 +412,16 @@ uninstall-man5: sed -n '/\.5[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir) + test -z "$$files" || { \ + echo " ( cd '$(DESTDIR)$(man5dir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(man5dir)" && rm -f $$files; } install-man8: $(man_MANS) @$(NORMAL_INSTALL) - @list1=''; \ - list2='$(man_MANS)'; \ - test -n "$(man8dir)" \ - && test -n "`echo $$list1$$list2`" \ - || exit 0; \ - echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \ - { for i in $$list1; do echo "$$i"; done; \ - if test -n "$$list2"; then \ - for i in $$list2; do echo "$$i"; done \ - | sed -n '/\.8[a-z]*$$/p'; \ - fi; \ + test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)" + @list=''; test -n "$(man8dir)" || exit 0; \ + { for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.8[a-z]*$$/p'; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ @@ -567,18 +450,30 @@ uninstall-man8: sed -n '/\.8[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir) -tags TAGS: + test -z "$$files" || { \ + echo " ( cd '$(DESTDIR)$(man8dir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(man8dir)" && rm -f $$files; } +tags: TAGS +TAGS: -ctags CTAGS: - -cscope cscopelist: +ctags: CTAGS +CTAGS: -distdir: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) distdir-am - -distdir-am: $(DISTFILES) +distdir: $(DISTFILES) + @list='$(MANS)'; if test -n "$$list"; then \ + list=`for p in $$list; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ + if test -n "$$list" && \ + grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ + echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ + grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ + echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ + echo " typically \`make maintainer-clean' will remove them" >&2; \ + exit 1; \ + else :; fi; \ + else :; fi @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -628,15 +523,10 @@ install-am: all-am installcheck: installcheck-am install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: @@ -675,11 +565,8 @@ install-dvi: install-dvi-am install-dvi-am: $(DVIS) @$(NORMAL_INSTALL) + test -z "$(dvidir)" || $(MKDIR_P) "$(DESTDIR)$(dvidir)" @list='$(DVIS)'; test -n "$(dvidir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(dvidir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(dvidir)" || exit 1; \ - fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -694,22 +581,18 @@ install-html: install-html-am install-html-am: $(HTMLS) @$(NORMAL_INSTALL) + test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)" @list='$(HTMLS)'; list2=; test -n "$(htmldir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(htmldir)" || exit 1; \ - fi; \ for p in $$list; do \ if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \ $(am__strip_dir) \ - d2=$$d$$p; \ - if test -d "$$d2"; then \ + if test -d "$$d$$p"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \ $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ - echo " $(INSTALL_DATA) '$$d2'/* '$(DESTDIR)$(htmldir)/$$f'"; \ - $(INSTALL_DATA) "$$d2"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \ + echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \ + $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \ else \ - list2="$$list2 $$d2"; \ + list2="$$list2 $$d$$p"; \ fi; \ done; \ test -z "$$list2" || { echo "$$list2" | $(am__base_list) | \ @@ -721,12 +604,9 @@ install-info: install-info-am install-info-am: $(INFO_DEPS) @$(NORMAL_INSTALL) + test -z "$(infodir)" || $(MKDIR_P) "$(DESTDIR)$(infodir)" @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(infodir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(infodir)" || exit 1; \ - fi; \ for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ @@ -744,7 +624,8 @@ install-info-am: $(INFO_DEPS) echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(infodir)" || exit $$?; done @$(POST_INSTALL) - @if $(am__can_run_installinfo); then \ + @if (install-info --version && \ + install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ for file in $$list; do \ relfile=`echo "$$file" | sed 's|^.*/||'`; \ @@ -758,11 +639,8 @@ install-pdf: install-pdf-am install-pdf-am: $(PDFS) @$(NORMAL_INSTALL) + test -z "$(pdfdir)" || $(MKDIR_P) "$(DESTDIR)$(pdfdir)" @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(pdfdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pdfdir)" || exit 1; \ - fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -774,11 +652,8 @@ install-ps: install-ps-am install-ps-am: $(PSS) @$(NORMAL_INSTALL) + test -z "$(psdir)" || $(MKDIR_P) "$(DESTDIR)$(psdir)" @list='$(PSS)'; test -n "$(psdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(psdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(psdir)" || exit 1; \ - fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -813,40 +688,58 @@ uninstall-man: uninstall-man5 uninstall-man8 .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-aminfo clean-generic \ - cscopelist-am ctags-am dist-info distclean distclean-generic \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-man5 install-man8 install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-aminfo maintainer-clean-generic mostlyclean \ - mostlyclean-aminfo mostlyclean-generic pdf pdf-am ps ps-am \ - tags-am uninstall uninstall-am uninstall-dvi-am \ - uninstall-html-am uninstall-info-am uninstall-man \ - uninstall-man5 uninstall-man8 uninstall-pdf-am uninstall-ps-am + dist-info distclean distclean-generic distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-man5 install-man8 \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-aminfo \ + maintainer-clean-generic mostlyclean mostlyclean-aminfo \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-dvi-am uninstall-html-am uninstall-info-am \ + uninstall-man uninstall-man5 uninstall-man8 uninstall-pdf-am \ + uninstall-ps-am -.PRECIOUS: Makefile +# For additional rules usually of interest only to the maintainer, +# see GNUmakefile and Makefile.maint. + +sample-config.tar.gz: sample-config + GZIP=$(GZIP_ENV) $(AMTAR) chozf sample-config.tar.gz --exclude .svn sample-config texi2html: tinc.texi - $(AM_V_GEN)texi2html -split=chapter $< + texi2html -split=chapter tinc.texi tincd.8.html: tincd.8 - $(AM_V_GEN)w3mman2html $< > $@ + w3mman2html $< > $@ + +tincctl.8.html: tincctl.8 + w3mman2html $< > $@ + +tinc-gui.8.html: tinc-gui.8 + w3mman2html $< > $@ tinc.conf.5.html: tinc.conf.5 - $(AM_V_GEN)w3mman2html $< > $@ + w3mman2html $< > $@ -tincd.8: $(srcdir)/tincd.8.in - $(AM_V_GEN)$(substitute) $(srcdir)/tincd.8.in > $@ +tincd.8: tincd.8.in + $(substitute) $< > $@ -tinc.conf.5: $(srcdir)/tinc.conf.5.in - $(AM_V_GEN)$(substitute) $(srcdir)/tinc.conf.5.in > $@ +tincctl.8: tincctl.8.in + $(substitute) $< > $@ -tincinclude.texi: $(srcdir)/tincinclude.texi.in - $(AM_V_GEN)$(substitute) $(srcdir)/tincinclude.texi.in > $@ +tinc-gui.8: tinc-gui.8.in + $(substitute) $< > $@ + +tinc.conf.5: tinc.conf.5.in + $(substitute) $< > $@ + +tincinclude.texi: tincinclude.texi.in + $(substitute) $< > $@ + +tinc.texi: tincinclude.texi # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/doc/sample-config.tar.gz b/doc/sample-config.tar.gz new file mode 100644 index 0000000..3ad2d9a Binary files /dev/null and b/doc/sample-config.tar.gz differ diff --git a/doc/sample-config/hosts/alpha b/doc/sample-config/hosts/alpha deleted file mode 100644 index 0f5e56a..0000000 --- a/doc/sample-config/hosts/alpha +++ /dev/null @@ -1,15 +0,0 @@ -# Sample host configuration file - -# The real IP address of this tinc host. Can be used by other tinc hosts. -Address = 123.234.35.67 - -# Portnumber for incoming connections. Default is 655. -Port = 655 - -# Subnet on the virtual private network that is local for this host. -Subnet = 192.168.1.0/24 - -# The public key generated by `tincd -n example -K' is stored here ------BEGIN RSA PUBLIC KEY----- -... ------END RSA PUBLIC KEY----- diff --git a/doc/sample-config/hosts/beta b/doc/sample-config/hosts/beta deleted file mode 100644 index 6f70d4f..0000000 --- a/doc/sample-config/hosts/beta +++ /dev/null @@ -1,16 +0,0 @@ -# Sample host configuration file -# This file was generated by host beta. - -# The real IP address of this tinc host. Can be used by other tinc hosts. -Address = 123.45.67.189 - -# Portnumber for incoming connections. Default is 655. -Port = 6500 - -# Subnet on the virtual private network that is local for this host. -Subnet = 192.168.2.0/24 - -# The public key generated by `tincd -n example -K' is stored here ------BEGIN RSA PUBLIC KEY----- -... ------END RSA PUBLIC KEY----- diff --git a/doc/sample-config/rsa_key.priv b/doc/sample-config/rsa_key.priv deleted file mode 100644 index ac13536..0000000 --- a/doc/sample-config/rsa_key.priv +++ /dev/null @@ -1 +0,0 @@ -# Generate this file with `tincd -n example -K` diff --git a/doc/sample-config/tinc-down b/doc/sample-config/tinc-down deleted file mode 100644 index 65b049e..0000000 --- a/doc/sample-config/tinc-down +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# This file closes down the tap device. - -ifconfig $INTERFACE down diff --git a/doc/sample-config/tinc-up b/doc/sample-config/tinc-up deleted file mode 100644 index 2d8b4d6..0000000 --- a/doc/sample-config/tinc-up +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# This file sets up the tap device. -# It gives you the freedom to do anything you want with it. -# Use the correct name for the tap device: -# The environment variable $INTERFACE is set to the right name -# on most platforms, but if it doesn't work try to set it manually. - -# Give it the right ip and netmask. Remember, the subnet of the -# tap device must be larger than that of the individual Subnets -# as defined in the host configuration file! -ifconfig $INTERFACE 192.168.1.1 netmask 255.255.0.0 diff --git a/doc/sample-config/tinc.conf b/doc/sample-config/tinc.conf deleted file mode 100644 index 7081764..0000000 --- a/doc/sample-config/tinc.conf +++ /dev/null @@ -1,22 +0,0 @@ -# Sample tinc configuration file - -# This is a comment. -# Spaces and tabs are eliminated. -# The = sign isn't strictly necessary any longer, though you may want -# to leave it in as it improves readability :) -# Variable names are treated case insensitive. - -# The name of this tinc host. Required. -Name = alpha - -# The internet host to connect with. -# Comment these out to make yourself a listen-only connection -# You must use the name of another tinc host. -# May be used multiple times for redundance. -ConnectTo = beta - -# The tap device tinc will use. -# /dev/tap0 for ethertap, FreeBSD or OpenBSD -# /dev/tun0 for Solaris -# /dev/net/tun for Linux tun/tap -Device = /dev/net/tun diff --git a/doc/texinfo.tex b/doc/texinfo.tex index ac5c1d9..9140826 100644 --- a/doc/texinfo.tex +++ b/doc/texinfo.tex @@ -3,12 +3,11 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2018-02-12.17} +\def\texinfoversion{2009-08-14.15} % % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -% 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 -% Free Software Foundation, Inc. +% 2007, 2008, 2009 Free Software Foundation, Inc. % % This texinfo.tex file is free software: you can redistribute it and/or % modify it under the terms of the GNU General Public License as @@ -21,18 +20,17 @@ % General Public License for more details. % % You should have received a copy of the GNU General Public License -% along with this program. If not, see . +% along with this program. If not, see . % % As a special exception, when this file is read by TeX when processing % a Texinfo source document, you may use the result without -% restriction. This Exception is an additional permission under section 7 -% of the GNU General Public License, version 3 ("GPLv3"). +% restriction. (This has been our intent since Texinfo was invented.) % % Please try the latest version of texinfo.tex before submitting bug % reports; you can get the latest version from: -% https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or -% https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or -% https://www.gnu.org/software/texinfo/ (the Texinfo home page) +% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or +% ftp://tug.org/tex/texinfo.tex +% (and all CTAN mirrors, see http://www.ctan.org). % The texinfo.tex in any given distribution could well be out % of date, so if that's what you're using, please check. % @@ -56,7 +54,7 @@ % extent. You can get the existing language-specific files from the % full Texinfo distribution. % -% The GNU Texinfo home page is https://www.gnu.org/software/texinfo. +% The GNU Texinfo home page is http://www.gnu.org/software/texinfo. \message{Loading texinfo [version \texinfoversion]:} @@ -67,9 +65,6 @@ \everyjob{\message{[Texinfo version \texinfoversion]}% \catcode`+=\active \catcode`\_=\active} -% LaTeX's \typeout. This ensures that the messages it is used for -% are identical in format to the corresponding ones from latex/pdflatex. -\def\typeout{\immediate\write17}% \chardef\other=12 @@ -98,15 +93,14 @@ \let\ptexnewwrite\newwrite \let\ptexnoindent=\noindent \let\ptexplus=+ -\let\ptexraggedright=\raggedright \let\ptexrbrace=\} \let\ptexslash=\/ -\let\ptexsp=\sp \let\ptexstar=\* -\let\ptexsup=\sup \let\ptext=\t \let\ptextop=\top -{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode +{\catcode`\'=\active +\global\let\ptexquoteright'}% Math-mode def from plain.tex. +\let\ptexraggedright=\raggedright % If this character appears in an error message or help string, it % starts a new line in the output. @@ -124,11 +118,10 @@ % Set up fixed words for English if not already set. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi -\ifx\putworderror\undefined \gdef\putworderror{error}\fi \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi \ifx\putwordin\undefined \gdef\putwordin{in}\fi -\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi -\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi +\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi +\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi @@ -162,14 +155,20 @@ \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi -% Give the space character the catcode for a space. -\def\spaceisspace{\catcode`\ =10\relax} - -% Likewise for ^^M, the end of line character. -\def\endlineisspace{\catcode13=10\relax} +% Since the category of space is not known, we have to be careful. +\chardef\spacecat = 10 +\def\spaceisspace{\catcode`\ =\spacecat} +% sometimes characters are active, so we need control sequences. +\chardef\colonChar = `\: +\chardef\commaChar = `\, \chardef\dashChar = `\- -\chardef\slashChar = `\/ +\chardef\dotChar = `\. +\chardef\exclamChar= `\! +\chardef\lquoteChar= `\` +\chardef\questChar = `\? +\chardef\rquoteChar= `\' +\chardef\semiChar = `\; \chardef\underChar = `\_ % Ignore a token. @@ -182,7 +181,7 @@ % Hyphenation fixes. \hyphenation{ Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script - auto-ma-ti-cal-ly ap-pen-dix bit-map bit-maps + ap-pen-dix bit-map bit-maps data-base data-bases eshell fall-ing half-way long-est man-u-script man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces @@ -191,6 +190,46 @@ wide-spread wrap-around } +% Margin to add to right of even pages, to left of odd pages. +\newdimen\bindingoffset +\newdimen\normaloffset +\newdimen\pagewidth \newdimen\pageheight + +% For a final copy, take out the rectangles +% that mark overfull boxes (in case you have decided +% that the text looks ok even though it passes the margin). +% +\def\finalout{\overfullrule=0pt} + +% @| inserts a changebar to the left of the current line. It should +% surround any changed text. This approach does *not* work if the +% change spans more than two lines of output. To handle that, we would +% have adopt a much more difficult approach (putting marks into the main +% vertical list for the beginning and end of each change). +% +\def\|{% + % \vadjust can only be used in horizontal mode. + \leavevmode + % + % Append this vertical mode material after the current line in the output. + \vadjust{% + % We want to insert a rule with the height and depth of the current + % leading; that is exactly what \strutbox is supposed to record. + \vskip-\baselineskip + % + % \vadjust-items are inserted at the left edge of the type. So + % the \llap here moves out into the left-hand margin. + \llap{% + % + % For a thicker or thinner bar, change the `1pt'. + \vrule height\baselineskip width1pt + % + % This is the space between the bar and the text. + \hskip 12pt + }% + }% +} + % Sometimes it is convenient to have everything in the transcript file % and nothing on the terminal. We don't just call \tracingall here, % since that produces some useless output on the terminal. We also make @@ -207,7 +246,7 @@ \tracingmacros2 \tracingrestores1 \showboxbreadth\maxdimen \showboxdepth\maxdimen - \ifx\eTeXversion\thisisundefined\else % etex gives us more logging + \ifx\eTeXversion\undefined\else % etex gives us more logging \tracingscantokens1 \tracingifs1 \tracinggroups1 @@ -218,13 +257,6 @@ \errorcontextlines16 }% -% @errormsg{MSG}. Do the index-like expansions on MSG, but if things -% aren't perfect, it's not the end of the world, being an error message, -% after all. -% -\def\errormsg{\begingroup \indexnofonts \doerrormsg} -\def\doerrormsg#1{\errmessage{#1}} - % add check for \lastpenalty to plain's definitions. If the last thing % we did was a \nobreak, we don't want to insert more space. % @@ -235,15 +267,7 @@ \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount \removelastskip\penalty-200\bigskip\fi\fi} -% Output routine -% - -% For a final copy, take out the rectangles -% that mark overfull boxes (in case you have decided -% that the text looks ok even though it passes the margin). -% -\def\finalout{\overfullrule=0pt } - +% For @cropmarks command. % Do @cropmarks to get crop marks. % \newif\ifcropmarks @@ -266,18 +290,10 @@ % % Another complication is to let the user choose whether \thischapter % (\thissection) refers to the chapter (section) in effect at the top -% of a page, or that at the bottom of a page. - -% \domark is called twice inside \chapmacro, to add one -% mark before the section break, and one after. -% In the second call \prevchapterdefs is the same as \lastchapterdefs, -% and \prevsectiondefs is the same as \lastsectiondefs. -% Then if the page is not broken at the mark, some of the previous -% section appears on the page, and we can get the name of this section -% from \firstmark for @everyheadingmarks top. -% @everyheadingmarks bottom uses \botmark. -% -% See page 260 of The TeXbook. +% of a page, or that at the bottom of a page. The solution is +% described on page 260 of The TeXbook. It involves outputting two +% marks for the sectioning macros, one before the section break, and +% one after. I won't pretend I can describe this better than DEK... \def\domark{% \toks0=\expandafter{\lastchapterdefs}% \toks2=\expandafter{\lastsectiondefs}% @@ -285,15 +301,11 @@ \toks6=\expandafter{\prevsectiondefs}% \toks8=\expandafter{\lastcolordefs}% \mark{% - \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top - \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom - \noexpand\else \the\toks8 % 2: color marks + \the\toks0 \the\toks2 + \noexpand\or \the\toks4 \the\toks6 + \noexpand\else \the\toks8 }% } - -% \gettopheadingmarks, \getbottomheadingmarks, -% \getcolormarks - extract needed part of mark. -% % \topmark doesn't work for the very first chapter (after the title % page or the contents), so we use \firstmark there -- this gets us % the mark with the chapter defs, unless the user sneaks in, e.g., @@ -309,67 +321,33 @@ % Avoid "undefined control sequence" errors. \def\lastchapterdefs{} \def\lastsectiondefs{} -\def\lastsection{} \def\prevchapterdefs{} \def\prevsectiondefs{} \def\lastcolordefs{} -% Margin to add to right of even pages, to left of odd pages. -\newdimen\bindingoffset -\newdimen\normaloffset -\newdimen\txipagewidth \newdimen\txipageheight - % Main output routine. -% \chardef\PAGE = 255 \output = {\onepageout{\pagecontents\PAGE}} \newbox\headlinebox \newbox\footlinebox -% \onepageout takes a vbox as an argument. -% \shipout a vbox for a single page, adding an optional header, footer, -% cropmarks, and footnote. This also causes index entries for this page -% to be written to the auxiliary files. -% +% \onepageout takes a vbox as an argument. Note that \pagecontents +% does insertions, but you have to call it yourself. \def\onepageout#1{% \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi % \ifodd\pageno \advance\hoffset by \bindingoffset \else \advance\hoffset by -\bindingoffset\fi % - % Common context changes for both heading and footing. % Do this outside of the \shipout so @code etc. will be expanded in % the headline as they should be, not taken literally (outputting ''code). - \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars} - % - % Retrieve the information for the headings from the marks in the page, - % and call Plain TeX's \makeheadline and \makefootline, which use the - % values in \headline and \footline. - % - % This is used to check if we are on the first page of a chapter. - \ifcase1\topmark\fi - \let\prevchaptername\thischaptername - \ifcase0\firstmark\fi - \let\curchaptername\thischaptername - % \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi + \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi - % - \ifx\curchaptername\prevchaptername - \let\thischapterheading\thischapter - \else - % \thischapterheading is the same as \thischapter except it is blank - % for the first page of a chapter. This is to prevent the chapter name - % being shown twice. - \def\thischapterheading{}% - \fi - % - \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}% - \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}% + \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% % {% - % Set context for writing to auxiliary files like index files. % Have to do this stuff outside the \shipout because we want it to % take effect in \write's, yet the group defined by the \vbox ends % before the \shipout runs. @@ -378,10 +356,10 @@ \normalturnoffactive % \ in index entries must not stay \, e.g., if % the page break happens to be in the middle of an example. % We don't want .vr (or whatever) entries like this: - % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}} + % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} % "\acronym" won't work when it's read back in; % it needs to be - % {\code {{\backslashcurfont }acronym} + % {\code {{\tt \backslashcurfont }acronym} \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi @@ -439,8 +417,7 @@ \newinsert\margin \dimen\margin=\maxdimen -% Main part of page, including any footnotes -\def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}} +\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} {\catcode`\@ =11 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi % marginal hacks, juha@viisa.uucp (Juha Takala) @@ -462,13 +439,9 @@ \def\nsbot{\vbox {\hrule height\cornerlong depth\cornerthick width\cornerthick}} - -% Argument parsing - % Parse an argument, then pass it to #1. The argument is the rest of % the input line (except we remove a trailing comment). #1 should be a % macro which expects an ordinary undelimited TeX argument. -% For example, \def\foo{\parsearg\fooxxx}. % \def\parsearg{\parseargusing{}} \def\parseargusing#1#2{% @@ -487,11 +460,9 @@ }% } -% First remove any @comment, then any @c comment. Also remove a @texinfoc -% comment (see \scanmacro for details). Pass the result on to \argcheckspaces. +% First remove any @comment, then any @c comment. \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} -\def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm} -\def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} +\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} % Each occurrence of `\^^M' or `\^^M' is replaced by a single space. % @@ -526,13 +497,14 @@ % \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} - -% \parseargdef - define a command taking an argument on the line -% % \parseargdef\foo{...} % is roughly equivalent to % \def\foo{\parsearg\Xfoo} % \def\Xfoo#1{...} +% +% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my +% favourite TeX trick. --kasal, 16nov03 + \def\parseargdef#1{% \expandafter \doparseargdef \csname\string#1\endcsname #1% } @@ -605,7 +577,7 @@ } \def\inenvironment#1{% \ifx#1\empty - outside of any environment% + out of any environment% \else in environment \expandafter\string#1% \fi @@ -617,7 +589,7 @@ \parseargdef\end{% \if 1\csname iscond.#1\endcsname \else - % The general wording of \badenverr may not be ideal. + % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03 \expandafter\checkenv\csname#1\endcsname \csname E#1\endcsname \endgroup @@ -627,6 +599,85 @@ \newhelp\EMsimple{Press RETURN to continue.} +%% Simple single-character @ commands + +% @@ prints an @ +% Kludge this until the fonts are right (grr). +\def\@{{\tt\char64}} + +% This is turned off because it was never documented +% and you can use @w{...} around a quote to suppress ligatures. +%% Define @` and @' to be the same as ` and ' +%% but suppressing ligatures. +%\def\`{{`}} +%\def\'{{'}} + +% Used to generate quoted braces. +\def\mylbrace {{\tt\char123}} +\def\myrbrace {{\tt\char125}} +\let\{=\mylbrace +\let\}=\myrbrace +\begingroup + % Definitions to produce \{ and \} commands for indices, + % and @{ and @} for the aux/toc files. + \catcode`\{ = \other \catcode`\} = \other + \catcode`\[ = 1 \catcode`\] = 2 + \catcode`\! = 0 \catcode`\\ = \other + !gdef!lbracecmd[\{]% + !gdef!rbracecmd[\}]% + !gdef!lbraceatcmd[@{]% + !gdef!rbraceatcmd[@}]% +!endgroup + +% @comma{} to avoid , parsing problems. +\let\comma = , + +% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent +% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. +\let\, = \c +\let\dotaccent = \. +\def\ringaccent#1{{\accent23 #1}} +\let\tieaccent = \t +\let\ubaraccent = \b +\let\udotaccent = \d + +% Other special characters: @questiondown @exclamdown @ordf @ordm +% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. +\def\questiondown{?`} +\def\exclamdown{!`} +\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} +\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} + +% Dotless i and dotless j, used for accents. +\def\imacro{i} +\def\jmacro{j} +\def\dotless#1{% + \def\temp{#1}% + \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi + \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi + \else \errmessage{@dotless can be used only with i or j}% + \fi\fi +} + +% The \TeX{} logo, as in plain, but resetting the spacing so that a +% period following counts as ending a sentence. (Idea found in latex.) +% +\edef\TeX{\TeX \spacefactor=1000 } + +% @LaTeX{} logo. Not quite the same results as the definition in +% latex.ltx, since we use a different font for the raised A; it's most +% convenient for us to use an explicitly smaller font, rather than using +% the \scriptstyle font (since we don't reset \scriptstyle and +% \scriptscriptstyle). +% +\def\LaTeX{% + L\kern-.36em + {\setbox0=\hbox{T}% + \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}% + \kern-.15em + \TeX +} + % Be sure we're in horizontal mode when doing a tie, since we make space % equivalent to this in @example-like environments. Otherwise, a space % at the beginning of a line will start with \penalty -- and @@ -643,7 +694,7 @@ \def\:{\spacefactor=1000 } % @* forces a line break. -\def\*{\unskip\hfil\break\hbox{}\ignorespaces} +\def\*{\hfil\break\hbox{}\ignorespaces} % @/ allows a line break. \let\/=\allowbreak @@ -668,7 +719,7 @@ \else\ifx\temp\offword \plainnonfrenchspacing \else \errhelp = \EMsimple - \errmessage{Unknown @frenchspacing option `\temp', must be on|off}% + \errmessage{Unknown @frenchspacing option `\temp', must be on/off}% \fi\fi } @@ -722,26 +773,21 @@ \endgraf % Not \par, as it may have been set to \lisppar. \global\dimen1 = \prevdepth \egroup % End the \vtop. - \addgroupbox - \prevdepth = \dimen1 - \checkinserts -} - -\def\addgroupbox{ % \dimen0 is the vertical size of the group's box. \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox % \dimen2 is how much space is left on the page (more or less). - \dimen2 = \txipageheight \advance\dimen2 by -\pagetotal + \dimen2 = \pageheight \advance\dimen2 by -\pagetotal % if the group doesn't fit on the current page, and it's a big big % group, force a page break. \ifdim \dimen0 > \dimen2 - \ifdim \pagetotal < \vfilllimit\txipageheight + \ifdim \pagetotal < \vfilllimit\pageheight \page \fi \fi \box\groupbox + \prevdepth = \dimen1 + \checkinserts } - % % TeX puts in an \escapechar (i.e., `@') at the beginning of the help % message, so this ends up printing `@group can only ...'. @@ -755,6 +801,15 @@ where each line of input produces a line of output.} \newdimen\mil \mil=0.001in +% Old definition--didn't work. +%\parseargdef\need{\par % +%% This method tries to make TeX break the page naturally +%% if the depth of the box does not fit. +%{\baselineskip=0pt% +%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak +%\prevdepth=-1000pt +%}} + \parseargdef\need{% % Ensure vertical mode, so we don't make a big box in the middle of a % paragraph. @@ -818,7 +873,7 @@ where each line of input produces a line of output.} % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current % paragraph. For more general purposes, use the \margin insertion -% class. WHICH is `l' or `r'. Not documented, written for gawk manual. +% class. WHICH is `l' or `r'. % \newskip\inmarginspacing \inmarginspacing=1cm \def\strutdepth{\dp\strutbox} @@ -875,7 +930,6 @@ where each line of input produces a line of output.} \makevalueexpandable % we want to expand any @value in FILE. \turnoffactive % and allow special characters in the expansion \indexnofonts % Allow `@@' and other weird things in file names. - \wlog{texinfo.tex: doing @include of #1^^J}% \edef\temp{\noexpand\input #1 }% % % This trickery is to read FILE outside of a group, in case it makes @@ -911,7 +965,7 @@ where each line of input produces a line of output.} \def\popthisfilestack{\errthisfilestackempty} \def\errthisfilestackempty{\errmessage{Internal error: the stack of filenames is empty.}} -% + \def\thisfile{} % @center line @@ -919,48 +973,37 @@ where each line of input produces a line of output.} % \parseargdef\center{% \ifhmode - \let\centersub\centerH + \let\next\centerH \else - \let\centersub\centerV + \let\next\centerV \fi - \centersub{\hfil \ignorespaces#1\unskip \hfil}% - \let\centersub\relax % don't let the definition persist, just in case + \next{\hfil \ignorespaces#1\unskip \hfil}% } -\def\centerH#1{{% - \hfil\break - \advance\hsize by -\leftskip - \advance\hsize by -\rightskip - \line{#1}% - \break -}} -% -\newcount\centerpenalty -\def\centerV#1{% - % The idea here is the same as in \startdefun, \cartouche, etc.: if - % @center is the first thing after a section heading, we need to wipe - % out the negative parskip inserted by \sectionheading, but still - % prevent a page break here. - \centerpenalty = \lastpenalty - \ifnum\centerpenalty>10000 \vskip\parskip \fi - \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi - \line{\kern\leftskip #1\kern\rightskip}% +\def\centerH#1{% + {% + \hfil\break + \advance\hsize by -\leftskip + \advance\hsize by -\rightskip + \line{#1}% + \break + }% } +\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}} % @sp n outputs n lines of vertical space -% + \parseargdef\sp{\vskip #1\baselineskip} % @comment ...line which is ignored... % @c is the same as @comment % @ignore ... @end ignore is another way to write a comment - -\def\c{\begingroup \catcode`\^^M=\active% +\def\comment{\begingroup \catcode`\^^M=\other% \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% -\cxxx} -{\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}} -% -\let\comment\c +\commentxxx} +{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} + +\let\c=\comment % @paragraphindent NCHARS % We'll use ems for NCHARS, close enough. @@ -1031,23 +1074,172 @@ where each line of input produces a line of output.} % paragraph. % \gdef\dosuppressfirstparagraphindent{% - \gdef\indent {\restorefirstparagraphindent \indent}% - \gdef\noindent{\restorefirstparagraphindent \noindent}% - \global\everypar = {\kern -\parindent \restorefirstparagraphindent}% -} -% -\gdef\restorefirstparagraphindent{% - \global\let\indent = \ptexindent - \global\let\noindent = \ptexnoindent - \global\everypar = {}% + \gdef\indent{% + \restorefirstparagraphindent + \indent + }% + \gdef\noindent{% + \restorefirstparagraphindent + \noindent + }% + \global\everypar = {% + \kern -\parindent + \restorefirstparagraphindent + }% } +\gdef\restorefirstparagraphindent{% + \global \let \indent = \ptexindent + \global \let \noindent = \ptexnoindent + \global \everypar = {}% +} + + +% @asis just yields its argument. Used with @table, for example. +% +\def\asis#1{#1} + +% @math outputs its argument in math mode. +% +% One complication: _ usually means subscripts, but it could also mean +% an actual _ character, as in @math{@var{some_variable} + 1}. So make +% _ active, and distinguish by seeing if the current family is \slfam, +% which is what @var uses. +{ + \catcode`\_ = \active + \gdef\mathunderscore{% + \catcode`\_=\active + \def_{\ifnum\fam=\slfam \_\else\sb\fi}% + } +} +% Another complication: we want \\ (and @\) to output a \ character. +% FYI, plain.tex uses \\ as a temporary control sequence (why?), but +% this is not advertised and we don't care. Texinfo does not +% otherwise define @\. +% +% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. +\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} +% +\def\math{% + \tex + \mathunderscore + \let\\ = \mathbackslash + \mathactive + % make the texinfo accent commands work in math mode + \let\"=\ddot + \let\'=\acute + \let\==\bar + \let\^=\hat + \let\`=\grave + \let\u=\breve + \let\v=\check + \let\~=\tilde + \let\dotaccent=\dot + $\finishmath +} +\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. + +% Some active characters (such as <) are spaced differently in math. +% We have to reset their definitions in case the @math was an argument +% to a command which sets the catcodes (such as @item or @section). +% +{ + \catcode`^ = \active + \catcode`< = \active + \catcode`> = \active + \catcode`+ = \active + \catcode`' = \active + \gdef\mathactive{% + \let^ = \ptexhat + \let< = \ptexless + \let> = \ptexgtr + \let+ = \ptexplus + \let' = \ptexquoteright + } +} + +% Some math mode symbols. +\def\bullet{$\ptexbullet$} +\def\geq{\ifmmode \ge\else $\ge$\fi} +\def\leq{\ifmmode \le\else $\le$\fi} +\def\minus{\ifmmode -\else $-$\fi} + +% @dots{} outputs an ellipsis using the current font. +% We do .5em per period so that it has the same spacing in the cm +% typewriter fonts as three actual period characters; on the other hand, +% in other typewriter fonts three periods are wider than 1.5em. So do +% whichever is larger. +% +\def\dots{% + \leavevmode + \setbox0=\hbox{...}% get width of three periods + \ifdim\wd0 > 1.5em + \dimen0 = \wd0 + \else + \dimen0 = 1.5em + \fi + \hbox to \dimen0{% + \hskip 0pt plus.25fil + .\hskip 0pt plus1fil + .\hskip 0pt plus1fil + .\hskip 0pt plus.5fil + }% +} + +% @enddots{} is an end-of-sentence ellipsis. +% +\def\enddots{% + \dots + \spacefactor=\endofsentencespacefactor +} + +% @comma{} is so commas can be inserted into text without messing up +% Texinfo's parsing. +% +\let\comma = , % @refill is a no-op. \let\refill=\relax -% @setfilename INFO-FILENAME - ignored -\let\setfilename=\comment +% If working on a large document in chapters, it is convenient to +% be able to disable indexing, cross-referencing, and contents, for test runs. +% This is done with @novalidate (before @setfilename). +% +\newif\iflinks \linkstrue % by default we want the aux files. +\let\novalidate = \linksfalse + +% @setfilename is done at the beginning of every texinfo file. +% So open here the files we need to have open while reading the input. +% This makes it possible to make a .fmt file for texinfo. +\def\setfilename{% + \fixbackslash % Turn off hack to swallow `\input texinfo'. + \iflinks + \tryauxfile + % Open the new aux file. TeX will close it automatically at exit. + \immediate\openout\auxfile=\jobname.aux + \fi % \openindices needs to do some work in any case. + \openindices + \let\setfilename=\comment % Ignore extra @setfilename cmds. + % + % If texinfo.cnf is present on the system, read it. + % Useful for site-wide @afourpaper, etc. + \openin 1 texinfo.cnf + \ifeof 1 \else \input texinfo.cnf \fi + \closein 1 + % + \comment % Ignore the actual filename. +} + +% Called from \setfilename. +% +\def\openindices{% + \newindex{cp}% + \newcodeindex{fn}% + \newcodeindex{vr}% + \newcodeindex{tp}% + \newcodeindex{ky}% + \newcodeindex{pg}% +} % @bye. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} @@ -1065,94 +1257,14 @@ where each line of input produces a line of output.} \newtoks\toksC \newtoks\toksD \newbox\boxA -\newbox\boxB \newcount\countA \newif\ifpdf \newif\ifpdfmakepagedest -% -% For LuaTeX -% - -\newif\iftxiuseunicodedestname -\txiuseunicodedestnamefalse % For pdfTeX etc. - -\ifx\luatexversion\thisisundefined -\else - % Use Unicode destination names - \txiuseunicodedestnametrue - % Escape PDF strings with converting UTF-16 from UTF-8 - \begingroup - \catcode`\%=12 - \directlua{ - function UTF16oct(str) - tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377') - for c in string.utfvalues(str) do - if c < 0x10000 then - tex.sprint( - string.format(string.char(0x5c) .. string.char(0x25) .. '03o' .. - string.char(0x5c) .. string.char(0x25) .. '03o', - (c / 256), (c % 256))) - else - c = c - 0x10000 - local c_hi = c / 1024 + 0xd800 - local c_lo = c % 1024 + 0xdc00 - tex.sprint( - string.format(string.char(0x5c) .. string.char(0x25) .. '03o' .. - string.char(0x5c) .. string.char(0x25) .. '03o' .. - string.char(0x5c) .. string.char(0x25) .. '03o' .. - string.char(0x5c) .. string.char(0x25) .. '03o', - (c_hi / 256), (c_hi % 256), - (c_lo / 256), (c_lo % 256))) - end - end - end - } - \endgroup - \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}} - % Escape PDF strings without converting - \begingroup - \directlua{ - function PDFescstr(str) - for c in string.bytes(str) do - if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then - tex.sprint( - string.format(string.char(0x5c) .. string.char(0x25) .. '03o', - c)) - else - tex.sprint(string.char(c)) - end - end - end - } - \endgroup - \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}} - \ifnum\luatexversion>84 - % For LuaTeX >= 0.85 - \def\pdfdest{\pdfextension dest} - \let\pdfoutput\outputmode - \def\pdfliteral{\pdfextension literal} - \def\pdfcatalog{\pdfextension catalog} - \def\pdftexversion{\numexpr\pdffeedback version\relax} - \let\pdfximage\saveimageresource - \let\pdfrefximage\useimageresource - \let\pdflastximage\lastsavedimageresourceindex - \def\pdfendlink{\pdfextension endlink\relax} - \def\pdfoutline{\pdfextension outline} - \def\pdfstartlink{\pdfextension startlink} - \def\pdffontattr{\pdfextension fontattr} - \def\pdfobj{\pdfextension obj} - \def\pdflastobj{\numexpr\pdffeedback lastobj\relax} - \let\pdfpagewidth\pagewidth - \let\pdfpageheight\pageheight - \edef\pdfhorigin{\pdfvariable horigin} - \edef\pdfvorigin{\pdfvariable vorigin} - \fi -\fi - % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 -% can be set). So we test for \relax and 0 as well as being undefined. -\ifx\pdfoutput\thisisundefined +% can be set). So we test for \relax and 0 as well as \undefined, +% borrowed from ifpdf.sty. +\ifx\pdfoutput\undefined \else \ifx\pdfoutput\relax \else @@ -1167,33 +1279,50 @@ where each line of input produces a line of output.} % for display in the outlines, and in other places. Thus, we have to % double any backslashes. Otherwise, a name like "\node" will be % interpreted as a newline (\n), followed by o, d, e. Not good. -% -% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and -% related messages. The final outcome is that it is up to the TeX user -% to double the backslashes and otherwise make the string valid, so -% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to -% do this reliably, so we use it. +% http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html +% (and related messages, the final outcome is that it is up to the TeX +% user to double the backslashes and otherwise make the string valid, so +% that's what we do). -% #1 is a control sequence in which to do the replacements, -% which we \xdef. -\def\txiescapepdf#1{% - \ifx\pdfescapestring\thisisundefined - % No primitive available; should we give a warning or log? - % Many times it won't matter. - \xdef#1{#1}% - \else - % The expandable \pdfescapestring primitive escapes parentheses, - % backslashes, and other special chars. - \xdef#1{\pdfescapestring{#1}}% - \fi +% double active backslashes. +% +{\catcode`\@=0 \catcode`\\=\active + @gdef@activebackslashdouble{% + @catcode`@\=@active + @let\=@doublebackslash} } -\def\txiescapepdfutfsixteen#1{% - \ifx\pdfescapestrutfsixteen\thisisundefined - % No UTF-16 converting macro available. - \txiescapepdf{#1}% - \else - \xdef#1{\pdfescapestrutfsixteen{#1}}% - \fi + +% To handle parens, we must adopt a different approach, since parens are +% not active characters. hyperref.dtx (which has the same problem as +% us) handles it with this amazing macro to replace tokens, with minor +% changes for Texinfo. It is included here under the GPL by permission +% from the author, Heiko Oberdiek. +% +% #1 is the tokens to replace. +% #2 is the replacement. +% #3 is the control sequence with the string. +% +\def\HyPsdSubst#1#2#3{% + \def\HyPsdReplace##1#1##2\END{% + ##1% + \ifx\\##2\\% + \else + #2% + \HyReturnAfterFi{% + \HyPsdReplace##2\END + }% + \fi + }% + \xdef#3{\expandafter\HyPsdReplace#3#1\END}% +} +\long\def\HyReturnAfterFi#1\fi{\fi#1} + +% #1 is a control sequence in which to do the replacements. +\def\backslashparens#1{% + \xdef#1{#1}% redefine it as its expansion; the definition is simply + % \lastnode when called from \setref -> \pdfmkdest. + \HyPsdSubst{(}{\realbackslash(}{#1}% + \HyPsdSubst{)}{\realbackslash)}{#1}% } \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images @@ -1203,17 +1332,15 @@ output) for that.)} \ifpdf % - % Color manipulation macros using ideas from pdfcolor.tex, + % Color manipulation macros based on pdfcolor.tex, % except using rgb instead of cmyk; the latter is said to render as a % very dark gray on-screen and a very dark halftone in print, instead - % of actual black. The dark red here is dark enough to print on paper as - % nearly black, but still distinguishable for online viewing. We use - % black by default, though. + % of actual black. \def\rgbDarkRed{0.50 0.09 0.12} \def\rgbBlack{0 0 0} % - % rg sets the color for filling (usual text, etc.); - % RG sets the color for stroking (thin rules, e.g., normal _'s). + % k sets the color for filling (usual text, etc.); + % K sets the color for stroking (thin rules, e.g., normal _'s). \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} % % Set color, and create a mark which defines \thiscolor accordingly, @@ -1254,34 +1381,32 @@ output) for that.)} % % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). \def\dopdfimage#1#2#3{% - \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% - \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% + \def\imagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% + \def\imageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% % - % pdftex (and the PDF format) support .pdf, .png, .jpg (among - % others). Let's try in that order, PDF first since if - % someone has a scalable image, presumably better to use that than a - % bitmap. + % pdftex (and the PDF format) support .png, .jpg, .pdf (among + % others). Let's try in that order. \let\pdfimgext=\empty \begingroup - \openin 1 #1.pdf \ifeof 1 - \openin 1 #1.PDF \ifeof 1 - \openin 1 #1.png \ifeof 1 - \openin 1 #1.jpg \ifeof 1 - \openin 1 #1.jpeg \ifeof 1 - \openin 1 #1.JPG \ifeof 1 + \openin 1 #1.png \ifeof 1 + \openin 1 #1.jpg \ifeof 1 + \openin 1 #1.jpeg \ifeof 1 + \openin 1 #1.JPG \ifeof 1 + \openin 1 #1.pdf \ifeof 1 + \openin 1 #1.PDF \ifeof 1 \errhelp = \nopdfimagehelp \errmessage{Could not find image file #1 for pdf}% - \else \gdef\pdfimgext{JPG}% + \else \gdef\pdfimgext{PDF}% \fi - \else \gdef\pdfimgext{jpeg}% + \else \gdef\pdfimgext{pdf}% \fi - \else \gdef\pdfimgext{jpg}% + \else \gdef\pdfimgext{JPG}% \fi - \else \gdef\pdfimgext{png}% + \else \gdef\pdfimgext{jpeg}% \fi - \else \gdef\pdfimgext{PDF}% + \else \gdef\pdfimgext{jpg}% \fi - \else \gdef\pdfimgext{pdf}% + \else \gdef\pdfimgext{png}% \fi \closein 1 \endgroup @@ -1293,8 +1418,8 @@ output) for that.)} \else \immediate\pdfximage \fi - \ifdim \wd0 >0pt width \pdfimagewidth \fi - \ifdim \wd2 >0pt height \pdfimageheight \fi + \ifdim \wd0 >0pt width \imagewidth \fi + \ifdim \wd2 >0pt height \imageheight \fi \ifnum\pdftexversion<13 #1.\pdfimgext \else @@ -1304,83 +1429,25 @@ output) for that.)} \pdfrefximage \pdflastximage \fi} % - \def\setpdfdestname#1{{% + \def\pdfmkdest#1{{% % We have to set dummies so commands such as @code, and characters % such as \, aren't expanded when present in a section title. \indexnofonts - \makevalueexpandable \turnoffactive - \iftxiuseunicodedestname - \ifx \declaredencoding \latone - % Pass through Latin-1 characters. - % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode. - \else - \ifx \declaredencoding \utfeight - % Pass through Unicode characters. - \else - % Use ASCII approximations in destination names. - \passthroughcharsfalse - \fi - \fi - \else - % Use ASCII approximations in destination names. - \passthroughcharsfalse - \fi + \activebackslashdouble + \makevalueexpandable \def\pdfdestname{#1}% - \txiescapepdf\pdfdestname - }} - % - \def\setpdfoutlinetext#1{{% - \indexnofonts - \makevalueexpandable - \turnoffactive - \ifx \declaredencoding \latone - % The PDF format can use an extended form of Latin-1 in bookmark - % strings. See Appendix D of the PDF Reference, Sixth Edition, for - % the "PDFDocEncoding". - \passthroughcharstrue - % Pass through Latin-1 characters. - % LuaTeX: Convert to Unicode - % pdfTeX: Use Latin-1 as PDFDocEncoding - \def\pdfoutlinetext{#1}% - \else - \ifx \declaredencoding \utfeight - \ifx\luatexversion\thisisundefined - % For pdfTeX with UTF-8. - % TODO: the PDF format can use UTF-16 in bookmark strings, - % but the code for this isn't done yet. - % Use ASCII approximations. - \passthroughcharsfalse - \def\pdfoutlinetext{#1}% - \else - % For LuaTeX with UTF-8. - % Pass through Unicode characters for title texts. - \passthroughcharstrue - \def\pdfoutlinetext{#1}% - \fi - \else - % For non-Latin-1 or non-UTF-8 encodings. - % Use ASCII approximations. - \passthroughcharsfalse - \def\pdfoutlinetext{#1}% - \fi - \fi - % LuaTeX: Convert to UTF-16 - % pdfTeX: Use Latin-1 as PDFDocEncoding - \txiescapepdfutfsixteen\pdfoutlinetext - }} - % - \def\pdfmkdest#1{% - \setpdfdestname{#1}% + \backslashparens\pdfdestname \safewhatsit{\pdfdest name{\pdfdestname} xyz}% - } + }} % % used to mark target names; must be expandable. \def\pdfmkpgn#1{#1} % - % by default, use black for everything. - \def\urlcolor{\rgbBlack} - \def\linkcolor{\rgbBlack} + % by default, use a color that is dark enough to print on paper as + % nearly black, but still distinguishable for online viewing. + \def\urlcolor{\rgbDarkRed} + \def\linkcolor{\rgbDarkRed} \def\endlink{\setcolor{\maincolor}\pdfendlink} % % Adding outlines to PDF; macros for calculating structure of outlines @@ -1402,19 +1469,29 @@ output) for that.)} % page number. We could generate a destination for the section % text in the case where a section has no node, but it doesn't % seem worth the trouble, since most documents are normally structured. - \setpdfoutlinetext{#1} - \setpdfdestname{#3} - \ifx\pdfdestname\empty - \def\pdfdestname{#4}% + \def\pdfoutlinedest{#3}% + \ifx\pdfoutlinedest\empty + \def\pdfoutlinedest{#4}% + \else + % Doubled backslashes in the name. + {\activebackslashdouble \xdef\pdfoutlinedest{#3}% + \backslashparens\pdfoutlinedest}% \fi % - \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}% + % Also double the backslashes in the display string. + {\activebackslashdouble \xdef\pdfoutlinetext{#1}% + \backslashparens\pdfoutlinetext}% + % + \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}% } % \def\pdfmakeoutlines{% \begingroup + % Thanh's hack / proper braces in bookmarks + \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace + \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace + % % Read toc silently, to get counts of subentries for \pdfoutline. - \def\partentry##1##2##3##4{}% ignore parts in the outlines \def\numchapentry##1##2##3##4{% \def\thischapnum{##2}% \def\thissecnum{0}% @@ -1468,41 +1545,25 @@ output) for that.)} % Latin 2 (0xea) gets translated to a | character. Info from % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. % - % TODO this right, we have to translate 8-bit characters to - % their "best" equivalent, based on the @documentencoding. Too - % much work for too little return. Just use the ASCII equivalents - % we use for the index sort strings. - % + % xx to do this right, we have to translate 8-bit characters to + % their "best" equivalent, based on the @documentencoding. Right + % now, I guess we'll just let the pdf reader have its way. \indexnofonts \setupdatafile - % We can have normal brace characters in the PDF outlines, unlike - % Texinfo index files. So set that up. - \def\{{\lbracecharliteral}% - \def\}{\rbracecharliteral}% \catcode`\\=\active \otherbackslash \input \tocreadfilename \endgroup } - {\catcode`[=1 \catcode`]=2 - \catcode`{=\other \catcode`}=\other - \gdef\lbracecharliteral[{]% - \gdef\rbracecharliteral[}]% - ] % \def\skipspaces#1{\def\PP{#1}\def\D{|}% \ifx\PP\D\let\nextsp\relax \else\let\nextsp\skipspaces - \addtokens{\filename}{\PP}% - \advance\filenamelength by 1 + \ifx\p\space\else\addtokens{\filename}{\PP}% + \advance\filenamelength by 1 + \fi \fi \nextsp} - \def\getfilename#1{% - \filenamelength=0 - % If we don't expand the argument now, \skipspaces will get - % snagged on things like "@value{foo}". - \edef\temp{#1}% - \expandafter\skipspaces\temp|\relax - } + \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} \ifnum\pdftexversion < 14 \let \startlink \pdfannotlink \else @@ -1563,298 +1624,45 @@ output) for that.)} \let\pdfmakeoutlines = \relax \fi % \ifx\pdfoutput -% -% For XeTeX -% -\ifx\XeTeXrevision\thisisundefined -\else - % - % XeTeX version check - % - \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1 - % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307. - % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941). - % For avoiding PDF destination name replacement, we use this special - % instead of xdvipdfmx's command line option `-C 0x0010'. - \special{dvipdfmx:config C 0x0010} - % XeTeX 0.99995+ comes with xdvipdfmx 20160307+. - % It can handle Unicode destination names for PDF. - \txiuseunicodedestnametrue - \else - % XeTeX < 0.99996 (TeX Live < 2016) cannot use the - % `dvipdfmx:config' special. - % So for avoiding PDF destination name replacement, - % xdvipdfmx's command line option `-C 0x0010' is necessary. - % - % XeTeX < 0.99995 can not handle Unicode destination names for PDF - % because xdvipdfmx 20150315 has a UTF-16 conversion issue. - % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753). - \txiuseunicodedestnamefalse - \fi - % - % Color support - % - \def\rgbDarkRed{0.50 0.09 0.12} - \def\rgbBlack{0 0 0} - % - \def\pdfsetcolor#1{\special{pdf:scolor [#1]}} - % - % Set color, and create a mark which defines \thiscolor accordingly, - % so that \makeheadline knows which color to restore. - \def\setcolor#1{% - \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% - \domark - \pdfsetcolor{#1}% - } - % - \def\maincolor{\rgbBlack} - \pdfsetcolor{\maincolor} - \edef\thiscolor{\maincolor} - \def\lastcolordefs{} - % - \def\makefootline{% - \baselineskip24pt - \line{\pdfsetcolor{\maincolor}\the\footline}% - } - % - \def\makeheadline{% - \vbox to 0pt{% - \vskip-22.5pt - \line{% - \vbox to8.5pt{}% - % Extract \thiscolor definition from the marks. - \getcolormarks - % Typeset the headline with \maincolor, then restore the color. - \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% - }% - \vss - }% - \nointerlineskip - } - % - % PDF outline support - % - % Emulate pdfTeX primitive - \def\pdfdest name#1 xyz{% - \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}% - } - % - \def\setpdfdestname#1{{% - % We have to set dummies so commands such as @code, and characters - % such as \, aren't expanded when present in a section title. - \indexnofonts - \makevalueexpandable - \turnoffactive - \iftxiuseunicodedestname - % Pass through Unicode characters. - \else - % Use ASCII approximations in destination names. - \passthroughcharsfalse - \fi - \def\pdfdestname{#1}% - \txiescapepdf\pdfdestname - }} - % - \def\setpdfoutlinetext#1{{% - \turnoffactive - % Always use Unicode characters in title texts. - \def\pdfoutlinetext{#1}% - % For XeTeX, xdvipdfmx converts to UTF-16. - % So we do not convert. - \txiescapepdf\pdfoutlinetext - }} - % - \def\pdfmkdest#1{% - \setpdfdestname{#1}% - \safewhatsit{\pdfdest name{\pdfdestname} xyz}% - } - % - % by default, use black for everything. - \def\urlcolor{\rgbBlack} - \def\linkcolor{\rgbBlack} - \def\endlink{\setcolor{\maincolor}\pdfendlink} - % - \def\dopdfoutline#1#2#3#4{% - \setpdfoutlinetext{#1} - \setpdfdestname{#3} - \ifx\pdfdestname\empty - \def\pdfdestname{#4}% - \fi - % - \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A - << /S /GoTo /D (\pdfdestname) >> >> }% - } - % - \def\pdfmakeoutlines{% - \begingroup - % - % For XeTeX, counts of subentries are not necessary. - % Therefore, we read toc only once. - % - % We use node names as destinations. - \def\partentry##1##2##3##4{}% ignore parts in the outlines - \def\numchapentry##1##2##3##4{% - \dopdfoutline{##1}{1}{##3}{##4}}% - \def\numsecentry##1##2##3##4{% - \dopdfoutline{##1}{2}{##3}{##4}}% - \def\numsubsecentry##1##2##3##4{% - \dopdfoutline{##1}{3}{##3}{##4}}% - \def\numsubsubsecentry##1##2##3##4{% - \dopdfoutline{##1}{4}{##3}{##4}}% - % - \let\appentry\numchapentry% - \let\appsecentry\numsecentry% - \let\appsubsecentry\numsubsecentry% - \let\appsubsubsecentry\numsubsubsecentry% - \let\unnchapentry\numchapentry% - \let\unnsecentry\numsecentry% - \let\unnsubsecentry\numsubsecentry% - \let\unnsubsubsecentry\numsubsubsecentry% - % - % For XeTeX, xdvipdfmx converts strings to UTF-16. - % Therefore, the encoding and the language may not be considered. - % - \indexnofonts - \setupdatafile - % We can have normal brace characters in the PDF outlines, unlike - % Texinfo index files. So set that up. - \def\{{\lbracecharliteral}% - \def\}{\rbracecharliteral}% - \catcode`\\=\active \otherbackslash - \input \tocreadfilename - \endgroup - } - {\catcode`[=1 \catcode`]=2 - \catcode`{=\other \catcode`}=\other - \gdef\lbracecharliteral[{]% - \gdef\rbracecharliteral[}]% - ] - \special{pdf:docview << /PageMode /UseOutlines >> } - % ``\special{pdf:tounicode ...}'' is not necessary - % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it. - % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315, - % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings. - % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753). -% - \def\skipspaces#1{\def\PP{#1}\def\D{|}% - \ifx\PP\D\let\nextsp\relax - \else\let\nextsp\skipspaces - \addtokens{\filename}{\PP}% - \advance\filenamelength by 1 - \fi - \nextsp} - \def\getfilename#1{% - \filenamelength=0 - % If we don't expand the argument now, \skipspaces will get - % snagged on things like "@value{foo}". - \edef\temp{#1}% - \expandafter\skipspaces\temp|\relax - } - % make a live url in pdf output. - \def\pdfurl#1{% - \begingroup - % it seems we really need yet another set of dummies; have not - % tried to figure out what each command should do in the context - % of @url. for now, just make @/ a no-op, that's the only one - % people have actually reported a problem with. - % - \normalturnoffactive - \def\@{@}% - \let\/=\empty - \makevalueexpandable - % do we want to go so far as to use \indexnofonts instead of just - % special-casing \var here? - \def\var##1{##1}% - % - \leavevmode\setcolor{\urlcolor}% - \special{pdf:bann << /Border [0 0 0] - /Subtype /Link /A << /S /URI /URI (#1) >> >>}% - \endgroup} - \def\endlink{\setcolor{\maincolor}\special{pdf:eann}} - \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} - \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} - \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} - \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} - \def\maketoks{% - \expandafter\poptoks\the\toksA|ENDTOKS|\relax - \ifx\first0\adn0 - \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 - \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 - \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 - \else - \ifnum0=\countA\else\makelink\fi - \ifx\first.\let\next=\done\else - \let\next=\maketoks - \addtokens{\toksB}{\the\toksD} - \ifx\first,\addtokens{\toksB}{\space}\fi - \fi - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi - \next} - \def\makelink{\addtokens{\toksB}% - {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} - \def\pdflink#1{% - \special{pdf:bann << /Border [0 0 0] - /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}% - \setcolor{\linkcolor}#1\endlink} - \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} -% - % - % @image support - % - % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). - \def\doxeteximage#1#2#3{% - \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% - \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% - % - % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among - % others). Let's try in that order, PDF first since if - % someone has a scalable image, presumably better to use that than a - % bitmap. - \let\xeteximgext=\empty - \begingroup - \openin 1 #1.pdf \ifeof 1 - \openin 1 #1.PDF \ifeof 1 - \openin 1 #1.png \ifeof 1 - \openin 1 #1.jpg \ifeof 1 - \openin 1 #1.jpeg \ifeof 1 - \openin 1 #1.JPG \ifeof 1 - \errmessage{Could not find image file #1 for XeTeX}% - \else \gdef\xeteximgext{JPG}% - \fi - \else \gdef\xeteximgext{jpeg}% - \fi - \else \gdef\xeteximgext{jpg}% - \fi - \else \gdef\xeteximgext{png}% - \fi - \else \gdef\xeteximgext{PDF}% - \fi - \else \gdef\xeteximgext{pdf}% - \fi - \closein 1 - \endgroup - % - \def\xetexpdfext{pdf}% - \ifx\xeteximgext\xetexpdfext - \XeTeXpdffile "#1".\xeteximgext "" - \else - \def\xetexpdfext{PDF}% - \ifx\xeteximgext\xetexpdfext - \XeTeXpdffile "#1".\xeteximgext "" - \else - \XeTeXpicfile "#1".\xeteximgext "" - \fi - \fi - \ifdim \wd0 >0pt width \xeteximagewidth \fi - \ifdim \wd2 >0pt height \xeteximageheight \fi \relax - } -\fi - - -% \message{fonts,} +% Change the current font style to #1, remembering it in \curfontstyle. +% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in +% italics, not bold italics. +% +\def\setfontstyle#1{% + \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. + \csname ten#1\endcsname % change the current font +} + +% Select #1 fonts with the current style. +% +\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} + +\def\rm{\fam=0 \setfontstyle{rm}} +\def\it{\fam=\itfam \setfontstyle{it}} +\def\sl{\fam=\slfam \setfontstyle{sl}} +\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} +\def\tt{\fam=\ttfam \setfontstyle{tt}} + +% Unfortunately, we have to override this for titles and the like, since +% in those cases "rm" is bold. Sigh. +\def\rmisbold{\rm\def\curfontstyle{bf}} + +% Texinfo sort of supports the sans serif font style, which plain TeX does not. +% So we set up a \sf. +\newfam\sffam +\def\sf{\fam=\sffam \setfontstyle{sf}} +\let\li = \sf % Sometimes we call it \li, not \sf. + +% We don't need math for this font style. +\def\ttsl{\setfontstyle{ttsl}} + + +% Default leading. +\newdimen\textleading \textleading = 13.2pt + % Set the baselineskip to #1, and the lineskip and strut size % correspondingly. There is no deep meaning behind these magic numbers % used as factors; they just match (closely enough) what Knuth defined. @@ -1866,7 +1674,6 @@ output) for that.)} % can get a sort of poor man's double spacing by redefining this. \def\baselinefactor{1} % -\newdimen\textleading \def\setleading#1{% \dimen0 = #1\relax \normalbaselineskip = \baselinefactor\dimen0 @@ -1888,7 +1695,7 @@ output) for that.)} % if we are producing pdf, and we have \pdffontattr, then define cmaps. % (\pdffontattr was introduced many years ago, but people still run % older pdftex's; it's easy to conditionalize, so we do.) -\ifpdf \ifx\pdffontattr\thisisundefined \else +\ifpdf \ifx\pdffontattr\undefined \else \begingroup \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap @@ -2139,34 +1946,28 @@ end \fi\fi -% Set the font macro #1 to the font named \fontprefix#2. +% Set the font macro #1 to the font named #2, adding on the +% specified font prefix (normally `cm'). % #3 is the font's design size, #4 is a scale factor, #5 is the CMap -% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit). -% Example: -% #1 = \textrm -% #2 = \rmshape -% #3 = 10 -% #4 = \mainmagstep -% #5 = OT1 -% +% encoding (currently only OT1, OT1IT and OT1TT are allowed, pass +% empty to omit). \def\setfont#1#2#3#4#5{% \font#1=\fontprefix#2#3 scaled #4 \csname cmap#5\endcsname#1% } % This is what gets called when #5 of \setfont is empty. \let\cmap\gobble -% -% (end of cmaps) +% emacs-page end of cmaps % Use cm as the default font prefix. % To specify the font prefix, you must define \fontprefix % before you read in texinfo.tex. -\ifx\fontprefix\thisisundefined +\ifx\fontprefix\undefined \def\fontprefix{cm} \fi % Support font families that don't use the same naming scheme as CM. \def\rmshape{r} -\def\rmbshape{bx} % where the normal face is bold +\def\rmbshape{bx} %where the normal face is bold \def\bfshape{b} \def\bxshape{bx} \def\ttshape{tt} @@ -2181,7 +1982,8 @@ end \def\scshape{csc} \def\scbshape{csc} -% Definitions for a main text size of 11pt. (The default in Texinfo.) +% Definitions for a main text size of 11pt. This is the default in +% Texinfo. % \def\definetextfontsizexi{% % Text fonts (11.2pt, magstep1). @@ -2202,10 +2004,8 @@ end % A few fonts for @defun names and args. \setfont\defbf\bfshape{10}{\magstep1}{OT1} \setfont\deftt\ttshape{10}{\magstep1}{OT1TT} -\setfont\defsl\slshape{10}{\magstep1}{OT1TT} \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} -\def\df{\let\ttfont=\deftt \let\bffont = \defbf -\let\ttslfont=\defttsl \let\slfont=\defsl \bf} +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} % Fonts for indices, footnotes, small examples (9pt). \def\smallnominalsize{9pt} @@ -2235,20 +2035,6 @@ end \font\smallersy=cmsy8 \def\smallerecsize{0800} -% Fonts for math mode superscripts (7pt). -\def\sevennominalsize{7pt} -\setfont\sevenrm\rmshape{7}{1000}{OT1} -\setfont\seventt\ttshape{10}{700}{OT1TT} -\setfont\sevenbf\bfshape{10}{700}{OT1} -\setfont\sevenit\itshape{7}{1000}{OT1IT} -\setfont\sevensl\slshape{10}{700}{OT1} -\setfont\sevensf\sfshape{10}{700}{OT1} -\setfont\sevensc\scshape{10}{700}{OT1} -\setfont\seventtsl\ttslshape{10}{700}{OT1TT} -\font\seveni=cmmi7 -\font\sevensy=cmsy7 -\def\sevenecsize{0700} - % Fonts for title page (20.4pt): \def\titlenominalsize{20pt} \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} @@ -2280,7 +2066,6 @@ end % Section fonts (14.4pt). \def\secnominalsize{14pt} \setfont\secrm\rmbshape{12}{\magstep1}{OT1} -\setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1} \setfont\secit\itbshape{10}{\magstep2}{OT1IT} \setfont\secsl\slbshape{10}{\magstep2}{OT1} \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} @@ -2306,7 +2091,7 @@ end \font\ssecsy=cmsy10 scaled 1315 \def\ssececsize{1200} -% Reduced fonts for @acronym in text (10pt). +% Reduced fonts for @acro in text (10pt). \def\reducednominalsize{10pt} \setfont\reducedrm\rmshape{10}{1000}{OT1} \setfont\reducedtt\ttshape{10}{1000}{OT1TT} @@ -2320,10 +2105,10 @@ end \font\reducedsy=cmsy10 \def\reducedecsize{1000} -\textleading = 13.2pt % line spacing for 11pt CM -\textfonts % reset the current fonts +% reset the current fonts +\textfonts \rm -} % end of 11pt text font size definitions, \definetextfontsizexi +} % end of 11pt text font size definitions % Definitions to make the main text be 10pt Computer Modern, with @@ -2350,10 +2135,8 @@ end % A few fonts for @defun names and args. \setfont\defbf\bfshape{10}{\magstephalf}{OT1} \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} -\setfont\defsl\slshape{10}{\magstephalf}{OT1TT} \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} -\def\df{\let\ttfont=\deftt \let\bffont = \defbf -\let\slfont=\defsl \let\ttslfont=\defttsl \bf} +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} % Fonts for indices, footnotes, small examples (9pt). \def\smallnominalsize{9pt} @@ -2383,20 +2166,6 @@ end \font\smallersy=cmsy8 \def\smallerecsize{0800} -% Fonts for math mode superscripts (7pt). -\def\sevennominalsize{7pt} -\setfont\sevenrm\rmshape{7}{1000}{OT1} -\setfont\seventt\ttshape{10}{700}{OT1TT} -\setfont\sevenbf\bfshape{10}{700}{OT1} -\setfont\sevenit\itshape{7}{1000}{OT1IT} -\setfont\sevensl\slshape{10}{700}{OT1} -\setfont\sevensf\sfshape{10}{700}{OT1} -\setfont\sevensc\scshape{10}{700}{OT1} -\setfont\seventtsl\ttslshape{10}{700}{OT1TT} -\font\seveni=cmmi7 -\font\sevensy=cmsy7 -\def\sevenecsize{0700} - % Fonts for title page (20.4pt): \def\titlenominalsize{20pt} \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} @@ -2453,7 +2222,7 @@ end \font\ssecsy=cmsy10 \def\ssececsize{1000} -% Reduced fonts for @acronym in text (9pt). +% Reduced fonts for @acro in text (9pt). \def\reducednominalsize{9pt} \setfont\reducedrm\rmshape{9}{1000}{OT1} \setfont\reducedtt\ttshape{9}{1000}{OT1TT} @@ -2467,30 +2236,25 @@ end \font\reducedsy=cmsy9 \def\reducedecsize{0900} -\divide\parskip by 2 % reduce space between paragraphs -\textleading = 12pt % line spacing for 10pt CM -\textfonts % reset the current fonts -\rm -} % end of 10pt text font size definitions, \definetextfontsizex +% reduce space between paragraphs +\divide\parskip by 2 -% Fonts for short table of contents. -\setfont\shortcontrm\rmshape{12}{1000}{OT1} -\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 -\setfont\shortcontsl\slshape{12}{1000}{OT1} -\setfont\shortconttt\ttshape{12}{1000}{OT1TT} +% reset the current fonts +\textfonts +\rm +} % end of 10pt text font size definitions % We provide the user-level command % @fonttextsize 10 % (or 11) to redefine the text font size. pt is assumed. % -\def\xiword{11} \def\xword{10} -\def\xwordpt{10pt} +\def\xiword{11} % \parseargdef\fonttextsize{% \def\textsizearg{#1}% - %\wlog{doing @fonttextsize \textsizearg}% + \wlog{doing @fonttextsize \textsizearg}% % % Set \globaldefs so that documents can use this inside @tex, since % makeinfo 4.8 does not support it, but we need it nonetheless. @@ -2505,121 +2269,102 @@ end \endgroup } -% -% Change the current font style to #1, remembering it in \curfontstyle. -% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in -% italics, not bold italics. -% -\def\setfontstyle#1{% - \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. - \csname #1font\endcsname % change the current font -} - -\def\rm{\fam=0 \setfontstyle{rm}} -\def\it{\fam=\itfam \setfontstyle{it}} -\def\sl{\fam=\slfam \setfontstyle{sl}} -\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} -\def\tt{\fam=\ttfam \setfontstyle{tt}} - -% Texinfo sort of supports the sans serif font style, which plain TeX does not. -% So we set up a \sf. -\newfam\sffam -\def\sf{\fam=\sffam \setfontstyle{sf}} - -% We don't need math for this font style. -\def\ttsl{\setfontstyle{ttsl}} - % In order for the font changes to affect most math symbols and letters, -% we have to define the \textfont of the standard families. -% We don't bother to reset \scriptscriptfont; awaiting user need. +% we have to define the \textfont of the standard families. Since +% texinfo doesn't allow for producing subscripts and superscripts except +% in the main text, we don't bother to reset \scriptfont and +% \scriptscriptfont (which would also require loading a lot more fonts). % \def\resetmathfonts{% - \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont - \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont - \textfont\ttfam=\ttfont \textfont\sffam=\sffont - % - % Fonts for superscript. Note that the 7pt fonts are used regardless - % of the current font size. - \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy - \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl - \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt - \scriptfont\sffam=\sevensf + \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy + \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf + \textfont\ttfam=\tentt \textfont\sffam=\tensf } -% - -% The font-changing commands (all called \...fonts) redefine the meanings -% of \STYLEfont, instead of just \STYLE. We do this because \STYLE needs -% to also set the current \fam for math mode. Our \STYLE (e.g., \rm) -% commands hardwire \STYLEfont to set the current font. -% -% The fonts used for \ifont are for "math italics" (\itfont is for italics -% in regular text). \syfont is also used in math mode only. +% The font-changing commands redefine the meanings of \tenSTYLE, instead +% of just \STYLE. We do this because \STYLE needs to also set the +% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire +% \tenSTYLE to set the current font. % % Each font-changing command also sets the names \lsize (one size lower) -% and \lllsize (three sizes lower). These relative commands are used -% in, e.g., the LaTeX logo and acronyms. +% and \lllsize (three sizes lower). These relative commands are used in +% the LaTeX logo and acronyms. % % This all needs generalizing, badly. % +\def\textfonts{% + \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl + \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc + \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy + \let\tenttsl=\textttsl + \def\curfontsize{text}% + \def\lsize{reduced}\def\lllsize{smaller}% + \resetmathfonts \setleading{\textleading}} +\def\titlefonts{% + \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl + \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc + \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy + \let\tenttsl=\titlettsl + \def\curfontsize{title}% + \def\lsize{chap}\def\lllsize{subsec}% + \resetmathfonts \setleading{25pt}} +\def\titlefont#1{{\titlefonts\rmisbold #1}} +\def\chapfonts{% + \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl + \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc + \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy + \let\tenttsl=\chapttsl + \def\curfontsize{chap}% + \def\lsize{sec}\def\lllsize{text}% + \resetmathfonts \setleading{19pt}} +\def\secfonts{% + \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl + \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc + \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy + \let\tenttsl=\secttsl + \def\curfontsize{sec}% + \def\lsize{subsec}\def\lllsize{reduced}% + \resetmathfonts \setleading{16pt}} +\def\subsecfonts{% + \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl + \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc + \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy + \let\tenttsl=\ssecttsl + \def\curfontsize{ssec}% + \def\lsize{text}\def\lllsize{small}% + \resetmathfonts \setleading{15pt}} +\let\subsubsecfonts = \subsecfonts +\def\reducedfonts{% + \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl + \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc + \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy + \let\tenttsl=\reducedttsl + \def\curfontsize{reduced}% + \def\lsize{small}\def\lllsize{smaller}% + \resetmathfonts \setleading{10.5pt}} +\def\smallfonts{% + \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl + \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc + \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy + \let\tenttsl=\smallttsl + \def\curfontsize{small}% + \def\lsize{smaller}\def\lllsize{smaller}% + \resetmathfonts \setleading{10.5pt}} +\def\smallerfonts{% + \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl + \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc + \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy + \let\tenttsl=\smallerttsl + \def\curfontsize{smaller}% + \def\lsize{smaller}\def\lllsize{smaller}% + \resetmathfonts \setleading{9.5pt}} -\def\assignfonts#1{% - \expandafter\let\expandafter\rmfont\csname #1rm\endcsname - \expandafter\let\expandafter\itfont\csname #1it\endcsname - \expandafter\let\expandafter\slfont\csname #1sl\endcsname - \expandafter\let\expandafter\bffont\csname #1bf\endcsname - \expandafter\let\expandafter\ttfont\csname #1tt\endcsname - \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname - \expandafter\let\expandafter\sffont \csname #1sf\endcsname - \expandafter\let\expandafter\ifont \csname #1i\endcsname - \expandafter\let\expandafter\syfont \csname #1sy\endcsname - \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname -} - -\newif\ifrmisbold - -% Select smaller font size with the current style. Used to change font size -% in, e.g., the LaTeX logo and acronyms. If we are using bold fonts for -% normal roman text, also use bold fonts for roman text in the smaller size. -\def\switchtolllsize{% - \expandafter\assignfonts\expandafter{\lllsize}% - \ifrmisbold - \let\rmfont\bffont - \fi - \csname\curfontstyle\endcsname -}% - -\def\switchtolsize{% - \expandafter\assignfonts\expandafter{\lsize}% - \ifrmisbold - \let\rmfont\bffont - \fi - \csname\curfontstyle\endcsname -}% - -\def\definefontsetatsize#1#2#3#4#5{% -\expandafter\def\csname #1fonts\endcsname{% - \def\curfontsize{#1}% - \def\lsize{#2}\def\lllsize{#3}% - \csname rmisbold#5\endcsname - \assignfonts{#1}% - \resetmathfonts - \setleading{#4}% -}} - -\definefontsetatsize{text} {reduced}{smaller}{\textleading}{false} -\definefontsetatsize{title} {chap} {subsec} {27pt} {true} -\definefontsetatsize{chap} {sec} {text} {19pt} {true} -\definefontsetatsize{sec} {subsec} {reduced}{17pt} {true} -\definefontsetatsize{ssec} {text} {small} {15pt} {true} -\definefontsetatsize{reduced}{small} {smaller}{10.5pt}{false} -\definefontsetatsize{small} {smaller}{smaller}{10.5pt}{false} -\definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false} - -\def\titlefont#1{{\titlefonts\rm #1}} -\let\subsecfonts = \ssecfonts -\let\subsubsecfonts = \ssecfonts +% Fonts for short table of contents. +\setfont\shortcontrm\rmshape{12}{1000}{OT1} +\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 +\setfont\shortcontsl\slshape{12}{1000}{OT1} +\setfont\shortconttt\ttshape{12}{1000}{OT1TT} % Define these just so they can be easily changed for other fonts. \def\angleleft{$\langle$} @@ -2657,11 +2402,26 @@ end % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will % define and register \INITMACRO to be called on markup style changes. % \INITMACRO can check \currentmarkupstyle for the innermost -% style. +% style and the set of \ifmarkupSTYLE switches for all styles +% currently in effect. +\newif\ifmarkupvar +\newif\ifmarkupsamp +\newif\ifmarkupkey +%\newif\ifmarkupfile % @file == @samp. +%\newif\ifmarkupoption % @option == @samp. +\newif\ifmarkupcode +\newif\ifmarkupkbd +%\newif\ifmarkupenv % @env == @code. +%\newif\ifmarkupcommand % @command == @code. +\newif\ifmarkuptex % @tex (and part of @math, for now). +\newif\ifmarkupexample +\newif\ifmarkupverb +\newif\ifmarkupverbatim \let\currentmarkupstyle\empty \def\setupmarkupstyle#1{% + \csname markup#1true\endcsname \def\currentmarkupstyle{#1}% \markupstylesetup } @@ -2676,14 +2436,12 @@ end % Markup style setup for left and right quotes. \defmarkupstylesetup\markupsetuplq{% - \expandafter\let\expandafter \temp - \csname markupsetuplq\currentmarkupstyle\endcsname + \expandafter\let\expandafter \temp \csname markupsetuplq\currentmarkupstyle\endcsname \ifx\temp\relax \markupsetuplqdefault \else \temp \fi } \defmarkupstylesetup\markupsetuprq{% - \expandafter\let\expandafter \temp - \csname markupsetuprq\currentmarkupstyle\endcsname + \expandafter\let\expandafter \temp \csname markupsetuprq\currentmarkupstyle\endcsname \ifx\temp\relax \markupsetuprqdefault \else \temp \fi } @@ -2696,42 +2454,35 @@ end \gdef\markupsetcodequoteleft{\let`\codequoteleft} \gdef\markupsetcodequoteright{\let'\codequoteright} + +\gdef\markupsetnoligaturesquoteleft{\let`\noligaturesquoteleft} } \let\markupsetuplqcode \markupsetcodequoteleft \let\markupsetuprqcode \markupsetcodequoteright -% \let\markupsetuplqexample \markupsetcodequoteleft \let\markupsetuprqexample \markupsetcodequoteright -% -\let\markupsetuplqkbd \markupsetcodequoteleft -\let\markupsetuprqkbd \markupsetcodequoteright -% -\let\markupsetuplqsamp \markupsetcodequoteleft -\let\markupsetuprqsamp \markupsetcodequoteright -% \let\markupsetuplqverb \markupsetcodequoteleft \let\markupsetuprqverb \markupsetcodequoteright -% \let\markupsetuplqverbatim \markupsetcodequoteleft \let\markupsetuprqverbatim \markupsetcodequoteright -% Allow an option to not use regular directed right quote/apostrophe -% (char 0x27), but instead the undirected quote from cmtt (char 0x0d). -% The undirected quote is ugly, so don't make it the default, but it -% works for pasting with more pdf viewers (at least evince), the -% lilypond developers report. xpdf does work with the regular 0x27. +\let\markupsetuplqsamp \markupsetnoligaturesquoteleft +\let\markupsetuplqkbd \markupsetnoligaturesquoteleft + +% Allow an option to not replace quotes with a regular directed right +% quote/apostrophe (char 0x27), but instead use the undirected quote +% from cmtt (char 0x0d). The undirected quote is ugly, so don't make it +% the default, but it works for pasting with more pdf viewers (at least +% evince), the lilypond developers report. xpdf does work with the +% regular 0x27. % \def\codequoteright{% - \ifmonospace - \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax - \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax - '% - \else \char'15 \fi + \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax + \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax + '% \else \char'15 \fi - \else - '% - \fi + \else \char'15 \fi } % % and a similar option for the left quote char vs. a grave accent. @@ -2739,47 +2490,13 @@ end % the code environments to do likewise. % \def\codequoteleft{% - \ifmonospace - \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax - \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax - % [Knuth] pp. 380,381,391 - % \relax disables Spanish ligatures ?` and !` of \tt font. - \relax`% - \else \char'22 \fi + \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax + \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax + % [Knuth] pp. 380,381,391 + % \relax disables Spanish ligatures ?` and !` of \tt font. + \relax`% \else \char'22 \fi - \else - \relax`% - \fi -} - -% Commands to set the quote options. -% -\parseargdef\codequoteundirected{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETtxicodequoteundirected\endcsname - = t% - \else\ifx\temp\offword - \expandafter\let\csname SETtxicodequoteundirected\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}% - \fi\fi -} -% -\parseargdef\codequotebacktick{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETtxicodequotebacktick\endcsname - = t% - \else\ifx\temp\offword - \expandafter\let\csname SETtxicodequotebacktick\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}% - \fi\fi + \else \char'22 \fi } % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. @@ -2788,49 +2505,27 @@ end % Count depth in font-changes, for error checks \newcount\fontdepth \fontdepth=0 -% Font commands. +%% Add scribe-like font environments, plus @l for inline lisp (usually sans +%% serif) and @ii for TeX italic -% #1 is the font command (\sl or \it), #2 is the text to slant. -% If we are in a monospaced environment, however, 1) always use \ttsl, -% and 2) do not add an italic correction. -\def\dosmartslant#1#2{% - \ifusingtt - {{\ttsl #2}\let\next=\relax}% - {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% - \next -} -\def\smartslanted{\dosmartslant\sl} -\def\smartitalic{\dosmartslant\it} +% \smartitalic{ARG} outputs arg in italics, followed by an italic correction +% unless the following character is such as not to need one. +\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else + \ptexslash\fi\fi\fi} +\def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx} +\def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx} -% Output an italic correction unless \next (presumed to be the following -% character) is such as not to need one. -\def\smartitaliccorrection{% - \ifx\next,% - \else\ifx\next-% - \else\ifx\next.% - \else\ifx\next\.% - \else\ifx\next\comma% - \else\ptexslash - \fi\fi\fi\fi\fi - \aftersmartic -} - -% Unconditional use \ttsl, and no ic. @var is set to this for defuns. -\def\ttslanted#1{{\ttsl #1}} +% like \smartslanted except unconditionally uses \ttsl. +% @var is set to this for defun arguments. +\def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx} % @cite is like \smartslanted except unconditionally use \sl. We never want % ttsl for book titles, do we? -\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} - -\def\aftersmartic{} -\def\var#1{% - \let\saveaftersmartic = \aftersmartic - \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% - \smartslanted{#1}% -} +\def\cite#1{{\sl #1}\futurelet\next\smartitalicx} \let\i=\smartitalic \let\slanted=\smartslanted +\def\var#1{{\setupmarkupstyle{var}\smartslanted{#1}}} \let\dfn=\smartslanted \let\emph=\smartitalic @@ -2859,8 +2554,8 @@ end % \catcode`@=11 \def\plainfrenchspacing{% - \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m - \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m + \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m + \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m \def\endofsentencespacefactor{1000}% for @. and friends } \def\plainnonfrenchspacing{% @@ -2880,326 +2575,6 @@ end % @samp. \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}} -% @indicateurl is \samp, that is, with quotes. -\let\indicateurl=\samp - -% @code (and similar) prints in typewriter, but with spaces the same -% size as normal in the surrounding text, without hyphenation, etc. -% This is a subroutine for that. -\def\tclose#1{% - {% - % Change normal interword space to be same as for the current font. - \spaceskip = \fontdimen2\font - % - % Switch to typewriter. - \tt - % - % But `\ ' produces the large typewriter interword space. - \def\ {{\spaceskip = 0pt{} }}% - % - % Turn off hyphenation. - \nohyphenation - % - \rawbackslash - \plainfrenchspacing - #1% - }% - \null % reset spacefactor to 1000 -} - -% We *must* turn on hyphenation at `-' and `_' in @code. -% (But see \codedashfinish below.) -% Otherwise, it is too hard to avoid overfull hboxes -% in the Emacs manual, the Library manual, etc. -% -% Unfortunately, TeX uses one parameter (\hyphenchar) to control -% both hyphenation at - and hyphenation within words. -% We must therefore turn them both off (\tclose does that) -% and arrange explicitly to hyphenate at a dash. -- rms. -{ - \catcode`\-=\active \catcode`\_=\active - \catcode`\'=\active \catcode`\`=\active - \global\let'=\rq \global\let`=\lq % default definitions - % - \global\def\code{\begingroup - \setupmarkupstyle{code}% - % The following should really be moved into \setupmarkupstyle handlers. - \catcode\dashChar=\active \catcode\underChar=\active - \ifallowcodebreaks - \let-\codedash - \let_\codeunder - \else - \let-\normaldash - \let_\realunder - \fi - % Given -foo (with a single dash), we do not want to allow a break - % after the hyphen. - \global\let\codedashprev=\codedash - % - \codex - } - % - \gdef\codedash{\futurelet\next\codedashfinish} - \gdef\codedashfinish{% - \normaldash % always output the dash character itself. - % - % Now, output a discretionary to allow a line break, unless - % (a) the next character is a -, or - % (b) the preceding character is a -. - % E.g., given --posix, we do not want to allow a break after either -. - % Given --foo-bar, we do want to allow a break between the - and the b. - \ifx\next\codedash \else - \ifx\codedashprev\codedash - \else \discretionary{}{}{}\fi - \fi - % we need the space after the = for the case when \next itself is a - % space token; it would get swallowed otherwise. As in @code{- a}. - \global\let\codedashprev= \next - } -} -\def\normaldash{-} -% -\def\codex #1{\tclose{#1}\endgroup} - -\def\codeunder{% - % this is all so @math{@code{var_name}+1} can work. In math mode, _ - % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) - % will therefore expand the active definition of _, which is us - % (inside @code that is), therefore an endless loop. - \ifusingtt{\ifmmode - \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. - \else\normalunderscore \fi - \discretionary{}{}{}}% - {\_}% -} - -% An additional complication: the above will allow breaks after, e.g., -% each of the four underscores in __typeof__. This is bad. -% @allowcodebreaks provides a document-level way to turn breaking at - -% and _ on and off. -% -\newif\ifallowcodebreaks \allowcodebreakstrue - -\def\keywordtrue{true} -\def\keywordfalse{false} - -\parseargdef\allowcodebreaks{% - \def\txiarg{#1}% - \ifx\txiarg\keywordtrue - \allowcodebreakstrue - \else\ifx\txiarg\keywordfalse - \allowcodebreaksfalse - \else - \errhelp = \EMsimple - \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}% - \fi\fi -} - -% For @command, @env, @file, @option quotes seem unnecessary, -% so use \code rather than \samp. -\let\command=\code -\let\env=\code -\let\file=\code -\let\option=\code - -% @uref (abbreviation for `urlref') aka @url takes an optional -% (comma-separated) second argument specifying the text to display and -% an optional third arg as text to display instead of (rather than in -% addition to) the url itself. First (mandatory) arg is the url. - -% TeX-only option to allow changing PDF output to show only the second -% arg (if given), and not the url (which is then just the link target). -\newif\ifurefurlonlylink - -% The main macro is \urefbreak, which allows breaking at expected -% places within the url. (There used to be another version, which -% didn't support automatic breaking.) -\def\urefbreak{\begingroup \urefcatcodes \dourefbreak} -\let\uref=\urefbreak -% -\def\dourefbreak#1{\urefbreakfinish #1,,,\finish} -\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example - \unsepspaces - \pdfurl{#1}% - \setbox0 = \hbox{\ignorespaces #3}% - \ifdim\wd0 > 0pt - \unhbox0 % third arg given, show only that - \else - \setbox0 = \hbox{\ignorespaces #2}% look for second arg - \ifdim\wd0 > 0pt - \ifpdf - % For pdfTeX and LuaTeX - \ifurefurlonlylink - % PDF plus option to not display url, show just arg - \unhbox0 - \else - % PDF, normally display both arg and url for consistency, - % visibility, if the pdf is eventually used to print, etc. - \unhbox0\ (\urefcode{#1})% - \fi - \else - \ifx\XeTeXrevision\thisisundefined - \unhbox0\ (\urefcode{#1})% DVI, always show arg and url - \else - % For XeTeX - \ifurefurlonlylink - % PDF plus option to not display url, show just arg - \unhbox0 - \else - % PDF, normally display both arg and url for consistency, - % visibility, if the pdf is eventually used to print, etc. - \unhbox0\ (\urefcode{#1})% - \fi - \fi - \fi - \else - \urefcode{#1}% only url given, so show it - \fi - \fi - \endlink -\endgroup} - -% Allow line breaks around only a few characters (only). -\def\urefcatcodes{% - \catcode`\&=\active \catcode`\.=\active - \catcode`\#=\active \catcode`\?=\active - \catcode`\/=\active -} -{ - \urefcatcodes - % - \global\def\urefcode{\begingroup - \setupmarkupstyle{code}% - \urefcatcodes - \let&\urefcodeamp - \let.\urefcodedot - \let#\urefcodehash - \let?\urefcodequest - \let/\urefcodeslash - \codex - } - % - % By default, they are just regular characters. - \global\def&{\normalamp} - \global\def.{\normaldot} - \global\def#{\normalhash} - \global\def?{\normalquest} - \global\def/{\normalslash} -} - -% we put a little stretch before and after the breakable chars, to help -% line breaking of long url's. The unequal skips make look better in -% cmtt at least, especially for dots. -\def\urefprestretchamount{.13em} -\def\urefpoststretchamount{.1em} -\def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax} -\def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax} -% -\def\urefcodeamp{\urefprestretch \&\urefpoststretch} -\def\urefcodedot{\urefprestretch .\urefpoststretch} -\def\urefcodehash{\urefprestretch \#\urefpoststretch} -\def\urefcodequest{\urefprestretch ?\urefpoststretch} -\def\urefcodeslash{\futurelet\next\urefcodeslashfinish} -{ - \catcode`\/=\active - \global\def\urefcodeslashfinish{% - \urefprestretch \slashChar - % Allow line break only after the final / in a sequence of - % slashes, to avoid line break between the slashes in http://. - \ifx\next/\else \urefpoststretch \fi - } -} - -% One more complication: by default we'll break after the special -% characters, but some people like to break before the special chars, so -% allow that. Also allow no breaking at all, for manual control. -% -\parseargdef\urefbreakstyle{% - \def\txiarg{#1}% - \ifx\txiarg\wordnone - \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak} - \else\ifx\txiarg\wordbefore - \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak} - \else\ifx\txiarg\wordafter - \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak} - \else - \errhelp = \EMsimple - \errmessage{Unknown @urefbreakstyle setting `\txiarg'}% - \fi\fi\fi -} -\def\wordafter{after} -\def\wordbefore{before} -\def\wordnone{none} - -\urefbreakstyle after - -% @url synonym for @uref, since that's how everyone uses it. -% -\let\url=\uref - -% rms does not like angle brackets --karl, 17may97. -% So now @email is just like @uref, unless we are pdf. -% -%\def\email#1{\angleleft{\tt #1}\angleright} -\ifpdf - \def\email#1{\doemail#1,,\finish} - \def\doemail#1,#2,#3\finish{\begingroup - \unsepspaces - \pdfurl{mailto:#1}% - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi - \endlink - \endgroup} -\else - \ifx\XeTeXrevision\thisisundefined - \let\email=\uref - \else - \def\email#1{\doemail#1,,\finish} - \def\doemail#1,#2,#3\finish{\begingroup - \unsepspaces - \pdfurl{mailto:#1}% - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi - \endlink - \endgroup} - \fi -\fi - -% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), -% `example' (@kbd uses ttsl only inside of @example and friends), -% or `code' (@kbd uses normal tty font always). -\parseargdef\kbdinputstyle{% - \def\txiarg{#1}% - \ifx\txiarg\worddistinct - \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% - \else\ifx\txiarg\wordexample - \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% - \else\ifx\txiarg\wordcode - \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% - \else - \errhelp = \EMsimple - \errmessage{Unknown @kbdinputstyle setting `\txiarg'}% - \fi\fi\fi -} -\def\worddistinct{distinct} -\def\wordexample{example} -\def\wordcode{code} - -% Default is `distinct'. -\kbdinputstyle distinct - -% @kbd is like @code, except that if the argument is just one @key command, -% then @kbd has no effect. -\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}} - -\def\xkey{\key} -\def\kbdsub#1#2#3\par{% - \def\one{#1}\def\three{#3}\def\threex{??}% - \ifx\one\xkey\ifx\threex\three \key{#2}% - \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi - \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi -} - % definition of @key that produces a lozenge. Doesn't adjust to text size. %\setfont\keyrm\rmshape{8}{1000}{OT1} %\font\keysy=cmsy9 @@ -3219,6 +2594,140 @@ end \ifmonospace\else\tt\fi #1}\null} +% ctrl is no longer a Texinfo command. +\def\ctrl #1{{\tt \rawbackslash \hat}#1} + +% @file, @option are the same as @samp. +\let\file=\samp +\let\option=\samp + +% @code is a modification of @t, +% which makes spaces the same size as normal in the surrounding text. +\def\tclose#1{% + {% + % Change normal interword space to be same as for the current font. + \spaceskip = \fontdimen2\font + % + % Switch to typewriter. + \tt + % + % But `\ ' produces the large typewriter interword space. + \def\ {{\spaceskip = 0pt{} }}% + % + % Turn off hyphenation. + \nohyphenation + % + \rawbackslash + \plainfrenchspacing + #1% + }% + \null +} + +% We *must* turn on hyphenation at `-' and `_' in @code. +% Otherwise, it is too hard to avoid overfull hboxes +% in the Emacs manual, the Library manual, etc. + +% Unfortunately, TeX uses one parameter (\hyphenchar) to control +% both hyphenation at - and hyphenation within words. +% We must therefore turn them both off (\tclose does that) +% and arrange explicitly to hyphenate at a dash. +% -- rms. +{ + \catcode`\-=\active \catcode`\_=\active + \catcode`\'=\active \catcode`\`=\active + \global\let'=\rq \global\let`=\lq % default definitions + % + \global\def\code{\begingroup + \setupmarkupstyle{code}% + % The following should really be moved into \setupmarkupstyle handlers. + \catcode\dashChar=\active \catcode\underChar=\active + \ifallowcodebreaks + \let-\codedash + \let_\codeunder + \else + \let-\realdash + \let_\realunder + \fi + \codex + } +} + +\def\realdash{-} +\def\codedash{-\discretionary{}{}{}} +\def\codeunder{% + % this is all so @math{@code{var_name}+1} can work. In math mode, _ + % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) + % will therefore expand the active definition of _, which is us + % (inside @code that is), therefore an endless loop. + \ifusingtt{\ifmmode + \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. + \else\normalunderscore \fi + \discretionary{}{}{}}% + {\_}% +} +\def\codex #1{\tclose{#1}\endgroup} + +% An additional complication: the above will allow breaks after, e.g., +% each of the four underscores in __typeof__. This is undesirable in +% some manuals, especially if they don't have long identifiers in +% general. @allowcodebreaks provides a way to control this. +% +\newif\ifallowcodebreaks \allowcodebreakstrue + +\def\keywordtrue{true} +\def\keywordfalse{false} + +\parseargdef\allowcodebreaks{% + \def\txiarg{#1}% + \ifx\txiarg\keywordtrue + \allowcodebreakstrue + \else\ifx\txiarg\keywordfalse + \allowcodebreaksfalse + \else + \errhelp = \EMsimple + \errmessage{Unknown @allowcodebreaks option `\txiarg'}% + \fi\fi +} + +% @kbd is like @code, except that if the argument is just one @key command, +% then @kbd has no effect. +\def\kbd#1{{\setupmarkupstyle{kbd}\def\look{#1}\expandafter\kbdfoo\look??\par}} + +% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), +% `example' (@kbd uses ttsl only inside of @example and friends), +% or `code' (@kbd uses normal tty font always). +\parseargdef\kbdinputstyle{% + \def\txiarg{#1}% + \ifx\txiarg\worddistinct + \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% + \else\ifx\txiarg\wordexample + \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% + \else\ifx\txiarg\wordcode + \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% + \else + \errhelp = \EMsimple + \errmessage{Unknown @kbdinputstyle option `\txiarg'}% + \fi\fi\fi +} +\def\worddistinct{distinct} +\def\wordexample{example} +\def\wordcode{code} + +% Default is `distinct'. +\kbdinputstyle distinct + +\def\xkey{\key} +\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% +\ifx\one\xkey\ifx\threex\three \key{#2}% +\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi +\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi} + +% For @indicateurl, @env, @command quotes seem unnecessary, so use \code. +\let\indicateurl=\code +\let\env=\code +\let\command=\code + % @clicksequence{File @click{} Open ...} \def\clicksequence#1{\begingroup #1\endgroup} @@ -3226,23 +2735,76 @@ end \parseargdef\clickstyle{\def\click{#1}} \def\click{\arrow} +% @uref (abbreviation for `urlref') takes an optional (comma-separated) +% second argument specifying the text to display and an optional third +% arg as text to display instead of (rather than in addition to) the url +% itself. First (mandatory) arg is the url. Perhaps eventually put in +% a hypertex \special here. +% +\def\uref#1{\douref #1,,,\finish} +\def\douref#1,#2,#3,#4\finish{\begingroup + \unsepspaces + \pdfurl{#1}% + \setbox0 = \hbox{\ignorespaces #3}% + \ifdim\wd0 > 0pt + \unhbox0 % third arg given, show only that + \else + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0 > 0pt + \ifpdf + \unhbox0 % PDF: 2nd arg given, show only it + \else + \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url + \fi + \else + \code{#1}% only url given, so show it + \fi + \fi + \endlink +\endgroup} + +% @url synonym for @uref, since that's how everyone uses it. +% +\let\url=\uref + +% rms does not like angle brackets --karl, 17may97. +% So now @email is just like @uref, unless we are pdf. +% +%\def\email#1{\angleleft{\tt #1}\angleright} +\ifpdf + \def\email#1{\doemail#1,,\finish} + \def\doemail#1,#2,#3\finish{\begingroup + \unsepspaces + \pdfurl{mailto:#1}% + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi + \endlink + \endgroup} +\else + \let\email=\uref +\fi + % Typeset a dimension, e.g., `in' or `pt'. The only reason for the % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. % \def\dmn#1{\thinspace #1} +% @l was never documented to mean ``switch to the Lisp font'', +% and it is not used as such in any manual I can find. We need it for +% Polish suppressed-l. --karl, 22sep96. +%\def\l#1{{\li #1}\null} + % @acronym for "FBI", "NATO", and the like. % We print this one point size smaller, since it's intended for % all-uppercase. % \def\acronym#1{\doacronym #1,,\finish} \def\doacronym#1,#2,#3\finish{% - {\switchtolsize #1}% + {\selectfonts\lsize #1}% \def\temp{#2}% \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi - \null % reset \spacefactor=1000 } % @abbr for "Comput. J." and the like. @@ -3255,252 +2817,10 @@ end \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi - \null % reset \spacefactor=1000 -} - -% @asis just yields its argument. Used with @table, for example. -% -\def\asis#1{#1} - -% @math outputs its argument in math mode. -% -% One complication: _ usually means subscripts, but it could also mean -% an actual _ character, as in @math{@var{some_variable} + 1}. So make -% _ active, and distinguish by seeing if the current family is \slfam, -% which is what @var uses. -{ - \catcode`\_ = \active - \gdef\mathunderscore{% - \catcode`\_=\active - \def_{\ifnum\fam=\slfam \_\else\sb\fi}% - } -} -% Another complication: we want \\ (and @\) to output a math (or tt) \. -% FYI, plain.tex uses \\ as a temporary control sequence (for no -% particular reason), but this is not advertised and we don't care. -% -% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. -\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} -% -\def\math{% - \ifmmode\else % only go into math if not in math mode already - \tex - \mathunderscore - \let\\ = \mathbackslash - \mathactive - % make the texinfo accent commands work in math mode - \let\"=\ddot - \let\'=\acute - \let\==\bar - \let\^=\hat - \let\`=\grave - \let\u=\breve - \let\v=\check - \let\~=\tilde - \let\dotaccent=\dot - % have to provide another name for sup operator - \let\mathopsup=\sup - $\expandafter\finishmath\fi -} -\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. - -% Some active characters (such as <) are spaced differently in math. -% We have to reset their definitions in case the @math was an argument -% to a command which sets the catcodes (such as @item or @section). -% -{ - \catcode`^ = \active - \catcode`< = \active - \catcode`> = \active - \catcode`+ = \active - \catcode`' = \active - \gdef\mathactive{% - \let^ = \ptexhat - \let< = \ptexless - \let> = \ptexgtr - \let+ = \ptexplus - \let' = \ptexquoteright - } -} - -% for @sub and @sup, if in math mode, just do a normal sub/superscript. -% If in text, use math to place as sub/superscript, but switch -% into text mode, with smaller fonts. This is a different font than the -% one used for real math sub/superscripts (8pt vs. 7pt), but let's not -% fix it (significant additions to font machinery) until someone notices. -% -\def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi} -\def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}% -% -\def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi} -\def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}% - -% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. -% Ignore unless FMTNAME == tex; then it is like @iftex and @tex, -% except specified as a normal braced arg, so no newlines to worry about. -% -\def\outfmtnametex{tex} -% -\long\def\inlinefmt#1{\doinlinefmt #1,\finish} -\long\def\doinlinefmt#1,#2,\finish{% - \def\inlinefmtname{#1}% - \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi -} -% -% @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if -% FMTNAME is tex, else ELSE-TEXT. -\long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish} -\long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{% - \def\inlinefmtname{#1}% - \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi -} -% -% For raw, must switch into @tex before parsing the argument, to avoid -% setting catcodes prematurely. Doing it this way means that, for -% example, @inlineraw{html, foo{bar} gets a parse error instead of being -% ignored. But this isn't important because if people want a literal -% *right* brace they would have to use a command anyway, so they may as -% well use a command to get a left brace too. We could re-use the -% delimiter character idea from \verb, but it seems like overkill. -% -\long\def\inlineraw{\tex \doinlineraw} -\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish} -\def\doinlinerawtwo#1,#2,\finish{% - \def\inlinerawname{#1}% - \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi - \endgroup % close group opened by \tex. -} - -% @inlineifset{VAR, TEXT} expands TEXT if VAR is @set. -% -\long\def\inlineifset#1{\doinlineifset #1,\finish} -\long\def\doinlineifset#1,#2,\finish{% - \def\inlinevarname{#1}% - \expandafter\ifx\csname SET\inlinevarname\endcsname\relax - \else\ignorespaces#2\fi -} - -% @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set. -% -\long\def\inlineifclear#1{\doinlineifclear #1,\finish} -\long\def\doinlineifclear#1,#2,\finish{% - \def\inlinevarname{#1}% - \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi } \message{glyphs,} -% and logos. - -% @@ prints an @, as does @atchar{}. -\def\@{\char64 } -\let\atchar=\@ - -% @{ @} @lbracechar{} @rbracechar{} all generate brace characters. -\def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}} -\def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}} -\let\{=\lbracechar -\let\}=\rbracechar - -% @comma{} to avoid , parsing problems. -\let\comma = , - -% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent -% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. -\let\, = \ptexc -\let\dotaccent = \ptexdot -\def\ringaccent#1{{\accent23 #1}} -\let\tieaccent = \ptext -\let\ubaraccent = \ptexb -\let\udotaccent = \d - -% Other special characters: @questiondown @exclamdown @ordf @ordm -% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. -\def\questiondown{?`} -\def\exclamdown{!`} -\def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}} -\def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}} - -% Dotless i and dotless j, used for accents. -\def\imacro{i} -\def\jmacro{j} -\def\dotless#1{% - \def\temp{#1}% - \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi - \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi - \else \errmessage{@dotless can be used only with i or j}% - \fi\fi -} - -% The \TeX{} logo, as in plain, but resetting the spacing so that a -% period following counts as ending a sentence. (Idea found in latex.) -% -\edef\TeX{\TeX \spacefactor=1000 } - -% @LaTeX{} logo. Not quite the same results as the definition in -% latex.ltx, since we use a different font for the raised A; it's most -% convenient for us to use an explicitly smaller font, rather than using -% the \scriptstyle font (since we don't reset \scriptstyle and -% \scriptscriptstyle). -% -\def\LaTeX{% - L\kern-.36em - {\setbox0=\hbox{T}% - \vbox to \ht0{\hbox{% - \ifx\textnominalsize\xwordpt - % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX. - % Revert to plain's \scriptsize, which is 7pt. - \count255=\the\fam $\fam\count255 \scriptstyle A$% - \else - % For 11pt, we can use our lllsize. - \switchtolllsize A% - \fi - }% - \vss - }}% - \kern-.15em - \TeX -} - -% Some math mode symbols. Define \ensuremath to switch into math mode -% unless we are already there. Expansion tricks may not be needed here, -% but safer, and can't hurt. -\def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi} -\def\ensuredmath#1{$\relax#1$} -% -\def\bullet{\ensuremath\ptexbullet} -\def\geq{\ensuremath\ge} -\def\leq{\ensuremath\le} -\def\minus{\ensuremath-} - -% @dots{} outputs an ellipsis using the current font. -% We do .5em per period so that it has the same spacing in the cm -% typewriter fonts as three actual period characters; on the other hand, -% in other typewriter fonts three periods are wider than 1.5em. So do -% whichever is larger. -% -\def\dots{% - \leavevmode - \setbox0=\hbox{...}% get width of three periods - \ifdim\wd0 > 1.5em - \dimen0 = \wd0 - \else - \dimen0 = 1.5em - \fi - \hbox to \dimen0{% - \hskip 0pt plus.25fil - .\hskip 0pt plus1fil - .\hskip 0pt plus1fil - .\hskip 0pt plus.5fil - }% -} - -% @enddots{} is an end-of-sentence ellipsis. -% -\def\enddots{% - \dots - \spacefactor=\endofsentencespacefactor -} % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. % @@ -3519,10 +2839,10 @@ end % \newbox\errorbox % -{\ttfont \global\dimen0 = 3em}% Width of the box. +{\tentt \global\dimen0 = 3em}% Width of the box. \dimen2 = .55pt % Thickness of rules % The text. (`r' is open on the right, `e' somewhat less so on the left.) -\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} +\setbox0 = \hbox{\kern-.75pt \reducedsf error\kern-1.5pt} % \setbox\errorbox=\hbox to \dimen0{\hfil \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. @@ -3635,32 +2955,20 @@ end \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} % -% Use the European Computer Modern fonts (cm-super in outline format) -% for non-CM glyphs. That is ec* for regular text and tc* for the text -% companion symbols (LaTeX TS1 encoding). Both are part of the ec -% package and follow the same conventions. -% -\def\ecfont{\etcfont{e}} -\def\tcfont{\etcfont{t}} -% -\def\etcfont#1{% +% Use the ec* fonts (cm-super in outline format) for non-CM glyphs. +\def\ecfont{% % We can't distinguish serif/sans and italic/slanted, but this % is used for crude hacks anyway (like adding French and German % quotes to documents typeset with CM, where we lose kerning), so % hopefully nobody will notice/care. \edef\ecsize{\csname\curfontsize ecsize\endcsname}% \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% - \ifmonospace - % typewriter: - \font\thisecfont = #1ctt\ecsize \space at \nominalsize + \ifx\curfontstyle\bfstylename + % bold: + \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize \else - \ifx\curfontstyle\bfstylename - % bold: - \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize - \else - % regular: - \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize - \fi + % regular: + \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize \fi \thisecfont } @@ -3670,7 +2978,7 @@ end % Adapted from the plain.tex definition of \copyright. % \def\registeredsymbol{% - $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}% + $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% \hfil\crcr\Orb}}% }$% } @@ -3683,7 +2991,7 @@ end % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 % so we'll define it if necessary. % -\ifx\Orb\thisisundefined +\ifx\Orb\undefined \def\Orb{\mathhexbox20D} \fi @@ -3703,20 +3011,16 @@ end \newif\ifseenauthor \newif\iffinishedtitlepage -% @setcontentsaftertitlepage used to do an implicit @contents or -% @shortcontents after @end titlepage, but it is now obsolete. -\def\setcontentsaftertitlepage{% - \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo - command; move your @contents command if you want the contents - after the title page.}}% -\def\setshortcontentsaftertitlepage{% - \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo - command; move your @shortcontents and @contents commands if you - want the contents after the title page.}}% +% Do an implicit @contents or @shortcontents after @end titlepage if the +% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. +% +\newif\ifsetcontentsaftertitlepage + \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue +\newif\ifsetshortcontentsaftertitlepage + \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue -\parseargdef\shorttitlepage{% - \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}% - \endgroup\page\hbox{}\page} +\parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% + \endgroup\page\hbox{}\page} \envdef\titlepage{% % Open one extra group, as we want to close it in the middle of \Etitlepage. @@ -3754,6 +3058,20 @@ end % Need this before the \...aftertitlepage checks so that if they are % in effect the toc pages will come out with page numbers. \HEADINGSon + % + % If they want short, they certainly want long too. + \ifsetshortcontentsaftertitlepage + \shortcontents + \contents + \global\let\shortcontents = \relax + \global\let\contents = \relax + \fi + % + \ifsetcontentsaftertitlepage + \contents + \global\let\contents = \relax + \global\let\shortcontents = \relax + \fi } \def\finishtitlepage{% @@ -3762,27 +3080,14 @@ end \finishedtitlepagetrue } -% Settings used for typesetting titles: no hyphenation, no indentation, -% don't worry much about spacing, ragged right. This should be used -% inside a \vbox, and fonts need to be set appropriately first. \par should -% be specified before the end of the \vbox, since a vbox is a group. -% -\def\raggedtitlesettings{% - \rm - \hyphenpenalty=10000 - \parindent=0pt - \tolerance=5000 - \ptexraggedright -} +%%% Macros to be used within @titlepage: -% Macros to be used within @titlepage: - -\let\subtitlerm=\rmfont +\let\subtitlerm=\tenrm \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} \parseargdef\title{% \checkenv\titlepage - \vbox{\titlefonts \raggedtitlesettings #1\par}% + \leftline{\titlefonts\rmisbold #1} % print a rule at the page bottom also. \finishedtitlepagefalse \vskip4pt \hrule height 4pt width \hsize \vskip4pt @@ -3803,12 +3108,12 @@ end \else \checkenv\titlepage \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi - {\secfonts\rm \leftline{#1}}% + {\secfonts\rmisbold \leftline{#1}}% \fi } -% Set up page headings and footings. +%%% Set up page headings and footings. \let\thispage=\folio @@ -3817,7 +3122,7 @@ end \newtoks\evenfootline % footline on even pages \newtoks\oddfootline % footline on odd pages -% Now make \makeheadline and \makefootline in Plain TeX use those variables +% Now make TeX use those variables \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}} \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline @@ -3856,7 +3161,7 @@ end % % Leave some space for the footline. Hopefully ok to assume % @evenfooting will not be used by itself. - \global\advance\txipageheight by -12pt + \global\advance\pageheight by -12pt \global\advance\vsize by -12pt } @@ -3873,17 +3178,13 @@ end % @everyheadingmarks % @everyfootingmarks -% These define \getoddheadingmarks, \getevenheadingmarks, -% \getoddfootingmarks, and \getevenfootingmarks, each to one of -% \gettopheadingmarks, \getbottomheadingmarks. -% \def\evenheadingmarks{\headingmarks{even}{heading}} \def\oddheadingmarks{\headingmarks{odd}{heading}} \def\evenfootingmarks{\headingmarks{even}{footing}} \def\oddfootingmarks{\headingmarks{odd}{footing}} -\parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1} +\def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1} \headingmarks{odd}{heading}{#1} } -\parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1} +\def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1} \headingmarks{odd}{footing}{#1} } % #1 = even/odd, #2 = heading/footing, #3 = top/bottom. \def\headingmarks#1#2#3 {% @@ -3904,16 +3205,12 @@ end % By default, they are off at the start of a document, % and turned `on' after @end titlepage. -\parseargdef\headings{\csname HEADINGS#1\endcsname} - -\def\headingsoff{% non-global headings elimination - \evenheadline={\hfil}\evenfootline={\hfil}% - \oddheadline={\hfil}\oddfootline={\hfil}% -} - -\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting -\HEADINGSoff % it's the default +\def\headings #1 {\csname HEADINGS#1\endcsname} +\def\HEADINGSoff{% +\global\evenheadline={\hfil} \global\evenfootline={\hfil} +\global\oddheadline={\hfil} \global\oddfootline={\hfil}} +\HEADINGSoff % When we turn headings on, set the page number to 1. % For double-sided printing, put current file name in lower left corner, % chapter name on inside top of right hand pages, document @@ -3924,7 +3221,7 @@ end \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapterheading\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } \let\contentsalignmacro = \chappager @@ -3935,8 +3232,8 @@ end \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapterheading\hfil\folio}} -\global\oddheadline={\line{\thischapterheading\hfil\folio}} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } \def\HEADINGSon{\HEADINGSdouble} @@ -3947,7 +3244,7 @@ end \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapterheading\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } @@ -3955,8 +3252,8 @@ end \def\HEADINGSsinglex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapterheading\hfil\folio}} -\global\oddheadline={\line{\thischapterheading\hfil\folio}} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } @@ -3964,7 +3261,7 @@ end % This produces Day Month Year style of output. % Only define if not already defined, in case a txi-??.tex file has set % up a different format (e.g., txi-cs.tex does this). -\ifx\today\thisisundefined +\ifx\today\undefined \def\today{% \number\day\space \ifcase\month @@ -4025,7 +3322,7 @@ end \begingroup \advance\leftskip by-\tableindent \advance\hsize by\tableindent - \advance\rightskip by0pt plus1fil\relax + \advance\rightskip by0pt plus1fil \leavevmode\unhbox0\par \endgroup % @@ -4134,7 +3431,7 @@ end \parskip=\smallskipamount \ifdim\parskip=0pt \parskip=2pt \fi % - % Try typesetting the item mark so that if the document erroneously says + % Try typesetting the item mark that if the document erroneously says % something like @itemize @samp (intending @table), there's an error % right away at the @itemize. It's not the best error message in the % world, but it's better than leaving it to the @item. This means if @@ -4166,12 +3463,7 @@ end \noindent \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% % - \ifinner\else - \vadjust{\penalty 1200}% not good to break after first line of item. - \fi - % We can be in inner vertical mode in a footnote, although an - % @itemize looks awful there. - }% + \vadjust{\penalty 1200}}% not good to break after first line of item. \flushcr } @@ -4389,23 +3681,19 @@ end } % multitable-only commands. -% -% @headitem starts a heading row, which we typeset in bold. Assignments -% have to be global since we are inside the implicit group of an -% alignment entry. \everycr below resets \everytab so we don't have to +% +% @headitem starts a heading row, which we typeset in bold. +% Assignments have to be global since we are inside the implicit group +% of an alignment entry. \everycr resets \everytab so we don't have to % undo it ourselves. \def\headitemfont{\b}% for people to use in the template row; not changeable \def\headitem{% \checkenv\multitable \crcr - \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings \global\everytab={\bf}% can't use \headitemfont since the parsing differs \the\everytab % for the first item }% % -% default for tables with no headings. -\let\headitemcrhook=\relax -% % A \tab used to include \hskip1sp. But then the space in a template % line is not enough. That is bad. So let's go back to just `&' until % we again encounter the problem the 1sp was intended to solve. @@ -4436,15 +3724,15 @@ end % \everycr = {% \noalign{% - \global\everytab={}% Reset from possible headitem. + \global\everytab={}% \global\colcount=0 % Reset the column counter. - % - % Check for saved footnotes, etc.: + % Check for saved footnotes, etc. \checkinserts - % - % Perhaps a \nobreak, then reset: - \headitemcrhook - \global\let\headitemcrhook=\relax + % Keeps underfull box messages off when table breaks over pages. + %\filbreak + % Maybe so, but it also creates really weird page breaks when the + % table breaks over pages. Wouldn't \vfil be better? Wait until the + % problem manifests itself, so it can be fixed for real --karl. }% }% % @@ -4520,18 +3808,18 @@ end \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip \global\advance\multitablelinespace by-\ht0 \fi -% Test to see if parskip is larger than space between lines of -% table. If not, do nothing. -% If so, set to same dimension as multitablelinespace. +%% Test to see if parskip is larger than space between lines of +%% table. If not, do nothing. +%% If so, set to same dimension as multitablelinespace. \ifdim\multitableparskip>\multitablelinespace \global\multitableparskip=\multitablelinespace -\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller - % than skip between lines in the table. +\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller + %% than skip between lines in the table. \fi% \ifdim\multitableparskip=0pt \global\multitableparskip=\multitablelinespace -\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller - % than skip between lines in the table. +\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller + %% than skip between lines in the table. \fi} @@ -4683,7 +3971,7 @@ end \def\value{\begingroup\makevalueexpandable\valuexxx} \def\valuexxx#1{\expandablevalue{#1}\endgroup} { - \catcode`\-=\active \catcode`\_=\active + \catcode`\- = \active \catcode`\_ = \active % \gdef\makevalueexpandable{% \let\value = \expandablevalue @@ -4692,7 +3980,7 @@ end % ..., but we might end up with active ones in the argument if % we're called from @code, as @code{@value{foo-bar_}}, though. % So \let them to their normal equivalents. - \let-\normaldash \let_\normalunderscore + \let-\realdash \let_\normalunderscore } } @@ -4703,12 +3991,7 @@ end % variable's value contains other Texinfo commands, it's almost certain % it will fail (although perhaps we could fix that with sufficient work % to do a one-level expansion on the result, instead of complete). -% -% Unfortunately, this has the consequence that when _ is in the *value* -% of an @set, it does not print properly in the roman fonts (get the cmr -% dot accent at position 126 instead). No fix comes to mind, and it's -% been this way since 2003 or earlier, so just ignore it. -% +% \def\expandablevalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax {[No value for ``#1'']}% @@ -4718,36 +4001,10 @@ end \fi } -% Like \expandablevalue, but completely expandable (the \message in the -% definition above operates at the execution level of TeX). Used when -% writing to auxiliary files, due to the expansion that \write does. -% If flag is undefined, pass through an unexpanded @value command: maybe it -% will be set by the time it is read back in. -% -% NB flag names containing - or _ may not work here. -\def\dummyvalue#1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \noexpand\value{#1}% - \else - \csname SET#1\endcsname - \fi -} - -% Used for @value's in index entries to form the sort key: expand the @value -% if possible, otherwise sort late. -\def\indexnofontsvalue#1{% - \expandafter\ifx\csname SET#1\endcsname\relax - ZZZZZZZ - \else - \csname SET#1\endcsname - \fi -} - % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined % with @set. -% -% To get the special treatment we need for `@end ifset,' we call -% \makecond and then redefine. +% +% To get special treatment of `@end ifset,' call \makeond and the redefine. % \makecond{ifset} \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} @@ -4763,7 +4020,7 @@ end } \def\ifsetfail{\doignore{ifset}} -% @ifclear VAR ... @end executes the `...' iff VAR has never been +% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been % defined with @set, or has been undefined with @clear. % % The `\else' inside the `\doifset' parameter is a trick to reuse the @@ -4774,35 +4031,6 @@ end \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} \def\ifclearfail{\doignore{ifclear}} -% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written -% without the @) is in fact defined. We can only feasibly check at the -% TeX level, so something like `mathcode' is going to considered -% defined even though it is not a Texinfo command. -% -\makecond{ifcommanddefined} -\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}} -% -\def\doifcmddefined#1#2{{% - \makevalueexpandable - \let\next=\empty - \expandafter\ifx\csname #2\endcsname\relax - #1% If not defined, \let\next as above. - \fi - \expandafter - }\next -} -\def\ifcmddefinedfail{\doignore{ifcommanddefined}} - -% @ifcommandnotdefined CMD ... handled similar to @ifclear above. -\makecond{ifcommandnotdefined} -\def\ifcommandnotdefined{% - \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}} -\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}} - -% Set the `txicommandconditionals' variable, so documents have a way to -% test if the @ifcommand...defined conditionals are available. -\set txicommandconditionals - % @dircategory CATEGORY -- specify a category of the dir file % which this file should belong to. Ignore this in TeX. \let\dircategory=\comment @@ -4818,16 +4046,19 @@ end % except not \outer, so it can be used within macros and \if's. \edef\newwrite{\makecsname{ptexnewwrite}} -% \newindex {foo} defines an index named IX. -% It automatically defines \IXindex such that -% \IXindex ...rest of line... puts an entry in the index IX. -% It also defines \IXindfile to be the number of the output channel for -% the file that accumulates this index. The file's extension is IX. +% \newindex {foo} defines an index named foo. +% It automatically defines \fooindex such that +% \fooindex ...rest of line... puts an entry in the index foo. +% It also defines \fooindfile to be the number of the output channel for +% the file that accumulates this index. The file's extension is foo. % The name of an index should be no more than 2 characters long % for the sake of vms. % \def\newindex#1{% - \expandafter\chardef\csname#1indfile\endcsname=0 + \iflinks + \expandafter\newwrite \csname#1indfile\endcsname + \openout \csname#1indfile\endcsname \jobname.#1 % Open the file + \fi \expandafter\xdef\csname#1index\endcsname{% % Define @#1index \noexpand\doindex{#1}} } @@ -4841,19 +4072,14 @@ end \def\defcodeindex{\parsearg\newcodeindex} % \def\newcodeindex#1{% - \expandafter\chardef\csname#1indfile\endcsname=0 + \iflinks + \expandafter\newwrite \csname#1indfile\endcsname + \openout \csname#1indfile\endcsname \jobname.#1 + \fi \expandafter\xdef\csname#1index\endcsname{% \noexpand\docodeindex{#1}}% } -% The default indices: -\newindex{cp}% concepts, -\newcodeindex{fn}% functions, -\newcodeindex{vr}% variables, -\newcodeindex{tp}% types, -\newcodeindex{ky}% keys -\newcodeindex{pg}% and programs. - % @synindex foo bar makes index foo feed into index bar. % Do this instead of @defindex foo if you don't want it as a separate index. @@ -4867,7 +4093,14 @@ end % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), % #3 the target index (bar). \def\dosynindex#1#2#3{% - \requireopenindexfile{#3}% + % Only do \closeout if we haven't already done it, else we'll end up + % closing the target index. + \expandafter \ifx\csname donesynindex#2\endcsname \relax + % The \closeout helps reduce unnecessary open files; the limit on the + % Acorn RISC OS is a mere 16 files. + \expandafter\closeout\csname#2indfile\endcsname + \expandafter\let\csname donesynindex#2\endcsname = 1 + \fi % redefine \fooindfile: \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname \expandafter\let\csname#2indfile\endcsname=\temp @@ -4875,76 +4108,108 @@ end \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% } -% Define \doindex, the driver for all index macros. +% Define \doindex, the driver for all \fooindex macros. % Argument #1 is generated by the calling \fooindex macro, -% and it is the two-letter name of the index. +% and it is "foo", the name of the index. -\def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx} -\def\doindexxxx #1{\doind{\indexname}{#1}} +% \doindex just uses \parsearg; it calls \doind for the actual work. +% This is because \doind is more useful to call from other macros. + +% There is also \dosubind {index}{topic}{subtopic} +% which makes an entry in a two-level index such as the operation index. + +\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} +\def\singleindexer #1{\doind{\indexname}{#1}} % like the previous two, but they put @code around the argument. -\def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx} -\def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}} +\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} +\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} - -% Used when writing an index entry out to an index file to prevent -% expansion of Texinfo commands that can appear in an index entry. +% Take care of Texinfo commands that can appear in an index entry. +% Since there are some commands we want to expand, and others we don't, +% we have to laboriously prevent expansion for those that we don't. % \def\indexdummies{% \escapechar = `\\ % use backslash in output files. - \definedummyletter\@% - \definedummyletter\ % + \def\@{@}% change to @@ when we switch to @ as escape char in index files. + \def\ {\realbackslash\space }% % - % For texindex which always views { and } as separators. - \def\{{\lbracechar{}}% - \def\}{\rbracechar{}}% + % Need these in case \tex is in effect and \{ is a \delimiter again. + % But can't use \lbracecmd and \rbracecmd because texindex assumes + % braces and backslashes are used only as delimiters. + \let\{ = \mylbrace + \let\} = \myrbrace + % + % I don't entirely understand this, but when an index entry is + % generated from a macro call, the \endinput which \scanmacro inserts + % causes processing to be prematurely terminated. This is, + % apparently, because \indexsorttmp is fully expanded, and \endinput + % is an expandable command. The redefinition below makes \endinput + % disappear altogether for that purpose -- although logging shows that + % processing continues to some further point. On the other hand, it + % seems \endinput does not hurt in the printed index arg, since that + % is still getting written without apparent harm. + % + % Sample source (mac-idx3.tex, reported by Graham Percival to + % help-texinfo, 22may06): + % @macro funindex {WORD} + % @findex xyz + % @end macro + % ... + % @funindex commtest + % + % The above is not enough to reproduce the bug, but it gives the flavor. + % + % Sample whatsit resulting: + % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}} + % + % So: + \let\endinput = \empty % % Do the redefinitions. - \definedummies + \commondummies } -% Used for the aux and toc files, where @ is the escape character. +% For the aux and toc files, @ is the escape character. So we want to +% redefine everything using @ as the escape character (instead of +% \realbackslash, still used for index files). When everything uses @, +% this will be simpler. % \def\atdummies{% - \definedummyletter\@% - \definedummyletter\ % - \definedummyletter\{% - \definedummyletter\}% + \def\@{@@}% + \def\ {@ }% + \let\{ = \lbraceatcmd + \let\} = \rbraceatcmd % % Do the redefinitions. - \definedummies + \commondummies \otherbackslash } -% \definedummyword defines \#1 as \string\#1\space, thus effectively -% preventing its expansion. This is used only for control words, -% not control letters, because the \space would be incorrect for -% control characters, but is needed to separate the control word -% from whatever follows. +% Called from \indexdummies and \atdummies. % -% These can be used both for control words that take an argument and -% those that do not. If it is followed by {arg} in the input, then -% that will dutifully get written to the index (or wherever). -% -% For control letters, we have \definedummyletter, which omits the -% space. -% -\def\definedummyword #1{\def#1{\string#1\space}}% -\def\definedummyletter#1{\def#1{\string#1}}% -\let\definedummyaccent\definedummyletter - -% Called from \indexdummies and \atdummies, to effectively prevent -% the expansion of commands. -% -\def\definedummies{% +\def\commondummies{% + % + % \definedummyword defines \#1 as \string\#1\space, thus effectively + % preventing its expansion. This is used only for control% words, + % not control letters, because the \space would be incorrect for + % control characters, but is needed to separate the control word + % from whatever follows. + % + % For control letters, we have \definedummyletter, which omits the + % space. + % + % These can be used both for control words that take an argument and + % those that do not. If it is followed by {arg} in the input, then + % that will dutifully get written to the index (or wherever). + % + \def\definedummyword ##1{\def##1{\string##1\space}}% + \def\definedummyletter##1{\def##1{\string##1}}% + \let\definedummyaccent\definedummyletter % - \let\commondummyword\definedummyword - \let\commondummyletter\definedummyletter - \let\commondummyaccent\definedummyaccent \commondummiesnofonts % \definedummyletter\_% - \definedummyletter\-% % % Non-English letters. \definedummyword\AA @@ -4981,27 +4246,20 @@ end \definedummyword\TeX % % Assorted special characters. - \definedummyword\atchar - \definedummyword\arrow \definedummyword\bullet \definedummyword\comma \definedummyword\copyright \definedummyword\registeredsymbol \definedummyword\dots \definedummyword\enddots - \definedummyword\entrybreak \definedummyword\equiv \definedummyword\error \definedummyword\euro - \definedummyword\expansion - \definedummyword\geq \definedummyword\guillemetleft \definedummyword\guillemetright \definedummyword\guilsinglleft \definedummyword\guilsinglright - \definedummyword\lbracechar - \definedummyword\leq - \definedummyword\mathopsup + \definedummyword\expansion \definedummyword\minus \definedummyword\ogonek \definedummyword\pounds @@ -5013,138 +4271,81 @@ end \definedummyword\quoteleft \definedummyword\quoteright \definedummyword\quotesinglbase - \definedummyword\rbracechar \definedummyword\result - \definedummyword\sub - \definedummyword\sup \definedummyword\textdegree % % We want to disable all macros so that they are not expanded by \write. \macrolist - \let\value\dummyvalue % \normalturnoffactive + % + % Handle some cases of @value -- where it does not contain any + % (non-fully-expandable) commands. + \makevalueexpandable } -% \commondummiesnofonts: common to \definedummies and \indexnofonts. -% Define \commondummyletter, \commondummyaccent and \commondummyword before -% using. Used for accents, font commands, and various control letters. +% \commondummiesnofonts: common to \commondummies and \indexnofonts. % \def\commondummiesnofonts{% % Control letters and accents. - \commondummyletter\!% - \commondummyaccent\"% - \commondummyaccent\'% - \commondummyletter\*% - \commondummyaccent\,% - \commondummyletter\.% - \commondummyletter\/% - \commondummyletter\:% - \commondummyaccent\=% - \commondummyletter\?% - \commondummyaccent\^% - \commondummyaccent\`% - \commondummyaccent\~% - \commondummyword\u - \commondummyword\v - \commondummyword\H - \commondummyword\dotaccent - \commondummyword\ogonek - \commondummyword\ringaccent - \commondummyword\tieaccent - \commondummyword\ubaraccent - \commondummyword\udotaccent - \commondummyword\dotless + \definedummyletter\!% + \definedummyaccent\"% + \definedummyaccent\'% + \definedummyletter\*% + \definedummyaccent\,% + \definedummyletter\.% + \definedummyletter\/% + \definedummyletter\:% + \definedummyaccent\=% + \definedummyletter\?% + \definedummyaccent\^% + \definedummyaccent\`% + \definedummyaccent\~% + \definedummyword\u + \definedummyword\v + \definedummyword\H + \definedummyword\dotaccent + \definedummyword\ogonek + \definedummyword\ringaccent + \definedummyword\tieaccent + \definedummyword\ubaraccent + \definedummyword\udotaccent + \definedummyword\dotless % % Texinfo font commands. - \commondummyword\b - \commondummyword\i - \commondummyword\r - \commondummyword\sansserif - \commondummyword\sc - \commondummyword\slanted - \commondummyword\t + \definedummyword\b + \definedummyword\i + \definedummyword\r + \definedummyword\sc + \definedummyword\t % % Commands that take arguments. - \commondummyword\abbr - \commondummyword\acronym - \commondummyword\anchor - \commondummyword\cite - \commondummyword\code - \commondummyword\command - \commondummyword\dfn - \commondummyword\dmn - \commondummyword\email - \commondummyword\emph - \commondummyword\env - \commondummyword\file - \commondummyword\image - \commondummyword\indicateurl - \commondummyword\inforef - \commondummyword\kbd - \commondummyword\key - \commondummyword\math - \commondummyword\option - \commondummyword\pxref - \commondummyword\ref - \commondummyword\samp - \commondummyword\strong - \commondummyword\tie - \commondummyword\U - \commondummyword\uref - \commondummyword\url - \commondummyword\var - \commondummyword\verb - \commondummyword\w - \commondummyword\xref + \definedummyword\acronym + \definedummyword\cite + \definedummyword\code + \definedummyword\command + \definedummyword\dfn + \definedummyword\email + \definedummyword\emph + \definedummyword\env + \definedummyword\file + \definedummyword\kbd + \definedummyword\key + \definedummyword\math + \definedummyword\option + \definedummyword\pxref + \definedummyword\ref + \definedummyword\samp + \definedummyword\strong + \definedummyword\tie + \definedummyword\uref + \definedummyword\url + \definedummyword\var + \definedummyword\verb + \definedummyword\w + \definedummyword\xref } -% For testing: output @{ and @} in index sort strings as \{ and \}. -\newif\ifusebracesinindexes - -\let\indexlbrace\relax -\let\indexrbrace\relax - -{\catcode`\@=0 -\catcode`\\=13 - @gdef@backslashdisappear{@def\{}} -} - -{ -\catcode`\<=13 -\catcode`\-=13 -\catcode`\`=13 - \gdef\indexnonalnumdisappear{% - \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else - % @set txiindexlquoteignore makes us ignore left quotes in the sort term. - % (Introduced for FSFS 2nd ed.) - \let`=\empty - \fi - % - \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else - \backslashdisappear - \fi - % - \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else - \def-{}% - \fi - \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else - \def<{}% - \fi - \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else - \def\@{}% - \fi - } - - \gdef\indexnonalnumreappear{% - \useindexbackslash - \let-\normaldash - \let<\normalless - \def\@{@}% - } -} - - % \indexnofonts is used when outputting the strings to sort the index % by, and when constructing control sequence names. It eliminates all % control sequences and just writes whatever the best ASCII sort string @@ -5152,11 +4353,12 @@ end % \def\indexnofonts{% % Accent commands should become @asis. - \def\commondummyaccent##1{\let##1\asis}% + \def\definedummyaccent##1{\let##1\asis}% % We can just ignore other control letters. - \def\commondummyletter##1{\let##1\empty}% - % All control words become @asis by default; overrides below. - \let\commondummyword\commondummyaccent + \def\definedummyletter##1{\let##1\empty}% + % Hopefully, all control words can become @asis. + \let\definedummyword\definedummyaccent + % \commondummiesnofonts % % Don't no-op \tt, since it isn't a user-level command @@ -5166,13 +4368,8 @@ end % \def\ { }% \def\@{@}% + % how to handle braces? \def\_{\normalunderscore}% - \def\-{}% @- shouldn't affect sorting - % - \uccode`\1=`\{ \uppercase{\def\{{1}}% - \uccode`\1=`\} \uppercase{\def\}{1}}% - \let\lbracechar\{% - \let\rbracechar\}% % % Non-English letters. \def\AA{AA}% @@ -5181,7 +4378,7 @@ end \def\L{L}% \def\OE{OE}% \def\O{O}% - \def\TH{TH}% + \def\TH{ZZZ}% \def\aa{aa}% \def\ae{ae}% \def\dh{dzz}% @@ -5193,45 +4390,39 @@ end \def\o{o}% \def\questiondown{?}% \def\ss{ss}% - \def\th{th}% + \def\th{zzz}% % \def\LaTeX{LaTeX}% \def\TeX{TeX}% % - % Assorted special characters. \defglyph gives the control sequence a - % definition that removes the {} that follows its use. - \defglyph\atchar{@}% - \defglyph\arrow{->}% - \defglyph\bullet{bullet}% - \defglyph\comma{,}% - \defglyph\copyright{copyright}% - \defglyph\dots{...}% - \defglyph\enddots{...}% - \defglyph\equiv{==}% - \defglyph\error{error}% - \defglyph\euro{euro}% - \defglyph\expansion{==>}% - \defglyph\geq{>=}% - \defglyph\guillemetleft{<<}% - \defglyph\guillemetright{>>}% - \defglyph\guilsinglleft{<}% - \defglyph\guilsinglright{>}% - \defglyph\leq{<=}% - \defglyph\lbracechar{\{}% - \defglyph\minus{-}% - \defglyph\point{.}% - \defglyph\pounds{pounds}% - \defglyph\print{-|}% - \defglyph\quotedblbase{"}% - \defglyph\quotedblleft{"}% - \defglyph\quotedblright{"}% - \defglyph\quoteleft{`}% - \defglyph\quoteright{'}% - \defglyph\quotesinglbase{,}% - \defglyph\rbracechar{\}}% - \defglyph\registeredsymbol{R}% - \defglyph\result{=>}% - \defglyph\textdegree{o}% + % Assorted special characters. + % (The following {} will end up in the sort string, but that's ok.) + \def\bullet{bullet}% + \def\comma{,}% + \def\copyright{copyright}% + \def\dots{...}% + \def\enddots{...}% + \def\equiv{==}% + \def\error{error}% + \def\euro{euro}% + \def\expansion{==>}% + \def\guillemetleft{<<}% + \def\guillemetright{>>}% + \def\guilsinglleft{<}% + \def\guilsinglright{>}% + \def\minus{-}% + \def\point{.}% + \def\pounds{pounds}% + \def\print{-|}% + \def\quotedblbase{"}% + \def\quotedblleft{"}% + \def\quotedblright{"}% + \def\quoteleft{`}% + \def\quoteright{'}% + \def\quotesinglbase{,}% + \def\registeredsymbol{R}% + \def\result{=>}% + \def\textdegree{o}% % % We need to get rid of all macros, leaving only the arguments (if present). % Of course this is not nearly correct, but it is the best we can do for now. @@ -5244,24 +4435,16 @@ end % goes to end-of-line is not handled. % \macrolist - \let\value\indexnofontsvalue } -\def\defglyph#1#2{\def#1##1{#2}} % see above - - - +\let\indexbackslash=0 %overridden during \printindex. \let\SETmarginindex=\relax % put index entries in margin (undocumented)? % Most index entries go through here, but \dosubind is the general case. % #1 is the index name, #2 is the entry text. \def\doind#1#2{\dosubind{#1}{#2}{}} -% There is also \dosubind {index}{topic}{subtopic} -% which makes an entry in a two-level index such as the operation index. -% TODO: Two-level index? Operation index? - -% Workhorse for all indexes. +% Workhorse for all \fooindexes. % #1 is name of index, #2 is stuff to put there, #3 is subentry -- % empty if called from \doind, as we usually are (the main exception % is with most defuns, which call us directly). @@ -5269,7 +4452,6 @@ end \def\dosubind#1#2#3{% \iflinks {% - \requireopenindexfile{#1}% % Store the main index entry text (including the third arg). \toks0 = {#2}% % If third arg is present, precede it with a space. @@ -5285,50 +4467,7 @@ end \fi } -% Check if an index file has been opened, and if not, open it. -\def\requireopenindexfile#1{% -\ifnum\csname #1indfile\endcsname=0 - \expandafter\newwrite \csname#1indfile\endcsname - \edef\suffix{#1}% - % A .fls suffix would conflict with the file extension for the output - % of -recorder, so use .f1s instead. - \ifx\suffix\indexisfl\def\suffix{f1}\fi - % Open the file - \immediate\openout\csname#1indfile\endcsname \jobname.\suffix - % Using \immediate above here prevents an object entering into the current - % box, which could confound checks such as those in \safewhatsit for - % preceding skips. - \typeout{Writing index file \jobname.\suffix}% -\fi} -\def\indexisfl{fl} - -% Output \ as {\indexbackslash}, because \ is an escape character in -% the index files. -\let\indexbackslash=\relax -{\catcode`\@=0 \catcode`\\=\active - @gdef@useindexbackslash{@def\{{@indexbackslash}}} -} - -% Definition for writing index entry text. -\def\sortas#1{\ignorespaces}% - -% Definition for writing index entry sort key. Should occur at the at -% the beginning of the index entry, like -% @cindex @sortas{september} \september -% The \ignorespaces takes care of following space, but there's no way -% to remove space before it. -{ -\catcode`\-=13 -\gdef\indexwritesortas{% - \begingroup - \indexnonalnumreappear - \indexwritesortasxxx} -\gdef\indexwritesortasxxx#1{% - \xdef\indexsortkey{#1}\endgroup} -} - - -% Write the entry in \toks0 to the index file. +% Write the entry in \toks0 to the index file: % \def\dosubindwrite{% % Put the index entry in the margin if desired. @@ -5338,26 +4477,14 @@ end % % Remember, we are within a group. \indexdummies % Must do this here, since \bf, etc expand at this stage - \useindexbackslash % \indexbackslash isn't defined now so it will be output - % as is; and it will print as backslash. - % The braces around \indexbrace are recognized by texindex. + \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now + % so it will be output as is; and it will print as backslash. % - % Get the string to sort by, by processing the index entry with all - % font commands turned off. + % Process the index entry with all font commands turned off, to + % get the string to sort by. {\indexnofonts - \def\lbracechar{{\indexlbrace}}% - \def\rbracechar{{\indexrbrace}}% - \let\{=\lbracechar - \let\}=\rbracechar - \indexnonalnumdisappear - \xdef\indexsortkey{}% - \let\sortas=\indexwritesortas - \edef\temp{\the\toks0}% - \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas - \ifx\indexsortkey\empty - \xdef\indexsortkey{\temp}% - \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi - \fi + \edef\temp{\the\toks0}% need full expansion + \xdef\indexsorttmp{\temp}% }% % % Set up the complete index entry, with both the sort key and @@ -5367,11 +4494,10 @@ end % sorted result. \edef\temp{% \write\writeto{% - \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}% + \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}% }% \temp } -\newbox\dummybox % used above % Take care of unwanted page breaks/skips around a whatsit: % @@ -5408,9 +4534,10 @@ end % % ..., ready, GO: % -\def\safewhatsit#1{\ifhmode +\def\safewhatsit#1{% +\ifhmode #1% - \else +\else % \lastskip and \lastpenalty cannot both be nonzero simultaneously. \whatsitskip = \lastskip \edef\lastskipmacro{\the\lastskip}% @@ -5434,6 +4561,7 @@ end % to re-insert the same penalty (values >10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: + % % @deffn deffn-whatever % @vindex index-whatever % Description. @@ -5446,7 +4574,8 @@ end % (the whatsit from the \write), so we must insert a \nobreak. \nobreak\vskip\whatsitskip \fi -\fi} +\fi +} % The index entry written in the file actually looks like % \entry {sortstring}{page}{topic} @@ -5496,113 +4625,52 @@ end % \initial {@} % as its first line, TeX doesn't complain about mismatched braces % (because it thinks @} is a control sequence). - \catcode`\@ = 12 - % See comment in \requireopenindexfile. - \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi - \openin 1 \jobname.\indexname s + \catcode`\@ = 11 + \openin 1 \jobname.#1s \ifeof 1 % \enddoublecolumns gets confused if there is no text in the index, % and it loses the chapter title and the aux file entries for the % index. The easiest way to prevent this problem is to make sure % there is some text. \putwordIndexNonexistent - \typeout{No file \jobname.\indexname s.}% \else - \catcode`\\ = 0 % % If the index file exists but is empty, then \openin leaves \ifeof % false. We have to make TeX try to read something from the file, so % it can discover if there is anything in it. - \read 1 to \thisline + \read 1 to \temp \ifeof 1 \putwordIndexIsEmpty \else % Index files are almost Texinfo source, but we use \ as the escape % character. It would be better to use @, but that's too big a change % to make right now. - \def\indexbackslash{\ttbackslash}% - \let\indexlbrace\{ % Likewise, set these sequences for braces - \let\indexrbrace\} % used in the sort key. + \def\indexbackslash{\backslashcurfont}% + \catcode`\\ = 0 + \escapechar = `\\ \begindoublecolumns - \let\dotheinsertentrybox\dotheinsertentryboxwithpenalty - % - % Read input from the index file line by line. - \loopdo - \ifeof1 \else - \read 1 to \nextline - \fi - % - \indexinputprocessing - \thisline - % - \ifeof1\else - \let\thisline\nextline - \repeat - %% + \input \jobname.#1s \enddoublecolumns \fi \fi \closein 1 \endgroup} -\def\loopdo#1\repeat{\def\body{#1}\loopdoxxx} -\def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next} - -\def\indexinputprocessing{% - \ifeof1 - \let\firsttoken\relax - \else - \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}% - \act - \fi -} -\def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken} -\long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1} - % These macros are used by the sorted index file itself. % Change them to control the appearance of the index. -{\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13 -\catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13 -\catcode`\$=3 -\gdef\initialglyphs{% - % Some changes for non-alphabetic characters. Using the glyphs from the - % math fonts looks more consistent than the typewriter font used elsewhere - % for these characters. - \def\indexbackslash{\math{\backslash}}% - \let\\=\indexbackslash +\def\initial#1{{% + % Some minor font changes for the special characters. + \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt % - % Can't get bold backslash so don't use bold forward slash - \catcode`\/=13 - \def/{{\secrmnotbold \normalslash}}% - \def-{{\normaldash\normaldash}}% en dash `--' - \def^{{\chapbf \normalcaret}}% - \def~{{\chapbf \normaltilde}}% - \def\_{% - \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }% - \def|{$\vert$}% - \def<{$\less$}% - \def>{$\gtr$}% - \def+{$\normalplus$}% -}} - -\def\initial{% - \bgroup - \initialglyphs - \initialx -} - -\def\initialx#1{% % Remove any glue we may have, we'll be inserting our own. \removelastskip % % We like breaks before the index initials, so insert a bonus. - % The glue before the bonus allows a little bit of space at the - % bottom of a column to reduce an increase in inter-line spacing. \nobreak - \vskip 0pt plus 5\baselineskip - \penalty -300 - \vskip 0pt plus -5\baselineskip + \vskip 0pt plus 3\baselineskip + \penalty 0 + \vskip 0pt plus -3\baselineskip % % Typeset the initial. Making this add up to a whole number of % baselineskips increases the chance of the dots lining up from column @@ -5610,214 +4678,103 @@ end % we need before each entry, but it's better. % % No shrink because it confuses \balancecolumns. - \vskip 1.67\baselineskip plus 1\baselineskip - \leftline{\secfonts \kern-0.05em \secbf #1}% - % \secfonts is inside the argument of \leftline so that the change of - % \baselineskip will not affect any glue inserted before the vbox that - % \leftline creates. + \vskip 1.67\baselineskip plus .5\baselineskip + \leftline{\secbf #1}% % Do our best not to break after the initial. \nobreak \vskip .33\baselineskip plus .1\baselineskip - \egroup % \initialglyphs -} - -\newdimen\entryrightmargin -\entryrightmargin=0pt +}} % \entry typesets a paragraph consisting of the text (#1), dot leaders, and % then page number (#2) flushed to the right margin. It is used for index % and table of contents entries. The paragraph is indented by \leftskip. % +% A straightforward implementation would start like this: +% \def\entry#1#2{... +% But this freezes the catcodes in the argument, and can cause problems to +% @code, which sets - active. This problem was fixed by a kludge--- +% ``-'' was active throughout whole index, but this isn't really right. +% +% The right solution is to prevent \entry from swallowing the whole text. +% --kasal, 21nov03 \def\entry{% \begingroup - % - % For pdfTeX and XeTeX. - % The redefinition of \domark stops marks being added in \pdflink to - % preserve coloured links across page boundaries. Otherwise the marks - % would get in the way of \lastbox in \insertentrybox. - \let\domark\relax % % Start a new paragraph if necessary, so our assignments below can't % affect previous text. \par % + % Do not fill out the last line with white space. + \parfillskip = 0in + % % No extra space above this paragraph. \parskip = 0in % - % When reading the text of entry, convert explicit line breaks - % from @* into spaces. The user might give these in long section - % titles, for instance. - \def\*{\unskip\space\ignorespaces}% - \def\entrybreak{\hfil\break}% An undocumented command + % Do not prefer a separate line ending with a hyphen to fewer lines. + \finalhyphendemerits = 0 + % + % \hangindent is only relevant when the entry text and page number + % don't both fit on one line. In that case, bob suggests starting the + % dots pretty far over on the line. Unfortunately, a large + % indentation looks wrong when the entry text itself is broken across + % lines. So we use a small indentation and put up with long leaders. + % + % \hangafter is reset to 1 (which is the value we want) at the start + % of each paragraph, so we need not do anything with that. + \hangindent = 2em + % + % When the entry text needs to be broken, just fill out the first line + % with blank space. + \rightskip = 0pt plus1fil + % + % A bit of stretch before each entry for the benefit of balancing + % columns. + \vskip 0pt plus1pt % % Swallow the left brace of the text (first parameter): \afterassignment\doentry \let\temp = } -\def\entrybreak{\unskip\space\ignorespaces}% \def\doentry{% - % Save the text of the entry - \global\setbox\boxA=\hbox\bgroup \bgroup % Instead of the swallowed brace. \noindent \aftergroup\finishentry % And now comes the text of the entry. - % Not absorbing as a macro argument reduces the chance of problems - % with catcodes occurring. } -{\catcode`\@=11 -\gdef\finishentry#1{% - \egroup % end box A - \dimen@ = \wd\boxA % Length of text of entry - \global\setbox\boxA=\hbox\bgroup\unhbox\boxA +\def\finishentry#1{% % #1 is the page number. % - % Get the width of the page numbers, and only use - % leaders if they are present. - \global\setbox\boxB = \hbox{#1}% - \ifdim\wd\boxB = 0pt - \null\nobreak\hfill\ % + % The following is kludged to not output a line of dots in the index if + % there are no page numbers. The next person who breaks this will be + % cursed by a Unix daemon. + \setbox\boxA = \hbox{#1}% + \ifdim\wd\boxA = 0pt + \ % \else % + % If we must, put the page number on a line of its own, and fill out + % this line with blank space. (The \hfil is overwhelmed with the + % fill leaders glue in \indexdotfill if the page number does fit.) + \hfil\penalty50 \null\nobreak\indexdotfill % Have leaders before the page number. % + % The `\ ' here is removed by the implicit \unskip that TeX does as + % part of (the primitive) \par. Without it, a spurious underfull + % \hbox ensues. \ifpdf - \pdfgettoks#1.% - \hskip\skip\thinshrinkable\the\toksA + \pdfgettoks#1.% + \ \the\toksA \else - \ifx\XeTeXrevision\thisisundefined - \hskip\skip\thinshrinkable #1% - \else - \pdfgettoks#1.% - \hskip\skip\thinshrinkable\the\toksA - \fi + \ #1% \fi \fi - \egroup % end \boxA - \ifdim\wd\boxB = 0pt - \global\setbox\entrybox=\vbox{\unhbox\boxA}% - \else - \global\setbox\entrybox=\vbox\bgroup - % We want the text of the entries to be aligned to the left, and the - % page numbers to be aligned to the right. - % - \parindent = 0pt - \advance\leftskip by 0pt plus 1fil - \advance\leftskip by 0pt plus -1fill - \rightskip = 0pt plus -1fil - \advance\rightskip by 0pt plus 1fill - % Cause last line, which could consist of page numbers on their own - % if the list of page numbers is long, to be aligned to the right. - \parfillskip=0pt plus -1fill - % - \advance\rightskip by \entryrightmargin - % Determine how far we can stretch into the margin. - % This allows, e.g., "Appendix H GNU Free Documentation License" to - % fit on one line in @letterpaper format. - \ifdim\entryrightmargin>2.1em - \dimen@i=2.1em - \else - \dimen@i=0em - \fi - \advance \parfillskip by 0pt minus 1\dimen@i - % - \dimen@ii = \hsize - \advance\dimen@ii by -1\leftskip - \advance\dimen@ii by -1\entryrightmargin - \advance\dimen@ii by 1\dimen@i - \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line - \ifdim\dimen@ > 0.8\dimen@ii % due to long index text - % Try to split the text roughly evenly. \dimen@ will be the length of - % the first line. - \dimen@ = 0.7\dimen@ - \dimen@ii = \hsize - \ifnum\dimen@>\dimen@ii - % If the entry is too long (for example, if it needs more than - % two lines), use all the space in the first line. - \dimen@ = \dimen@ii - \fi - \advance\leftskip by 0pt plus 1fill % ragged right - \advance \dimen@ by 1\rightskip - \parshape = 2 0pt \dimen@ 0em \dimen@ii - % Ideally we'd add a finite glue at the end of the first line only, - % instead of using \parshape with explicit line lengths, but TeX - % doesn't seem to provide a way to do such a thing. - % - % Indent all lines but the first one. - \advance\leftskip by 1em - \advance\parindent by -1em - \fi\fi - \indent % start paragraph - \unhbox\boxA - % - % Do not prefer a separate line ending with a hyphen to fewer lines. - \finalhyphendemerits = 0 - % - % Word spacing - no stretch - \spaceskip=\fontdimen2\font minus \fontdimen4\font - % - \linepenalty=1000 % Discourage line breaks. - \hyphenpenalty=5000 % Discourage hyphenation. - % - \par % format the paragraph - \egroup % The \vbox - \fi + \par \endgroup - \dotheinsertentrybox -}} - -\newskip\thinshrinkable -\skip\thinshrinkable=.15em minus .15em - -\newbox\entrybox -\def\insertentrybox{% - \ourunvbox\entrybox } -% default definition -\let\dotheinsertentrybox\insertentrybox - -% Use \lastbox to take apart vbox box by box, and add each sub-box -% to the current vertical list. -\def\ourunvbox#1{% -\bgroup % for local binding of \delayedbox - % Remove the last box from box #1 - \global\setbox#1=\vbox{% - \unvbox#1% - \unskip % remove any glue - \unpenalty - \global\setbox\interbox=\lastbox - }% - \setbox\delayedbox=\box\interbox - \ifdim\ht#1=0pt\else - \ourunvbox#1 % Repeat on what's left of the box - \nobreak - \fi - \box\delayedbox -\egroup -} -\newbox\delayedbox -\newbox\interbox - -% Used from \printindex. \firsttoken should be the first token -% after the \entry. If it's not another \entry, we are at the last -% line of a group of index entries, so insert a penalty to discourage -% widowed index entries. -\def\dotheinsertentryboxwithpenalty{% - \ifx\firsttoken\isentry - \else - \penalty 9000 - \fi - \insertentrybox -} -\def\isentry{\entry}% - % Like plain.tex's \dotfill, except uses up at least 1 em. -% The filll stretch here overpowers both the fil and fill stretch to push -% the page number to the right. \def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll} - + \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill} \def\primary #1{\line{#1\hfil}} @@ -5831,11 +4788,7 @@ end \ifpdf \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. \else - \ifx\XeTeXrevision\thisisundefined - #2 - \else - \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. - \fi + #2 \fi \par }} @@ -5843,37 +4796,12 @@ end % Define two-column mode, which we use to typeset indexes. % Adapted from the TeXbook, page 416, which is to say, % the manmac.tex format used to print the TeXbook itself. -\catcode`\@=11 % private names +\catcode`\@=11 \newbox\partialpage \newdimen\doublecolumnhsize -% Use inside an output routine to save \topmark and \firstmark -\def\savemarks{% - \global\savedtopmark=\expandafter{\topmark }% - \global\savedfirstmark=\expandafter{\firstmark }% -} -\newtoks\savedtopmark -\newtoks\savedfirstmark - -% Set \topmark and \firstmark for next time \output runs. -% Can't be run from withinside \output (because any material -% added while an output routine is active, including -% penalties, is saved for after it finishes). The page so far -% should be empty, otherwise what's on it will be thrown away. -\def\restoremarks{% - \mark{\the\savedtopmark}% - \bgroup\output = {% - \setbox\dummybox=\box\PAGE - }abc\eject\egroup - % "abc" because output routine doesn't fire for a completely empty page. - \mark{\the\savedfirstmark}% -} - \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns - % If not much space left on page, start a new page. - \ifdim\pagetotal>0.8\vsize\vfill\eject\fi - % % Grab any single-column material above us. \output = {% % @@ -5893,15 +4821,8 @@ end \unvbox\PAGE \kern-\topskip \kern\baselineskip }% - \savemarks }% \eject % run that output routine to set \partialpage - \restoremarks - % - % We recover the two marks that the last output routine saved in order - % to propagate the information in marks added around a chapter heading, - % which could be otherwise be lost by the time the final page is output. - % % % Use the double-column output routine for subsequent pages. \output = {\doublecolumnout}% @@ -5927,31 +4848,27 @@ end \divide\doublecolumnhsize by 2 \hsize = \doublecolumnhsize % - % Double the \vsize as well. - \advance\vsize by -\ht\partialpage + % Double the \vsize as well. (We don't need a separate register here, + % since nobody clobbers \vsize.) \vsize = 2\vsize - % - % For the benefit of balancing columns - \advance\baselineskip by 0pt plus 0.5pt } % The double-column output routine for all double-column pages except -% the last, which is done by \balancecolumns. +% the last. % \def\doublecolumnout{% - % \splittopskip=\topskip \splitmaxdepth=\maxdepth % Get the available space for the double columns -- the normal % (undoubled) page height minus any material left over from the % previous page. \dimen@ = \vsize \divide\dimen@ by 2 + \advance\dimen@ by -\ht\partialpage % % box0 will be the left-hand column, box2 the right. - \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@ - \global\advance\vsize by 2\ht\partialpage + \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ \onepageout\pagesofar - \unvbox\PAGE + \unvbox255 \penalty\outputpenalty } % @@ -5962,11 +4879,10 @@ end % \hsize = \doublecolumnhsize \wd0=\hsize \wd2=\hsize - \hbox to\txipagewidth{\box0\hfil\box2}% + \hbox to\pagewidth{\box0\hfil\box2}% } - - -% Finished with with double columns. +% +% All done with double columns. \def\enddoublecolumns{% % The following penalty ensures that the page builder is exercised % _before_ we change the output routine. This is necessary in the @@ -5989,7 +4905,7 @@ end % goal. When TeX sees \eject from below which follows the final % section, it invokes the new output routine that we've set after % \balancecolumns below; \onepageout will try to fit the two columns - % and the final section into the vbox of \txipageheight (see + % and the final section into the vbox of \pageheight (see % \pagebody), causing an overfull box. % % Note that glue won't work here, because glue does not exercise the @@ -5997,88 +4913,53 @@ end \penalty0 % \output = {% - % Split the last of the double-column material. - \savemarks + % Split the last of the double-column material. Leave it on the + % current page, no automatic page break. \balancecolumns - }% - \eject % call the \output just set - \ifdim\pagetotal=0pt - % Having called \balancecolumns once, we do not + % + % If we end up splitting too much material for the current page, + % though, there will be another page break right after this \output + % invocation ends. Having called \balancecolumns once, we do not % want to call it again. Therefore, reset \output to its normal - % definition right away. + % definition right away. (We hope \balancecolumns will never be + % called on to balance too much material, but if it is, this makes + % the output somewhat more palatable.) \global\output = {\onepageout{\pagecontents\PAGE}}% - % - \endgroup % started in \begindoublecolumns - \restoremarks - % Leave the double-column material on the current page, no automatic - % page break. - \box\balancedcolumns - % - % \pagegoal was set to the doubled \vsize above, since we restarted - % the current page. We're now back to normal single-column - % typesetting, so reset \pagegoal to the normal \vsize. - \global\vsize = \txipageheight % - \pagegoal = \txipageheight % - \else - % We had some left-over material. This might happen when \doublecolumnout - % is called in \balancecolumns. Try again. - \expandafter\enddoublecolumns - \fi + }% + \eject + \endgroup % started in \begindoublecolumns + % + % \pagegoal was set to the doubled \vsize above, since we restarted + % the current page. We're now back to normal single-column + % typesetting, so reset \pagegoal to the normal \vsize (after the + % \endgroup where \vsize got restored). + \pagegoal = \vsize } -\newbox\balancedcolumns -\setbox\balancedcolumns=\vbox{shouldnt see this}% % -% Only called for the last of the double column material. \doublecolumnout -% does the others. +% Called at the end of the double column material. \def\balancecolumns{% - \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120. + \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. \dimen@ = \ht0 \advance\dimen@ by \topskip \advance\dimen@ by-\baselineskip - \ifdim\dimen@<5\baselineskip - % Don't split a short final column in two. - \setbox2=\vbox{}% - \global\setbox\balancedcolumns=\vbox{\pagesofar}% - \else - \divide\dimen@ by 2 % target to split to - \dimen@ii = \dimen@ - \splittopskip = \topskip - % Loop until left column is at least as high as the right column. - {% - \vbadness = 10000 - \loop - \global\setbox3 = \copy0 - \global\setbox1 = \vsplit3 to \dimen@ - \ifdim\ht1<\ht3 - \global\advance\dimen@ by 1pt - \repeat - }% - % Now the left column is in box 1, and the right column in box 3. - % - % Check whether the left column has come out higher than the page itself. - % (Note that we have doubled \vsize for the double columns, so - % the actual height of the page is 0.5\vsize). - \ifdim2\ht1>\vsize - % It appears that we have been called upon to balance too much material. - % Output some of it with \doublecolumnout, leaving the rest on the page. - \setbox\PAGE=\box0 - \doublecolumnout - \else - % Compare the heights of the two columns. - \ifdim4\ht1>5\ht3 - % Column heights are too different, so don't make their bottoms - % flush with each other. - \setbox2=\vbox to \ht1 {\unvbox3\vfill}% - \setbox0=\vbox to \ht1 {\unvbox1\vfill}% - \else - % Make column bottoms flush with each other. - \setbox2=\vbox to\ht1{\unvbox3\unskip}% - \setbox0=\vbox to\ht1{\unvbox1\unskip}% - \fi - \global\setbox\balancedcolumns=\vbox{\pagesofar}% - \fi - \fi + \divide\dimen@ by 2 % target to split to + %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% + \splittopskip = \topskip + % Loop until we get a decent breakpoint. + {% + \vbadness = 10000 + \loop + \global\setbox3 = \copy0 + \global\setbox1 = \vsplit3 to \dimen@ + \ifdim\ht3>\dimen@ + \global\advance\dimen@ by 1pt + \repeat + }% + %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% + \setbox0=\vbox to\dimen@{\unvbox1}% + \setbox2=\vbox to\dimen@{\unvbox3}% % + \pagesofar } \catcode`\@ = \other @@ -6086,26 +4967,7 @@ end \message{sectioning,} % Chapters, sections, etc. -% Let's start with @part. -\outer\parseargdef\part{\partzzz{#1}} -\def\partzzz#1{% - \chapoddpage - \null - \vskip.3\vsize % move it down on the page a bit - \begingroup - \noindent \titlefonts\rm #1\par % the text - \let\lastnode=\empty % no node to associate with - \writetocentry{part}{#1}{}% but put it in the toc - \headingsoff % no headline or footline on the part page - % This outputs a mark at the end of the page that clears \thischapter - % and \thissection, as is done in \startcontents. - \let\pchapsepmacro\relax - \chapmacro{}{Yomitfromtoc}{}% - \chapoddpage - \endgroup -} - -% \unnumberedno is an oxymoron. But we count the unnumbered +% \unnumberedno is an oxymoron, of course. But we count the unnumbered % sections so that we can refer to them unambiguously in the pdf % outlines by their "section number". We avoid collisions with chapter % numbers by starting them at 10000. (If a document ever has 10000 @@ -6184,8 +5046,8 @@ end \chardef\maxseclevel = 3 % % A numbered section within an unnumbered changes to unnumbered too. -% To achieve this, remember the "biggest" unnum. sec. we are currently in: -\chardef\unnlevel = \maxseclevel +% To achive this, remember the "biggest" unnum. sec. we are currently in: +\chardef\unmlevel = \maxseclevel % % Trace whether the current chapter is an appendix or not: % \chapheadtype is "N" or "A", unnumbered chapters are ignored. @@ -6210,8 +5072,8 @@ end % The heading type: \def\headtype{#1}% \if \headtype U% - \ifnum \absseclevel < \unnlevel - \chardef\unnlevel = \absseclevel + \ifnum \absseclevel < \unmlevel + \chardef\unmlevel = \absseclevel \fi \else % Check for appendix sections: @@ -6223,10 +5085,10 @@ end \fi\fi \fi % Check for numbered within unnumbered: - \ifnum \absseclevel > \unnlevel + \ifnum \absseclevel > \unmlevel \def\headtype{U}% \else - \chardef\unnlevel = 3 + \chardef\unmlevel = 3 \fi \fi % Now print the heading: @@ -6312,8 +5174,7 @@ end \global\let\subsubsection = \appendixsubsubsec } -% normally unnmhead0 calls unnumberedzzz: -\outer\parseargdef\unnumbered{\unnmhead0{#1}} +\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz \def\unnumberedzzz#1{% \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 \global\advance\unnumberedno by 1 @@ -6345,6 +5206,9 @@ end % @centerchap is like @unnumbered, but the heading is centered. \outer\parseargdef\centerchap{% + % Well, we could do the following in a group, but that would break + % an assumption that \chapmacro is called at the outermost level. + % Thus we are safer this way: --kasal, 24feb04 \let\centerparametersmaybe = \centerparameters \unnmhead0{#1}% \let\centerparametersmaybe = \relax @@ -6354,47 +5218,40 @@ end \let\top\unnumbered % Sections. -% \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz \def\seczzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% } -% normally calls appendixsectionzzz: -\outer\parseargdef\appendixsection{\apphead1{#1}} +\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz \def\appendixsectionzzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% } \let\appendixsec\appendixsection -% normally calls unnumberedseczzz: -\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} +\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz \def\unnumberedseczzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% } % Subsections. -% -% normally calls numberedsubseczzz: -\outer\parseargdef\numberedsubsec{\numhead2{#1}} +\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz \def\numberedsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% } -% normally calls appendixsubseczzz: -\outer\parseargdef\appendixsubsec{\apphead2{#1}} +\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz \def\appendixsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Yappendix}% {\appendixletter.\the\secno.\the\subsecno}% } -% normally calls unnumberedsubseczzz: -\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} +\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz \def\unnumberedsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Ynothing}% @@ -6402,25 +5259,21 @@ end } % Subsubsections. -% -% normally numberedsubsubseczzz: -\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} +\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz \def\numberedsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Ynumbered}% {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% } -% normally appendixsubsubseczzz: -\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} +\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz \def\appendixsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Yappendix}% {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% } -% normally unnumberedsubsubseczzz: -\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} +\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz \def\unnumberedsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Ynothing}% @@ -6436,6 +5289,14 @@ end % Define @majorheading, @heading and @subheading +% NOTE on use of \vbox for chapter headings, section headings, and such: +% 1) We use \vbox rather than the earlier \line to permit +% overlong headings to fold. +% 2) \hyphenpenalty is set to 10000 because hyphenation in a +% heading is obnoxious; this forbids it. +% 3) Likewise, headings look best if no \parindent is used, and +% if justification is not attempted. Hence \raggedright. + \def\majorheading{% {\advance\chapheadingskip by 10pt \chapbreak }% \parsearg\chapheadingzzz @@ -6443,8 +5304,10 @@ end \def\chapheading{\chapbreak \parsearg\chapheadingzzz} \def\chapheadingzzz#1{% - \vbox{\chapfonts \raggedtitlesettings #1\par}% - \nobreak\bigskip \nobreak + {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\ptexraggedright + \rmisbold #1\hfill}}% + \bigskip \par\penalty 200\relax \suppressfirstparagraphindent } @@ -6460,19 +5323,16 @@ end % (including whitespace, linebreaking, etc. around it), % given all the information in convenient, parsed form. -% Args are the skip and penalty (usually negative) +%%% Args are the skip and penalty (usually negative) \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} +%%% Define plain chapter starts, and page on/off switching for it % Parameter controlling skip before chapter headings (if needed) + \newskip\chapheadingskip -% Define plain chapter starts, and page on/off switching for it. \def\chapbreak{\dobreak \chapheadingskip {-4000}} - -% Start a new page \def\chappager{\par\vfill\supereject} - -% \chapoddpage - start on an odd page for a new chapter % Because \domark is called before \chapoddpage, the filler page will % get the headings for the next chapter, which is wrong. But we don't % care -- we just disable all headings on the filler page. @@ -6480,14 +5340,15 @@ end \chappager \ifodd\pageno \else \begingroup - \headingsoff - \null + \evenheadline={\hfil}\evenfootline={\hfil}% + \oddheadline={\hfil}\oddfootline={\hfil}% + \hbox to 0pt{}% \chappager \endgroup \fi } -\parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname} +\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} \def\CHAPPAGoff{% \global\let\contentsalignmacro = \chappager @@ -6508,26 +5369,17 @@ end \CHAPPAGon -% \chapmacro - Chapter opening. +% Chapter opening. % % #1 is the text, #2 is the section type (Ynumbered, Ynothing, % Yappendix, Yomitfromtoc), #3 the chapter number. -% Not used for @heading series. % % To test against our argument. \def\Ynothingkeyword{Ynothing} -\def\Yappendixkeyword{Yappendix} \def\Yomitfromtockeyword{Yomitfromtoc} +\def\Yappendixkeyword{Yappendix} % \def\chapmacro#1#2#3{% - \expandafter\ifx\thisenv\titlepage\else - \checkenv{}% chapters, etc., should not start inside an environment. - \fi - % FIXME: \chapmacro is currently called from inside \titlepage when - % \setcontentsaftertitlepage to print the "Table of Contents" heading, but - % this should probably be done by \sectionheading with an option to print - % in chapter size. - % % Insert the first mark before the heading break (see notes for \domark). \let\prevchapterdefs=\lastchapterdefs \let\prevsectiondefs=\lastsectiondefs @@ -6579,8 +5431,7 @@ end \domark % {% - \chapfonts \rm - \let\footnote=\errfootnoteheading % give better error message + \chapfonts \rmisbold % % Have to define \lastsection before calling \donoderef, because the % xref code eventually uses it. On the other hand, it has to be called @@ -6617,7 +5468,8 @@ end % % Typeset the actual heading. \nobreak % Avoid page breaks at the interline glue. - \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe + \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright + \hangindent=\wd0 \centerparametersmaybe \unhbox0 #1\par}% }% \nobreak\bigskip % no page break after a chapter title @@ -6633,6 +5485,30 @@ end } +% I don't think this chapter style is supported any more, so I'm not +% updating it with the new noderef stuff. We'll see. --karl, 11aug03. +% +\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} +% +\def\unnchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\ptexraggedright + \rmisbold #1\hfill}}\bigskip \par\nobreak +} +\def\chfopen #1#2{\chapoddpage {\chapfonts +\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% +\par\penalty 5000 % +} +\def\centerchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt + \hfill {\rmisbold #1}\hfill}}\bigskip \par\nobreak +} +\def\CHAPFopen{% + \global\let\chapmacro=\chfopen + \global\let\centerchapmacro=\centerchfopen} + + % Section titles. These macros combine the section number parts and % call the generic \sectionheading to do the printing. % @@ -6650,29 +5526,20 @@ end % Print any size, any type, section title. % -% #1 is the text of the title, -% #2 is the section level (sec/subsec/subsubsec), -% #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc), -% #4 is the section number. +% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is +% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the +% section number. % \def\seckeyword{sec} % \def\sectionheading#1#2#3#4{% {% + % Switch to the right set of fonts. + \csname #2fonts\endcsname \rmisbold + % \def\sectionlevel{#2}% \def\temptype{#3}% % - % It is ok for the @heading series commands to appear inside an - % environment (it's been historically allowed, though the logic is - % dubious), but not the others. - \ifx\temptype\Yomitfromtockeyword\else - \checkenv{}% non-@*heading should not be in an environment. - \fi - \let\footnote=\errfootnoteheading - % - % Switch to the right set of fonts. - \csname #2fonts\endcsname \rm - % % Insert first mark before the heading break (see notes for \domark). \let\prevsectiondefs=\lastsectiondefs \ifx\temptype\Ynothingkeyword @@ -6724,7 +5591,7 @@ end % % Now the second mark, after the heading break. No break points % between here and the heading. - \global\let\prevsectiondefs=\lastsectiondefs + \let\prevsectiondefs=\lastsectiondefs \domark % % Only insert the space after the number if we have a section number. @@ -6778,15 +5645,15 @@ end % % We'll almost certainly start a paragraph next, so don't let that % glue accumulate. (Not a breakpoint because it's preceded by a - % discardable item.) However, when a paragraph is not started next - % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out - % or the negative glue will cause weirdly wrong output, typically - % obscuring the section heading with something else. + % discardable item.) \vskip-\parskip % - % This is so the last item on the main vertical list is a known - % \penalty > 10000, so \startdefun, etc., can recognize the situation - % and do the needful. + % This is purely so the last item on the list is a known \penalty > + % 10000. This is so \startdefun can avoid allowing breakpoints after + % section headings. Otherwise, it would insert a valid breakpoint between: + % + % @section sec-whatever + % @deffn def-whatever \penalty 10001 } @@ -6835,14 +5702,7 @@ end % 1 and 2 (the page numbers aren't printed), and so are the first % two pages of the document. Thus, we'd have two destinations named % `1', and two named `2'. - \ifpdf - \global\pdfmakepagedesttrue - \else - \ifx\XeTeXrevision\thisisundefined - \else - \global\pdfmakepagedesttrue - \fi - \fi + \ifpdf \global\pdfmakepagedesttrue \fi } @@ -6891,7 +5751,7 @@ end \savepageno = \pageno \begingroup % Set up to handle contents files properly. \raggedbottom % Worry more about breakpoints than the bottom. - \entryrightmargin=\contentsrightmargin % Don't use the full line length. + \advance\hsize by -\contentsrightmargin % Don't use the full line length. % % Roman numerals for page numbers. \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi @@ -6925,7 +5785,6 @@ end \def\summarycontents{% \startcontents{\putwordShortTOC}% % - \let\partentry = \shortpartentry \let\numchapentry = \shortchapentry \let\appentry = \shortchapentry \let\unnchapentry = \shortunnchapentry @@ -6981,30 +5840,9 @@ end % The last argument is the page number. % The arguments in between are the chapter number, section number, ... -% Parts, in the main contents. Replace the part number, which doesn't -% exist, with an empty box. Let's hope all the numbers have the same width. -% Also ignore the page number, which is conventionally not printed. -\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} -\def\partentry#1#2#3#4{% - % Add stretch and a bonus for breaking the page before the part heading. - % This reduces the chance of the page being broken immediately after the - % part heading, before a following chapter heading. - \vskip 0pt plus 5\baselineskip - \penalty-300 - \vskip 0pt plus -5\baselineskip - \dochapentry{\numeralbox\labelspace#1}{}% -} -% -% Parts, in the short toc. -\def\shortpartentry#1#2#3#4{% - \penalty-300 - \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip - \shortchapentry{{\bf #1}}{\numeralbox}{}{}% -} - % Chapters, in the main contents. \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} - +% % Chapters, in the short toc. % See comments in \dochapentry re vbox and related settings. \def\shortchapentry#1#2#3#4{% @@ -7019,7 +5857,7 @@ end \setbox0 = \hbox{\putwordAppendix{} M}% \hbox to \wd0{\putwordAppendix{} #1\hss}} % -\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}} +\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}} % Unnumbered chapters. \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} @@ -7052,8 +5890,6 @@ end \def\dochapentry#1#2{% \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip \begingroup - % Move the page numbers slightly to the right - \advance\entryrightmargin by -0.05em \chapentryfonts \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup @@ -7093,9 +5929,9 @@ end \message{environments,} % @foo ... @end foo. -% @tex ... @end tex escapes into raw TeX temporarily. +% @tex ... @end tex escapes into raw Tex temporarily. % One exception: @ is still an escape character, so that @end tex works. -% But \@ or @@ will get a plain @ character. +% But \@ or @@ will get a plain tex @ character. \envdef\tex{% \setupmarkupstyle{tex}% @@ -7108,14 +5944,10 @@ end \catcode `\|=\other \catcode `\<=\other \catcode `\>=\other - \catcode `\`=\other - \catcode `\'=\other + \catcode`\`=\other + \catcode`\'=\other + \escapechar=`\\ % - % ' is active in math mode (mathcode"8000). So reset it, and all our - % other math active characters (just in case), to plain's definitions. - \mathactive - % - % Inverse of the list at the beginning of the file. \let\b=\ptexb \let\bullet=\ptexbullet \let\c=\ptexc @@ -7131,11 +5963,9 @@ end \let\+=\tabalign \let\}=\ptexrbrace \let\/=\ptexslash - \let\sp=\ptexsp \let\*=\ptexstar - %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode \let\t=\ptext - \expandafter \let\csname top\endcsname=\ptextop % we've made it outer + \expandafter \let\csname top\endcsname=\ptextop % outer \let\frenchspacing=\plainfrenchspacing % \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% @@ -7165,24 +5995,6 @@ end % start of the next paragraph will insert \parskip. % \def\aboveenvbreak{{% - % =10000 instead of <10000 because of a special case in \itemzzz and - % \sectionheading, q.v. - \ifnum \lastpenalty=10000 \else - \advance\envskipamount by \parskip - \endgraf - \ifdim\lastskip<\envskipamount - \removelastskip - \ifnum\lastpenalty<10000 - % Penalize breaking before the environment, because preceding text - % often leads into it. - \penalty100 - \fi - \vskip\envskipamount - \fi - \fi -}} - -\def\afterenvbreak{{% % =10000 instead of <10000 because of a special case in \itemzzz and % \sectionheading, q.v. \ifnum \lastpenalty=10000 \else @@ -7198,6 +6010,8 @@ end \fi }} +\let\afterenvbreak = \aboveenvbreak + % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will % also clear it, so that its embedded environments do the narrowing again. \let\nonarrowing=\relax @@ -7235,13 +6049,9 @@ end % side, and for 6pt waste from % each corner char, and rule thickness \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip - % - % If this cartouche directly follows a sectioning command, we need the - % \parskip glue (backspaced over by default) or the cartouche can - % collide with the section heading. - \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi - % - \setbox\groupbox=\vbox\bgroup + % Flag to tell @lisp, etc., not to narrow margin. + \let\nonarrowing = t% + \vbox\bgroup \baselineskip=0pt\parskip=0pt\lineskip=0pt \carttop \hbox\bgroup @@ -7254,7 +6064,7 @@ end \lineskip=\normlskip \parskip=\normpskip \vskip -\parskip - \comment % For explanation, see the end of def\group. + \comment % For explanation, see the end of \def\group. } \def\Ecartouche{% \ifhmode\par\fi @@ -7265,7 +6075,6 @@ end \egroup \cartbot \egroup - \addgroupbox \checkinserts } @@ -7275,7 +6084,7 @@ end \newdimen\nonfillparindent \def\nonfillstart{% \aboveenvbreak - \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy + \hfuzz = 12pt % Don't be fussy \sepspaces % Make spaces be word-separators rather than space tokens. \let\par = \lisppar % don't ignore blank lines \obeylines % each line of input is a line of output @@ -7341,42 +6150,41 @@ end } % We often define two environments, @foo and @smallfoo. -% Let's do it in one command. #1 is the env name, #2 the definition. -\def\makedispenvdef#1#2{% - \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}% - \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}% +% Let's do it by one command: +\def\makedispenv #1#2{ + \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2} + \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2} \expandafter\let\csname E#1\endcsname \afterenvbreak \expandafter\let\csname Esmall#1\endcsname \afterenvbreak } -% Define two environment synonyms (#1 and #2) for an environment. -\def\maketwodispenvdef#1#2#3{% - \makedispenvdef{#1}{#3}% - \makedispenvdef{#2}{#3}% +% Define two synonyms: +\def\maketwodispenvs #1#2#3{ + \makedispenv{#1}{#3} + \makedispenv{#2}{#3} } -% -% @lisp: indented, narrowed, typewriter font; -% @example: same as @lisp. + +% @lisp: indented, narrowed, typewriter font; @example: same as @lisp. % % @smallexample and @smalllisp: use smaller fonts. % Originally contributed by Pavel@xerox. % -\maketwodispenvdef{lisp}{example}{% +\maketwodispenvs {lisp}{example}{% \nonfillstart \tt\setupmarkupstyle{example}% \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. - \gobble % eat return + \gobble % eat return } % @display/@smalldisplay: same as @lisp except keep current font. % -\makedispenvdef{display}{% +\makedispenv {display}{% \nonfillstart \gobble } % @format/@smallformat: same as @display except don't narrow margins. % -\makedispenvdef{format}{% +\makedispenv{format}{% \let\nonarrowing = t% \nonfillstart \gobble @@ -7395,20 +6203,16 @@ end \envdef\flushright{% \let\nonarrowing = t% \nonfillstart - \advance\leftskip by 0pt plus 1fill\relax + \advance\leftskip by 0pt plus 1fill \gobble } \let\Eflushright = \afterenvbreak % @raggedright does more-or-less normal line breaking but no right -% justification. From plain.tex. Don't stretch around special -% characters in urls in this environment, since the stretch at the right -% should be enough. +% justification. From plain.tex. \envdef\raggedright{% - \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax - \def\urefprestretchamount{0pt}% - \def\urefpoststretchamount{0pt}% + \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax } \let\Eraggedright\par @@ -7434,28 +6238,43 @@ end % we're doing normal filling. So, when using \aboveenvbreak and % \afterenvbreak, temporarily make \parskip 0. % -\makedispenvdef{quotation}{\quotationstart} -% \def\quotationstart{% - \indentedblockstart % same as \indentedblock, but increase right margin too. + {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip + \parindent=0pt + % + % @cartouche defines \nonarrowing to inhibit narrowing at next level down. \ifx\nonarrowing\relax + \advance\leftskip by \lispnarrowing \advance\rightskip by \lispnarrowing + \exdentamount = \lispnarrowing + \else + \let\nonarrowing = \relax \fi \parsearg\quotationlabel } +\envdef\quotation{% + \setnormaldispenv + \quotationstart +} + +\envdef\smallquotation{% + \setsmalldispenv + \quotationstart +} +\let\Esmallquotation = \Equotation + % We have retained a nonzero parskip for the environment, since we're % doing normal filling. % \def\Equotation{% \par - \ifx\quotationauthor\thisisundefined\else + \ifx\quotationauthor\undefined\else % indent a bit. \leftline{\kern 2\leftskip \sl ---\quotationauthor}% \fi {\parskip=0pt \afterenvbreak}% } -\def\Esmallquotation{\Equotation} % If we're given an argument, typeset it in bold with a colon after. \def\quotationlabel#1{% @@ -7465,32 +6284,6 @@ end \fi } -% @indentedblock is like @quotation, but indents only on the left and -% has no optional argument. -% -\makedispenvdef{indentedblock}{\indentedblockstart} -% -\def\indentedblockstart{% - {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip - \parindent=0pt - % - % @cartouche defines \nonarrowing to inhibit narrowing at next level down. - \ifx\nonarrowing\relax - \advance\leftskip by \lispnarrowing - \exdentamount = \lispnarrowing - \else - \let\nonarrowing = \relax - \fi -} - -% Keep a nonzero parskip for the environment, since we're doing normal filling. -% -\def\Eindentedblock{% - \par - {\parskip=0pt \afterenvbreak}% -} -\def\Esmallindentedblock{\Eindentedblock} - % LaTeX-like @verbatim...@end verbatim and @verb{...} % If we want to allow any as delimiter, @@ -7538,28 +6331,21 @@ end % Setup for the @verbatim environment % -% Real tab expansion. +% Real tab expansion \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount % -% We typeset each line of the verbatim in an \hbox, so we can handle -% tabs. The \global is in case the verbatim line starts with an accent, -% or some other command that starts with a begin-group. Otherwise, the -% entire \verbbox would disappear at the corresponding end-group, before -% it is typeset. Meanwhile, we can't have nested verbatim commands -% (can we?), so the \global won't be overwriting itself. -\newbox\verbbox -\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup} +\def\starttabbox{\setbox0=\hbox\bgroup} % \begingroup \catcode`\^^I=\active \gdef\tabexpand{% \catcode`\^^I=\active \def^^I{\leavevmode\egroup - \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab - \divide\dimen\verbbox by\tabw - \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw - \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw - \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox + \dimen0=\wd0 % the width so far, or since the previous tab + \divide\dimen0 by\tabw + \multiply\dimen0 by\tabw % compute previous multiple of \tabw + \advance\dimen0 by\tabw % advance to next multiple of \tabw + \wd0=\dimen0 \box0 \starttabbox }% } \endgroup @@ -7568,16 +6354,15 @@ end \def\setupverbatim{% \let\nonarrowing = t% \nonfillstart - \tt % easiest (and conventionally used) font for verbatim - % The \leavevmode here is for blank lines. Otherwise, we would - % never \starttabox and the \egroup would end verbatim mode. - \def\par{\leavevmode\egroup\box\verbbox\endgraf}% + % Easiest (and conventionally used) font for verbatim + \tt + \def\par{\leavevmode\egroup\box0\endgraf}% \tabexpand \setupmarkupstyle{verbatim}% % Respect line breaks, % print special symbols as themselves, and - % make each space count. - % Must do in this order: + % make each space count + % must do in this order: \obeylines \uncatcodespecials \sepspaces \everypar{\starttabbox}% } @@ -7634,7 +6419,6 @@ end \makevalueexpandable \setupverbatim \indexnofonts % Allow `@@' and other weird things in file names. - \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}% \input #1 \afterenvbreak }% @@ -7648,7 +6432,7 @@ end % typesetting commands (@smallbook, font changes, etc.) have to be done % beforehand -- and a) we want @copying to be done first in the source % file; b) letting users define the frontmatter in as flexible order as -% possible is desirable. +% possible is very desirable. % \def\copying{\checkenv{}\begingroup\scanargctxt\docopying} \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} @@ -7684,7 +6468,7 @@ end % commands also insert a nobreak penalty, and we don't want to allow % a break between a section heading and a defun. % - % As a further refinement, we avoid "club" headers by signalling + % As a minor refinement, we avoid "club" headers by signalling % with penalty of 10003 after the very first @deffn in the % sequence (see above), and penalty of 10002 after any following % @def command. @@ -7721,7 +6505,7 @@ end #1#2 \endheader % common ending: \interlinepenalty = 10000 - \advance\rightskip by 0pt plus 1fil\relax + \advance\rightskip by 0pt plus 1fil \endgraf \nobreak\vskip -\parskip \penalty\defunpenalty % signal to \startdefun and \dodefunx @@ -7743,7 +6527,7 @@ end \temp } -% \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) } +% \domakedefun \deffn \deffnx \deffnheader % % Define \deffn and \deffnx, without parameters. % \deffnheader has to be defined explicitly. @@ -7751,36 +6535,13 @@ end \def\domakedefun#1#2#3{% \envdef#1{% \startdefun - \doingtypefnfalse % distinguish typed functions from all else \parseargusing\activeparens{\printdefunline#3}% }% \def#2{\dodefunx#1}% \def#3% } -\newif\ifdoingtypefn % doing typed function? -\newif\ifrettypeownline % typeset return type on its own line? - -% @deftypefnnewline on|off says whether the return type of typed functions -% are printed on their own line. This affects @deftypefn, @deftypefun, -% @deftypeop, and @deftypemethod. -% -\parseargdef\deftypefnnewline{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETtxideftypefnnl\endcsname - = \empty - \else\ifx\temp\offword - \expandafter\let\csname SETtxideftypefnnl\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @txideftypefnnl value `\temp', - must be on|off}% - \fi\fi -} - -% Untyped functions: +%%% Untyped functions: % @deffn category name args \makedefun{deffn}{\deffngeneral{}} @@ -7799,7 +6560,7 @@ end \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% } -% Typed functions: +%%% Typed functions: % @deftypefn category type name args \makedefun{deftypefn}{\deftypefngeneral{}} @@ -7814,11 +6575,10 @@ end % \def\deftypefngeneral#1#2 #3 #4 #5\endheader{% \dosubind{fn}{\code{#4}}{#1}% - \doingtypefntrue \defname{#2}{#3}{#4}\defunargs{#5\unskip}% } -% Typed variables: +%%% Typed variables: % @deftypevr category type var args \makedefun{deftypevr}{\deftypecvgeneral{}} @@ -7836,7 +6596,7 @@ end \defname{#2}{#3}{#4}\defunargs{#5\unskip}% } -% Untyped variables: +%%% Untyped variables: % @defvr category var args \makedefun{defvr}#1 {\deftypevrheader{#1} {} } @@ -7847,8 +6607,7 @@ end % \defcvof {category of}class var args \def\defcvof#1#2 {\deftypecvof{#1}#2 {} } -% Types: - +%%% Type: % @deftp category name args \makedefun{deftp}#1 #2 #3\endheader{% \doind{tp}{\code{#2}}% @@ -7876,49 +6635,25 @@ end % We are followed by (but not passed) the arguments, if any. % \def\defname#1#2#3{% - \par % Get the values of \leftskip and \rightskip as they were outside the @def... \advance\leftskip by -\defbodyindent % - % Determine if we are typesetting the return type of a typed function - % on a line by itself. - \rettypeownlinefalse - \ifdoingtypefn % doing a typed function specifically? - % then check user option for putting return type on its own line: - \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else - \rettypeownlinetrue - \fi - \fi - % - % How we'll format the category name. Putting it in brackets helps + % How we'll format the type name. Putting it in brackets helps % distinguish it from the body text that may end up on the next line % just below it. \def\temp{#1}% \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} % - % Figure out line sizes for the paragraph shape. We'll always have at - % least two. - \tempnum = 2 - % + % Figure out line sizes for the paragraph shape. % The first line needs space for \box0; but if \rightskip is nonzero, % we need only space for the part of \box0 which exceeds it: \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip - % - % If doing a return type on its own line, we'll have another line. - \ifrettypeownline - \advance\tempnum by 1 - \def\maybeshapeline{0in \hsize}% - \else - \def\maybeshapeline{}% - \fi - % % The continuations: \dimen2=\hsize \advance\dimen2 by -\defargsindent + % (plain.tex says that \dimen1 should be used only as global.) + \parshape 2 0in \dimen0 \defargsindent \dimen2 % - % The final paragraph shape: - \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2 - % - % Put the category name at the right margin. + % Put the type name to the right margin. \noindent \hbox to 0pt{% \hfil\box0 \kern-\hsize @@ -7940,19 +6675,11 @@ end % . this still does not fix the ?` and !` ligatures, but so far no % one has made identifiers using them :). \df \tt - \def\temp{#2}% text of the return type - \ifx\temp\empty\else - \tclose{\temp}% typeset the return type - \ifrettypeownline - % put return type on its own line; prohibit line break following: - \hfil\vadjust{\nobreak}\break - \else - \space % type on same line, so just followed by a space - \fi - \fi % no return type + \def\temp{#2}% return value type + \ifx\temp\empty\else \tclose{\temp} \fi #3% output function name }% - {\rm\enskip}% hskip 0.5 em of \rmfont + {\rm\enskip}% hskip 0.5 em of \tenrm % \boldbrax % arguments will be output next, if any. @@ -7969,10 +6696,7 @@ end \df \sl \hyphenchar\font=0 % % On the other hand, if an argument has two dashes (for instance), we - % want a way to get ttsl. We used to recommend @var for that, so - % leave the code in, but it's strange for @var to lead to typewriter. - % Nowadays we recommend @code, since the difference between a ttsl hyphen - % and a tt hyphen is pretty tiny. @code also disables ?` !`. + % want a way to get ttsl. Let's try @var for that. \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}% #1% \sl\hyphenchar\font=45 @@ -8070,7 +6794,7 @@ end % To do this right we need a feature of e-TeX, \scantokens, % which we arrange to emulate with a temporary file in ordinary TeX. -\ifx\eTeXversion\thisisundefined +\ifx\eTeXversion\undefined \newwrite\macscribble \def\scantokens#1{% \toks0={#1}% @@ -8081,41 +6805,29 @@ end } \fi -% alias because \c means cedilla in @tex or @math -\let\texinfoc=\c - -\newcount\savedcatcodeone -\newcount\savedcatcodetwo - -% Used at the time of macro expansion. -% Argument is macro body with arguments substituted \def\scanmacro#1{% - \newlinechar`\^^M - \def\xeatspaces{\eatspaces}% - % - % Temporarily undo catcode changes of \printindex. Set catcode of @ to - % 0 so that @-commands in macro expansions aren't printed literally when - % formatting an index file, where \ is used as the escape character. - \savedcatcodeone=\catcode`\@ - \savedcatcodetwo=\catcode`\\ - \catcode`\@=0 - \catcode`\\=\active - % - % Process the macro body under the current catcode regime. - \scantokens{#1@texinfoc}% - % - \catcode`\@=\savedcatcodeone - \catcode`\\=\savedcatcodetwo - % - % The \texinfoc is to remove the \newlinechar added by \scantokens, and - % can be noticed by \parsearg. - % We avoid surrounding the call to \scantokens with \bgroup and \egroup - % to allow macros to open or close groups themselves. + \begingroup + \newlinechar`\^^M + \let\xeatspaces\eatspaces + % Undo catcode changes of \startcontents and \doprintindex + % When called from @insertcopying or (short)caption, we need active + % backslash to get it printed correctly. Previously, we had + % \catcode`\\=\other instead. We'll see whether a problem appears + % with macro expansion. --kasal, 19aug04 + \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ + % ... and \example + \spaceisspace + % + % Append \endinput to make sure that TeX does not see the ending newline. + % I've verified that it is necessary both for e-TeX and for ordinary TeX + % --kasal, 29nov03 + \scantokens{#1\endinput}% + \endgroup } -% Used for copying and captions \def\scanexp#1{% - \expandafter\scanmacro\expandafter{#1}% + \edef\temp{\noexpand\scanmacro{#1}}% + \temp } \newcount\paramno % Count of parameters @@ -8123,7 +6835,7 @@ end \newif\ifrecursive % Is it recursive? % List of all defined macros in the form -% \commondummyword\macro1\commondummyword\macro2... +% \definedummyword\macro1\definedummyword\macro2... % Currently is also contains all @aliases; the list can be split % if there is a need. \def\macrolist{} @@ -8131,7 +6843,7 @@ end % Add the macro to \macrolist \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} \def\addtomacrolistxxx#1{% - \toks0 = \expandafter{\macrolist\commondummyword#1}% + \toks0 = \expandafter{\macrolist\definedummyword#1}% \xdef\macrolist{\the\toks0}% } @@ -8165,60 +6877,46 @@ end % Macro bodies are absorbed as an argument in a context where % all characters are catcode 10, 11 or 12, except \ which is active -% (as in normal texinfo). It is necessary to change the definition of \ -% to recognize macro arguments; this is the job of \mbodybackslash. -% +% (as in normal texinfo). It is necessary to change the definition of \. + % Non-ASCII encodings make 8-bit characters active, so un-activate % them to avoid their expansion. Must do this non-globally, to % confine the change to the current group. -% + % It's necessary to have hard CRs when the macro is executed. This is -% done by making ^^M (\endlinechar) catcode 12 when reading the macro +% done by making ^^M (\endlinechar) catcode 12 when reading the macro % body, and then making it the \newlinechar in \scanmacro. -% -\def\scanctxt{% used as subroutine + +\def\scanctxt{% \catcode`\"=\other \catcode`\+=\other \catcode`\<=\other \catcode`\>=\other + \catcode`\@=\other \catcode`\^=\other \catcode`\_=\other \catcode`\|=\other \catcode`\~=\other - \passthroughcharstrue + \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi } -\def\scanargctxt{% used for copying and captions, not macros. +\def\scanargctxt{% \scanctxt - \catcode`\@=\other \catcode`\\=\other \catcode`\^^M=\other } -\def\macrobodyctxt{% used for @macro definitions +\def\macrobodyctxt{% \scanctxt - \catcode`\ =\other - \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other \catcode`\^^M=\other \usembodybackslash } -% Used when scanning braced macro arguments. Note, however, that catcode -% changes here are ineffectual if the macro invocation was nested inside -% an argument to another Texinfo command. \def\macroargctxt{% \scanctxt - \catcode`\ =\active - \catcode`\^^M=\other - \catcode`\\=\active -} - -\def\macrolineargctxt{% used for whole-line arguments without braces - \scanctxt - \catcode`\{=\other - \catcode`\}=\other + \catcode`\\=\other } % \mbodybackslash is the definition of \ in @macro bodies. @@ -8226,30 +6924,22 @@ end % where N is the macro parameter number. % We define \csname macarg.\endcsname to be \realbackslash, so % \\ in macro replacement text gets you a backslash. -% + {\catcode`@=0 @catcode`@\=@active @gdef@usembodybackslash{@let\=@mbodybackslash} @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} } \expandafter\def\csname macarg.\endcsname{\realbackslash} -\def\margbackslash#1{\char`\#1 } - \def\macro{\recursivefalse\parsearg\macroxxx} \def\rmacro{\recursivetrue\parsearg\macroxxx} \def\macroxxx#1{% - \getargs{#1}% now \macname is the macname and \argl the arglist + \getargs{#1}% now \macname is the macname and \argl the arglist \ifx\argl\empty % no arguments - \paramno=0\relax + \paramno=0% \else \expandafter\parsemargdef \argl;% - \if\paramno>256\relax - \ifx\eTeXversion\thisisundefined - \errhelp = \EMsimple - \errmessage{You need eTeX to compile a file with macros with more than 256 arguments} - \fi - \fi \fi \if1\csname ismacro.\the\macname\endcsname \message{Warning: redefining \the\macname}% @@ -8272,7 +6962,7 @@ end % Remove the macro name from \macrolist: \begingroup \expandafter\let\csname#1\endcsname \relax - \let\commondummyword\unmacrodo + \let\definedummyword\unmacrodo \xdef\macrolist{\macrolist}% \endgroup \else @@ -8287,464 +6977,129 @@ end \ifx #1\relax % remove this \else - \noexpand\commondummyword \noexpand#1% + \noexpand\definedummyword \noexpand#1% \fi } -% \getargs -- Parse the arguments to a @macro line. Set \macname to -% the name of the macro, and \argl to the braced argument list. -\def\getargs#1{\getargsxxx#1{}} -\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} -\def\getmacname#1 #2\relax{\macname={#1}} -\def\getmacargs#1{\def\argl{#1}} -% This made use of the feature that if the last token of a +% This makes use of the obscure feature that if the last token of a % is #, then the preceding argument is delimited by % an opening brace, and that opening brace is not consumed. +\def\getargs#1{\getargsxxx#1{}} +\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} +\def\getmacname #1 #2\relax{\macname={#1}} +\def\getmacargs#1{\def\argl{#1}} -% Parse the optional {params} list to @macro or @rmacro. -% Set \paramno to the number of arguments, -% and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a -% three-param macro.) Define \macarg.BLAH for each BLAH in the params -% list to some hook where the argument is to be expanded. If there are -% less than 10 arguments that hook is to be replaced by ##N where N -% is the position in that list, that is to say the macro arguments are to be -% defined `a la TeX in the macro body. -% +% Parse the optional {params} list. Set up \paramno and \paramlist +% so \defmacro knows what to do. Define \macarg.blah for each blah +% in the params list, to be ##N where N is the position in that list. % That gets used by \mbodybackslash (above). + +% We need to get `macro parameter char #' into several definitions. +% The technique used is stolen from LaTeX: let \hash be something +% unexpandable, insert that wherever you need a #, and then redefine +% it to # just before using the token list produced. % -% If there are 10 or more arguments, a different technique is used: see -% \parsemmanyargdef. -% -\def\parsemargdef#1;{% - \paramno=0\def\paramlist{}% - \let\hash\relax - % \hash is redefined to `#' later to get it into definitions - \let\xeatspaces\relax - \parsemargdefxxx#1,;,% - \ifnum\paramno<10\relax\else - \paramno0\relax - \parsemmanyargdef@@#1,;,% 10 or more arguments - \fi -} +% The same technique is used to protect \eatspaces till just before +% the macro is used. + +\def\parsemargdef#1;{\paramno=0\def\paramlist{}% + \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} \def\parsemargdefxxx#1,{% \if#1;\let\next=\relax \else \let\next=\parsemargdefxxx - \advance\paramno by 1 + \advance\paramno by 1% \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname {\xeatspaces{\hash\the\paramno}}% \edef\paramlist{\paramlist\hash\the\paramno,}% \fi\next} -% \parsemacbody, \parsermacbody -% -% Read recursive and nonrecursive macro bodies. (They're different since -% rec and nonrec macros end differently.) -% -% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro -% body to be transformed. -% Set \macrobody to the body of the macro, and call \defmacro. -% -{\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{% -\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}% -{\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{% -\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}% +% These two commands read recursive and nonrecursive macro bodies. +% (They're different since rec and nonrec macros end differently.) -% Make @ a letter, so that we can make private-to-Texinfo macro names. -\edef\texiatcatcode{\the\catcode`\@} -\catcode `@=11\relax +\long\def\parsemacbody#1@end macro% +{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% +\long\def\parsermacbody#1@end rmacro% +{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% -%%%%%%%%%%%%%% Code for > 10 arguments only %%%%%%%%%%%%%%%%%% - -% If there are 10 or more arguments, a different technique is used, where the -% hook remains in the body, and when macro is to be expanded the body is -% processed again to replace the arguments. -% -% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the -% argument N value and then \edef the body (nothing else will expand because of -% the catcode regime under which the body was input). -% -% If you compile with TeX (not eTeX), and you have macros with 10 or more -% arguments, no macro can have more than 256 arguments (else error). -% -% In case that there are 10 or more arguments we parse again the arguments -% list to set new definitions for the \macarg.BLAH macros corresponding to -% each BLAH argument. It was anyhow needed to parse already once this list -% in order to count the arguments, and as macros with at most 9 arguments -% are by far more frequent than macro with 10 or more arguments, defining -% twice the \macarg.BLAH macros does not cost too much processing power. -\def\parsemmanyargdef@@#1,{% - \if#1;\let\next=\relax - \else - \let\next=\parsemmanyargdef@@ - \edef\tempb{\eatspaces{#1}}% - \expandafter\def\expandafter\tempa - \expandafter{\csname macarg.\tempb\endcsname}% - % Note that we need some extra \noexpand\noexpand, this is because we - % don't want \the to be expanded in the \parsermacbody as it uses an - % \xdef . - \expandafter\edef\tempa - {\noexpand\noexpand\noexpand\the\toks\the\paramno}% - \advance\paramno by 1\relax - \fi\next} - - -\let\endargs@\relax -\let\nil@\relax -\def\nilm@{\nil@}% -\long\def\nillm@{\nil@}% - -% This macro is expanded during the Texinfo macro expansion, not during its -% definition. It gets all the arguments' values and assigns them to macros -% macarg.ARGNAME -% -% #1 is the macro name -% #2 is the list of argument names -% #3 is the list of argument values -\def\getargvals@#1#2#3{% - \def\macargdeflist@{}% - \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion. - \def\paramlist{#2,\nil@}% - \def\macroname{#1}% - \begingroup - \macroargctxt - \def\argvaluelist{#3,\nil@}% - \def\@tempa{#3}% - \ifx\@tempa\empty - \setemptyargvalues@ - \else - \getargvals@@ - \fi -} -\def\getargvals@@{% - \ifx\paramlist\nilm@ - % Some sanity check needed here that \argvaluelist is also empty. - \ifx\argvaluelist\nillm@ - \else - \errhelp = \EMsimple - \errmessage{Too many arguments in macro `\macroname'!}% - \fi - \let\next\macargexpandinbody@ - \else - \ifx\argvaluelist\nillm@ - % No more arguments values passed to macro. Set remaining named-arg - % macros to empty. - \let\next\setemptyargvalues@ - \else - % pop current arg name into \@tempb - \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}% - \expandafter\@tempa\expandafter{\paramlist}% - % pop current argument value into \@tempc - \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}% - \expandafter\@tempa\expandafter{\argvaluelist}% - % Here \@tempb is the current arg name and \@tempc is the current arg value. - % First place the new argument macro definition into \@tempd - \expandafter\macname\expandafter{\@tempc}% - \expandafter\let\csname macarg.\@tempb\endcsname\relax - \expandafter\def\expandafter\@tempe\expandafter{% - \csname macarg.\@tempb\endcsname}% - \edef\@tempd{\long\def\@tempe{\the\macname}}% - \push@\@tempd\macargdeflist@ - \let\next\getargvals@@ - \fi - \fi - \next -} - -\def\push@#1#2{% - \expandafter\expandafter\expandafter\def - \expandafter\expandafter\expandafter#2% - \expandafter\expandafter\expandafter{% - \expandafter#1#2}% -} - -% Replace arguments by their values in the macro body, and place the result -% in macro \@tempa. -% -\def\macvalstoargs@{% - % To do this we use the property that token registers that are \the'ed - % within an \edef expand only once. So we are going to place all argument - % values into respective token registers. - % - % First we save the token context, and initialize argument numbering. - \begingroup - \paramno0\relax - % Then, for each argument number #N, we place the corresponding argument - % value into a new token list register \toks#N - \expandafter\putargsintokens@\saveparamlist@,;,% - % Then, we expand the body so that argument are replaced by their - % values. The trick for values not to be expanded themselves is that they - % are within tokens and that tokens expand only once in an \edef . - \edef\@tempc{\csname mac.\macroname .body\endcsname}% - % Now we restore the token stack pointer to free the token list registers - % which we have used, but we make sure that expanded body is saved after - % group. - \expandafter - \endgroup - \expandafter\def\expandafter\@tempa\expandafter{\@tempc}% - } - -% Define the named-macro outside of this group and then close this group. -% -\def\macargexpandinbody@{% - \expandafter - \endgroup - \macargdeflist@ - % First the replace in body the macro arguments by their values, the result - % is in \@tempa . - \macvalstoargs@ - % Then we point at the \norecurse or \gobble (for recursive) macro value - % with \@tempb . - \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname - % Depending on whether it is recursive or not, we need some tailing - % \egroup . - \ifx\@tempb\gobble - \let\@tempc\relax - \else - \let\@tempc\egroup - \fi - % And now we do the real job: - \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}% - \@tempd -} - -\def\putargsintokens@#1,{% - \if#1;\let\next\relax - \else - \let\next\putargsintokens@ - % First we allocate the new token list register, and give it a temporary - % alias \@tempb . - \toksdef\@tempb\the\paramno - % Then we place the argument value into that token list register. - \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname - \expandafter\@tempb\expandafter{\@tempa}% - \advance\paramno by 1\relax - \fi - \next -} - -% Trailing missing arguments are set to empty. -% -\def\setemptyargvalues@{% - \ifx\paramlist\nilm@ - \let\next\macargexpandinbody@ - \else - \expandafter\setemptyargvaluesparser@\paramlist\endargs@ - \let\next\setemptyargvalues@ - \fi - \next -} - -\def\setemptyargvaluesparser@#1,#2\endargs@{% - \expandafter\def\expandafter\@tempa\expandafter{% - \expandafter\def\csname macarg.#1\endcsname{}}% - \push@\@tempa\macargdeflist@ - \def\paramlist{#2}% -} - -% #1 is the element target macro -% #2 is the list macro -% #3,#4\endargs@ is the list value -\def\pop@#1#2#3,#4\endargs@{% - \def#1{#3}% - \def#2{#4}% -} -\long\def\longpop@#1#2#3,#4\endargs@{% - \long\def#1{#3}% - \long\def#2{#4}% -} - - -%%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%% - - -% This defines a Texinfo @macro or @rmacro, called by \parsemacbody. -% \macrobody has the body of the macro in it, with placeholders for -% its parameters, looking like "\xeatspaces{\hash 1}". -% \paramno is the number of parameters -% \paramlist is a TeX parameter text, e.g. "#1,#2,#3," -% There are four cases: macros of zero, one, up to nine, and many arguments. +% This defines the macro itself. There are six cases: recursive and +% nonrecursive macros of zero, one, and many arguments. +% Much magic with \expandafter here. % \xdef is used so that macro definitions will survive the file -% they're defined in: @include reads the file inside a group. -% +% they're defined in; @include reads the file inside a group. \def\defmacro{% \let\hash=##% convert placeholders to macro parameter chars - \ifnum\paramno=1 - \def\xeatspaces##1{##1}% - % This removes the pair of braces around the argument. We don't - % use \eatspaces, because this can cause ends of lines to be lost - % when the argument to \eatspaces is read, leading to line-based - % commands like "@itemize" not being read correctly. - \else - \let\xeatspaces\relax % suppress expansion - \fi - \ifcase\paramno - % 0 - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup - \noexpand\spaceisspace - \noexpand\endlineisspace - \noexpand\expandafter % skip any whitespace after the macro name. - \expandafter\noexpand\csname\the\macname @@@\endcsname}% - \expandafter\xdef\csname\the\macname @@@\endcsname{% - \egroup - \noexpand\scanmacro{\macrobody}}% - \or % 1 - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup - \noexpand\braceorline - \expandafter\noexpand\csname\the\macname @@@\endcsname}% - \expandafter\xdef\csname\the\macname @@@\endcsname##1{% - \egroup - \noexpand\scanmacro{\macrobody}% - }% - \else % at most 9 - \ifnum\paramno<10\relax - % @MACNAME sets the context for reading the macro argument - % @MACNAME@@ gets the argument, processes backslashes and appends a - % comma. - % @MACNAME@@@ removes braces surrounding the argument list. - % @MACNAME@@@@ scans the macro body with arguments substituted. + \ifrecursive + \ifcase\paramno + % 0 \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup - \noexpand\expandafter % This \expandafter skip any spaces after the - \noexpand\macroargctxt % macro before we change the catcode of space. - \noexpand\expandafter - \expandafter\noexpand\csname\the\macname @@\endcsname}% - \expandafter\xdef\csname\the\macname @@\endcsname##1{% - \noexpand\passargtomacro - \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}% - \expandafter\xdef\csname\the\macname @@@\endcsname##1{% - \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}% + \noexpand\scanmacro{\temp}}% + \or % 1 + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\braceorline + \expandafter\noexpand\csname\the\macname xxx\endcsname}% + \expandafter\xdef\csname\the\macname xxx\endcsname##1{% + \egroup\noexpand\scanmacro{\temp}}% + \else % many + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\csname\the\macname xx\endcsname}% + \expandafter\xdef\csname\the\macname xx\endcsname##1{% + \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter - \csname\the\macname @@@@\endcsname\paramlist{% - \egroup\noexpand\scanmacro{\macrobody}}% - \else % 10 or more: + \csname\the\macname xxx\endcsname + \paramlist{\egroup\noexpand\scanmacro{\temp}}% + \fi + \else + \ifcase\paramno + % 0 \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\getargvals@{\the\macname}{\argl}% - }% - \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody - \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \or % 1 + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\braceorline + \expandafter\noexpand\csname\the\macname xxx\endcsname}% + \expandafter\xdef\csname\the\macname xxx\endcsname##1{% + \egroup + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \else % many + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \expandafter\noexpand\csname\the\macname xx\endcsname}% + \expandafter\xdef\csname\the\macname xx\endcsname##1{% + \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% + \expandafter\expandafter + \expandafter\xdef + \expandafter\expandafter + \csname\the\macname xxx\endcsname + \paramlist{% + \egroup + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% \fi \fi} -\catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes - \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -{\catcode`\@=0 \catcode`\\=13 % We need to manipulate \ so use @ as escape -@catcode`@_=11 % private names -@catcode`@!=11 % used as argument separator - -% \passargtomacro#1#2 - -% Call #1 with a list of tokens #2, with any doubled backslashes in #2 -% compressed to one. -% -% This implementation works by expansion, and not execution (so we cannot use -% \def or similar). This reduces the risk of this failing in contexts where -% complete expansion is done with no execution (for example, in writing out to -% an auxiliary file for an index entry). -% -% State is kept in the input stream: the argument passed to -% @look_ahead, @gobble_and_check_finish and @add_segment is -% -% THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN (... rest of input) -% -% where: -% THE_MACRO - name of the macro we want to call -% ARG_RESULT - argument list we build to pass to that macro -% PENDING_BS - either a backslash or nothing -% NEXT_TOKEN - used to look ahead in the input stream to see what's coming next - -@gdef@passargtomacro#1#2{% - @add_segment #1!{}@relax#2\@_finish\% -} -@gdef@_finish{@_finishx} @global@let@_finishx@relax - -% #1 - THE_MACRO ARG_RESULT -% #2 - PENDING_BS -% #3 - NEXT_TOKEN -% #4 used to look ahead -% -% If the next token is not a backslash, process the rest of the argument; -% otherwise, remove the next token. -@gdef@look_ahead#1!#2#3#4{% - @ifx#4\% - @expandafter@gobble_and_check_finish - @else - @expandafter@add_segment - @fi#1!{#2}#4#4% -} - -% #1 - THE_MACRO ARG_RESULT -% #2 - PENDING_BS -% #3 - NEXT_TOKEN -% #4 should be a backslash, which is gobbled. -% #5 looks ahead -% -% Double backslash found. Add a single backslash, and look ahead. -@gdef@gobble_and_check_finish#1!#2#3#4#5{% - @add_segment#1\!{}#5#5% -} - -@gdef@is_fi{@fi} - -% #1 - THE_MACRO ARG_RESULT -% #2 - PENDING_BS -% #3 - NEXT_TOKEN -% #4 is input stream until next backslash -% -% Input stream is either at the start of the argument, or just after a -% backslash sequence, either a lone backslash, or a doubled backslash. -% NEXT_TOKEN contains the first token in the input stream: if it is \finish, -% finish; otherwise, append to ARG_RESULT the segment of the argument up until -% the next backslash. PENDING_BACKSLASH contains a backslash to represent -% a backslash just before the start of the input stream that has not been -% added to ARG_RESULT. -@gdef@add_segment#1!#2#3#4\{% -@ifx#3@_finish - @call_the_macro#1!% -@else - % append the pending backslash to the result, followed by the next segment - @expandafter@is_fi@look_ahead#1#2#4!{\}@fi - % this @fi is discarded by @look_ahead. - % we can't get rid of it with \expandafter because we don't know how - % long #4 is. -} - -% #1 - THE_MACRO -% #2 - ARG_RESULT -% #3 discards the res of the conditional in @add_segment, and @is_fi ends the -% conditional. -@gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}} - -} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -% \braceorline MAC is used for a one-argument macro MAC. It checks -% whether the next non-whitespace character is a {. It sets the context -% for reading the argument (slightly different in the two cases). Then, -% to read the argument, in the whole-line case, it then calls the regular -% \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC. -% +% \braceorline decides whether the next nonwhitespace character is a +% {. If so it reads up to the closing }, if not, it reads the whole +% line. Whatever was read is then fed to the next control sequence +% as an argument (by \parsebrace or \parsearg) \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} \def\braceorlinexxx{% - \ifx\nchar\bgroup - \macroargctxt - \expandafter\passargtomacro - \else - \macrolineargctxt\expandafter\parsearg + \ifx\nchar\bgroup\else + \expandafter\parsearg \fi \macnamexxx} % @alias. % We need some trickery to remove the optional spaces around the equal -% sign. Make them active and then expand them all to nothing. -% +% sign. Just make them active and then expand them all to nothing. \def\alias{\parseargusing\obeyspaces\aliasxxx} \def\aliasxxx #1{\aliasyyy#1\relax} \def\aliasyyy #1=#2\relax{% @@ -8765,8 +7120,7 @@ end % @inforef is relatively simple. \def\inforef #1{\inforefzzz #1,,,,**} -\def\inforefzzz #1,#2,#3,#4**{% - \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, +\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, node \samp{\ignorespaces#1{}}} % @node's only job in TeX is to define \lastnode, which is used in @@ -8819,10 +7173,7 @@ end \pdfmkdest{#1}% \iflinks {% - \requireauxfile \atdummies % preserve commands, but don't expand them - % match definition in \xrdef, \refx, \xrefX. - \def\value##1{##1}% \edef\writexrdef##1##2{% \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef ##1}{##2}}% these are parameters of \writexrdef @@ -8830,78 +7181,39 @@ end \toks0 = \expandafter{\lastsection}% \immediate \writexrdef{title}{\the\toks0 }% \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. - \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout + \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, during \shipout }% \fi } -% @xrefautosectiontitle on|off says whether @section(ing) names are used -% automatically in xrefs, if the third arg is not explicitly specified. -% This was provided as a "secret" @set xref-automatic-section-title -% variable, now it's official. -% -\parseargdef\xrefautomaticsectiontitle{% - \def\temp{#1}% - \ifx\temp\onword - \expandafter\let\csname SETxref-automatic-section-title\endcsname - = \empty - \else\ifx\temp\offword - \expandafter\let\csname SETxref-automatic-section-title\endcsname - = \relax - \else - \errhelp = \EMsimple - \errmessage{Unknown @xrefautomaticsectiontitle value `\temp', - must be on|off}% - \fi\fi -} - -% % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is % the node name, #2 the name of the Info cross-reference, #3 the printed % node name, #4 the name of the Info file, #5 the name of the printed % manual. All but the node name can be omitted. % -\def\pxref{\putwordsee{} \xrefXX} -\def\xref{\putwordSee{} \xrefXX} -\def\ref{\xrefXX} - -\def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX} -\def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]} -% -\newbox\toprefbox -\newbox\printedrefnamebox -\newbox\infofilenamebox -\newbox\printedmanualbox -% +\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} +\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} +\def\ref#1{\xrefX[#1,,,,,,,]} \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup \unsepspaces - % - % Get args without leading/trailing spaces. - \def\printedrefname{\ignorespaces #3}% - \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% - % - \def\infofilename{\ignorespaces #4}% - \setbox\infofilenamebox = \hbox{\infofilename\unskip}% - % \def\printedmanual{\ignorespaces #5}% - \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% - % - % If the printed reference name (arg #3) was not explicitly given in - % the @xref, figure out what we want to use. - \ifdim \wd\printedrefnamebox = 0pt + \def\printedrefname{\ignorespaces #3}% + \setbox1=\hbox{\printedmanual\unskip}% + \setbox0=\hbox{\printedrefname\unskip}% + \ifdim \wd0 = 0pt % No printed node name was explicitly given. - \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax - % Not auto section-title: use node name inside the square brackets. + \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax + % Use the node name inside the square brackets. \def\printedrefname{\ignorespaces #1}% \else - % Auto section-title: use chapter/section title inside - % the square brackets if we have it. - \ifdim \wd\printedmanualbox > 0pt - % It is in another manual, so we don't have it; use node name. + % Use the actual chapter/section title appear inside + % the square brackets. Use the real section title if we have it. + \ifdim \wd1 > 0pt + % It is in another manual, so we don't have it. \def\printedrefname{\ignorespaces #1}% \else \ifhavexrefs - % We (should) know the real title if we have the xref values. + % We know the real title if we have the xref values. \def\printedrefname{\refx{#1-title}{}}% \else % Otherwise just copy the Info node name. @@ -8913,124 +7225,64 @@ end % % Make link in pdf output. \ifpdf - % For pdfTeX and LuaTeX {\indexnofonts - \makevalueexpandable \turnoffactive % This expands tokens, so do it after making catcode changes, so _ - % etc. don't get their TeX definitions. This ignores all spaces in - % #4, including (wrongly) those in the middle of the filename. + % etc. don't get their TeX definitions. \getfilename{#4}% % - % This (wrongly) does not take account of leading or trailing - % spaces in #1, which should be ignored. - \setpdfdestname{#1}% - % - \ifx\pdfdestname\empty - \def\pdfdestname{Top}% no empty targets - \fi + % See comments at \activebackslashdouble. + {\activebackslashdouble \xdef\pdfxrefdest{#1}% + \backslashparens\pdfxrefdest}% % \leavevmode \startlink attr{/Border [0 0 0]}% \ifnum\filenamelength>0 - goto file{\the\filename.pdf} name{\pdfdestname}% + goto file{\the\filename.pdf} name{\pdfxrefdest}% \else - goto name{\pdfmkpgn{\pdfdestname}}% + goto name{\pdfmkpgn{\pdfxrefdest}}% \fi }% \setcolor{\linkcolor}% - \else - \ifx\XeTeXrevision\thisisundefined - \else - % For XeTeX - {\indexnofonts - \makevalueexpandable - \turnoffactive - % This expands tokens, so do it after making catcode changes, so _ - % etc. don't get their TeX definitions. This ignores all spaces in - % #4, including (wrongly) those in the middle of the filename. - \getfilename{#4}% - % - % This (wrongly) does not take account of leading or trailing - % spaces in #1, which should be ignored. - \setpdfdestname{#1}% - % - \ifx\pdfdestname\empty - \def\pdfdestname{Top}% no empty targets - \fi - % - \leavevmode - \ifnum\filenamelength>0 - % With default settings, - % XeTeX (xdvipdfmx) replaces link destination names with integers. - % In this case, the replaced destination names of - % remote PDFs are no longer known. In order to avoid a replacement, - % you can use xdvipdfmx's command line option `-C 0x0010'. - % If you use XeTeX 0.99996+ (TeX Live 2016+), - % this command line option is no longer necessary - % because we can use the `dvipdfmx:config' special. - \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A - << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}% - \else - \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A - << /S /GoTo /D (\pdfdestname) >> >>}% - \fi - }% - \setcolor{\linkcolor}% - \fi \fi + % + % Float references are printed completely differently: "Figure 1.2" + % instead of "[somenode], p.3". We distinguish them by the + % LABEL-title being set to a magic string. {% % Have to otherify everything special to allow the \csname to % include an _ in the xref name, etc. \indexnofonts \turnoffactive - \def\value##1{##1}% \expandafter\global\expandafter\let\expandafter\Xthisreftitle \csname XR#1-title\endcsname }% - % - % Float references are printed completely differently: "Figure 1.2" - % instead of "[somenode], p.3". \iffloat distinguishes them by - % \Xthisreftitle being set to a magic string. \iffloat\Xthisreftitle % If the user specified the print name (third arg) to the ref, % print it instead of our usual "Figure 1.2". - \ifdim\wd\printedrefnamebox = 0pt + \ifdim\wd0 = 0pt \refx{#1-snt}{}% \else \printedrefname \fi % - % If the user also gave the printed manual name (fifth arg), append + % if the user also gave the printed manual name (fifth arg), append % "in MANUALNAME". - \ifdim \wd\printedmanualbox > 0pt + \ifdim \wd1 > 0pt \space \putwordin{} \cite{\printedmanual}% \fi \else % node/anchor (non-float) references. - % - % If we use \unhbox to print the node names, TeX does not insert - % empty discretionaries after hyphens, which means that it will not - % find a line break at a hyphen in a node names. Since some manuals - % are best written with fairly long node names, containing hyphens, - % this is a loss. Therefore, we give the text of the node name - % again, so it is as if TeX is seeing it for the first time. - % - \ifdim \wd\printedmanualbox > 0pt - % Cross-manual reference with a printed manual name. - % - \crossmanualxref{\cite{\printedmanual\unskip}}% - % - \else\ifdim \wd\infofilenamebox > 0pt - % Cross-manual reference with only an info filename (arg 4), no - % printed manual name (arg 5). This is essentially the same as - % the case above; we output the filename, since we have nothing else. - % - \crossmanualxref{\code{\infofilename\unskip}}% % + % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not + % insert empty discretionaries after hyphens, which means that it will + % not find a line break at a hyphen in a node names. Since some manuals + % are best written with fairly long node names, containing hyphens, this + % is a loss. Therefore, we give the text of the node name again, so it + % is as if TeX is seeing it for the first time. + \ifdim \wd1 > 0pt + \putwordSection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}% \else - % Reference within this manual. - % % _ (for example) has to be the character _ for the purposes of the % control sequence corresponding to the node, but it has to expand % into the usual \leavevmode...\vrule stuff for purposes of @@ -9042,7 +7294,7 @@ end \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi }% - % output the `[mynode]' via the macro below so it can be overridden. + % output the `[mynode]' via a macro so it can be overridden. \xrefprintnodename\printedrefname % % But we always want a comma and a space: @@ -9050,46 +7302,11 @@ end % % output the `page 3'. \turnoffactive \putwordpage\tie\refx{#1-pg}{}% - % Add a , if xref followed by a space - \if\space\noexpand\tokenafterxref ,% - \else\ifx\ \tokenafterxref ,% @TAB - \else\ifx\*\tokenafterxref ,% @* - \else\ifx\ \tokenafterxref ,% @SPACE - \else\ifx\ - \tokenafterxref ,% @NL - \else\ifx\tie\tokenafterxref ,% @tie - \fi\fi\fi\fi\fi\fi - \fi\fi + \fi \fi \endlink \endgroup} -% Output a cross-manual xref to #1. Used just above (twice). -% -% Only include the text "Section ``foo'' in" if the foo is neither -% missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply -% "see The Foo Manual", the idea being to refer to the whole manual. -% -% But, this being TeX, we can't easily compare our node name against the -% string "Top" while ignoring the possible spaces before and after in -% the input. By adding the arbitrary 7sp below, we make it much less -% likely that a real node name would have the same width as "Top" (e.g., -% in a monospaced font). Hopefully it will never happen in practice. -% -% For the same basic reason, we retypeset the "Top" at every -% reference, since the current font is indeterminate. -% -\def\crossmanualxref#1{% - \setbox\toprefbox = \hbox{Top\kern7sp}% - \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% - \ifdim \wd2 > 7sp % nonempty? - \ifdim \wd2 = \wd\toprefbox \else % same as Top? - \putwordSection{} ``\printedrefname'' \putwordin{}\space - \fi - \fi - #1% -} - % This macro is called from \xrefX for the `[nodename]' part of xref % output. It's a separate macro only so it can be changed more easily, % since square brackets don't work well in some documents. Particularly @@ -9125,14 +7342,13 @@ end \fi\fi\fi } -% \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME. SUFFIX -% is output afterwards if non-empty. +% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. +% If its value is nonempty, SUFFIX is output afterward. +% \def\refx#1#2{% - \requireauxfile {% \indexnofonts \otherbackslash - \def\value##1{##1}% \expandafter\global\expandafter\let\expandafter\thisrefX \csname XR#1\endcsname }% @@ -9141,8 +7357,7 @@ end \angleleft un\-de\-fined\angleright \iflinks \ifhavexrefs - {\toks0 = {#1}% avoid expansion of possibly-complex value - \message{\linenumber Undefined cross reference `\the\toks0'.}}% + \message{\linenumber Undefined cross reference `#1'.}% \else \ifwarnedxrefs\else \global\warnedxrefstrue @@ -9157,28 +7372,20 @@ end #2% Output the suffix in any case. } -% This is the macro invoked by entries in the aux file. Define a control -% sequence for a cross-reference target (we prepend XR to the control sequence -% name to avoid collisions). The value is the page number. If this is a float -% type, we have more work to do. +% This is the macro invoked by entries in the aux file. Usually it's +% just a \def (we prepend XR to the control sequence name to avoid +% collisions). But if this is a float type, we have more work to do. % \def\xrdef#1#2{% - {% Expand the node or anchor name to remove control sequences. - % \turnoffactive stops 8-bit characters being changed to commands - % like @'e. \refx does the same to retrieve the value in the definition. + {% The node name might contain 8-bit characters, which in our current + % implementation are changed to commands like @'e. Don't let these + % mess up the control sequence name. \indexnofonts \turnoffactive - \def\value##1{##1}% \xdef\safexrefname{#1}% }% % - \bgroup - \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% - \egroup - % We put the \gdef inside a group to avoid the definitions building up on - % TeX's save stack, which can cause it to run out of space for aux files with - % thousands of lines. \gdef doesn't use the save stack, but \csname does - % when it defines an unknown control sequence as \relax. + \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref % % Was that xref control sequence that we just defined for a float? \expandafter\iffloat\csname XR\safexrefname\endcsname @@ -9201,23 +7408,6 @@ end \fi } -% If working on a large document in chapters, it is convenient to -% be able to disable indexing, cross-referencing, and contents, for test runs. -% This is done with @novalidate at the beginning of the file. -% -\newif\iflinks \linkstrue % by default we want the aux files. -\let\novalidate = \linksfalse - -% Used when writing to the aux file, or when using data from it. -\def\requireauxfile{% - \iflinks - \tryauxfile - % Open the new aux file. TeX will close it automatically at exit. - \immediate\openout\auxfile=\jobname.aux - \fi - \global\let\requireauxfile=\relax % Only do this once. -} - % Read the last existing aux file, if any. No error if none exists. % \def\tryauxfile{% @@ -9296,6 +7486,16 @@ end % now. --karl, 15jan04. \catcode`\\=\other % + % Make the characters 128-255 be printing characters. + {% + \count1=128 + \def\loop{% + \catcode\count1=\other + \advance\count1 by 1 + \ifnum \count1<256 \loop \fi + }% + }% + % % @ is our escape character in .aux files, and we need braces. \catcode`\{=1 \catcode`\}=2 @@ -9321,13 +7521,15 @@ end % space to prevent strange expansion errors.) \def\supereject{\par\penalty -20000\footnoteno =0 } -% @footnotestyle is meaningful for Info output only. +% @footnotestyle is meaningful for info output only. \let\footnotestyle=\comment {\catcode `\@=11 % % Auto-number footnotes. Otherwise like plain. \gdef\footnote{% + \let\indent=\ptexindent + \let\noindent=\ptexnoindent \global\advance\footnoteno by \@ne \edef\thisfootno{$^{\the\footnoteno}$}% % @@ -9351,15 +7553,10 @@ end % \gdef\dofootnote{% \insert\footins\bgroup - % - % Nested footnotes are not supported in TeX, that would take a lot - % more work. (\startsavinginserts does not suffice.) - \let\footnote=\errfootnotenest - % % We want to typeset this text as a normal paragraph, even if the % footnote reference occurs in (for example) a display environment. % So reset some parameters. - \hsize=\txipagewidth + \hsize=\pagewidth \interlinepenalty\interfootnotelinepenalty \splittopskip\ht\strutbox % top baseline for broken footnotes \splitmaxdepth\dp\strutbox @@ -9387,30 +7584,17 @@ end % expands into a box, it must come within the paragraph, lest it % provide a place where TeX can split the footnote. \footstrut - % - % Invoke rest of plain TeX footnote routine. \futurelet\next\fo@t } }%end \catcode `\@=11 -\def\errfootnotenest{% - \errhelp=\EMsimple - \errmessage{Nested footnotes not supported in texinfo.tex, - even though they work in makeinfo; sorry} -} - -\def\errfootnoteheading{% - \errhelp=\EMsimple - \errmessage{Footnotes in chapters, sections, etc., are not supported} -} - % In case a @footnote appears in a vbox, save the footnote text and create % the real \insert just after the vbox finished. Otherwise, the insertion % would be lost. % Similarly, if a @footnote appears inside an alignment, save the footnote % text to a box and make the \insert when a row of the table is finished. % And the same can be done for other insert classes. --kasal, 16nov03. -% + % Replace the \insert primitive by a cheating macro. % Deeper inside, just make sure that the saved insertions are not spilled % out prematurely. @@ -9484,10 +7668,10 @@ end \newif\ifwarnednoepsf \newhelp\noepsfhelp{epsf.tex must be installed for images to work. It is also included in the Texinfo distribution, or you can get - it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.} + it from ftp://tug.org/tex/epsf.tex.} % \def\image#1{% - \ifx\epsfbox\thisisundefined + \ifx\epsfbox\undefined \ifwarnednoepsf \else \errhelp = \noepsfhelp \errmessage{epsf.tex not found, images will be ignored}% @@ -9503,22 +7687,14 @@ end % #2 is (optional) width, #3 is (optional) height. % #4 is (ignored optional) html alt text. % #5 is (ignored optional) extension. -% #6 is just the usual extra ignored arg for parsing stuff. +% #6 is just the usual extra ignored arg for parsing this stuff. \newif\ifimagevmode \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup \catcode`\^^M = 5 % in case we're inside an example \normalturnoffactive % allow _ et al. in names - \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro % If the image is by itself, center it. \ifvmode \imagevmodetrue - \else \ifx\centersub\centerV - % for @center @image, we need a vbox so we can have our vertical space - \imagevmodetrue - \vbox\bgroup % vbox has better behavior than vtop herev - \fi\fi - % - \ifimagevmode \nobreak\medskip % Usually we'll have text after the image which will insert % \parskip glue, so insert it here too to equalize the space @@ -9528,37 +7704,21 @@ end \fi % % Leave vertical mode so that indentation from an enclosing - % environment such as @quotation is respected. - % However, if we're at the top level, we don't want the - % normal paragraph indentation. - % On the other hand, if we are in the case of @center @image, we don't - % want to start a paragraph, which will create a hsize-width box and - % eradicate the centering. - \ifx\centersub\centerV\else \noindent \fi + % environment such as @quotation is respected. On the other hand, if + % it's at the top level, we don't want the normal paragraph indentation. + \noindent % % Output the image. \ifpdf - % For pdfTeX and LuaTeX <= 0.80 \dopdfimage{#1}{#2}{#3}% \else - \ifx\XeTeXrevision\thisisundefined - % For epsf.tex - % \epsfbox itself resets \epsf?size at each figure. - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi - \setbox0 = \hbox{\ignorespaces #3}% - \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi - \epsfbox{#1.eps}% - \else - % For XeTeX - \doxeteximage{#1}{#2}{#3}% - \fi + % \epsfbox itself resets \epsf?size at each figure. + \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi + \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi + \epsfbox{#1.eps}% \fi % - \ifimagevmode - \medskip % space after a standalone image - \fi - \ifx\centersub\centerV \egroup \fi + \ifimagevmode \medskip \fi % space after the standalone image \endgroup} @@ -9674,7 +7834,7 @@ end % \ifx\thiscaption\empty \else \ifx\floatident\empty \else - \appendtomacro\captionline{: }% had ident, so need a colon between + \appendtomacro\captionline{: }% had ident, so need a colon between \fi % % caption text. @@ -9698,20 +7858,32 @@ end % \floatlabel-lof. Besides \floatident, we include the short % caption if specified, else the full caption if specified, else nothing. {% - \requireauxfile \atdummies % - \ifx\thisshortcaption\empty - \def\gtemp{\thiscaption}% - \else - \def\gtemp{\thisshortcaption}% - \fi + % since we read the caption text in the macro world, where ^^M + % is turned into a normal character, we have to scan it back, so + % we don't write the literal three characters "^^M" into the aux file. + \scanexp{% + \xdef\noexpand\gtemp{% + \ifx\thisshortcaption\empty + \thiscaption + \else + \thisshortcaption + \fi + }% + }% \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident - \ifx\gtemp\empty \else : \gtemp \fi}}% + \ifx\gtemp\empty \else : \gtemp \fi}}% }% \fi \egroup % end of \vtop % + % place the captured inserts + % + % BEWARE: when the floats start floating, we have to issue warning + % whenever an insert appears inside a float which could possibly + % float. --kasal, 26may04 + % \checkinserts } @@ -9825,20 +7997,20 @@ end { \catcode`\_ = \active \globaldefs=1 -\parseargdef\documentlanguage{% +\parseargdef\documentlanguage{\begingroup + \let_=\normalunderscore % normal _ character for filenames \tex % read txi-??.tex file in plain TeX. % Read the file by the name they passed if it exists. - \let_ = \normalunderscore % normal _ character for filename test \openin 1 txi-#1.tex \ifeof 1 - \documentlanguagetrywithoutunderscore #1_\finish + \documentlanguagetrywithoutunderscore{#1_\finish}% \else \globaldefs = 1 % everything in the txi-LL files needs to persist \input txi-#1.tex \fi \closein 1 \endgroup % end raw TeX -} +\endgroup} % % If they passed de_DE, and txi-de_DE.tex doesn't exist, % try txi-de.tex. @@ -9886,70 +8058,6 @@ directory should work if nowhere else does.} \global\righthyphenmin = #3\relax } -% XeTeX and LuaTeX can handle Unicode natively. -% Their default I/O uses UTF-8 sequences instead of a byte-wise operation. -% Other TeX engines' I/O (pdfTeX, etc.) is byte-wise. -% -\newif\iftxinativeunicodecapable -\newif\iftxiusebytewiseio - -\ifx\XeTeXrevision\thisisundefined - \ifx\luatexversion\thisisundefined - \txinativeunicodecapablefalse - \txiusebytewiseiotrue - \else - \txinativeunicodecapabletrue - \txiusebytewiseiofalse - \fi -\else - \txinativeunicodecapabletrue - \txiusebytewiseiofalse -\fi - -% Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex -% for non-UTF-8 (byte-wise) encodings. -% -\def\setbytewiseio{% - \ifx\XeTeXrevision\thisisundefined - \else - \XeTeXdefaultencoding "bytes" % For subsequent files to be read - \XeTeXinputencoding "bytes" % For document root file - % Unfortunately, there seems to be no corresponding XeTeX command for - % output encoding. This is a problem for auxiliary index and TOC files. - % The only solution would be perhaps to write out @U{...} sequences in - % place of non-ASCII characters. - \fi - - \ifx\luatexversion\thisisundefined - \else - \directlua{ - local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub - local function convert_char (char) - return utf8_char(byte(char)) - end - - local function convert_line (line) - return gsub(line, ".", convert_char) - end - - callback.register("process_input_buffer", convert_line) - - local function convert_line_out (line) - local line_out = "" - for c in string.utfvalues(line) do - line_out = line_out .. string.char(c) - end - return line_out - end - - callback.register("process_output_buffer", convert_line_out) - } - \fi - - \txiusebytewiseiotrue -} - - % Helpers for encodings. % Set the catcode of characters 128 through 255 to the specified number. % @@ -9972,9 +8080,7 @@ directory should work if nowhere else does.} % @documentencoding sets the definition of non-ASCII characters % according to the specified encoding. % -\def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz} -\def\documentencodingzzz#1{% - % +\parseargdef\documentencoding{% % Encoding being declared for the document. \def\declaredencoding{\csname #1.enc\endcsname}% % @@ -9990,66 +8096,35 @@ directory should work if nowhere else does.} \asciichardefs % \else \ifx \declaredencoding \lattwo - \iftxinativeunicodecapable - \setbytewiseio - \fi \setnonasciicharscatcode\active \lattwochardefs % \else \ifx \declaredencoding \latone - \iftxinativeunicodecapable - \setbytewiseio - \fi \setnonasciicharscatcode\active \latonechardefs % \else \ifx \declaredencoding \latnine - \iftxinativeunicodecapable - \setbytewiseio - \fi \setnonasciicharscatcode\active \latninechardefs % \else \ifx \declaredencoding \utfeight - \iftxinativeunicodecapable - % For native Unicode handling (XeTeX and LuaTeX) - \nativeunicodechardefs - \else - % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX) - \setnonasciicharscatcode\active - % since we already invoked \utfeightchardefs at the top level - % (below), do not re-invoke it, otherwise our check for duplicated - % definitions gets triggered. Making non-ascii chars active is - % sufficient. - \fi + \setnonasciicharscatcode\active + \utfeightchardefs % \else - \message{Ignoring unknown document encoding: #1.}% + \message{Unknown document encoding #1, ignoring.}% % \fi % utfeight \fi % latnine \fi % latone \fi % lattwo \fi % ascii - % - \ifx\XeTeXrevision\thisisundefined - \else - \ifx \declaredencoding \utfeight - \else - \ifx \declaredencoding \ascii - \else - \message{Warning: XeTeX with non-UTF-8 encodings cannot handle % - non-ASCII characters in auxiliary files.}% - \fi - \fi - \fi } -% emacs-page % A message to be logged when using a character that isn't available % the default font encoding (OT1). % -\def\missingcharmsg#1{\message{Character missing, sorry: #1.}} +\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} % Take account of \c (plain) vs. \, (Texinfo) difference. \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} @@ -10059,119 +8134,111 @@ directory should work if nowhere else does.} % macros containing the character definitions. \setnonasciicharscatcode\active % - -\def\gdefchar#1#2{% -\gdef#1{% - \ifpassthroughchars - \string#1% - \else - #2% - \fi -}} - % Latin1 (ISO-8859-1) character definitions. \def\latonechardefs{% - \gdefchar^^a0{\tie} - \gdefchar^^a1{\exclamdown} - \gdefchar^^a2{{\tcfont \char162}} % cent - \gdefchar^^a3{\pounds{}} - \gdefchar^^a4{{\tcfont \char164}} % currency - \gdefchar^^a5{{\tcfont \char165}} % yen - \gdefchar^^a6{{\tcfont \char166}} % broken bar - \gdefchar^^a7{\S} - \gdefchar^^a8{\"{}} - \gdefchar^^a9{\copyright{}} - \gdefchar^^aa{\ordf} - \gdefchar^^ab{\guillemetleft{}} - \gdefchar^^ac{\ensuremath\lnot} - \gdefchar^^ad{\-} - \gdefchar^^ae{\registeredsymbol{}} - \gdefchar^^af{\={}} + \gdef^^a0{~} + \gdef^^a1{\exclamdown} + \gdef^^a2{\missingcharmsg{CENT SIGN}} + \gdef^^a3{{\pounds}} + \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} + \gdef^^a5{\missingcharmsg{YEN SIGN}} + \gdef^^a6{\missingcharmsg{BROKEN BAR}} + \gdef^^a7{\S} + \gdef^^a8{\"{}} + \gdef^^a9{\copyright} + \gdef^^aa{\ordf} + \gdef^^ab{\guillemetleft} + \gdef^^ac{$\lnot$} + \gdef^^ad{\-} + \gdef^^ae{\registeredsymbol} + \gdef^^af{\={}} % - \gdefchar^^b0{\textdegree} - \gdefchar^^b1{$\pm$} - \gdefchar^^b2{$^2$} - \gdefchar^^b3{$^3$} - \gdefchar^^b4{\'{}} - \gdefchar^^b5{$\mu$} - \gdefchar^^b6{\P} - \gdefchar^^b7{\ensuremath\cdot} - \gdefchar^^b8{\cedilla\ } - \gdefchar^^b9{$^1$} - \gdefchar^^ba{\ordm} - \gdefchar^^bb{\guillemetright{}} - \gdefchar^^bc{$1\over4$} - \gdefchar^^bd{$1\over2$} - \gdefchar^^be{$3\over4$} - \gdefchar^^bf{\questiondown} + \gdef^^b0{\textdegree} + \gdef^^b1{$\pm$} + \gdef^^b2{$^2$} + \gdef^^b3{$^3$} + \gdef^^b4{\'{}} + \gdef^^b5{$\mu$} + \gdef^^b6{\P} % - \gdefchar^^c0{\`A} - \gdefchar^^c1{\'A} - \gdefchar^^c2{\^A} - \gdefchar^^c3{\~A} - \gdefchar^^c4{\"A} - \gdefchar^^c5{\ringaccent A} - \gdefchar^^c6{\AE} - \gdefchar^^c7{\cedilla C} - \gdefchar^^c8{\`E} - \gdefchar^^c9{\'E} - \gdefchar^^ca{\^E} - \gdefchar^^cb{\"E} - \gdefchar^^cc{\`I} - \gdefchar^^cd{\'I} - \gdefchar^^ce{\^I} - \gdefchar^^cf{\"I} + \gdef^^b7{$^.$} + \gdef^^b8{\cedilla\ } + \gdef^^b9{$^1$} + \gdef^^ba{\ordm} % - \gdefchar^^d0{\DH} - \gdefchar^^d1{\~N} - \gdefchar^^d2{\`O} - \gdefchar^^d3{\'O} - \gdefchar^^d4{\^O} - \gdefchar^^d5{\~O} - \gdefchar^^d6{\"O} - \gdefchar^^d7{$\times$} - \gdefchar^^d8{\O} - \gdefchar^^d9{\`U} - \gdefchar^^da{\'U} - \gdefchar^^db{\^U} - \gdefchar^^dc{\"U} - \gdefchar^^dd{\'Y} - \gdefchar^^de{\TH} - \gdefchar^^df{\ss} + \gdef^^bb{\guilletright} + \gdef^^bc{$1\over4$} + \gdef^^bd{$1\over2$} + \gdef^^be{$3\over4$} + \gdef^^bf{\questiondown} % - \gdefchar^^e0{\`a} - \gdefchar^^e1{\'a} - \gdefchar^^e2{\^a} - \gdefchar^^e3{\~a} - \gdefchar^^e4{\"a} - \gdefchar^^e5{\ringaccent a} - \gdefchar^^e6{\ae} - \gdefchar^^e7{\cedilla c} - \gdefchar^^e8{\`e} - \gdefchar^^e9{\'e} - \gdefchar^^ea{\^e} - \gdefchar^^eb{\"e} - \gdefchar^^ec{\`{\dotless i}} - \gdefchar^^ed{\'{\dotless i}} - \gdefchar^^ee{\^{\dotless i}} - \gdefchar^^ef{\"{\dotless i}} + \gdef^^c0{\`A} + \gdef^^c1{\'A} + \gdef^^c2{\^A} + \gdef^^c3{\~A} + \gdef^^c4{\"A} + \gdef^^c5{\ringaccent A} + \gdef^^c6{\AE} + \gdef^^c7{\cedilla C} + \gdef^^c8{\`E} + \gdef^^c9{\'E} + \gdef^^ca{\^E} + \gdef^^cb{\"E} + \gdef^^cc{\`I} + \gdef^^cd{\'I} + \gdef^^ce{\^I} + \gdef^^cf{\"I} % - \gdefchar^^f0{\dh} - \gdefchar^^f1{\~n} - \gdefchar^^f2{\`o} - \gdefchar^^f3{\'o} - \gdefchar^^f4{\^o} - \gdefchar^^f5{\~o} - \gdefchar^^f6{\"o} - \gdefchar^^f7{$\div$} - \gdefchar^^f8{\o} - \gdefchar^^f9{\`u} - \gdefchar^^fa{\'u} - \gdefchar^^fb{\^u} - \gdefchar^^fc{\"u} - \gdefchar^^fd{\'y} - \gdefchar^^fe{\th} - \gdefchar^^ff{\"y} + \gdef^^d0{\DH} + \gdef^^d1{\~N} + \gdef^^d2{\`O} + \gdef^^d3{\'O} + \gdef^^d4{\^O} + \gdef^^d5{\~O} + \gdef^^d6{\"O} + \gdef^^d7{$\times$} + \gdef^^d8{\O} + \gdef^^d9{\`U} + \gdef^^da{\'U} + \gdef^^db{\^U} + \gdef^^dc{\"U} + \gdef^^dd{\'Y} + \gdef^^de{\TH} + \gdef^^df{\ss} + % + \gdef^^e0{\`a} + \gdef^^e1{\'a} + \gdef^^e2{\^a} + \gdef^^e3{\~a} + \gdef^^e4{\"a} + \gdef^^e5{\ringaccent a} + \gdef^^e6{\ae} + \gdef^^e7{\cedilla c} + \gdef^^e8{\`e} + \gdef^^e9{\'e} + \gdef^^ea{\^e} + \gdef^^eb{\"e} + \gdef^^ec{\`{\dotless i}} + \gdef^^ed{\'{\dotless i}} + \gdef^^ee{\^{\dotless i}} + \gdef^^ef{\"{\dotless i}} + % + \gdef^^f0{\dh} + \gdef^^f1{\~n} + \gdef^^f2{\`o} + \gdef^^f3{\'o} + \gdef^^f4{\^o} + \gdef^^f5{\~o} + \gdef^^f6{\"o} + \gdef^^f7{$\div$} + \gdef^^f8{\o} + \gdef^^f9{\`u} + \gdef^^fa{\'u} + \gdef^^fb{\^u} + \gdef^^fc{\"u} + \gdef^^fd{\'y} + \gdef^^fe{\th} + \gdef^^ff{\"y} } % Latin9 (ISO-8859-15) encoding character definitions. @@ -10179,119 +8246,119 @@ directory should work if nowhere else does.} % Encoding is almost identical to Latin1. \latonechardefs % - \gdefchar^^a4{\euro{}} - \gdefchar^^a6{\v S} - \gdefchar^^a8{\v s} - \gdefchar^^b4{\v Z} - \gdefchar^^b8{\v z} - \gdefchar^^bc{\OE} - \gdefchar^^bd{\oe} - \gdefchar^^be{\"Y} + \gdef^^a4{\euro} + \gdef^^a6{\v S} + \gdef^^a8{\v s} + \gdef^^b4{\v Z} + \gdef^^b8{\v z} + \gdef^^bc{\OE} + \gdef^^bd{\oe} + \gdef^^be{\"Y} } % Latin2 (ISO-8859-2) character definitions. \def\lattwochardefs{% - \gdefchar^^a0{\tie} - \gdefchar^^a1{\ogonek{A}} - \gdefchar^^a2{\u{}} - \gdefchar^^a3{\L} - \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}} - \gdefchar^^a5{\v L} - \gdefchar^^a6{\'S} - \gdefchar^^a7{\S} - \gdefchar^^a8{\"{}} - \gdefchar^^a9{\v S} - \gdefchar^^aa{\cedilla S} - \gdefchar^^ab{\v T} - \gdefchar^^ac{\'Z} - \gdefchar^^ad{\-} - \gdefchar^^ae{\v Z} - \gdefchar^^af{\dotaccent Z} + \gdef^^a0{~} + \gdef^^a1{\ogonek{A}} + \gdef^^a2{\u{}} + \gdef^^a3{\L} + \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} + \gdef^^a5{\v L} + \gdef^^a6{\'S} + \gdef^^a7{\S} + \gdef^^a8{\"{}} + \gdef^^a9{\v S} + \gdef^^aa{\cedilla S} + \gdef^^ab{\v T} + \gdef^^ac{\'Z} + \gdef^^ad{\-} + \gdef^^ae{\v Z} + \gdef^^af{\dotaccent Z} % - \gdefchar^^b0{\textdegree{}} - \gdefchar^^b1{\ogonek{a}} - \gdefchar^^b2{\ogonek{ }} - \gdefchar^^b3{\l} - \gdefchar^^b4{\'{}} - \gdefchar^^b5{\v l} - \gdefchar^^b6{\'s} - \gdefchar^^b7{\v{}} - \gdefchar^^b8{\cedilla\ } - \gdefchar^^b9{\v s} - \gdefchar^^ba{\cedilla s} - \gdefchar^^bb{\v t} - \gdefchar^^bc{\'z} - \gdefchar^^bd{\H{}} - \gdefchar^^be{\v z} - \gdefchar^^bf{\dotaccent z} + \gdef^^b0{\textdegree} + \gdef^^b1{\ogonek{a}} + \gdef^^b2{\ogonek{ }} + \gdef^^b3{\l} + \gdef^^b4{\'{}} + \gdef^^b5{\v l} + \gdef^^b6{\'s} + \gdef^^b7{\v{}} + \gdef^^b8{\cedilla\ } + \gdef^^b9{\v s} + \gdef^^ba{\cedilla s} + \gdef^^bb{\v t} + \gdef^^bc{\'z} + \gdef^^bd{\H{}} + \gdef^^be{\v z} + \gdef^^bf{\dotaccent z} % - \gdefchar^^c0{\'R} - \gdefchar^^c1{\'A} - \gdefchar^^c2{\^A} - \gdefchar^^c3{\u A} - \gdefchar^^c4{\"A} - \gdefchar^^c5{\'L} - \gdefchar^^c6{\'C} - \gdefchar^^c7{\cedilla C} - \gdefchar^^c8{\v C} - \gdefchar^^c9{\'E} - \gdefchar^^ca{\ogonek{E}} - \gdefchar^^cb{\"E} - \gdefchar^^cc{\v E} - \gdefchar^^cd{\'I} - \gdefchar^^ce{\^I} - \gdefchar^^cf{\v D} + \gdef^^c0{\'R} + \gdef^^c1{\'A} + \gdef^^c2{\^A} + \gdef^^c3{\u A} + \gdef^^c4{\"A} + \gdef^^c5{\'L} + \gdef^^c6{\'C} + \gdef^^c7{\cedilla C} + \gdef^^c8{\v C} + \gdef^^c9{\'E} + \gdef^^ca{\ogonek{E}} + \gdef^^cb{\"E} + \gdef^^cc{\v E} + \gdef^^cd{\'I} + \gdef^^ce{\^I} + \gdef^^cf{\v D} % - \gdefchar^^d0{\DH} - \gdefchar^^d1{\'N} - \gdefchar^^d2{\v N} - \gdefchar^^d3{\'O} - \gdefchar^^d4{\^O} - \gdefchar^^d5{\H O} - \gdefchar^^d6{\"O} - \gdefchar^^d7{$\times$} - \gdefchar^^d8{\v R} - \gdefchar^^d9{\ringaccent U} - \gdefchar^^da{\'U} - \gdefchar^^db{\H U} - \gdefchar^^dc{\"U} - \gdefchar^^dd{\'Y} - \gdefchar^^de{\cedilla T} - \gdefchar^^df{\ss} + \gdef^^d0{\DH} + \gdef^^d1{\'N} + \gdef^^d2{\v N} + \gdef^^d3{\'O} + \gdef^^d4{\^O} + \gdef^^d5{\H O} + \gdef^^d6{\"O} + \gdef^^d7{$\times$} + \gdef^^d8{\v R} + \gdef^^d9{\ringaccent U} + \gdef^^da{\'U} + \gdef^^db{\H U} + \gdef^^dc{\"U} + \gdef^^dd{\'Y} + \gdef^^de{\cedilla T} + \gdef^^df{\ss} % - \gdefchar^^e0{\'r} - \gdefchar^^e1{\'a} - \gdefchar^^e2{\^a} - \gdefchar^^e3{\u a} - \gdefchar^^e4{\"a} - \gdefchar^^e5{\'l} - \gdefchar^^e6{\'c} - \gdefchar^^e7{\cedilla c} - \gdefchar^^e8{\v c} - \gdefchar^^e9{\'e} - \gdefchar^^ea{\ogonek{e}} - \gdefchar^^eb{\"e} - \gdefchar^^ec{\v e} - \gdefchar^^ed{\'{\dotless{i}}} - \gdefchar^^ee{\^{\dotless{i}}} - \gdefchar^^ef{\v d} + \gdef^^e0{\'r} + \gdef^^e1{\'a} + \gdef^^e2{\^a} + \gdef^^e3{\u a} + \gdef^^e4{\"a} + \gdef^^e5{\'l} + \gdef^^e6{\'c} + \gdef^^e7{\cedilla c} + \gdef^^e8{\v c} + \gdef^^e9{\'e} + \gdef^^ea{\ogonek{e}} + \gdef^^eb{\"e} + \gdef^^ec{\v e} + \gdef^^ed{\'\i} + \gdef^^ee{\^\i} + \gdef^^ef{\v d} % - \gdefchar^^f0{\dh} - \gdefchar^^f1{\'n} - \gdefchar^^f2{\v n} - \gdefchar^^f3{\'o} - \gdefchar^^f4{\^o} - \gdefchar^^f5{\H o} - \gdefchar^^f6{\"o} - \gdefchar^^f7{$\div$} - \gdefchar^^f8{\v r} - \gdefchar^^f9{\ringaccent u} - \gdefchar^^fa{\'u} - \gdefchar^^fb{\H u} - \gdefchar^^fc{\"u} - \gdefchar^^fd{\'y} - \gdefchar^^fe{\cedilla t} - \gdefchar^^ff{\dotaccent{}} + \gdef^^f0{\dh} + \gdef^^f1{\'n} + \gdef^^f2{\v n} + \gdef^^f3{\'o} + \gdef^^f4{\^o} + \gdef^^f5{\H o} + \gdef^^f6{\"o} + \gdef^^f7{$\div$} + \gdef^^f8{\v r} + \gdef^^f9{\ringaccent u} + \gdef^^fa{\'u} + \gdef^^fb{\H u} + \gdef^^fc{\"u} + \gdef^^fd{\'y} + \gdef^^fe{\cedilla t} + \gdef^^ff{\dotaccent{}} } % UTF-8 character definitions. @@ -10321,94 +8388,38 @@ directory should work if nowhere else does.} \fi } -% Give non-ASCII bytes the active definitions for processing UTF-8 sequences \begingroup \catcode`\~13 - \catcode`\$12 \catcode`\"12 - % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp - % substituting ~ and $ with a character token of that value. \def\UTFviiiLoop{% \global\catcode\countUTFx\active \uccode`\~\countUTFx - \uccode`\$\countUTFx \uppercase\expandafter{\UTFviiiTmp}% \advance\countUTFx by 1 \ifnum\countUTFx < \countUTFy \expandafter\UTFviiiLoop \fi} - % For bytes other than the first in a UTF-8 sequence. Not expected to - % be expanded except when writing to auxiliary files. - \countUTFx = "80 - \countUTFy = "C2 - \def\UTFviiiTmp{% - \gdef~{% - \ifpassthroughchars $\fi}}% - \UTFviiiLoop - \countUTFx = "C2 \countUTFy = "E0 \def\UTFviiiTmp{% - \gdef~{% - \ifpassthroughchars $% - \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}% + \xdef~{\noexpand\UTFviiiTwoOctets\string~}} \UTFviiiLoop \countUTFx = "E0 \countUTFy = "F0 \def\UTFviiiTmp{% - \gdef~{% - \ifpassthroughchars $% - \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}% + \xdef~{\noexpand\UTFviiiThreeOctets\string~}} \UTFviiiLoop \countUTFx = "F0 \countUTFy = "F4 \def\UTFviiiTmp{% - \gdef~{% - \ifpassthroughchars $% - \else\expandafter\UTFviiiFourOctets\expandafter$\fi - }}% + \xdef~{\noexpand\UTFviiiFourOctets\string~}} \UTFviiiLoop \endgroup -\def\globallet{\global\let} % save some \expandafter's below - -% @U{xxxx} to produce U+xxxx, if we support it. -\def\U#1{% - \expandafter\ifx\csname uni:#1\endcsname \relax - \iftxinativeunicodecapable - % All Unicode characters can be used if native Unicode handling is - % active. However, if the font does not have the glyph, - % letters are missing. - \begingroup - \uccode`\.="#1\relax - \uppercase{.} - \endgroup - \else - \errhelp = \EMsimple - \errmessage{Unicode character U+#1 not supported, sorry}% - \fi - \else - \csname uni:#1\endcsname - \fi -} - -% These macros are used here to construct the name of a control -% sequence to be defined. -\def\UTFviiiTwoOctetsName#1#2{% - \csname u8:#1\string #2\endcsname}% -\def\UTFviiiThreeOctetsName#1#2#3{% - \csname u8:#1\string #2\string #3\endcsname}% -\def\UTFviiiFourOctetsName#1#2#3#4{% - \csname u8:#1\string #2\string #3\string #4\endcsname}% - -% For UTF-8 byte sequences (TeX, e-TeX and pdfTeX), -% provide a definition macro to replace a Unicode character; -% this gets used by the @U command -% \begingroup \catcode`\"=12 \catcode`\<=12 @@ -10417,839 +8428,459 @@ directory should work if nowhere else does.} \catcode`\;=12 \catcode`\!=12 \catcode`\~=13 - \gdef\DeclareUnicodeCharacterUTFviii#1#2{% + + \gdef\DeclareUnicodeCharacter#1#2{% \countUTFz = "#1\relax + \wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}% \begingroup \parseXMLCharref - - % Give \u8:... its definition. The sequence of seven \expandafter's - % expands after the \gdef three times, e.g. - % - % 1. \UTFviiTwoOctetsName B1 B2 - % 2. \csname u8:B1 \string B2 \endcsname - % 3. \u8: B1 B2 (a single control sequence token) - % - \expandafter\expandafter - \expandafter\expandafter - \expandafter\expandafter - \expandafter\gdef \UTFviiiTmp{#2}% - % - \expandafter\ifx\csname uni:#1\endcsname \relax \else - \message{Internal error, already defined: #1}% - \fi - % - % define an additional control sequence for this code point. - \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp + \def\UTFviiiTwoOctets##1##2{% + \csname u8:##1\string ##2\endcsname}% + \def\UTFviiiThreeOctets##1##2##3{% + \csname u8:##1\string ##2\string ##3\endcsname}% + \def\UTFviiiFourOctets##1##2##3##4{% + \csname u8:##1\string ##2\string ##3\string ##4\endcsname}% + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter + \gdef\UTFviiiTmp{#2}% \endgroup} - % - % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp - % to the corresponding UTF-8 sequence. + \gdef\parseXMLCharref{% \ifnum\countUTFz < "A0\relax \errhelp = \EMsimple \errmessage{Cannot define Unicode char value < 00A0}% \else\ifnum\countUTFz < "800\relax \parseUTFviiiA,% - \parseUTFviiiB C\UTFviiiTwoOctetsName.,% + \parseUTFviiiB C\UTFviiiTwoOctets.,% \else\ifnum\countUTFz < "10000\relax \parseUTFviiiA;% \parseUTFviiiA,% - \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}% + \parseUTFviiiB E\UTFviiiThreeOctets.{,;}% \else \parseUTFviiiA;% \parseUTFviiiA,% \parseUTFviiiA!% - \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}% + \parseUTFviiiB F\UTFviiiFourOctets.{!,;}% \fi\fi\fi } - % Extract a byte from the end of the UTF-8 representation of \countUTFx. - % It must be a non-initial byte in the sequence. - % Change \uccode of #1 for it to be used in \parseUTFviiiB as one - % of the bytes. \gdef\parseUTFviiiA#1{% \countUTFx = \countUTFz \divide\countUTFz by 64 - \countUTFy = \countUTFz % Save to be the future value of \countUTFz. + \countUTFy = \countUTFz \multiply\countUTFz by 64 - - % \countUTFz is now \countUTFx with the last 5 bits cleared. Subtract - % in order to get the last five bits. \advance\countUTFx by -\countUTFz - - % Convert this to the byte in the UTF-8 sequence. \advance\countUTFx by 128 \uccode `#1\countUTFx \countUTFz = \countUTFy} - % Used to put a UTF-8 byte sequence into \UTFviiiTmp - % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8 - % sequence. - % #2 is one of the \UTFviii*OctetsName macros. - % #3 is always a full stop (.) - % #4 is a template for the other bytes in the sequence. The values for these - % bytes is substituted in here with \uppercase using the \uccode's. \gdef\parseUTFviiiB#1#2#3#4{% \advance\countUTFz by "#10\relax \uccode `#3\countUTFz \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} \endgroup -% For native Unicode handling (XeTeX and LuaTeX), -% provide a definition macro that sets a catcode to `other' non-globally -% -\def\DeclareUnicodeCharacterNativeOther#1#2{% - \catcode"#1=\other -} - -% https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M -% U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block) -% U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block) -% U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A -% U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B -% -% Many of our renditions are less than wonderful, and all the missing -% characters are available somewhere. Loading the necessary fonts -% awaits user request. We can't truly support Unicode without -% reimplementing everything that's been done in LaTeX for many years, -% plus probably using luatex or xetex, and who knows what else. -% We won't be doing that here in this simple file. But we can try to at -% least make most of the characters not bomb out. -% -\def\unicodechardefs{% - \DeclareUnicodeCharacter{00A0}{\tie}% - \DeclareUnicodeCharacter{00A1}{\exclamdown}% - \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent - \DeclareUnicodeCharacter{00A3}{\pounds{}}% - \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency - \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen - \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar - \DeclareUnicodeCharacter{00A7}{\S}% - \DeclareUnicodeCharacter{00A8}{\"{ }}% - \DeclareUnicodeCharacter{00A9}{\copyright{}}% - \DeclareUnicodeCharacter{00AA}{\ordf}% - \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}% - \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}% - \DeclareUnicodeCharacter{00AD}{\-}% - \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}% - \DeclareUnicodeCharacter{00AF}{\={ }}% - % - \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}% - \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}% - \DeclareUnicodeCharacter{00B2}{$^2$}% - \DeclareUnicodeCharacter{00B3}{$^3$}% - \DeclareUnicodeCharacter{00B4}{\'{ }}% - \DeclareUnicodeCharacter{00B5}{$\mu$}% - \DeclareUnicodeCharacter{00B6}{\P}% - \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}% - \DeclareUnicodeCharacter{00B8}{\cedilla{ }}% - \DeclareUnicodeCharacter{00B9}{$^1$}% - \DeclareUnicodeCharacter{00BA}{\ordm}% - \DeclareUnicodeCharacter{00BB}{\guillemetright{}}% - \DeclareUnicodeCharacter{00BC}{$1\over4$}% - \DeclareUnicodeCharacter{00BD}{$1\over2$}% - \DeclareUnicodeCharacter{00BE}{$3\over4$}% - \DeclareUnicodeCharacter{00BF}{\questiondown}% - % - \DeclareUnicodeCharacter{00C0}{\`A}% - \DeclareUnicodeCharacter{00C1}{\'A}% - \DeclareUnicodeCharacter{00C2}{\^A}% - \DeclareUnicodeCharacter{00C3}{\~A}% - \DeclareUnicodeCharacter{00C4}{\"A}% - \DeclareUnicodeCharacter{00C5}{\AA}% - \DeclareUnicodeCharacter{00C6}{\AE}% - \DeclareUnicodeCharacter{00C7}{\cedilla{C}}% - \DeclareUnicodeCharacter{00C8}{\`E}% - \DeclareUnicodeCharacter{00C9}{\'E}% - \DeclareUnicodeCharacter{00CA}{\^E}% - \DeclareUnicodeCharacter{00CB}{\"E}% - \DeclareUnicodeCharacter{00CC}{\`I}% - \DeclareUnicodeCharacter{00CD}{\'I}% - \DeclareUnicodeCharacter{00CE}{\^I}% - \DeclareUnicodeCharacter{00CF}{\"I}% - % - \DeclareUnicodeCharacter{00D0}{\DH}% - \DeclareUnicodeCharacter{00D1}{\~N}% - \DeclareUnicodeCharacter{00D2}{\`O}% - \DeclareUnicodeCharacter{00D3}{\'O}% - \DeclareUnicodeCharacter{00D4}{\^O}% - \DeclareUnicodeCharacter{00D5}{\~O}% - \DeclareUnicodeCharacter{00D6}{\"O}% - \DeclareUnicodeCharacter{00D7}{\ensuremath\times}% - \DeclareUnicodeCharacter{00D8}{\O}% - \DeclareUnicodeCharacter{00D9}{\`U}% - \DeclareUnicodeCharacter{00DA}{\'U}% - \DeclareUnicodeCharacter{00DB}{\^U}% - \DeclareUnicodeCharacter{00DC}{\"U}% - \DeclareUnicodeCharacter{00DD}{\'Y}% - \DeclareUnicodeCharacter{00DE}{\TH}% - \DeclareUnicodeCharacter{00DF}{\ss}% - % - \DeclareUnicodeCharacter{00E0}{\`a}% - \DeclareUnicodeCharacter{00E1}{\'a}% - \DeclareUnicodeCharacter{00E2}{\^a}% - \DeclareUnicodeCharacter{00E3}{\~a}% - \DeclareUnicodeCharacter{00E4}{\"a}% - \DeclareUnicodeCharacter{00E5}{\aa}% - \DeclareUnicodeCharacter{00E6}{\ae}% - \DeclareUnicodeCharacter{00E7}{\cedilla{c}}% - \DeclareUnicodeCharacter{00E8}{\`e}% - \DeclareUnicodeCharacter{00E9}{\'e}% - \DeclareUnicodeCharacter{00EA}{\^e}% - \DeclareUnicodeCharacter{00EB}{\"e}% - \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}% - \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}% - \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}% - \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}% - % - \DeclareUnicodeCharacter{00F0}{\dh}% - \DeclareUnicodeCharacter{00F1}{\~n}% - \DeclareUnicodeCharacter{00F2}{\`o}% - \DeclareUnicodeCharacter{00F3}{\'o}% - \DeclareUnicodeCharacter{00F4}{\^o}% - \DeclareUnicodeCharacter{00F5}{\~o}% - \DeclareUnicodeCharacter{00F6}{\"o}% - \DeclareUnicodeCharacter{00F7}{\ensuremath\div}% - \DeclareUnicodeCharacter{00F8}{\o}% - \DeclareUnicodeCharacter{00F9}{\`u}% - \DeclareUnicodeCharacter{00FA}{\'u}% - \DeclareUnicodeCharacter{00FB}{\^u}% - \DeclareUnicodeCharacter{00FC}{\"u}% - \DeclareUnicodeCharacter{00FD}{\'y}% - \DeclareUnicodeCharacter{00FE}{\th}% - \DeclareUnicodeCharacter{00FF}{\"y}% - % - \DeclareUnicodeCharacter{0100}{\=A}% - \DeclareUnicodeCharacter{0101}{\=a}% - \DeclareUnicodeCharacter{0102}{\u{A}}% - \DeclareUnicodeCharacter{0103}{\u{a}}% - \DeclareUnicodeCharacter{0104}{\ogonek{A}}% - \DeclareUnicodeCharacter{0105}{\ogonek{a}}% - \DeclareUnicodeCharacter{0106}{\'C}% - \DeclareUnicodeCharacter{0107}{\'c}% - \DeclareUnicodeCharacter{0108}{\^C}% - \DeclareUnicodeCharacter{0109}{\^c}% - \DeclareUnicodeCharacter{010A}{\dotaccent{C}}% - \DeclareUnicodeCharacter{010B}{\dotaccent{c}}% - \DeclareUnicodeCharacter{010C}{\v{C}}% - \DeclareUnicodeCharacter{010D}{\v{c}}% - \DeclareUnicodeCharacter{010E}{\v{D}}% - \DeclareUnicodeCharacter{010F}{d'}% - % - \DeclareUnicodeCharacter{0110}{\DH}% - \DeclareUnicodeCharacter{0111}{\dh}% - \DeclareUnicodeCharacter{0112}{\=E}% - \DeclareUnicodeCharacter{0113}{\=e}% - \DeclareUnicodeCharacter{0114}{\u{E}}% - \DeclareUnicodeCharacter{0115}{\u{e}}% - \DeclareUnicodeCharacter{0116}{\dotaccent{E}}% - \DeclareUnicodeCharacter{0117}{\dotaccent{e}}% - \DeclareUnicodeCharacter{0118}{\ogonek{E}}% - \DeclareUnicodeCharacter{0119}{\ogonek{e}}% - \DeclareUnicodeCharacter{011A}{\v{E}}% - \DeclareUnicodeCharacter{011B}{\v{e}}% - \DeclareUnicodeCharacter{011C}{\^G}% - \DeclareUnicodeCharacter{011D}{\^g}% - \DeclareUnicodeCharacter{011E}{\u{G}}% - \DeclareUnicodeCharacter{011F}{\u{g}}% - % - \DeclareUnicodeCharacter{0120}{\dotaccent{G}}% - \DeclareUnicodeCharacter{0121}{\dotaccent{g}}% - \DeclareUnicodeCharacter{0122}{\cedilla{G}}% - \DeclareUnicodeCharacter{0123}{\cedilla{g}}% - \DeclareUnicodeCharacter{0124}{\^H}% - \DeclareUnicodeCharacter{0125}{\^h}% - \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}% - \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}% - \DeclareUnicodeCharacter{0128}{\~I}% - \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}% - \DeclareUnicodeCharacter{012A}{\=I}% - \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}% - \DeclareUnicodeCharacter{012C}{\u{I}}% - \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}% - \DeclareUnicodeCharacter{012E}{\ogonek{I}}% - \DeclareUnicodeCharacter{012F}{\ogonek{i}}% - % - \DeclareUnicodeCharacter{0130}{\dotaccent{I}}% - \DeclareUnicodeCharacter{0131}{\dotless{i}}% - \DeclareUnicodeCharacter{0132}{IJ}% - \DeclareUnicodeCharacter{0133}{ij}% - \DeclareUnicodeCharacter{0134}{\^J}% - \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}% - \DeclareUnicodeCharacter{0136}{\cedilla{K}}% - \DeclareUnicodeCharacter{0137}{\cedilla{k}}% - \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}% - \DeclareUnicodeCharacter{0139}{\'L}% - \DeclareUnicodeCharacter{013A}{\'l}% - \DeclareUnicodeCharacter{013B}{\cedilla{L}}% - \DeclareUnicodeCharacter{013C}{\cedilla{l}}% - \DeclareUnicodeCharacter{013D}{L'}% should kern - \DeclareUnicodeCharacter{013E}{l'}% should kern - \DeclareUnicodeCharacter{013F}{L\U{00B7}}% - % - \DeclareUnicodeCharacter{0140}{l\U{00B7}}% - \DeclareUnicodeCharacter{0141}{\L}% - \DeclareUnicodeCharacter{0142}{\l}% - \DeclareUnicodeCharacter{0143}{\'N}% - \DeclareUnicodeCharacter{0144}{\'n}% - \DeclareUnicodeCharacter{0145}{\cedilla{N}}% - \DeclareUnicodeCharacter{0146}{\cedilla{n}}% - \DeclareUnicodeCharacter{0147}{\v{N}}% - \DeclareUnicodeCharacter{0148}{\v{n}}% - \DeclareUnicodeCharacter{0149}{'n}% - \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}% - \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}% - \DeclareUnicodeCharacter{014C}{\=O}% - \DeclareUnicodeCharacter{014D}{\=o}% - \DeclareUnicodeCharacter{014E}{\u{O}}% - \DeclareUnicodeCharacter{014F}{\u{o}}% - % - \DeclareUnicodeCharacter{0150}{\H{O}}% - \DeclareUnicodeCharacter{0151}{\H{o}}% - \DeclareUnicodeCharacter{0152}{\OE}% - \DeclareUnicodeCharacter{0153}{\oe}% - \DeclareUnicodeCharacter{0154}{\'R}% - \DeclareUnicodeCharacter{0155}{\'r}% - \DeclareUnicodeCharacter{0156}{\cedilla{R}}% - \DeclareUnicodeCharacter{0157}{\cedilla{r}}% - \DeclareUnicodeCharacter{0158}{\v{R}}% - \DeclareUnicodeCharacter{0159}{\v{r}}% - \DeclareUnicodeCharacter{015A}{\'S}% - \DeclareUnicodeCharacter{015B}{\'s}% - \DeclareUnicodeCharacter{015C}{\^S}% - \DeclareUnicodeCharacter{015D}{\^s}% - \DeclareUnicodeCharacter{015E}{\cedilla{S}}% - \DeclareUnicodeCharacter{015F}{\cedilla{s}}% - % - \DeclareUnicodeCharacter{0160}{\v{S}}% - \DeclareUnicodeCharacter{0161}{\v{s}}% - \DeclareUnicodeCharacter{0162}{\cedilla{T}}% - \DeclareUnicodeCharacter{0163}{\cedilla{t}}% - \DeclareUnicodeCharacter{0164}{\v{T}}% - \DeclareUnicodeCharacter{0165}{\v{t}}% - \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}% - \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}% - \DeclareUnicodeCharacter{0168}{\~U}% - \DeclareUnicodeCharacter{0169}{\~u}% - \DeclareUnicodeCharacter{016A}{\=U}% - \DeclareUnicodeCharacter{016B}{\=u}% - \DeclareUnicodeCharacter{016C}{\u{U}}% - \DeclareUnicodeCharacter{016D}{\u{u}}% - \DeclareUnicodeCharacter{016E}{\ringaccent{U}}% - \DeclareUnicodeCharacter{016F}{\ringaccent{u}}% - % - \DeclareUnicodeCharacter{0170}{\H{U}}% - \DeclareUnicodeCharacter{0171}{\H{u}}% - \DeclareUnicodeCharacter{0172}{\ogonek{U}}% - \DeclareUnicodeCharacter{0173}{\ogonek{u}}% - \DeclareUnicodeCharacter{0174}{\^W}% - \DeclareUnicodeCharacter{0175}{\^w}% - \DeclareUnicodeCharacter{0176}{\^Y}% - \DeclareUnicodeCharacter{0177}{\^y}% - \DeclareUnicodeCharacter{0178}{\"Y}% - \DeclareUnicodeCharacter{0179}{\'Z}% - \DeclareUnicodeCharacter{017A}{\'z}% - \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}% - \DeclareUnicodeCharacter{017C}{\dotaccent{z}}% - \DeclareUnicodeCharacter{017D}{\v{Z}}% - \DeclareUnicodeCharacter{017E}{\v{z}}% - \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}% - % - \DeclareUnicodeCharacter{01C4}{D\v{Z}}% - \DeclareUnicodeCharacter{01C5}{D\v{z}}% - \DeclareUnicodeCharacter{01C6}{d\v{z}}% - \DeclareUnicodeCharacter{01C7}{LJ}% - \DeclareUnicodeCharacter{01C8}{Lj}% - \DeclareUnicodeCharacter{01C9}{lj}% - \DeclareUnicodeCharacter{01CA}{NJ}% - \DeclareUnicodeCharacter{01CB}{Nj}% - \DeclareUnicodeCharacter{01CC}{nj}% - \DeclareUnicodeCharacter{01CD}{\v{A}}% - \DeclareUnicodeCharacter{01CE}{\v{a}}% - \DeclareUnicodeCharacter{01CF}{\v{I}}% - % - \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}% - \DeclareUnicodeCharacter{01D1}{\v{O}}% - \DeclareUnicodeCharacter{01D2}{\v{o}}% - \DeclareUnicodeCharacter{01D3}{\v{U}}% - \DeclareUnicodeCharacter{01D4}{\v{u}}% - % - \DeclareUnicodeCharacter{01E2}{\={\AE}}% - \DeclareUnicodeCharacter{01E3}{\={\ae}}% - \DeclareUnicodeCharacter{01E6}{\v{G}}% - \DeclareUnicodeCharacter{01E7}{\v{g}}% - \DeclareUnicodeCharacter{01E8}{\v{K}}% - \DeclareUnicodeCharacter{01E9}{\v{k}}% - % - \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}% - \DeclareUnicodeCharacter{01F1}{DZ}% - \DeclareUnicodeCharacter{01F2}{Dz}% - \DeclareUnicodeCharacter{01F3}{dz}% - \DeclareUnicodeCharacter{01F4}{\'G}% - \DeclareUnicodeCharacter{01F5}{\'g}% - \DeclareUnicodeCharacter{01F8}{\`N}% - \DeclareUnicodeCharacter{01F9}{\`n}% - \DeclareUnicodeCharacter{01FC}{\'{\AE}}% - \DeclareUnicodeCharacter{01FD}{\'{\ae}}% - \DeclareUnicodeCharacter{01FE}{\'{\O}}% - \DeclareUnicodeCharacter{01FF}{\'{\o}}% - % - \DeclareUnicodeCharacter{021E}{\v{H}}% - \DeclareUnicodeCharacter{021F}{\v{h}}% - % - \DeclareUnicodeCharacter{0226}{\dotaccent{A}}% - \DeclareUnicodeCharacter{0227}{\dotaccent{a}}% - \DeclareUnicodeCharacter{0228}{\cedilla{E}}% - \DeclareUnicodeCharacter{0229}{\cedilla{e}}% - \DeclareUnicodeCharacter{022E}{\dotaccent{O}}% - \DeclareUnicodeCharacter{022F}{\dotaccent{o}}% - % - \DeclareUnicodeCharacter{0232}{\=Y}% - \DeclareUnicodeCharacter{0233}{\=y}% - \DeclareUnicodeCharacter{0237}{\dotless{j}}% - % - \DeclareUnicodeCharacter{02DB}{\ogonek{ }}% - % - % Greek letters upper case - \DeclareUnicodeCharacter{0391}{{\it A}}% - \DeclareUnicodeCharacter{0392}{{\it B}}% - \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}% - \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}% - \DeclareUnicodeCharacter{0395}{{\it E}}% - \DeclareUnicodeCharacter{0396}{{\it Z}}% - \DeclareUnicodeCharacter{0397}{{\it H}}% - \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}% - \DeclareUnicodeCharacter{0399}{{\it I}}% - \DeclareUnicodeCharacter{039A}{{\it K}}% - \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}% - \DeclareUnicodeCharacter{039C}{{\it M}}% - \DeclareUnicodeCharacter{039D}{{\it N}}% - \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}% - \DeclareUnicodeCharacter{039F}{{\it O}}% - \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}% - \DeclareUnicodeCharacter{03A1}{{\it P}}% - %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma - \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}% - \DeclareUnicodeCharacter{03A4}{{\it T}}% - \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}% - \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}% - \DeclareUnicodeCharacter{03A7}{{\it X}}% - \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}% - \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}% - % - % Vowels with accents - \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}% - \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}% - \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}% - \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}% - \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}% - \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}% - % - % Standalone accent - \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}% - % - % Greek letters lower case - \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}% - \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}% - \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}% - \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}% - \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}% - \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}% - \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}% - \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}% - \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}% - \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}% - \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}% - \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}% - \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}% - \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}% - \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron - \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}% - \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}% - \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}% - \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}% - \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}% - \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}% - \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}% - \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}% - \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}% - \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}% - % - % More Greek vowels with accents - \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}% - \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}% - \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}% - \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}% - \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}% - % - % Variant Greek letters - \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}% - \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}% - \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}% - % - \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}% - \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}% - \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}% - \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}% - \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}% - \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}% - \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}% - \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}% - \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}% - \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}% - \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}% - \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}% - % - \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}% - \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}% - % - \DeclareUnicodeCharacter{1E20}{\=G}% - \DeclareUnicodeCharacter{1E21}{\=g}% - \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}% - \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}% - \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}% - \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}% - \DeclareUnicodeCharacter{1E26}{\"H}% - \DeclareUnicodeCharacter{1E27}{\"h}% - % - \DeclareUnicodeCharacter{1E30}{\'K}% - \DeclareUnicodeCharacter{1E31}{\'k}% - \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}% - \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}% - \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}% - \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}% - \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}% - \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}% - \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}% - \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}% - \DeclareUnicodeCharacter{1E3E}{\'M}% - \DeclareUnicodeCharacter{1E3F}{\'m}% - % - \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}% - \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}% - \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}% - \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}% - \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}% - \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}% - \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}% - \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}% - \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}% - \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}% - % - \DeclareUnicodeCharacter{1E54}{\'P}% - \DeclareUnicodeCharacter{1E55}{\'p}% - \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}% - \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}% - \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}% - \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}% - \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}% - \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}% - \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}% - \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}% - % - \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}% - \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}% - \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}% - \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}% - \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}% - \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}% - \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}% - \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}% - \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}% - \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}% - % - \DeclareUnicodeCharacter{1E7C}{\~V}% - \DeclareUnicodeCharacter{1E7D}{\~v}% - \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}% - \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}% - % - \DeclareUnicodeCharacter{1E80}{\`W}% - \DeclareUnicodeCharacter{1E81}{\`w}% - \DeclareUnicodeCharacter{1E82}{\'W}% - \DeclareUnicodeCharacter{1E83}{\'w}% - \DeclareUnicodeCharacter{1E84}{\"W}% - \DeclareUnicodeCharacter{1E85}{\"w}% - \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}% - \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}% - \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}% - \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}% - \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}% - \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}% - \DeclareUnicodeCharacter{1E8C}{\"X}% - \DeclareUnicodeCharacter{1E8D}{\"x}% - \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}% - \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}% - % - \DeclareUnicodeCharacter{1E90}{\^Z}% - \DeclareUnicodeCharacter{1E91}{\^z}% - \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}% - \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}% - \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}% - \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}% - \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}% - \DeclareUnicodeCharacter{1E97}{\"t}% - \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}% - \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}% - % - \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}% - \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}% - % - \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}% - \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}% - \DeclareUnicodeCharacter{1EBC}{\~E}% - \DeclareUnicodeCharacter{1EBD}{\~e}% - % - \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}% - \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}% - \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}% - \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}% - % - \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}% - \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}% - % - \DeclareUnicodeCharacter{1EF2}{\`Y}% - \DeclareUnicodeCharacter{1EF3}{\`y}% - \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}% - % - \DeclareUnicodeCharacter{1EF8}{\~Y}% - \DeclareUnicodeCharacter{1EF9}{\~y}% - % - % Punctuation - \DeclareUnicodeCharacter{2013}{--}% - \DeclareUnicodeCharacter{2014}{---}% - \DeclareUnicodeCharacter{2018}{\quoteleft{}}% - \DeclareUnicodeCharacter{2019}{\quoteright{}}% - \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}% - \DeclareUnicodeCharacter{201C}{\quotedblleft{}}% - \DeclareUnicodeCharacter{201D}{\quotedblright{}}% - \DeclareUnicodeCharacter{201E}{\quotedblbase{}}% - \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}% - \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}% - \DeclareUnicodeCharacter{2022}{\bullet{}}% - \DeclareUnicodeCharacter{202F}{\thinspace}% - \DeclareUnicodeCharacter{2026}{\dots{}}% - \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}% - \DeclareUnicodeCharacter{203A}{\guilsinglright{}}% - % - \DeclareUnicodeCharacter{20AC}{\euro{}}% - % - \DeclareUnicodeCharacter{2192}{\expansion{}}% - \DeclareUnicodeCharacter{21D2}{\result{}}% - % - % Mathematical symbols - \DeclareUnicodeCharacter{2200}{\ensuremath\forall}% - \DeclareUnicodeCharacter{2203}{\ensuremath\exists}% - \DeclareUnicodeCharacter{2208}{\ensuremath\in}% - \DeclareUnicodeCharacter{2212}{\minus{}}% - \DeclareUnicodeCharacter{2217}{\ast}% - \DeclareUnicodeCharacter{221E}{\ensuremath\infty}% - \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}% - \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}% - \DeclareUnicodeCharacter{2229}{\ensuremath\cap}% - \DeclareUnicodeCharacter{2261}{\equiv{}}% - \DeclareUnicodeCharacter{2264}{\ensuremath\leq}% - \DeclareUnicodeCharacter{2265}{\ensuremath\geq}% - \DeclareUnicodeCharacter{2282}{\ensuremath\subset}% - \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}% - % - \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}% - \DeclareUnicodeCharacter{2032}{\ensuremath\prime}% - \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}% - \DeclareUnicodeCharacter{2111}{\ensuremath\Im}% - \DeclareUnicodeCharacter{2113}{\ensuremath\ell}% - \DeclareUnicodeCharacter{2118}{\ensuremath\wp}% - \DeclareUnicodeCharacter{211C}{\ensuremath\Re}% - \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}% - \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}% - \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}% - \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}% - \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}% - \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}% - \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}% - \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}% - \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}% - \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}% - \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}% - \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}% - \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}% - \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}% - \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}% - \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}% - \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}% - \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}% - \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}% - \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}% - \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}% - \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}% - \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}% - \DeclareUnicodeCharacter{2202}{\ensuremath\partial}% - \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}% - \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}% - \DeclareUnicodeCharacter{2209}{\ensuremath\notin}% - \DeclareUnicodeCharacter{220B}{\ensuremath\owns}% - \DeclareUnicodeCharacter{220F}{\ensuremath\prod}% - \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}% - \DeclareUnicodeCharacter{2211}{\ensuremath\sum}% - \DeclareUnicodeCharacter{2213}{\ensuremath\mp}% - \DeclareUnicodeCharacter{2218}{\ensuremath\circ}% - \DeclareUnicodeCharacter{221A}{\ensuremath\surd}% - \DeclareUnicodeCharacter{221D}{\ensuremath\propto}% - \DeclareUnicodeCharacter{2220}{\ensuremath\angle}% - \DeclareUnicodeCharacter{2223}{\ensuremath\mid}% - \DeclareUnicodeCharacter{2228}{\ensuremath\vee}% - \DeclareUnicodeCharacter{222A}{\ensuremath\cup}% - \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}% - \DeclareUnicodeCharacter{222E}{\ensuremath\oint}% - \DeclareUnicodeCharacter{223C}{\ensuremath\sim}% - \DeclareUnicodeCharacter{2240}{\ensuremath\wr}% - \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}% - \DeclareUnicodeCharacter{2245}{\ensuremath\cong}% - \DeclareUnicodeCharacter{2248}{\ensuremath\approx}% - \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}% - \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}% - \DeclareUnicodeCharacter{2260}{\ensuremath\neq}% - \DeclareUnicodeCharacter{226A}{\ensuremath\ll}% - \DeclareUnicodeCharacter{226B}{\ensuremath\gg}% - \DeclareUnicodeCharacter{227A}{\ensuremath\prec}% - \DeclareUnicodeCharacter{227B}{\ensuremath\succ}% - \DeclareUnicodeCharacter{2283}{\ensuremath\supset}% - \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}% - \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}% - \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}% - \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}% - \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}% - \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}% - \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}% - \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}% - \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}% - \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}% - \DeclareUnicodeCharacter{2299}{\ensuremath\odot}% - \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}% - \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}% - \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}% - \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}% - \DeclareUnicodeCharacter{22A8}{\ensuremath\models}% - \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}% - \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}% - \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}% - \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}% - \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}% - \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}% - \DeclareUnicodeCharacter{22C6}{\ensuremath\star}% - \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}% - \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}% - \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}% - \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}% - \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}% - \DeclareUnicodeCharacter{2322}{\ensuremath\frown}% - \DeclareUnicodeCharacter{2323}{\ensuremath\smile}% - % - \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}% - \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}% - \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}% - \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}% - \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}% - \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}% - \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}% - \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}% - \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}% - \DeclareUnicodeCharacter{266D}{\ensuremath\flat}% - \DeclareUnicodeCharacter{266E}{\ensuremath\natural}% - \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}% - \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}% - \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}% - \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}% - \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}% - \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}% - \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}% - \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}% - \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}% - \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}% - \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}% - \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}% - \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}% - \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}% - \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}% - \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}% - \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}% - \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}% - % - \global\mathchardef\checkmark="1370% actually the square root sign - \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}% -}% end of \unicodechardefs - -% UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command) -% It makes the setting that replace UTF-8 byte sequence. \def\utfeightchardefs{% - \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii - \unicodechardefs -} + \DeclareUnicodeCharacter{00A0}{\tie} + \DeclareUnicodeCharacter{00A1}{\exclamdown} + \DeclareUnicodeCharacter{00A3}{\pounds} + \DeclareUnicodeCharacter{00A8}{\"{ }} + \DeclareUnicodeCharacter{00A9}{\copyright} + \DeclareUnicodeCharacter{00AA}{\ordf} + \DeclareUnicodeCharacter{00AB}{\guillemetleft} + \DeclareUnicodeCharacter{00AD}{\-} + \DeclareUnicodeCharacter{00AE}{\registeredsymbol} + \DeclareUnicodeCharacter{00AF}{\={ }} -% Whether the active definitions of non-ASCII characters expand to -% non-active tokens with the same character code. This is used to -% write characters literally, instead of using active definitions for -% printing the correct glyphs. -\newif\ifpassthroughchars -\passthroughcharsfalse + \DeclareUnicodeCharacter{00B0}{\ringaccent{ }} + \DeclareUnicodeCharacter{00B4}{\'{ }} + \DeclareUnicodeCharacter{00B8}{\cedilla{ }} + \DeclareUnicodeCharacter{00BA}{\ordm} + \DeclareUnicodeCharacter{00BB}{\guillemetright} + \DeclareUnicodeCharacter{00BF}{\questiondown} -% For native Unicode handling (XeTeX and LuaTeX), -% provide a definition macro to replace/pass-through a Unicode character -% -\def\DeclareUnicodeCharacterNative#1#2{% - \catcode"#1=\active - \def\dodeclareunicodecharacternative##1##2##3{% - \begingroup - \uccode`\~="##2\relax - \uppercase{\gdef~}{% - \ifpassthroughchars - ##1% - \else - ##3% - \fi - } - \endgroup - } - \begingroup - \uccode`\.="#1\relax - \uppercase{\def\UTFNativeTmp{.}}% - \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}% - \endgroup -} + \DeclareUnicodeCharacter{00C0}{\`A} + \DeclareUnicodeCharacter{00C1}{\'A} + \DeclareUnicodeCharacter{00C2}{\^A} + \DeclareUnicodeCharacter{00C3}{\~A} + \DeclareUnicodeCharacter{00C4}{\"A} + \DeclareUnicodeCharacter{00C5}{\AA} + \DeclareUnicodeCharacter{00C6}{\AE} + \DeclareUnicodeCharacter{00C7}{\cedilla{C}} + \DeclareUnicodeCharacter{00C8}{\`E} + \DeclareUnicodeCharacter{00C9}{\'E} + \DeclareUnicodeCharacter{00CA}{\^E} + \DeclareUnicodeCharacter{00CB}{\"E} + \DeclareUnicodeCharacter{00CC}{\`I} + \DeclareUnicodeCharacter{00CD}{\'I} + \DeclareUnicodeCharacter{00CE}{\^I} + \DeclareUnicodeCharacter{00CF}{\"I} -% Native Unicode handling (XeTeX and LuaTeX) character replacing definition. -% It activates the setting that replaces Unicode characters. -\def\nativeunicodechardefs{% - \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative - \unicodechardefs -} + \DeclareUnicodeCharacter{00D0}{\DH} + \DeclareUnicodeCharacter{00D1}{\~N} + \DeclareUnicodeCharacter{00D2}{\`O} + \DeclareUnicodeCharacter{00D3}{\'O} + \DeclareUnicodeCharacter{00D4}{\^O} + \DeclareUnicodeCharacter{00D5}{\~O} + \DeclareUnicodeCharacter{00D6}{\"O} + \DeclareUnicodeCharacter{00D8}{\O} + \DeclareUnicodeCharacter{00D9}{\`U} + \DeclareUnicodeCharacter{00DA}{\'U} + \DeclareUnicodeCharacter{00DB}{\^U} + \DeclareUnicodeCharacter{00DC}{\"U} + \DeclareUnicodeCharacter{00DD}{\'Y} + \DeclareUnicodeCharacter{00DE}{\TH} + \DeclareUnicodeCharacter{00DF}{\ss} -% For native Unicode handling (XeTeX and LuaTeX), -% make the character token expand -% to the sequences given in \unicodechardefs for printing. -\def\DeclareUnicodeCharacterNativeAtU#1#2{% - \def\UTFAtUTmp{#2} - \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp -} + \DeclareUnicodeCharacter{00E0}{\`a} + \DeclareUnicodeCharacter{00E1}{\'a} + \DeclareUnicodeCharacter{00E2}{\^a} + \DeclareUnicodeCharacter{00E3}{\~a} + \DeclareUnicodeCharacter{00E4}{\"a} + \DeclareUnicodeCharacter{00E5}{\aa} + \DeclareUnicodeCharacter{00E6}{\ae} + \DeclareUnicodeCharacter{00E7}{\cedilla{c}} + \DeclareUnicodeCharacter{00E8}{\`e} + \DeclareUnicodeCharacter{00E9}{\'e} + \DeclareUnicodeCharacter{00EA}{\^e} + \DeclareUnicodeCharacter{00EB}{\"e} + \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}} + \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}} + \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}} + \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}} + + \DeclareUnicodeCharacter{00F0}{\dh} + \DeclareUnicodeCharacter{00F1}{\~n} + \DeclareUnicodeCharacter{00F2}{\`o} + \DeclareUnicodeCharacter{00F3}{\'o} + \DeclareUnicodeCharacter{00F4}{\^o} + \DeclareUnicodeCharacter{00F5}{\~o} + \DeclareUnicodeCharacter{00F6}{\"o} + \DeclareUnicodeCharacter{00F8}{\o} + \DeclareUnicodeCharacter{00F9}{\`u} + \DeclareUnicodeCharacter{00FA}{\'u} + \DeclareUnicodeCharacter{00FB}{\^u} + \DeclareUnicodeCharacter{00FC}{\"u} + \DeclareUnicodeCharacter{00FD}{\'y} + \DeclareUnicodeCharacter{00FE}{\th} + \DeclareUnicodeCharacter{00FF}{\"y} + + \DeclareUnicodeCharacter{0100}{\=A} + \DeclareUnicodeCharacter{0101}{\=a} + \DeclareUnicodeCharacter{0102}{\u{A}} + \DeclareUnicodeCharacter{0103}{\u{a}} + \DeclareUnicodeCharacter{0104}{\ogonek{A}} + \DeclareUnicodeCharacter{0105}{\ogonek{a}} + \DeclareUnicodeCharacter{0106}{\'C} + \DeclareUnicodeCharacter{0107}{\'c} + \DeclareUnicodeCharacter{0108}{\^C} + \DeclareUnicodeCharacter{0109}{\^c} + \DeclareUnicodeCharacter{0118}{\ogonek{E}} + \DeclareUnicodeCharacter{0119}{\ogonek{e}} + \DeclareUnicodeCharacter{010A}{\dotaccent{C}} + \DeclareUnicodeCharacter{010B}{\dotaccent{c}} + \DeclareUnicodeCharacter{010C}{\v{C}} + \DeclareUnicodeCharacter{010D}{\v{c}} + \DeclareUnicodeCharacter{010E}{\v{D}} + + \DeclareUnicodeCharacter{0112}{\=E} + \DeclareUnicodeCharacter{0113}{\=e} + \DeclareUnicodeCharacter{0114}{\u{E}} + \DeclareUnicodeCharacter{0115}{\u{e}} + \DeclareUnicodeCharacter{0116}{\dotaccent{E}} + \DeclareUnicodeCharacter{0117}{\dotaccent{e}} + \DeclareUnicodeCharacter{011A}{\v{E}} + \DeclareUnicodeCharacter{011B}{\v{e}} + \DeclareUnicodeCharacter{011C}{\^G} + \DeclareUnicodeCharacter{011D}{\^g} + \DeclareUnicodeCharacter{011E}{\u{G}} + \DeclareUnicodeCharacter{011F}{\u{g}} + + \DeclareUnicodeCharacter{0120}{\dotaccent{G}} + \DeclareUnicodeCharacter{0121}{\dotaccent{g}} + \DeclareUnicodeCharacter{0124}{\^H} + \DeclareUnicodeCharacter{0125}{\^h} + \DeclareUnicodeCharacter{0128}{\~I} + \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}} + \DeclareUnicodeCharacter{012A}{\=I} + \DeclareUnicodeCharacter{012B}{\={\dotless{i}}} + \DeclareUnicodeCharacter{012C}{\u{I}} + \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}} + + \DeclareUnicodeCharacter{0130}{\dotaccent{I}} + \DeclareUnicodeCharacter{0131}{\dotless{i}} + \DeclareUnicodeCharacter{0132}{IJ} + \DeclareUnicodeCharacter{0133}{ij} + \DeclareUnicodeCharacter{0134}{\^J} + \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}} + \DeclareUnicodeCharacter{0139}{\'L} + \DeclareUnicodeCharacter{013A}{\'l} + + \DeclareUnicodeCharacter{0141}{\L} + \DeclareUnicodeCharacter{0142}{\l} + \DeclareUnicodeCharacter{0143}{\'N} + \DeclareUnicodeCharacter{0144}{\'n} + \DeclareUnicodeCharacter{0147}{\v{N}} + \DeclareUnicodeCharacter{0148}{\v{n}} + \DeclareUnicodeCharacter{014C}{\=O} + \DeclareUnicodeCharacter{014D}{\=o} + \DeclareUnicodeCharacter{014E}{\u{O}} + \DeclareUnicodeCharacter{014F}{\u{o}} + + \DeclareUnicodeCharacter{0150}{\H{O}} + \DeclareUnicodeCharacter{0151}{\H{o}} + \DeclareUnicodeCharacter{0152}{\OE} + \DeclareUnicodeCharacter{0153}{\oe} + \DeclareUnicodeCharacter{0154}{\'R} + \DeclareUnicodeCharacter{0155}{\'r} + \DeclareUnicodeCharacter{0158}{\v{R}} + \DeclareUnicodeCharacter{0159}{\v{r}} + \DeclareUnicodeCharacter{015A}{\'S} + \DeclareUnicodeCharacter{015B}{\'s} + \DeclareUnicodeCharacter{015C}{\^S} + \DeclareUnicodeCharacter{015D}{\^s} + \DeclareUnicodeCharacter{015E}{\cedilla{S}} + \DeclareUnicodeCharacter{015F}{\cedilla{s}} + + \DeclareUnicodeCharacter{0160}{\v{S}} + \DeclareUnicodeCharacter{0161}{\v{s}} + \DeclareUnicodeCharacter{0162}{\cedilla{t}} + \DeclareUnicodeCharacter{0163}{\cedilla{T}} + \DeclareUnicodeCharacter{0164}{\v{T}} + + \DeclareUnicodeCharacter{0168}{\~U} + \DeclareUnicodeCharacter{0169}{\~u} + \DeclareUnicodeCharacter{016A}{\=U} + \DeclareUnicodeCharacter{016B}{\=u} + \DeclareUnicodeCharacter{016C}{\u{U}} + \DeclareUnicodeCharacter{016D}{\u{u}} + \DeclareUnicodeCharacter{016E}{\ringaccent{U}} + \DeclareUnicodeCharacter{016F}{\ringaccent{u}} + + \DeclareUnicodeCharacter{0170}{\H{U}} + \DeclareUnicodeCharacter{0171}{\H{u}} + \DeclareUnicodeCharacter{0174}{\^W} + \DeclareUnicodeCharacter{0175}{\^w} + \DeclareUnicodeCharacter{0176}{\^Y} + \DeclareUnicodeCharacter{0177}{\^y} + \DeclareUnicodeCharacter{0178}{\"Y} + \DeclareUnicodeCharacter{0179}{\'Z} + \DeclareUnicodeCharacter{017A}{\'z} + \DeclareUnicodeCharacter{017B}{\dotaccent{Z}} + \DeclareUnicodeCharacter{017C}{\dotaccent{z}} + \DeclareUnicodeCharacter{017D}{\v{Z}} + \DeclareUnicodeCharacter{017E}{\v{z}} + + \DeclareUnicodeCharacter{01C4}{D\v{Z}} + \DeclareUnicodeCharacter{01C5}{D\v{z}} + \DeclareUnicodeCharacter{01C6}{d\v{z}} + \DeclareUnicodeCharacter{01C7}{LJ} + \DeclareUnicodeCharacter{01C8}{Lj} + \DeclareUnicodeCharacter{01C9}{lj} + \DeclareUnicodeCharacter{01CA}{NJ} + \DeclareUnicodeCharacter{01CB}{Nj} + \DeclareUnicodeCharacter{01CC}{nj} + \DeclareUnicodeCharacter{01CD}{\v{A}} + \DeclareUnicodeCharacter{01CE}{\v{a}} + \DeclareUnicodeCharacter{01CF}{\v{I}} + + \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}} + \DeclareUnicodeCharacter{01D1}{\v{O}} + \DeclareUnicodeCharacter{01D2}{\v{o}} + \DeclareUnicodeCharacter{01D3}{\v{U}} + \DeclareUnicodeCharacter{01D4}{\v{u}} + + \DeclareUnicodeCharacter{01E2}{\={\AE}} + \DeclareUnicodeCharacter{01E3}{\={\ae}} + \DeclareUnicodeCharacter{01E6}{\v{G}} + \DeclareUnicodeCharacter{01E7}{\v{g}} + \DeclareUnicodeCharacter{01E8}{\v{K}} + \DeclareUnicodeCharacter{01E9}{\v{k}} + + \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}} + \DeclareUnicodeCharacter{01F1}{DZ} + \DeclareUnicodeCharacter{01F2}{Dz} + \DeclareUnicodeCharacter{01F3}{dz} + \DeclareUnicodeCharacter{01F4}{\'G} + \DeclareUnicodeCharacter{01F5}{\'g} + \DeclareUnicodeCharacter{01F8}{\`N} + \DeclareUnicodeCharacter{01F9}{\`n} + \DeclareUnicodeCharacter{01FC}{\'{\AE}} + \DeclareUnicodeCharacter{01FD}{\'{\ae}} + \DeclareUnicodeCharacter{01FE}{\'{\O}} + \DeclareUnicodeCharacter{01FF}{\'{\o}} + + \DeclareUnicodeCharacter{021E}{\v{H}} + \DeclareUnicodeCharacter{021F}{\v{h}} + + \DeclareUnicodeCharacter{0226}{\dotaccent{A}} + \DeclareUnicodeCharacter{0227}{\dotaccent{a}} + \DeclareUnicodeCharacter{0228}{\cedilla{E}} + \DeclareUnicodeCharacter{0229}{\cedilla{e}} + \DeclareUnicodeCharacter{022E}{\dotaccent{O}} + \DeclareUnicodeCharacter{022F}{\dotaccent{o}} + + \DeclareUnicodeCharacter{0232}{\=Y} + \DeclareUnicodeCharacter{0233}{\=y} + \DeclareUnicodeCharacter{0237}{\dotless{j}} + + \DeclareUnicodeCharacter{02DB}{\ogonek{ }} + + \DeclareUnicodeCharacter{1E02}{\dotaccent{B}} + \DeclareUnicodeCharacter{1E03}{\dotaccent{b}} + \DeclareUnicodeCharacter{1E04}{\udotaccent{B}} + \DeclareUnicodeCharacter{1E05}{\udotaccent{b}} + \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}} + \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}} + \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}} + \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}} + \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}} + \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}} + \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}} + \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}} + + \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}} + \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}} + + \DeclareUnicodeCharacter{1E20}{\=G} + \DeclareUnicodeCharacter{1E21}{\=g} + \DeclareUnicodeCharacter{1E22}{\dotaccent{H}} + \DeclareUnicodeCharacter{1E23}{\dotaccent{h}} + \DeclareUnicodeCharacter{1E24}{\udotaccent{H}} + \DeclareUnicodeCharacter{1E25}{\udotaccent{h}} + \DeclareUnicodeCharacter{1E26}{\"H} + \DeclareUnicodeCharacter{1E27}{\"h} + + \DeclareUnicodeCharacter{1E30}{\'K} + \DeclareUnicodeCharacter{1E31}{\'k} + \DeclareUnicodeCharacter{1E32}{\udotaccent{K}} + \DeclareUnicodeCharacter{1E33}{\udotaccent{k}} + \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}} + \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}} + \DeclareUnicodeCharacter{1E36}{\udotaccent{L}} + \DeclareUnicodeCharacter{1E37}{\udotaccent{l}} + \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}} + \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}} + \DeclareUnicodeCharacter{1E3E}{\'M} + \DeclareUnicodeCharacter{1E3F}{\'m} + + \DeclareUnicodeCharacter{1E40}{\dotaccent{M}} + \DeclareUnicodeCharacter{1E41}{\dotaccent{m}} + \DeclareUnicodeCharacter{1E42}{\udotaccent{M}} + \DeclareUnicodeCharacter{1E43}{\udotaccent{m}} + \DeclareUnicodeCharacter{1E44}{\dotaccent{N}} + \DeclareUnicodeCharacter{1E45}{\dotaccent{n}} + \DeclareUnicodeCharacter{1E46}{\udotaccent{N}} + \DeclareUnicodeCharacter{1E47}{\udotaccent{n}} + \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}} + \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}} + + \DeclareUnicodeCharacter{1E54}{\'P} + \DeclareUnicodeCharacter{1E55}{\'p} + \DeclareUnicodeCharacter{1E56}{\dotaccent{P}} + \DeclareUnicodeCharacter{1E57}{\dotaccent{p}} + \DeclareUnicodeCharacter{1E58}{\dotaccent{R}} + \DeclareUnicodeCharacter{1E59}{\dotaccent{r}} + \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}} + \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}} + \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}} + \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}} + + \DeclareUnicodeCharacter{1E60}{\dotaccent{S}} + \DeclareUnicodeCharacter{1E61}{\dotaccent{s}} + \DeclareUnicodeCharacter{1E62}{\udotaccent{S}} + \DeclareUnicodeCharacter{1E63}{\udotaccent{s}} + \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}} + \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}} + \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}} + \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}} + \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}} + \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}} + + \DeclareUnicodeCharacter{1E7C}{\~V} + \DeclareUnicodeCharacter{1E7D}{\~v} + \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}} + \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}} + + \DeclareUnicodeCharacter{1E80}{\`W} + \DeclareUnicodeCharacter{1E81}{\`w} + \DeclareUnicodeCharacter{1E82}{\'W} + \DeclareUnicodeCharacter{1E83}{\'w} + \DeclareUnicodeCharacter{1E84}{\"W} + \DeclareUnicodeCharacter{1E85}{\"w} + \DeclareUnicodeCharacter{1E86}{\dotaccent{W}} + \DeclareUnicodeCharacter{1E87}{\dotaccent{w}} + \DeclareUnicodeCharacter{1E88}{\udotaccent{W}} + \DeclareUnicodeCharacter{1E89}{\udotaccent{w}} + \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}} + \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}} + \DeclareUnicodeCharacter{1E8C}{\"X} + \DeclareUnicodeCharacter{1E8D}{\"x} + \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}} + \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}} + + \DeclareUnicodeCharacter{1E90}{\^Z} + \DeclareUnicodeCharacter{1E91}{\^z} + \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}} + \DeclareUnicodeCharacter{1E93}{\udotaccent{z}} + \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}} + \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}} + \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}} + \DeclareUnicodeCharacter{1E97}{\"t} + \DeclareUnicodeCharacter{1E98}{\ringaccent{w}} + \DeclareUnicodeCharacter{1E99}{\ringaccent{y}} + + \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}} + \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}} + + \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}} + \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}} + \DeclareUnicodeCharacter{1EBC}{\~E} + \DeclareUnicodeCharacter{1EBD}{\~e} + + \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}} + \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}} + \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}} + \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}} + + \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}} + \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}} + + \DeclareUnicodeCharacter{1EF2}{\`Y} + \DeclareUnicodeCharacter{1EF3}{\`y} + \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}} + + \DeclareUnicodeCharacter{1EF8}{\~Y} + \DeclareUnicodeCharacter{1EF9}{\~y} + + \DeclareUnicodeCharacter{2013}{--} + \DeclareUnicodeCharacter{2014}{---} + \DeclareUnicodeCharacter{2018}{\quoteleft} + \DeclareUnicodeCharacter{2019}{\quoteright} + \DeclareUnicodeCharacter{201A}{\quotesinglbase} + \DeclareUnicodeCharacter{201C}{\quotedblleft} + \DeclareUnicodeCharacter{201D}{\quotedblright} + \DeclareUnicodeCharacter{201E}{\quotedblbase} + \DeclareUnicodeCharacter{2022}{\bullet} + \DeclareUnicodeCharacter{2026}{\dots} + \DeclareUnicodeCharacter{2039}{\guilsinglleft} + \DeclareUnicodeCharacter{203A}{\guilsinglright} + \DeclareUnicodeCharacter{20AC}{\euro} + + \DeclareUnicodeCharacter{2192}{\expansion} + \DeclareUnicodeCharacter{21D2}{\result} + + \DeclareUnicodeCharacter{2212}{\minus} + \DeclareUnicodeCharacter{2217}{\point} + \DeclareUnicodeCharacter{2261}{\equiv} +}% end of \utfeightchardefs -% @U command definitions for native Unicode handling (XeTeX and LuaTeX). -\def\nativeunicodechardefsatu{% - \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU - \unicodechardefs -} % US-ASCII character definitions. \def\asciichardefs{% nothing need be done \relax } -% define all Unicode characters we know about, for the sake of @U. -\iftxinativeunicodecapable - \nativeunicodechardefsatu -\else - \utfeightchardefs -\fi - - % Make non-ASCII characters printable again for compatibility with % existing Texinfo documents that may use them, even without declaring a % document encoding. @@ -11268,8 +8899,8 @@ directory should work if nowhere else does.} % Prevent underfull vbox error messages. \vbadness = 10000 -% Don't be very finicky about underfull hboxes, either. -\hbadness = 6666 +% Don't be so finicky about underfull hboxes, either. +\hbadness = 2000 % Following George Bush, get rid of widows and orphans. \widowpenalty=10000 @@ -11305,12 +8936,12 @@ directory should work if nowhere else does.} \advance\vsize by \topskip \outervsize = \vsize \advance\outervsize by 2\topandbottommargin - \txipageheight = \vsize + \pageheight = \vsize % \hsize = #2\relax \outerhsize = \hsize \advance\outerhsize by 0.5in - \txipagewidth = \hsize + \pagewidth = \hsize % \normaloffset = #4\relax \bindingoffset = #5\relax @@ -11322,14 +8953,6 @@ directory should work if nowhere else does.} % whatever layout pdftex was dumped with. \pdfhorigin = 1 true in \pdfvorigin = 1 true in - \else - \ifx\XeTeXrevision\thisisundefined - \special{papersize=#8,#7}% - \else - \pdfpageheight #7\relax - \pdfpagewidth #8\relax - % XeTeX does not have \pdfhorigin and \pdfvorigin. - \fi \fi % \setleading{\textleading} @@ -11362,6 +8985,7 @@ directory should work if nowhere else does.} % \lispnarrowing = 0.3in \tolerance = 700 + \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = .5cm }} @@ -11379,6 +9003,7 @@ directory should work if nowhere else does.} % \lispnarrowing = 0.25in \tolerance = 700 + \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = .4cm }} @@ -11404,6 +9029,7 @@ directory should work if nowhere else does.} {297mm}{210mm}% % \tolerance = 700 + \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = 5mm }} @@ -11422,6 +9048,7 @@ directory should work if nowhere else does.} % \lispnarrowing = 0.2in \tolerance = 800 + \hfuzz = 1.2pt \contentsrightmargin = 0pt \defbodyindent = 2mm \tableindent = 12mm @@ -11463,11 +9090,9 @@ directory should work if nowhere else does.} % \dimen0 = #1\relax \advance\dimen0 by \voffset - \advance\dimen0 by 1in % reference point for DVI is 1 inch from top of page % \dimen2 = \hsize \advance\dimen2 by \normaloffset - \advance\dimen2 by 1in % reference point is 1 inch from left edge of page % \internalpagesizes{#1}{\hsize}% {\voffset}{\normaloffset}% @@ -11479,27 +9104,31 @@ directory should work if nowhere else does.} % \letterpaper -% Default value of \hfuzz, for suppressing warnings about overfull hboxes. -\hfuzz = 1pt - \message{and turning on texinfo input format.} -\def^^L{\par} % remove \outer, so ^L can appear in an @comment - % DEL is a comment character, in case @c does not suffice. \catcode`\^^? = 14 % Define macros to output various characters with catcode for normal text. -\catcode`\"=\other \def\normaldoublequote{"} -\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix -\catcode`\+=\other \def\normalplus{+} -\catcode`\<=\other \def\normalless{<} -\catcode`\>=\other \def\normalgreater{>} -\catcode`\^=\other \def\normalcaret{^} -\catcode`\_=\other \def\normalunderscore{_} -\catcode`\|=\other \def\normalverticalbar{|} -\catcode`\~=\other \def\normaltilde{~} +\catcode`\"=\other +\catcode`\~=\other +\catcode`\^=\other +\catcode`\_=\other +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode`\+=\other +\catcode`\$=\other +\def\normaldoublequote{"} +\def\normaltilde{~} +\def\normalcaret{^} +\def\normalunderscore{_} +\def\normalverticalbar{|} +\def\normalless{<} +\def\normalgreater{>} +\def\normalplus{+} +\def\normaldollar{$}%$ font-lock fix % This macro is used to make a character print one way in \tt % (where it can probably be output as-is), and another way in other fonts, @@ -11518,47 +9147,44 @@ directory should work if nowhere else does.} % this is not a problem. \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} -% Set catcodes for Texinfo file - -% Active characters for printing the wanted glyph. +% Turn off all special characters except @ +% (and those which the user can use as if they were ordinary). % Most of these we simply print from the \tt font, but for some, we can % use math or other variants that look better in normal text. -% + \catcode`\"=\active \def\activedoublequote{{\tt\char34}} \let"=\activedoublequote -\catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde -\chardef\hatchar=`\^ -\catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat +\catcode`\~=\active +\def~{{\tt\char126}} +\chardef\hat=`\^ +\catcode`\^=\active +\def^{{\tt \hat}} \catcode`\_=\active \def_{\ifusingtt\normalunderscore\_} -\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } \let\realunder=_ +% Subroutine for the previous macro. +\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } -\catcode`\|=\active \def|{{\tt\char124}} - +\catcode`\|=\active +\def|{{\tt\char124}} \chardef \less=`\< -\catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless +\catcode`\<=\active +\def<{{\tt \less}} \chardef \gtr=`\> -\catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr -\catcode`\+=\active \def+{{\tt \char 43}} -\catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix -\catcode`\-=\active \let-=\normaldash +\catcode`\>=\active +\def>{{\tt \gtr}} +\catcode`\+=\active +\def+{{\tt \char 43}} +\catcode`\$=\active +\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix - -% used for headline/footline in the output routine, in case the page -% breaks in the middle of an @tex block. -\def\texinfochars{% - \let< = \activeless - \let> = \activegtr - \let~ = \activetilde - \let^ = \activehat - \markupsetuplqdefault \markupsetuprqdefault - \let\b = \strong - \let\i = \smartitalic - % in principle, all other definitions in \tex have to be undone too. -} +% If a .fmt file is being used, characters that might appear in a file +% name cannot be active until we have parsed the command line. +% So turn them off again, and have \everyjob (or @setfilename) turn them on. +% \otherifyactive is called near the end of this file. +\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} % Used sometimes to turn off (effectively) the active characters even after % parsing them. @@ -11578,132 +9204,68 @@ directory should work if nowhere else does.} % \doublebackslash is two of them (for the pdf outlines). {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} -% In Texinfo, backslash is an active character; it prints the backslash +% In texinfo, backslash is an active character; it prints the backslash % in fixed width font. -\catcode`\\=\active % @ for escape char from now on. - -% Print a typewriter backslash. For math mode, we can't simply use -% \backslashcurfont: the story here is that in math mode, the \char -% of \backslashcurfont ends up printing the roman \ from the math symbol -% font (because \char in math mode uses the \mathcode, and plain.tex -% sets \mathcode`\\="026E). Hence we use an explicit \mathchar, -% which is the decimal equivalent of "715c (class 7, e.g., use \fam; -% ignored family value; char position "5C). We can't use " for the -% usual hex value because it has already been made active. - -@def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} -@let@backslashchar = @ttbackslash % @backslashchar{} is for user documents. +\catcode`\\=\active +@def@normalbackslash{{@tt@backslashcurfont}} +% On startup, @fixbackslash assigns: +% @let \ = @normalbackslash % \rawbackslash defines an active \ to do \backslashcurfont. % \otherbackslash defines an active \ to be a literal `\' character with -% catcode other. We switch back and forth between these. +% catcode other. @gdef@rawbackslash{@let\=@backslashcurfont} @gdef@otherbackslash{@let\=@realbackslash} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of % the literal character `\'. % -{@catcode`- = @active - @gdef@normalturnoffactive{% - @passthroughcharstrue - @let-=@normaldash - @let"=@normaldoublequote - @let$=@normaldollar %$ font-lock fix - @let+=@normalplus - @let<=@normalless - @let>=@normalgreater - @let^=@normalcaret - @let_=@normalunderscore - @let|=@normalverticalbar - @let~=@normaltilde - @let\=@ttbackslash - @markupsetuplqdefault - @markupsetuprqdefault - @unsepspaces - } +@def@normalturnoffactive{% + @let\=@normalbackslash + @let"=@normaldoublequote + @let~=@normaltilde + @let^=@normalcaret + @let_=@normalunderscore + @let|=@normalverticalbar + @let<=@normalless + @let>=@normalgreater + @let+=@normalplus + @let$=@normaldollar %$ font-lock fix + @markupsetuplqdefault + @markupsetuprqdefault + @unsepspaces } -% If a .fmt file is being used, characters that might appear in a file -% name cannot be active until we have parsed the command line. -% So turn them off again, and have @fixbackslash turn them back on. -@catcode`+=@other @catcode`@_=@other +% Make _ and + \other characters, temporarily. +% This is canceled by @fixbackslash. +@otherifyactive -% \enablebackslashhack - allow file to begin `\input texinfo' -% % If a .fmt file is being used, we don't want the `\input texinfo' to show up. % That is what \eatinput is for; after that, the `\' should revert to printing % a backslash. -% If the file did not have a `\input texinfo', then it is turned off after -% the first line; otherwise the first `\' in the file would cause an error. -% This is used on the very last line of this file, texinfo.tex. -% We also use @c to call @fixbackslash, in case ends of lines are hidden. -{ -@catcode`@^=7 -@catcode`@^^M=13@gdef@enablebackslashhack{% - @global@let\ = @eatinput% - @catcode`@^^M=13% - @def@c{@fixbackslash@c}% - % Definition for the newline at the end of this file. - @def ^^M{@let^^M@secondlinenl}% - % Definition for a newline in the main Texinfo file. - @gdef @secondlinenl{@fixbackslash}% - % In case the first line has a whole-line command on it - @let@originalparsearg@parsearg - @def@parsearg{@fixbackslash@originalparsearg} -}} - -{@catcode`@^=7 @catcode`@^^M=13% -@gdef@eatinput input texinfo#1^^M{@fixbackslash}} - -% Emergency active definition of newline, in case an active newline token -% appears by mistake. -{@catcode`@^=7 @catcode13=13% -@gdef@enableemergencynewline{% - @gdef^^M{% - @par% - %@par% -}}} - +% +@gdef@eatinput input texinfo{@fixbackslash} +@global@let\ = @eatinput +% On the other hand, perhaps the file did not have a `\input texinfo'. Then +% the first `\' in the file would cause an error. This macro tries to fix +% that, assuming it is called before the first `\' could plausibly occur. +% Also turn back on active characters that might appear in the input +% file name, in case not using a pre-dumped format. +% @gdef@fixbackslash{% - @ifx\@eatinput @let\ = @ttbackslash @fi - @catcode13=5 % regular end of line - @enableemergencynewline - @let@c=@texinfoc - @let@parsearg@originalparsearg - % Also turn back on active characters that might appear in the input - % file name, in case not using a pre-dumped format. + @ifx\@eatinput @let\ = @normalbackslash @fi @catcode`+=@active @catcode`@_=@active - % - % If texinfo.cnf is present on the system, read it. - % Useful for site-wide @afourpaper, etc. This macro, @fixbackslash, gets - % called at the beginning of every Texinfo file. Not opening texinfo.cnf - % directly in this file, texinfo.tex, makes it possible to make a format - % file for Texinfo. - % - @openin 1 texinfo.cnf - @ifeof 1 @else @input texinfo.cnf @fi - @closein 1 } - % Say @foo, not \foo, in error messages. @escapechar = `@@ -% These (along with & and #) are made active for url-breaking, so need -% active definitions as the normal characters. -@def@normaldot{.} -@def@normalquest{?} -@def@normalslash{/} - % These look ok in all fonts, so just make them not special. -% @hashchar{} gets its own user-level command, because of #line. -@catcode`@& = @other @def@normalamp{&} -@catcode`@# = @other @def@normalhash{#} -@catcode`@% = @other @def@normalpercent{%} - -@let @hashchar = @normalhash +@catcode`@& = @other +@catcode`@# = @other +@catcode`@% = @other @c Finally, make ` and ' active, so that txicodequoteundirected and @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we @@ -11716,7 +9278,7 @@ directory should work if nowhere else does.} @c Local variables: @c eval: (add-hook 'write-file-hooks 'time-stamp) -@c page-delimiter: "^\\\\message\\|emacs-page" +@c page-delimiter: "^\\\\message" @c time-stamp-start: "def\\\\texinfoversion{" @c time-stamp-format: "%:y-%02m-%02d.%02H" @c time-stamp-end: "}" @@ -11724,4 +9286,6 @@ directory should work if nowhere else does.} @c vim:sw=2: -@enablebackslashhack +@ignore + arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 +@end ignore diff --git a/doc/tinc-gui.8.in b/doc/tinc-gui.8.in new file mode 100644 index 0000000..f5ebadb --- /dev/null +++ b/doc/tinc-gui.8.in @@ -0,0 +1,57 @@ +.Dd 2011-06-26 +.Dt TINC-GUI 8 +.\" Manual page created by: +.\" Guus Sliepen +.Sh NAME +.Nm tinc-gui +.Nd tinc GUI +.Sh SYNOPSIS +.Nm +.Op Fl n +.Op Fl -net Ns = Ns Ar NETNAME +.Op Fl -pidfile Ns = Ns Ar FILENAME +.Op Fl -help +.Sh DESCRIPTION +This is a Python/wxWidgets based graphical user interface for tinc, a secure virtual private network (VPN) project. +.Nm +communicates with +.Xr tincd 8 +to alter and inspect the running VPN's state. +It can show the current settings, the list of connections, nodes, subnets, and edges. +For now, the debug level can be changed from the GUI, and by right-clicking on a node in the list of connections, +a pop-up menu will appear that allows one to disconnect that node. +.Sh OPTIONS +.Bl -tag -width indent +.It Fl n, -net Ns = Ns Ar NETNAME +Communicate with tincd(8) connected with +.Ar NETNAME . +.It Fl -pidfile Ns = Ns Ar FILENAME +Use the cookie from +.Ar FILENAME +to authenticate with a running tinc daemon. +If unspecified, the default is +.Pa @localstatedir@/run/tinc. Ns Ar NETNAME Ns Pa .pid. +.It Fl -help +Display short list of options. +.El +.Sh BUGS +The GUI is not finished yet, the final version will have much more functionality. +If you find any bugs, report them to tinc@tinc-vpn.org. +.Sh SEE ALSO +.Xr tincd 8 , +.Pa http://www.tinc-vpn.org/ . +.Pp +The full documentation for tinc is maintained as a Texinfo manual. +If the info and tinc programs are properly installed at your site, +the command +.Ic info tinc +should give you access to the complete manual. +.Pp +tinc comes with ABSOLUTELY NO WARRANTY. +This is free software, and you are welcome to redistribute it under certain conditions; +see the file COPYING for details. +.Sh AUTHORS +.An "Ivo Timmermans" +.An "Guus Sliepen" Aq guus@tinc-vpn.org +.Pp +And thanks to many others for their contributions to tinc! diff --git a/doc/tinc.conf.5.in b/doc/tinc.conf.5.in index cd7d1a0..a44f27c 100644 --- a/doc/tinc.conf.5.in +++ b/doc/tinc.conf.5.in @@ -1,21 +1,25 @@ -.Dd 2016-10-29 +.Dd 2010-01-16 .Dt TINC.CONF 5 .\" Manual page created by: .\" Ivo Timmermans .\" Guus Sliepen + .Sh NAME .Nm tinc.conf .Nd tinc daemon configuration + .Sh DESCRIPTION The files in the .Pa @sysconfdir@/tinc/ directory contain runtime and security information for the tinc daemon. + .Sh NETWORKS It is perfectly ok for you to run more than one tinc daemon. However, in its default form, you will soon notice that you can't use two different configuration files without the .Fl c option. + .Pp We have thought of another way of dealing with this: network names. This means that you call @@ -23,6 +27,7 @@ This means that you call with the .Fl n option, which will assign a name to this daemon. + .Pp The effect of this is that the daemon will set its configuration root to .Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa / , @@ -33,6 +38,7 @@ is your argument to the option. You'll notice that messages appear in syslog as coming from .Nm tincd. Ns Ar NETNAME . + .Pp However, it is not strictly necessary that you call tinc with the .Fl n @@ -48,21 +54,25 @@ the configuration file should be .Pa @sysconfdir@/tinc/tinc.conf , and the host configuration files are now expected to be in .Pa @sysconfdir@/tinc/hosts/ . + .Pp But it is highly recommended that you use this feature of .Nm tinc , because it will be so much clearer whom your daemon talks to. Hence, we will assume that you use it. + .Sh NAMES -Each tinc daemon must have a name that is unique in the network which it will be part of. +Each tinc daemon should have a name that is unique in the network which it will be part of. The name will be used by other tinc daemons for identification. The name has to be declared in the .Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc.conf file. + .Pp To make things easy, choose something that will give unique and easy to remember names to your tinc daemon(s). You could try things like hostnames, owner surnames or location names. + .Sh PUBLIC/PRIVATE KEYS You should use .Ic tincd -K @@ -81,14 +91,17 @@ The public key should be stored in the host configuration file .Va NAME stands for the name of the local tinc daemon (see .Sx NAMES ) . + .Sh SERVER CONFIGURATION The server configuration of the daemon is done in the file .Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc.conf . This file consists of comments (lines started with a .Li # ) or assignments in the form of: + .Pp .Va Variable Li = Ar Value . + .Pp The variable names are case insensitive, and any spaces, tabs, newlines and carriage returns are ignored. @@ -96,67 +109,44 @@ Note: it is not required that you put in the .Li = sign, but doing so improves readability. If you leave it out, remember to replace it with at least one space character. + .Pp The server configuration is complemented with host specific configuration (see the next section). Although all configuration options for the local host listed in this document can also be put in .Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc.conf , it is recommended to put host specific configuration options in the host configuration file, as this makes it easy to exchange with other nodes. + .Pp Here are all valid variables, listed in alphabetical order. The default value is given between parentheses. .Bl -tag -width indent + .It Va AddressFamily Li = ipv4 | ipv6 | any Pq any This option affects the address family of listening and outgoing sockets. If .Qq any is selected, then depending on the operating system both IPv4 and IPv6 or just IPv6 listening sockets will be created. -.It Va BindToAddress Li = Ar address Oo Ar port Oc Bq experimental + +.It Va BindToAddress Li = Ar address Bq experimental If your computer has more than one IPv4 or IPv6 address, .Nm tinc will by default listen on all of them for incoming connections. -Multiple -.Va BindToAddress -variables may be specified, -in which case listening sockets for each specified address are made. -.Pp -If no -.Ar port -is specified, the socket will be bound to the port specified by the -.Va Port -option, or to port 655 if neither is given. -To only bind to a specific port but not to a specific address, use -.Li * -for the -.Ar address . +It is possible to bind only to a single address with this variable. + .Pp This option may not work on all platforms. + .It Va BindToInterface Li = Ar interface Bq experimental If your computer has more than one network interface, .Nm tinc will by default listen on all of them for incoming connections. It is possible to bind only to a single interface with this variable. + .Pp This option may not work on all platforms. -Also, on some platforms it will not actually bind to an interface, -but rather to the address that the interface has at the moment a socket is created. -.It Va Broadcast Li = no | mst | direct Po mst Pc Bq experimental -This option selects the way broadcast packets are sent to other daemons. -NOTE: all nodes in a VPN must use the same -.Va Broadcast -mode, otherwise routing loops can form. -.Bl -tag -width indent -.It no -Broadcast packets are never sent to other nodes. -.It mst -Broadcast packets are sent and forwarded via the VPN's Minimum Spanning Tree. -This ensures broadcast packets reach all nodes. -.It direct -Broadcast packets are sent directly to all nodes that can be reached directly. -Broadcast packets received from other nodes are never forwarded. -If the IndirectData option is also set, broadcast packets will only be sent to nodes which we have a meta connection to. -.El + .It Va ConnectTo Li = Ar name Specifies which other tinc daemon to connect to on startup. Multiple @@ -167,21 +157,14 @@ The names should be known to this tinc daemon (i.e., there should be a host configuration file for the name on the .Va ConnectTo line). + .Pp If you don't specify a host with .Va ConnectTo , .Nm tinc won't try to connect to other daemons at all, and will instead just listen for incoming connections. -.It Va DecrementTTL Li = yes | no Po no Pc Bq experimental -When enabled, -.Nm tinc -will decrement the Time To Live field in IPv4 packets, or the Hop Limit field in IPv6 packets, -before forwarding a received packet to the virtual network device or to another node, -and will drop packets that have a TTL value of zero, -in which case it will send an ICMP Time Exceeded packet back. -.Pp -Do not use this option if you use switch mode and want to use IPv6. + .It Va Device Li = Ar device Po Pa /dev/tap0 , Pa /dev/net/tun No or other depending on platform Pc The virtual network device to use. .Nm tinc @@ -193,92 +176,77 @@ instead of .Va Device . The info pages of the tinc package contain more information about configuring the virtual network device. -.It Va DeviceType Li = Ar type Pq platform dependent + +.It Va DeviceType Li = tun | tunnohead | tunifhead | tap Po only supported on BSD platforms Pc The type of the virtual network device. -Tinc will normally automatically select the right type of tun/tap interface, and this option should not be used. -However, this option can be used to select one of the special interface types, if support for them is compiled in. +Tinc will normally automatically select the right type, and this option should not be used. +However, in case tinc does not seem to correctly interpret packets received from the virtual network device, +using this option might help. .Bl -tag -width indent -.It dummy -Use a dummy interface. -No packets are ever read or written to a virtual network device. -Useful for testing, or when setting up a node that only forwards packets for other nodes. -.It raw_socket -Open a raw socket, and bind it to a pre-existing -.Va Interface -(eth0 by default). -All packets are read from this interface. -Packets received for the local node are written to the raw socket. -However, at least on Linux, the operating system does not process IP packets destined for the local host. -.It multicast -Open a multicast UDP socket and bind it to the address and port (separated by spaces) and optionally a TTL value specified using -.Va Device . -Packets are read from and written to this multicast socket. -This can be used to connect to UML, QEMU or KVM instances listening on the same multicast address. -Do NOT connect multiple -.Nm tinc -daemons to the same multicast address, this will very likely cause routing loops. -Also note that this can cause decrypted VPN packets to be sent out on a real network if misconfigured. -.It uml Pq not compiled in by default -Create a UNIX socket with the filename specified by -.Va Device , -or -.Pa @runstatedir@/ Ns Ar NETNAME Ns Pa .umlsocket -if not specified. -.Nm tinc -will wait for a User Mode Linux instance to connect to this socket. -.It vde Pq not compiled in by default -Uses the libvdeplug library to connect to a Virtual Distributed Ethernet switch, -using the UNIX socket specified by -.Va Device , -or -.Pa @runstatedir@/vde.ctl -if not specified. -.El -Also, in case tinc does not seem to correctly interpret packets received from the virtual network device, -it can be used to change the way packets are interpreted: -.Bl -tag -width indent -.It tun Pq BSD and Linux + +.It tun Set type to tun. Depending on the platform, this can either be with or without an address family header (see below). -.It tunnohead Pq BSD + +.It tunnohead Set type to tun without an address family header. Tinc will expect packets read from the virtual network device to start with an IP header. On some platforms IPv6 packets cannot be read from or written to the device in this mode. -.It tunifhead Pq BSD + +.It tunifhead Set type to tun with an address family header. Tinc will expect packets read from the virtual network device to start with a four byte header containing the address family, followed by an IP header. This mode should support both IPv4 and IPv6 packets. -.It utun Pq OS X -Set type to utun. -This is only supported on OS X version 10.6.8 and higher, but doesn't require the tuntaposx module. -This mode should support both IPv4 and IPv6 packets. -.It tap Pq BSD and Linux + +.It tap Set type to tap. Tinc will expect packets read from the virtual network device to start with an Ethernet header. .El + .It Va DirectOnly Li = yes | no Po no Pc Bq experimental When this option is enabled, packets that cannot be sent directly to the destination node, but which would have to be forwarded by an intermediate node, are dropped instead. When combined with the IndirectData option, packets for nodes for which we do not have a meta connection with are also dropped. + +.It Va ECDSAPrivateKeyFile Li = Ar filename Po Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /ecdsa_key.priv Pc +The file in which the private ECDSA key of this tinc daemon resides. +This is only used if +.Va ExperimentalProtocol +is enabled. + +.It Va ExperimentalProtocol Li = yes | no Po no Pc Bq experimental +When this option is enabled, experimental protocol enhancements will be used. +Ephemeral ECDH will be used for key exchanges, +and ECDSA will be used instead of RSA for authentication. +When enabled, an ECDSA key must have been generated before with +.Nm tincctl generate-ecdsa-keys . +The experimental protocol may change at any time, +and there is no guarantee that tinc will run stable when it is used. + .It Va Forwarding Li = off | internal | kernel Po internal Pc Bq experimental This option selects the way indirect packets are forwarded. .Bl -tag -width indent + .It off Incoming packets that are not meant for the local node, but which should be forwarded to another node, are dropped. + .It internal Incoming packets that are meant for another node are forwarded by tinc internally. + .Pp This is the default mode, and unless you really know you need another forwarding mode, don't change it. + .It kernel Incoming packets are always sent to the TUN/TAP device, even if the packets are not for the local node. This is less efficient, but allows the kernel to apply its routing and firewall rules on them, and can also help debugging. .El + .It Va GraphDumpFile Li = Ar filename Bq experimental If this option is present, .Nm tinc @@ -291,16 +259,20 @@ If starts with a pipe symbol |, then the rest of the filename is interpreted as a shell command that is executed, the graph is then sent to stdin. + .It Va Hostnames Li = yes | no Pq no This option selects whether IP addresses (both real and on the VPN) should be resolved. Since DNS lookups are blocking, it might affect tinc's efficiency, even stopping the daemon for a few seconds every time it does a lookup if your DNS server is not responding. + .Pp This does not affect resolving hostnames to IP addresses from the -host configuration files, but whether hostnames should be resolved while logging. +host configuration files. + .It Va IffOneQueue Li = yes | no Po no Pc Bq experimental (Linux only) Set IFF_ONE_QUEUE flag on TUN/TAP devices. + .It Va Interface Li = Ar interface Defines the name of the interface corresponding to the virtual network device. Depending on the operating system and the type of device this may or may not actually set the name of the interface. @@ -308,117 +280,85 @@ Under Windows, this variable is used to select which network interface will be u If you specified a .Va Device , this variable is almost always already correctly set. + .It Va KeyExpire Li = Ar seconds Pq 3600 This option controls the period the encryption keys used to encrypt the data are valid. It is common practice to change keys at regular intervals to make it even harder for crackers, even though it is thought to be nearly impossible to crack a single key. -.It Va LocalDiscovery Li = yes | no Po no Pc Bq experimental -When enabled, -.Nm tinc -will try to detect peers that are on the same local network. -This will allow direct communication using LAN addresses, even if both peers are behind a NAT -and they only ConnectTo a third node outside the NAT, -which normally would prevent the peers from learning each other's LAN address. -.Pp -Currently, local discovery is implemented by sending broadcast packets to the LAN during path MTU discovery. -This feature may not work in all possible situations. + .It Va MACExpire Li = Ar seconds Pq 600 This option controls the amount of time MAC addresses are kept before they are removed. This only has effect when .Va Mode is set to .Qq switch . + .It Va MaxTimeout Li = Ar seconds Pq 900 This is the maximum delay before trying to reconnect to other tinc daemons. + .It Va Mode Li = router | switch | hub Pq router This option selects the way packets are routed to other daemons. .Bl -tag -width indent + .It router In this mode .Va Subnet variables in the host configuration files will be used to form a routing table. Only unicast packets of routable protocols (IPv4 and IPv6) are supported in this mode. + .Pp This is the default mode, and unless you really know you need another mode, don't change it. + .It switch In this mode the MAC addresses of the packets on the VPN will be used to dynamically create a routing table just like an Ethernet switch does. Unicast, multicast and broadcast packets of every protocol that runs over Ethernet are supported in this mode at the cost of frequent broadcast ARP requests and routing table updates. + .Pp This mode is primarily useful if you want to bridge Ethernet segments. + .It hub This mode is almost the same as the switch mode, but instead every packet will be broadcast to the other daemons while no routing table is managed. .El + .It Va Name Li = Ar name Bq required This is the name which identifies this tinc daemon. It must be unique for the virtual private network this daemon will connect to. -The Name may only consist of alphanumeric and underscore characters. -If -.Va Name -starts with a -.Li $ , -then the contents of the environment variable that follows will be used. -In that case, invalid characters will be converted to underscores. -If -.Va Name -is -.Li $HOST , -but no such environment variable exist, the hostname will be read using the gethostname() system call. + .It Va PingInterval Li = Ar seconds Pq 60 The number of seconds of inactivity that .Nm tinc will wait before sending a probe to the other end. + .It Va PingTimeout Li = Ar seconds Pq 5 The number of seconds to wait for a response to pings or to allow meta connections to block. If the other end doesn't respond within this time, the connection is terminated, and the others will be notified of this. + .It Va PriorityInheritance Li = yes | no Po no Pc Bq experimental When this option is enabled the value of the TOS field of tunneled IPv4 packets will be inherited by the UDP packets that are sent out. + .It Va PrivateKey Li = Ar key Bq obsolete The private RSA key of this tinc daemon. It will allow this tinc daemon to authenticate itself to other daemons. + .It Va PrivateKeyFile Li = Ar filename Po Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /rsa_key.priv Pc The file in which the private RSA key of this tinc daemon resides. +Note that there must be exactly one of +.Va PrivateKey +or +.Va PrivateKeyFile +specified in the configuration file. + .It Va ProcessPriority Li = low | normal | high When this option is used the priority of the tincd process will be adjusted. Increasing the priority may help to reduce latency and packet loss on the VPN. -.It Va Proxy Li = socks4 | socks5 | http | exec Ar ... Bq experimental -Use a proxy when making outgoing connections. -The following proxy types are currently supported: -.Bl -tag -width indent -.It socks4 Ar address Ar port Op Ar username -Connects to the proxy using the SOCKS version 4 protocol. -Optionally, a -.Ar username -can be supplied which will be passed on to the proxy server. -Only IPv4 connections can be proxied using SOCKS 4. -.It socks5 Ar address Ar port Op Ar username Ar password -Connect to the proxy using the SOCKS version 5 protocol. -If a -.Ar username -and -.Ar password -are given, basic username/password authentication will be used, -otherwise no authentication will be used. -.It http Ar address Ar port -Connects to the proxy and sends a HTTP CONNECT request. -.It exec Ar command -Executes the given -.Ar command -which should set up the outgoing connection. -The environment variables -.Ev NAME , -.Ev NODE , -.Ev REMOTEADDRES -and -.Ev REMOTEPORT -are available. -.El + .It Va ReplayWindow Li = Ar bytes Pq 16 This is the size of the replay tracking window for each remote node, in bytes. The window is a bitfield which tracks 1 packet per bit, so for example @@ -428,30 +368,35 @@ the interaction of replay tracking with underlying real packet loss and/or reordering. Setting this to zero will disable replay tracking completely and pass all traffic, but leaves tinc vulnerable to replay-based attacks on your traffic. + .It Va StrictSubnets Li = yes | no Po no Pc Bq experimental When this option is enabled tinc will only use Subnet statements which are present in the host config files in the local .Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /hosts/ -directory. Subnets learned via connections to other nodes and which are not -present in the local host config files are ignored. +directory. + .It Va TunnelServer Li = yes | no Po no Pc Bq experimental When this option is enabled tinc will no longer forward information between other tinc daemons, and will only allow connections with nodes for which host config files are present in the local .Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /hosts/ directory. Setting this options also implicitly sets StrictSubnets. + .It Va UDPRcvBuf Li = Ar bytes Pq OS default Sets the socket receive buffer size for the UDP socket, in bytes. If unset, the default buffer size will be used by the operating system. + .It Va UDPSndBuf Li = Ar bytes Pq OS default Sets the socket send buffer size for the UDP socket, in bytes. If unset, the default buffer size will be used by the operating system. .El + .Sh HOST CONFIGURATION FILES The host configuration files contain all information needed to establish a connection to those hosts. A host configuration file is also required for the local tinc daemon, it will use it to read in it's listen port, public key and subnets. + .Pp The idea is that these files are portable. You can safely mail your own host configuration file to someone else. @@ -460,7 +405,8 @@ and now his tinc daemon will be able to connect to your tinc daemon. Since host configuration files only contain public keys, no secrets are revealed by sending out this information. .Bl -tag -width indent -.It Va Address Li = Ar address Oo Ar port Oc Bq recommended + +.It Va Address Li = Ar address Oo port Oc Bq recommended The IP address or hostname of this tinc daemon on the real network. This will only be used when trying to make an outgoing connection to this tinc daemon. Optionally, a port can be specified to use for this address. @@ -468,51 +414,66 @@ Multiple .Va Address variables can be specified, in which case each address will be tried until a working connection has been established. -.It Va Cipher Li = Ar cipher Pq aes-256-cbc + +.It Va Cipher Li = Ar cipher Pq blowfish The symmetric cipher algorithm used to encrypt UDP packets. -Any cipher supported by LibreSSL or OpenSSL is recognised. +Any cipher supported by OpenSSL is recognised. Furthermore, specifying .Qq none will turn off packet encryption. It is best to use only those ciphers which support CBC mode. + .It Va ClampMSS Li = yes | no Pq yes This option specifies whether tinc should clamp the maximum segment size (MSS) of TCP packets to the path MTU. This helps in situations where ICMP Fragmentation Needed or Packet too Big messages are dropped by firewalls. + .It Va Compression Li = Ar level Pq 0 This option sets the level of compression used for UDP packets. Possible values are 0 (off), 1 (fast zlib) and any integer up to 9 (best zlib), 10 (fast lzo) and 11 (best lzo). -.It Va Digest Li = Ar digest Pq sha256 + +.It Va Digest Li = Ar digest Pq sha1 The digest algorithm used to authenticate UDP packets. -Any digest supported by LibreSSL or OpenSSL is recognised. +Any digest supported by OpenSSL is recognised. Furthermore, specifying .Qq none will turn off packet authentication. + .It Va IndirectData Li = yes | no Pq no -When set to yes, only nodes which already have a meta connection to you -will try to establish direct communication with you. -It is best to leave this option out or set it to no. +This option specifies whether other tinc daemons besides the one you specified with +.Va ConnectTo +can make a direct connection to you. +This is especially useful if you are behind a firewall +and it is impossible to make a connection from the outside to your tinc daemon. +Otherwise, it is best to leave this option out or set it to no. + .It Va MACLength Li = Ar length Pq 4 The length of the message authentication code used to authenticate UDP packets. Can be anything from .Qq 0 up to the length of the digest produced by the digest algorithm. + .It Va PMTU Li = Ar mtu Po 1514 Pc This option controls the initial path MTU to this node. + .It Va PMTUDiscovery Li = yes | no Po yes Pc When this option is enabled, tinc will try to discover the path MTU to this node. After the path MTU has been discovered, it will be enforced on the VPN. + .It Va Port Li = Ar port Pq 655 The port number on which this tinc daemon is listening for incoming connections, which is used if no port number is specified in an .Va Address statement. + .It Va PublicKey Li = Ar key Bq obsolete The public RSA key of this tinc daemon. It will be used to cryptographically verify it's identity and to set up a secure connection. + .It Va PublicKeyFile Li = Ar filename Bq obsolete The file in which the public RSA key of this tinc daemon resides. + .Pp From version 1.0pre4 on .Nm tinc @@ -521,6 +482,7 @@ the above two options then are not necessary. Either the PEM format is used, or exactly one of the above two options must be specified in each host configuration file, if you want to be able to establish a connection with that host. + .It Va Subnet Li = Ar address Ns Op Li / Ns Ar prefixlength Ns Op Li # Ns Ar weight The subnet which this tinc daemon will serve. .Nm tinc @@ -530,22 +492,26 @@ it will be sent to the daemon who has this subnet in his host configuration file Multiple .Va Subnet variables can be specified. + .Pp Subnets can either be single MAC, IPv4 or IPv6 addresses, in which case a subnet consisting of only that single address is assumed, or they can be a IPv4 or IPv6 network address with a prefixlength. +Shorthand notations are not supported. For example, IPv4 subnets must be in a form like 192.168.1.0/24, where 192.168.1.0 is the network address and 24 is the number of bits set in the netmask. Note that subnets like 192.168.1.1/24 are invalid! Read a networking HOWTO/FAQ/guide if you don't understand this. -IPv6 subnets are notated like fec0:0:0:1::/64. +IPv6 subnets are notated like fec0:0:0:1:0:0:0:0/64. MAC addresses are notated like 0:1a:2b:3c:4d:5e. + .Pp A Subnet can be given a weight to indicate its priority over identical Subnets owned by different nodes. The default weight is 10. Lower values indicate higher priority. Packets will be sent to the node with the highest priority, unless that node is not reachable, in which case the node with the next highest priority will be tried, and so on. + .It Va TCPOnly Li = yes | no Pq no Bq obsolete If this variable is set to yes, then the packets are tunnelled over the TCP connection instead of a UDP connection. @@ -553,51 +519,53 @@ This is especially useful for those who want to run a tinc daemon from behind a masquerading firewall, or if UDP packet routing is disabled somehow. Setting this options also implicitly sets IndirectData. + .Pp Since version 1.0.10, tinc will automatically detect whether communication via UDP is possible or not. .El + .Sh SCRIPTS Apart from reading the server and host configuration files, tinc can also run scripts at certain moments. -Below is a list of filenames of scripts and a description of when they are run. -A script is only run if it exists and if it is executable. -.Pp -Scripts are run synchronously; -this means that tinc will temporarily stop processing packets until the called script finishes executing. -This guarantees that scripts will execute in the exact same order as the events that trigger them. -If you need to run commands asynchronously, you have to ensure yourself that they are being run in the background. -.Pp -Under Windows (not Cygwin), the scripts must have the extension +Under Windows (not Cygwin), the scripts should have the extension .Pa .bat . .Bl -tag -width indent + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc-up This is the most important script. If it is present it will be executed right after the tinc daemon has been started and has connected to the virtual network device. It should be used to set up the corresponding network interface, but can also be used to start other things. -.Pp Under Windows you can use the Network Connections control panel instead of creating this script. + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc-down This script is started right before the tinc daemon quits. + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /hosts/ Ns Ar HOST Ns Pa -up This script is started when the tinc daemon with name .Ar HOST becomes reachable. + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /hosts/ Ns Ar HOST Ns Pa -down This script is started when the tinc daemon with name .Ar HOST becomes unreachable. + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /host-up This script is started when any host becomes reachable. + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /host-down This script is started when any host becomes unreachable. + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /subnet-up This script is started when a Subnet becomes reachable. The Subnet and the node it belongs to are passed in environment variables. + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /subnet-down This script is started when a Subnet becomes unreachable. .El + .Pp The scripts are started without command line arguments, but can make use of certain environment variables. Under UNIX like operating systems the names of environment variables must be preceded by a @@ -609,56 +577,68 @@ files, they have to be put between .Li % signs. .Bl -tag -width indent + .It Ev NETNAME If a netname was specified, this environment variable contains it. + .It Ev NAME Contains the name of this tinc daemon. + .It Ev DEVICE Contains the name of the virtual network device that tinc uses. + .It Ev INTERFACE Contains the name of the virtual network interface that tinc uses. This should be used for commands like .Pa ifconfig . + .It Ev NODE When a host becomes (un)reachable, this is set to its name. If a subnet becomes (un)reachable, this is set to the owner of that subnet. + .It Ev REMOTEADDRESS When a host becomes (un)reachable, this is set to its real address. + .It Ev REMOTEPORT When a host becomes (un)reachable, this is set to the port number it uses for communication with other tinc daemons. + .It Ev SUBNET When a subnet becomes (un)reachable, this is set to the subnet. + .It Ev WEIGHT When a subnet becomes (un)reachable, this is set to the subnet weight. .El -.Pp -Do not forget that under UNIX operating systems, you have to make the scripts executable, using the command -.Nm chmod Li a+x Pa script . + .Sh FILES The most important files are: .Bl -tag -width indent + .It Pa @sysconfdir@/tinc/ The top directory for configuration files. + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc.conf The default name of the server configuration file for net .Ar NETNAME . -.It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /conf.d/ -Optional directory from which any *.conf file will be loaded + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /hosts/ Host configuration files are kept in this directory. + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc-up If an executable file with this name exists, it will be executed right after the tinc daemon has connected to the virtual network device. It can be used to set up the corresponding network interface. + .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc-down If an executable file with this name exists, it will be executed right before the tinc daemon is going to close its connection to the virtual network device. .El + .Sh SEE ALSO .Xr tincd 8 , -.Pa https://www.tinc-vpn.org/ , -.Pa http://www.tldp.org/LDP/nag2/ . +.Pa http://www.tinc-vpn.org/ , +.Pa http://www.linuxdoc.org/LDP/nag2/ . + .Pp The full documentation for .Nm tinc @@ -666,6 +646,7 @@ is maintained as a Texinfo manual. If the info and tinc programs are properly installed at your site, the command .Ic info tinc should give you access to the complete manual. + .Pp .Nm tinc comes with ABSOLUTELY NO WARRANTY. diff --git a/doc/tinc.info b/doc/tinc.info index 97caea4..f6c0548 100644 --- a/doc/tinc.info +++ b/doc/tinc.info @@ -1,14 +1,14 @@ -This is tinc.info, produced by makeinfo version 6.5 from tinc.texi. +This is tinc.info, produced by makeinfo version 4.13 from tinc.texi. INFO-DIR-SECTION Networking tools START-INFO-DIR-ENTRY * tinc: (tinc). The tinc Manual. END-INFO-DIR-ENTRY -This is the info manual for tinc version 1.0.35, a Virtual Private + This is the info manual for tinc version 1.1pre2, a Virtual Private Network daemon. - Copyright (C) 1998-2018 Ivo Timmermans, Guus Sliepen + Copyright (C) 1998-2011 Ivo Timmermans, Guus Sliepen and Wessel Dankers . Permission is granted to make and distribute verbatim copies of this @@ -33,6 +33,7 @@ Top * Installation:: * Configuration:: * Running tinc:: +* Controlling tinc:: * Technical information:: * Platform specific information:: * About us:: @@ -73,12 +74,12 @@ A Virtual Private Network or VPN is a network that can only be accessed by a few elected computers that participate. This goal is achievable in more than just one way. - Private networks can consist of a single stand-alone Ethernet LAN. Or -even two computers hooked up using a null-modem cable. In these cases, -it is obvious that the network is _private_, no one can access it from -the outside. But if your computers are linked to the Internet, the -network is not private anymore, unless one uses firewalls to block all -private traffic. But then, there is no way to send private data to + Private networks can consist of a single stand-alone Ethernet LAN. +Or even two computers hooked up using a null-modem cable. In these +cases, it is obvious that the network is _private_, no one can access +it from the outside. But if your computers are linked to the Internet, +the network is not private anymore, unless one uses firewalls to block +all private traffic. But then, there is no way to send private data to trusted computers on the other end of the Internet. This problem can be solved by using _virtual_ networks. Virtual @@ -93,10 +94,10 @@ has to go through the Internet, where other people can look at it. worse, alter data. Hence it's probably advisable to encrypt the data that flows over the network. - When one introduces encryption, we can form a true VPN. Other people -may see encrypted traffic, but if they don't know how to decipher it -(they need to know the key for that), they cannot read the information -that flows through the VPN. This is what tinc was made for. + When one introduces encryption, we can form a true VPN. Other +people may see encrypted traffic, but if they don't know how to +decipher it (they need to know the key for that), they cannot read the +information that flows through the VPN. This is what tinc was made for.  File: tinc.info, Node: tinc, Next: Supported platforms, Prev: Virtual Private Networks, Up: Introduction @@ -107,8 +108,8 @@ File: tinc.info, Node: tinc, Next: Supported platforms, Prev: Virtual Private I really don't quite remember what got us started, but it must have been Guus' idea. He wrote a simple implementation (about 50 lines of C) that used the ethertap device that Linux knows of since somewhere about -kernel 2.1.60. It didn't work immediately and he improved it a bit. At -this stage, the project was still simply called "vpnd". +kernel 2.1.60. It didn't work immediately and he improved it a bit. +At this stage, the project was still simply called "vpnd". Since then, a lot has changed--to say the least. @@ -117,14 +118,14 @@ for both the receiving and sending end, it has become largely runtime-configurable--in short, it has become a full-fledged professional package. - Tinc also allows more than two sites to connect to eachother and form -a single VPN. Traditionally VPNs are created by making tunnels, which -only have two endpoints. Larger VPNs with more sites are created by -adding more tunnels. Tinc takes another approach: only endpoints are -specified, the software itself will take care of creating the tunnels. -This allows for easier configuration and improved scalability. + Tinc also allows more than two sites to connect to eachother and +form a single VPN. Traditionally VPNs are created by making tunnels, +which only have two endpoints. Larger VPNs with more sites are created +by adding more tunnels. Tinc takes another approach: only endpoints +are specified, the software itself will take care of creating the +tunnels. This allows for easier configuration and improved scalability. - A lot can--and will be--changed. We have a number of things that we + A lot can--and will be--changed. We have a number of things that we would like to see in the future releases of tinc. Not everything will be available in the near future. Our first objective is to make tinc work perfectly as it stands, and then add more advanced features. @@ -139,7 +140,7 @@ File: tinc.info, Node: Supported platforms, Prev: tinc, Up: Introduction ======================= Tinc has been verified to work under Linux, FreeBSD, OpenBSD, NetBSD, -Mac OS X (Darwin), Solaris, and Windows (both natively and in a Cygwin +MacOS/X (Darwin), Solaris, and Windows (both natively and in a Cygwin environment), with various hardware architectures. These are some of the platforms that are supported by the universal tun/tap device driver or other virtual network device drivers. Without such a driver, tinc @@ -147,7 +148,7 @@ will most likely compile and run, but it will not be able to send or receive data packets. For an up to date list of supported platforms, please check the list -on our website: . +on our website: `http://www.tinc-vpn.org/platforms'.  File: tinc.info, Node: Preparations, Next: Installation, Prev: Introduction, Up: Top @@ -176,7 +177,7 @@ File: tinc.info, Node: Configuring the kernel, Next: Libraries, Up: Preparati * Configuration of OpenBSD kernels:: * Configuration of NetBSD kernels:: * Configuration of Solaris kernels:: -* Configuration of Darwin (Mac OS X) kernels:: +* Configuration of Darwin (MacOS/X) kernels:: * Configuration of Windows::  @@ -198,7 +199,7 @@ Here are the options you have to turn on when configuring a new kernel: are going to run more than one instance of tinc. If you decide to build the tun/tap driver as a kernel module, add -these lines to '/etc/modules.conf': +these lines to `/etc/modules.conf': alias char-major-10-200 tun @@ -209,9 +210,7 @@ File: tinc.info, Node: Configuration of FreeBSD kernels, Next: Configuration o -------------------------------------- For FreeBSD version 4.1 and higher, tun and tap drivers are included in -the default kernel configuration. The tap driver can be loaded with -'kldload if_tap', or by adding 'if_tap_load="YES"' to -'/boot/loader.conf'. +the default kernel configuration. Using tap devices is recommended.  File: tinc.info, Node: Configuration of OpenBSD kernels, Next: Configuration of NetBSD kernels, Prev: Configuration of FreeBSD kernels, Up: Configuring the kernel @@ -219,8 +218,12 @@ File: tinc.info, Node: Configuration of OpenBSD kernels, Next: Configuration o 2.1.3 Configuration of OpenBSD kernels -------------------------------------- -Recent versions of OpenBSD come with both tun and tap devices enabled in -the default kernel configuration. +For OpenBSD version 2.9 and higher, the tun driver is included in the +default kernel configuration. There is also a kernel patch from +`http://diehard.n-r-g.com/stuff/openbsd/' which adds a tap device to +OpenBSD which should work with tinc, but with recent versions of +OpenBSD, a tun device can act as a tap device by setting the link0 +option with ifconfig.  File: tinc.info, Node: Configuration of NetBSD kernels, Next: Configuration of Solaris kernels, Prev: Configuration of OpenBSD kernels, Up: Configuring the kernel @@ -234,44 +237,42 @@ default kernel configuration. Tunneling IPv6 may not work on NetBSD's tun device.  -File: tinc.info, Node: Configuration of Solaris kernels, Next: Configuration of Darwin (Mac OS X) kernels, Prev: Configuration of NetBSD kernels, Up: Configuring the kernel +File: tinc.info, Node: Configuration of Solaris kernels, Next: Configuration of Darwin (MacOS/X) kernels, Prev: Configuration of NetBSD kernels, Up: Configuring the kernel 2.1.5 Configuration of Solaris kernels -------------------------------------- For Solaris 8 (SunOS 5.8) and higher, the tun driver may or may not be included in the default kernel configuration. If it isn't, the source -can be downloaded from . For x86 and +can be downloaded from `http://vtun.sourceforge.net/tun/'. For x86 and sparc64 architectures, precompiled versions can be found at -. If the 'net/if_tun.h' +`http://www.monkey.org/~dugsong/fragroute/'. If the `net/if_tun.h' header file is missing, install it from the source package.  -File: tinc.info, Node: Configuration of Darwin (Mac OS X) kernels, Next: Configuration of Windows, Prev: Configuration of Solaris kernels, Up: Configuring the kernel +File: tinc.info, Node: Configuration of Darwin (MacOS/X) kernels, Next: Configuration of Windows, Prev: Configuration of Solaris kernels, Up: Configuring the kernel -2.1.6 Configuration of Darwin (Mac OS X) kernels ------------------------------------------------- +2.1.6 Configuration of Darwin (MacOS/X) kernels +----------------------------------------------- Tinc on Darwin relies on a tunnel driver for its data acquisition from -the kernel. OS X version 10.6.8 and later have a built-in tun driver -called "utun". Tinc also supports the driver from -, which supports both tun and tap -style devices. +the kernel. Tinc supports either the driver from +`http://tuntaposx.sourceforge.net/', which supports both tun and tap +style devices, and also the driver from from +`http://chrisp.de/en/projects/tunnel.html'. The former driver is +recommended. The tunnel driver must be loaded before starting tinc +with the following command: - By default, tinc expects the tuntaposx driver to be installed. To -use the utun driver, set add 'Device = utunX' to 'tinc.conf', where X is -the desired number for the utun interface. You can also omit the -number, in which case the first free number will be chosen. + kmodload tunnel  -File: tinc.info, Node: Configuration of Windows, Prev: Configuration of Darwin (Mac OS X) kernels, Up: Configuring the kernel +File: tinc.info, Node: Configuration of Windows, Prev: Configuration of Darwin (MacOS/X) kernels, Up: Configuring the kernel 2.1.7 Configuration of Windows ------------------------------ -You will need to install the latest TAP-Win32 driver from OpenVPN. You -can download it from -. Using the +You will need to install the latest TAP-Win32 driver from OpenVPN. You +can download it from `http://openvpn.sourceforge.net'. Using the Network Connections control panel, configure the TAP-Win32 network interface in the same way as you would do from the tinc-up script, as explained in the rest of the documentation. @@ -282,50 +283,49 @@ File: tinc.info, Node: Libraries, Prev: Configuring the kernel, Up: Preparati 2.2 Libraries ============= -Before you can configure or build tinc, you need to have the LibreSSL or -OpenSSL, zlib and lzo libraries installed on your system. If you try to -configure tinc without having them installed, configure will give you an -error message, and stop. +Before you can configure or build tinc, you need to have the OpenSSL, +zlib and lzo libraries installed on your system. If you try to +configure tinc without having them installed, configure will give you +an error message, and stop. * Menu: -* LibreSSL/OpenSSL:: +* OpenSSL:: * zlib:: * lzo:: +* libevent::  -File: tinc.info, Node: LibreSSL/OpenSSL, Next: zlib, Up: Libraries +File: tinc.info, Node: OpenSSL, Next: zlib, Up: Libraries -2.2.1 LibreSSL/OpenSSL ----------------------- +2.2.1 OpenSSL +------------- For all cryptography-related functions, tinc uses the functions provided -by the LibreSSL or the OpenSSL library. +by the OpenSSL library. - If this library is not installed, you will get an error when -configuring tinc for build. Support for running tinc with other -cryptographic libraries installed _may_ be added in the future. + If this library is not installed, you wil get an error when +configuring tinc for build. Support for running tinc without having +OpenSSL installed _may_ be added in the future. You can use your operating system's package manager to install this if available. Make sure you install the development AND runtime versions of this package. - If your operating system comes neither with LibreSSL or OpenSSL, you -have to install one manually. It is recommended that you get the latest -version of LibreSSL from . Instructions on -how to configure, build and install this package are included within the -package. Please make sure you build development and runtime libraries -(which is the default). + If you have to install OpenSSL manually, you can get the source code +from `http://www.openssl.org/'. Instructions on how to configure, +build and install this package are included within the package. Please +make sure you build development and runtime libraries (which is the +default). - If you installed the LibreSSL or OpenSSL libraries from source, it -may be necessary to let configure know where they are, by passing -configure one of the -with-openssl-* parameters. Note that you even -have to use -with-openssl-* if you are using LibreSSL. + If you installed the OpenSSL libraries from source, it may be +necessary to let configure know where they are, by passing configure +one of the -with-openssl-* parameters. - --with-openssl=DIR LibreSSL/OpenSSL library and headers prefix - --with-openssl-include=DIR LibreSSL/OpenSSL headers directory + --with-openssl=DIR OpenSSL library and headers prefix + --with-openssl-include=DIR OpenSSL headers directory (Default is OPENSSL_DIR/include) - --with-openssl-lib=DIR LibreSSL/OpenSSL library directory + --with-openssl-lib=DIR OpenSSL library directory (Default is OPENSSL_DIR/lib) License @@ -334,26 +334,26 @@ License The complete source code of tinc is covered by the GNU GPL version 2. Since the license under which OpenSSL is distributed is not directly compatible with the terms of the GNU GPL -, we include an +`http://www.openssl.org/support/faq.html#LEGAL2', we include an exemption to the GPL (see also the file COPYING.README) to allow everyone to create a statically or dynamically linked executable: This program is released under the GPL with the additional - exemption that compiling, linking, and/or using OpenSSL is allowed. - You may provide binary packages linked to the OpenSSL libraries, - provided that all other requirements of the GPL are met. + exemption that compiling, linking, and/or using OpenSSL is + allowed. You may provide binary packages linked to the OpenSSL + libraries, provided that all other requirements of the GPL are met. Since the LZO library used by tinc is also covered by the GPL, we also present the following exemption: Hereby I grant a special exception to the tinc VPN project - (https://www.tinc-vpn.org/) to link the LZO library with the - OpenSSL library (https://www.openssl.org). + (http://www.tinc-vpn.org/) to link the LZO library with the + OpenSSL library (http://www.openssl.org). Markus F.X.J. Oberhumer  -File: tinc.info, Node: zlib, Next: lzo, Prev: LibreSSL/OpenSSL, Up: Libraries +File: tinc.info, Node: zlib, Next: lzo, Prev: OpenSSL, Up: Libraries 2.2.2 zlib ---------- @@ -361,43 +361,59 @@ File: tinc.info, Node: zlib, Next: lzo, Prev: LibreSSL/OpenSSL, Up: Librarie For the optional compression of UDP packets, tinc uses the functions provided by the zlib library. - If this library is not installed, you will get an error when running -the configure script. You can either install the zlib library, or -disable support for zlib compression by using the "-disable-zlib" option -when running the configure script. Note that if you disable support for -zlib, the resulting binary will not work correctly on VPNs where zlib -compression is used. + If this library is not installed, you wil get an error when +configuring tinc for build. Support for running tinc without having +zlib installed _may_ be added in the future. You can use your operating system's package manager to install this if available. Make sure you install the development AND runtime versions of this package. If you have to install zlib manually, you can get the source code -from . Instructions on how to configure, build and -install this package are included within the package. Please make sure -you build development and runtime libraries (which is the default). +from `http://www.gzip.org/zlib/'. Instructions on how to configure, +build and install this package are included within the package. Please +make sure you build development and runtime libraries (which is the +default).  -File: tinc.info, Node: lzo, Prev: zlib, Up: Libraries +File: tinc.info, Node: lzo, Next: libevent, Prev: zlib, Up: Libraries 2.2.3 lzo --------- -Another form of compression is offered using the LZO library. +Another form of compression is offered using the lzo library. - If this library is not installed, you will get an error when running -the configure script. You can either install the LZO library, or -disable support for LZO compression by using the "-disable-lzo" option -when running the configure script. Note that if you disable support for -LZO, the resulting binary will not work correctly on VPNs where LZO -compression is used. + If this library is not installed, you wil get an error when +configuring tinc for build. Support for running tinc without having lzo +installed _may_ be added in the future. You can use your operating system's package manager to install this if available. Make sure you install the development AND runtime versions of this package. - If you have to install lzo manually, you can get the source code from -. Instructions on how to + If you have to install lzo manually, you can get the source code +from `http://www.oberhumer.com/opensource/lzo/'. Instructions on how +to configure, build and install this package are included within the +package. Please make sure you build development and runtime libraries +(which is the default). + + +File: tinc.info, Node: libevent, Prev: lzo, Up: Libraries + +2.2.4 libevent +-------------- + +For the main event loop, tinc uses the libevent library. + + If this library is not installed, you wil get an error when +configuring tinc for build. + + You can use your operating system's package manager to install this +if available. Make sure you install the development AND runtime +versions of this package. + + If you have to install libevent manually, you can get the source code +from `http://monkey.org/~provos/libevent/'. Instructions on how to configure, build and install this package are included within the package. Please make sure you build development and runtime libraries (which is the default). @@ -414,13 +430,15 @@ startup scripts and sample configurations. If you cannot use one of the precompiled packages, or you want to compile tinc for yourself, you can use the source. The source is -distributed under the GNU General Public License (GPL). Download the -source from the download page (https://www.tinc-vpn.org/download/). +distributed under the GNU General Public License (GPL). Download the +source from the download page (http://www.tinc-vpn.org/download), which +has the checksums of these files listed; you may wish to check these +with md5sum before continuing. Tinc comes in a convenient autoconf/automake package, which you can just treat the same as any other package. Which is just untar it, type -'./configure' and then 'make'. More detailed instructions are in the -file 'INSTALL', which is included in the source distribution. +`./configure' and then `make'. More detailed instructions are in the +file `INSTALL', which is included in the source distribution. * Menu: @@ -434,7 +452,7 @@ File: tinc.info, Node: Building and installing tinc, Next: System files, Up: ================================ Detailed instructions on configuring the source, building tinc and -installing tinc can be found in the file called 'INSTALL'. +installing tinc can be found in the file called `INSTALL'. If you happen to have a binary package for tinc for your distribution, you can use the package management tools of that @@ -443,36 +461,36 @@ your distribution will tell you how to do that. * Menu: -* Darwin (Mac OS X) build environment:: +* Darwin (MacOS/X) build environment:: * Cygwin (Windows) build environment:: * MinGW (Windows) build environment::  -File: tinc.info, Node: Darwin (Mac OS X) build environment, Next: Cygwin (Windows) build environment, Up: Building and installing tinc +File: tinc.info, Node: Darwin (MacOS/X) build environment, Next: Cygwin (Windows) build environment, Up: Building and installing tinc -3.1.1 Darwin (Mac OS X) build environment ------------------------------------------ +3.1.1 Darwin (MacOS/X) build environment +---------------------------------------- -In order to build tinc on Darwin, you need to install Xcode from -. It might also help to install a -recent version of Fink from . +In order to build tinc on Darwin, you need to install the MacOS/X +Developer Tools from +`http://developer.apple.com/tools/macosxtools.html' and a recent +version of Fink from `http://fink.sourceforge.net/'. - You need to download and install LibreSSL (or OpenSSL) and LZO, -either directly from their websites (see *note Libraries::) or using -Fink. + After installation use fink to download and install the following +packages: autoconf25, automake, dlcompat, m4, openssl, zlib and lzo.  -File: tinc.info, Node: Cygwin (Windows) build environment, Next: MinGW (Windows) build environment, Prev: Darwin (Mac OS X) build environment, Up: Building and installing tinc +File: tinc.info, Node: Cygwin (Windows) build environment, Next: MinGW (Windows) build environment, Prev: Darwin (MacOS/X) build environment, Up: Building and installing tinc 3.1.2 Cygwin (Windows) build environment ---------------------------------------- If Cygwin hasn't already been installed, install it directly from -. +`http://www.cygwin.com/'. When tinc is compiled in a Cygwin environment, it can only be run in this environment, but all programs, including those started outside the -Cygwin environment, will be able to use the VPN. It will also support +Cygwin environment, will be able to use the VPN. It will also support all features.  @@ -482,8 +500,7 @@ File: tinc.info, Node: MinGW (Windows) build environment, Prev: Cygwin (Window --------------------------------------- You will need to install the MinGW environment from -. You also need to download and install LibreSSL -(or OpenSSL) and LZO. +`http://www.mingw.org'. When tinc is compiled using MinGW it runs natively under Windows, it is not necessary to keep MinGW installed. @@ -525,20 +542,20 @@ File: tinc.info, Node: Other files, Prev: Device files, Up: System files 3.2.2 Other files ----------------- -'/etc/networks' +`/etc/networks' ............... -You may add a line to '/etc/networks' so that your VPN will get a +You may add a line to `/etc/networks' so that your VPN will get a symbolic name. For example: myvpn 10.0.0.0 -'/etc/services' +`/etc/services' ............... -You may add this line to '/etc/services'. The effect is that you may -supply a 'tinc' as a valid port number to some programs. The number 655 -is registered with the IANA. +You may add this line to `/etc/services'. The effect is that you may +supply a `tinc' as a valid port number to some programs. The number +655 is registered with the IANA. tinc 655/tcp TINC tinc 655/udp TINC @@ -570,17 +587,17 @@ Before actually starting to configure tinc and editing files, make sure you have read this entire section so you know what to expect. Then, make it clear to yourself how you want to organize your VPN: What are the nodes (computers running tinc)? What IP addresses/subnets do they -have? What is the network mask of the entire VPN? Do you need special +have? What is the network mask of the entire VPN? Do you need special firewall rules? Do you have to set up masquerading or forwarding rules? Do you want to run tinc in router mode or switch mode? These questions can only be answered by yourself, you will not find the answers in this -documentation. Make sure you have an adequate understanding of networks -in general. A good resource on networking is the Linux Network -Administrators Guide (http://www.tldp.org/LDP/nag2/). +documentation. Make sure you have an adequate understanding of +networks in general. A good resource on networking is the Linux +Network Administrators Guide (http://www.linuxdoc.org/LDP/nag2/). If you have everything clearly pictured in your mind, proceed in the -following order: First, generate the configuration files ('tinc.conf', -your host configuration file, 'tinc-up' and perhaps 'tinc-down'). Then +following order: First, generate the configuration files (`tinc.conf', +your host configuration file, `tinc-up' and perhaps `tinc-down'). Then generate the keypairs. Finally, distribute the host configuration files. These steps are described in the subsections below. @@ -592,28 +609,28 @@ File: tinc.info, Node: Multiple networks, Next: How connections work, Prev: C In order to allow you to run more than one tinc daemon on one computer, for instance if your computer is part of more than one VPN, you can -assign a NETNAME to your VPN. It is not required if you only run one +assign a NETNAME to your VPN. It is not required if you only run one tinc daemon, it doesn't even have to be the same on all the sites of your VPN, but it is recommended that you choose one anyway. - We will assume you use a netname throughout this document. This + We will asume you use a netname throughout this document. This means that you call tincd with the -n argument, which will assign a netname to this daemon. - The effect of this is that the daemon will set its configuration root -to '/etc/tinc/NETNAME/', where NETNAME is your argument to the -n -option. You'll notice that it appears in syslog as 'tinc.NETNAME'. + The effect of this is that the daemon will set its configuration +root to `/etc/tinc/NETNAME/', where NETNAME is your argument to the -n +option. You'll notice that it appears in syslog as `tinc.NETNAME'. However, it is not strictly necessary that you call tinc with the -n option. In this case, the network name would just be empty, and it will -be used as such. tinc now looks for files in '/etc/tinc/', instead of -'/etc/tinc/NETNAME/'; the configuration file should be -'/etc/tinc/tinc.conf', and the host configuration files are now expected -to be in '/etc/tinc/hosts/'. +be used as such. tinc now looks for files in `/etc/tinc/', instead of +`/etc/tinc/NETNAME/'; the configuration file should be +`/etc/tinc/tinc.conf', and the host configuration files are now +expected to be in `/etc/tinc/hosts/'. But it is highly recommended that you use this feature of tinc, -because it will be so much clearer whom your daemon talks to. Hence, we -will assume that you use it. +because it will be so much clearer whom your daemon talks to. Hence, +we will assume that you use it.  File: tinc.info, Node: How connections work, Next: Configuration files, Prev: Multiple networks, Up: Configuration @@ -622,22 +639,22 @@ File: tinc.info, Node: How connections work, Next: Configuration files, Prev: ======================== When tinc starts up, it parses the command-line options and then reads -in the configuration file tinc.conf. If it sees one or more 'ConnectTo' -values pointing to other tinc daemons in that file, it will try to -connect to those other daemons. Whether this succeeds or not and -whether 'ConnectTo' is specified or not, tinc will listen for incoming -connection from other daemons. If you did specify a 'ConnectTo' value -and the other side is not responding, tinc will keep retrying. This -means that once started, tinc will stay running until you tell it to -stop, and failures to connect to other tinc daemons will not stop your -tinc daemon for trying again later. This means you don't have to -intervene if there are temporary network problems. +in the configuration file tinc.conf. If it sees one or more +`ConnectTo' values pointing to other tinc daemons in that file, it will +try to connect to those other daemons. Whether this succeeds or not +and whether `ConnectTo' is specified or not, tinc will listen for +incoming connection from other deamons. If you did specify a +`ConnectTo' value and the other side is not responding, tinc will keep +retrying. This means that once started, tinc will stay running until +you tell it to stop, and failures to connect to other tinc daemons will +not stop your tinc daemon for trying again later. This means you don't +have to intervene if there are temporary network problems. There is no real distinction between a server and a client in tinc. -If you wish, you can view a tinc daemon without a 'ConnectTo' value as a -server, and one which does specify such a value as a client. It does -not matter if two tinc daemons have a 'ConnectTo' value pointing to each -other however. +If you wish, you can view a tinc daemon without a `ConnectTo' value as +a server, and one which does specify such a value as a client. It does +not matter if two tinc daemons have a `ConnectTo' value pointing to +each other however.  File: tinc.info, Node: Configuration files, Next: Generating keypairs, Prev: How connections work, Up: Configuration @@ -646,11 +663,8 @@ File: tinc.info, Node: Configuration files, Next: Generating keypairs, Prev: ======================= The actual configuration of the daemon is done in the file -'/etc/tinc/NETNAME/tinc.conf' and at least one other file in the -directory '/etc/tinc/NETNAME/hosts/'. - - An optional directory '/etc/tinc/NETNAME/conf.d' can be added from -which any .conf file will be read. +`/etc/tinc/NETNAME/tinc.conf' and at least one other file in the +directory `/etc/tinc/NETNAME/hosts/'. These file consists of comments (lines started with a #) or assignments in the form of @@ -659,13 +673,14 @@ assignments in the form of The variable names are case insensitive, and any spaces, tabs, newlines and carriage returns are ignored. Note: it is not required -that you put in the '=' sign, but doing so improves readability. If you -leave it out, remember to replace it with at least one space character. +that you put in the `=' sign, but doing so improves readability. If +you leave it out, remember to replace it with at least one space +character. The server configuration is complemented with host specific -configuration (see the next section). Although all host configuration +configuration (see the next section). Although all host configuration options for the local node listed in this document can also be put in -'/etc/tinc/NETNAME/tinc.conf', it is recommended to put host specific +`/etc/tinc/NETNAME/tinc.conf', it is recommended to put host specific configuration options in the host configuration file, as this makes it easy to exchange with other nodes. @@ -692,47 +707,21 @@ AddressFamily = (any) system both IPv4 and IPv6 or just IPv6 listening sockets will be created. -BindToAddress =
[] [experimental] +BindToAddress =
[experimental] If your computer has more than one IPv4 or IPv6 address, tinc will - by default listen on all of them for incoming connections. - Multiple BindToAddress variables may be specified, in which case - listening sockets for each specified address are made. - - If no PORT is specified, the socket will be bound to the port - specified by the Port option, or to port 655 if neither is given. - To only bind to a specific port but not to a specific address, use - "*" for the ADDRESS. + by default listen on all of them for incoming connections. It is + possible to bind only to a single address with this variable. This option may not work on all platforms. BindToInterface = [experimental] If you have more than one network interface in your computer, tinc - will by default listen on all of them for incoming connections. It - is possible to bind tinc to a single interface like eth0 or ppp0 - with this variable. + will by default listen on all of them for incoming connections. + It is possible to bind tinc to a single interface like eth0 or + ppp0 with this variable. This option may not work on all platforms. -Broadcast = (mst) [experimental] - This option selects the way broadcast packets are sent to other - daemons. _NOTE: all nodes in a VPN must use the same Broadcast - mode, otherwise routing loops can form._ - - no - Broadcast packets are never sent to other nodes. - - mst - Broadcast packets are sent and forwarded via the VPN's Minimum - Spanning Tree. This ensures broadcast packets reach all - nodes. - - direct - Broadcast packets are sent directly to all nodes that can be - reached directly. Broadcast packets received from other nodes - are never forwarded. If the IndirectData option is also set, - broadcast packets will only be sent to nodes which we have a - meta connection to. - ConnectTo = Specifies which other tinc daemon to connect to on startup. Multiple ConnectTo variables may be specified, in which case @@ -744,139 +733,98 @@ ConnectTo = connect to other daemons at all, and will instead just listen for incoming connections. -DecrementTTL = (no) [experimental] - When enabled, tinc will decrement the Time To Live field in IPv4 - packets, or the Hop Limit field in IPv6 packets, before forwarding - a received packet to the virtual network device or to another node, - and will drop packets that have a TTL value of zero, in which case - it will send an ICMP Time Exceeded packet back. - - Do not use this option if you use switch mode and want to use IPv6. - -Device = ('/dev/tap0', '/dev/net/tun' or other depending on platform) +Device = (`/dev/tap0', `/dev/net/tun' or other depending on platform) The virtual network device to use. Tinc will automatically detect - what kind of device it is. Under Windows, use INTERFACE instead of - DEVICE. Note that you can only use one device per daemon. See - also *note Device files::. + what kind of device it is. Note that you can only use one device + per daemon. Under Windows, use INTERFACE instead of DEVICE. Note + that you can only use one device per daemon. See also *note + Device files::. -DeviceType = (platform dependent) +DeviceType = (only supported on BSD platforms) The type of the virtual network device. Tinc will normally - automatically select the right type of tun/tap interface, and this - option should not be used. However, this option can be used to - select one of the special interface types, if support for them is - compiled in. + automatically select the right type, and this option should not be + used. However, in case tinc does not seem to correctly interpret + packets received from the virtual network device, using this + option might help. - dummy - Use a dummy interface. No packets are ever read or written to - a virtual network device. Useful for testing, or when setting - up a node that only forwards packets for other nodes. - - raw_socket - Open a raw socket, and bind it to a pre-existing INTERFACE - (eth0 by default). All packets are read from this interface. - Packets received for the local node are written to the raw - socket. However, at least on Linux, the operating system does - not process IP packets destined for the local host. - - multicast - Open a multicast UDP socket and bind it to the address and - port (separated by spaces) and optionally a TTL value - specified using DEVICE. Packets are read from and written to - this multicast socket. This can be used to connect to UML, - QEMU or KVM instances listening on the same multicast address. - Do NOT connect multiple tinc daemons to the same multicast - address, this will very likely cause routing loops. Also note - that this can cause decrypted VPN packets to be sent out on a - real network if misconfigured. - - uml (not compiled in by default) - Create a UNIX socket with the filename specified by DEVICE, or - '/var/run/NETNAME.umlsocket' if not specified. Tinc will wait - for a User Mode Linux instance to connect to this socket. - - vde (not compiled in by default) - Uses the libvdeplug library to connect to a Virtual - Distributed Ethernet switch, using the UNIX socket specified - by DEVICE, or '/var/run/vde.ctl' if not specified. - - Also, in case tinc does not seem to correctly interpret packets - received from the virtual network device, it can be used to change - the way packets are interpreted: - - tun (BSD and Linux) + tun Set type to tun. Depending on the platform, this can either be with or without an address family header (see below). - tunnohead (BSD) + tunnohead Set type to tun without an address family header. Tinc will expect packets read from the virtual network device to start with an IP header. On some platforms IPv6 packets cannot be read from or written to the device in this mode. - tunifhead (BSD) + tunifhead Set type to tun with an address family header. Tinc will expect packets read from the virtual network device to start with a four byte header containing the address family, followed by an IP header. This mode should support both IPv4 and IPv6 packets. - utun (OS X) - Set type to utun. This is only supported on OS X version - 10.6.8 and higher, but doesn't require the tuntaposx module. - This mode should support both IPv4 and IPv6 packets. - - tap (BSD and Linux) + tap Set type to tap. Tinc will expect packets read from the virtual network device to start with an Ethernet header. DirectOnly = (no) [experimental] When this option is enabled, packets that cannot be sent directly - to the destination node, but which would have to be forwarded by an - intermediate node, are dropped instead. When combined with the + to the destination node, but which would have to be forwarded by + an intermediate node, are dropped instead. When combined with the IndirectData option, packets for nodes for which we do not have a meta connection with are also dropped. +ECDSAPrivateKeyFile = (`/etc/tinc/NETNAME/ecdsa_key.priv') + The file in which the private ECDSA key of this tinc daemon + resides. This is only used if ExperimentalProtocol is enabled. + +ExperimentalProtocol = (no) [experimental] + When this option is enabled, experimental protocol enhancements + will be used. Ephemeral ECDH will be used for key exchanges, and + ECDSA will be used instead of RSA for authentication. When + enabled, an ECDSA key must have been generated before with + `tincctl generate-ecdsa-keys'. The experimental protocol may + change at any time, and there is no guarantee that tinc will run + stable when it is used. + Forwarding = (internal) [experimental] This option selects the way indirect packets are forwarded. - off + off Incoming packets that are not meant for the local node, but which should be forwarded to another node, are dropped. - internal - Incoming packets that are meant for another node are forwarded - by tinc internally. + internal + Incoming packets that are meant for another node are + forwarded by tinc internally. This is the default mode, and unless you really know you need another forwarding mode, don't change it. - kernel + kernel Incoming packets are always sent to the TUN/TAP device, even if the packets are not for the local node. This is less efficient, but allows the kernel to apply its routing and firewall rules on them, and can also help debugging. GraphDumpFile = [experimental] - If this option is present, tinc will dump the current network graph - to the file FILENAME every minute, unless there were no changes to - the graph. The file is in a format that can be read by graphviz - tools. If FILENAME starts with a pipe symbol |, then the rest of - the filename is interpreted as a shell command that is executed, - the graph is then sent to stdin. + If this option is present, tinc will dump the current network + graph to the file FILENAME every minute, unless there were no + changes to the graph. The file is in a format that can be read by + graphviz tools. If FILENAME starts with a pipe symbol |, then the + rest of the filename is interpreted as a shell command that is + executed, the graph is then sent to stdin. Hostnames = (no) This option selects whether IP addresses (both real and on the VPN) should be resolved. Since DNS lookups are blocking, it might affect tinc's efficiency, even stopping the daemon for a few - seconds every time it does a lookup if your DNS server is not + seconds everytime it does a lookup if your DNS server is not responding. This does not affect resolving hostnames to IP addresses from the - configuration file, but whether hostnames should be resolved while - logging. - -IffOneQueue = (no) [experimental] - (Linux only) Set IFF_ONE_QUEUE flag on TUN/TAP devices. + configuration file. Interface = Defines the name of the interface corresponding to the virtual @@ -886,44 +834,19 @@ Interface = interface will be used. If you specified a Device, this variable is almost always already correctly set. -KeyExpire = (3600) - This option controls the time the encryption keys used to encrypt - the data are valid. It is common practice to change keys at - regular intervals to make it even harder for crackers, even though - it is thought to be nearly impossible to crack a single key. - -LocalDiscovery = (no) [experimental] - When enabled, tinc will try to detect peers that are on the same - local network. This will allow direct communication using LAN - addresses, even if both peers are behind a NAT and they only - ConnectTo a third node outside the NAT, which normally would - prevent the peers from learning each other's LAN address. - - Currently, local discovery is implemented by sending broadcast - packets to the LAN during path MTU discovery. This feature may not - work in all possible situations. - -MACExpire = (600) - This option controls the amount of time MAC addresses are kept - before they are removed. This only has effect when Mode is set to - "switch". - -MaxTimeout = (900) - This is the maximum delay before trying to reconnect to other tinc - daemons. - Mode = (router) This option selects the way packets are routed to other daemons. - router + router In this mode Subnet variables in the host configuration files - will be used to form a routing table. Only unicast packets of - routable protocols (IPv4 and IPv6) are supported in this mode. + will be used to form a routing table. Only unicast packets + of routable protocols (IPv4 and IPv6) are supported in this + mode. This is the default mode, and unless you really know you need another mode, don't change it. - switch + switch In this mode the MAC addresses of the packets on the VPN will be used to dynamically create a routing table just like an Ethernet switch does. Unicast, multicast and broadcast @@ -934,21 +857,26 @@ Mode = (router) This mode is primarily useful if you want to bridge Ethernet segments. - hub + hub This mode is almost the same as the switch mode, but instead every packet will be broadcast to the other daemons while no routing table is managed. -Name = [required] - This is a symbolic name for this connection. The name must consist - only of alphanumeric and underscore characters (a-z, A-Z, 0-9 and - _). +KeyExpire = (3600) + This option controls the time the encryption keys used to encrypt + the data are valid. It is common practice to change keys at + regular intervals to make it even harder for crackers, even though + it is thought to be nearly impossible to crack a single key. - If Name starts with a $, then the contents of the environment - variable that follows will be used. In that case, invalid - characters will be converted to underscores. If Name is $HOST, but - no such environment variable exist, the hostname will be read using - the gethostname() system call. +MACExpire = (600) + This option controls the amount of time MAC addresses are kept + before they are removed. This only has effect when Mode is set to + "switch". + +Name = [required] + This is a symbolic name for this connection. The name should + consist only of alfanumeric and underscore characters (a-z, A-Z, + 0-9 and _). PingInterval = (60) The number of seconds of inactivity that tinc will wait before @@ -956,7 +884,7 @@ PingInterval = (60) PingTimeout = (5) The number of seconds to wait for a response to pings or to allow - meta connections to block. If the other end doesn't respond within + meta connections to block. If the other end doesn't respond within this time, the connection is terminated, and the others will be notified of this. @@ -966,68 +894,46 @@ PriorityInheritance = (no) [experimental] out. PrivateKey = [obsolete] - This is the RSA private key for tinc. However, for safety reasons + This is the RSA private key for tinc. However, for safety reasons it is advised to store private keys of any kind in separate files. - This prevents accidental eavesdropping if you are editing the + This prevents accidental eavesdropping if you are editting the configuration file. -PrivateKeyFile = ('/etc/tinc/NETNAME/rsa_key.priv') +PrivateKeyFile = (`/etc/tinc/NETNAME/rsa_key.priv') This is the full path name of the RSA private key file that was - generated by 'tincd --generate-keys'. It must be a full path, not + generated by `tincctl generate-keys'. It must be a full path, not a relative directory. + Note that there must be exactly one of PrivateKey or PrivateKeyFile + specified in the configuration file. + ProcessPriority = When this option is used the priority of the tincd process will be adjusted. Increasing the priority may help to reduce latency and packet loss on the VPN. -Proxy = socks4 | socks5 | http | exec ... [experimental] - Use a proxy when making outgoing connections. The following proxy - types are currently supported: - - socks4
[] - Connects to the proxy using the SOCKS version 4 protocol. - Optionally, a USERNAME can be supplied which will be passed on - to the proxy server. - - socks5
[ ] - Connect to the proxy using the SOCKS version 5 protocol. If a - USERNAME and PASSWORD are given, basic username/password - authentication will be used, otherwise no authentication will - be used. - - http
- Connects to the proxy and sends a HTTP CONNECT request. - - exec - Executes the given command which should set up the outgoing - connection. The environment variables 'NAME', 'NODE', - 'REMOTEADDRES' and 'REMOTEPORT' are available. - ReplayWindow = (16) This is the size of the replay tracking window for each remote - node, in bytes. The window is a bitfield which tracks 1 packet per - bit, so for example the default setting of 16 will track up to 128 - packets in the window. In high bandwidth scenarios, setting this - to a higher value can reduce packet loss from the interaction of - replay tracking with underlying real packet loss and/or reordering. - Setting this to zero will disable replay tracking completely and - pass all traffic, but leaves tinc vulnerable to replay-based - attacks on your traffic. + node, in bytes. The window is a bitfield which tracks 1 packet + per bit, so for example the default setting of 16 will track up to + 128 packets in the window. In high bandwidth scenarios, setting + this to a higher value can reduce packet loss from the interaction + of replay tracking with underlying real packet loss and/or + reordering. Setting this to zero will disable replay tracking + completely and pass all traffic, but leaves tinc vulnerable to + replay-based attacks on your traffic. -StrictSubnets = (no) [experimental] +StrictSubnets (no) [experimental] When this option is enabled tinc will only use Subnet statements which are present in the host config files in the local - '/etc/tinc/NETNAME/hosts/' directory. Subnets learned via - connections to other nodes and which are not present in the local - host config files are ignored. + `/etc/tinc/NETNAME/hosts/' directory. TunnelServer = (no) [experimental] - When this option is enabled tinc will no longer forward information - between other tinc daemons, and will only allow connections with - nodes for which host config files are present in the local - '/etc/tinc/NETNAME/hosts/' directory. Setting this options also - implicitly sets StrictSubnets. + When this option is enabled tinc will no longer forward + information between other tinc daemons, and will only allow + connections with nodes for which host config files are present in + the local `/etc/tinc/NETNAME/hosts/' directory. Setting this + options also implicitly sets StrictSubnets. UDPRcvBuf = (OS default) Sets the socket receive buffer size for the UDP socket, in bytes. @@ -1039,6 +945,7 @@ UDPSndBuf = Pq OS default unset, the default buffer size will be used by the operating system. +  File: tinc.info, Node: Host configuration variables, Next: Scripts, Prev: Main configuration variables, Up: Configuration files @@ -1046,34 +953,32 @@ File: tinc.info, Node: Host configuration variables, Next: Scripts, Prev: Mai ---------------------------------- Address = [] [recommended] - This variable is only required if you want to connect to this host. - It must resolve to the external IP address where the host can be - reached, not the one that is internal to the VPN. If no port is - specified, the default Port is used. Multiple Address variables - can be specified, in which case each address will be tried until a - working connection has been established. + This variable is only required if you want to connect to this + host. It must resolve to the external IP address where the host + can be reached, not the one that is internal to the VPN. If no + port is specified, the default Port is used. -Cipher = (aes-256-cbc) +Cipher = (blowfish) The symmetric cipher algorithm used to encrypt UDP packets. Any - cipher supported by LibreSSL or OpenSSL is recognized. - Furthermore, specifying "none" will turn off packet encryption. It - is best to use only those ciphers which support CBC mode. + cipher supported by OpenSSL is recognized. Furthermore, + specifying "none" will turn off packet encryption. It is best to + use only those ciphers which support CBC mode. ClampMSS = (yes) - This option specifies whether tinc should clamp the maximum segment - size (MSS) of TCP packets to the path MTU. This helps in situations - where ICMP Fragmentation Needed or Packet too Big messages are - dropped by firewalls. + This option specifies whether tinc should clamp the maximum + segment size (MSS) of TCP packets to the path MTU. This helps in + situations where ICMP Fragmentation Needed or Packet too Big + messages are dropped by firewalls. Compression = (0) This option sets the level of compression used for UDP packets. Possible values are 0 (off), 1 (fast zlib) and any integer up to 9 (best zlib), 10 (fast lzo) and 11 (best lzo). -Digest = (sha256) +Digest = (sha1) The digest algorithm used to authenticate UDP packets. Any digest - supported by LibreSSL or OpenSSL is recognized. Furthermore, - specifying "none" will turn off packet authentication. + supported by OpenSSL is recognized. Furthermore, specifying + "none" will turn off packet authentication. IndirectData = (no) This option specifies whether other tinc daemons besides the one @@ -1085,32 +990,32 @@ IndirectData = (no) MACLength = (4) The length of the message authentication code used to authenticate - UDP packets. Can be anything from 0 up to the length of the digest - produced by the digest algorithm. + UDP packets. Can be anything from 0 up to the length of the + digest produced by the digest algorithm. PMTU = (1514) This option controls the initial path MTU to this node. PMTUDiscovery = (yes) - When this option is enabled, tinc will try to discover the path MTU - to this node. After the path MTU has been discovered, it will be - enforced on the VPN. + When this option is enabled, tinc will try to discover the path + MTU to this node. After the path MTU has been discovered, it will + be enforced on the VPN. Port = (655) This is the port this tinc daemon listens on. You can use decimal - portnumbers or symbolic names (as listed in '/etc/services'). + portnumbers or symbolic names (as listed in `/etc/services'). PublicKey = [obsolete] This is the RSA public key for this host. PublicKeyFile = [obsolete] This is the full path name of the RSA public key file that was - generated by 'tincd --generate-keys'. It must be a full path, not + generated by `tincctl generate-keys'. It must be a full path, not a relative directory. From version 1.0pre4 on tinc will store the public key directly into the host configuration file in PEM format, the above two - options then are not necessary. Either the PEM format is used, or + options then are not necessary. Either the PEM format is used, or exactly *one of the above two options* must be specified in each host configuration file, if you want to be able to establish a connection with that host. @@ -1118,41 +1023,40 @@ PublicKeyFile = [obsolete] Subnet = The subnet which this tinc daemon will serve. Tinc tries to look up which other daemon it should send a packet to by searching the - appropriate subnet. If the packet matches a subnet, it will be + appropiate subnet. If the packet matches a subnet, it will be sent to the daemon who has this subnet in his host configuration file. Multiple subnet lines can be specified for each daemon. Subnets can either be single MAC, IPv4 or IPv6 addresses, in which - case a subnet consisting of only that single address is assumed, or - they can be a IPv4 or IPv6 network address with a prefixlength. - For example, IPv4 subnets must be in a form like 192.168.1.0/24, - where 192.168.1.0 is the network address and 24 is the number of - bits set in the netmask. Note that subnets like 192.168.1.1/24 are - invalid! Read a networking HOWTO/FAQ/guide if you don't understand - this. IPv6 subnets are notated like fec0:0:0:1::/64. MAC - addresses are notated like 0:1a:2b:3c:4d:5e. + case a subnet consisting of only that single address is assumed, + or they can be a IPv4 or IPv6 network address with a prefixlength. + Shorthand notations are not supported. For example, IPv4 subnets + must be in a form like 192.168.1.0/24, where 192.168.1.0 is the + network address and 24 is the number of bits set in the netmask. + Note that subnets like 192.168.1.1/24 are invalid! Read a + networking HOWTO/FAQ/guide if you don't understand this. IPv6 + subnets are notated like fec0:0:0:1:0:0:0:0/64. MAC addresses are + notated like 0:1a:2b:3c:4d:5e. Prefixlength is the number of bits set to 1 in the netmask part; for example: netmask 255.255.255.0 would become /24, 255.255.252.0 - becomes /22. This conforms to standard CIDR notation as described - in RFC1519 (https://www.ietf.org/rfc/rfc1519.txt) + becomes /22. This conforms to standard CIDR notation as described + in RFC1519 (ftp://ftp.isi.edu/in-notes/rfc1519.txt) A Subnet can be given a weight to indicate its priority over - identical Subnets owned by different nodes. The default weight is - 10. Lower values indicate higher priority. Packets will be sent - to the node with the highest priority, unless that node is not + identical Subnets owned by different nodes. The default weight is + 10. Lower values indicate higher priority. Packets will be sent to + the node with the highest priority, unless that node is not reachable, in which case the node with the next highest priority will be tried, and so on. -TCPonly = (no) [deprecated] - If this variable is set to yes, then the packets are tunnelled over - a TCP connection instead of a UDP connection. This is especially - useful for those who want to run a tinc daemon from behind a - masquerading firewall, or if UDP packet routing is disabled - somehow. Setting this options also implicitly sets IndirectData. - - Since version 1.0.10, tinc will automatically detect whether - communication via UDP is possible or not. +TCPonly = (no) + If this variable is set to yes, then the packets are tunnelled + over a TCP connection instead of a UDP connection. This is + especially useful for those who want to run a tinc daemon from + behind a masquerading firewall, or if UDP packet routing is + disabled somehow. Setting this options also implicitly sets + IndirectData.  File: tinc.info, Node: Scripts, Next: How to configure, Prev: Host configuration variables, Up: Configuration files @@ -1161,88 +1065,76 @@ File: tinc.info, Node: Scripts, Next: How to configure, Prev: Host configurat ------------- Apart from reading the server and host configuration files, tinc can -also run scripts at certain moments. Below is a list of filenames of -scripts and a description of when they are run. A script is only run if -it exists and if it is executable. +also run scripts at certain moments. Under Windows (not Cygwin), the +scripts should have the extension .bat. - Scripts are run synchronously; this means that tinc will temporarily -stop processing packets until the called script finishes executing. -This guarantees that scripts will execute in the exact same order as the -events that trigger them. If you need to run commands asynchronously, -you have to ensure yourself that they are being run in the background. - - Under Windows (not Cygwin), the scripts must have the extension .bat. - -'/etc/tinc/NETNAME/tinc-up' +`/etc/tinc/NETNAME/tinc-up' This is the most important script. If it is present it will be executed right after the tinc daemon has been started and has connected to the virtual network device. It should be used to set up the corresponding network interface, but can also be used to - start other things. + start other things. Under Windows you can use the Network + Connections control panel instead of creating this script. - Under Windows you can use the Network Connections control panel - instead of creating this script. - -'/etc/tinc/NETNAME/tinc-down' +`/etc/tinc/NETNAME/tinc-down' This script is started right before the tinc daemon quits. -'/etc/tinc/NETNAME/hosts/HOST-up' +`/etc/tinc/NETNAME/hosts/HOST-up' This script is started when the tinc daemon with name HOST becomes reachable. -'/etc/tinc/NETNAME/hosts/HOST-down' +`/etc/tinc/NETNAME/hosts/HOST-down' This script is started when the tinc daemon with name HOST becomes unreachable. -'/etc/tinc/NETNAME/host-up' +`/etc/tinc/NETNAME/host-up' This script is started when any host becomes reachable. -'/etc/tinc/NETNAME/host-down' +`/etc/tinc/NETNAME/host-down' This script is started when any host becomes unreachable. -'/etc/tinc/NETNAME/subnet-up' - This script is started when a subnet becomes reachable. The Subnet - and the node it belongs to are passed in environment variables. +`/etc/tinc/NETNAME/subnet-up' + This script is started when a Subnet becomes reachable. The + Subnet and the node it belongs to are passed in environment + variables. -'/etc/tinc/NETNAME/subnet-down' - This script is started when a subnet becomes unreachable. +`/etc/tinc/NETNAME/subnet-down' + This script is started when a Subnet becomes unreachable. The scripts are started without command line arguments, but can make -use of certain environment variables. Under UNIX like operating systems -the names of environment variables must be preceded by a $ in scripts. -Under Windows, in '.bat' files, they have to be put between % signs. +use of certain environment variables. Under UNIX like operating +systems the names of environment variables must be preceded by a $ in +scripts. Under Windows, in `.bat' files, they have to be put between % +signs. -'NETNAME' +`NETNAME' If a netname was specified, this environment variable contains it. -'NAME' +`NAME' Contains the name of this tinc daemon. -'DEVICE' +`DEVICE' Contains the name of the virtual network device that tinc uses. -'INTERFACE' +`INTERFACE' Contains the name of the virtual network interface that tinc uses. This should be used for commands like ifconfig. -'NODE' +`NODE' When a host becomes (un)reachable, this is set to its name. If a subnet becomes (un)reachable, this is set to the owner of that subnet. -'REMOTEADDRESS' +`REMOTEADDRESS' When a host becomes (un)reachable, this is set to its real address. -'REMOTEPORT' +`REMOTEPORT' When a host becomes (un)reachable, this is set to the port number it uses for communication with other tinc daemons. -'SUBNET' +`SUBNET' When a subnet becomes (un)reachable, this is set to the subnet. -'WEIGHT' - When a subnet becomes (un)reachable, this is set to the subnet - weight.  File: tinc.info, Node: How to configure, Prev: Scripts, Up: Configuration files @@ -1250,35 +1142,35 @@ File: tinc.info, Node: How to configure, Prev: Scripts, Up: Configuration fil 4.4.4 How to configure ---------------------- -Step 1. Creating the main configuration file -............................................ +Step 1. Creating the main configuration file +............................................. The main configuration file will be called -'/etc/tinc/NETNAME/tinc.conf'. Adapt the following example to create a +`/etc/tinc/NETNAME/tinc.conf'. Adapt the following example to create a basic configuration file: Name = YOURNAME - Device = /dev/tap0 + Device = `/dev/tap0' Then, if you know to which other tinc daemon(s) yours is going to -connect, add 'ConnectTo' values. +connect, add `ConnectTo' values. -Step 2. Creating your host configuration file -............................................. +Step 2. Creating your host configuration file +.............................................. -If you added a line containing 'Name = yourname' in the main -configuration file, you will need to create a host configuration file -'/etc/tinc/NETNAME/hosts/yourname'. Adapt the following example to +If you added a line containing `Name = yourname' in the main +configuarion file, you will need to create a host configuration file +`/etc/tinc/NETNAME/hosts/yourname'. Adapt the following example to create a host configuration file: Address = your.real.hostname.org Subnet = 192.168.1.0/24 - You can also use an IP address instead of a hostname. The 'Subnet' + You can also use an IP address instead of a hostname. The `Subnet' specifies the address range that is local for _your part of the VPN only_. If you have multiple address ranges you can specify more than -one 'Subnet'. You might also need to add a 'Port' if you want your tinc -daemon to run on a different port number than the default (655). +one `Subnet'. You might also need to add a `Port' if you want your +tinc daemon to run on a different port number than the default (655).  File: tinc.info, Node: Generating keypairs, Next: Network interfaces, Prev: Configuration files, Up: Configuration @@ -1290,7 +1182,7 @@ Now that you have already created the main configuration file and your host configuration file, you can easily create a public/private keypair by entering the following command: - tincd -n NETNAME -K + tincctl -n NETNAME generate-keys Tinc will generate a public and a private key and ask you where to put them. Just press enter to accept the defaults. @@ -1307,27 +1199,28 @@ the virtual network interface. First, decide which IP addresses you want to have associated with these devices, and what network mask they must have. - Tinc will open a virtual network device ('/dev/tun', '/dev/tap0' or + Tinc will open a virtual network device (`/dev/tun', `/dev/tap0' or similar), which will also create a network interface called something -like 'tun0', 'tap0'. If you are using the Linux tun/tap driver, the +like `tun0', `tap0'. If you are using the Linux tun/tap driver, the network interface will by default have the same name as the NETNAME. Under Windows you can change the name of the network interface from the Network Connections control panel. - You can configure the network interface by putting ordinary ifconfig, -route, and other commands to a script named '/etc/tinc/NETNAME/tinc-up'. -When tinc starts, this script will be executed. When tinc exits, it -will execute the script named '/etc/tinc/NETNAME/tinc-down', but -normally you don't need to create that script. + You can configure the network interface by putting ordinary +ifconfig, route, and other commands to a script named +`/etc/tinc/NETNAME/tinc-up'. When tinc starts, this script will be +executed. When tinc exits, it will execute the script named +`/etc/tinc/NETNAME/tinc-down', but normally you don't need to create +that script. - An example 'tinc-up' script: + An example `tinc-up' script: #!/bin/sh ifconfig $INTERFACE 192.168.1.1 netmask 255.255.0.0 This script gives the interface an IP address and a netmask. The kernel will also automatically add a route to this interface, so -normally you don't need to add route commands to the 'tinc-up' script. +normally you don't need to add route commands to the `tinc-up' script. The kernel will also bring the interface up after this command. The netmask is the mask of the _entire_ VPN network, not just your own subnet. @@ -1344,12 +1237,12 @@ File: tinc.info, Node: Example configuration, Prev: Network interfaces, Up: C 4.7 Example configuration ========================= -Imagine the following situation. Branch A of our example 'company' +Imagine the following situation. Branch A of our example `company' wants to connect three branch offices in B, C and D using the Internet. All four offices have a 24/7 connection to the Internet. A is going to serve as the center of the network. B and C will -connect to A, and D will connect to C. Each office will be assigned +connect to A, and D will connect to C. Each office will be assigned their own IP network, 10.x.0.0. A: net 10.1.0.0 mask 255.255.0.0 gateway 10.1.54.1 internet IP 1.2.3.4 @@ -1362,31 +1255,31 @@ the tincd, and "internet IP" is the IP address of the firewall, which does not need to run tincd, but it must do a port forwarding of TCP and UDP on port 655 (unless otherwise configured). - In this example, it is assumed that eth0 is the interface that points -to the inner (physical) LAN of the office, although this could also be -the same as the interface that leads to the Internet. The configuration -of the real interface is also shown as a comment, to give you an idea of -how these example host is set up. All branches use the netname -'company' for this particular VPN. + In this example, it is assumed that eth0 is the interface that +points to the inner (physical) LAN of the office, although this could +also be the same as the interface that leads to the Internet. The +configuration of the real interface is also shown as a comment, to give +you an idea of how these example host is set up. All branches use the +netname `company' for this particular VPN. For Branch A ............ _BranchA_ would be configured like this: - In '/etc/tinc/company/tinc-up': + In `/etc/tinc/company/tinc-up': # Real interface of internal network: # ifconfig eth0 10.1.54.1 netmask 255.255.0.0 ifconfig $INTERFACE 10.1.54.1 netmask 255.0.0.0 - and in '/etc/tinc/company/tinc.conf': + and in `/etc/tinc/company/tinc.conf': Name = BranchA Device = /dev/tap0 - On all hosts, '/etc/tinc/company/hosts/BranchA' contains: + On all hosts, `/etc/tinc/company/hosts/BranchA' contains: Subnet = 10.1.0.0/16 Address = 1.2.3.4 @@ -1396,22 +1289,22 @@ _BranchA_ would be configured like this: -----END RSA PUBLIC KEY----- Note that the IP addresses of eth0 and tap0 are the same. This is -quite possible, if you make sure that the netmasks of the interfaces are -different. It is in fact recommended to give both real internal network -interfaces and tap interfaces the same IP address, since that will make -things a lot easier to remember and set up. +quite possible, if you make sure that the netmasks of the interfaces +are different. It is in fact recommended to give both real internal +network interfaces and tap interfaces the same IP address, since that +will make things a lot easier to remember and set up. For Branch B ............ -In '/etc/tinc/company/tinc-up': +In `/etc/tinc/company/tinc-up': # Real interface of internal network: # ifconfig eth0 10.2.43.8 netmask 255.255.0.0 ifconfig $INTERFACE 10.2.1.12 netmask 255.0.0.0 - and in '/etc/tinc/company/tinc.conf': + and in `/etc/tinc/company/tinc.conf': Name = BranchB ConnectTo = BranchA @@ -1420,7 +1313,7 @@ In '/etc/tinc/company/tinc-up': same as on the tap0 device. Also, ConnectTo is given so that this node will always try to connect to BranchA. - On all hosts, in '/etc/tinc/company/hosts/BranchB': + On all hosts, in `/etc/tinc/company/hosts/BranchB': Subnet = 10.2.0.0/16 Address = 2.3.4.5 @@ -1432,24 +1325,24 @@ will always try to connect to BranchA. For Branch C ............ -In '/etc/tinc/company/tinc-up': +In `/etc/tinc/company/tinc-up': # Real interface of internal network: # ifconfig eth0 10.3.69.254 netmask 255.255.0.0 ifconfig $INTERFACE 10.3.69.254 netmask 255.0.0.0 - and in '/etc/tinc/company/tinc.conf': + and in `/etc/tinc/company/tinc.conf': Name = BranchC ConnectTo = BranchA Device = /dev/tap1 C already has another daemon that runs on port 655, so they have to -reserve another port for tinc. It knows the portnumber it has to listen +reserve another port for tinc. It knows the portnumber it has to listen on from it's own host configuration file. - On all hosts, in '/etc/tinc/company/hosts/BranchC': + On all hosts, in `/etc/tinc/company/hosts/BranchC': Address = 3.4.5.6 Subnet = 10.3.0.0/16 @@ -1462,26 +1355,26 @@ on from it's own host configuration file. For Branch D ............ -In '/etc/tinc/company/tinc-up': +In `/etc/tinc/company/tinc-up': # Real interface of internal network: # ifconfig eth0 10.4.3.32 netmask 255.255.0.0 ifconfig $INTERFACE 10.4.3.32 netmask 255.0.0.0 - and in '/etc/tinc/company/tinc.conf': + and in `/etc/tinc/company/tinc.conf': Name = BranchD ConnectTo = BranchC Device = /dev/net/tun - D will be connecting to C, which has a tincd running for this network -on port 2000. It knows the port number from the host configuration -file. Also note that since D uses the tun/tap driver, the network -interface will not be called 'tun' or 'tap0' or something like that, but -will have the same name as netname. + D will be connecting to C, which has a tincd running for this +network on port 2000. It knows the port number from the host +configuration file. Also note that since D uses the tun/tap driver, +the network interface will not be called `tun' or `tap0' or something +like that, but will have the same name as netname. - On all hosts, in '/etc/tinc/company/hosts/BranchD': + On all hosts, in `/etc/tinc/company/hosts/BranchD': Subnet = 10.4.0.0/16 Address = 4.5.6.7 @@ -1496,13 +1389,13 @@ Key files A, B, C and D all have generated a public/private keypair with the following command: - tincd -n company -K + tincctl -n company generate-keys - The private key is stored in '/etc/tinc/company/rsa_key.priv', the + The private key is stored in `/etc/tinc/company/rsa_key.priv', the public key is put into the host configuration file in the -'/etc/tinc/company/hosts/' directory. During key generation, tinc -automatically guesses the right filenames based on the -n option and the -Name directive in the 'tinc.conf' file (if it is available). +`/etc/tinc/company/hosts/' directory. During key generation, tinc +automatically guesses the right filenames based on the -n option and +the Name directive in the `tinc.conf' file (if it is available). Starting ........ @@ -1514,7 +1407,7 @@ have started their daemons, tinc will try connecting until they are available.  -File: tinc.info, Node: Running tinc, Next: Technical information, Prev: Configuration, Up: Top +File: tinc.info, Node: Running tinc, Next: Controlling tinc, Prev: Configuration, Up: Top 5 Running tinc ************** @@ -1547,90 +1440,67 @@ File: tinc.info, Node: Runtime options, Next: Signals, Up: Running tinc Besides the settings in the configuration file, tinc also accepts some command line options. -'-c, --config=PATH' +`-c, --config=PATH' Read configuration options from the directory PATH. The default is - '/etc/tinc/NETNAME/'. + `/etc/tinc/NETNAME/'. -'-D, --no-detach' +`-D, --no-detach' Don't fork and detach. This will also disable the automatic restart mechanism for fatal errors. -'-d, --debug=LEVEL' +`-d, --debug=LEVEL' Set debug level to LEVEL. The higher the debug level, the more gets logged. Everything goes via syslog. -'-k, --kill[=SIGNAL]' - Attempt to kill a running tincd (optionally with the specified - SIGNAL instead of SIGTERM) and exit. Use it in conjunction with - the -n option to make sure you kill the right tinc daemon. Under - native Windows the optional argument is ignored, the service will - always be stopped and removed. - -'-n, --net=NETNAME' +`-n, --net=NETNAME' Use configuration for net NETNAME. This will let tinc read all - configuration files from '/etc/tinc/NETNAME/'. Specifying . for + configuration files from `/etc/tinc/NETNAME/'. Specifying . for NETNAME is the same as not specifying any NETNAME. *Note Multiple networks::. -'-K, --generate-keys[=BITS]' - Generate public/private keypair of BITS length. If BITS is not - specified, 2048 is the default. tinc will ask where you want to - store the files, but will default to the configuration directory - (you can use the -c or -n option in combination with -K). After - that, tinc will quit. +`--pidfile=FILENAME' + Store a cookie in FILENAME which allows tincctl to authenticate. + If unspecified, the default is `/var/run/tinc.NETNAME.pid'. -'-o, --option=[HOST.]KEY=VALUE' - Without specifying a HOST, this will set server configuration - variable KEY to VALUE. If specified as HOST.KEY=VALUE, this will - set the host configuration variable KEY of the host named HOST to - VALUE. This option can be used more than once to specify multiple - configuration variables. - -'-L, --mlock' +`-L, --mlock' Lock tinc into main memory. This will prevent sensitive data like shared private keys to be written to the system swap files/partitions. -'--logfile[=FILE]' +`--logfile[=FILE]' Write log entries to a file instead of to the system logging facility. If FILE is omitted, the default is - '/var/log/tinc.NETNAME.log'. + `/var/log/tinc.NETNAME.log'. -'--pidfile=FILE' - Write PID to FILE instead of '/var/run/tinc.NETNAME.pid'. - -'--bypass-security' +`--bypass-security' Disables encryption and authentication. Only useful for debugging. -'-R, --chroot' +`-R, --chroot' Change process root directory to the directory where the config - file is located ('/etc/tinc/NETNAME/' as determined by -n/-net + file is located (`/etc/tinc/NETNAME/' as determined by -n/-net option or as given by -c/-config option), for added security. The chroot is performed after all the initialization is done, after writing pid files and opening network sockets. - This option is best used in combination with the -U/-user option - described below. + Note that this option alone does not do any good without -U/-user, + below. - You will need to ensure the chroot environment contains all the - files necessary for tinc to run correctly. Most importantly, for - tinc to be able to resolve hostnames inside the chroot environment, - you must copy '/etc/resolv.conf' into the chroot directory. If you - want to be able to run scripts other than 'tinc-up' in the chroot, - you must ensure the appropriate shell is also installed in the - chroot, along with all its dependencies. + Note also that tinc can't run scripts anymore (such as tinc-down + or host-up), unless it's setup to be runnable inside chroot + environment. -'-U, --user=USER' +`-U, --user=USER' Switch to the given USER after initialization, at the same time as chroot is performed (see -chroot above). With this option tinc drops privileges, for added security. -'--help' +`--help' Display a short reminder of these runtime options and terminate. -'--version' +`--version' Output version information and exit. +  File: tinc.info, Node: Signals, Next: Debug levels, Prev: Runtime options, Up: Running tinc @@ -1639,33 +1509,20 @@ File: tinc.info, Node: Signals, Next: Debug levels, Prev: Runtime options, U You can also send the following signals to a running tincd process: -'ALRM' +`ALRM' Forces tinc to try to connect to all uplinks immediately. Usually tinc attempts to do this itself, but increases the time it waits between the attempts each time it failed, and if tinc didn't - succeed to connect to an uplink the first time after it started, it - defaults to the maximum time of 15 minutes. + succeed to connect to an uplink the first time after it started, + it defaults to the maximum time of 15 minutes. -'HUP' +`HUP' Partially rereads configuration files. Connections to hosts whose host config file are removed are closed. New outgoing connections - specified in 'tinc.conf' will be made. If the -logfile option is - used, this will also close and reopen the log file, useful when log - rotation is used. + specified in `tinc.conf' will be made. If the -logfile option is + used, this will also close and reopen the log file, useful when + log rotation is used. -'INT' - Temporarily increases debug level to 5. Send this signal again to - revert to the original level. - -'USR1' - Dumps the connection list to syslog. - -'USR2' - Dumps virtual network device statistics, all known nodes, edges and - subnets to syslog. - -'WINCH' - Purges all information remembered about unreachable nodes.  File: tinc.info, Node: Debug levels, Next: Solving problems, Prev: Signals, Up: Running tinc @@ -1674,32 +1531,33 @@ File: tinc.info, Node: Debug levels, Next: Solving problems, Prev: Signals, ================ The tinc daemon can send a lot of messages to the syslog. The higher -the debug level, the more messages it will log. Each level inherits all -messages of the previous level: +the debug level, the more messages it will log. Each level inherits +all messages of the previous level: -'0' +`0' This will log a message indicating tinc has started along with a version number. It will also log any serious error. -'1' +`1' This will log all connections that are made with other tinc daemons. -'2' - This will log status and error messages from scripts and other tinc - daemons. +`2' + This will log status and error messages from scripts and other + tinc daemons. -'3' +`3' This will log all requests that are exchanged with other tinc - daemons. These include authentication, key exchange and connection + daemons. These include authentication, key exchange and connection list updates. -'4' +`4' This will log a copy of everything received on the meta socket. -'5' +`5' This will log all network traffic over the virtual private network. +  File: tinc.info, Node: Solving problems, Next: Error messages, Prev: Debug levels, Up: Running tinc @@ -1713,10 +1571,10 @@ directly see everything tinc logs: tincd -n NETNAME -d5 -D - If tinc does not log any error messages, then you might want to check -the following things: + If tinc does not log any error messages, then you might want to +check the following things: - * 'tinc-up' script Does this script contain the right commands? + * `tinc-up' script Does this script contain the right commands? Normally you must give the interface the address of this host on the VPN, and the netmask must be big enough so that the entire VPN is covered. @@ -1730,11 +1588,10 @@ the following things: masquerading)? If so, check that it allows TCP and UDP traffic on port 655. If it masquerades and the host running tinc is behind it, make sure that it forwards TCP and UDP traffic to port 655 to - the host running tinc. You can add 'TCPOnly = yes' to your host - config file to force tinc to only use a single TCP connection, this - works through most firewalls and NATs. Since version 1.0.10, tinc - will automatically fall back to TCP if direct communication via UDP - is not possible. + the host running tinc. You can add `TCPOnly = yes' to your host + config file to force tinc to only use a single TCP connection, + this works through most firewalls and NATs. +  File: tinc.info, Node: Error messages, Next: Sending bug reports, Prev: Solving problems, Up: Running tinc @@ -1746,93 +1603,98 @@ What follows is a list of the most common error messages you might find in the logs. Some of them will only be visible if the debug level is high enough. -'Could not open /dev/tap0: No such device' +`Could not open /dev/tap0: No such device' + * You forgot to `modprobe netlink_dev' or `modprobe ethertap'. - * You forgot to 'modprobe netlink_dev' or 'modprobe ethertap'. - * You forgot to compile 'Netlink device emulation' in the + * You forgot to compile `Netlink device emulation' in the kernel. -'Can't write to /dev/net/tun: No such device' +`Can't write to /dev/net/tun: No such device' + * You forgot to `modprobe tun'. - * You forgot to 'modprobe tun'. - * You forgot to compile 'Universal TUN/TAP driver' in the + * You forgot to compile `Universal TUN/TAP driver' in the kernel. - * The tun device is located somewhere else in '/dev/'. -'Network address and prefix length do not match!' + * The tun device is located somewhere else in `/dev/'. +`Network address and prefix length do not match!' * The Subnet field must contain a _network_ address, trailing bits should be 0. + * If you only want to use one IP address, set the netmask to /32. -'Error reading RSA key file `rsa_key.priv': No such file or directory' - +`Error reading RSA key file `rsa_key.priv': No such file or directory' * You forgot to create a public/private keypair. - * Specify the complete pathname to the private key file with the - 'PrivateKeyFile' option. -'Warning: insecure file permissions for RSA private key file `rsa_key.priv'!' + * Specify the complete pathname to the private key file with + the `PrivateKeyFile' option. +`Warning: insecure file permissions for RSA private key file `rsa_key.priv'!' * The private key file is readable by users other than root. Use chmod to correct the file permissions. -'Creating metasocket failed: Address family not supported' - +`Creating metasocket failed: Address family not supported' * By default tinc tries to create both IPv4 and IPv6 sockets. On some platforms this might not be implemented. If the logs - show 'Ready' later on, then at least one metasocket was + show `Ready' later on, then at least one metasocket was created, and you can ignore this message. You can add - 'AddressFamily = ipv4' to 'tinc.conf' to prevent this from + `AddressFamily = ipv4' to `tinc.conf' to prevent this from happening. -'Cannot route packet: unknown IPv4 destination 1.2.3.4' - +`Cannot route packet: unknown IPv4 destination 1.2.3.4' * You try to send traffic to a host on the VPN for which no Subnet is known. + * If it is a broadcast address (ending in .255), it probably is a samba server or a Windows host sending broadcast packets. You can ignore it. -'Cannot route packet: ARP request for unknown address 1.2.3.4' - +`Cannot route packet: ARP request for unknown address 1.2.3.4' * You try to send traffic to a host on the VPN for which no Subnet is known. -'Packet with destination 1.2.3.4 is looping back to us!' - - * Something is not configured right. Packets are being sent out +`Packet with destination 1.2.3.4 is looping back to us!' + * Something is not configured right. Packets are being sent out to the virtual network device, but according to the Subnet directives in your host configuration file, those packets - should go to your own host. Most common mistake is that you + should go to your own host. Most common mistake is that you have a Subnet line in your host configuration file with a prefix length which is just as large as the prefix of the - virtual network interface. The latter should in almost all - cases be larger. Rethink your configuration. Note that you - will only see this message if you specified a debug level of 5 - or higher! - * Chances are that a 'Subnet = ...' line in the host - configuration file of this tinc daemon is wrong. Change it to - a subnet that is accepted locally by another interface, or if - that is not the case, try changing the prefix length into /32. + virtual network interface. The latter should in almost all + cases be larger. Rethink your configuration. Note that you + will only see this message if you specified a debug level of + 5 or higher! -'Node foo (1.2.3.4) is not reachable' + * Chances are that a `Subnet = ...' line in the host + configuration file of this tinc daemon is wrong. Change it + to a subnet that is accepted locally by another interface, or + if that is not the case, try changing the prefix length into + /32. +`Node foo (1.2.3.4) is not reachable' * Node foo does not have a connection anymore, its tinc daemon is not running or its connection to the Internet is broken. -'Received UDP packet from unknown source 1.2.3.4 (port 12345)' - +`Received UDP packet from unknown source 1.2.3.4 (port 12345)' * If you see this only sporadically, it is harmless and caused by a node sending packets using an old key. -'Got bad/bogus/unauthorized REQUEST from foo (1.2.3.4 port 12345)' + * If you see this often and another node is not reachable + anymore, then a NAT (masquerading firewall) is changing the + source address of UDP packets. You can add `TCPOnly = yes' + to host configuration files to force all VPN traffic to go + over a TCP connection. +`Got bad/bogus/unauthorized REQUEST from foo (1.2.3.4 port 12345)' * Node foo does not have the right public/private keypair. Generate new keypairs and distribute them again. + * An attacker tries to gain access to your VPN. + * A network error caused corruption of metadata sent from foo. +  File: tinc.info, Node: Sending bug reports, Prev: Error messages, Up: Running tinc @@ -1846,21 +1708,217 @@ bugreport: * A clear description of what you are trying to achieve and what the problem is. + * What platform (operating system, version, hardware architecture) and which version of tinc you use. - * If compiling tinc fails, a copy of 'config.log' and the error + + * If compiling tinc fails, a copy of `config.log' and the error messages you get. - * Otherwise, a copy of 'tinc.conf', 'tinc-up' and all files in the - 'hosts/' directory. - * The output of the commands 'ifconfig -a' and 'route -n' (or - 'netstat -rn' if that doesn't work). + + * Otherwise, a copy of `tinc.conf', `tinc-up' and all files in the + `hosts/' directory. + + * The output of the commands `ifconfig -a' and `route -n' (or + `netstat -rn' if that doesn't work). + * The output of any command that fails to work as it should (like ping or traceroute).  -File: tinc.info, Node: Technical information, Next: Platform specific information, Prev: Running tinc, Up: Top +File: tinc.info, Node: Controlling tinc, Next: Technical information, Prev: Running tinc, Up: Top -6 Technical information +6 Controlling tinc +****************** + +You can control and inspect a running tincd through the tincctl +command. A quick example: + + tincctl -n NETNAME reload + +* Menu: + +* tincctl runtime options:: +* tincctl commands:: +* tincctl examples:: +* tincctl top:: + + +File: tinc.info, Node: tincctl runtime options, Next: tincctl commands, Up: Controlling tinc + +6.1 tincctl runtime options +=========================== + +`-c, --config=PATH' + Read configuration options from the directory PATH. The default is + `/etc/tinc/NETNAME/'. + +`-n, --net=NETNAME' + Use configuration for net NETNAME. *Note Multiple networks::. + +`--pidfile=FILENAME' + Use the cookie from FILENAME to authenticate with a running tinc + daemon. If unspecified, the default is + `/var/run/tinc.NETNAME.pid'. + +`--help' + Display a short reminder of runtime options and commands, then + terminate. + +`--version' + Output version information and exit. + + + +File: tinc.info, Node: tincctl commands, Next: tincctl examples, Prev: tincctl runtime options, Up: Controlling tinc + +6.2 tincctl commands +==================== + +`start' + Start `tincd'. + +`stop' + Stop `tincd'. + +`restart' + Restart `tincd'. + +`reload' + Partially rereads configuration files. Connections to hosts whose + host config files are removed are closed. New outgoing connections + specified in `tinc.conf' will be made. + +`pid' + Shows the PID of the currently running `tincd'. + +`generate-keys [BITS]' + Generate public/private keypair of BITS length. If BITS is not + specified, 1024 is the default. tinc will ask where you want to + store the files, but will default to the configuration directory + (you can use the -c or -n option). + +`dump nodes' + Dump a list of all known nodes in the VPN. + +`dump edges' + Dump a list of all known connections in the VPN. + +`dump subnets' + Dump a list of all known subnets in the VPN. + +`dump connections' + Dump a list of all meta connections with ourself. + +`dump graph' + Dump a graph of the VPN in dotty format. + +`purge' + Purges all information remembered about unreachable nodes. + +`debug LEVEL' + Sets debug level to LEVEL. + +`retry' + Forces tinc to try to connect to all uplinks immediately. Usually + tinc attempts to do this itself, but increases the time it waits + between the attempts each time it failed, and if tinc didn't + succeed to connect to an uplink the first time after it started, + it defaults to the maximum time of 15 minutes. + +`disconnect NODE' + Closes the meta connection with the given NODE. + +`top' + If tincctl is compiled with libcurses support, this will display + live traffic statistics for all the known nodes, similar to the + UNIX top command. See below for more information. + +`pcap' + Dump VPN traffic going through the local tinc node in + pcap-savefile format to standard output, from where it can be + redirected to a file or piped through a program that can parse it + directly, such as tcpdump. + + + +File: tinc.info, Node: tincctl examples, Next: tincctl top, Prev: tincctl commands, Up: Controlling tinc + +6.3 tincctl examples +==================== + +Examples of some commands: + + tincctl -n vpn dump graph | circo -Txlib + tincctl -n vpn pcap | tcpdump -r - + tincctl -n vpn top + + +File: tinc.info, Node: tincctl top, Prev: tincctl examples, Up: Controlling tinc + +6.4 tincctl top +=============== + +The top command connects to a running tinc daemon and repeatedly +queries its per-node traffic counters. It displays a list of all the +known nodes in the left-most column, and the amount of bytes and +packets read from and sent to each node in the other columns. By +default, the information is updated every second. The behaviour of the +top command can be changed using the following keys: + + + Change the interval between updates. After pressing the key, + enter the desired interval in seconds, followed by enter. + Fractional seconds are honored. Intervals lower than 0.1 seconds + are not allowed. + + + Toggle between displaying current traffic rates (in packets and + bytes per second) and cummulative traffic (total packets and bytes + since the tinc daemon started). + + + Sort the list of nodes by name. + + + Sort the list of nodes by incoming amount of bytes. + + + Sort the list of nodes by incoming amount of packets. + + + Sort the list of nodes by outgoing amount of bytes. + + + Sort the list of nodes by outgoing amount of packets. + + + Sort the list of nodes by sum of incoming and outgoing amount of + bytes. + + + Sort the list of nodes by sum of incoming and outgoing amount of + packets. + + + Show amount of traffic in bytes. + + + Show amount of traffic in kilobytes. + + + Show amount of traffic in megabytes. + + + Show amount of traffic in gigabytes. + + + Quit. + + + +File: tinc.info, Node: Technical information, Next: Platform specific information, Prev: Controlling tinc, Up: Top + +7 Technical information *********************** * Menu: @@ -1872,7 +1930,7 @@ File: tinc.info, Node: Technical information, Next: Platform specific informat  File: tinc.info, Node: The connection, Next: The meta-protocol, Up: Technical information -6.1 The connection +7.1 The connection ================== Tinc is a daemon that takes VPN data and transmit that to another host @@ -1886,65 +1944,66 @@ computer over the existing Internet infrastructure.  File: tinc.info, Node: The UDP tunnel, Next: The meta-connection, Up: The connection -6.1.1 The UDP tunnel +7.1.1 The UDP tunnel -------------------- The data itself is read from a character device file, the so-called _virtual network device_. This device is associated with a network interface. Any data sent to this interface can be read from the device, and any data written to the device gets sent from the interface. There -are two possible types of virtual network devices: 'tun' style, which +are two possible types of virtual network devices: `tun' style, which are point-to-point devices which can only handle IPv4 and/or IPv6 -packets, and 'tap' style, which are Ethernet devices and handle complete -Ethernet frames. +packets, and `tap' style, which are Ethernet devices and handle +complete Ethernet frames. So when tinc reads an Ethernet frame from the device, it determines -its type. When tinc is in its default routing mode, it can handle IPv4 -and IPv6 packets. Depending on the Subnet lines, it will send the -packets off to their destination IP address. In the 'switch' and 'hub' +its type. When tinc is in it's default routing mode, it can handle IPv4 +and IPv6 packets. Depending on the Subnet lines, it will send the +packets off to their destination IP address. In the `switch' and `hub' mode, tinc will use broadcasts and MAC address discovery to deduce the destination of the packets. Since the latter modes only depend on the link layer information, any protocol that runs over Ethernet is -supported (for instance IPX and Appletalk). However, only 'tap' style +supported (for instance IPX and Appletalk). However, only `tap' style devices provide this information. After the destination has been determined, the packet will be compressed (optionally), a sequence number will be added to the packet, -the packet will then be encrypted and a message authentication code will -be appended. +the packet will then be encrypted and a message authentication code +will be appended. When that is done, time has come to actually transport the packet to the destination computer. We do this by sending the packet over an UDP -connection to the destination host. This is called _encapsulating_, the -VPN packet (though now encrypted) is encapsulated in another IP +connection to the destination host. This is called _encapsulating_, +the VPN packet (though now encrypted) is encapsulated in another IP datagram. When the destination receives this packet, the same thing happens, -only in reverse. So it checks the message authentication code, decrypts -the contents of the UDP datagram, checks the sequence number and writes -the decrypted information to its own virtual network device. +only in reverse. So it checks the message authentication code, +decrypts the contents of the UDP datagram, checks the sequence number +and writes the decrypted information to its own virtual network device. - If the virtual network device is a 'tun' device (a point-to-point + If the virtual network device is a `tun' device (a point-to-point tunnel), there is no problem for the kernel to accept a packet. -However, if it is a 'tap' device (this is the only available type on +However, if it is a `tap' device (this is the only available type on FreeBSD), the destination MAC address must match that of the virtual -network interface. If tinc is in its default routing mode, ARP does not -work, so the correct destination MAC can not be known by the sending -host. Tinc solves this by letting the receiving end detect the MAC -address of its own virtual network interface and overwriting the +network interface. If tinc is in it's default routing mode, ARP does +not work, so the correct destination MAC can not be known by the +sending host. Tinc solves this by letting the receiving end detect the +MAC address of its own virtual network interface and overwriting the destination MAC address of the received packet. In switch or hub modes ARP does work so the sender already knows the correct destination MAC address. In those modes every interface should have a unique MAC address, so make sure they are not the same. Because switch and hub modes rely on MAC addresses to function correctly, these -modes cannot be used on the following operating systems which don't have -a 'tap' style virtual network device: NetBSD, Darwin and Solaris. +modes cannot be used on the following operating systems which don't +have a `tap' style virtual network device: OpenBSD, NetBSD, Darwin and +Solaris.  File: tinc.info, Node: The meta-connection, Prev: The UDP tunnel, Up: The connection -6.1.2 The meta-connection +7.1.2 The meta-connection ------------------------- Having only a UDP connection available is not enough. Though suitable @@ -1954,8 +2013,8 @@ information, such as routing and session key information to somebody. TCP is a better alternative, because it already contains protection against information being lost, unlike UDP. - So we establish two connections. One for the encrypted VPN data, and -one for other information, the meta-data. Hence, we call the second + So we establish two connections. One for the encrypted VPN data, +and one for other information, the meta-data. Hence, we call the second connection the meta-connection. We can now be sure that the meta-information doesn't get lost on the way to another computer. @@ -1976,11 +2035,12 @@ re-sending packets.  File: tinc.info, Node: The meta-protocol, Next: Security, Prev: The connection, Up: Technical information -6.2 The meta-protocol +7.2 The meta-protocol ===================== -The meta protocol is used to tie all tinc daemons together, and exchange -information about which tinc daemon serves which virtual subnet. +The meta protocol is used to tie all tinc daemons together, and +exchange information about which tinc daemon serves which virtual +subnet. The meta protocol consists of requests that can be sent to the other side. Each request has a unique number and several parameters. All @@ -1990,10 +2050,10 @@ daemon started with the -bypass-security option and to read and write requests by hand, provided that one understands the numeric codes sent. The authentication scheme is described in *note Authentication -protocol::. After a successful authentication, the server and the +protocol::. After a successful authentication, the server and the client will exchange all the information about other tinc daemons and -subnets they know of, so that both sides (and all the other tinc daemons -behind them) have their information synchronised. +subnets they know of, so that both sides (and all the other tinc +daemons behind them) have their information synchronised. message ------------------------------------------------------------------ @@ -2012,11 +2072,11 @@ behind them) have their information synchronised. ------------------------------------------------------------------ The ADD_EDGE messages are to inform other tinc daemons that a -connection between two nodes exist. The address of the destination node +connection between two nodes exist. The address of the destination node is available so that VPN packets can be sent directly to that node. The ADD_SUBNET messages inform other tinc daemons that certain -subnets belong to certain nodes. tinc will use it to determine to which +subnets belong to certain nodes. tinc will use it to determine to which node a VPN packet has to be sent. message @@ -2054,12 +2114,12 @@ unreachable if there isn't any. +--> daemon that has changed it's packet key ------------------------------------------------------------------ - The keys used to encrypt VPN packets are not sent out directly. This -is because it would generate a lot of traffic on VPNs with many daemons, -and chances are that not every tinc daemon will ever send a packet to -every other daemon. Instead, if a daemon needs a key it sends a request -for it via the meta connection of the nearest hop in the direction of -the destination. + The keys used to encrypt VPN packets are not sent out directly. This +is because it would generate a lot of traffic on VPNs with many +daemons, and chances are that not every tinc daemon will ever send a +packet to every other daemon. Instead, if a daemon needs a key it sends +a request for it via the meta connection of the nearest hop in the +direction of the destination. daemon message ------------------------------------------------------------------ @@ -2067,11 +2127,11 @@ the destination. dest. PONG ------------------------------------------------------------------ - There is also a mechanism to check if hosts are still alive. Since + There is also a mechanism to check if hosts are still alive. Since network failures or a crash can cause a daemon to be killed without properly shutting down the TCP connection, this is necessary to keep an -up to date connection list. PINGs are sent at regular intervals, except -when there is also some other traffic. A little bit of salt (random +up to date connection list. PINGs are sent at regular intervals, except +when there is also some other traffic. A little bit of salt (random data) is added with each PING and PONG message, to make sure that long sequences of PING/PONG messages without any other traffic won't result in known plaintext. @@ -2081,13 +2141,13 @@ in known plaintext.  File: tinc.info, Node: Security, Prev: The meta-protocol, Up: Technical information -6.3 Security +7.3 Security ============ Tinc got its name from "TINC," short for _There Is No Cabal_; the alleged Cabal was/is an organisation that was said to keep an eye on the -entire Internet. As this is exactly what you _don't_ want, we named the -tinc project after TINC. +entire Internet. As this is exactly what you _don't_ want, we named +the tinc project after TINC. But in order to be "immune" to eavesdropping, you'll have to encrypt your data. Because tinc is a _Secure_ VPN (SVPN) daemon, it does @@ -2095,11 +2155,10 @@ exactly that: encrypt. Tinc by default uses blowfish encryption with 128 bit keys in CBC mode, 32 bit sequence numbers and 4 byte long message authentication codes to make sure eavesdroppers cannot get and cannot change any information at all from the packets they can -intercept. The encryption algorithm and message authentication -algorithm can be changed in the configuration. The length of the -message authentication codes is also adjustable. The length of the key -for the encryption algorithm is always the default length used by -LibreSSL/OpenSSL. +intercept. The encryption algorithm and message authentication +algorithm can be changed in the configuration. The length of the message +authentication codes is also adjustable. The length of the key for the +encryption algorithm is always the default length used by OpenSSL. * Menu: @@ -2110,7 +2169,7 @@ LibreSSL/OpenSSL.  File: tinc.info, Node: Authentication protocol, Next: Encryption of network packets, Up: Security -6.3.1 Authentication protocol +7.3.1 Authentication protocol ----------------------------- A new scheme for authentication in tinc has been devised, which offers @@ -2164,54 +2223,54 @@ Explanation is below. client ACK 655 123 0 | | +-> options - | +----> estimated weight - +--------> listening port of client + | +----> estimated weight + +--------> listening port of client server ACK 655 321 0 | | +-> options - | +----> estimated weight - +--------> listening port of server + | +----> estimated weight + +--------> listening port of server -------------------------------------------------------------------------- This new scheme has several improvements, both in efficiency and security. - First of all, the server sends exactly the same kind of messages over -the wire as the client. The previous versions of tinc first -authenticated the client, and then the server. This scheme even allows + First of all, the server sends exactly the same kind of messages +over the wire as the client. The previous versions of tinc first +authenticated the client, and then the server. This scheme even allows both sides to send their messages simultaneously, there is no need to wait for the other to send something first. This means that any calculations that need to be done upon sending or receiving a message -can also be done in parallel. This is especially important when doing -RSA encryption/decryption. Given that these calculations are the main +can also be done in parallel. This is especially important when doing +RSA encryption/decryption. Given that these calculations are the main part of the CPU time spent for the authentication, speed is improved by a factor 2. - Second, only one RSA encrypted message is sent instead of two. This + Second, only one RSA encrypted message is sent instead of two. This reduces the amount of information attackers can see (and thus use for a -cryptographic attack). It also improves speed by a factor two, making +cryptographic attack). It also improves speed by a factor two, making the total speedup a factor 4. Third, and most important: The symmetric cipher keys are exchanged -first, the challenge is done afterwards. In the previous authentication +first, the challenge is done afterwards. In the previous authentication scheme, because a man-in-the-middle could pass the challenge/chal_reply phase (by just copying the messages between the two real tinc daemons), -but no information was exchanged that was really needed to read the rest -of the messages, the challenge/chal_reply phase was of no real use. The -man-in-the-middle was only stopped by the fact that only after the ACK -messages were encrypted with the symmetric cipher. Potentially, it -could even send it's own symmetric key to the server (if it knew the -server's public key) and read some of the metadata the server would send -it (it was impossible for the mitm to read actual network packets -though). The new scheme however prevents this. +but no information was exchanged that was really needed to read the +rest of the messages, the challenge/chal_reply phase was of no real +use. The man-in-the-middle was only stopped by the fact that only after +the ACK messages were encrypted with the symmetric cipher. Potentially, +it could even send it's own symmetric key to the server (if it knew the +server's public key) and read some of the metadata the server would +send it (it was impossible for the mitm to read actual network packets +though). The new scheme however prevents this. This new scheme makes sure that first of all, symmetric keys are -exchanged. The rest of the messages are then encrypted with the -symmetric cipher. Then, each side can only read received messages if -they have their private key. The challenge is there to let the other +exchanged. The rest of the messages are then encrypted with the +symmetric cipher. Then, each side can only read received messages if +they have their private key. The challenge is there to let the other side know that the private key is really known, because a challenge -reply can only be sent back if the challenge is decrypted correctly, and -that can only be done with knowledge of the private key. +reply can only be sent back if the challenge is decrypted correctly, +and that can only be done with knowledge of the private key. Fourth: the first thing that is sent via the symmetric cipher encrypted connection is a totally random string, so that there is no @@ -2221,14 +2280,14 @@ stream.  File: tinc.info, Node: Encryption of network packets, Next: Security issues, Prev: Authentication protocol, Up: Security -6.3.2 Encryption of network packets +7.3.2 Encryption of network packets ----------------------------------- A data packet can only be sent if the encryption key is known to both -parties, and the connection is activated. If the encryption key is not -known, a request is sent to the destination using the meta connection to -retrieve it. The packet is stored in a queue while waiting for the key -to arrive. +parties, and the connection is activated. If the encryption key is not +known, a request is sent to the destination using the meta connection +to retrieve it. The packet is stored in a queue while waiting for the +key to arrive. The UDP packet containing the network packet from the VPN has the following layout: @@ -2240,62 +2299,61 @@ following layout: Encrypted with symmetric cipher So, the entire VPN packet is encrypted using a symmetric cipher, -including a 32 bits sequence number that is added in front of the actual -VPN packet, to act as a unique IV for each packet and to prevent replay -attacks. A message authentication code is added to the UDP packet to -prevent alteration of packets. By default the first 4 bytes of the -digest are used for this, but this can be changed using the MACLength -configuration variable. +including a 32 bits sequence number that is added in front of the +actual VPN packet, to act as a unique IV for each packet and to prevent +replay attacks. A message authentication code is added to the UDP +packet to prevent alteration of packets. By default the first 4 bytes +of the digest are used for this, but this can be changed using the +MACLength configuration variable.  File: tinc.info, Node: Security issues, Prev: Encryption of network packets, Up: Security -6.3.3 Security issues +7.3.3 Security issues --------------------- In August 2000, we discovered the existence of a security hole in all -versions of tinc up to and including 1.0pre2. This had to do with the -way we exchanged keys. Since then, we have been working on a new -authentication scheme to make tinc as secure as possible. The current -version uses the LibreSSL or OpenSSL library and uses strong -authentication with RSA keys. +versions of tinc up to and including 1.0pre2. This had to do with the +way we exchanged keys. Since then, we have been working on a new +authentication scheme to make tinc as secure as possible. The current +version uses the OpenSSL library and uses strong authentication with +RSA keys. On the 29th of December 2001, Jerome Etienne posted a security -analysis of tinc 1.0pre4. Due to a lack of sequence numbers and a +analysis of tinc 1.0pre4. Due to a lack of sequence numbers and a message authentication code for each packet, an attacker could possibly -disrupt certain network services or launch a denial of service attack by -replaying intercepted packets. The current version adds sequence +disrupt certain network services or launch a denial of service attack +by replaying intercepted packets. The current version adds sequence numbers and message authentication codes to prevent such attacks. On the 15th of September 2003, Peter Gutmann posted a security -analysis of tinc 1.0.1. He argues that the 32 bit sequence number used +analysis of tinc 1.0.1. He argues that the 32 bit sequence number used by tinc is not a good IV, that tinc's default length of 4 bytes for the MAC is too short, and he doesn't like tinc's use of RSA during -authentication. We do not know of a security hole in this version of +authentication. We do not know of a security hole in this version of tinc, but tinc's security is not as strong as TLS or IPsec. We will address these issues in tinc 2.0. - Cryptography is a hard thing to get right. We cannot make any -guarantees. Time, review and feedback are the only things that can -prove the security of any cryptographic product. If you wish to review + Cryptography is a hard thing to get right. We cannot make any +guarantees. Time, review and feedback are the only things that can +prove the security of any cryptographic product. If you wish to review tinc or give us feedback, you are stronly encouraged to do so.  File: tinc.info, Node: Platform specific information, Next: About us, Prev: Technical information, Up: Top -7 Platform specific information +8 Platform specific information ******************************* * Menu: * Interface configuration:: * Routes:: -* Automatically starting tinc::  File: tinc.info, Node: Interface configuration, Next: Routes, Up: Platform specific information -7.1 Interface configuration +8.1 Interface configuration =========================== When configuring an interface, one normally assigns it an address and a @@ -2309,140 +2367,66 @@ that it encompasses the entire VPN. For IPv4 addresses: -Linux 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -Linux iproute2 'ip addr add' ADDRESS'/'PREFIXLENGTH 'dev' INTERFACE -FreeBSD 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -OpenBSD 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -NetBSD 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -Solaris 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -Darwin (Mac OS X) 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -Windows 'netsh interface ip set address' INTERFACE 'static' ADDRESS NETMASK +Linux `ifconfig' INTERFACE ADDRESS `netmask' NETMASK +Linux iproute2 `ip addr add' ADDRESS`/'PREFIXLENGTH `dev' INTERFACE +FreeBSD `ifconfig' INTERFACE ADDRESS `netmask' NETMASK +OpenBSD `ifconfig' INTERFACE ADDRESS `netmask' NETMASK +NetBSD `ifconfig' INTERFACE ADDRESS `netmask' NETMASK +Solaris `ifconfig' INTERFACE ADDRESS `netmask' NETMASK +Darwin (MacOS/X) `ifconfig' INTERFACE ADDRESS `netmask' NETMASK +Windows `netsh interface ip set address' INTERFACE `static' ADDRESS NETMASK For IPv6 addresses: -Linux 'ifconfig' INTERFACE 'add' ADDRESS'/'PREFIXLENGTH -FreeBSD 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH -OpenBSD 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH -NetBSD 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH -Solaris 'ifconfig' INTERFACE 'inet6 plumb up' - 'ifconfig' INTERFACE 'inet6 addif' ADDRESS ADDRESS -Darwin (Mac OS X) 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH -Windows 'netsh interface ipv6 add address' INTERFACE 'static' ADDRESS/PREFIXLENGTH - - On Linux, it is possible to create a persistent tun/tap interface -which will continue to exist even if tinc quit, although this is -normally not required. It can be useful to set up a tun/tap interface -owned by a non-root user, so tinc can be started without needing any -root privileges at all. - -Linux 'ip tuntap add dev' INTERFACE 'mode' TUN|TAP 'user' USERNAME +Linux `ifconfig' INTERFACE `add' ADDRESS`/'PREFIXLENGTH +FreeBSD `ifconfig' INTERFACE `inet6' ADDRESS `prefixlen' PREFIXLENGTH +OpenBSD `ifconfig' INTERFACE `inet6' ADDRESS `prefixlen' PREFIXLENGTH +NetBSD `ifconfig' INTERFACE `inet6' ADDRESS `prefixlen' PREFIXLENGTH +Solaris `ifconfig' INTERFACE `inet6 plumb up' + `ifconfig' INTERFACE `inet6 addif' ADDRESS ADDRESS +Darwin (MacOS/X) `ifconfig' INTERFACE `inet6' ADDRESS `prefixlen' PREFIXLENGTH +Windows `netsh interface ipv6 add address' INTERFACE `static' ADDRESS/PREFIXLENGTH  -File: tinc.info, Node: Routes, Next: Automatically starting tinc, Prev: Interface configuration, Up: Platform specific information +File: tinc.info, Node: Routes, Prev: Interface configuration, Up: Platform specific information -7.2 Routes +8.2 Routes ========== In some cases it might be necessary to add more routes to the virtual network interface. There are two ways to indicate which interface a packet should go to, one is to use the name of the interface itself, another way is to specify the (local) address that is assigned to that -interface (LOCAL_ADDRESS). The former way is unambiguous and therefore +interface (LOCAL_ADDRESS). The former way is unambiguous and therefore preferable, but not all platforms support this. Adding routes to IPv4 subnets: -Linux 'route add -net' NETWORK_ADDRESS 'netmask' NETMASK INTERFACE -Linux iproute2 'ip route add' NETWORK_ADDRESS'/'PREFIXLENGTH 'dev' INTERFACE -FreeBSD 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS -OpenBSD 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS -NetBSD 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS -Solaris 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS '-interface' -Darwin (Mac OS X) 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH '-interface' INTERFACE -Windows 'netsh routing ip add persistentroute' NETWORK_ADDRESS NETMASK INTERFACE - LOCAL_ADDRESS +Linux `route add -net' NETWORK_ADDRESS `netmask' NETMASK INTERFACE +Linux iproute2 `ip route add' NETWORK_ADDRESS`/'PREFIXLENGTH `dev' INTERFACE +FreeBSD `route add' NETWORK_ADDRESS`/'PREFIXLENGTH LOCAL_ADDRESS +OpenBSD `route add' NETWORK_ADDRESS`/'PREFIXLENGTH LOCAL_ADDRESS +NetBSD `route add' NETWORK_ADDRESS`/'PREFIXLENGTH LOCAL_ADDRESS +Solaris `route add' NETWORK_ADDRESS`/'PREFIXLENGTH LOCAL_ADDRESS `-interface' +Darwin (MacOS/X) `route add' NETWORK_ADDRESS`/'PREFIXLENGTH LOCAL_ADDRESS +Windows `netsh routing ip add persistentroute' NETWORK_ADDRESS NETMASK INTERFACE + LOCAL_ADDRESS Adding routes to IPv6 subnets: -Linux 'route add -A inet6' NETWORK_ADDRESS'/'PREFIXLENGTH INTERFACE -Linux iproute2 'ip route add' NETWORK_ADDRESS'/'PREFIXLENGTH 'dev' INTERFACE -FreeBSD 'route add -inet6' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS -OpenBSD 'route add -inet6' NETWORK_ADDRESS LOCAL_ADDRESS '-prefixlen' PREFIXLENGTH -NetBSD 'route add -inet6' NETWORK_ADDRESS LOCAL_ADDRESS '-prefixlen' PREFIXLENGTH -Solaris 'route add -inet6' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS '-interface' -Darwin (Mac OS X) 'route add -inet6' NETWORK_ADDRESS'/'PREFIXLENGTH '-interface' INTERFACE -Windows 'netsh interface ipv6 add route' NETWORK ADDRESS/PREFIXLENGTH INTERFACE - - -File: tinc.info, Node: Automatically starting tinc, Prev: Routes, Up: Platform specific information - -7.3 Automatically starting tinc -=============================== - -* Menu: - -* Linux:: -* Windows:: -* Other platforms:: - - -File: tinc.info, Node: Linux, Next: Windows, Up: Automatically starting tinc - -7.3.1 Linux ------------ - -There are many Linux distributions, and historically, many of them had -their own way of starting programs at boot time. Today, a number of -major Linux distributions have chosen to use systemd as their init -system. Tinc ships with systemd service files that allow you to start -and stop tinc using systemd. There are two service files: -'tinc.service' is used to globally enable or disable all tinc daemons -managed by systemd, and 'tinc@NETNAME.service' is used to enable or -disable specific tinc daemons. So if one has created a tinc network -with netname 'foo', then you have to run the following two commands to -ensure it is started at boot time: - - systemctl enable tinc - systemctl enable tinc@foo - - To start the tinc daemon immediately if it wasn't already running, -use the following command: - - systemctl start tinc@foo - - You can also use 'systemctl start tinc', this will start all tinc -daemons that are enabled. You can stop and disable tinc networks in the -same way. - - If your system is not using systemd, then you have to look up your -distribution's way of starting tinc at boot time. - - -File: tinc.info, Node: Windows, Next: Other platforms, Prev: Linux, Up: Automatically starting tinc - -7.3.2 Windows -------------- - -On Windows, if tinc is started without the '-D' or '--no-detach' option, -it will automatically register itself as a service that is started at -boot time. When tinc is stopped using the '-k' or '--kill', it will -also automatically unregister itself. Once tinc is registered as a -service, it is also possible to stop and start tinc using the Windows -Services Manager. - - -File: tinc.info, Node: Other platforms, Prev: Windows, Up: Automatically starting tinc - -7.3.3 Other platforms ---------------------- - -On platforms other than the ones mentioned in the earlier sections, you -have to look up your platform's way of starting programs at boot time. +Linux `route add -A inet6' NETWORK_ADDRESS`/'PREFIXLENGTH INTERFACE +Linux iproute2 `ip route add' NETWORK_ADDRESS`/'PREFIXLENGTH `dev' INTERFACE +FreeBSD `route add -inet6' NETWORK_ADDRESS`/'PREFIXLENGTH LOCAL_ADDRESS +OpenBSD `route add -inet6' NETWORK_ADDRESS LOCAL_ADDRESS `-prefixlen' PREFIXLENGTH +NetBSD `route add -inet6' NETWORK_ADDRESS LOCAL_ADDRESS `-prefixlen' PREFIXLENGTH +Solaris `route add -inet6' NETWORK_ADDRESS`/'PREFIXLENGTH LOCAL_ADDRESS `-interface' +Darwin (MacOS/X) ? +Windows `netsh interface ipv6 add route' NETWORK ADDRESS/PREFIXLENGTH INTERFACE  File: tinc.info, Node: About us, Next: Concept Index, Prev: Platform specific information, Up: Top -8 About us +9 About us ********** * Menu: @@ -2453,28 +2437,29 @@ File: tinc.info, Node: About us, Next: Concept Index, Prev: Platform specific  File: tinc.info, Node: Contact information, Next: Authors, Up: About us -8.1 Contact information +9.1 Contact information ======================= -Tinc's website is at , this server is located +Tinc's website is at `http://www.tinc-vpn.org/', this server is located in the Netherlands. We have an IRC channel on the FreeNode and OFTC IRC networks. -Connect to irc.freenode.net (https://freenode.net/) or irc.oftc.net -(https://www.oftc.net/) and join channel #tinc. +Connect to irc.freenode.net (http://www.freenode.net/) or irc.oftc.net +(http://www.oftc.net/) and join channel #tinc.  File: tinc.info, Node: Authors, Prev: Contact information, Up: About us -8.2 Authors +9.2 Authors =========== Ivo Timmermans (zarq) + Guus Sliepen (guus) () We have received a lot of valuable input from users. With their -help, tinc has become the flexible and robust tool that it is today. We -have composed a list of contributions, in the file called 'THANKS' in +help, tinc has become the flexible and robust tool that it is today. +We have composed a list of contributions, in the file called `THANKS' in the source distribution.  @@ -2488,13 +2473,13 @@ Concept Index * ACK: Authentication protocol. (line 10) +* ADD_EDGE: The meta-protocol. (line 23) +* ADD_SUBNET: The meta-protocol. (line 23) * Address: Host configuration variables. (line 6) * AddressFamily: Main configuration variables. (line 6) -* ADD_EDGE: The meta-protocol. (line 22) -* ADD_SUBNET: The meta-protocol. (line 22) -* ANS_KEY: The meta-protocol. (line 63) +* ANS_KEY: The meta-protocol. (line 64) * authentication: Authentication protocol. (line 6) * binary package: Building and installing tinc. @@ -2502,207 +2487,176 @@ Concept Index * BindToAddress: Main configuration variables. (line 12) * BindToInterface: Main configuration variables. - (line 25) -* Broadcast: Main configuration variables. - (line 33) + (line 19) * Cabal: Security. (line 6) -* CHALLENGE: Authentication protocol. - (line 10) * CHAL_REPLY: Authentication protocol. (line 10) +* CHALLENGE: Authentication protocol. + (line 10) * CIDR notation: Host configuration variables. - (line 93) + (line 92) * Cipher: Host configuration variables. - (line 14) + (line 12) * ClampMSS: Host configuration variables. - (line 20) + (line 18) * client: How connections work. (line 18) * command line: Runtime options. (line 9) * Compression: Host configuration variables. - (line 26) + (line 24) * connection: The connection. (line 6) * ConnectTo: Main configuration variables. - (line 53) + (line 27) * daemon: Running tinc. (line 11) * data-protocol: The meta-connection. (line 18) * debug level: Runtime options. (line 17) * debug levels: Debug levels. (line 6) -* DecrementTTL: Main configuration variables. - (line 64) -* DEL_EDGE: The meta-protocol. (line 46) -* DEL_SUBNET: The meta-protocol. (line 46) +* DEL_EDGE: The meta-protocol. (line 47) +* DEL_SUBNET: The meta-protocol. (line 47) +* DEVICE: Scripts. (line 55) * Device: Main configuration variables. - (line 73) -* DEVICE: Scripts. (line 64) + (line 38) * device files: Device files. (line 6) * DeviceType: Main configuration variables. - (line 79) + (line 45) * Digest: Host configuration variables. - (line 31) + (line 29) * DirectOnly: Main configuration variables. - (line 149) -* dummy: Main configuration variables. - (line 86) + (line 73) +* ECDSAPrivateKeyFile: Main configuration variables. + (line 80) * encapsulating: The UDP tunnel. (line 30) * encryption: Encryption of network packets. (line 6) -* environment variables: Scripts. (line 53) +* environment variables: Scripts. (line 43) * example: Example configuration. (line 6) -* exec: Main configuration variables. - (line 319) +* ExperimentalProtocol: Main configuration variables. + (line 84) * Forwarding: Main configuration variables. - (line 156) + (line 93) * frame type: The UDP tunnel. (line 6) * GraphDumpFile: Main configuration variables. - (line 176) + (line 113) * Hostnames: Main configuration variables. - (line 184) -* http: Main configuration variables. - (line 316) + (line 121) * hub: Main configuration variables. - (line 254) + (line 162) * ID: Authentication protocol. (line 10) -* IffOneQueue: Main configuration variables. - (line 195) * IndirectData: Host configuration variables. - (line 36) + (line 34) +* INTERFACE: Scripts. (line 58) * Interface: Main configuration variables. - (line 198) -* INTERFACE: Scripts. (line 67) + (line 131) * IRC: Contact information. (line 9) * key generation: Generating keypairs. (line 6) +* KEY_CHANGED: The meta-protocol. (line 64) * KeyExpire: Main configuration variables. - (line 206) -* KEY_CHANGED: The meta-protocol. (line 63) + (line 167) +* libevent: libevent. (line 6) * libraries: Libraries. (line 6) -* LibreSSL: LibreSSL/OpenSSL. (line 6) -* license: LibreSSL/OpenSSL. (line 38) -* LocalDiscovery: Main configuration variables. - (line 212) +* license: OpenSSL. (line 36) * lzo: lzo. (line 6) * MACExpire: Main configuration variables. - (line 223) + (line 173) * MACLength: Host configuration variables. - (line 44) -* MaxTimeout: Main configuration variables. - (line 228) + (line 42) * meta-protocol: The meta-connection. (line 18) * META_KEY: Authentication protocol. (line 10) * Mode: Main configuration variables. - (line 232) -* multicast: Main configuration variables. - (line 98) + (line 139) * multiple networks: Multiple networks. (line 6) +* NAME: Scripts. (line 52) * Name: Main configuration variables. - (line 259) -* NAME: Scripts. (line 61) -* netmask: Network interfaces. (line 33) + (line 178) +* netmask: Network interfaces. (line 34) +* NETNAME: Scripts. (line 49) * netname: Multiple networks. (line 6) -* NETNAME: Scripts. (line 58) * Network Administrators Guide: Configuration introduction. (line 15) -* NODE: Scripts. (line 71) -* OpenSSL: LibreSSL/OpenSSL. (line 6) +* NODE: Scripts. (line 62) +* OpenSSL: OpenSSL. (line 6) * options: Runtime options. (line 9) * PEM format: Host configuration variables. - (line 69) -* PING: The meta-protocol. (line 88) + (line 67) +* PING: The meta-protocol. (line 89) * PingInterval: Main configuration variables. - (line 270) + (line 183) * PingTimeout: Main configuration variables. - (line 274) + (line 187) * platforms: Supported platforms. (line 6) * PMTU: Host configuration variables. - (line 49) + (line 47) * PMTUDiscovery: Host configuration variables. - (line 52) -* PONG: The meta-protocol. (line 88) + (line 50) +* PONG: The meta-protocol. (line 89) * Port: Host configuration variables. - (line 57) + (line 55) * port numbers: Other files. (line 17) * PriorityInheritance: Main configuration variables. - (line 280) + (line 193) * private: Virtual Private Networks. (line 10) * PrivateKey: Main configuration variables. - (line 285) + (line 198) * PrivateKeyFile: Main configuration variables. - (line 291) + (line 204) * ProcessPriority: Main configuration variables. - (line 296) -* Proxy: Main configuration variables. - (line 301) + (line 212) * PublicKey: Host configuration variables. - (line 61) + (line 59) * PublicKeyFile: Host configuration variables. - (line 64) -* raw_socket: Main configuration variables. - (line 91) + (line 62) * release: Supported platforms. (line 14) -* REMOTEADDRESS: Scripts. (line 76) -* REMOTEPORT: Scripts. (line 79) +* REMOTEADDRESS: Scripts. (line 67) +* REMOTEPORT: Scripts. (line 70) * ReplayWindow: Main configuration variables. - (line 324) + (line 217) +* REQ_KEY: The meta-protocol. (line 64) * requirements: Libraries. (line 6) -* REQ_KEY: The meta-protocol. (line 63) * router: Main configuration variables. - (line 235) + (line 142) * runtime options: Runtime options. (line 9) * scalability: tinc. (line 19) * scripts: Scripts. (line 6) * server: How connections work. (line 18) * signals: Signals. (line 6) -* socks4: Main configuration variables. - (line 305) -* socks5: Main configuration variables. - (line 310) * StrictSubnets: Main configuration variables. - (line 335) + (line 228) +* SUBNET: Scripts. (line 74) * Subnet: Host configuration variables. - (line 76) -* SUBNET: Scripts. (line 83) -* Subnet weight: Host configuration variables. - (line 98) + (line 74) * SVPN: Security. (line 11) * switch: Main configuration variables. - (line 243) -* systemd: Linux. (line 6) + (line 151) * TCP: The meta-connection. (line 10) * TCPonly: Host configuration variables. - (line 105) -* tinc: Introduction. (line 6) + (line 104) * TINC: Security. (line 6) -* tinc-down: Scripts. (line 29) -* tinc-up: Scripts. (line 19) +* tinc: Introduction. (line 6) +* tinc-down: Scripts. (line 18) * tinc-up <1>: Network interfaces. (line 19) +* tinc-up: Scripts. (line 10) * tincd: tinc. (line 14) * traditional VPNs: tinc. (line 19) * tunifhead: Main configuration variables. - (line 133) + (line 62) * TunnelServer: Main configuration variables. - (line 342) + (line 233) * tunnohead: Main configuration variables. - (line 127) -* UDP: The UDP tunnel. (line 30) + (line 56) * UDP <1>: Encryption of network packets. (line 12) +* UDP: The UDP tunnel. (line 30) * UDPRcvBuf: Main configuration variables. - (line 349) + (line 240) * UDPSndBuf: Main configuration variables. - (line 354) -* UML: Main configuration variables. - (line 109) + (line 245) * Universal tun/tap: Configuration of Linux kernels. (line 6) -* utun: Main configuration variables. - (line 140) -* VDE: Main configuration variables. - (line 114) * virtual: Virtual Private Networks. (line 18) * virtual network device: The UDP tunnel. (line 6) @@ -2710,76 +2664,77 @@ Concept Index (line 6) * vpnd: tinc. (line 6) * website: Contact information. (line 6) -* WEIGHT: Scripts. (line 86) * zlib: zlib. (line 6)  Tag Table: -Node: Top806 -Node: Introduction1105 -Node: Virtual Private Networks1915 -Node: tinc3639 -Node: Supported platforms5166 -Node: Preparations5867 -Node: Configuring the kernel6123 -Node: Configuration of Linux kernels6533 -Node: Configuration of FreeBSD kernels7388 -Node: Configuration of OpenBSD kernels7853 -Node: Configuration of NetBSD kernels8210 -Node: Configuration of Solaris kernels8615 -Node: Configuration of Darwin (Mac OS X) kernels9278 -Node: Configuration of Windows10097 -Node: Libraries10637 -Node: LibreSSL/OpenSSL11046 -Node: zlib13588 -Node: lzo14617 -Node: Installation15600 -Node: Building and installing tinc16510 -Node: Darwin (Mac OS X) build environment17170 -Node: Cygwin (Windows) build environment17735 -Node: MinGW (Windows) build environment18324 -Node: System files18918 -Node: Device files19183 -Node: Other files19599 -Node: Configuration20212 -Node: Configuration introduction20523 -Node: Multiple networks21791 -Node: How connections work23217 -Node: Configuration files24439 -Node: Main configuration variables25933 -Node: Host configuration variables42189 -Node: Scripts47721 -Node: How to configure50987 -Node: Generating keypairs52245 -Node: Network interfaces52744 -Node: Example configuration54592 -Node: Running tinc59917 -Node: Runtime options60507 -Node: Signals64136 -Node: Debug levels65327 -Node: Solving problems66263 -Node: Error messages67815 -Node: Sending bug reports71824 -Node: Technical information72771 -Node: The connection73002 -Node: The UDP tunnel73314 -Node: The meta-connection76366 -Node: The meta-protocol77835 -Node: Security82852 -Node: Authentication protocol83994 -Node: Encryption of network packets89039 -Node: Security issues90415 -Node: Platform specific information92054 -Node: Interface configuration92314 -Node: Routes94610 -Node: Automatically starting tinc96660 -Node: Linux96883 -Node: Windows98104 -Node: Other platforms98609 -Node: About us98891 -Node: Contact information99066 -Node: Authors99469 -Node: Concept Index99874 +Node: Top811 +Node: Introduction1131 +Node: Virtual Private Networks1941 +Node: tinc3667 +Node: Supported platforms5194 +Node: Preparations5892 +Node: Configuring the kernel6148 +Node: Configuration of Linux kernels6557 +Node: Configuration of FreeBSD kernels7412 +Node: Configuration of OpenBSD kernels7802 +Node: Configuration of NetBSD kernels8410 +Node: Configuration of Solaris kernels8815 +Node: Configuration of Darwin (MacOS/X) kernels9476 +Node: Configuration of Windows10165 +Node: Libraries10679 +Node: OpenSSL11080 +Node: zlib13356 +Node: lzo14185 +Node: libevent14989 +Node: Installation15700 +Node: Building and installing tinc16715 +Node: Darwin (MacOS/X) build environment17374 +Node: Cygwin (Windows) build environment17942 +Node: MinGW (Windows) build environment18530 +Node: System files19054 +Node: Device files19319 +Node: Other files19735 +Node: Configuration20348 +Node: Configuration introduction20659 +Node: Multiple networks21932 +Node: How connections work23358 +Node: Configuration files24580 +Node: Main configuration variables25967 +Node: Host configuration variables37161 +Node: Scripts42445 +Node: How to configure45124 +Node: Generating keypairs46387 +Node: Network interfaces46899 +Node: Example configuration48747 +Node: Running tinc54083 +Node: Runtime options54668 +Node: Signals57028 +Node: Debug levels57878 +Node: Solving problems58814 +Node: Error messages60244 +Node: Sending bug reports64566 +Node: Controlling tinc65518 +Node: tincctl runtime options65881 +Node: tincctl commands66567 +Node: tincctl examples68653 +Node: tincctl top68947 +Node: Technical information70545 +Node: The connection70780 +Node: The UDP tunnel71092 +Node: The meta-connection74153 +Node: The meta-protocol75622 +Node: Security80631 +Node: Authentication protocol81761 +Node: Encryption of network packets86765 +Node: Security issues88138 +Node: Platform specific information89755 +Node: Interface configuration89983 +Node: Routes91882 +Node: About us93798 +Node: Contact information93973 +Node: Authors94377 +Node: Concept Index94782  End Tag Table diff --git a/doc/tinc.texi b/doc/tinc.texi index b1f5d9d..69e5a2b 100644 --- a/doc/tinc.texi +++ b/doc/tinc.texi @@ -15,7 +15,7 @@ This is the info manual for @value{PACKAGE} version @value{VERSION}, a Virtual Private Network daemon. -Copyright @copyright{} 1998-2018 Ivo Timmermans, +Copyright @copyright{} 1998-2011 Ivo Timmermans, Guus Sliepen and Wessel Dankers . @@ -39,7 +39,7 @@ permission notice identical to this one. @vskip 0pt plus 1filll This is the info manual for @value{PACKAGE} version @value{VERSION}, a Virtual Private Network daemon. -Copyright @copyright{} 1998-2018 Ivo Timmermans, +Copyright @copyright{} 1998-2011 Ivo Timmermans, Guus Sliepen and Wessel Dankers . @@ -65,6 +65,7 @@ permission notice identical to this one. * Installation:: * Configuration:: * Running tinc:: +* Controlling tinc:: * Technical information:: * Platform specific information:: * About us:: @@ -176,7 +177,7 @@ available too. @section Supported platforms @cindex platforms -Tinc has been verified to work under Linux, FreeBSD, OpenBSD, NetBSD, Mac OS X (Darwin), Solaris, and Windows (both natively and in a Cygwin environment), +Tinc has been verified to work under Linux, FreeBSD, OpenBSD, NetBSD, MacOS/X (Darwin), Solaris, and Windows (both natively and in a Cygwin environment), with various hardware architectures. These are some of the platforms that are supported by the universal tun/tap device driver or other virtual network device drivers. Without such a driver, tinc will most @@ -186,7 +187,7 @@ packets. @cindex release For an up to date list of supported platforms, please check the list on our website: -@uref{https://www.tinc-vpn.org/platforms/}. +@uref{http://www.tinc-vpn.org/platforms}. @c @c @@ -224,7 +225,7 @@ support tinc. * Configuration of OpenBSD kernels:: * Configuration of NetBSD kernels:: * Configuration of Solaris kernels:: -* Configuration of Darwin (Mac OS X) kernels:: +* Configuration of Darwin (MacOS/X) kernels:: * Configuration of Windows:: @end menu @@ -261,15 +262,19 @@ alias char-major-10-200 tun @subsection Configuration of FreeBSD kernels For FreeBSD version 4.1 and higher, tun and tap drivers are included in the default kernel configuration. -The tap driver can be loaded with @code{kldload if_tap}, or by adding @code{if_tap_load="YES"} to @file{/boot/loader.conf}. +Using tap devices is recommended. @c ================================================================== @node Configuration of OpenBSD kernels @subsection Configuration of OpenBSD kernels -Recent versions of OpenBSD come with both tun and tap devices enabled in the default kernel configuration. - +For OpenBSD version 2.9 and higher, +the tun driver is included in the default kernel configuration. +There is also a kernel patch from @uref{http://diehard.n-r-g.com/stuff/openbsd/} +which adds a tap device to OpenBSD which should work with tinc, +but with recent versions of OpenBSD, +a tun device can act as a tap device by setting the link0 option with ifconfig. @c ================================================================== @node Configuration of NetBSD kernels @@ -288,23 +293,24 @@ Tunneling IPv6 may not work on NetBSD's tun device. For Solaris 8 (SunOS 5.8) and higher, the tun driver may or may not be included in the default kernel configuration. If it isn't, the source can be downloaded from @uref{http://vtun.sourceforge.net/tun/}. -For x86 and sparc64 architectures, precompiled versions can be found at @uref{https://www.monkey.org/~dugsong/fragroute/}. +For x86 and sparc64 architectures, precompiled versions can be found at @uref{http://www.monkey.org/~dugsong/fragroute/}. If the @file{net/if_tun.h} header file is missing, install it from the source package. @c ================================================================== -@node Configuration of Darwin (Mac OS X) kernels -@subsection Configuration of Darwin (Mac OS X) kernels +@node Configuration of Darwin (MacOS/X) kernels +@subsection Configuration of Darwin (MacOS/X) kernels Tinc on Darwin relies on a tunnel driver for its data acquisition from the kernel. -OS X version 10.6.8 and later have a built-in tun driver called "utun". -Tinc also supports the driver from @uref{http://tuntaposx.sourceforge.net/}, -which supports both tun and tap style devices. +Tinc supports either the driver from @uref{http://tuntaposx.sourceforge.net/}, +which supports both tun and tap style devices, +and also the driver from from @uref{http://chrisp.de/en/projects/tunnel.html}. +The former driver is recommended. +The tunnel driver must be loaded before starting tinc with the following command: -By default, tinc expects the tuntaposx driver to be installed. -To use the utun driver, set add @code{Device = utunX} to @file{tinc.conf}, -where X is the desired number for the utun interface. -You can also omit the number, in which case the first free number will be chosen. +@example +kmodload tunnel +@end example @c ================================================================== @@ -312,7 +318,7 @@ You can also omit the number, in which case the first free number will be chosen @subsection Configuration of Windows You will need to install the latest TAP-Win32 driver from OpenVPN. -You can download it from @uref{https://openvpn.net/index.php/open-source/downloads.html}. +You can download it from @uref{http://openvpn.sourceforge.net}. Using the Network Connections control panel, configure the TAP-Win32 network interface in the same way as you would do from the tinc-up script, as explained in the rest of the documentation. @@ -324,51 +330,49 @@ as explained in the rest of the documentation. @cindex requirements @cindex libraries -Before you can configure or build tinc, you need to have the LibreSSL or OpenSSL, +Before you can configure or build tinc, you need to have the OpenSSL, zlib and lzo libraries installed on your system. If you try to configure tinc without having them installed, configure will give you an error message, and stop. @menu -* LibreSSL/OpenSSL:: +* OpenSSL:: * zlib:: * lzo:: +* libevent:: @end menu @c ================================================================== -@node LibreSSL/OpenSSL -@subsection LibreSSL/OpenSSL +@node OpenSSL +@subsection OpenSSL -@cindex LibreSSL @cindex OpenSSL For all cryptography-related functions, tinc uses the functions provided -by the LibreSSL or the OpenSSL library. +by the OpenSSL library. -If this library is not installed, you will get an error when configuring -tinc for build. Support for running tinc with other cryptographic libraries +If this library is not installed, you wil get an error when configuring +tinc for build. Support for running tinc without having OpenSSL installed @emph{may} be added in the future. You can use your operating system's package manager to install this if available. Make sure you install the development AND runtime versions of this package. -If your operating system comes neither with LibreSSL or OpenSSL, you have to -install one manually. It is recommended that you get the latest version of -LibreSSL from @url{http://www.libressl.org/}. Instructions on how to -configure, build and install this package are included within the package. -Please make sure you build development and runtime libraries (which is the +If you have to install OpenSSL manually, you can get the source code +from @url{http://www.openssl.org/}. Instructions on how to configure, +build and install this package are included within the package. Please +make sure you build development and runtime libraries (which is the default). -If you installed the LibreSSL or OpenSSL libraries from source, it may be necessary +If you installed the OpenSSL libraries from source, it may be necessary to let configure know where they are, by passing configure one of the ---with-openssl-* parameters. Note that you even have to use --with-openssl-* if you -are using LibreSSL. +--with-openssl-* parameters. @example ---with-openssl=DIR LibreSSL/OpenSSL library and headers prefix ---with-openssl-include=DIR LibreSSL/OpenSSL headers directory +--with-openssl=DIR OpenSSL library and headers prefix +--with-openssl-include=DIR OpenSSL headers directory (Default is OPENSSL_DIR/include) ---with-openssl-lib=DIR LibreSSL/OpenSSL library directory +--with-openssl-lib=DIR OpenSSL library directory (Default is OPENSSL_DIR/lib) @end example @@ -379,7 +383,7 @@ are using LibreSSL. The complete source code of tinc is covered by the GNU GPL version 2. Since the license under which OpenSSL is distributed is not directly compatible with the terms of the GNU GPL -@uref{https://www.openssl.org/support/faq.html#LEGAL2}, we +@uref{http://www.openssl.org/support/faq.html#LEGAL2}, we include an exemption to the GPL (see also the file COPYING.README) to allow everyone to create a statically or dynamically linked executable: @@ -395,8 +399,8 @@ we also present the following exemption: @quotation Hereby I grant a special exception to the tinc VPN project -(https://www.tinc-vpn.org/) to link the LZO library with the OpenSSL library -(https://www.openssl.org). +(http://www.tinc-vpn.org/) to link the LZO library with the OpenSSL library +(http://www.openssl.org). Markus F.X.J. Oberhumer @end quotation @@ -410,18 +414,16 @@ Markus F.X.J. Oberhumer For the optional compression of UDP packets, tinc uses the functions provided by the zlib library. -If this library is not installed, you will get an error when running the -configure script. You can either install the zlib library, or disable support -for zlib compression by using the "--disable-zlib" option when running the -configure script. Note that if you disable support for zlib, the resulting -binary will not work correctly on VPNs where zlib compression is used. +If this library is not installed, you wil get an error when configuring +tinc for build. Support for running tinc without having zlib +installed @emph{may} be added in the future. You can use your operating system's package manager to install this if available. Make sure you install the development AND runtime versions of this package. If you have to install zlib manually, you can get the source code -from @url{https://zlib.net/}. Instructions on how to configure, +from @url{http://www.gzip.org/zlib/}. Instructions on how to configure, build and install this package are included within the package. Please make sure you build development and runtime libraries (which is the default). @@ -432,20 +434,39 @@ default). @subsection lzo @cindex lzo -Another form of compression is offered using the LZO library. +Another form of compression is offered using the lzo library. -If this library is not installed, you will get an error when running the -configure script. You can either install the LZO library, or disable support -for LZO compression by using the "--disable-lzo" option when running the -configure script. Note that if you disable support for LZO, the resulting -binary will not work correctly on VPNs where LZO compression is used. +If this library is not installed, you wil get an error when configuring +tinc for build. Support for running tinc without having lzo +installed @emph{may} be added in the future. You can use your operating system's package manager to install this if available. Make sure you install the development AND runtime versions of this package. If you have to install lzo manually, you can get the source code -from @url{https://www.oberhumer.com/opensource/lzo/}. Instructions on how to configure, +from @url{http://www.oberhumer.com/opensource/lzo/}. Instructions on how to configure, +build and install this package are included within the package. Please +make sure you build development and runtime libraries (which is the +default). + + +@c ================================================================== +@node libevent +@subsection libevent + +@cindex libevent +For the main event loop, tinc uses the libevent library. + +If this library is not installed, you wil get an error when configuring +tinc for build. + +You can use your operating system's package manager to install this if +available. Make sure you install the development AND runtime versions +of this package. + +If you have to install libevent manually, you can get the source code +from @url{http://monkey.org/~provos/libevent/}. Instructions on how to configure, build and install this package are included within the package. Please make sure you build development and runtime libraries (which is the default). @@ -471,7 +492,9 @@ system startup scripts and sample configurations. If you cannot use one of the precompiled packages, or you want to compile tinc for yourself, you can use the source. The source is distributed under the GNU General Public License (GPL). Download the source from the -@uref{https://www.tinc-vpn.org/download/, download page}. +@uref{http://www.tinc-vpn.org/download, download page}, which has +the checksums of these files listed; you may wish to check these with +md5sum before continuing. Tinc comes in a convenient autoconf/automake package, which you can just treat the same as any other package. Which is just untar it, type @@ -498,28 +521,29 @@ you can use the package management tools of that distribution to install tinc. The documentation that comes along with your distribution will tell you how to do that. @menu -* Darwin (Mac OS X) build environment:: +* Darwin (MacOS/X) build environment:: * Cygwin (Windows) build environment:: * MinGW (Windows) build environment:: @end menu @c ================================================================== -@node Darwin (Mac OS X) build environment -@subsection Darwin (Mac OS X) build environment +@node Darwin (MacOS/X) build environment +@subsection Darwin (MacOS/X) build environment -In order to build tinc on Darwin, you need to install Xcode from @uref{https://developer.apple.com/xcode/}. -It might also help to install a recent version of Fink from @uref{http://www.finkproject.org/}. +In order to build tinc on Darwin, you need to install the MacOS/X Developer Tools +from @uref{http://developer.apple.com/tools/macosxtools.html} and +a recent version of Fink from @uref{http://fink.sourceforge.net/}. -You need to download and install LibreSSL (or OpenSSL) and LZO, -either directly from their websites (see @ref{Libraries}) or using Fink. +After installation use fink to download and install the following packages: +autoconf25, automake, dlcompat, m4, openssl, zlib and lzo. @c ================================================================== @node Cygwin (Windows) build environment @subsection Cygwin (Windows) build environment If Cygwin hasn't already been installed, install it directly from -@uref{https://www.cygwin.com/}. +@uref{http://www.cygwin.com/}. When tinc is compiled in a Cygwin environment, it can only be run in this environment, but all programs, including those started outside the Cygwin environment, will be able to use the VPN. @@ -530,7 +554,6 @@ It will also support all features. @subsection MinGW (Windows) build environment You will need to install the MinGW environment from @uref{http://www.mingw.org}. -You also need to download and install LibreSSL (or OpenSSL) and LZO. When tinc is compiled using MinGW it runs natively under Windows, it is not necessary to keep MinGW installed. @@ -638,7 +661,7 @@ you will not find the answers in this documentation. Make sure you have an adequate understanding of networks in general. @cindex Network Administrators Guide A good resource on networking is the -@uref{http://www.tldp.org/LDP/nag2/, Linux Network Administrators Guide}. +@uref{http://www.linuxdoc.org/LDP/nag2/, Linux Network Administrators Guide}. If you have everything clearly pictured in your mind, proceed in the following order: @@ -661,7 +684,7 @@ It is not required if you only run one tinc daemon, it doesn't even have to be the same on all the sites of your VPN, but it is recommended that you choose one anyway. -We will assume you use a netname throughout this document. +We will asume you use a netname throughout this document. This means that you call tincd with the -n argument, which will assign a netname to this daemon. @@ -689,7 +712,7 @@ reads in the configuration file tinc.conf. If it sees one or more `ConnectTo' values pointing to other tinc daemons in that file, it will try to connect to those other daemons. Whether this succeeds or not and whether `ConnectTo' is specified or not, -tinc will listen for incoming connection from other daemons. +tinc will listen for incoming connection from other deamons. If you did specify a `ConnectTo' value and the other side is not responding, tinc will keep retrying. This means that once started, tinc will stay running until you tell it to stop, @@ -713,9 +736,6 @@ The actual configuration of the daemon is done in the file @file{@value{sysconfdir}/tinc/@var{netname}/tinc.conf} and at least one other file in the directory @file{@value{sysconfdir}/tinc/@var{netname}/hosts/}. -An optional directory @file{@value{sysconfdir}/tinc/@var{netname}/conf.d} can be added from which -any .conf file will be read. - These file consists of comments (lines started with a #) or assignments in the form of @@ -759,15 +779,10 @@ If any is selected, then depending on the operating system both IPv4 and IPv6 or just IPv6 listening sockets will be created. @cindex BindToAddress -@item BindToAddress = <@var{address}> [<@var{port}>] [experimental] +@item BindToAddress = <@var{address}> [experimental] If your computer has more than one IPv4 or IPv6 address, tinc will by default listen on all of them for incoming connections. -Multiple BindToAddress variables may be specified, -in which case listening sockets for each specified address are made. - -If no @var{port} is specified, the socket will be bound to the port specified by the Port option, -or to port 655 if neither is given. -To only bind to a specific port but not to a specific address, use "*" for the @var{address}. +It is possible to bind only to a single address with this variable. This option may not work on all platforms. @@ -780,25 +795,6 @@ variable. This option may not work on all platforms. -@cindex Broadcast -@item Broadcast = (mst) [experimental] -This option selects the way broadcast packets are sent to other daemons. -@emph{NOTE: all nodes in a VPN must use the same Broadcast mode, otherwise routing loops can form.} - -@table @asis -@item no -Broadcast packets are never sent to other nodes. - -@item mst -Broadcast packets are sent and forwarded via the VPN's Minimum Spanning Tree. -This ensures broadcast packets reach all nodes. - -@item direct -Broadcast packets are sent directly to all nodes that can be reached directly. -Broadcast packets received from other nodes are never forwarded. -If the IndirectData option is also set, broadcast packets will only be sent to nodes which we have a meta connection to. -@end table - @cindex ConnectTo @item ConnectTo = <@var{name}> Specifies which other tinc daemon to connect to on startup. @@ -811,96 +807,42 @@ If you don't specify a host with ConnectTo, tinc won't try to connect to other daemons at all, and will instead just listen for incoming connections. -@cindex DecrementTTL -@item DecrementTTL = (no) [experimental] -When enabled, tinc will decrement the Time To Live field in IPv4 packets, or the Hop Limit field in IPv6 packets, -before forwarding a received packet to the virtual network device or to another node, -and will drop packets that have a TTL value of zero, -in which case it will send an ICMP Time Exceeded packet back. - -Do not use this option if you use switch mode and want to use IPv6. - @cindex Device @item Device = <@var{device}> (@file{/dev/tap0}, @file{/dev/net/tun} or other depending on platform) The virtual network device to use. Tinc will automatically detect what kind of device it is. +Note that you can only use one device per daemon. Under Windows, use @var{Interface} instead of @var{Device}. Note that you can only use one device per daemon. See also @ref{Device files}. @cindex DeviceType -@item DeviceType = <@var{type}> (platform dependent) +@item DeviceType = (only supported on BSD platforms) The type of the virtual network device. -Tinc will normally automatically select the right type of tun/tap interface, and this option should not be used. -However, this option can be used to select one of the special interface types, if support for them is compiled in. +Tinc will normally automatically select the right type, and this option should not be used. +However, in case tinc does not seem to correctly interpret packets received from the virtual network device, +using this option might help. @table @asis -@cindex dummy -@item dummy -Use a dummy interface. -No packets are ever read or written to a virtual network device. -Useful for testing, or when setting up a node that only forwards packets for other nodes. - -@cindex raw_socket -@item raw_socket -Open a raw socket, and bind it to a pre-existing -@var{Interface} (eth0 by default). -All packets are read from this interface. -Packets received for the local node are written to the raw socket. -However, at least on Linux, the operating system does not process IP packets destined for the local host. - -@cindex multicast -@item multicast -Open a multicast UDP socket and bind it to the address and port (separated by spaces) and optionally a TTL value specified using @var{Device}. -Packets are read from and written to this multicast socket. -This can be used to connect to UML, QEMU or KVM instances listening on the same multicast address. -Do NOT connect multiple tinc daemons to the same multicast address, this will very likely cause routing loops. -Also note that this can cause decrypted VPN packets to be sent out on a real network if misconfigured. - -@cindex UML -@item uml (not compiled in by default) -Create a UNIX socket with the filename specified by -@var{Device}, or @file{@value{runstatedir}/@var{netname}.umlsocket} -if not specified. -Tinc will wait for a User Mode Linux instance to connect to this socket. - -@cindex VDE -@item vde (not compiled in by default) -Uses the libvdeplug library to connect to a Virtual Distributed Ethernet switch, -using the UNIX socket specified by -@var{Device}, or @file{@value{runstatedir}/vde.ctl} -if not specified. -@end table - -Also, in case tinc does not seem to correctly interpret packets received from the virtual network device, -it can be used to change the way packets are interpreted: - -@table @asis -@item tun (BSD and Linux) +@item tun Set type to tun. Depending on the platform, this can either be with or without an address family header (see below). @cindex tunnohead -@item tunnohead (BSD) +@item tunnohead Set type to tun without an address family header. Tinc will expect packets read from the virtual network device to start with an IP header. On some platforms IPv6 packets cannot be read from or written to the device in this mode. @cindex tunifhead -@item tunifhead (BSD) +@item tunifhead Set type to tun with an address family header. Tinc will expect packets read from the virtual network device to start with a four byte header containing the address family, followed by an IP header. This mode should support both IPv4 and IPv6 packets. -@cindex utun -@item utun (OS X) -Set type to utun. -This is only supported on OS X version 10.6.8 and higher, but doesn't require the tuntaposx module. -This mode should support both IPv4 and IPv6 packets. - -@item tap (BSD and Linux) +@item tap Set type to tap. Tinc will expect packets read from the virtual network device to start with an Ethernet header. @@ -913,6 +855,21 @@ but which would have to be forwarded by an intermediate node, are dropped instea When combined with the IndirectData option, packets for nodes for which we do not have a meta connection with are also dropped. +@cindex ECDSAPrivateKeyFile +@item ECDSAPrivateKeyFile = <@var{path}> (@file{@value{sysconfdir}/tinc/@var{netname}/ecdsa_key.priv}) +The file in which the private ECDSA key of this tinc daemon resides. +This is only used if ExperimentalProtocol is enabled. + +@cindex ExperimentalProtocol +@item ExperimentalProtocol = (no) [experimental] +When this option is enabled, experimental protocol enhancements will be used. +Ephemeral ECDH will be used for key exchanges, +and ECDSA will be used instead of RSA for authentication. +When enabled, an ECDSA key must have been generated before with +@samp{tincctl generate-ecdsa-keys}. +The experimental protocol may change at any time, +and there is no guarantee that tinc will run stable when it is used. + @cindex Forwarding @item Forwarding = (internal) [experimental] This option selects the way indirect packets are forwarded. @@ -947,15 +904,11 @@ that is executed, the graph is then sent to stdin. @item Hostnames = (no) This option selects whether IP addresses (both real and on the VPN) should be resolved. Since DNS lookups are blocking, it might affect -tinc's efficiency, even stopping the daemon for a few seconds every time +tinc's efficiency, even stopping the daemon for a few seconds everytime it does a lookup if your DNS server is not responding. This does not affect resolving hostnames to IP addresses from the -configuration file, but whether hostnames should be resolved while logging. - -@cindex IffOneQueue -@item IffOneQueue = (no) [experimental] -(Linux only) Set IFF_ONE_QUEUE flag on TUN/TAP devices. +configuration file. @cindex Interface @item Interface = <@var{interface}> @@ -964,32 +917,6 @@ Depending on the operating system and the type of device this may or may not act Under Windows, this variable is used to select which network interface will be used. If you specified a Device, this variable is almost always already correctly set. -@cindex KeyExpire -@item KeyExpire = <@var{seconds}> (3600) -This option controls the time the encryption keys used to encrypt the data -are valid. It is common practice to change keys at regular intervals to -make it even harder for crackers, even though it is thought to be nearly -impossible to crack a single key. - -@cindex LocalDiscovery -@item LocalDiscovery = (no) [experimental] -When enabled, tinc will try to detect peers that are on the same local network. -This will allow direct communication using LAN addresses, even if both peers are behind a NAT -and they only ConnectTo a third node outside the NAT, -which normally would prevent the peers from learning each other's LAN address. - -Currently, local discovery is implemented by sending broadcast packets to the LAN during path MTU discovery. -This feature may not work in all possible situations. - -@cindex MACExpire -@item MACExpire = <@var{seconds}> (600) -This option controls the amount of time MAC addresses are kept before they are removed. -This only has effect when Mode is set to "switch". - -@cindex MaxTimeout -@item MaxTimeout = <@var{seconds}> (900) -This is the maximum delay before trying to reconnect to other tinc daemons. - @cindex Mode @item Mode = (router) This option selects the way packets are routed to other daemons. @@ -1019,15 +946,22 @@ every packet will be broadcast to the other daemons while no routing table is managed. @end table +@cindex KeyExpire +@item KeyExpire = <@var{seconds}> (3600) +This option controls the time the encryption keys used to encrypt the data +are valid. It is common practice to change keys at regular intervals to +make it even harder for crackers, even though it is thought to be nearly +impossible to crack a single key. + +@cindex MACExpire +@item MACExpire = <@var{seconds}> (600) +This option controls the amount of time MAC addresses are kept before they are removed. +This only has effect when Mode is set to "switch". + @cindex Name @item Name = <@var{name}> [required] This is a symbolic name for this connection. -The name must consist only of alphanumeric and underscore characters (a-z, A-Z, 0-9 and _). - -If Name starts with a $, then the contents of the environment variable that follows will be used. -In that case, invalid characters will be converted to underscores. -If Name is $HOST, but no such environment variable exist, -the hostname will be read using the gethostname() system call. +The name should consist only of alfanumeric and underscore characters (a-z, A-Z, 0-9 and _). @cindex PingInterval @item PingInterval = <@var{seconds}> (60) @@ -1049,46 +983,23 @@ will be inherited by the UDP packets that are sent out. @item PrivateKey = <@var{key}> [obsolete] This is the RSA private key for tinc. However, for safety reasons it is advised to store private keys of any kind in separate files. This prevents -accidental eavesdropping if you are editing the configuration file. +accidental eavesdropping if you are editting the configuration file. @cindex PrivateKeyFile @item PrivateKeyFile = <@var{path}> (@file{@value{sysconfdir}/tinc/@var{netname}/rsa_key.priv}) This is the full path name of the RSA private key file that was -generated by @samp{tincd --generate-keys}. It must be a full path, not a +generated by @samp{tincctl generate-keys}. It must be a full path, not a relative directory. +Note that there must be exactly one of PrivateKey +or PrivateKeyFile +specified in the configuration file. + @cindex ProcessPriority @item ProcessPriority = When this option is used the priority of the tincd process will be adjusted. Increasing the priority may help to reduce latency and packet loss on the VPN. -@cindex Proxy -@item Proxy = socks4 | socks5 | http | exec @var{...} [experimental] -Use a proxy when making outgoing connections. -The following proxy types are currently supported: - -@table @asis -@cindex socks4 -@item socks4 <@var{address}> <@var{port}> [<@var{username}>] -Connects to the proxy using the SOCKS version 4 protocol. -Optionally, a @var{username} can be supplied which will be passed on to the proxy server. - -@cindex socks5 -@item socks5 <@var{address}> <@var{port}> [<@var{username}> <@var{password}>] -Connect to the proxy using the SOCKS version 5 protocol. -If a @var{username} and @var{password} are given, basic username/password authentication will be used, -otherwise no authentication will be used. - -@cindex http -@item http <@var{address}> <@var{port}> -Connects to the proxy and sends a HTTP CONNECT request. - -@cindex exec -@item exec <@var{command}> -Executes the given command which should set up the outgoing connection. -The environment variables @env{NAME}, @env{NODE}, @env{REMOTEADDRES} and @env{REMOTEPORT} are available. -@end table - @cindex ReplayWindow @item ReplayWindow = (16) This is the size of the replay tracking window for each remote node, in bytes. @@ -1100,13 +1011,12 @@ reordering. Setting this to zero will disable replay tracking completely and pass all traffic, but leaves tinc vulnerable to replay-based attacks on your traffic. + @cindex StrictSubnets -@item StrictSubnets = (no) [experimental] +@item StrictSubnets (no) [experimental] When this option is enabled tinc will only use Subnet statements which are present in the host config files in the local @file{@value{sysconfdir}/tinc/@var{netname}/hosts/} directory. -Subnets learned via connections to other nodes and which are not -present in the local host config files are ignored. @cindex TunnelServer @item TunnelServer = (no) [experimental] @@ -1139,13 +1049,11 @@ This variable is only required if you want to connect to this host. It must resolve to the external IP address where the host can be reached, not the one that is internal to the VPN. If no port is specified, the default Port is used. -Multiple Address variables can be specified, in which case each address will be -tried until a working connection has been established. @cindex Cipher -@item Cipher = <@var{cipher}> (aes-256-cbc) +@item Cipher = <@var{cipher}> (blowfish) The symmetric cipher algorithm used to encrypt UDP packets. -Any cipher supported by LibreSSL or OpenSSL is recognized. +Any cipher supported by OpenSSL is recognized. Furthermore, specifying "none" will turn off packet encryption. It is best to use only those ciphers which support CBC mode. @@ -1162,9 +1070,9 @@ Possible values are 0 (off), 1 (fast zlib) and any integer up to 9 (best zlib), 10 (fast lzo) and 11 (best lzo). @cindex Digest -@item Digest = <@var{digest}> (sha256) +@item Digest = <@var{digest}> (sha1) The digest algorithm used to authenticate UDP packets. -Any digest supported by LibreSSL or OpenSSL is recognized. +Any digest supported by OpenSSL is recognized. Furthermore, specifying "none" will turn off packet authentication. @cindex IndirectData @@ -1202,7 +1110,7 @@ This is the RSA public key for this host. @cindex PublicKeyFile @item PublicKeyFile = <@var{path}> [obsolete] This is the full path name of the RSA public key file that was generated -by @samp{tincd --generate-keys}. It must be a full path, not a relative +by @samp{tincctl generate-keys}. It must be a full path, not a relative directory. @cindex PEM format @@ -1216,7 +1124,7 @@ connection with that host. @cindex Subnet @item Subnet = <@var{address}[/@var{prefixlength}[#@var{weight}]]> The subnet which this tinc daemon will serve. -Tinc tries to look up which other daemon it should send a packet to by searching the appropriate subnet. +Tinc tries to look up which other daemon it should send a packet to by searching the appropiate subnet. If the packet matches a subnet, it will be sent to the daemon who has this subnet in his host configuration file. Multiple subnet lines can be specified for each daemon. @@ -1224,20 +1132,20 @@ Multiple subnet lines can be specified for each daemon. Subnets can either be single MAC, IPv4 or IPv6 addresses, in which case a subnet consisting of only that single address is assumed, or they can be a IPv4 or IPv6 network address with a prefixlength. +Shorthand notations are not supported. For example, IPv4 subnets must be in a form like 192.168.1.0/24, where 192.168.1.0 is the network address and 24 is the number of bits set in the netmask. Note that subnets like 192.168.1.1/24 are invalid! Read a networking HOWTO/FAQ/guide if you don't understand this. -IPv6 subnets are notated like fec0:0:0:1::/64. +IPv6 subnets are notated like fec0:0:0:1:0:0:0:0/64. MAC addresses are notated like 0:1a:2b:3c:4d:5e. @cindex CIDR notation Prefixlength is the number of bits set to 1 in the netmask part; for example: netmask 255.255.255.0 would become /24, 255.255.252.0 becomes /22. This conforms to standard CIDR notation as described in -@uref{https://www.ietf.org/rfc/rfc1519.txt, RFC1519} +@uref{ftp://ftp.isi.edu/in-notes/rfc1519.txt, RFC1519} -@cindex Subnet weight A Subnet can be given a weight to indicate its priority over identical Subnets owned by different nodes. The default weight is 10. Lower values indicate higher priority. Packets will be sent to the node with the highest priority, @@ -1245,15 +1153,12 @@ unless that node is not reachable, in which case the node with the next highest priority will be tried, and so on. @cindex TCPonly -@item TCPonly = (no) [deprecated] +@item TCPonly = (no) If this variable is set to yes, then the packets are tunnelled over a TCP connection instead of a UDP connection. This is especially useful for those who want to run a tinc daemon from behind a masquerading firewall, or if UDP packet routing is disabled somehow. Setting this options also implicitly sets IndirectData. - -Since version 1.0.10, tinc will automatically detect whether communication via -UDP is possible or not. @end table @@ -1264,15 +1169,7 @@ UDP is possible or not. @cindex scripts Apart from reading the server and host configuration files, tinc can also run scripts at certain moments. -Below is a list of filenames of scripts and a description of when they are run. -A script is only run if it exists and if it is executable. - -Scripts are run synchronously; -this means that tinc will temporarily stop processing packets until the called script finishes executing. -This guarantees that scripts will execute in the exact same order as the events that trigger them. -If you need to run commands asynchronously, you have to ensure yourself that they are being run in the background. - -Under Windows (not Cygwin), the scripts must have the extension .bat. +Under Windows (not Cygwin), the scripts should have the extension .bat. @table @file @cindex tinc-up @@ -1282,7 +1179,6 @@ If it is present it will be executed right after the tinc daemon has been started and has connected to the virtual network device. It should be used to set up the corresponding network interface, but can also be used to start other things. - Under Windows you can use the Network Connections control panel instead of creating this script. @cindex tinc-down @@ -1302,11 +1198,11 @@ This script is started when any host becomes reachable. This script is started when any host becomes unreachable. @item @value{sysconfdir}/tinc/@var{netname}/subnet-up -This script is started when a subnet becomes reachable. +This script is started when a Subnet becomes reachable. The Subnet and the node it belongs to are passed in environment variables. @item @value{sysconfdir}/tinc/@var{netname}/subnet-down -This script is started when a subnet becomes unreachable. +This script is started when a Subnet becomes unreachable. @end table @cindex environment variables @@ -1351,10 +1247,6 @@ this is set to the port number it uses for communication with other tinc daemons @item SUBNET When a subnet becomes (un)reachable, this is set to the subnet. -@cindex WEIGHT -@item WEIGHT -When a subnet becomes (un)reachable, this is set to the subnet weight. - @end table @@ -1377,7 +1269,7 @@ add `ConnectTo' values. @subsubheading Step 2. Creating your host configuration file -If you added a line containing `Name = yourname' in the main configuration file, +If you added a line containing `Name = yourname' in the main configuarion file, you will need to create a host configuration file @file{@value{sysconfdir}/tinc/@var{netname}/hosts/yourname}. Adapt the following example to create a host configuration file: @@ -1401,7 +1293,7 @@ Now that you have already created the main configuration file and your host conf you can easily create a public/private keypair by entering the following command: @example -tincd -n @var{netname} -K +tincctl -n @var{netname} generate-keys @end example Tinc will generate a public and a private key and ask you where to put them. @@ -1630,7 +1522,7 @@ Address = 4.5.6.7 A, B, C and D all have generated a public/private keypair with the following command: @example -tincd -n company -K +tincctl -n company generate-keys @end example The private key is stored in @file{@value{sysconfdir}/tinc/company/rsa_key.priv}, @@ -1696,12 +1588,6 @@ This will also disable the automatic restart mechanism for fatal errors. Set debug level to @var{level}. The higher the debug level, the more gets logged. Everything goes via syslog. -@item -k, --kill[=@var{signal}] -Attempt to kill a running tincd (optionally with the specified @var{signal} instead of SIGTERM) and exit. -Use it in conjunction with the -n option to make sure you kill the right tinc daemon. -Under native Windows the optional argument is ignored, -the service will always be stopped and removed. - @item -n, --net=@var{netname} Use configuration for net @var{netname}. This will let tinc read all configuration files from @@ -1709,17 +1595,10 @@ This will let tinc read all configuration files from Specifying . for @var{netname} is the same as not specifying any @var{netname}. @xref{Multiple networks}. -@item -K, --generate-keys[=@var{bits}] -Generate public/private keypair of @var{bits} length. If @var{bits} is not specified, -2048 is the default. tinc will ask where you want to store the files, -but will default to the configuration directory (you can use the -c or -n option -in combination with -K). After that, tinc will quit. - -@item -o, --option=[@var{HOST}.]@var{KEY}=@var{VALUE} -Without specifying a @var{HOST}, this will set server configuration variable @var{KEY} to @var{VALUE}. -If specified as @var{HOST}.@var{KEY}=@var{VALUE}, -this will set the host configuration variable @var{KEY} of the host named @var{HOST} to @var{VALUE}. -This option can be used more than once to specify multiple configuration variables. +@item --pidfile=@var{filename} +Store a cookie in @var{filename} which allows tincctl to authenticate. +If unspecified, the default is +@file{@value{localstatedir}/run/tinc.@var{netname}.pid}. @item -L, --mlock Lock tinc into main memory. @@ -1729,9 +1608,6 @@ This will prevent sensitive data like shared private keys to be written to the s Write log entries to a file instead of to the system logging facility. If @var{file} is omitted, the default is @file{@value{localstatedir}/log/tinc.@var{netname}.log}. -@item --pidfile=@var{file} -Write PID to @var{file} instead of @file{@value{runstatedir}/tinc.@var{netname}.pid}. - @item --bypass-security Disables encryption and authentication. Only useful for debugging. @@ -1743,14 +1619,10 @@ located (@file{@value{sysconfdir}/tinc/@var{netname}/} as determined by The chroot is performed after all the initialization is done, after writing pid files and opening network sockets. -This option is best used in combination with the -U/--user option described below. +Note that this option alone does not do any good without -U/--user, below. -You will need to ensure the chroot environment contains all the files necessary -for tinc to run correctly. -Most importantly, for tinc to be able to resolve hostnames inside the chroot environment, -you must copy @file{/etc/resolv.conf} into the chroot directory. -If you want to be able to run scripts other than @file{tinc-up} in the chroot, -you must ensure the appropriate shell is also installed in the chroot, along with all its dependencies. +Note also that tinc can't run scripts anymore (such as tinc-down or host-up), +unless it's setup to be runnable inside chroot environment. @item -U, --user=@var{user} Switch to the given @var{user} after initialization, at the same time as @@ -1789,19 +1661,6 @@ New outgoing connections specified in @file{tinc.conf} will be made. If the --logfile option is used, this will also close and reopen the log file, useful when log rotation is used. -@item INT -Temporarily increases debug level to 5. -Send this signal again to revert to the original level. - -@item USR1 -Dumps the connection list to syslog. - -@item USR2 -Dumps virtual network device statistics, all known nodes, edges and subnets to syslog. - -@item WINCH -Purges all information remembered about unreachable nodes. - @end table @c ================================================================== @@ -1865,7 +1724,7 @@ Do you have a firewall or a NAT device (a masquerading firewall or perhaps an AD If so, check that it allows TCP and UDP traffic on port 655. If it masquerades and the host running tinc is behind it, make sure that it forwards TCP and UDP traffic to port 655 to the host running tinc. You can add @samp{TCPOnly = yes} to your host config file to force tinc to only use a single TCP connection, -this works through most firewalls and NATs. Since version 1.0.10, tinc will automatically fall back to TCP if direct communication via UDP is not possible. +this works through most firewalls and NATs. @end itemize @@ -1951,7 +1810,7 @@ Note that you will only see this message if you specified a debug level of 5 or higher! @item Chances are that a @samp{Subnet = ...} line in the host configuration file of this tinc daemon is wrong. Change it to a subnet that is accepted locally by another interface, -or if that is not the case, try changing the prefix length into /32. +or if that is not the case, try changing the prefix length into /32. @end itemize @item Node foo (1.2.3.4) is not reachable @@ -1964,6 +1823,8 @@ or if that is not the case, try changing the prefix length into /32. @itemize @item If you see this only sporadically, it is harmless and caused by a node sending packets using an old key. +@item If you see this often and another node is not reachable anymore, then a NAT (masquerading firewall) is changing the source address of UDP packets. +You can add @samp{TCPOnly = yes} to host configuration files to force all VPN traffic to go over a TCP connection. @end itemize @item Got bad/bogus/unauthorized REQUEST from foo (1.2.3.4 port 12345) @@ -1994,6 +1855,198 @@ Be sure to include the following information in your bugreport: @item The output of any command that fails to work as it should (like ping or traceroute). @end itemize +@c ================================================================== +@node Controlling tinc +@chapter Controlling tinc + +You can control and inspect a running tincd through the tincctl +command. A quick example: + +@example +tincctl -n @var{netname} reload +@end example + +@menu +* tincctl runtime options:: +* tincctl commands:: +* tincctl examples:: +* tincctl top:: +@end menu + + +@c ================================================================== +@node tincctl runtime options +@section tincctl runtime options + +@c from the manpage +@table @option +@item -c, --config=@var{path} +Read configuration options from the directory @var{path}. The default is +@file{@value{sysconfdir}/tinc/@var{netname}/}. + +@item -n, --net=@var{netname} +Use configuration for net @var{netname}. @xref{Multiple networks}. + +@item --pidfile=@var{filename} +Use the cookie from @var{filename} to authenticate with a running tinc daemon. +If unspecified, the default is +@file{@value{localstatedir}/run/tinc.@var{netname}.pid}. + +@item --help +Display a short reminder of runtime options and commands, then terminate. + +@item --version +Output version information and exit. + +@end table + + +@c ================================================================== +@node tincctl commands +@section tincctl commands + +@c from the manpage +@table @code + +@item start +Start @samp{tincd}. + +@item stop +Stop @samp{tincd}. + +@item restart +Restart @samp{tincd}. + +@item reload +Partially rereads configuration files. Connections to hosts whose host +config files are removed are closed. New outgoing connections specified +in @file{tinc.conf} will be made. + +@item pid +Shows the PID of the currently running @samp{tincd}. + +@item generate-keys [@var{bits}] +Generate public/private keypair of @var{bits} length. If @var{bits} is not specified, +1024 is the default. tinc will ask where you want to store the files, +but will default to the configuration directory (you can use the -c or -n +option). + +@item dump nodes +Dump a list of all known nodes in the VPN. + +@item dump edges +Dump a list of all known connections in the VPN. + +@item dump subnets +Dump a list of all known subnets in the VPN. + +@item dump connections +Dump a list of all meta connections with ourself. + +@item dump graph +Dump a graph of the VPN in dotty format. + +@item purge +Purges all information remembered about unreachable nodes. + +@item debug @var{level} +Sets debug level to @var{level}. + +@item retry +Forces tinc to try to connect to all uplinks immediately. +Usually tinc attempts to do this itself, +but increases the time it waits between the attempts each time it failed, +and if tinc didn't succeed to connect to an uplink the first time after it started, +it defaults to the maximum time of 15 minutes. + +@item disconnect @var{node} +Closes the meta connection with the given @var{node}. + +@item top +If tincctl is compiled with libcurses support, this will display live traffic statistics for all the known nodes, +similar to the UNIX top command. +See below for more information. + +@item pcap +Dump VPN traffic going through the local tinc node in pcap-savefile format to standard output, +from where it can be redirected to a file or piped through a program that can parse it directly, +such as tcpdump. + +@end table + +@c ================================================================== +@node tincctl examples +@section tincctl examples + +Examples of some commands: + +@example +tincctl -n vpn dump graph | circo -Txlib +tincctl -n vpn pcap | tcpdump -r - +tincctl -n vpn top +@end example + +@c ================================================================== +@node tincctl top +@section tincctl top + +The top command connects to a running tinc daemon and repeatedly queries its per-node traffic counters. +It displays a list of all the known nodes in the left-most column, +and the amount of bytes and packets read from and sent to each node in the other columns. +By default, the information is updated every second. +The behaviour of the top command can be changed using the following keys: + +@table @key + +@item s +Change the interval between updates. +After pressing the @key{s} key, enter the desired interval in seconds, followed by enter. +Fractional seconds are honored. +Intervals lower than 0.1 seconds are not allowed. + +@item c +Toggle between displaying current traffic rates (in packets and bytes per second) +and cummulative traffic (total packets and bytes since the tinc daemon started). + +@item n +Sort the list of nodes by name. + +@item i +Sort the list of nodes by incoming amount of bytes. + +@item I +Sort the list of nodes by incoming amount of packets. + +@item o +Sort the list of nodes by outgoing amount of bytes. + +@item O +Sort the list of nodes by outgoing amount of packets. + +@item t +Sort the list of nodes by sum of incoming and outgoing amount of bytes. + +@item T +Sort the list of nodes by sum of incoming and outgoing amount of packets. + +@item b +Show amount of traffic in bytes. + +@item k +Show amount of traffic in kilobytes. + +@item M +Show amount of traffic in megabytes. + +@item G +Show amount of traffic in gigabytes. + +@item q +Quit. + +@end table + + @c ================================================================== @node Technical information @chapter Technical information @@ -2035,7 +2088,7 @@ There are two possible types of virtual network devices: and `tap' style, which are Ethernet devices and handle complete Ethernet frames. So when tinc reads an Ethernet frame from the device, it determines its -type. When tinc is in its default routing mode, it can handle IPv4 and IPv6 +type. When tinc is in it's default routing mode, it can handle IPv4 and IPv6 packets. Depending on the Subnet lines, it will send the packets off to their destination IP address. In the `switch' and `hub' mode, tinc will use broadcasts and MAC address discovery to deduce the destination of the packets. @@ -2066,7 +2119,7 @@ If the virtual network device is a `tun' device (a point-to-point tunnel), there is no problem for the kernel to accept a packet. However, if it is a `tap' device (this is the only available type on FreeBSD), the destination MAC address must match that of the virtual network interface. -If tinc is in its default routing mode, ARP does not work, so the correct destination MAC +If tinc is in it's default routing mode, ARP does not work, so the correct destination MAC can not be known by the sending host. Tinc solves this by letting the receiving end detect the MAC address of its own virtual network interface and overwriting the destination MAC address of the received packet. @@ -2075,7 +2128,7 @@ In switch or hub modes ARP does work so the sender already knows the correct des In those modes every interface should have a unique MAC address, so make sure they are not the same. Because switch and hub modes rely on MAC addresses to function correctly, these modes cannot be used on the following operating systems which don't have a `tap' style virtual network device: -NetBSD, Darwin and Solaris. +OpenBSD, NetBSD, Darwin and Solaris. @c ================================================================== @@ -2190,7 +2243,7 @@ message ------------------------------------------------------------------ REQ_KEY origin destination | +--> name of the tinc daemon it wants the key from - +----------> name of the daemon that wants the key + +----------> name of the daemon that wants the key ANS_KEY origin destination 4ae0b0a82d6e0078 91 64 4 | | \______________/ | | +--> MAC length @@ -2254,7 +2307,7 @@ eavesdroppers cannot get and cannot change any information at all from the packets they can intercept. The encryption algorithm and message authentication algorithm can be changed in the configuration. The length of the message authentication codes is also adjustable. The length of the key for the -encryption algorithm is always the default length used by LibreSSL/OpenSSL. +encryption algorithm is always the default length used by OpenSSL. @menu * Authentication protocol:: @@ -2325,13 +2378,13 @@ their identity. Further information is exchanged. client ACK 655 123 0 | | +-> options - | +----> estimated weight - +--------> listening port of client + | +----> estimated weight + +--------> listening port of client server ACK 655 321 0 | | +-> options - | +----> estimated weight - +--------> listening port of server + | +----> estimated weight + +--------> listening port of server -------------------------------------------------------------------------- @end example @@ -2413,7 +2466,7 @@ the MACLength configuration variable. In August 2000, we discovered the existence of a security hole in all versions of tinc up to and including 1.0pre2. This had to do with the way we exchanged keys. Since then, we have been working on a new authentication scheme to make -tinc as secure as possible. The current version uses the LibreSSL or OpenSSL library and +tinc as secure as possible. The current version uses the OpenSSL library and uses strong authentication with RSA keys. On the 29th of December 2001, Jerome Etienne posted a security analysis of tinc @@ -2443,7 +2496,6 @@ tinc or give us feedback, you are stronly encouraged to do so. @menu * Interface configuration:: * Routes:: -* Automatically starting tinc:: @end menu @c ================================================================== @@ -2460,7 +2512,7 @@ netmask should be such that it encompasses the entire VPN. For IPv4 addresses: -@multitable {Darwin (Mac OS X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} +@multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} @item Linux @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask} @item Linux iproute2 @@ -2473,15 +2525,16 @@ For IPv4 addresses: @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask} @item Solaris @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask} -@item Darwin (Mac OS X) +@item Darwin (MacOS/X) @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask} @item Windows @tab @code{netsh interface ip set address} @var{interface} @code{static} @var{address} @var{netmask} @end multitable + For IPv6 addresses: -@multitable {Darwin (Mac OS X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} +@multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} @item Linux @tab @code{ifconfig} @var{interface} @code{add} @var{address}@code{/}@var{prefixlength} @item FreeBSD @@ -2494,21 +2547,12 @@ For IPv6 addresses: @tab @code{ifconfig} @var{interface} @code{inet6 plumb up} @item @tab @code{ifconfig} @var{interface} @code{inet6 addif} @var{address} @var{address} -@item Darwin (Mac OS X) +@item Darwin (MacOS/X) @tab @code{ifconfig} @var{interface} @code{inet6} @var{address} @code{prefixlen} @var{prefixlength} @item Windows @tab @code{netsh interface ipv6 add address} @var{interface} @code{static} @var{address}/@var{prefixlength} @end multitable -On Linux, it is possible to create a persistent tun/tap interface which will -continue to exist even if tinc quit, although this is normally not required. -It can be useful to set up a tun/tap interface owned by a non-root user, so -tinc can be started without needing any root privileges at all. - -@multitable {Darwin (Mac OS X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} -@item Linux -@tab @code{ip tuntap add dev} @var{interface} @code{mode} @var{tun|tap} @code{user} @var{username} -@end multitable @c ================================================================== @node Routes @@ -2523,7 +2567,7 @@ support this. Adding routes to IPv4 subnets: -@multitable {Darwin (Mac OS X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} +@multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} @item Linux @tab @code{route add -net} @var{network_address} @code{netmask} @var{netmask} @var{interface} @item Linux iproute2 @@ -2536,15 +2580,15 @@ Adding routes to IPv4 subnets: @tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address} @item Solaris @tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address} @code{-interface} -@item Darwin (Mac OS X) -@tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @code{-interface} @var{interface} +@item Darwin (MacOS/X) +@tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address} @item Windows @tab @code{netsh routing ip add persistentroute} @var{network_address} @var{netmask} @var{interface} @var{local_address} @end multitable Adding routes to IPv6 subnets: -@multitable {Darwin (Mac OS X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} +@multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} @item Linux @tab @code{route add -A inet6} @var{network_address}@code{/}@var{prefixlength} @var{interface} @item Linux iproute2 @@ -2557,72 +2601,12 @@ Adding routes to IPv6 subnets: @tab @code{route add -inet6} @var{network_address} @var{local_address} @code{-prefixlen} @var{prefixlength} @item Solaris @tab @code{route add -inet6} @var{network_address}@code{/}@var{prefixlength} @var{local_address} @code{-interface} -@item Darwin (Mac OS X) -@tab @code{route add -inet6} @var{network_address}@code{/}@var{prefixlength} @code{-interface} @var{interface} +@item Darwin (MacOS/X) +@tab ? @item Windows @tab @code{netsh interface ipv6 add route} @var{network address}/@var{prefixlength} @var{interface} @end multitable -@c ================================================================== -@node Automatically starting tinc -@section Automatically starting tinc - -@menu -* Linux:: -* Windows:: -* Other platforms:: -@end menu - -@c ================================================================== -@node Linux -@subsection Linux - -@cindex systemd -There are many Linux distributions, and historically, many of them had their -own way of starting programs at boot time. Today, a number of major Linux -distributions have chosen to use systemd as their init system. Tinc ships with -systemd service files that allow you to start and stop tinc using systemd. -There are two service files: @code{tinc.service} is used to globally enable or -disable all tinc daemons managed by systemd, and -@code{tinc@@@var{netname}.service} is used to enable or disable specific tinc -daemons. So if one has created a tinc network with netname @code{foo}, then -you have to run the following two commands to ensure it is started at boot -time: - -@example -systemctl enable tinc -systemctl enable tinc@@foo -@end example - -To start the tinc daemon immediately if it wasn't already running, use the -following command: - -@example -systemctl start tinc@@foo -@end example - -You can also use @samp{systemctl start tinc}, this will start all tinc daemons -that are enabled. You can stop and disable tinc networks in the same way. - -If your system is not using systemd, then you have to look up your -distribution's way of starting tinc at boot time. - -@c ================================================================== -@node Windows -@subsection Windows - -On Windows, if tinc is started without the @code{-D} or @code{--no-detach} -option, it will automatically register itself as a service that is started at -boot time. When tinc is stopped using the @code{-k} or @code{--kill}, it will -also automatically unregister itself. Once tinc is registered as a service, it -is also possible to stop and start tinc using the Windows Services Manager. - -@c ================================================================== -@node Other platforms -@subsection Other platforms - -On platforms other than the ones mentioned in the earlier sections, you have to -look up your platform's way of starting programs at boot time. @c ================================================================== @node About us @@ -2640,14 +2624,14 @@ look up your platform's way of starting programs at boot time. @section Contact information @cindex website -Tinc's website is at @url{https://www.tinc-vpn.org/}, +Tinc's website is at @url{http://www.tinc-vpn.org/}, this server is located in the Netherlands. @cindex IRC We have an IRC channel on the FreeNode and OFTC IRC networks. Connect to -@uref{https://freenode.net/, irc.freenode.net} +@uref{http://www.freenode.net/, irc.freenode.net} or -@uref{https://www.oftc.net/, irc.oftc.net} +@uref{http://www.oftc.net/, irc.oftc.net} and join channel #tinc. diff --git a/doc/tincctl.8.in b/doc/tincctl.8.in new file mode 100644 index 0000000..bbc8dba --- /dev/null +++ b/doc/tincctl.8.in @@ -0,0 +1,194 @@ +.Dd 2011-06-25 +.Dt TINCCTL 8 +.\" Manual page created by: +.\" Scott Lamb +.Sh NAME +.Nm tincctl +.Nd tinc VPN control +.Sh SYNOPSIS +.Nm +.Op Fl cn +.Op Fl -config Ns = Ns Ar DIR +.Op Fl -net Ns = Ns Ar NETNAME +.Op Fl -pidfile Ns = Ns Ar FILENAME +.Op Fl -help +.Op Fl -version +.Ar COMMAND +.Sh DESCRIPTION +This is the control program of tinc, a secure virtual private network (VPN) +project. +.Nm +communicates with +.Xr tincd 8 +to alter and inspect the running VPN's state. +.Sh OPTIONS +.Bl -tag -width indent +.It Fl n, -net Ns = Ns Ar NETNAME +Communicate with tincd(8) connected with +.Ar NETNAME . +.It Fl -pidfile Ns = Ns Ar FILENAME +Use the cookie from +.Ar FILENAME +to authenticate with a running tinc daemon. +If unspecified, the default is +.Pa @localstatedir@/run/tinc. Ns Ar NETNAME Ns Pa .pid. +.It Fl -help +Display short list of options. +.It Fl -version +Output version information and exit. +.El +.Sh COMMANDS +.zZ +.Bl -tag -width indent +.It start +Start +.Xr tincd 8 . +.It stop +Stop +.Xr tincd 8 . +.It restart +Restart +.Xr tincd 8 . +.It reload +Partially rereads configuration files. Connections to hosts whose host +config files are removed are closed. New outgoing connections specified +in +.Xr tinc.conf 5 +will be made. +.It pid +Shows the PID of the currently running +.Xr tincd 8 . +.It generate-keys Op bits +Generate both RSA and ECDSA keypairs (see below) and exit. +.It generate-ecdsa-keys +Generate public/private ECDSA keypair and exit. +.It generate-rsa-keys Op bits +Generate public/private RSA keypair and exit. +If +.Ar bits +is omitted, the default length will be 2048 bits. +When saving keys to existing files, tinc will not delete the old keys; +you have to remove them manually. +.It dump nodes +Dump a list of all known nodes in the VPN. +.It dump edges +Dump a list of all known connections in the VPN. +.It dump subnets +Dump a list of all known subnets in the VPN. +.It dump connections +Dump a list of all meta connections with ourself. +.It dump graph +Dump a graph of the VPN in +.Xr dotty 1 +format. +.It purge +Purges all information remembered about unreachable nodes. +.It debug Ar N +Sets debug level to +.Ar N . +.It retry +Forces +.Xr tincd 8 +to try to connect to all uplinks immediately. +Usually +.Xr tincd 8 +attempts to do this itself, +but increases the time it waits between the attempts each time it failed, +and if +.Xr tincd 8 +didn't succeed to connect to an uplink the first time after it started, +it defaults to the maximum time of 15 minutes. +.It disconnect Ar NODE +Closes the meta connection with the given +.Ar NODE . +.It top +If +.Nm +is compiled with libcurses support, this will display live traffic statistics +for all the known nodes, similar to the UNIX +.Xr top 1 +command. +See below for more information. +.It pcap +Dump VPN traffic going through the local tinc node in +.Xr pcap-savefile 5 +format to standard output, +from where it can be redirected to a file or piped through a program that can parse it directly, +such as +.Xr tcpdump 8 . +.El +.Sh EXAMPLES +Examples of some commands: +.Bd -literal -offset indent +tincctl -n vpn dump graph | circo -Txlib +tincctl -n vpn pcap | tcpdump -r - +tincctl -n vpn top +.Ed +.Sh TOP +The top command connects to a running tinc daemon and repeatedly queries its per-node traffic counters. +It displays a list of all the known nodes in the left-most column, +and the amount of bytes and packets read from and sent to each node in the other columns. +By default, the information is updated every second. +The behaviour of the top command can be changed using the following keys: +.Bl -tag +.It Ic s +Change the interval between updates. +After pressing the +.Ic s +key, enter the desired interval in seconds, followed by enter. +Fractional seconds are honored. +Intervals lower than 0.1 seconds are not allowed. +.It Ic c +Toggle between displaying current traffic rates (in packets and bytes per second) +and cummulative traffic (total packets and bytes since the tinc daemon started). +.It Ic n +Sort the list of nodes by name. +.It Ic i +Sort the list of nodes by incoming amount of bytes. +.It Ic I +Sort the list of nodes by incoming amount of packets. +.It Ic o +Sort the list of nodes by outgoing amount of bytes. +.It Ic O +Sort the list of nodes by outgoing amount of packets. +.It Ic t +Sort the list of nodes by sum of incoming and outgoing amount of bytes. +.It Ic T +Sort the list of nodes by sum of incoming and outgoing amount of packets. +.It Ic b +Show amount of traffic in bytes. +.It Ic k +Show amount of traffic in kilobytes. +.It Ic M +Show amount of traffic in megabytes. +.It Ic G +Show amount of traffic in gigabytes. +.It Ic q +Quit. +.El +.Sh BUGS +If you find any bugs, report them to tinc@tinc-vpn.org. +.Sh SEE ALSO +.Xr tincd 8 , +.Xr tinc.conf 5 , +.Xr dotty 1 , +.Xr pcap-savefile 7 , +.Xr tcpdump 8 , +.Xr top 1 , +.Pa http://www.tinc-vpn.org/ , +.Pa http://www.cabal.org/ . +.Pp +The full documentation for tinc is maintained as a Texinfo manual. +If the info and tinc programs are properly installed at your site, +the command +.Ic info tinc +should give you access to the complete manual. +.Pp +tinc comes with ABSOLUTELY NO WARRANTY. +This is free software, and you are welcome to redistribute it under certain conditions; +see the file COPYING for details. +.Sh AUTHORS +.An "Ivo Timmermans" +.An "Guus Sliepen" Aq guus@tinc-vpn.org +.Pp +And thanks to many others for their contributions to tinc! diff --git a/doc/tincd.8.in b/doc/tincd.8.in index bdccf9d..bb4aa48 100644 --- a/doc/tincd.8.in +++ b/doc/tincd.8.in @@ -1,4 +1,4 @@ -.Dd 2014-05-11 +.Dd 2011-06-25 .Dt TINCD 8 .\" Manual page created by: .\" Ivo Timmermans @@ -8,17 +8,13 @@ .Nd tinc VPN daemon .Sh SYNOPSIS .Nm -.Op Fl cdDkKnoLRU +.Op Fl cdDKnLRU .Op Fl -config Ns = Ns Ar DIR .Op Fl -no-detach .Op Fl -debug Ns Op = Ns Ar LEVEL -.Op Fl -kill Ns Op = Ns Ar SIGNAL .Op Fl -net Ns = Ns Ar NETNAME -.Op Fl -generate-keys Ns Op = Ns Ar BITS -.Op Fl -option Ns = Ns Ar [HOST.]KEY=VALUE .Op Fl -mlock .Op Fl -logfile Ns Op = Ns Ar FILE -.Op Fl -pidfile Ns = Ns Ar FILE .Op Fl -bypass-security .Op Fl -chroot .Op Fl -user Ns = Ns Ar USER @@ -54,14 +50,6 @@ If not mentioned otherwise, this will show log messages on the standard error ou Increase debug level or set it to .Ar LEVEL (see below). -.It Fl k, -kill Ns Op = Ns Ar SIGNAL -Attempt to kill a running -.Nm -(optionally with the specified -.Ar SIGNAL -instead of SIGTERM) and exit. -Under Windows (not Cygwin) the optional argument is ignored, -the service will always be stopped and removed. .It Fl n, -net Ns = Ns Ar NETNAME Connect to net .Ar NETNAME . @@ -73,29 +61,6 @@ for .Ar NETNAME is the same as not specifying any .Ar NETNAME . -.It Fl K, -generate-keys Ns Op = Ns Ar BITS -Generate public/private RSA keypair and exit. -If -.Ar BITS -is omitted, the default length will be 2048 bits. -When saving keys to existing files, tinc will not delete the old keys, -you have to remove them manually. -.It Fl o, -option Ns = Ns Ar [HOST.]KEY=VALUE -Without specifying a -.Ar HOST , -this will set server configuration variable -.Ar KEY -to -.Ar VALUE . -If specified as -.Ar HOST.KEY=VALUE , -this will set the host configuration variable -.Ar KEY -of the host named -.Ar HOST -to -.Ar VALUE . -This option can be used more than once to specify multiple configuration variables. .It Fl L, -mlock Lock tinc into main memory. This will prevent sensitive data like shared private keys to be written to the system swap files/partitions. @@ -105,12 +70,16 @@ If .Ar FILE is omitted, the default is .Pa @localstatedir@/log/tinc. Ns Ar NETNAME Ns Pa .log. -.It Fl -pidfile Ns = Ns Ar FILE -Write PID to +.It Fl -pidfile Ns = Ns Ar FILENAME +Store a cookie in +.Ar FILENAME +which allows +.Xr tincctl 8 +to authenticate. +If .Ar FILE -instead of -.Pa @runstatedir@/tinc. Ns Ar NETNAME Ns Pa .pid. -Under Windows this option will be ignored. +is omitted, the default is +.Pa @localstatedir@/run/tinc. Ns Ar NETNAME Ns Pa .pid. .It Fl -bypass-security Disables encryption and authentication of the meta protocol. Only useful for debugging. @@ -151,15 +120,6 @@ If the .Fl -logfile option is used, this will also close and reopen the log file, useful when log rotation is used. -.It INT -Temporarily increases debug level to 5. -Send this signal again to revert to the original level. -.It USR1 -Dumps the connection list to syslog. -.It USR2 -Dumps virtual network device statistics, all known nodes, edges and subnets to syslog. -.It WINCH -Purges all information remembered about unreachable nodes. .El .Sh DEBUG LEVELS The tinc daemon can send a lot of messages to the syslog. @@ -190,7 +150,7 @@ This will log all network traffic over the virtual private network. Directory containing the configuration files tinc uses. For more information, see .Xr tinc.conf 5 . -.It Pa @runstatedir@/tinc. Ns Ar NETNAME Ns Pa .pid +.It Pa @localstatedir@/run/tinc. Ns Ar NETNAME Ns Pa .pid The PID of the currently running .Nm is stored in this file. @@ -206,8 +166,9 @@ If you find any bugs, report them to tinc@tinc-vpn.org. .Sh TODO A lot, especially security auditing. .Sh SEE ALSO +.Xr tincctl 8 , .Xr tinc.conf 5 , -.Pa https://www.tinc-vpn.org/ , +.Pa http://www.tinc-vpn.org/ , .Pa http://www.cabal.org/ . .Pp The full documentation for tinc is maintained as a Texinfo manual. diff --git a/doc/tincinclude.texi b/doc/tincinclude.texi deleted file mode 100644 index 93d7ad2..0000000 --- a/doc/tincinclude.texi +++ /dev/null @@ -1,5 +0,0 @@ -@set VERSION 1.0.35 -@set PACKAGE tinc -@set sysconfdir /etc -@set localstatedir /var -@set runstatedir /var/run diff --git a/doc/tincinclude.texi.in b/doc/tincinclude.texi.in index 01fee35..da4adc5 100644 --- a/doc/tincinclude.texi.in +++ b/doc/tincinclude.texi.in @@ -2,4 +2,3 @@ @set PACKAGE @PACKAGE@ @set sysconfdir @sysconfdir@ @set localstatedir @localstatedir@ -@set runstatedir @runstatedir@ diff --git a/gui/Makefile.am b/gui/Makefile.am new file mode 100644 index 0000000..4f2c7fe --- /dev/null +++ b/gui/Makefile.am @@ -0,0 +1,3 @@ +dist_bin_SCRIPTS = tinc-gui + +extra_DIST = README.gui diff --git a/systemd/Makefile.in b/gui/Makefile.in similarity index 58% rename from systemd/Makefile.in rename to gui/Makefile.in index 376a668..632fd78 100644 --- a/systemd/Makefile.in +++ b/gui/Makefile.in @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. - +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -15,61 +16,6 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -88,42 +34,20 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -subdir = systemd +subdir = gui +DIST_COMMON = $(dist_bin_SCRIPTS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ - $(top_srcdir)/m4/ax_append_flag.m4 \ - $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ - $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_check_link_flag.m4 \ - $(top_srcdir)/m4/ax_require_defined.m4 $(top_srcdir)/m4/lzo.m4 \ - $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/zlib.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/m4/curses.m4 $(top_srcdir)/m4/libevent.m4 \ + $(top_srcdir)/m4/lzo.m4 $(top_srcdir)/m4/openssl.m4 \ + $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -145,20 +69,13 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(systemddir)" -DATA = $(nodist_systemd_DATA) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -am__DIST_COMMON = $(srcdir)/Makefile.in +am__installdirs = "$(DESTDIR)$(bindir)" +SCRIPTS = $(dist_bin_SCRIPTS) +SOURCES = +DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -168,6 +85,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -177,15 +95,21 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ +INCLUDES = @INCLUDES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ @@ -197,6 +121,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -243,28 +168,20 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemd_path = @systemd_path@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -EXTRA_DIST = tinc.service.in tinc@.service.in -CLEANFILES = tinc.service tinc@.service -@WITH_SYSTEMD_TRUE@systemddir = @systemd_path@ -@WITH_SYSTEMD_TRUE@nodist_systemd_DATA = tinc.service tinc@.service -substitute = sed \ - -e s,'@sbindir\@',"$(sbindir)",g \ - -e s,'@sysconfdir\@',"$(sysconfdir)",g - +dist_bin_SCRIPTS = tinc-gui +extra_DIST = README.gui all: all-am .SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -273,58 +190,69 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu systemd/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu gui/Makefile'; \ $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu systemd/Makefile + $(AUTOMAKE) --gnu gui/Makefile +.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -install-nodist_systemdDATA: $(nodist_systemd_DATA) +install-dist_binSCRIPTS: $(dist_bin_SCRIPTS) @$(NORMAL_INSTALL) - @list='$(nodist_systemd_DATA)'; test -n "$(systemddir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(systemddir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(systemddir)" || exit 1; \ - fi; \ + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(dist_bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(systemddir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(systemddir)" || exit $$?; \ - done + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done -uninstall-nodist_systemdDATA: +uninstall-dist_binSCRIPTS: @$(NORMAL_UNINSTALL) - @list='$(nodist_systemd_DATA)'; test -n "$(systemddir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(systemddir)'; $(am__uninstall_files_from_dir) -tags TAGS: + @list='$(dist_bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files +tags: TAGS +TAGS: -ctags CTAGS: - -cscope cscopelist: +ctags: CTAGS +CTAGS: -distdir: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) distdir-am - -distdir-am: $(DISTFILES) +distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -356,9 +284,9 @@ distdir-am: $(DISTFILES) done check-am: all-am check: check-am -all-am: Makefile $(DATA) +all-am: Makefile $(SCRIPTS) installdirs: - for dir in "$(DESTDIR)$(systemddir)"; do \ + for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -371,19 +299,13 @@ install-am: all-am installcheck: installcheck-am install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -412,13 +334,13 @@ info: info-am info-am: -install-data-am: install-nodist_systemdDATA +install-data-am: install-dvi: install-dvi-am install-dvi-am: -install-exec-am: +install-exec-am: install-dist_binSCRIPTS install-html: install-html-am @@ -456,30 +378,22 @@ ps: ps-am ps-am: -uninstall-am: uninstall-nodist_systemdDATA +uninstall-am: uninstall-dist_binSCRIPTS .MAKE: install-am install-strip -.PHONY: all all-am check check-am clean clean-generic cscopelist-am \ - ctags-am distclean distclean-generic distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-nodist_systemdDATA \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am tags-am uninstall \ - uninstall-am uninstall-nodist_systemdDATA +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-dist_binSCRIPTS install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am uninstall uninstall-am \ + uninstall-dist_binSCRIPTS -.PRECIOUS: Makefile - - -tinc.service: $(srcdir)/tinc.service.in - $(AM_V_GEN)$(substitute) $(srcdir)/tinc.service.in > $@ - -tinc@.service: $(srcdir)/tinc@.service.in - $(AM_V_GEN)$(substitute) $(srcdir)/tinc@.service.in > $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/gui/tinc-gui b/gui/tinc-gui new file mode 100755 index 0000000..c0f1cb1 --- /dev/null +++ b/gui/tinc-gui @@ -0,0 +1,537 @@ +#!/usr/bin/python + +import string +import socket +import wx +import sys +from wx.lib.mixins.listctrl import ColumnSorterMixin +from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin + +# Classes to interface with a running tinc daemon + +REQ_STOP = 0 +REQ_RELOAD = 1 +REQ_RESTART = 2 +REQ_DUMP_NODES = 3 +REQ_DUMP_EDGES = 4 +REQ_DUMP_SUBNETS = 5 +REQ_DUMP_CONNECTIONS = 6 +REQ_DUMP_GRAPH = 7 +REQ_PURGE = 8 +REQ_SET_DEBUG = 9 +REQ_RETRY = 10 +REQ_CONNECT = 11 +REQ_DISCONNECT = 12 + +ID = 0 +ACK = 4 +CONTROL = 18 + +class Node: + def parse(self, args): + self.name = args[0] + self.address = args[2] + if args[3] != 'port': + args.insert(3, 'port') + args.insert(4, '') + self.port = args[4] + self.cipher = int(args[6]) + self.digest = int(args[8]) + self.maclength = int(args[10]) + self.compression = int(args[12]) + self.options = int(args[14], 0x10) + self.status = int(args[16], 0x10) + self.nexthop = args[18] + self.via = args[20] + self.distance = int(args[22]) + self.pmtu = int(args[24]) + self.minmtu = int(args[26]) + self.maxmtu = int(args[28][:-1]) + + self.subnets = {} + +class Edge: + def parse(self, args): + self.fr = args[0] + self.to = args[2] + self.address = args[4] + self.port = args[6] + self.options = int(args[8], 16) + self.weight = int(args[10]) + +class Subnet: + def parse(self, args): + if args[0].find('#') >= 0: + (address, self.weight) = args[0].split('#', 1) + else: + self.weight = 10 + address = args[0] + + if address.find('/') >= 0: + (self.address, self.prefixlen) = address.split('/', 1) + else: + self.address = address + self.prefixlen = '48' + + self.owner = args[2] + +class Connection: + def parse(self, args): + self.name = args[0] + self.address = args[2] + if args[3] != 'port': + args.insert(3, 'port') + args.insert(4, '') + self.port = args[4] + self.options = int(args[6], 0x10) + self.socket = int(args[8]) + self.status = int(args[10], 0x10) + self.weight = 123 + +class VPN: + confdir = '/etc/tinc' + piddir = '/var/run/' + + def connect(self): + f = open(self.pidfile) + info = string.split(f.readline()) + f.close() + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect((info[2], int(info[4]))) + self.sf = s.makefile() + s.close() + hello = string.split(self.sf.readline()) + self.name = hello[1] + self.sf.write('0 ^' + info[1] + ' 17\r\n') + self.sf.flush() + resp = string.split(self.sf.readline()) + self.port = info[4] + self.nodes = {} + self.edges = {} + self.subnets = {} + self.connections = {} + self.refresh() + + def refresh(self): + self.sf.write('18 3\r\n18 4\r\n18 5\r\n18 6\r\n') + self.sf.flush() + + for node in self.nodes.values(): + node.visited = False + for edge in self.edges.values(): + edge.visited = False + for subnet in self.subnets.values(): + subnet.visited = False + for connections in self.connections.values(): + connections.visited = False + + while True: + resp = string.split(self.sf.readline()) + if len(resp) < 2: + break + if resp[0] != '18': + break + if resp[1] == '3': + if len(resp) < 3: + continue + node = self.nodes.get(resp[2]) or Node() + node.parse(resp[2:]) + node.visited = True + self.nodes[resp[2]] = node + elif resp[1] == '4': + if len(resp) < 5: + continue + edge = self.nodes.get((resp[2], resp[4])) or Edge() + edge.parse(resp[2:]) + edge.visited = True + self.edges[(resp[2], resp[4])] = edge + elif resp[1] == '5': + if len(resp) < 5: + continue + subnet = self.subnets.get((resp[2], resp[4])) or Subnet() + subnet.parse(resp[2:]) + subnet.visited = True + self.subnets[(resp[2], resp[4])] = subnet + self.nodes[subnet.owner].subnets[resp[2]] = subnet + elif resp[1] == '6': + if len(resp) < 5: + break + connection = self.connections.get((resp[2], resp[4])) or Connection() + connection.parse(resp[2:]) + connection.visited = True + self.connections[(resp[2], resp[4])] = connection + else: + break + + for key, subnet in self.subnets.items(): + if not subnet.visited: + del self.subnets[key] + + for key, edge in self.edges.items(): + if not edge.visited: + del self.edges[key] + + for key, node in self.nodes.items(): + if not node.visited: + del self.nodes[key] + else: + for key, subnet in node.subnets.items(): + if not subnet.visited: + del node.subnets[key] + + for key, connection in self.connections.items(): + if not connection.visited: + del self.connections[key] + + def close(self): + self.sf.close() + + def disconnect(self, name): + self.sf.write('18 12 ' + name + '\r\n') + self.sf.flush() + resp = string.split(self.sf.readline()) + + def debug(self, level = -1): + self.sf.write('18 9 ' + str(level) + '\r\n') + self.sf.flush() + resp = string.split(self.sf.readline()) + return int(resp[2]) + + def __init__(self, netname = None, pidfile = None): + self.tincconf = VPN.confdir + '/' + + if netname: + self.netname = netname + self.tincconf += netname + '/' + + self.tincconf += 'tinc.conf' + + if pidfile is not None: + self.pidfile = pidfile + else: + self.pidfile = VPN.piddir + 'tinc.' + if netname: + self.pidfile += netname + '.' + self.pidfile += 'pid' + +# GUI starts here + +argv0 = sys.argv[0] +del sys.argv[0] +net = None +pidfile = None + +def usage(exitcode = 0): + print('Usage: ' + argv0 + ' [options]') + print('\nValid options are:') + print(' -n, --net=NETNAME Connect to net NETNAME.') + print(' --pidfile=FILENAME Read control cookie from FILENAME.') + print(' --help Display this help and exit.') + print('\nReport bugs to tinc@tinc-vpn.org.') + sys.exit(exitcode) + +while len(sys.argv): + if sys.argv[0] in ('-n', '--net'): + del sys.argv[0] + net = sys.argv[0] + elif sys.argv[0] in ('--pidfile'): + del sys.argv[0] + pidfile = sys.argv[0] + elif sys.argv[0] in ('--help'): + usage(0) + else: + print(argv0 + ': unrecognized option \'' + sys.argv[0] + '\'') + usage(1) + + del sys.argv[0] + +vpn = VPN(net, pidfile) +vpn.connect() + +class SuperListCtrl(wx.ListCtrl, ColumnSorterMixin, ListCtrlAutoWidthMixin): + def __init__(self, parent, style): + wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES) + ListCtrlAutoWidthMixin.__init__(self) + ColumnSorterMixin.__init__(self, 14) + + def GetListCtrl(self): + return self + + +class SettingsPage(wx.Panel): + def OnDebugLevel(self, event): + vpn.debug(self.debug.GetValue()) + + def __init__(self, parent, id): + wx.Panel.__init__(self, parent, id) + grid = wx.FlexGridSizer(cols = 2) + grid.AddGrowableCol(0, 1) + + namelabel = wx.StaticText(self, -1, 'Name:') + self.name = wx.TextCtrl(self, -1, vpn.name) + grid.Add(namelabel) + grid.Add(self.name) + + portlabel = wx.StaticText(self, -1, 'Port:') + self.port = wx.TextCtrl(self, -1, vpn.port) + grid.Add(portlabel) + grid.Add(self.port) + + debuglabel = wx.StaticText(self, -1, 'Debug level:') + self.debug = wx.SpinCtrl(self, min = 0, max = 5, initial = vpn.debug()) + self.debug.Bind(wx.EVT_SPINCTRL, self.OnDebugLevel) + grid.Add(debuglabel) + grid.Add(self.debug) + + modelabel = wx.StaticText(self, -1, 'Mode:') + self.mode = wx.ComboBox(self, -1, style = wx.CB_READONLY, value = 'Router', choices = ['Router', 'Switch', 'Hub']) + grid.Add(modelabel) + grid.Add(self.mode) + + self.SetSizer(grid) + +class ConnectionsPage(wx.Panel): + def __init__(self, parent, id): + wx.Panel.__init__(self, parent, id) + self.list = wx.ListCtrl(self, id, style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES) + self.list.InsertColumn(0, 'Name') + self.list.InsertColumn(1, 'Address') + self.list.InsertColumn(2, 'Port') + self.list.InsertColumn(3, 'Options') + self.list.InsertColumn(4, 'Weight') + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add(self.list, 1, wx.EXPAND) + self.SetSizer(hbox) + self.refresh() + + class ContextMenu(wx.Menu): + def __init__(self, item): + wx.Menu.__init__(self) + + self.item = item + + disconnect = wx.MenuItem(self, -1, 'Disconnect') + self.AppendItem(disconnect) + self.Bind(wx.EVT_MENU, self.OnDisconnect, id=disconnect.GetId()) + + def OnDisconnect(self, event): + vpn.disconnect(self.item[0]) + + def OnContext(self, event): + i = event.GetIndex() + self.PopupMenu(self.ContextMenu(self.list.itemDataMap[event.GetIndex()]), event.GetPosition()) + + def refresh(self): + self.list.itemDataMap = {} + i = 0 + + for key, connection in vpn.connections.items(): + if self.list.GetItemCount() <= i: + self.list.InsertStringItem(i, connection.name) + else: + self.list.SetStringItem(i, 0, connection.name) + self.list.SetStringItem(i, 1, connection.address) + self.list.SetStringItem(i, 2, connection.port) + self.list.SetStringItem(i, 3, str(connection.options)) + self.list.SetStringItem(i, 4, str(connection.weight)) + self.list.itemDataMap[i] = (connection.name, connection.address, connection.port, connection.options, connection.weight) + self.list.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnContext) + i += 1 + + while self.list.GetItemCount() > i: + self.list.DeleteItem(self.list.GetItemCount() - 1) + + +class NodesPage(wx.Panel): + def __init__(self, parent, id): + wx.Panel.__init__(self, parent, id) + self.list = SuperListCtrl(self, id) + self.list.InsertColumn( 0, 'Name') + self.list.InsertColumn( 1, 'Address') + self.list.InsertColumn( 2, 'Port') + self.list.InsertColumn( 3, 'Cipher') + self.list.InsertColumn( 4, 'Digest') + self.list.InsertColumn( 5, 'MACLength') + self.list.InsertColumn( 6, 'Compression') + self.list.InsertColumn( 7, 'Options') + self.list.InsertColumn( 8, 'Status') + self.list.InsertColumn( 9, 'Nexthop') + self.list.InsertColumn(10, 'Via') + self.list.InsertColumn(11, 'Distance') + self.list.InsertColumn(12, 'PMTU') + self.list.InsertColumn(13, 'Min MTU') + self.list.InsertColumn(14, 'Max MTU') + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add(self.list, 1, wx.EXPAND) + self.SetSizer(hbox) + self.refresh() + + def refresh(self): + self.list.itemDataMap = {} + i = 0 + + for key, node in vpn.nodes.items(): + if self.list.GetItemCount() <= i: + self.list.InsertStringItem(i, node.name) + else: + self.list.SetStringItem(i, 0, node.name) + self.list.SetStringItem(i, 1, node.address) + self.list.SetStringItem(i, 2, node.port) + self.list.SetStringItem(i, 3, str(node.cipher)) + self.list.SetStringItem(i, 4, str(node.digest)) + self.list.SetStringItem(i, 5, str(node.maclength)) + self.list.SetStringItem(i, 6, str(node.compression)) + self.list.SetStringItem(i, 7, str(node.options)) + self.list.SetStringItem(i, 8, str(node.status)) + self.list.SetStringItem(i, 9, node.nexthop) + self.list.SetStringItem(i, 10, node.via) + self.list.SetStringItem(i, 11, str(node.distance)) + self.list.SetStringItem(i, 12, str(node.pmtu)) + self.list.SetStringItem(i, 13, str(node.minmtu)) + self.list.SetStringItem(i, 14, str(node.maxmtu)) + self.list.itemDataMap[i] = (node.name, node.address, node.port, node.cipher, node.digest, node.maclength, node.compression, node.options, node.status, node.nexthop, node.via, node.distance, node.pmtu, node.minmtu, node.maxmtu) + self.list.SetItemData(i, i) + i += 1 + + while self.list.GetItemCount() > i: + self.list.DeleteItem(self.list.GetItemCount() - 1) + +class EdgesPage(wx.Panel): + def __init__(self, parent, id): + wx.Panel.__init__(self, parent, id) + self.list = wx.ListCtrl(self, id, style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES) + self.list.InsertColumn(0, 'From') + self.list.InsertColumn(1, 'To') + self.list.InsertColumn(2, 'Address') + self.list.InsertColumn(3, 'Port') + self.list.InsertColumn(4, 'Options') + self.list.InsertColumn(5, 'Weight') + + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add(self.list, 1, wx.EXPAND) + self.SetSizer(hbox) + self.refresh() + + def refresh(self): + self.list.itemDataMap = {} + i = 0 + + for key, edge in vpn.edges.items(): + if self.list.GetItemCount() <= i: + self.list.InsertStringItem(i, edge.fr) + else: + self.list.SetStringItem(i, 0, edge.fr) + self.list.SetStringItem(i, 1, edge.to) + self.list.SetStringItem(i, 2, edge.address) + self.list.SetStringItem(i, 3, edge.port) + self.list.SetStringItem(i, 4, str(edge.options)) + self.list.SetStringItem(i, 5, str(edge.weight)) + self.list.itemDataMap[i] = (edge.fr, edge.to, edge.address, edge.port, edge.options, edge.weight) + i += 1 + + while self.list.GetItemCount() > i: + self.list.DeleteItem(self.list.GetItemCount() - 1) + +class SubnetsPage(wx.Panel): + def __init__(self, parent, id): + wx.Panel.__init__(self, parent, id) + self.list = SuperListCtrl(self, id) + self.list.InsertColumn(0, 'Subnet', wx.LIST_FORMAT_RIGHT) + self.list.InsertColumn(1, 'Weight', wx.LIST_FORMAT_RIGHT) + self.list.InsertColumn(2, 'Owner') + hbox = wx.BoxSizer(wx.HORIZONTAL) + hbox.Add(self.list, 1, wx.EXPAND) + self.SetSizer(hbox) + self.refresh() + + def refresh(self): + self.list.itemDataMap = {} + i = 0 + + for key, subnet in vpn.subnets.items(): + if self.list.GetItemCount() <= i: + self.list.InsertStringItem(i, subnet.address + '/' + subnet.prefixlen) + else: + self.list.SetStringItem(i, 0, subnet.address + '/' + subnet.prefixlen) + self.list.SetStringItem(i, 1, subnet.weight) + self.list.SetStringItem(i, 2, subnet.owner) + self.list.itemDataMap[i] = (subnet.address + '/' + subnet.prefixlen, subnet.weight, subnet.owner) + i = i + 1 + + while self.list.GetItemCount() > i: + self.list.DeleteItem(self.list.GetItemCount() - 1) + +class StatusPage(wx.Panel): + def __init__(self, parent, id): + wx.Panel.__init__(self, parent, id) + +class GraphPage(wx.Window): + def __init__(self, parent, id): + wx.Window.__init__(self, parent, id) + +class NetPage(wx.Notebook): + def __init__(self, parent, id): + wx.Notebook.__init__(self, parent) + self.settings = SettingsPage(self, id) + self.connections = ConnectionsPage(self, id) + self.nodes = NodesPage(self, id) + self.edges = EdgesPage(self, id) + self.subnets = SubnetsPage(self, id) + self.graph = GraphPage(self, id) + self.status = StatusPage(self, id) + + self.AddPage(self.settings, 'Settings') + #self.AddPage(self.status, 'Status') + self.AddPage(self.connections, 'Connections') + self.AddPage(self.nodes, 'Nodes') + self.AddPage(self.edges, 'Edges') + self.AddPage(self.subnets, 'Subnets') + #self.AddPage(self.graph, 'Graph') + + +class MainWindow(wx.Frame): + def OnQuit(self, event): + self.Close(True) + + def OnTimer(self, event): + vpn.refresh() + self.np.nodes.refresh() + self.np.subnets.refresh() + self.np.edges.refresh() + self.np.connections.refresh() + + def __init__(self, parent, id, title): + wx.Frame.__init__(self, parent, id, title) + + menubar = wx.MenuBar() + file = wx.Menu() + file.Append(1, '&Quit\tCtrl-X', 'Quit tinc GUI') + menubar.Append(file, '&File') + + #nb = wx.Notebook(self, -1) + #nb.SetPadding((0, 0)) + self.np = NetPage(self, -1) + #nb.AddPage(np, 'VPN') + + self.timer = wx.Timer(self, -1) + self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) + self.timer.Start(1000) + self.Bind(wx.EVT_MENU, self.OnQuit, id=1) + self.SetMenuBar(menubar) + self.Show() + +app = wx.App() +mw = MainWindow(None, -1, 'Tinc GUI') + +#def OnTaskBarIcon(event): +# mw.Raise() +# +#icon = wx.Icon("tincgui.ico", wx.BITMAP_TYPE_PNG) +#taskbaricon = wx.TaskBarIcon() +#taskbaricon.SetIcon(icon, 'Tinc GUI') +#wx.EVT_TASKBAR_RIGHT_UP(taskbaricon, OnTaskBarIcon) + +app.MainLoop() +vpn.close() diff --git a/src/have.h b/have.h similarity index 88% rename from src/have.h rename to have.h index 11fa56a..0ab8134 100644 --- a/src/have.h +++ b/have.h @@ -1,10 +1,7 @@ -#ifndef TINC_HAVE_H -#define TINC_HAVE_H - /* have.h -- include headers which are known to exist Copyright (C) 1998-2005 Ivo Timmermans - 2003-2015 Guus Sliepen + 2003-2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,32 +18,30 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_HAVE_H__ +#define __TINC_HAVE_H__ + #ifdef HAVE_MINGW #ifdef WITH_WINDOWS2000 #define WINVER Windows2000 #else #define WINVER WindowsXP #endif +#define WIN32_LEAN_AND_MEAN #endif #include -#include -#include -#include #include #include #include #include +#include #include -#include - #include #include -#include #ifdef HAVE_MINGW #include -#include #include #include #endif @@ -59,8 +54,8 @@ #include #endif -#ifdef HAVE_ALLOCA_H -#include +#ifdef HAVE_INTTYPES_H +#include #endif /* Include system specific headers */ @@ -109,6 +104,10 @@ #include #endif +#ifdef HAVE_SYS_UN_H +#include +#endif + #ifdef HAVE_DIRENT_H #include #endif @@ -196,19 +195,8 @@ #include #endif -#ifdef HAVE_ARPA_NAMESER_H -#include -#ifdef STATUS -#undef STATUS -#endif +#ifdef HAVE_EVENT_H +#include #endif -#ifdef HAVE_RESOLV_H -#include -#endif - -#ifdef HAVE_LINUX_IF_TUN_H -#include -#endif - -#endif +#endif /* __TINC_SYSTEM_H__ */ diff --git a/install-sh b/install-sh index 8175c64..6781b98 100755 --- a/install-sh +++ b/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2018-03-11.20; # UTC +scriptversion=2009-04-28.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -35,21 +35,25 @@ scriptversion=2018-03-11.20; # UTC # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent -# 'make' implicit rules from creating a file called install from it +# `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. -tab=' ' nl=' ' -IFS=" $tab$nl" +IFS=" "" $nl" -# Set DOITPROG to "echo" to test this script. +# set DOITPROG to echo to test this script +# Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} -doit_exec=${doit:-exec} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi # Put in absolute file names if you don't have them in your path; # or use environment vars. @@ -64,6 +68,17 @@ mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + posix_mkdir= # Desired mode of installed file. @@ -82,7 +97,7 @@ dir_arg= dst_arg= copy_on_change=false -is_target_a_directory=possibly +no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE @@ -122,57 +137,42 @@ while test $# -ne 0; do -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 - case $mode in - *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift;; + shift;; -s) stripcmd=$stripprog;; - -t) - is_target_a_directory=always - dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; + -t) dst_arg=$2 + shift;; - -T) is_target_a_directory=never;; + -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; - --) shift - break;; + --) shift + break;; - -*) echo "$0: invalid option: $1" >&2 - exit 1;; + -*) echo "$0: invalid option: $1" >&2 + exit 1;; *) break;; esac shift done -# We allow the use of options -d and -T together, by making -d -# take the precedence; this is for compatibility with GNU install. - -if test -n "$dir_arg"; then - if test -n "$dst_arg"; then - echo "$0: target directory not allowed when installing a directory." >&2 - exit 1 - fi -fi - if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. @@ -186,10 +186,6 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then fi shift # arg dst_arg=$arg - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac done fi @@ -198,26 +194,13 @@ if test $# -eq 0; then echo "$0: no input file specified." >&2 exit 1 fi - # It's OK to call 'install-sh -d' without argument. + # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then - if test $# -gt 1 || test "$is_target_a_directory" = always; then - if test ! -d "$dst_arg"; then - echo "$0: $dst_arg: Is not a directory." >&2 - exit 1 - fi - fi -fi - -if test -z "$dir_arg"; then - do_exit='(exit $ret); exit $ret' - trap "ret=129; $do_exit" 1 - trap "ret=130; $do_exit" 2 - trap "ret=141; $do_exit" 13 - trap "ret=143; $do_exit" 15 + trap '(exit $?); exit' 1 2 13 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. @@ -228,16 +211,16 @@ if test -z "$dir_arg"; then *[0-7]) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw='% 200' + u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw=,u+rw + u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac @@ -245,9 +228,9 @@ fi for src do - # Protect names problematic for 'test' and other utilities. + # Protect names starting with `-'. case $src in - -* | [=\(\)!]) src=./$src;; + -*) src=./$src;; esac if test -n "$dir_arg"; then @@ -269,115 +252,129 @@ do echo "$0: no destination specified." >&2 exit 1 fi - dst=$dst_arg - # If destination is a directory, append the input filename. + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. if test -d "$dst"; then - if test "$is_target_a_directory" = never; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi dstdir=$dst - dstbase=`basename "$src"` - case $dst in - */) dst=$dst$dstbase;; - *) dst=$dst/$dstbase;; - esac + dst=$dstdir/`basename "$src"` dstdir_status=0 else - dstdir=`dirname "$dst"` + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + test -d "$dstdir" dstdir_status=$? fi fi - case $dstdir in - */) dstdirslash=$dstdir;; - *) dstdirslash=$dstdir/;; - esac - obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - # Note that $RANDOM variable is not portable (e.g. dash); Use it - # here however when possible just to lower collision chance. - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 - - # Because "mkdir -p" follows existing symlinks and we likely work - # directly in world-writeable /tmp, make sure that the '$tmpdir' - # directory is successfully created first before we actually test - # 'mkdir -p' feature. - if (umask $mkdir_umask && - $mkdirprog $mkdir_mode "$tmpdir" && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - test_tmpdir="$tmpdir/a" - ls_ld_tmpdir=`ls -ld "$test_tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null - fi - trap '' 0;; - esac;; + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; esac if $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else @@ -387,51 +384,53 @@ do # directory the slow way, step by step, checking for races as we go. case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; esac + eval "$initialize_posix_glob" + oIFS=$IFS IFS=/ - set -f + $posix_glob set -f set fnord $dstdir shift - set +f + $posix_glob set +f IFS=$oIFS prefixes= for d do - test X"$d" = X && continue + test -z "$d" && continue - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ done if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi fi fi @@ -444,8 +443,8 @@ do else # Make a couple of temp file names in the proper directory. - dsttmp=${dstdirslash}_inst.$$_ - rmtmp=${dstdirslash}_rm.$$_ + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 @@ -466,12 +465,15 @@ do # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - set -f && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && - set +f && + $posix_glob set +f && + test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then @@ -484,24 +486,24 @@ do # to itself, or perhaps because mv is so ancient that it does not # support -f. { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 @@ -510,9 +512,9 @@ do done # Local variables: -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff --git a/m4/Makefile.am b/m4/Makefile.am new file mode 100644 index 0000000..0f58aef --- /dev/null +++ b/m4/Makefile.am @@ -0,0 +1,4 @@ +## Process this file with automake to produce Makefile.in -*-Makefile-*- + +EXTRA_DIST = README *.m4 + diff --git a/m4/Makefile.in b/m4/Makefile.in new file mode 100644 index 0000000..17af65a --- /dev/null +++ b/m4/Makefile.in @@ -0,0 +1,335 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = m4 +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ + $(top_srcdir)/m4/curses.m4 $(top_srcdir)/m4/libevent.m4 \ + $(top_srcdir)/m4/lzo.m4 $(top_srcdir)/m4/openssl.m4 \ + $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CURSES_LIBS = @CURSES_LIBS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GREP = @GREP@ +INCLUDES = @INCLUDES@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +EXTRA_DIST = README *.m4 +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu m4/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu m4/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/m4/README b/m4/README new file mode 100644 index 0000000..df032df --- /dev/null +++ b/m4/README @@ -0,0 +1,8 @@ +These files are used by a program called aclocal (part of the GNU automake +package). aclocal uses these files to create aclocal.m4 which is in turn +used by autoconf to create the configure script at the the top level in +this distribution. + +The Makefile.am file in this directory is automatically generated +from the template file, Makefile.am.in. The generation will fail +if you don't have all the right tools. diff --git a/m4/attribute.m4 b/m4/attribute.m4 index 9d673e9..6a8f555 100644 --- a/m4/attribute.m4 +++ b/m4/attribute.m4 @@ -9,8 +9,8 @@ AC_DEFUN([tinc_ATTRIBUTE], CFLAGS="$CFLAGS -Wall -Werror" AC_COMPILE_IFELSE( [AC_LANG_SOURCE( - [void *test(void) __attribute__ (($1)); - void *test(void) { return (void *)0; } + [void test(void) __attribute__ (($1)); + void test(void) { return; } ], )], [tinc_cv_attribute_$1=yes], diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4 deleted file mode 100644 index 1d38b76..0000000 --- a/m4/ax_append_flag.m4 +++ /dev/null @@ -1,69 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) -# -# DESCRIPTION -# -# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space -# added in between. -# -# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. -# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains -# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly -# FLAG. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 2 - -AC_DEFUN([AX_APPEND_FLAG], -[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX -AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl -AS_VAR_SET_IF(FLAGS, - [case " AS_VAR_GET(FLAGS) " in - *" $1 "*) - AC_RUN_LOG([: FLAGS already contains $1]) - ;; - *) - AC_RUN_LOG([: FLAGS="$FLAGS $1"]) - AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"]) - ;; - esac], - [AS_VAR_SET(FLAGS,["$1"])]) -AS_VAR_POPDEF([FLAGS])dnl -])dnl AX_APPEND_FLAG diff --git a/m4/ax_cflags_warn_all.m4 b/m4/ax_cflags_warn_all.m4 deleted file mode 100644 index 1f07799..0000000 --- a/m4/ax_cflags_warn_all.m4 +++ /dev/null @@ -1,122 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] -# AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] -# AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] -# -# DESCRIPTION -# -# Try to find a compiler option that enables most reasonable warnings. -# -# For the GNU compiler it will be -Wall (and -ansi -pedantic) The result -# is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default. -# -# Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, -# HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and -# Intel compilers. For a given compiler, the Fortran flags are much more -# experimental than their C equivalents. -# -# - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS -# - $2 add-value-if-not-found : nothing -# - $3 action-if-found : add value to shellvariable -# - $4 action-if-not-found : nothing -# -# NOTE: These macros depend on AX_APPEND_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2010 Rhys Ulerich -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 15 - -AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl -AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl -AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl -AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], -VAR,[VAR="no, unknown" -ac_save_[]FLAGS="$[]FLAGS" -for ac_arg dnl -in "-warn all % -warn all" dnl Intel - "-pedantic % -Wall" dnl GCC - "-xstrconst % -v" dnl Solaris C - "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix - "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX - "-ansi -ansiE % -fullwarn" dnl IRIX - "+ESlit % +w1" dnl HP-UX C - "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) - "-h conform % -h msglevel 2" dnl Cray C (Unicos) - # -do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` - AC_COMPILE_IFELSE([AC_LANG_PROGRAM], - [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) -done -FLAGS="$ac_save_[]FLAGS" -]) -AS_VAR_POPDEF([FLAGS])dnl -AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) -case ".$VAR" in - .ok|.ok,*) m4_ifvaln($3,$3) ;; - .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; - *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; -esac -AS_VAR_POPDEF([VAR])dnl -])dnl AX_FLAGS_WARN_ALL -dnl implementation tactics: -dnl the for-argument contains a list of options. The first part of -dnl these does only exist to detect the compiler - usually it is -dnl a global option to enable -ansi or -extrawarnings. All other -dnl compilers will fail about it. That was needed since a lot of -dnl compilers will give false positives for some option-syntax -dnl like -Woption or -Xoption as they think of it is a pass-through -dnl to later compile stages or something. The "%" is used as a -dnl delimiter. A non-option comment can be given after "%%" marks -dnl which will be shown but not added to the respective C/CXXFLAGS. - -AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl -AC_LANG_PUSH([C]) -AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) -AC_LANG_POP([C]) -]) - -AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl -AC_LANG_PUSH([C++]) -AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) -AC_LANG_POP([C++]) -]) - -AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl -AC_LANG_PUSH([Fortran]) -AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) -AC_LANG_POP([Fortran]) -]) diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 deleted file mode 100644 index c3a8d69..0000000 --- a/m4/ax_check_compile_flag.m4 +++ /dev/null @@ -1,72 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the current language's compiler -# or gives an error. (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the current language's default -# flags (e.g. CFLAGS) when the check is done. The check is thus made with -# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to -# force the compiler to issue an error when a bad flag is given. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 2 - -AC_DEFUN([AX_CHECK_COMPILE_FLAG], -[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX -AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ - ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS - _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) -AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_COMPILE_FLAGS diff --git a/m4/ax_check_link_flag.m4 b/m4/ax_check_link_flag.m4 deleted file mode 100644 index e2d0d36..0000000 --- a/m4/ax_check_link_flag.m4 +++ /dev/null @@ -1,71 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) -# -# DESCRIPTION -# -# Check whether the given FLAG works with the linker or gives an error. -# (Warnings, however, are ignored) -# -# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on -# success/failure. -# -# If EXTRA-FLAGS is defined, it is added to the linker's default flags -# when the check is done. The check is thus made with the flags: "LDFLAGS -# EXTRA-FLAGS FLAG". This can for example be used to force the linker to -# issue an error when a bad flag is given. -# -# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this -# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. -# -# LICENSE -# -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2011 Maarten Bosmans -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 2 - -AC_DEFUN([AX_CHECK_LINK_FLAG], -[AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl -AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ - ax_check_save_flags=$LDFLAGS - LDFLAGS="$LDFLAGS $4 $1" - AC_LINK_IFELSE([AC_LANG_PROGRAM()], - [AS_VAR_SET(CACHEVAR,[yes])], - [AS_VAR_SET(CACHEVAR,[no])]) - LDFLAGS=$ax_check_save_flags]) -AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], - [m4_default([$2], :)], - [m4_default([$3], :)]) -AS_VAR_POPDEF([CACHEVAR])dnl -])dnl AX_CHECK_LINK_FLAGS diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4 deleted file mode 100644 index cae1111..0000000 --- a/m4/ax_require_defined.m4 +++ /dev/null @@ -1,37 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_REQUIRE_DEFINED(MACRO) -# -# DESCRIPTION -# -# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have -# been defined and thus are available for use. This avoids random issues -# where a macro isn't expanded. Instead the configure script emits a -# non-fatal: -# -# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found -# -# It's like AC_REQUIRE except it doesn't expand the required macro. -# -# Here's an example: -# -# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) -# -# LICENSE -# -# Copyright (c) 2014 Mike Frysinger -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 1 - -AC_DEFUN([AX_REQUIRE_DEFINED], [dnl - m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) -])dnl AX_REQUIRE_DEFINED diff --git a/m4/curses.m4 b/m4/curses.m4 new file mode 100644 index 0000000..50a90a5 --- /dev/null +++ b/m4/curses.m4 @@ -0,0 +1,41 @@ +dnl Check to find the curses headers/libraries + +AC_DEFUN([tinc_CURSES], +[ + AC_ARG_ENABLE([curses], + AS_HELP_STRING([--disable-curses], [disable curses support])) + AS_IF([test "x$enable_curses" != "xno"], [ + AC_DEFINE(HAVE_CURSES, 1, [have curses support]) + curses=true + AC_ARG_WITH(curses, + AS_HELP_STRING([--with-curses=DIR], [curses base directory, or:]), + [curses="$withval" + CPPFLAGS="$CPPFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib"] + ) + + AC_ARG_WITH(curses-include, + AS_HELP_STRING([--with-curses-include=DIR], [curses headers directory]), + [curses_include="$withval" + CPPFLAGS="$CPPFLAGS -I$withval"] + ) + + AC_ARG_WITH(curses-lib, + AS_HELP_STRING([--with-curses-lib=DIR], [curses library directory]), + [curses_lib="$withval" + LDFLAGS="$LDFLAGS -L$withval"] + ) + + AC_CHECK_HEADERS(curses.h, + [], + [AC_MSG_ERROR("curses header files not found."); break] + ) + + AC_CHECK_LIB(curses, initscr, + [CURSES_LIBS="-lcurses"], + [AC_MSG_ERROR("curses libraries not found.")] + ) + ]) + + AC_SUBST(CURSES_LIBS) +]) diff --git a/m4/libevent.m4 b/m4/libevent.m4 new file mode 100644 index 0000000..34bdef7 --- /dev/null +++ b/m4/libevent.m4 @@ -0,0 +1,33 @@ +dnl Check to find the libevent headers/libraries + +AC_DEFUN([tinc_LIBEVENT], +[ + AC_ARG_WITH(libevent, + AS_HELP_STRING([--with-libevent=DIR], [libevent base directory, or:]), + [libevent="$withval" + CPPFLAGS="$CPPFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib"] + ) + + AC_ARG_WITH(libevent-include, + AS_HELP_STRING([--with-libevent-include=DIR], [libevent headers directory]), + [libevent_include="$withval" + CPPFLAGS="$CPPFLAGS -I$withval"] + ) + + AC_ARG_WITH(libevent-lib, + AS_HELP_STRING([--with-libevent-lib=DIR], [libevent library directory]), + [libevent_lib="$withval" + LDFLAGS="$LDFLAGS -L$withval"] + ) + + AC_CHECK_HEADERS(event.h, + [], + [AC_MSG_ERROR("libevent header files not found."); break] + ) + + AC_CHECK_LIB(event, event_init, + [LIBS="-levent $LIBS"], + [AC_MSG_ERROR("libevent libraries not found.")] + ) +]) diff --git a/m4/openssl.m4 b/m4/openssl.m4 index 895c31a..254ea4f 100644 --- a/m4/openssl.m4 +++ b/m4/openssl.m4 @@ -1,4 +1,4 @@ -dnl Check to find the LibreSSL/OpenSSL headers/libraries +dnl Check to find the OpenSSL headers/libraries AC_DEFUN([tinc_OPENSSL], [ @@ -10,49 +10,47 @@ AC_DEFUN([tinc_OPENSSL], [], [AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"], - [AC_MSG_ERROR([LibreSSL/OpenSSL depends on libdl.]); break] + [AC_MSG_ERROR([OpenSSL depends on libdl.]); break] )] ) ;; esac AC_ARG_WITH(openssl, - AS_HELP_STRING([--with-openssl=DIR], [LibreSSL/OpenSSL base directory, or:]), + AS_HELP_STRING([--with-openssl=DIR], [OpenSSL base directory, or:]), [openssl="$withval" CPPFLAGS="$CPPFLAGS -I$withval/include" LDFLAGS="$LDFLAGS -L$withval/lib"] ) AC_ARG_WITH(openssl-include, - AS_HELP_STRING([--with-openssl-include=DIR], [LibreSSL/OpenSSL headers directory (without trailing /openssl)]), + AS_HELP_STRING([--with-openssl-include=DIR], [OpenSSL headers directory (without trailing /openssl)]), [openssl_include="$withval" CPPFLAGS="$CPPFLAGS -I$withval"] ) AC_ARG_WITH(openssl-lib, - AS_HELP_STRING([--with-openssl-lib=DIR], [LibreSSL/OpenSSL library directory]), + AS_HELP_STRING([--with-openssl-lib=DIR], [OpenSSL library directory]), [openssl_lib="$withval" LDFLAGS="$LDFLAGS -L$withval"] ) AC_CHECK_HEADERS(openssl/evp.h openssl/rsa.h openssl/rand.h openssl/err.h openssl/sha.h openssl/pem.h openssl/engine.h, [], - [AC_MSG_ERROR([LibreSSL/OpenSSL header files not found.]); break] + [AC_MSG_ERROR([OpenSSL header files not found.]); break] ) AC_CHECK_LIB(crypto, EVP_EncryptInit_ex, [LIBS="-lcrypto $LIBS"], - [AC_MSG_ERROR([LibreSSL/OpenSSL libraries not found.])] + [AC_MSG_ERROR([OpenSSL libraries not found.])] ) - AC_CHECK_FUNCS([RAND_bytes EVP_EncryptInit_ex EVP_CIPHER_CTX_new], , - [AC_MSG_ERROR([Missing LibreSSL/OpenSSL functionality, make sure you have installed the latest version.]); break], + AC_CHECK_FUNCS([RAND_pseudo_bytes EVP_EncryptInit_ex], , + [AC_MSG_ERROR([Missing OpenSSL functionality, make sure you have installed the latest version.]); break], ) - AC_CHECK_DECLS([OpenSSL_add_all_algorithms, EVP_aes_256_cfb], , - [AC_MSG_ERROR([Missing LibreSSL/OpenSSL functionality, make sure you have installed the latest version.]); break], + AC_CHECK_DECL([OpenSSL_add_all_algorithms], , + [AC_MSG_ERROR([Missing OpenSSL functionality, make sure you have installed the latest version.]); break], [#include ] ) - - AC_CHECK_FUNCS([BN_GENCB_new RSA_set0_key], , , [#include ]) ]) diff --git a/missing b/missing index 625aeb1..28055d2 100755 --- a/missing +++ b/missing @@ -1,10 +1,11 @@ #! /bin/sh -# Common wrapper for a few potentially missing GNU programs. +# Common stub for a few missing GNU programs while installing. -scriptversion=2018-03-07.03; # UTC +scriptversion=2009-04-28.21; # UTC -# Copyright (C) 1996-2018 Free Software Foundation, Inc. -# Originally written by Fran,cois Pinard , 1996. +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, +# 2008, 2009 Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +18,7 @@ scriptversion=2018-03-07.03; # UTC # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -25,40 +26,69 @@ scriptversion=2018-03-07.03; # UTC # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then - echo 1>&2 "Try '$0 --help' for more information" + echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi +run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + case $1 in - - --is-lightweight) - # Used by our autoconf macros to check whether the available missing - # script is modern enough. - exit 0 - ;; - - --run) - # Back-compat with the calling convention used by older automake. - shift - ;; +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... -Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due -to PROGRAM being missing or too old. +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails Supported PROGRAM values: - aclocal autoconf autoheader autom4te automake makeinfo - bison yacc flex lex help2man + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] -Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and -'g' are ignored when checking the name. +Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and +\`g' are ignored when checking the name. Send bug reports to ." exit $? @@ -70,146 +100,277 @@ Send bug reports to ." ;; -*) - echo 1>&2 "$0: unknown '$1' option" - echo 1>&2 "Try '$0 --help' for more information" + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac -# Run the given program, remember its exit status. -"$@"; st=$? +# normalize program name to check for. +program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` -# If it succeeded, we are done. -test $st -eq 0 && exit 0 - -# Also exit now if we it failed (or wasn't found), and '--version' was -# passed; such an option is passed most likely to detect whether the -# program is present and works. -case $2 in --version|--help) exit $st;; esac - -# Exit code 63 means version mismatch. This often happens when the user -# tries to use an ancient version of a tool on a file that requires a -# minimum version. -if test $st -eq 63; then - msg="probably too old" -elif test $st -eq 127; then - # Program was missing. - msg="missing on your system" -else - # Program was found and executed, but failed. Give up. - exit $st -fi - -perl_URL=https://www.perl.org/ -flex_URL=https://github.com/westes/flex -gnu_software_URL=https://www.gnu.org/software - -program_details () -{ - case $1 in - aclocal|automake) - echo "The '$1' program is part of the GNU Automake package:" - echo "<$gnu_software_URL/automake>" - echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" - echo "<$gnu_software_URL/autoconf>" - echo "<$gnu_software_URL/m4/>" - echo "<$perl_URL>" - ;; - autoconf|autom4te|autoheader) - echo "The '$1' program is part of the GNU Autoconf package:" - echo "<$gnu_software_URL/autoconf/>" - echo "It also requires GNU m4 and Perl in order to run:" - echo "<$gnu_software_URL/m4/>" - echo "<$perl_URL>" - ;; - esac -} - -give_advice () -{ - # Normalize program name to check for. - normalized_program=`echo "$1" | sed ' - s/^gnu-//; t - s/^gnu//; t - s/^g//; t'` - - printf '%s\n' "'$1' is $msg." - - configure_deps="'configure.ac' or m4 files included by 'configure.ac'" - case $normalized_program in - autoconf*) - echo "You should only need it if you modified 'configure.ac'," - echo "or m4 files included by it." - program_details 'autoconf' - ;; - autoheader*) - echo "You should only need it if you modified 'acconfig.h' or" - echo "$configure_deps." - program_details 'autoheader' - ;; - automake*) - echo "You should only need it if you modified 'Makefile.am' or" - echo "$configure_deps." - program_details 'automake' - ;; - aclocal*) - echo "You should only need it if you modified 'acinclude.m4' or" - echo "$configure_deps." - program_details 'aclocal' - ;; - autom4te*) - echo "You might have modified some maintainer files that require" - echo "the 'autom4te' program to be rebuilt." - program_details 'autom4te' - ;; - bison*|yacc*) - echo "You should only need it if you modified a '.y' file." - echo "You may want to install the GNU Bison package:" - echo "<$gnu_software_URL/bison/>" - ;; - lex*|flex*) - echo "You should only need it if you modified a '.l' file." - echo "You may want to install the Fast Lexical Analyzer package:" - echo "<$flex_URL>" - ;; - help2man*) - echo "You should only need it if you modified a dependency" \ - "of a man page." - echo "You may want to install the GNU Help2man package:" - echo "<$gnu_software_URL/help2man/>" +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). This is about non-GNU programs, so use $1 not +# $program. +case $1 in + lex*|yacc*) + # Not GNU programs, they don't have --version. ;; - makeinfo*) - echo "You should only need it if you modified a '.texi' file, or" - echo "any other file indirectly affecting the aspect of the manual." - echo "You might want to install the Texinfo package:" - echo "<$gnu_software_URL/texinfo/>" - echo "The spurious makeinfo call might also be the consequence of" - echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" - echo "want to install GNU make:" - echo "<$gnu_software_URL/make/>" - ;; - *) - echo "You might have modified some files without having the proper" - echo "tools for further handling them. Check the 'README' file, it" - echo "often tells you about the needed prerequisites for installing" - echo "this package. You may also peek at any GNU archive site, in" - echo "case some other package contains this missing '$1' program." - ;; - esac -} -give_advice "$1" | sed -e '1s/^/WARNING: /' \ - -e '2,$s/^/ /' >&2 + tar*) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; -# Propagate the correct exit status (expected to be 127 for a program -# not found, 63 for a program that failed due to version mismatch). -exit $st + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case $program in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case $f in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te*) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison*|yacc*) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if test ! -f y.tab.h; then + echo >y.tab.h + fi + if test ! -f y.tab.c; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex*|flex*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if test ! -f lex.yy.c; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit $? + fi + ;; + + makeinfo*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + tar*) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case $firstarg in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case $firstarg in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 # Local variables: -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" +# time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: diff --git a/src/Makefile.am b/src/Makefile.am index 7b3dd97..186c042 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,89 +1,50 @@ ## Produce this file with automake to get Makefile.in -sbin_PROGRAMS = tincd +sbin_PROGRAMS = tincd tincctl + +EXTRA_DIST = linux bsd solaris cygwin mingw raw_socket uml_socket openssl gcrypt tincd_SOURCES = \ - have.h \ - system.h \ - avl_tree.c avl_tree.h \ - conf.c conf.h \ - connection.c connection.h \ - device.h \ - dropin.c dropin.h \ - dummy_device.c \ - edge.c edge.h \ - ethernet.h \ - event.c event.h \ - fake-getaddrinfo.c fake-getaddrinfo.h \ - fake-getnameinfo.c fake-getnameinfo.h \ - graph.c graph.h \ - ipv4.h \ - ipv6.h \ - list.c list.h \ - logger.c logger.h \ - meta.c meta.h \ - multicast_device.c \ - net.c net.h \ - net_packet.c \ - net_setup.c \ - net_socket.c \ - netutl.c netutl.h \ - node.c node.h \ - pidfile.c pidfile.h \ - process.c process.h \ - protocol.c protocol.h \ - protocol_auth.c \ - protocol_edge.c \ - protocol_misc.c \ - protocol_key.c \ - protocol_subnet.c \ - proxy.c proxy.h \ - raw_socket_device.c \ - route.c route.h \ - subnet.c subnet.h \ - tincd.c \ - utils.c utils.h \ - xalloc.h + utils.c getopt.c getopt1.c list.c splay_tree.c dropin.c fake-getaddrinfo.c fake-getnameinfo.c \ + buffer.c conf.c connection.c control.c edge.c graph.c logger.c meta.c net.c net_packet.c net_setup.c \ + net_socket.c netutl.c node.c process.c protocol.c protocol_auth.c protocol_edge.c protocol_misc.c \ + protocol_key.c protocol_subnet.c route.c subnet.c tincd.c -if !GETOPT -tincd_SOURCES += \ - getopt.c getopt.h \ - getopt1.c -endif +nodist_tincd_SOURCES = \ + device.c cipher.c crypto.c ecdh.c ecdsa.c digest.c prf.c rsa.c -if LINUX -tincd_SOURCES += linux/device.c -endif +tincctl_SOURCES = \ + utils.c getopt.c getopt1.c dropin.c \ + list.c tincctl.c top.c + +nodist_tincctl_SOURCES = \ + ecdsagen.c rsagen.c -if BSD -tincd_SOURCES += bsd/device.c if TUNEMU -tincd_SOURCES += bsd/tunemu.c bsd/tunemu.h -endif +tincd_SOURCES += bsd/tunemu.c endif -if SOLARIS -tincd_SOURCES += solaris/device.c -endif +tincctl_LDADD = $(CURSES_LIBS) -if MINGW -tincd_SOURCES += mingw/device.c mingw/common.h -endif +DEFAULT_INCLUDES = -if CYGWIN -tincd_SOURCES += cygwin/device.c -endif +INCLUDES = @INCLUDES@ -I$(top_builddir) -if UML -tincd_SOURCES += uml_device.c -endif +noinst_HEADERS = \ + xalloc.h utils.h getopt.h list.h splay_tree.h dropin.h fake-getaddrinfo.h fake-getnameinfo.h fake-gai-errnos.h ipv6.h ipv4.h ethernet.h \ + buffer.h conf.h connection.h control.h control_common.h device.h edge.h graph.h logger.h meta.h net.h netutl.h node.h process.h \ + protocol.h route.h subnet.h tincctl.h top.h bsd/tunemu.h -if VDE -tincd_SOURCES += vde_device.c -endif +nodist_noinst_HEADERS = \ + cipher.h crypto.h ecdh.h ecdsa.h digest.h prf.h rsa.h ecdsagen.h rsagen.h + +LIBS = @LIBS@ @LIBGCRYPT_LIBS@ if TUNEMU LIBS += -lpcap endif -AM_CPPFLAGS = -DCONFDIR=\"$(sysconfdir)\" -DRUNSTATEDIR=\"$(runstatedir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -I $(abs_top_builddir)/ +AM_CFLAGS = -DCONFDIR=\"$(sysconfdir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -DSBINDIR=\"$(sbindir)\" + +dist-hook: + rm -f `find . -type l` diff --git a/src/Makefile.in b/src/Makefile.in index 93039a2..d7e2afd 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,8 +1,9 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. - +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -14,62 +15,8 @@ @SET_MAKE@ + VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -88,163 +35,74 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -sbin_PROGRAMS = tincd$(EXEEXT) -@GETOPT_FALSE@am__append_1 = \ -@GETOPT_FALSE@ getopt.c getopt.h \ -@GETOPT_FALSE@ getopt1.c - -@LINUX_TRUE@am__append_2 = linux/device.c -@BSD_TRUE@am__append_3 = bsd/device.c -@BSD_TRUE@@TUNEMU_TRUE@am__append_4 = bsd/tunemu.c bsd/tunemu.h -@SOLARIS_TRUE@am__append_5 = solaris/device.c -@MINGW_TRUE@am__append_6 = mingw/device.c mingw/common.h -@CYGWIN_TRUE@am__append_7 = cygwin/device.c -@UML_TRUE@am__append_8 = uml_device.c -@VDE_TRUE@am__append_9 = vde_device.c -@TUNEMU_TRUE@am__append_10 = -lpcap +sbin_PROGRAMS = tincd$(EXEEXT) tincctl$(EXEEXT) +@TUNEMU_TRUE@am__append_1 = bsd/tunemu.c +@TUNEMU_TRUE@am__append_2 = -lpcap subdir = src +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ - $(top_srcdir)/m4/ax_append_flag.m4 \ - $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ - $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_check_link_flag.m4 \ - $(top_srcdir)/m4/ax_require_defined.m4 $(top_srcdir)/m4/lzo.m4 \ - $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/zlib.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/m4/curses.m4 $(top_srcdir)/m4/libevent.m4 \ + $(top_srcdir)/m4/lzo.m4 $(top_srcdir)/m4/openssl.m4 \ + $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(sbindir)" PROGRAMS = $(sbin_PROGRAMS) -am__tincd_SOURCES_DIST = have.h system.h avl_tree.c avl_tree.h conf.c \ - conf.h connection.c connection.h device.h dropin.c dropin.h \ - dummy_device.c edge.c edge.h ethernet.h event.c event.h \ - fake-getaddrinfo.c fake-getaddrinfo.h fake-getnameinfo.c \ - fake-getnameinfo.h graph.c graph.h ipv4.h ipv6.h list.c list.h \ - logger.c logger.h meta.c meta.h multicast_device.c net.c net.h \ - net_packet.c net_setup.c net_socket.c netutl.c netutl.h node.c \ - node.h pidfile.c pidfile.h process.c process.h protocol.c \ - protocol.h protocol_auth.c protocol_edge.c protocol_misc.c \ - protocol_key.c protocol_subnet.c proxy.c proxy.h \ - raw_socket_device.c route.c route.h subnet.c subnet.h tincd.c \ - utils.c utils.h xalloc.h getopt.c getopt.h getopt1.c \ - linux/device.c bsd/device.c bsd/tunemu.c bsd/tunemu.h \ - solaris/device.c mingw/device.c mingw/common.h cygwin/device.c \ - uml_device.c vde_device.c -@GETOPT_FALSE@am__objects_1 = getopt.$(OBJEXT) getopt1.$(OBJEXT) -am__dirstamp = $(am__leading_dot)dirstamp -@LINUX_TRUE@am__objects_2 = linux/device.$(OBJEXT) -@BSD_TRUE@am__objects_3 = bsd/device.$(OBJEXT) -@BSD_TRUE@@TUNEMU_TRUE@am__objects_4 = bsd/tunemu.$(OBJEXT) -@SOLARIS_TRUE@am__objects_5 = solaris/device.$(OBJEXT) -@MINGW_TRUE@am__objects_6 = mingw/device.$(OBJEXT) -@CYGWIN_TRUE@am__objects_7 = cygwin/device.$(OBJEXT) -@UML_TRUE@am__objects_8 = uml_device.$(OBJEXT) -@VDE_TRUE@am__objects_9 = vde_device.$(OBJEXT) -am_tincd_OBJECTS = avl_tree.$(OBJEXT) conf.$(OBJEXT) \ - connection.$(OBJEXT) dropin.$(OBJEXT) dummy_device.$(OBJEXT) \ - edge.$(OBJEXT) event.$(OBJEXT) fake-getaddrinfo.$(OBJEXT) \ - fake-getnameinfo.$(OBJEXT) graph.$(OBJEXT) list.$(OBJEXT) \ - logger.$(OBJEXT) meta.$(OBJEXT) multicast_device.$(OBJEXT) \ - net.$(OBJEXT) net_packet.$(OBJEXT) net_setup.$(OBJEXT) \ - net_socket.$(OBJEXT) netutl.$(OBJEXT) node.$(OBJEXT) \ - pidfile.$(OBJEXT) process.$(OBJEXT) protocol.$(OBJEXT) \ - protocol_auth.$(OBJEXT) protocol_edge.$(OBJEXT) \ - protocol_misc.$(OBJEXT) protocol_key.$(OBJEXT) \ - protocol_subnet.$(OBJEXT) proxy.$(OBJEXT) \ - raw_socket_device.$(OBJEXT) route.$(OBJEXT) subnet.$(OBJEXT) \ - tincd.$(OBJEXT) utils.$(OBJEXT) $(am__objects_1) \ - $(am__objects_2) $(am__objects_3) $(am__objects_4) \ - $(am__objects_5) $(am__objects_6) $(am__objects_7) \ - $(am__objects_8) $(am__objects_9) -tincd_OBJECTS = $(am_tincd_OBJECTS) +am_tincctl_OBJECTS = utils.$(OBJEXT) getopt.$(OBJEXT) \ + getopt1.$(OBJEXT) dropin.$(OBJEXT) list.$(OBJEXT) \ + tincctl.$(OBJEXT) top.$(OBJEXT) +nodist_tincctl_OBJECTS = ecdsagen.$(OBJEXT) rsagen.$(OBJEXT) +tincctl_OBJECTS = $(am_tincctl_OBJECTS) $(nodist_tincctl_OBJECTS) +am__DEPENDENCIES_1 = +tincctl_DEPENDENCIES = $(am__DEPENDENCIES_1) +am__tincd_SOURCES_DIST = utils.c getopt.c getopt1.c list.c \ + splay_tree.c dropin.c fake-getaddrinfo.c fake-getnameinfo.c \ + buffer.c conf.c connection.c control.c edge.c graph.c logger.c \ + meta.c net.c net_packet.c net_setup.c net_socket.c netutl.c \ + node.c process.c protocol.c protocol_auth.c protocol_edge.c \ + protocol_misc.c protocol_key.c protocol_subnet.c route.c \ + subnet.c tincd.c bsd/tunemu.c +@TUNEMU_TRUE@am__objects_1 = tunemu.$(OBJEXT) +am_tincd_OBJECTS = utils.$(OBJEXT) getopt.$(OBJEXT) getopt1.$(OBJEXT) \ + list.$(OBJEXT) splay_tree.$(OBJEXT) dropin.$(OBJEXT) \ + fake-getaddrinfo.$(OBJEXT) fake-getnameinfo.$(OBJEXT) \ + buffer.$(OBJEXT) conf.$(OBJEXT) connection.$(OBJEXT) \ + control.$(OBJEXT) edge.$(OBJEXT) graph.$(OBJEXT) \ + logger.$(OBJEXT) meta.$(OBJEXT) net.$(OBJEXT) \ + net_packet.$(OBJEXT) net_setup.$(OBJEXT) net_socket.$(OBJEXT) \ + netutl.$(OBJEXT) node.$(OBJEXT) process.$(OBJEXT) \ + protocol.$(OBJEXT) protocol_auth.$(OBJEXT) \ + protocol_edge.$(OBJEXT) protocol_misc.$(OBJEXT) \ + protocol_key.$(OBJEXT) protocol_subnet.$(OBJEXT) \ + route.$(OBJEXT) subnet.$(OBJEXT) tincd.$(OBJEXT) \ + $(am__objects_1) +nodist_tincd_OBJECTS = device.$(OBJEXT) cipher.$(OBJEXT) \ + crypto.$(OBJEXT) ecdh.$(OBJEXT) ecdsa.$(OBJEXT) \ + digest.$(OBJEXT) prf.$(OBJEXT) rsa.$(OBJEXT) +tincd_OBJECTS = $(am_tincd_OBJECTS) $(nodist_tincd_OBJECTS) tincd_LDADD = $(LDADD) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = depcomp = $(SHELL) $(top_srcdir)/depcomp -am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ./$(DEPDIR)/avl_tree.Po ./$(DEPDIR)/conf.Po \ - ./$(DEPDIR)/connection.Po ./$(DEPDIR)/dropin.Po \ - ./$(DEPDIR)/dummy_device.Po ./$(DEPDIR)/edge.Po \ - ./$(DEPDIR)/event.Po ./$(DEPDIR)/fake-getaddrinfo.Po \ - ./$(DEPDIR)/fake-getnameinfo.Po ./$(DEPDIR)/getopt.Po \ - ./$(DEPDIR)/getopt1.Po ./$(DEPDIR)/graph.Po \ - ./$(DEPDIR)/list.Po ./$(DEPDIR)/logger.Po ./$(DEPDIR)/meta.Po \ - ./$(DEPDIR)/multicast_device.Po ./$(DEPDIR)/net.Po \ - ./$(DEPDIR)/net_packet.Po ./$(DEPDIR)/net_setup.Po \ - ./$(DEPDIR)/net_socket.Po ./$(DEPDIR)/netutl.Po \ - ./$(DEPDIR)/node.Po ./$(DEPDIR)/pidfile.Po \ - ./$(DEPDIR)/process.Po ./$(DEPDIR)/protocol.Po \ - ./$(DEPDIR)/protocol_auth.Po ./$(DEPDIR)/protocol_edge.Po \ - ./$(DEPDIR)/protocol_key.Po ./$(DEPDIR)/protocol_misc.Po \ - ./$(DEPDIR)/protocol_subnet.Po ./$(DEPDIR)/proxy.Po \ - ./$(DEPDIR)/raw_socket_device.Po ./$(DEPDIR)/route.Po \ - ./$(DEPDIR)/subnet.Po ./$(DEPDIR)/tincd.Po \ - ./$(DEPDIR)/uml_device.Po ./$(DEPDIR)/utils.Po \ - ./$(DEPDIR)/vde_device.Po bsd/$(DEPDIR)/device.Po \ - bsd/$(DEPDIR)/tunemu.Po cygwin/$(DEPDIR)/device.Po \ - linux/$(DEPDIR)/device.Po mingw/$(DEPDIR)/device.Po \ - solaris/$(DEPDIR)/device.Po +am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(tincd_SOURCES) -DIST_SOURCES = $(am__tincd_SOURCES_DIST) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` +SOURCES = $(tincctl_SOURCES) $(nodist_tincctl_SOURCES) \ + $(tincd_SOURCES) $(nodist_tincd_SOURCES) +DIST_SOURCES = $(tincctl_SOURCES) $(am__tincd_SOURCES_DIST) +HEADERS = $(nodist_noinst_HEADERS) $(noinst_HEADERS) ETAGS = etags CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -254,6 +112,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -263,15 +122,21 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ +INCLUDES = @INCLUDES@ -I$(top_builddir) INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ $(am__append_10) +LIBS = @LIBS@ @LIBGCRYPT_LIBS@ $(am__append_2) +LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ @@ -283,6 +148,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -329,37 +195,48 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemd_path = @systemd_path@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -tincd_SOURCES = have.h system.h avl_tree.c avl_tree.h conf.c conf.h \ - connection.c connection.h device.h dropin.c dropin.h \ - dummy_device.c edge.c edge.h ethernet.h event.c event.h \ - fake-getaddrinfo.c fake-getaddrinfo.h fake-getnameinfo.c \ - fake-getnameinfo.h graph.c graph.h ipv4.h ipv6.h list.c list.h \ - logger.c logger.h meta.c meta.h multicast_device.c net.c net.h \ - net_packet.c net_setup.c net_socket.c netutl.c netutl.h node.c \ - node.h pidfile.c pidfile.h process.c process.h protocol.c \ - protocol.h protocol_auth.c protocol_edge.c protocol_misc.c \ - protocol_key.c protocol_subnet.c proxy.c proxy.h \ - raw_socket_device.c route.c route.h subnet.c subnet.h tincd.c \ - utils.c utils.h xalloc.h $(am__append_1) $(am__append_2) \ - $(am__append_3) $(am__append_4) $(am__append_5) \ - $(am__append_6) $(am__append_7) $(am__append_8) \ - $(am__append_9) -AM_CPPFLAGS = -DCONFDIR=\"$(sysconfdir)\" -DRUNSTATEDIR=\"$(runstatedir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -I $(abs_top_builddir)/ +EXTRA_DIST = linux bsd solaris cygwin mingw raw_socket uml_socket openssl gcrypt +tincd_SOURCES = utils.c getopt.c getopt1.c list.c splay_tree.c \ + dropin.c fake-getaddrinfo.c fake-getnameinfo.c buffer.c conf.c \ + connection.c control.c edge.c graph.c logger.c meta.c net.c \ + net_packet.c net_setup.c net_socket.c netutl.c node.c \ + process.c protocol.c protocol_auth.c protocol_edge.c \ + protocol_misc.c protocol_key.c protocol_subnet.c route.c \ + subnet.c tincd.c $(am__append_1) +nodist_tincd_SOURCES = \ + device.c cipher.c crypto.c ecdh.c ecdsa.c digest.c prf.c rsa.c + +tincctl_SOURCES = \ + utils.c getopt.c getopt1.c dropin.c \ + list.c tincctl.c top.c + +nodist_tincctl_SOURCES = \ + ecdsagen.c rsagen.c + +tincctl_LDADD = $(CURSES_LIBS) +DEFAULT_INCLUDES = +noinst_HEADERS = \ + xalloc.h utils.h getopt.h list.h splay_tree.h dropin.h fake-getaddrinfo.h fake-getnameinfo.h fake-gai-errnos.h ipv6.h ipv4.h ethernet.h \ + buffer.h conf.h connection.h control.h control_common.h device.h edge.h graph.h logger.h meta.h net.h netutl.h node.h process.h \ + protocol.h route.h subnet.h tincctl.h top.h bsd/tunemu.h + +nodist_noinst_HEADERS = \ + cipher.h crypto.h ecdh.h ecdsa.h digest.h prf.h rsa.h ecdsagen.h rsagen.h + +AM_CFLAGS = -DCONFDIR=\"$(sysconfdir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -DSBINDIR=\"$(sbindir)\" all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -371,37 +248,34 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile +.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-sbinPROGRAMS: $(sbin_PROGRAMS) @$(NORMAL_INSTALL) + test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)" @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \ - fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p \ - ; then echo "$$p"; echo "$$p"; else :; fi; \ + while read p p1; do if test -f $$p; \ + then echo "$$p"; echo "$$p"; else :; fi; \ done | \ - sed -e 'p;s,.*/,,;n;h' \ - -e 's|.*|.|' \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ @@ -422,164 +296,120 @@ uninstall-sbinPROGRAMS: @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' \ - `; \ + -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(sbindir)" && rm -f $$files clean-sbinPROGRAMS: -test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS) - -installcheck-sbinPROGRAMS: $(sbin_PROGRAMS) - bad=0; pid=$$$$; list="$(sbin_PROGRAMS)"; for p in $$list; do \ - case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \ - *" $$p "* | *" $(srcdir)/$$p "*) continue;; \ - esac; \ - f=`echo "$$p" | \ - sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - for opt in --help --version; do \ - if "$(DESTDIR)$(sbindir)/$$f" $$opt >c$${pid}_.out \ - 2>c$${pid}_.err &2; bad=1; fi; \ - done; \ - done; rm -f c$${pid}_.???; exit $$bad -linux/$(am__dirstamp): - @$(MKDIR_P) linux - @: > linux/$(am__dirstamp) -linux/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) linux/$(DEPDIR) - @: > linux/$(DEPDIR)/$(am__dirstamp) -linux/device.$(OBJEXT): linux/$(am__dirstamp) \ - linux/$(DEPDIR)/$(am__dirstamp) -bsd/$(am__dirstamp): - @$(MKDIR_P) bsd - @: > bsd/$(am__dirstamp) -bsd/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) bsd/$(DEPDIR) - @: > bsd/$(DEPDIR)/$(am__dirstamp) -bsd/device.$(OBJEXT): bsd/$(am__dirstamp) \ - bsd/$(DEPDIR)/$(am__dirstamp) -bsd/tunemu.$(OBJEXT): bsd/$(am__dirstamp) \ - bsd/$(DEPDIR)/$(am__dirstamp) -solaris/$(am__dirstamp): - @$(MKDIR_P) solaris - @: > solaris/$(am__dirstamp) -solaris/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) solaris/$(DEPDIR) - @: > solaris/$(DEPDIR)/$(am__dirstamp) -solaris/device.$(OBJEXT): solaris/$(am__dirstamp) \ - solaris/$(DEPDIR)/$(am__dirstamp) -mingw/$(am__dirstamp): - @$(MKDIR_P) mingw - @: > mingw/$(am__dirstamp) -mingw/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) mingw/$(DEPDIR) - @: > mingw/$(DEPDIR)/$(am__dirstamp) -mingw/device.$(OBJEXT): mingw/$(am__dirstamp) \ - mingw/$(DEPDIR)/$(am__dirstamp) -cygwin/$(am__dirstamp): - @$(MKDIR_P) cygwin - @: > cygwin/$(am__dirstamp) -cygwin/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) cygwin/$(DEPDIR) - @: > cygwin/$(DEPDIR)/$(am__dirstamp) -cygwin/device.$(OBJEXT): cygwin/$(am__dirstamp) \ - cygwin/$(DEPDIR)/$(am__dirstamp) - -tincd$(EXEEXT): $(tincd_OBJECTS) $(tincd_DEPENDENCIES) $(EXTRA_tincd_DEPENDENCIES) +tincctl$(EXEEXT): $(tincctl_OBJECTS) $(tincctl_DEPENDENCIES) + @rm -f tincctl$(EXEEXT) + $(LINK) $(tincctl_OBJECTS) $(tincctl_LDADD) $(LIBS) +tincd$(EXEEXT): $(tincd_OBJECTS) $(tincd_DEPENDENCIES) @rm -f tincd$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(tincd_OBJECTS) $(tincd_LDADD) $(LIBS) + $(LINK) $(tincd_OBJECTS) $(tincd_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) - -rm -f bsd/*.$(OBJEXT) - -rm -f cygwin/*.$(OBJEXT) - -rm -f linux/*.$(OBJEXT) - -rm -f mingw/*.$(OBJEXT) - -rm -f solaris/*.$(OBJEXT) distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avl_tree.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conf.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dropin.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy_device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edge.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fake-getaddrinfo.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fake-getnameinfo.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/graph.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logger.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/meta.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multicast_device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_packet.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_setup.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_socket.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netutl.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pidfile.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_auth.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_edge.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_key.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_misc.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_subnet.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxy.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw_socket_device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/route.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subnet.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tincd.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uml_device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vde_device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@bsd/$(DEPDIR)/device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@bsd/$(DEPDIR)/tunemu.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@cygwin/$(DEPDIR)/device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@linux/$(DEPDIR)/device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@mingw/$(DEPDIR)/device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@solaris/$(DEPDIR)/device.Po@am__quote@ # am--include-marker - -$(am__depfiles_remade): - @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ - -am--depfiles: $(am__depfiles_remade) +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buffer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cipher.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/control.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypto.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/device.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/digest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dropin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecdh.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecdsa.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecdsagen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edge.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fake-getaddrinfo.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fake-getnameinfo.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/graph.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logger.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/meta.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_packet.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_setup.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_socket.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netutl.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_auth.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_edge.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_key.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_misc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_subnet.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/route.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsa.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsagen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/splay_tree.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subnet.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tincctl.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tincd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/top.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tunemu.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ .c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< +@am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags +tunemu.o: bsd/tunemu.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tunemu.o -MD -MP -MF $(DEPDIR)/tunemu.Tpo -c -o tunemu.o `test -f 'bsd/tunemu.c' || echo '$(srcdir)/'`bsd/tunemu.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tunemu.Tpo $(DEPDIR)/tunemu.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bsd/tunemu.c' object='tunemu.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tunemu.o `test -f 'bsd/tunemu.c' || echo '$(srcdir)/'`bsd/tunemu.c -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) +tunemu.obj: bsd/tunemu.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tunemu.obj -MD -MP -MF $(DEPDIR)/tunemu.Tpo -c -o tunemu.obj `if test -f 'bsd/tunemu.c'; then $(CYGPATH_W) 'bsd/tunemu.c'; else $(CYGPATH_W) '$(srcdir)/bsd/tunemu.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tunemu.Tpo $(DEPDIR)/tunemu.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bsd/tunemu.c' object='tunemu.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tunemu.obj `if test -f 'bsd/tunemu.c'; then $(CYGPATH_W) 'bsd/tunemu.c'; else $(CYGPATH_W) '$(srcdir)/bsd/tunemu.c'; fi` + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ - $(am__define_uniq_tagged_files); \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -591,11 +421,15 @@ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $$unique; \ fi; \ fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique @@ -604,29 +438,11 @@ GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) distdir-am - -distdir-am: $(DISTFILES) +distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -656,9 +472,12 @@ distdir-am: $(DISTFILES) || exit 1; \ fi; \ done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook check-am: all-am check: check-am -all-am: Makefile $(PROGRAMS) +all-am: Makefile $(PROGRAMS) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(sbindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ @@ -673,15 +492,10 @@ install-am: all-am installcheck: installcheck-am install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: @@ -689,16 +503,6 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -rm -f bsd/$(DEPDIR)/$(am__dirstamp) - -rm -f bsd/$(am__dirstamp) - -rm -f cygwin/$(DEPDIR)/$(am__dirstamp) - -rm -f cygwin/$(am__dirstamp) - -rm -f linux/$(DEPDIR)/$(am__dirstamp) - -rm -f linux/$(am__dirstamp) - -rm -f mingw/$(DEPDIR)/$(am__dirstamp) - -rm -f mingw/$(am__dirstamp) - -rm -f solaris/$(DEPDIR)/$(am__dirstamp) - -rm -f solaris/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -708,50 +512,7 @@ clean: clean-am clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am distclean: distclean-am - -rm -f ./$(DEPDIR)/avl_tree.Po - -rm -f ./$(DEPDIR)/conf.Po - -rm -f ./$(DEPDIR)/connection.Po - -rm -f ./$(DEPDIR)/dropin.Po - -rm -f ./$(DEPDIR)/dummy_device.Po - -rm -f ./$(DEPDIR)/edge.Po - -rm -f ./$(DEPDIR)/event.Po - -rm -f ./$(DEPDIR)/fake-getaddrinfo.Po - -rm -f ./$(DEPDIR)/fake-getnameinfo.Po - -rm -f ./$(DEPDIR)/getopt.Po - -rm -f ./$(DEPDIR)/getopt1.Po - -rm -f ./$(DEPDIR)/graph.Po - -rm -f ./$(DEPDIR)/list.Po - -rm -f ./$(DEPDIR)/logger.Po - -rm -f ./$(DEPDIR)/meta.Po - -rm -f ./$(DEPDIR)/multicast_device.Po - -rm -f ./$(DEPDIR)/net.Po - -rm -f ./$(DEPDIR)/net_packet.Po - -rm -f ./$(DEPDIR)/net_setup.Po - -rm -f ./$(DEPDIR)/net_socket.Po - -rm -f ./$(DEPDIR)/netutl.Po - -rm -f ./$(DEPDIR)/node.Po - -rm -f ./$(DEPDIR)/pidfile.Po - -rm -f ./$(DEPDIR)/process.Po - -rm -f ./$(DEPDIR)/protocol.Po - -rm -f ./$(DEPDIR)/protocol_auth.Po - -rm -f ./$(DEPDIR)/protocol_edge.Po - -rm -f ./$(DEPDIR)/protocol_key.Po - -rm -f ./$(DEPDIR)/protocol_misc.Po - -rm -f ./$(DEPDIR)/protocol_subnet.Po - -rm -f ./$(DEPDIR)/proxy.Po - -rm -f ./$(DEPDIR)/raw_socket_device.Po - -rm -f ./$(DEPDIR)/route.Po - -rm -f ./$(DEPDIR)/subnet.Po - -rm -f ./$(DEPDIR)/tincd.Po - -rm -f ./$(DEPDIR)/uml_device.Po - -rm -f ./$(DEPDIR)/utils.Po - -rm -f ./$(DEPDIR)/vde_device.Po - -rm -f bsd/$(DEPDIR)/device.Po - -rm -f bsd/$(DEPDIR)/tunemu.Po - -rm -f cygwin/$(DEPDIR)/device.Po - -rm -f linux/$(DEPDIR)/device.Po - -rm -f mingw/$(DEPDIR)/device.Po - -rm -f solaris/$(DEPDIR)/device.Po + -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -794,53 +555,10 @@ install-ps: install-ps-am install-ps-am: -installcheck-am: installcheck-sbinPROGRAMS +installcheck-am: maintainer-clean: maintainer-clean-am - -rm -f ./$(DEPDIR)/avl_tree.Po - -rm -f ./$(DEPDIR)/conf.Po - -rm -f ./$(DEPDIR)/connection.Po - -rm -f ./$(DEPDIR)/dropin.Po - -rm -f ./$(DEPDIR)/dummy_device.Po - -rm -f ./$(DEPDIR)/edge.Po - -rm -f ./$(DEPDIR)/event.Po - -rm -f ./$(DEPDIR)/fake-getaddrinfo.Po - -rm -f ./$(DEPDIR)/fake-getnameinfo.Po - -rm -f ./$(DEPDIR)/getopt.Po - -rm -f ./$(DEPDIR)/getopt1.Po - -rm -f ./$(DEPDIR)/graph.Po - -rm -f ./$(DEPDIR)/list.Po - -rm -f ./$(DEPDIR)/logger.Po - -rm -f ./$(DEPDIR)/meta.Po - -rm -f ./$(DEPDIR)/multicast_device.Po - -rm -f ./$(DEPDIR)/net.Po - -rm -f ./$(DEPDIR)/net_packet.Po - -rm -f ./$(DEPDIR)/net_setup.Po - -rm -f ./$(DEPDIR)/net_socket.Po - -rm -f ./$(DEPDIR)/netutl.Po - -rm -f ./$(DEPDIR)/node.Po - -rm -f ./$(DEPDIR)/pidfile.Po - -rm -f ./$(DEPDIR)/process.Po - -rm -f ./$(DEPDIR)/protocol.Po - -rm -f ./$(DEPDIR)/protocol_auth.Po - -rm -f ./$(DEPDIR)/protocol_edge.Po - -rm -f ./$(DEPDIR)/protocol_key.Po - -rm -f ./$(DEPDIR)/protocol_misc.Po - -rm -f ./$(DEPDIR)/protocol_subnet.Po - -rm -f ./$(DEPDIR)/proxy.Po - -rm -f ./$(DEPDIR)/raw_socket_device.Po - -rm -f ./$(DEPDIR)/route.Po - -rm -f ./$(DEPDIR)/subnet.Po - -rm -f ./$(DEPDIR)/tincd.Po - -rm -f ./$(DEPDIR)/uml_device.Po - -rm -f ./$(DEPDIR)/utils.Po - -rm -f ./$(DEPDIR)/vde_device.Po - -rm -f bsd/$(DEPDIR)/device.Po - -rm -f bsd/$(DEPDIR)/tunemu.Po - -rm -f cygwin/$(DEPDIR)/device.Po - -rm -f linux/$(DEPDIR)/device.Po - -rm -f mingw/$(DEPDIR)/device.Po - -rm -f solaris/$(DEPDIR)/device.Po + -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -860,22 +578,22 @@ uninstall-am: uninstall-sbinPROGRAMS .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ - clean-generic clean-sbinPROGRAMS cscopelist-am ctags ctags-am \ - distclean distclean-compile distclean-generic distclean-tags \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-sbinPROGRAMS install-strip installcheck \ - installcheck-am installcheck-sbinPROGRAMS installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am uninstall-sbinPROGRAMS +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-sbinPROGRAMS ctags dist-hook distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-sbinPROGRAMS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-sbinPROGRAMS -.PRECIOUS: Makefile +dist-hook: + rm -f `find . -type l` # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/src/avl_tree.c b/src/avl_tree.c deleted file mode 100644 index 96d3d43..0000000 --- a/src/avl_tree.c +++ /dev/null @@ -1,757 +0,0 @@ -/* - avl_tree.c -- avl_ tree and linked list convenience - Copyright (C) 1998 Michael H. Buselli - 2000-2005 Ivo Timmermans, - 2000-2015 Guus Sliepen - 2000-2005 Wessel Dankers - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Original AVL tree library by Michael H. Buselli . - - Modified 2000-11-28 by Wessel Dankers to use counts - instead of depths, to add the ->next and ->prev and to generally obfuscate - the code. Mail me if you found a bug. - - Cleaned up and incorporated some of the ideas from the red-black tree - library for inclusion into tinc (https://www.tinc-vpn.org/) by - Guus Sliepen . -*/ - -#include "system.h" - -#include "avl_tree.h" -#include "xalloc.h" - -#ifdef AVL_COUNT -#define AVL_NODE_COUNT(n) ((n) ? (n)->count : 0) -#define AVL_L_COUNT(n) (AVL_NODE_COUNT((n)->left)) -#define AVL_R_COUNT(n) (AVL_NODE_COUNT((n)->right)) -#define AVL_CALC_COUNT(n) (AVL_L_COUNT(n) + AVL_R_COUNT(n) + 1) -#endif - -#ifdef AVL_DEPTH -#define AVL_NODE_DEPTH(n) ((n) ? (n)->depth : 0) -#define L_AVL_DEPTH(n) (AVL_NODE_DEPTH((n)->left)) -#define R_AVL_DEPTH(n) (AVL_NODE_DEPTH((n)->right)) -#define AVL_CALC_DEPTH(n) ((L_AVL_DEPTH(n)>R_AVL_DEPTH(n)?L_AVL_DEPTH(n):R_AVL_DEPTH(n)) + 1) -#endif - -#ifndef AVL_DEPTH -static int lg(unsigned int u) __attribute__((__const__)); - -static int lg(unsigned int u) { - int r = 1; - - if(!u) { - return 0; - } - - if(u & 0xffff0000) { - u >>= 16; - r += 16; - } - - if(u & 0x0000ff00) { - u >>= 8; - r += 8; - } - - if(u & 0x000000f0) { - u >>= 4; - r += 4; - } - - if(u & 0x0000000c) { - u >>= 2; - r += 2; - } - - if(u & 0x00000002) { - r++; - } - - return r; -} -#endif - -/* Internal helper functions */ - -static int avl_check_balance(const avl_node_t *node) { -#ifdef AVL_DEPTH - int d; - - d = R_AVL_DEPTH(node) - L_AVL_DEPTH(node); - - return d < -1 ? -1 : d > 1 ? 1 : 0; -#else - /* int d; - * d = lg(AVL_R_COUNT(node)) - lg(AVL_L_COUNT(node)); - * d = d<-1?-1:d>1?1:0; - */ - int pl, r; - - pl = lg(AVL_L_COUNT(node)); - r = AVL_R_COUNT(node); - - if(r >> pl + 1) { - return 1; - } - - if(pl < 2 || r >> pl - 2) { - return 0; - } - - return -1; -#endif -} - -static void avl_rebalance(avl_tree_t *tree, avl_node_t *node) { - avl_node_t *child; - avl_node_t *gchild; - avl_node_t *parent; - avl_node_t **superparent; - - while(node) { - parent = node->parent; - - superparent = - parent ? node == - parent->left ? &parent->left : &parent->right : &tree->root; - - switch(avl_check_balance(node)) { - case -1: - child = node->left; -#ifdef AVL_DEPTH - - if(L_AVL_DEPTH(child) >= R_AVL_DEPTH(child)) { -#else - - if(AVL_L_COUNT(child) >= AVL_R_COUNT(child)) { -#endif - node->left = child->right; - - if(node->left) { - node->left->parent = node; - } - - child->right = node; - node->parent = child; - *superparent = child; - child->parent = parent; -#ifdef AVL_COUNT - node->count = AVL_CALC_COUNT(node); - child->count = AVL_CALC_COUNT(child); -#endif -#ifdef AVL_DEPTH - node->depth = AVL_CALC_DEPTH(node); - child->depth = AVL_CALC_DEPTH(child); -#endif - } else { - gchild = child->right; - node->left = gchild->right; - - if(node->left) { - node->left->parent = node; - } - - child->right = gchild->left; - - if(child->right) { - child->right->parent = child; - } - - gchild->right = node; - - gchild->right->parent = gchild; - gchild->left = child; - - gchild->left->parent = gchild; - - *superparent = gchild; - gchild->parent = parent; -#ifdef AVL_COUNT - node->count = AVL_CALC_COUNT(node); - child->count = AVL_CALC_COUNT(child); - gchild->count = AVL_CALC_COUNT(gchild); -#endif -#ifdef AVL_DEPTH - node->depth = AVL_CALC_DEPTH(node); - child->depth = AVL_CALC_DEPTH(child); - gchild->depth = AVL_CALC_DEPTH(gchild); -#endif - } - - break; - - case 1: - child = node->right; -#ifdef AVL_DEPTH - - if(R_AVL_DEPTH(child) >= L_AVL_DEPTH(child)) { -#else - - if(AVL_R_COUNT(child) >= AVL_L_COUNT(child)) { -#endif - node->right = child->left; - - if(node->right) { - node->right->parent = node; - } - - child->left = node; - node->parent = child; - *superparent = child; - child->parent = parent; -#ifdef AVL_COUNT - node->count = AVL_CALC_COUNT(node); - child->count = AVL_CALC_COUNT(child); -#endif -#ifdef AVL_DEPTH - node->depth = AVL_CALC_DEPTH(node); - child->depth = AVL_CALC_DEPTH(child); -#endif - } else { - gchild = child->left; - node->right = gchild->left; - - if(node->right) { - node->right->parent = node; - } - - child->left = gchild->right; - - if(child->left) { - child->left->parent = child; - } - - gchild->left = node; - - gchild->left->parent = gchild; - gchild->right = child; - - gchild->right->parent = gchild; - - *superparent = gchild; - gchild->parent = parent; -#ifdef AVL_COUNT - node->count = AVL_CALC_COUNT(node); - child->count = AVL_CALC_COUNT(child); - gchild->count = AVL_CALC_COUNT(gchild); -#endif -#ifdef AVL_DEPTH - node->depth = AVL_CALC_DEPTH(node); - child->depth = AVL_CALC_DEPTH(child); - gchild->depth = AVL_CALC_DEPTH(gchild); -#endif - } - - break; - - default: -#ifdef AVL_COUNT - node->count = AVL_CALC_COUNT(node); -#endif -#ifdef AVL_DEPTH - node->depth = AVL_CALC_DEPTH(node); -#endif - } - - node = parent; - } -} - -/* (De)constructors */ - -avl_tree_t *avl_alloc_tree(avl_compare_t compare, avl_action_t delete) { - avl_tree_t *tree; - - tree = xmalloc_and_zero(sizeof(avl_tree_t)); - tree->compare = compare; - tree->delete = delete; - - return tree; -} - -void avl_free_tree(avl_tree_t *tree) { - free(tree); -} - -avl_node_t *avl_alloc_node(void) { - return xmalloc_and_zero(sizeof(avl_node_t)); -} - -void avl_free_node(avl_tree_t *tree, avl_node_t *node) { - if(node->data && tree->delete) { - tree->delete(node->data); - } - - free(node); -} - -/* Searching */ - -void *avl_search(const avl_tree_t *tree, const void *data) { - avl_node_t *node; - - node = avl_search_node(tree, data); - - return node ? node->data : NULL; -} - -void *avl_search_closest(const avl_tree_t *tree, const void *data, int *result) { - avl_node_t *node; - - node = avl_search_closest_node(tree, data, result); - - return node ? node->data : NULL; -} - -void *avl_search_closest_smaller(const avl_tree_t *tree, const void *data) { - avl_node_t *node; - - node = avl_search_closest_smaller_node(tree, data); - - return node ? node->data : NULL; -} - -void *avl_search_closest_greater(const avl_tree_t *tree, const void *data) { - avl_node_t *node; - - node = avl_search_closest_greater_node(tree, data); - - return node ? node->data : NULL; -} - -avl_node_t *avl_search_node(const avl_tree_t *tree, const void *data) { - avl_node_t *node; - int result; - - node = avl_search_closest_node(tree, data, &result); - - return result ? NULL : node; -} - -avl_node_t *avl_search_closest_node(const avl_tree_t *tree, const void *data, - int *result) { - avl_node_t *node; - int c; - - node = tree->root; - - if(!node) { - if(result) { - *result = 0; - } - - return NULL; - } - - for(;;) { - c = tree->compare(data, node->data); - - if(c < 0) { - if(node->left) { - node = node->left; - } else { - if(result) { - *result = -1; - } - - break; - } - } else if(c > 0) { - if(node->right) { - node = node->right; - } else { - if(result) { - *result = 1; - } - - break; - } - } else { - if(result) { - *result = 0; - } - - break; - } - } - - return node; -} - -avl_node_t *avl_search_closest_smaller_node(const avl_tree_t *tree, - const void *data) { - avl_node_t *node; - int result; - - node = avl_search_closest_node(tree, data, &result); - - if(result < 0) { - node = node->prev; - } - - return node; -} - -avl_node_t *avl_search_closest_greater_node(const avl_tree_t *tree, - const void *data) { - avl_node_t *node; - int result; - - node = avl_search_closest_node(tree, data, &result); - - if(result > 0) { - node = node->next; - } - - return node; -} - -/* Insertion and deletion */ - -avl_node_t *avl_insert(avl_tree_t *tree, void *data) { - avl_node_t *closest, *new; - int result; - - if(!tree->root) { - new = avl_alloc_node(); - new->data = data; - avl_insert_top(tree, new); - } else { - closest = avl_search_closest_node(tree, data, &result); - - switch(result) { - case -1: - new = avl_alloc_node(); - new->data = data; - avl_insert_before(tree, closest, new); - break; - - case 1: - new = avl_alloc_node(); - new->data = data; - avl_insert_after(tree, closest, new); - break; - - default: - return NULL; - } - } - -#ifdef AVL_COUNT - new->count = 1; -#endif -#ifdef AVL_DEPTH - new->depth = 1; -#endif - - return new; -} - -avl_node_t *avl_insert_node(avl_tree_t *tree, avl_node_t *node) { - avl_node_t *closest; - int result; - - if(!tree->root) { - avl_insert_top(tree, node); - } else { - closest = avl_search_closest_node(tree, node->data, &result); - - switch(result) { - case -1: - avl_insert_before(tree, closest, node); - break; - - case 1: - avl_insert_after(tree, closest, node); - break; - - case 0: - return NULL; - } - } - -#ifdef AVL_COUNT - node->count = 1; -#endif -#ifdef AVL_DEPTH - node->depth = 1; -#endif - - return node; -} - -void avl_insert_top(avl_tree_t *tree, avl_node_t *node) { - node->prev = node->next = node->parent = NULL; - tree->head = tree->tail = tree->root = node; -} - -void avl_insert_before(avl_tree_t *tree, avl_node_t *before, - avl_node_t *node) { - if(!before) { - if(tree->tail) { - avl_insert_after(tree, tree->tail, node); - } else { - avl_insert_top(tree, node); - } - - return; - } - - node->next = before; - node->parent = before; - node->prev = before->prev; - - if(before->left) { - avl_insert_after(tree, before->prev, node); - return; - } - - if(before->prev) { - before->prev->next = node; - } else { - tree->head = node; - } - - before->prev = node; - before->left = node; - - avl_rebalance(tree, before); -} - -void avl_insert_after(avl_tree_t *tree, avl_node_t *after, avl_node_t *node) { - if(!after) { - if(tree->head) { - avl_insert_before(tree, tree->head, node); - } else { - avl_insert_top(tree, node); - } - - return; - } - - if(after->right) { - avl_insert_before(tree, after->next, node); - return; - } - - node->prev = after; - node->parent = after; - node->next = after->next; - - if(after->next) { - after->next->prev = node; - } else { - tree->tail = node; - } - - after->next = node; - after->right = node; - - avl_rebalance(tree, after); -} - -avl_node_t *avl_unlink(avl_tree_t *tree, void *data) { - avl_node_t *node; - - node = avl_search_node(tree, data); - - if(node) { - avl_unlink_node(tree, node); - } - - return node; -} - -void avl_unlink_node(avl_tree_t *tree, avl_node_t *node) { - avl_node_t *parent; - avl_node_t **superparent; - avl_node_t *subst, *left, *right; - avl_node_t *balnode; - - if(node->prev) { - node->prev->next = node->next; - } else { - tree->head = node->next; - } - - if(node->next) { - node->next->prev = node->prev; - } else { - tree->tail = node->prev; - } - - parent = node->parent; - - superparent = - parent ? node == - parent->left ? &parent->left : &parent->right : &tree->root; - - left = node->left; - right = node->right; - - if(!left) { - *superparent = right; - - if(right) { - right->parent = parent; - } - - balnode = parent; - } else if(!right) { - *superparent = left; - left->parent = parent; - balnode = parent; - } else { - subst = node->prev; - - if(!subst) { // This only happens if node is not actually in a tree at all. - abort(); - } - - if(subst == left) { - balnode = subst; - } else { - balnode = subst->parent; - balnode->right = subst->left; - - if(balnode->right) { - balnode->right->parent = balnode; - } - - subst->left = left; - left->parent = subst; - } - - subst->right = right; - subst->parent = parent; - right->parent = subst; - *superparent = subst; - } - - avl_rebalance(tree, balnode); - - node->next = node->prev = node->parent = node->left = node->right = NULL; - -#ifdef AVL_COUNT - node->count = 0; -#endif -#ifdef AVL_DEPTH - node->depth = 0; -#endif -} - -void avl_delete_node(avl_tree_t *tree, avl_node_t *node) { - avl_unlink_node(tree, node); - avl_free_node(tree, node); -} - -void avl_delete(avl_tree_t *tree, void *data) { - avl_node_t *node; - - node = avl_search_node(tree, data); - - if(node) { - avl_delete_node(tree, node); - } -} - -/* Fast tree cleanup */ - -void avl_delete_tree(avl_tree_t *tree) { - avl_node_t *node, *next; - - for(node = tree->head; node; node = next) { - next = node->next; - avl_free_node(tree, node); - } - - avl_free_tree(tree); -} - -/* Tree walking */ - -void avl_foreach(const avl_tree_t *tree, avl_action_t action) { - avl_node_t *node, *next; - - for(node = tree->head; node; node = next) { - next = node->next; - action(node->data); - } -} - -void avl_foreach_node(const avl_tree_t *tree, avl_action_t action) { - avl_node_t *node, *next; - - for(node = tree->head; node; node = next) { - next = node->next; - action(node); - } -} - -/* Indexing */ - -#ifdef AVL_COUNT -unsigned int avl_count(const avl_tree_t *tree) { - return AVL_NODE_COUNT(tree->root); -} - -avl_node_t *avl_get_node(const avl_tree_t *tree, unsigned int index) { - avl_node_t *node; - unsigned int c; - - node = tree->root; - - while(node) { - c = AVL_L_COUNT(node); - - if(index < c) { - node = node->left; - } else if(index > c) { - node = node->right; - index -= c + 1; - } else { - return node; - } - } - - return NULL; -} - -unsigned int avl_index(const avl_node_t *node) { - avl_node_t *next; - unsigned int index; - - index = AVL_L_COUNT(node); - - while((next = node->parent)) { - if(node == next->right) { - index += AVL_L_COUNT(next) + 1; - } - - node = next; - } - - return index; -} -#endif -#ifdef AVL_DEPTH -unsigned int avl_depth(const avl_tree_t *tree) { - return AVL_NODE_DEPTH(tree->root); -} -#endif diff --git a/src/avl_tree.h b/src/avl_tree.h deleted file mode 100644 index e8cefcf..0000000 --- a/src/avl_tree.h +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef TINC_AVL_TREE_H -#define TINC_AVL_TREE_H - -/* - avl_tree.h -- header file for avl_tree.c - Copyright (C) 1998 Michael H. Buselli - 2000-2005 Ivo Timmermans, - 2000-2006 Guus Sliepen - 2000-2005 Wessel Dankers - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - Original AVL tree library by Michael H. Buselli . - - Modified 2000-11-28 by Wessel Dankers to use counts - instead of depths, to add the ->next and ->prev and to generally obfuscate - the code. Mail me if you found a bug. - - Cleaned up and incorporated some of the ideas from the red-black tree - library for inclusion into tinc (https://www.tinc-vpn.org/) by - Guus Sliepen . -*/ - -#ifndef AVL_DEPTH -#ifndef AVL_COUNT -#define AVL_DEPTH -#endif -#endif - -typedef struct avl_node_t { - - /* Linked list part */ - - struct avl_node_t *next; - struct avl_node_t *prev; - - /* Tree part */ - - struct avl_node_t *parent; - struct avl_node_t *left; - struct avl_node_t *right; - -#ifdef AVL_COUNT - unsigned int count; -#endif -#ifdef AVL_DEPTH - unsigned char depth; -#endif - - /* Payload */ - - void *data; - -} avl_node_t; - -typedef int (*avl_compare_t)(const void *data1, const void *data2); -typedef void (*avl_action_t)(const void *data); -typedef void (*avl_action_node_t)(const avl_node_t *node); - -typedef struct avl_tree_t { - - /* Linked list part */ - - avl_node_t *head; - avl_node_t *tail; - - /* Tree part */ - - avl_node_t *root; - - avl_compare_t compare; - avl_action_t delete; - -} avl_tree_t; - -/* (De)constructors */ - -extern avl_tree_t *avl_alloc_tree(avl_compare_t compare, avl_action_t delete); -extern void avl_free_tree(avl_tree_t *tree); - -extern avl_node_t *avl_alloc_node(void); -extern void avl_free_node(avl_tree_t *tree, avl_node_t *node); - -/* Insertion and deletion */ - -extern avl_node_t *avl_insert(avl_tree_t *tree, void *data); -extern avl_node_t *avl_insert_node(avl_tree_t *tree, avl_node_t *node); - -extern void avl_insert_top(avl_tree_t *tree, avl_node_t *node); -extern void avl_insert_before(avl_tree_t *tree, avl_node_t *before, avl_node_t *node); -extern void avl_insert_after(avl_tree_t *tree, avl_node_t *after, avl_node_t *node); - -extern avl_node_t *avl_unlink(avl_tree_t *tree, void *data); -extern void avl_unlink_node(avl_tree_t *tree, avl_node_t *node); -extern void avl_delete(avl_tree_t *tree, void *data); -extern void avl_delete_node(avl_tree_t *tree, avl_node_t *node); - -/* Fast tree cleanup */ - -extern void avl_delete_tree(avl_tree_t *tree); - -/* Searching */ - -extern void *avl_search(const avl_tree_t *tree, const void *data); -extern void *avl_search_closest(const avl_tree_t *tree, const void *data, int *result); -extern void *avl_search_closest_smaller(const avl_tree_t *tree, const void *data); -extern void *avl_search_closest_greater(const avl_tree_t *tree, const void *data); - -extern avl_node_t *avl_search_node(const avl_tree_t *tree, const void *data); -extern avl_node_t *avl_search_closest_node(const avl_tree_t *tree, const void *data, int *result); -extern avl_node_t *avl_search_closest_smaller_node(const avl_tree_t *tree, const void *data); -extern avl_node_t *avl_search_closest_greater_node(const avl_tree_t *tree, const void *data); - -/* Tree walking */ - -extern void avl_foreach(const avl_tree_t *tree, avl_action_t action); -extern void avl_foreach_node(const avl_tree_t *tree, avl_action_t action); - -/* Indexing */ - -#ifdef AVL_COUNT -extern unsigned int avl_count(const avl_tree_t *tree); -extern avl_node_t *avl_get_node(const avl_tree_t *tree, unsigned int index); -extern unsigned int avl_index(const avl_node_t *node); -#endif -#ifdef AVL_DEPTH -extern unsigned int avl_depth(const avl_tree_t *tree); -#endif - -#endif diff --git a/src/bsd/device.c b/src/bsd/device.c index 23d6d69..9c3009d 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction BSD tun/tap device Copyright (C) 2001-2005 Ivo Timmermans, - 2001-2016 Guus Sliepen + 2001-2011 Guus Sliepen 2009 Grzegorz Dymarek This program is free software; you can redistribute it and/or modify @@ -19,46 +19,38 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "../system.h" +#include "system.h" -#include "../conf.h" -#include "../device.h" -#include "../logger.h" -#include "../net.h" -#include "../route.h" -#include "../utils.h" -#include "../xalloc.h" +#include "conf.h" +#include "device.h" +#include "logger.h" +#include "net.h" +#include "route.h" +#include "utils.h" +#include "xalloc.h" -#ifdef ENABLE_TUNEMU -#include "tunemu.h" +#ifdef HAVE_TUNEMU +#include "bsd/tunemu.h" #endif -#ifdef HAVE_NET_IF_UTUN_H -#include -#include -#include -#endif - -#define DEFAULT_TUN_DEVICE "/dev/tun0" -#define DEFAULT_TAP_DEVICE "/dev/tap0" +#define DEFAULT_DEVICE "/dev/tun0" typedef enum device_type { DEVICE_TYPE_TUN, DEVICE_TYPE_TUNIFHEAD, DEVICE_TYPE_TAP, -#ifdef ENABLE_TUNEMU +#ifdef HAVE_TUNEMU DEVICE_TYPE_TUNEMU, #endif - DEVICE_TYPE_UTUN, } device_type_t; int device_fd = -1; char *device = NULL; char *iface = NULL; -static const char *device_info = "OS X utun device"; +static char *device_info = NULL; static uint64_t device_total_in = 0; static uint64_t device_total_out = 0; -#if defined(ENABLE_TUNEMU) +#if defined(TUNEMU) static device_type_t device_type = DEVICE_TYPE_TUNEMU; #elif defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD) || defined(HAVE_DRAGONFLY) static device_type_t device_type = DEVICE_TYPE_TUNIFHEAD; @@ -66,140 +58,47 @@ static device_type_t device_type = DEVICE_TYPE_TUNIFHEAD; static device_type_t device_type = DEVICE_TYPE_TUN; #endif -#ifdef HAVE_NET_IF_UTUN_H -static bool setup_utun(void) { - device_fd = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL); - - if(device_fd == -1) { - logger(LOG_ERR, "Could not open PF_SYSTEM socket: %s\n", strerror(errno)); - return false; - } - - struct ctl_info info = {}; - - strlcpy(info.ctl_name, UTUN_CONTROL_NAME, sizeof(info.ctl_name)); - - if(ioctl(device_fd, CTLIOCGINFO, &info) == -1) { - logger(LOG_ERR, "ioctl(CTLIOCGINFO) failed: %s", strerror(errno)); - return false; - } - - int unit = -1; - char *p = strstr(device, "utun"), *e = NULL; - - if(p) { - unit = strtol(p + 4, &e, 10); - - if(!e) { - unit = -1; - } - } - - struct sockaddr_ctl sc = { - .sc_id = info.ctl_id, - .sc_len = sizeof(sc), - .sc_family = AF_SYSTEM, - .ss_sysaddr = AF_SYS_CONTROL, - .sc_unit = unit + 1, - }; - - if(connect(device_fd, (struct sockaddr *)&sc, sizeof(sc)) == -1) { - logger(LOG_ERR, "Could not connect utun socket: %s\n", strerror(errno)); - return false; - } - - char name[64] = ""; - socklen_t len = sizeof(name); - - if(getsockopt(device_fd, SYSPROTO_CONTROL, UTUN_OPT_IFNAME, name, &len)) { - iface = xstrdup(device); - } else { - iface = xstrdup(name); - } - - logger(LOG_INFO, "%s is a %s", device, device_info); - - return true; -} -#endif - -static bool setup_device(void) { - // Find out which device file to open - - if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { - if(routing_mode == RMODE_ROUTER) { - device = xstrdup(DEFAULT_TUN_DEVICE); - } else { - device = xstrdup(DEFAULT_TAP_DEVICE); - } - } - - // Find out if it's supposed to be a tun or a tap device - +bool setup_device(void) { char *type; + if(!get_config_string(lookup_config(config_tree, "Device"), &device)) + device = xstrdup(DEFAULT_DEVICE); + + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) + iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device); + if(get_config_string(lookup_config(config_tree, "DeviceType"), &type)) { if(!strcasecmp(type, "tun")) - /* use default */; - -#ifdef ENABLE_TUNEMU - else if(!strcasecmp(type, "tunemu")) { + /* use default */; +#ifdef HAVE_TUNEMU + else if(!strcasecmp(type, "tunemu")) device_type = DEVICE_TYPE_TUNEMU; - } - #endif -#ifdef HAVE_NET_IF_UTUN_H - else if(!strcasecmp(type, "utun")) { - device_type = DEVICE_TYPE_UTUN; - } - -#endif - else if(!strcasecmp(type, "tunnohead")) { + else if(!strcasecmp(type, "tunnohead")) device_type = DEVICE_TYPE_TUN; - } else if(!strcasecmp(type, "tunifhead")) { + else if(!strcasecmp(type, "tunifhead")) device_type = DEVICE_TYPE_TUNIFHEAD; - } else if(!strcasecmp(type, "tap")) { + else if(!strcasecmp(type, "tap")) device_type = DEVICE_TYPE_TAP; - } else { + else { logger(LOG_ERR, "Unknown device type %s!", type); return false; } } else { -#ifdef HAVE_NET_IF_UTUN_H - - if(strncmp(device, "utun", 4) == 0 || strncmp(device, "/dev/utun", 9) == 0) { - device_type = DEVICE_TYPE_UTUN; - } else -#endif - if(strstr(device, "tap") || routing_mode != RMODE_ROUTER) { - device_type = DEVICE_TYPE_TAP; - } + if(strstr(device, "tap") || routing_mode != RMODE_ROUTER) + device_type = DEVICE_TYPE_TAP; } - if(routing_mode == RMODE_SWITCH && device_type != DEVICE_TYPE_TAP) { - logger(LOG_ERR, "Only tap devices support switch mode!"); - return false; - } - - // Open the device - switch(device_type) { -#ifdef ENABLE_TUNEMU - - case DEVICE_TYPE_TUNEMU: { - char dynamic_name[256] = ""; - device_fd = tunemu_open(dynamic_name); - } - break; +#ifdef HAVE_TUNEMU + case DEVICE_TYPE_TUNEMU: { + char dynamic_name[256] = ""; + device_fd = tunemu_open(dynamic_name); + } + break; #endif -#ifdef HAVE_NET_IF_UTUN_H - - case DEVICE_TYPE_UTUN: - return setup_utun(); -#endif - - default: - device_fd = open(device, O_RDWR | O_NONBLOCK); + default: + device_fd = open(device, O_RDWR | O_NONBLOCK); } if(device_fd < 0) { @@ -207,307 +106,244 @@ static bool setup_device(void) { return false; } -#ifdef FD_CLOEXEC - fcntl(device_fd, F_SETFD, FD_CLOEXEC); -#endif - - // Guess what the corresponding interface is called - - char *realname = NULL; - -#if defined(HAVE_FDEVNAME) - realname = fdevname(device_fd); -#elif defined(HAVE_DEVNAME) - struct stat buf; - - if(!fstat(device_fd, &buf)) { - realname = devname(buf.st_rdev, S_IFCHR); - } - -#endif - - if(!realname) { - realname = device; - } - - if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) { - iface = xstrdup(strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname); - } else if(strcmp(iface, strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname)) { - logger(LOG_WARNING, "Warning: Interface does not match Device. $INTERFACE might be set incorrectly."); - } - - // Configure the device as best as we can - switch(device_type) { - default: - device_type = DEVICE_TYPE_TUN; - - case DEVICE_TYPE_TUN: + default: + device_type = DEVICE_TYPE_TUN; + case DEVICE_TYPE_TUN: #ifdef TUNSIFHEAD - { + { const int zero = 0; - - if(ioctl(device_fd, TUNSIFHEAD, &zero, sizeof(zero)) == -1) { + if(ioctl(device_fd, TUNSIFHEAD, &zero, sizeof zero) == -1) { logger(LOG_ERR, "System call `%s' failed: %s", "ioctl", strerror(errno)); return false; } } - #endif #if defined(TUNSIFMODE) && defined(IFF_BROADCAST) && defined(IFF_MULTICAST) { const int mode = IFF_BROADCAST | IFF_MULTICAST; - ioctl(device_fd, TUNSIFMODE, &mode, sizeof(mode)); + ioctl(device_fd, TUNSIFMODE, &mode, sizeof mode); } #endif - device_info = "Generic BSD tun device"; - break; - - case DEVICE_TYPE_TUNIFHEAD: + device_info = "Generic BSD tun device"; + break; + case DEVICE_TYPE_TUNIFHEAD: #ifdef TUNSIFHEAD { const int one = 1; - - if(ioctl(device_fd, TUNSIFHEAD, &one, sizeof(one)) == -1) { + if(ioctl(device_fd, TUNSIFHEAD, &one, sizeof one) == -1) { logger(LOG_ERR, "System call `%s' failed: %s", "ioctl", strerror(errno)); return false; } } - #endif #if defined(TUNSIFMODE) && defined(IFF_BROADCAST) && defined(IFF_MULTICAST) { - const int mode = IFF_BROADCAST | IFF_MULTICAST; - ioctl(device_fd, TUNSIFMODE, &mode, sizeof(mode)); + const int mode = IFF_BROADCAST | IFF_MULTICAST; + ioctl(device_fd, TUNSIFMODE, &mode, sizeof mode); } #endif - device_info = "Generic BSD tun device"; - break; - - case DEVICE_TYPE_TAP: - if(routing_mode == RMODE_ROUTER) { - overwrite_mac = true; - } - - device_info = "Generic BSD tap device"; + device_info = "Generic BSD tun device"; + break; + case DEVICE_TYPE_TAP: + if(routing_mode == RMODE_ROUTER) + overwrite_mac = true; + device_info = "Generic BSD tap device"; #ifdef TAPGIFNAME - { - struct ifreq ifr; - - if(ioctl(device_fd, TAPGIFNAME, (void *)&ifr) == 0) { - if(iface) { - free(iface); + { + struct ifreq ifr; + if(ioctl(device_fd, TAPGIFNAME, (void*)&ifr) == 0) { + if(iface) + free(iface); + iface = xstrdup(ifr.ifr_name); } - - iface = xstrdup(ifr.ifr_name); } - } - + #endif - break; -#ifdef ENABLE_TUNEMU - - case DEVICE_TYPE_TUNEMU: - device_info = "BSD tunemu device"; - break; + break; +#ifdef HAVE_TUNEMU + case DEVICE_TYPE_TUNEMU: + device_info = "BSD tunemu device"; + break; #endif } -#ifdef SIOCGIFADDR - - if(overwrite_mac) { - ioctl(device_fd, SIOCGIFADDR, mymac.x); - } - -#endif - logger(LOG_INFO, "%s is a %s", device, device_info); return true; } -static void close_device(void) { +void close_device(void) { switch(device_type) { -#ifdef ENABLE_TUNEMU - - case DEVICE_TYPE_TUNEMU: - tunemu_close(device_fd); - break; +#ifdef HAVE_TUNEMU + case DEVICE_TYPE_TUNEMU: + tunemu_close(device_fd); + break; #endif - - default: - close(device_fd); + default: + close(device_fd); } free(device); free(iface); } -static bool read_packet(vpn_packet_t *packet) { - int lenin; +bool read_packet(vpn_packet_t *packet) { + int inlen; switch(device_type) { - case DEVICE_TYPE_TUN: -#ifdef ENABLE_TUNEMU - case DEVICE_TYPE_TUNEMU: - if(device_type == DEVICE_TYPE_TUNEMU) { - lenin = tunemu_read(device_fd, packet->data + 14, MTU - 14); - } else + case DEVICE_TYPE_TUN: +#ifdef HAVE_TUNEMU + case DEVICE_TYPE_TUNEMU: + if(device_type == DEVICE_TYPE_TUNEMU) + inlen = tunemu_read(device_fd, packet->data + 14, MTU - 14); + else #endif - lenin = read(device_fd, packet->data + 14, MTU - 14); + inlen = read(device_fd, packet->data + 14, MTU - 14); - if(lenin <= 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, - device, strerror(errno)); - return false; - } + if(inlen <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, + device, strerror(errno)); + return false; + } - switch(packet->data[14] >> 4) { - case 4: - packet->data[12] = 0x08; - packet->data[13] = 0x00; + switch(packet->data[14] >> 4) { + case 4: + packet->data[12] = 0x08; + packet->data[13] = 0x00; + break; + case 6: + packet->data[12] = 0x86; + packet->data[13] = 0xDD; + break; + default: + ifdebug(TRAFFIC) logger(LOG_ERR, + "Unknown IP version %d while reading packet from %s %s", + packet->data[14] >> 4, device_info, device); + return false; + } + + packet->len = inlen + 14; break; - case 6: - packet->data[12] = 0x86; - packet->data[13] = 0xDD; + case DEVICE_TYPE_TUNIFHEAD: { + u_int32_t type; + struct iovec vector[2] = {{&type, sizeof type}, {packet->data + 14, MTU - 14}}; + + if((inlen = readv(device_fd, vector, 2)) <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, + device, strerror(errno)); + return false; + } + + switch (ntohl(type)) { + case AF_INET: + packet->data[12] = 0x08; + packet->data[13] = 0x00; + break; + + case AF_INET6: + packet->data[12] = 0x86; + packet->data[13] = 0xDD; + break; + + default: + ifdebug(TRAFFIC) logger(LOG_ERR, + "Unknown address family %x while reading packet from %s %s", + ntohl(type), device_info, device); + return false; + } + + packet->len = inlen + 10; + break; + } + + case DEVICE_TYPE_TAP: + if((inlen = read(device_fd, packet->data, MTU)) <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, + device, strerror(errno)); + return false; + } + + packet->len = inlen; break; default: - ifdebug(TRAFFIC) logger(LOG_ERR, - "Unknown IP version %d while reading packet from %s %s", - packet->data[14] >> 4, device_info, device); return false; - } - - memset(packet->data, 0, 12); - packet->len = lenin + 14; - break; - - case DEVICE_TYPE_UTUN: - case DEVICE_TYPE_TUNIFHEAD: { - if((lenin = read(device_fd, packet->data + 10, MTU - 10)) <= 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, - device, strerror(errno)); - return false; - } - - switch(packet->data[14] >> 4) { - case 4: - packet->data[12] = 0x08; - packet->data[13] = 0x00; - break; - - case 6: - packet->data[12] = 0x86; - packet->data[13] = 0xDD; - break; - - default: - ifdebug(TRAFFIC) logger(LOG_ERR, - "Unknown IP version %d while reading packet from %s %s", - packet->data[14] >> 4, device_info, device); - return false; - } - - memset(packet->data, 0, 12); - packet->len = lenin + 10; - break; } - - case DEVICE_TYPE_TAP: - if((lenin = read(device_fd, packet->data, MTU)) <= 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, - device, strerror(errno)); - return false; - } - - packet->len = lenin; - break; - - default: - return false; - } - + device_total_in += packet->len; ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", - packet->len, device_info); + packet->len, device_info); return true; } -static bool write_packet(vpn_packet_t *packet) { +bool write_packet(vpn_packet_t *packet) { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + packet->len, device_info); switch(device_type) { - case DEVICE_TYPE_TUN: - if(write(device_fd, packet->data + 14, packet->len - 14) < 0) { - logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, - device, strerror(errno)); - return false; - } - - break; - - case DEVICE_TYPE_UTUN: - case DEVICE_TYPE_TUNIFHEAD: { - int af = (packet->data[12] << 8) + packet->data[13]; - uint32_t type; - - switch(af) { - case 0x0800: - type = htonl(AF_INET); + case DEVICE_TYPE_TUN: + if(write(device_fd, packet->data + 14, packet->len - 14) < 0) { + logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, + device, strerror(errno)); + return false; + } break; - case 0x86DD: - type = htonl(AF_INET6); + case DEVICE_TYPE_TUNIFHEAD: { + u_int32_t type; + struct iovec vector[2] = {{&type, sizeof type}, {packet->data + 14, packet->len - 14}}; + int af; + + af = (packet->data[12] << 8) + packet->data[13]; + + switch (af) { + case 0x0800: + type = htonl(AF_INET); + break; + case 0x86DD: + type = htonl(AF_INET6); + break; + default: + ifdebug(TRAFFIC) logger(LOG_ERR, + "Unknown address family %x while writing packet to %s %s", + af, device_info, device); + return false; + } + + if(writev(device_fd, vector, 2) < 0) { + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, + strerror(errno)); + return false; + } + break; + } + + case DEVICE_TYPE_TAP: + if(write(device_fd, packet->data, packet->len) < 0) { + logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, + device, strerror(errno)); + return false; + } break; - default: - ifdebug(TRAFFIC) logger(LOG_ERR, - "Unknown address family %x while writing packet to %s %s", - af, device_info, device); - return false; - } - - memcpy(packet->data + 10, &type, sizeof(type)); - - if(write(device_fd, packet->data + 10, packet->len - 10) < 0) { - logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, - strerror(errno)); - return false; - } - - break; - } - - case DEVICE_TYPE_TAP: - if(write(device_fd, packet->data, packet->len) < 0) { - logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, - device, strerror(errno)); - return false; - } - - break; - -#ifdef ENABLE_TUNEMU - - case DEVICE_TYPE_TUNEMU: - if(tunemu_write(device_fd, packet->data + 14, packet->len - 14) < 0) { - logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, - device, strerror(errno)); - return false; - } - - break; +#ifdef HAVE_TUNEMU + case DEVICE_TYPE_TUNEMU: + if(tunemu_write(device_fd, packet->data + 14, packet->len - 14) < 0) { + logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, + device, strerror(errno)); + return false; + } + break; #endif - default: - return false; + default: + return false; } device_total_out += packet->len; @@ -515,16 +351,8 @@ static bool write_packet(vpn_packet_t *packet) { return true; } -static void dump_device_stats(void) { +void dump_device_stats(void) { logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); } - -const devops_t os_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, - .dump_stats = dump_device_stats, -}; diff --git a/src/bsd/tunemu.c b/src/bsd/tunemu.c index 7ff6f72..f532b04 100644 --- a/src/bsd/tunemu.c +++ b/src/bsd/tunemu.c @@ -1,20 +1,20 @@ /* * tunemu - Tun device emulation for Darwin * Copyright (C) 2009 Friedrich Schöller - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * */ #include "tunemu.h" @@ -36,34 +36,37 @@ #define PPPPROTO_CTL 1 -#define PPP_IP 0x21 -#define PPP_IPV6 0x57 +#define PPP_IP 0x21 +#define PPP_IPV6 0x57 #define SC_LOOP_TRAFFIC 0x00000200 -#define PPPIOCNEWUNIT _IOWR('t', 62, int) -#define PPPIOCSFLAGS _IOW('t', 89, int) -#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) -#define PPPIOCATTCHAN _IOW('t', 56, int) -#define PPPIOCGCHAN _IOR('t', 55, int) -#define PPPIOCCONNECT _IOW('t', 58, int) -#define PPPIOCGUNIT _IOR('t', 86, int) +#define PPPIOCNEWUNIT _IOWR('t', 62, int) +#define PPPIOCSFLAGS _IOW('t', 89, int) +#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) +#define PPPIOCATTCHAN _IOW('t', 56, int) +#define PPPIOCGCHAN _IOR('t', 55, int) +#define PPPIOCCONNECT _IOW('t', 58, int) +#define PPPIOCGUNIT _IOR('t', 86, int) -struct sockaddr_ppp { +struct sockaddr_ppp +{ u_int8_t ppp_len; u_int8_t ppp_family; u_int16_t ppp_proto; u_int32_t ppp_cookie; }; -enum NPmode { +enum NPmode +{ NPMODE_PASS, - NPMODE_DROP, - NPMODE_ERROR, - NPMODE_QUEUE + NPMODE_DROP, + NPMODE_ERROR, + NPMODE_QUEUE }; -struct npioctl { +struct npioctl +{ int protocol; enum NPmode mode; }; @@ -80,55 +83,58 @@ static pcap_t *pcap = NULL; static int data_buffer_length = 0; static char *data_buffer = NULL; -static void tun_error(char *format, ...) { +static void tun_error(char *format, ...) +{ va_list vl; va_start(vl, format); vsnprintf(tunemu_error, ERROR_BUFFER_SIZE, format, vl); va_end(vl); } -static void tun_noerror() { +static void tun_noerror() +{ *tunemu_error = 0; } -static void closeall() { - int fd = getdtablesize(); - - while(fd--) { +static void closeall() +{ + int fd = getdtablesize(); + while (fd--) close(fd); - } - open("/dev/null", O_RDWR, 0); - dup(0); - dup(0); + open("/dev/null", O_RDWR, 0); + dup(0); + dup(0); } -static int ppp_load_kext() { +static int ppp_load_kext() +{ int pid = fork(); - - if(pid < 0) { + if (pid < 0) + { tun_error("fork for ppp kext: %s", strerror(errno)); return -1; } - if(pid == 0) { + if (pid == 0) + { closeall(); execle("/sbin/kextload", "kextload", PPP_KEXT_PATH, NULL, NULL); exit(1); } int status; - - while(waitpid(pid, &status, 0) < 0) { - if(errno == EINTR) { + while (waitpid(pid, &status, 0) < 0) + { + if (errno == EINTR) continue; - } tun_error("waitpid for ppp kext: %s", strerror(errno)); return -1; } - if(WEXITSTATUS(status) != 0) { + if (WEXITSTATUS(status) != 0) + { tun_error("could not load ppp kext \"%s\"", PPP_KEXT_PATH); return -1; } @@ -137,73 +143,74 @@ static int ppp_load_kext() { return 0; } -static int ppp_new_instance() { +static int ppp_new_instance() +{ // create ppp socket - int ppp_sockfd = socket(PF_PPP, SOCK_RAW, PPPPROTO_CTL); - - if(ppp_sockfd < 0) { - if(ppp_load_kext() < 0) { + int ppp_sockfd = socket(PF_PPP, SOCK_RAW, PPPPROTO_CTL); + if (ppp_sockfd < 0) + { + if (ppp_load_kext() < 0) return -1; - } ppp_sockfd = socket(PF_PPP, SOCK_RAW, PPPPROTO_CTL); - - if(ppp_sockfd < 0) { + if (ppp_sockfd < 0) + { tun_error("creating ppp socket: %s", strerror(errno)); return -1; } } // connect to ppp procotol - struct sockaddr_ppp pppaddr; - pppaddr.ppp_len = sizeof(struct sockaddr_ppp); - pppaddr.ppp_family = AF_PPP; - pppaddr.ppp_proto = PPPPROTO_CTL; - pppaddr.ppp_cookie = 0; - - if(connect(ppp_sockfd, (struct sockaddr *)&pppaddr, sizeof(struct sockaddr_ppp)) < 0) { + struct sockaddr_ppp pppaddr; + pppaddr.ppp_len = sizeof(struct sockaddr_ppp); + pppaddr.ppp_family = AF_PPP; + pppaddr.ppp_proto = PPPPROTO_CTL; + pppaddr.ppp_cookie = 0; + if (connect(ppp_sockfd, (struct sockaddr *)&pppaddr, sizeof(struct sockaddr_ppp)) < 0) + { tun_error("connecting ppp socket: %s", strerror(errno)); close(ppp_sockfd); return -1; - } + } tun_noerror(); return ppp_sockfd; } -static int ppp_new_unit(int *unit_number) { +static int ppp_new_unit(int *unit_number) +{ int fd = ppp_new_instance(); - - if(fd < 0) { + if (fd < 0) return -1; - } // create ppp unit - if(ioctl(fd, PPPIOCNEWUNIT, unit_number) < 0) { + if (ioctl(fd, PPPIOCNEWUNIT, unit_number) < 0) + { tun_error("creating ppp unit: %s", strerror(errno)); close(fd); return -1; - } + } tun_noerror(); return fd; } -static int ppp_setup_unit(int unit_fd) { +static int ppp_setup_unit(int unit_fd) +{ // send traffic to program int flags = SC_LOOP_TRAFFIC; - - if(ioctl(unit_fd, PPPIOCSFLAGS, &flags) < 0) { + if (ioctl(unit_fd, PPPIOCSFLAGS, &flags) < 0) + { tun_error("setting ppp loopback mode: %s", strerror(errno)); return -1; - } + } // allow packets struct npioctl npi; npi.protocol = PPP_IP; npi.mode = NPMODE_PASS; - - if(ioctl(unit_fd, PPPIOCSNPMODE, &npi) < 0) { + if (ioctl(unit_fd, PPPIOCSNPMODE, &npi) < 0) + { tun_error("starting ppp unit: %s", strerror(errno)); return -1; } @@ -212,8 +219,10 @@ static int ppp_setup_unit(int unit_fd) { return 0; } -static int open_pcap() { - if(pcap != NULL) { +static int open_pcap() +{ + if (pcap != NULL) + { pcap_use_count++; return 0; } @@ -222,7 +231,8 @@ static int open_pcap() { pcap = pcap_open_live("lo0", BUFSIZ, 0, 1, errbuf); pcap_use_count = 1; - if(pcap == NULL) { + if (pcap == NULL) + { tun_error("opening pcap: %s", errbuf); return -1; } @@ -231,57 +241,59 @@ static int open_pcap() { return 0; } -static void close_pcap() { - if(pcap == NULL) { +static void close_pcap() +{ + if (pcap == NULL) return; - } pcap_use_count--; - - if(pcap_use_count == 0) { + if (pcap_use_count == 0) + { pcap_close(pcap); pcap = NULL; } } -static void allocate_data_buffer(int size) { - if(data_buffer_length < size) { +static void allocate_data_buffer(int size) +{ + if (data_buffer_length < size) + { free(data_buffer); data_buffer_length = size; data_buffer = malloc(data_buffer_length); } } -static void make_device_name(tunemu_device device, int unit_number) { +static void make_device_name(tunemu_device device, int unit_number) +{ snprintf(device, sizeof(tunemu_device), "ppp%d", unit_number); } -static int check_device_name(tunemu_device device) { - if(strlen(device) < 4) { +static int check_device_name(tunemu_device device) +{ + if (strlen(device) < 4) return -1; - } int unit_number = atoi(device + 3); - - if(unit_number < 0 || unit_number > 999) { + if (unit_number < 0 || unit_number > 999) return -1; - } tunemu_device compare; make_device_name(compare, unit_number); - if(strcmp(device, compare) != 0) { + if (strcmp(device, compare) != 0) return -1; - } return 0; } -int tunemu_open(tunemu_device device) { +int tunemu_open(tunemu_device device) +{ int ppp_unit_number = -1; - - if(device[0] != 0) { - if(check_device_name(device) < 0) { + if (device[0] != 0) + { + if (check_device_name(device) < 0) + { tun_error("invalid device name \"%s\"", device); return -1; } @@ -290,17 +302,17 @@ int tunemu_open(tunemu_device device) { } int ppp_unit_fd = ppp_new_unit(&ppp_unit_number); - - if(ppp_unit_fd < 0) { + if (ppp_unit_fd < 0) return -1; - } - if(ppp_setup_unit(ppp_unit_fd) < 0) { + if (ppp_setup_unit(ppp_unit_fd) < 0) + { close(ppp_unit_fd); return -1; } - if(open_pcap() < 0) { + if (open_pcap() < 0) + { close(ppp_unit_fd); return -1; } @@ -310,40 +322,39 @@ int tunemu_open(tunemu_device device) { return ppp_unit_fd; } -int tunemu_close(int ppp_sockfd) { +int tunemu_close(int ppp_sockfd) +{ int ret = close(ppp_sockfd); - if(ret == 0) { + if (ret == 0) close_pcap(); - } return ret; } -int tunemu_read(int ppp_sockfd, char *buffer, int length) { +int tunemu_read(int ppp_sockfd, char *buffer, int length) +{ allocate_data_buffer(length + 2); length = read(ppp_sockfd, data_buffer, length + 2); - - if(length < 0) { + if (length < 0) + { tun_error("reading packet: %s", strerror(errno)); return length; } - tun_noerror(); length -= 2; - - if(length < 0) { + if (length < 0) return 0; - } memcpy(buffer, data_buffer + 2, length); return length; } -int tunemu_write(int ppp_sockfd, char *buffer, int length) { +int tunemu_write(int ppp_sockfd, char *buffer, int length) +{ allocate_data_buffer(length + 4); data_buffer[0] = 0x02; @@ -353,25 +364,23 @@ int tunemu_write(int ppp_sockfd, char *buffer, int length) { memcpy(data_buffer + 4, buffer, length); - if(pcap == NULL) { + if (pcap == NULL) + { tun_error("pcap not open"); return -1; } length = pcap_inject(pcap, data_buffer, length + 4); - - if(length < 0) { + if (length < 0) + { tun_error("injecting packet: %s", pcap_geterr(pcap)); return length; } - tun_noerror(); length -= 4; - - if(length < 0) { + if (length < 0) return 0; - } return length; } diff --git a/src/bsd/tunemu.h b/src/bsd/tunemu.h index e0452a8..42b1785 100644 --- a/src/bsd/tunemu.h +++ b/src/bsd/tunemu.h @@ -1,20 +1,20 @@ /* * tunemu - Tun device emulation for Darwin * Copyright (C) 2009 Friedrich Schöller - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * */ #ifndef TUNEMU_H diff --git a/src/buffer.c b/src/buffer.c new file mode 100644 index 0000000..3d4c329 --- /dev/null +++ b/src/buffer.c @@ -0,0 +1,108 @@ +/* + buffer.c -- buffer management + Copyright (C) 2011 Guus Sliepen , + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include "buffer.h" +#include "xalloc.h" + +void buffer_compact(buffer_t *buffer, int maxsize) { + if(buffer->len >= maxsize || buffer->offset / 7 > buffer->len / 8) { + memmove(buffer->data, buffer->data + buffer->offset, buffer->len - buffer->offset); + buffer->len -= buffer->offset; + buffer->offset = 0; + } +} + +// Make sure we can add size bytes to the buffer, and return a pointer to the start of those bytes. + +char *buffer_prepare(buffer_t *buffer, int size) { + if(!buffer->data) { + buffer->maxlen = size; + buffer->data = xmalloc(size); + } else { + if(buffer->offset && buffer->len + size > buffer->maxlen) { + memmove(buffer->data, buffer->data + buffer->offset, buffer->len - buffer->offset); + buffer->len -= buffer->offset; + buffer->offset = 0; + } + + if(buffer->len + size > buffer->maxlen) { + buffer->maxlen = buffer->len + size; + buffer->data = xrealloc(buffer->data, buffer->maxlen); + } + } + + char *start = buffer->data + buffer->len; + + buffer->len += size; + + return start; +} + +// Copy data into the buffer. + +void buffer_add(buffer_t *buffer, const char *data, int size) { + memcpy(buffer_prepare(buffer, size), data, size); +} + +// Remove given number of bytes from the buffer, return a pointer to the start of them. + +static char *buffer_consume(buffer_t *buffer, int size) { + char *start = buffer->data + buffer->offset; + + buffer->offset += size; + + if(buffer->offset >= buffer->len) { + buffer->offset = 0; + buffer->len = 0; + } + + return start; +} + +// Check if there is a complete line in the buffer, and if so, return it NULL-terminated. + +char *buffer_readline(buffer_t *buffer) { + char *newline = memchr(buffer->data + buffer->offset, '\n', buffer->len - buffer->offset); + + if(!newline) + return NULL; + + int len = newline + 1 - (buffer->data + buffer->offset); + *newline = 0; + return buffer_consume(buffer, len); +} + +// Check if we have enough bytes in the buffer, and if so, return a pointer to the start of them. + +char *buffer_read(buffer_t *buffer, int size) { + if(buffer->len - buffer->offset < size) + return NULL; + + return buffer_consume(buffer, size); +} + +void buffer_clear(buffer_t *buffer) { + free(buffer->data); + buffer->data = NULL; + buffer->maxlen = 0; + buffer->len = 0; + buffer->offset = 0; +} diff --git a/src/buffer.h b/src/buffer.h new file mode 100644 index 0000000..a96c15a --- /dev/null +++ b/src/buffer.h @@ -0,0 +1,18 @@ +#ifndef __TINC_BUFFER_H__ +#define __TINC_BUFFER_H__ + +typedef struct buffer_t { + char *data; + int maxlen; + int len; + int offset; +} buffer_t; + +extern void buffer_compact(buffer_t *buffer, int maxsize); +extern char *buffer_prepare(buffer_t *buffer, int size); +extern void buffer_add(buffer_t *buffer, const char *data, int size); +extern char *buffer_readline(buffer_t *buffer); +extern char *buffer_read(buffer_t *buffer, int size); +extern void buffer_clear(buffer_t *buffer); + +#endif diff --git a/src/conf.c b/src/conf.c index 58d7b6d..f47faef 100644 --- a/src/conf.c +++ b/src/conf.c @@ -2,9 +2,9 @@ conf.c -- configuration code Copyright (C) 1998 Robert van der Meulen 1998-2005 Ivo Timmermans - 2000-2014 Guus Sliepen + 2000-2010 Guus Sliepen 2010-2011 Julien Muchembled - 2000 Cris van Pelt + 2000 Cris van Pelt This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,23 +23,23 @@ #include "system.h" -#include "avl_tree.h" +#include "splay_tree.h" #include "connection.h" #include "conf.h" #include "list.h" #include "logger.h" -#include "netutl.h" /* for str2address */ +#include "netutl.h" /* for str2address */ #include "protocol.h" -#include "utils.h" /* for cp */ +#include "utils.h" /* for cp */ #include "xalloc.h" -avl_tree_t *config_tree; +splay_tree_t *config_tree; -int pinginterval = 0; /* seconds between pings */ -int pingtimeout = 0; /* seconds to wait for response */ -char *confbase = NULL; /* directory in which all config files are */ -char *netname = NULL; /* name of the vpn network */ -list_t *cmdline_conf = NULL; /* global/host configuration values given at the command line */ +int pinginterval = 0; /* seconds between pings */ +int pingtimeout = 0; /* seconds to wait for response */ +char *confbase = NULL; /* directory in which all config files are */ +char *netname = NULL; /* name of the vpn network */ +list_t *cmdline_conf = NULL; /* global/host configuration values given at the command line */ static int config_compare(const config_t *a, const config_t *b) { @@ -47,32 +47,28 @@ static int config_compare(const config_t *a, const config_t *b) { result = strcasecmp(a->variable, b->variable); - if(result) { + if(result) return result; - } /* give priority to command line options */ result = !b->file - !a->file; - - if(result) { + if (result) return result; - } result = a->line - b->line; - if(result) { + if(result) return result; - } else { + else return a->file ? strcmp(a->file, b->file) : 0; - } } -void init_configuration(avl_tree_t **config_tree) { - *config_tree = avl_alloc_tree((avl_compare_t) config_compare, (avl_action_t) free_config); +void init_configuration(splay_tree_t ** config_tree) { + *config_tree = splay_alloc_tree((splay_compare_t) config_compare, (splay_action_t) free_config); } -void exit_configuration(avl_tree_t **config_tree) { - avl_delete_tree(*config_tree); +void exit_configuration(splay_tree_t ** config_tree) { + splay_delete_tree(*config_tree); *config_tree = NULL; } @@ -81,49 +77,52 @@ config_t *new_config(void) { } void free_config(config_t *cfg) { - free(cfg->variable); - free(cfg->value); - free(cfg->file); + if(cfg->variable) + free(cfg->variable); + + if(cfg->value) + free(cfg->value); + + if(cfg->file) + free(cfg->file); + free(cfg); } -void config_add(avl_tree_t *config_tree, config_t *cfg) { - avl_insert(config_tree, cfg); +void config_add(splay_tree_t *config_tree, config_t *cfg) { + splay_insert(config_tree, cfg); } -config_t *lookup_config(const avl_tree_t *config_tree, char *variable) { +config_t *lookup_config(splay_tree_t *config_tree, char *variable) { config_t cfg, *found; cfg.variable = variable; cfg.file = NULL; cfg.line = 0; - found = avl_search_closest_greater(config_tree, &cfg); + found = splay_search_closest_greater(config_tree, &cfg); - if(!found) { + if(!found) return NULL; - } - if(strcasecmp(found->variable, variable)) { + if(strcasecmp(found->variable, variable)) return NULL; - } return found; } -config_t *lookup_config_next(const avl_tree_t *config_tree, const config_t *cfg) { - avl_node_t *node; +config_t *lookup_config_next(splay_tree_t *config_tree, const config_t *cfg) { + splay_node_t *node; config_t *found; - node = avl_search_node(config_tree, cfg); + node = splay_search_node(config_tree, cfg); if(node) { if(node->next) { found = node->next->data; - if(!strcasecmp(found->variable, cfg->variable)) { + if(!strcasecmp(found->variable, cfg->variable)) return found; - } } } @@ -131,9 +130,8 @@ config_t *lookup_config_next(const avl_tree_t *config_tree, const config_t *cfg) } bool get_config_bool(const config_t *cfg, bool *result) { - if(!cfg) { + if(!cfg) return false; - } if(!strcasecmp(cfg->value, "yes")) { *result = true; @@ -144,30 +142,27 @@ bool get_config_bool(const config_t *cfg, bool *result) { } logger(LOG_ERR, "\"yes\" or \"no\" expected for configuration variable %s in %s line %d", - cfg->variable, cfg->file, cfg->line); + cfg->variable, cfg->file, cfg->line); return false; } bool get_config_int(const config_t *cfg, int *result) { - if(!cfg) { + if(!cfg) return false; - } - if(sscanf(cfg->value, "%d", result) == 1) { + if(sscanf(cfg->value, "%d", result) == 1) return true; - } logger(LOG_ERR, "Integer expected for configuration variable %s in %s line %d", - cfg->variable, cfg->file, cfg->line); + cfg->variable, cfg->file, cfg->line); return false; } bool get_config_string(const config_t *cfg, char **result) { - if(!cfg) { + if(!cfg) return false; - } *result = xstrdup(cfg->value); @@ -177,9 +172,8 @@ bool get_config_string(const config_t *cfg, char **result) { bool get_config_address(const config_t *cfg, struct addrinfo **result) { struct addrinfo *ai; - if(!cfg) { + if(!cfg) return false; - } ai = str2addrinfo(cfg->value, NULL, 0); @@ -189,32 +183,31 @@ bool get_config_address(const config_t *cfg, struct addrinfo **result) { } logger(LOG_ERR, "Hostname or IP address expected for configuration variable %s in %s line %d", - cfg->variable, cfg->file, cfg->line); + cfg->variable, cfg->file, cfg->line); return false; } -bool get_config_subnet(const config_t *cfg, subnet_t **result) { - subnet_t subnet = {0}; +bool get_config_subnet(const config_t *cfg, subnet_t ** result) { + subnet_t subnet = {NULL}; - if(!cfg) { + if(!cfg) return false; - } if(!str2net(&subnet, cfg->value)) { logger(LOG_ERR, "Subnet expected for configuration variable %s in %s line %d", - cfg->variable, cfg->file, cfg->line); + cfg->variable, cfg->file, cfg->line); return false; } /* Teach newbies what subnets are... */ if(((subnet.type == SUBNET_IPV4) - && !maskcheck(&subnet.net.ipv4.address, subnet.net.ipv4.prefixlength, sizeof(ipv4_t))) - || ((subnet.type == SUBNET_IPV6) - && !maskcheck(&subnet.net.ipv6.address, subnet.net.ipv6.prefixlength, sizeof(ipv6_t)))) { + && !maskcheck(&subnet.net.ipv4.address, subnet.net.ipv4.prefixlength, sizeof subnet.net.ipv4.address)) + || ((subnet.type == SUBNET_IPV6) + && !maskcheck(&subnet.net.ipv6.address, subnet.net.ipv6.prefixlength, sizeof subnet.net.ipv6.address))) { logger(LOG_ERR, "Network address and prefix length do not match for configuration variable %s in %s line %d", - cfg->variable, cfg->file, cfg->line); + cfg->variable, cfg->file, cfg->line); return false; } @@ -226,31 +219,26 @@ bool get_config_subnet(const config_t *cfg, subnet_t **result) { /* Read exactly one line and strip the trailing newline if any. */ -static char *readline(FILE *fp, char *buf, size_t buflen) { +static char *readline(FILE * fp, char *buf, size_t buflen) { char *newline = NULL; char *p; - if(feof(fp)) { + if(feof(fp)) return NULL; - } p = fgets(buf, buflen, fp); - if(!p) { + if(!p) return NULL; - } newline = strchr(p, '\n'); - if(!newline) { + if(!newline) return buf; - } - *newline = '\0'; /* kill newline */ - - if(newline > p && newline[-1] == '\r') { /* and carriage return if necessary */ + *newline = '\0'; /* kill newline */ + if(newline > p && newline[-1] == '\r') /* and carriage return if necessary */ newline[-1] = '\0'; - } return buf; } @@ -262,32 +250,26 @@ config_t *parse_config_line(char *line, const char *fname, int lineno) { variable = value = line; eol = line + strlen(line); - - while(strchr("\t ", *--eol)) { + while(strchr("\t ", *--eol)) *eol = '\0'; - } len = strcspn(value, "\t ="); value += len; value += strspn(value, "\t "); - if(*value == '=') { value++; value += strspn(value, "\t "); } - variable[len] = '\0'; if(!*value) { const char err[] = "No value for variable"; - - if(fname) + if (fname) logger(LOG_ERR, "%s `%s' on line %d while reading config file %s", - err, variable, lineno, fname); + err, variable, lineno, fname); else logger(LOG_ERR, "%s `%s' in command line option %d", - err, variable, lineno); - + err, variable, lineno); return NULL; } @@ -304,7 +286,7 @@ config_t *parse_config_line(char *line, const char *fname, int lineno) { Parse a configuration file and put the results in the configuration tree starting at *base. */ -bool read_config_file(avl_tree_t *config_tree, const char *fname) { +bool read_config_file(splay_tree_t *config_tree, const char *fname) { FILE *fp; char buffer[MAX_STRING_SIZE]; char *line; @@ -321,41 +303,33 @@ bool read_config_file(avl_tree_t *config_tree, const char *fname) { } for(;;) { - line = readline(fp, buffer, sizeof(buffer)); + line = readline(fp, buffer, sizeof buffer); if(!line) { - if(feof(fp)) { + if(feof(fp)) result = true; - } - break; } lineno++; - if(!*line || *line == '#') { + if(!*line || *line == '#') continue; - } if(ignore) { - if(!strncmp(line, "-----END", 8)) { + if(!strncmp(line, "-----END", 8)) ignore = false; - } - continue; } - + if(!strncmp(line, "-----BEGIN", 10)) { ignore = true; continue; } cfg = parse_config_line(line, fname, lineno); - - if(!cfg) { + if (!cfg) break; - } - config_add(config_tree, cfg); } @@ -364,234 +338,122 @@ bool read_config_file(avl_tree_t *config_tree, const char *fname) { return result; } -void read_config_options(avl_tree_t *config_tree, const char *prefix) { +void read_config_options(splay_tree_t *config_tree, const char *prefix) { + list_node_t *node, *next; size_t prefix_len = prefix ? strlen(prefix) : 0; - for(const list_node_t *node = cmdline_conf->tail; node; node = node->prev) { - const config_t *cfg = node->data; + for(node = cmdline_conf->tail; node; node = next) { + config_t *orig_cfg, *cfg = (config_t *)node->data; + next = node->prev; if(!prefix) { - if(strchr(cfg->variable, '.')) { + if(strchr(cfg->variable, '.')) continue; - } + node->data = NULL; + list_unlink_node(cmdline_conf, node); } else { if(strncmp(prefix, cfg->variable, prefix_len) || - cfg->variable[prefix_len] != '.') { + cfg->variable[prefix_len] != '.') continue; - } + /* Because host configuration is parsed again when + reconnecting, nodes must not be freed when a prefix + is given. */ + orig_cfg = cfg; + cfg = new_config(); + cfg->variable = xstrdup(orig_cfg->variable + prefix_len + 1); + cfg->value = xstrdup(orig_cfg->value); + cfg->file = NULL; + cfg->line = orig_cfg->line; } - - config_t *new = new_config(); - - if(prefix) { - new->variable = xstrdup(cfg->variable + prefix_len + 1); - } else { - new->variable = xstrdup(cfg->variable); - } - - new->value = xstrdup(cfg->value); - new->file = NULL; - new->line = cfg->line; - - config_add(config_tree, new); + config_add(config_tree, cfg); } } bool read_server_config(void) { - char fname[PATH_MAX]; + char *fname; bool x; read_config_options(config_tree, NULL); - snprintf(fname, sizeof(fname), "%s/tinc.conf", confbase); - errno = 0; + xasprintf(&fname, "%s/tinc.conf", confbase); x = read_config_file(config_tree, fname); - // We will try to read the conf files in the "conf.d" dir - if(x) { - char dname[PATH_MAX]; - snprintf(dname, sizeof(dname), "%s/conf.d", confbase); - DIR *dir = opendir(dname); - - // If we can find this dir - if(dir) { - struct dirent *ep; - - // We list all the files in it - while(x && (ep = readdir(dir))) { - size_t l = strlen(ep->d_name); - - // And we try to read the ones that end with ".conf" - if(l > 5 && !strcmp(".conf", & ep->d_name[ l - 5 ])) { - if((size_t)snprintf(fname, sizeof(fname), "%s/%s", dname, ep->d_name) >= sizeof(fname)) { - logger(LOG_ERR, "Pathname too long: %s/%s", dname, ep->d_name); - return false; - } - - x = read_config_file(config_tree, fname); - } - } - - closedir(dir); - } - } - - if(!x && errno) { + if(!x) { /* System error: complain */ logger(LOG_ERR, "Failed to read `%s': %s", fname, strerror(errno)); } + free(fname); + return x; } bool read_connection_config(connection_t *c) { - char fname[PATH_MAX]; + char *fname; bool x; read_config_options(c->config_tree, c->name); - snprintf(fname, sizeof(fname), "%s/hosts/%s", confbase, c->name); + xasprintf(&fname, "%s/hosts/%s", confbase, c->name); x = read_config_file(c->config_tree, fname); + free(fname); return x; } -static void disable_old_keys(const char *filename) { - char tmpfile[PATH_MAX] = ""; - char buf[1024]; - bool disabled = false; - FILE *r, *w; +bool append_config_file(const char *name, const char *key, const char *value) { + char *fname; + xasprintf(&fname, "%s/hosts/%s", confbase, name); - r = fopen(filename, "r"); + FILE *fp = fopen(fname, "a"); - if(!r) { - return; + if(!fp) { + logger(LOG_ERR, "Cannot open config file %s: %s", fname, strerror(errno)); + } else { + fprintf(fp, "\n# The following line was automatically added by tinc\n%s = %s\n", key, value); + fclose(fp); } - snprintf(tmpfile, sizeof(tmpfile), "%s.tmp", filename); + free(fname); - w = fopen(tmpfile, "w"); + return fp; +} - while(fgets(buf, sizeof(buf), r)) { - if(!strncmp(buf, "-----BEGIN RSA", 14)) { +bool disable_old_keys(FILE *f) { + char buf[100]; + long pos; + bool disabled = false; + + rewind(f); + pos = ftell(f); + + if(pos < 0) + return false; + + while(fgets(buf, sizeof buf, f)) { + if(!strncmp(buf, "-----BEGIN RSA", 14)) { buf[11] = 'O'; buf[12] = 'L'; buf[13] = 'D'; + if(fseek(f, pos, SEEK_SET)) + break; + if(fputs(buf, f) <= 0) + break; disabled = true; - } else if(!strncmp(buf, "-----END RSA", 12)) { + } + else if(!strncmp(buf, "-----END RSA", 12)) { buf[ 9] = 'O'; buf[10] = 'L'; buf[11] = 'D'; + if(fseek(f, pos, SEEK_SET)) + break; + if(fputs(buf, f) <= 0) + break; disabled = true; } - - if(w && fputs(buf, w) < 0) { - disabled = false; + pos = ftell(f); + if(pos < 0) break; - } } - if(w) { - fclose(w); - } - - fclose(r); - - if(!w && disabled) { - fprintf(stderr, "Warning: old key(s) found, remove them by hand!\n"); - return; - } - - if(disabled) { -#ifdef HAVE_MINGW - // We cannot atomically replace files on Windows. - char bakfile[PATH_MAX] = ""; - snprintf(bakfile, sizeof(bakfile), "%s.bak", filename); - - if(rename(filename, bakfile) || rename(tmpfile, filename)) { - rename(bakfile, filename); -#else - - if(rename(tmpfile, filename)) { -#endif - fprintf(stderr, "Warning: old key(s) found, remove them by hand!\n"); - } else { -#ifdef HAVE_MINGW - unlink(bakfile); -#endif - fprintf(stderr, "Warning: old key(s) found and disabled.\n"); - } - } - - unlink(tmpfile); + return disabled; } - -FILE *ask_and_open(const char *filename, const char *what) { - FILE *r; - char directory[PATH_MAX]; - char line[PATH_MAX]; - char abspath[PATH_MAX]; - const char *fn; - - /* Check stdin and stdout */ - if(!isatty(0) || !isatty(1)) { - /* Argh, they are running us from a script or something. Write - the files to the current directory and let them burn in hell - for ever. */ - fn = filename; - } else { - /* Ask for a file and/or directory name. */ - fprintf(stdout, "Please enter a file to save %s to [%s]: ", - what, filename); - fflush(stdout); - - fn = readline(stdin, line, sizeof(line)); - - if(!fn) { - fprintf(stderr, "Error while reading stdin: %s\n", - strerror(errno)); - return NULL; - } - - if(!strlen(fn)) - /* User just pressed enter. */ - { - fn = filename; - } - } - -#ifdef HAVE_MINGW - - if(fn[0] != '\\' && fn[0] != '/' && !strchr(fn, ':')) { -#else - - if(fn[0] != '/') { -#endif - /* The directory is a relative path or a filename. */ - getcwd(directory, sizeof(directory)); - - if((size_t)snprintf(abspath, sizeof(abspath), "%s/%s", directory, fn) >= sizeof(abspath)) { - fprintf(stderr, "Pathname too long: %s/%s\n", directory, fn); - return NULL; - } - - fn = abspath; - } - - umask(0077); /* Disallow everything for group and other */ - - disable_old_keys(fn); - - /* Open it first to keep the inode busy */ - - r = fopen(fn, "a"); - - if(!r) { - fprintf(stderr, "Error opening file `%s': %s\n", - fn, strerror(errno)); - return NULL; - } - - return r; -} - - diff --git a/src/conf.h b/src/conf.h index 770ada7..bd3850b 100644 --- a/src/conf.h +++ b/src/conf.h @@ -1,10 +1,7 @@ -#ifndef TINC_CONF_H -#define TINC_CONF_H - /* conf.h -- header for conf.c Copyright (C) 1998-2005 Ivo Timmermans - 2000-2012 Guus Sliepen + 2000-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,7 +18,10 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "avl_tree.h" +#ifndef __TINC_CONF_H__ +#define __TINC_CONF_H__ + +#include "splay_tree.h" #include "list.h" typedef struct config_t { @@ -33,35 +33,37 @@ typedef struct config_t { #include "subnet.h" -extern avl_tree_t *config_tree; +extern splay_tree_t *config_tree; extern int pinginterval; extern int pingtimeout; extern int maxtimeout; -extern int mintimeout; extern bool bypass_security; extern char *confbase; extern char *netname; extern list_t *cmdline_conf; -extern void init_configuration(avl_tree_t **config_tree); -extern void exit_configuration(avl_tree_t **config_tree); -extern config_t *new_config(void) __attribute__((__malloc__)); -extern void free_config(config_t *cfg); -extern void config_add(avl_tree_t *config_tree, config_t *cfg); -extern config_t *lookup_config(const avl_tree_t *config_tree, char *variable); -extern config_t *lookup_config_next(const avl_tree_t *config_tree, const config_t *cfg); -extern bool get_config_bool(const config_t *cfg, bool *result); -extern bool get_config_int(const config_t *cfg, int *result); -extern bool get_config_string(const config_t *cfg, char **result); -extern bool get_config_address(const config_t *cfg, struct addrinfo **result); -extern bool get_config_subnet(const config_t *cfg, struct subnet_t **result); +extern void init_configuration(splay_tree_t **); +extern void exit_configuration(splay_tree_t **); +extern config_t *new_config(void) __attribute__ ((__malloc__)); +extern void free_config(config_t *); +extern void config_add(splay_tree_t *, config_t *); +extern config_t *lookup_config(splay_tree_t *, char *); +extern config_t *lookup_config_next(splay_tree_t *, const config_t *); +extern bool get_config_bool(const config_t *, bool *); +extern bool get_config_int(const config_t *, int *); +extern bool get_config_string(const config_t *, char **); +extern bool get_config_address(const config_t *, struct addrinfo **); +extern bool get_config_subnet(const config_t *, struct subnet_t **); -extern config_t *parse_config_line(char *line, const char *fname, int lineno); -extern bool read_config_file(avl_tree_t *config_tree, const char *fname); -extern void read_config_options(avl_tree_t *config_tree, const char *prefix); +extern config_t *parse_config_line(char *, const char *, int); +extern bool read_config_file(splay_tree_t *, const char *); +extern void read_config_options(splay_tree_t *, const char *); extern bool read_server_config(void); -extern bool read_connection_config(struct connection_t *c); -extern FILE *ask_and_open(const char *fname, const char *what); +extern bool read_connection_config(struct connection_t *); +extern bool append_config_file(const char *, const char *, const char *); +extern FILE *ask_and_open(const char *, const char *, const char *); +extern bool is_safe_path(const char *); +extern bool disable_old_keys(FILE *); -#endif +#endif /* __TINC_CONF_H__ */ diff --git a/src/connection.c b/src/connection.c index 38b3ccf..bae86b9 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1,6 +1,6 @@ /* connection.c -- connection list management - Copyright (C) 2000-2016 Guus Sliepen , + Copyright (C) 2000-2009 Guus Sliepen , 2000-2005 Ivo Timmermans 2008 Max Rijevski @@ -21,131 +21,98 @@ #include "system.h" -#include "avl_tree.h" +#include "splay_tree.h" +#include "cipher.h" #include "conf.h" +#include "control_common.h" +#include "list.h" #include "logger.h" #include "subnet.h" #include "utils.h" #include "xalloc.h" -avl_tree_t *connection_tree; /* Meta connections */ -connection_t *everyone; +splay_tree_t *connection_tree; /* Meta connections */ +connection_t *broadcast; static int connection_compare(const connection_t *a, const connection_t *b) { return a < b ? -1 : a == b ? 0 : 1; } void init_connections(void) { - connection_tree = avl_alloc_tree((avl_compare_t) connection_compare, (avl_action_t) free_connection); - everyone = new_connection(); - everyone->name = xstrdup("everyone"); - everyone->hostname = xstrdup("BROADCAST"); + connection_tree = splay_alloc_tree((splay_compare_t) connection_compare, (splay_action_t) free_connection); + broadcast = new_connection(); + broadcast->name = xstrdup("everyone"); + broadcast->hostname = xstrdup("BROADCAST"); } void exit_connections(void) { - avl_delete_tree(connection_tree); - free_connection(everyone); + splay_delete_tree(connection_tree); + free_connection(broadcast); } connection_t *new_connection(void) { - connection_t *c; - - c = xmalloc_and_zero(sizeof(connection_t)); - - if(!c) { - return NULL; - } - - gettimeofday(&c->start, NULL); - - return c; -} - -void free_connection_partially(connection_t *c) { - free(c->inkey); - free(c->outkey); - free(c->mychallenge); - free(c->hischallenge); - free(c->outbuf); - - c->inkey = NULL; - c->outkey = NULL; - c->mychallenge = NULL; - c->hischallenge = NULL; - c->outbuf = NULL; - - c->status.pinged = false; - c->status.active = false; - c->status.connecting = false; - c->status.timeout = false; - c->status.encryptout = false; - c->status.decryptin = false; - c->status.mst = false; - - c->options = 0; - c->buflen = 0; - c->reqlen = 0; - c->tcplen = 0; - c->allow_request = 0; - c->outbuflen = 0; - c->outbufsize = 0; - c->outbufstart = 0; - c->last_ping_time = 0; - c->last_flushed_time = 0; - c->inbudget = 0; - c->outbudget = 0; - - if(c->inctx) { - EVP_CIPHER_CTX_cleanup(c->inctx); - free(c->inctx); - c->inctx = NULL; - } - - if(c->outctx) { - EVP_CIPHER_CTX_cleanup(c->outctx); - free(c->outctx); - c->outctx = NULL; - } - - if(c->rsa_key) { - RSA_free(c->rsa_key); - c->rsa_key = NULL; - } + return xmalloc_and_zero(sizeof(connection_t)); } void free_connection(connection_t *c) { - free_connection_partially(c); + if(!c) + return; - free(c->name); - free(c->hostname); + if(c->name) + free(c->name); - if(c->config_tree) { + if(c->hostname) + free(c->hostname); + + cipher_close(&c->incipher); + digest_close(&c->indigest); + cipher_close(&c->outcipher); + digest_close(&c->outdigest); + + ecdh_free(&c->ecdh); + ecdsa_free(&c->ecdsa); + rsa_free(&c->rsa); + + if(c->hischallenge) + free(c->hischallenge); + + if(c->config_tree) exit_configuration(&c->config_tree); - } + + buffer_clear(&c->inbuf); + buffer_clear(&c->outbuf); + + if(event_initialized(&c->inevent)) + event_del(&c->inevent); + + if(event_initialized(&c->outevent)) + event_del(&c->outevent); + + if(c->socket > 0) + closesocket(c->socket); free(c); } void connection_add(connection_t *c) { - avl_insert(connection_tree, c); + splay_insert(connection_tree, c); } void connection_del(connection_t *c) { - avl_delete(connection_tree, c); + splay_delete(connection_tree, c); } -void dump_connections(void) { - avl_node_t *node; +bool dump_connections(connection_t *cdump) { + splay_node_t *node; connection_t *c; - logger(LOG_DEBUG, "Connections:"); - for(node = connection_tree->head; node; node = node->next) { c = node->data; - logger(LOG_DEBUG, " %s at %s options %x socket %d status %04x outbuf %d/%d/%d", - c->name, c->hostname, c->options, c->socket, bitfield_to_int(&c->status, sizeof(c->status)), - c->outbufsize, c->outbufstart, c->outbuflen); + send_request(cdump, "%d %d %s at %s options %x socket %d status %04x", + CONTROL, REQ_DUMP_CONNECTIONS, + c->name, c->hostname, c->options, c->socket, + bitfield_to_int(&c->status, sizeof c->status)); } - logger(LOG_DEBUG, "End of connections."); + return send_request(cdump, "%d %d", CONTROL, REQ_DUMP_CONNECTIONS); } diff --git a/src/connection.h b/src/connection.h index 629e16b..26aa3f0 100644 --- a/src/connection.h +++ b/src/connection.h @@ -1,9 +1,6 @@ -#ifndef TINC_CONNECTION_H -#define TINC_CONNECTION_H - /* connection.h -- header for connection.c - Copyright (C) 2000-2016 Guus Sliepen , + Copyright (C) 2000-2010 Guus Sliepen , 2000-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -21,99 +18,95 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include +#ifndef __TINC_CONNECTION_H__ +#define __TINC_CONNECTION_H__ -#include "avl_tree.h" +#include "buffer.h" +#include "cipher.h" +#include "digest.h" +#include "rsa.h" +#include "splay_tree.h" -#define OPTION_INDIRECT 0x0001 -#define OPTION_TCPONLY 0x0002 -#define OPTION_PMTU_DISCOVERY 0x0004 -#define OPTION_CLAMP_MSS 0x0008 +#define OPTION_INDIRECT 0x0001 +#define OPTION_TCPONLY 0x0002 +#define OPTION_PMTU_DISCOVERY 0x0004 +#define OPTION_CLAMP_MSS 0x0008 typedef struct connection_status_t { - unsigned int pinged: 1; /* sent ping */ - unsigned int active: 1; /* 1 if active.. */ - unsigned int connecting: 1; /* 1 if we are waiting for a non-blocking connect() to finish */ - unsigned int unused_termreq: 1; /* the termination of this connection was requested */ - unsigned int remove: 1; /* Set to 1 if you want this connection removed */ - unsigned int timeout: 1; /* 1 if gotten timeout */ - unsigned int encryptout: 1; /* 1 if we can encrypt outgoing traffic */ - unsigned int decryptin: 1; /* 1 if we have to decrypt incoming traffic */ - unsigned int mst: 1; /* 1 if this connection is part of a minimum spanning tree */ - unsigned int proxy_passed: 1; /* 1 if we are connecting via a proxy and we have finished talking with it */ - unsigned int tarpit: 1; /* 1 if the connection should be added to the tarpit */ - unsigned int unused: 21; + unsigned int pinged:1; /* sent ping */ + unsigned int active:1; /* 1 if active.. */ + unsigned int connecting:1; /* 1 if we are waiting for a non-blocking connect() to finish */ + unsigned int termreq:1; /* the termination of this connection was requested */ + unsigned int remove_unused:1; /* Set to 1 if you want this connection removed */ + unsigned int timeout_unused:1; /* 1 if gotten timeout */ + unsigned int encryptout:1; /* 1 if we can encrypt outgoing traffic */ + unsigned int decryptin:1; /* 1 if we have to decrypt incoming traffic */ + unsigned int mst:1; /* 1 if this connection is part of a minimum spanning tree */ + unsigned int control:1; + unsigned int pcap:1; + unsigned int unused:21; } connection_status_t; +#include "ecdh.h" +#include "ecdsa.h" #include "edge.h" #include "net.h" #include "node.h" typedef struct connection_t { - char *name; /* name he claims to have */ + char *name; /* name he claims to have */ - union sockaddr_t address; /* his real (internet) ip */ - char *hostname; /* the hostname of its real ip */ - int protocol_version; /* used protocol */ + union sockaddr_t address; /* his real (internet) ip */ + char *hostname; /* the hostname of its real ip */ + int protocol_major; /* used protocol */ + int protocol_minor; /* used protocol */ - int socket; /* socket used for this connection */ - uint32_t options; /* options for this connection */ - connection_status_t status; /* status info */ - int estimated_weight; /* estimation for the weight of the edge for this connection */ - struct timeval start; /* time this connection was started, used for above estimation */ - struct outgoing_t *outgoing; /* used to keep track of outgoing connections */ + int socket; /* socket used for this connection */ + uint32_t options; /* options for this connection */ + connection_status_t status; /* status info */ + int estimated_weight; /* estimation for the weight of the edge for this connection */ + struct timeval start; /* time this connection was started, used for above estimation */ + struct outgoing_t *outgoing; /* used to keep track of outgoing connections */ - struct node_t *node; /* node associated with the other end */ - struct edge_t *edge; /* edge associated with this connection */ + struct node_t *node; /* node associated with the other end */ + struct edge_t *edge; /* edge associated with this connection */ + + rsa_t rsa; /* his public RSA key */ + ecdsa_t ecdsa; /* his public ECDSA key */ + ecdsa_t ecdh; /* state for ECDH key exchange */ + cipher_t incipher; /* Cipher he will use to send data to us */ + cipher_t outcipher; /* Cipher we will use to send data to him */ + digest_t indigest; + digest_t outdigest; - RSA *rsa_key; /* his public/private key */ - const EVP_CIPHER *incipher; /* Cipher he will use to send data to us */ - const EVP_CIPHER *outcipher; /* Cipher we will use to send data to him */ - EVP_CIPHER_CTX *inctx; /* Context of encrypted meta data that will come from him to us */ - EVP_CIPHER_CTX *outctx; /* Context of encrypted meta data that will be sent from us to him */ - uint64_t inbudget; /* Encrypted bytes send budget */ - uint64_t outbudget; /* Encrypted bytes receive budget */ - char *inkey; /* His symmetric meta key + iv */ - char *outkey; /* Our symmetric meta key + iv */ - int inkeylength; /* Length of his key + iv */ - int outkeylength; /* Length of our key + iv */ - const EVP_MD *indigest; - const EVP_MD *outdigest; int inmaclength; int outmaclength; int incompression; int outcompression; - char *mychallenge; /* challenge we received from him */ - char *hischallenge; /* challenge we sent to him */ - char buffer[MAXBUFSIZE]; /* metadata input buffer */ - int buflen; /* bytes read into buffer */ - int reqlen; /* length of incoming request */ - length_t tcplen; /* length of incoming TCPpacket */ - int allow_request; /* defined if there's only one request possible */ + char *hischallenge; /* The challenge we sent to him */ - char *outbuf; /* metadata output buffer */ - int outbufstart; /* index of first meaningful byte in output buffer */ - int outbuflen; /* number of meaningful bytes in output buffer */ - int outbufsize; /* number of bytes allocated to output buffer */ + struct buffer_t inbuf; + struct buffer_t outbuf; + struct event inevent; /* input event on this metadata connection */ + struct event outevent; /* output event on this metadata connection */ + int tcplen; /* length of incoming TCPpacket */ + int allow_request; /* defined if there's only one request possible */ - time_t last_ping_time; /* last time we saw some activity from the other end or pinged them */ - time_t last_flushed_time; /* last time buffer was empty. Only meaningful if outbuflen > 0 */ + time_t last_ping_time; /* last time we saw some activity from the other end or pinged them */ - avl_tree_t *config_tree; /* Pointer to configuration tree belonging to him */ + splay_tree_t *config_tree; /* Pointer to configuration tree belonging to him */ } connection_t; -extern avl_tree_t *connection_tree; -extern connection_t *everyone; +extern splay_tree_t *connection_tree; +extern connection_t *broadcast; extern void init_connections(void); extern void exit_connections(void); -extern connection_t *new_connection(void) __attribute__((__malloc__)); -extern void free_connection(connection_t *c); -extern void free_connection_partially(connection_t *c); -extern void connection_add(connection_t *c); -extern void connection_del(connection_t *c); -extern void dump_connections(void); +extern connection_t *new_connection(void) __attribute__ ((__malloc__)); +extern void free_connection(connection_t *); +extern void connection_add(connection_t *); +extern void connection_del(connection_t *); +extern bool dump_connections(struct connection_t *); -#endif +#endif /* __TINC_CONNECTION_H__ */ diff --git a/src/control.c b/src/control.c new file mode 100644 index 0000000..86224c2 --- /dev/null +++ b/src/control.c @@ -0,0 +1,182 @@ +/* + control.c -- Control socket handling. + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" +#include "crypto.h" +#include "conf.h" +#include "control.h" +#include "control_common.h" +#include "graph.h" +#include "logger.h" +#include "meta.h" +#include "net.h" +#include "netutl.h" +#include "protocol.h" +#include "route.h" +#include "splay_tree.h" +#include "utils.h" +#include "xalloc.h" + +char controlcookie[65]; +extern char *pidfilename; + +static bool control_return(connection_t *c, int type, int error) { + return send_request(c, "%d %d %d", CONTROL, type, error); +} + +static bool control_ok(connection_t *c, int type) { + return control_return(c, type, 0); +} + +bool control_h(connection_t *c, char *request) { + int type; + + if(!c->status.control || c->allow_request != CONTROL) { + logger(LOG_ERR, "Unauthorized control request from %s (%s)", c->name, c->hostname); + return false; + } + + if(sscanf(request, "%*d %d", &type) != 1) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "CONTROL", c->name, c->hostname); + return false; + } + + switch (type) { + case REQ_STOP: + event_loopexit(NULL); + return control_ok(c, REQ_STOP); + + case REQ_DUMP_NODES: + return dump_nodes(c); + + case REQ_DUMP_EDGES: + return dump_edges(c); + + case REQ_DUMP_SUBNETS: + return dump_subnets(c); + + case REQ_DUMP_CONNECTIONS: + return dump_connections(c); + + case REQ_PURGE: + purge(); + return control_ok(c, REQ_PURGE); + + case REQ_SET_DEBUG: { + int new_level; + if(sscanf(request, "%*d %*d %d", &new_level) != 1) + return false; + send_request(c, "%d %d %d", CONTROL, REQ_SET_DEBUG, debug_level); + if(new_level >= 0) + debug_level = new_level; + return true; + } + + case REQ_RETRY: + retry(); + return control_ok(c, REQ_RETRY); + + case REQ_RELOAD: + logger(LOG_NOTICE, "Got '%s' command", "reload"); + int result = reload_configuration(); + return control_return(c, REQ_RELOAD, result); + + case REQ_DISCONNECT: { + char name[MAX_STRING_SIZE]; + connection_t *other; + splay_node_t *node, *next; + bool found = false; + + if(sscanf(request, "%*d %*d " MAX_STRING, name) != 1) + return control_return(c, REQ_DISCONNECT, -1); + + for(node = connection_tree->head; node; node = next) { + next = node->next; + other = node->data; + if(strcmp(other->name, name)) + continue; + terminate_connection(other, other->status.active); + found = true; + } + + return control_return(c, REQ_DISCONNECT, found ? 0 : -2); + } + + case REQ_DUMP_TRAFFIC: + return dump_traffic(c); + + case REQ_PCAP: + c->status.pcap = true; + pcap = true; + return true; + + default: + return send_request(c, "%d %d", CONTROL, REQ_INVALID); + } +} + +bool init_control(void) { + randomize(controlcookie, sizeof controlcookie / 2); + bin2hex(controlcookie, controlcookie, sizeof controlcookie / 2); + + FILE *f = fopen(pidfilename, "w"); + if(!f) { + logger(LOG_ERR, "Cannot write control socket cookie file %s: %s", pidfilename, strerror(errno)); + return false; + } + +#ifdef HAVE_FCHMOD + fchmod(fileno(f), 0600); +#else + chmod(pidfilename, 0600); +#endif + // Get the address and port of the first listening socket + + char *localhost = NULL; + sockaddr_t sa; + socklen_t len = sizeof sa; + + // Make sure we have a valid address, and map 0.0.0.0 and :: to 127.0.0.1 and ::1. + + if(getsockname(listen_socket[0].tcp, (struct sockaddr *)&sa, &len)) { + xasprintf(&localhost, "127.0.0.1 port %d", myport); + } else { + if(sa.sa.sa_family == AF_INET) { + if(sa.in.sin_addr.s_addr == 0) + sa.in.sin_addr.s_addr = htonl(0x7f000001); + } else if(sa.sa.sa_family == AF_INET6) { + static const uint8_t zero[16] = {0}; + if(!memcmp(sa.in6.sin6_addr.s6_addr, zero, sizeof zero)) + sa.in6.sin6_addr.s6_addr[15] = 1; + } + + localhost = sockaddr2hostname(&sa); + } + + fprintf(f, "%d %s %s\n", (int)getpid(), controlcookie, localhost); + + free(localhost); + fclose(f); + + return true; +} + +void exit_control(void) { + unlink(pidfilename); +} diff --git a/src/control.h b/src/control.h new file mode 100644 index 0000000..ce8145a --- /dev/null +++ b/src/control.h @@ -0,0 +1,27 @@ +/* + control.h -- header for control.c. + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_CONTROL_H__ +#define __TINC_CONTROL_H__ + +extern bool init_control(); +extern void exit_control(); +extern char controlcookie[]; + +#endif diff --git a/src/control_common.h b/src/control_common.h new file mode 100644 index 0000000..615e10a --- /dev/null +++ b/src/control_common.h @@ -0,0 +1,46 @@ +/* + control_protocol.h -- control socket protocol. + Copyright (C) 2007 Scott Lamb + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_CONTROL_PROTOCOL_H__ +#define __TINC_CONTROL_PROTOCOL_H__ + +#include "protocol.h" + +enum request_type { + REQ_INVALID = -1, + REQ_STOP = 0, + REQ_RELOAD, + REQ_RESTART, + REQ_DUMP_NODES, + REQ_DUMP_EDGES, + REQ_DUMP_SUBNETS, + REQ_DUMP_CONNECTIONS, + REQ_DUMP_GRAPH, + REQ_PURGE, + REQ_SET_DEBUG, + REQ_RETRY, + REQ_CONNECT, + REQ_DISCONNECT, + REQ_DUMP_TRAFFIC, + REQ_PCAP, +}; + +#define TINC_CTL_VERSION_CURRENT 0 + +#endif diff --git a/src/cygwin/device.c b/src/cygwin/device.c index 1165d67..a4ab938 100644 --- a/src/cygwin/device.c +++ b/src/cygwin/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction with Windows tap driver in a Cygwin environment Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2016 Guus Sliepen + 2002-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,26 +18,26 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "../system.h" -#include "../net.h" +#include "system.h" #include #include -#include "../conf.h" -#include "../device.h" -#include "../logger.h" -#include "../route.h" -#include "../utils.h" -#include "../xalloc.h" +#include "conf.h" +#include "device.h" +#include "logger.h" +#include "net.h" +#include "route.h" +#include "utils.h" +#include "xalloc.h" -#include "../mingw/common.h" +#include "mingw/common.h" int device_fd = -1; static HANDLE device_handle = INVALID_HANDLE_VALUE; char *device = NULL; char *iface = NULL; -static const char *device_info = "Windows tap device"; +static char *device_info = NULL; static uint64_t device_total_in = 0; static uint64_t device_total_out = 0; @@ -45,7 +45,7 @@ static uint64_t device_total_out = 0; static pid_t reader_pid; static int sp[2]; -static bool setup_device(void) { +bool setup_device(void) { HKEY key, key2; int i, err; @@ -61,10 +61,6 @@ static bool setup_device(void) { get_config_string(lookup_config(config_tree, "Device"), &device); get_config_string(lookup_config(config_tree, "Interface"), &iface); - if(device && iface) { - logger(LOG_WARNING, "Warning: both Device and Interface specified, results may not be as expected"); - } - /* Open registry and look for network adapters */ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWORK_CONNECTIONS_KEY, 0, KEY_READ, &key)) { @@ -72,51 +68,44 @@ static bool setup_device(void) { return false; } - for(i = 0; ; i++) { - len = sizeof(adapterid); - - if(RegEnumKeyEx(key, i, adapterid, &len, 0, 0, 0, NULL)) { + for (i = 0; ; i++) { + len = sizeof adapterid; + if(RegEnumKeyEx(key, i, adapterid, &len, 0, 0, 0, NULL)) break; - } /* Find out more about this adapter */ - snprintf(regpath, sizeof(regpath), "%s\\%s\\Connection", NETWORK_CONNECTIONS_KEY, adapterid); + snprintf(regpath, sizeof regpath, "%s\\%s\\Connection", NETWORK_CONNECTIONS_KEY, adapterid); - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, regpath, 0, KEY_READ, &key2)) { + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, regpath, 0, KEY_READ, &key2)) continue; - } - len = sizeof(adaptername); + len = sizeof adaptername; err = RegQueryValueEx(key2, "Name", 0, 0, adaptername, &len); RegCloseKey(key2); - if(err) { + if(err) continue; - } if(device) { if(!strcmp(device, adapterid)) { found = true; break; - } else { + } else continue; - } } if(iface) { if(!strcmp(iface, adaptername)) { found = true; break; - } else { + } else continue; - } } - snprintf(tapname, sizeof(tapname), USERMODEDEVICEDIR "%s" TAPSUFFIX, adapterid); + snprintf(tapname, sizeof tapname, USERMODEDEVICEDIR "%s" TAPSUFFIX, adapterid); device_handle = CreateFile(tapname, GENERIC_WRITE | GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, 0); - if(device_handle != INVALID_HANDLE_VALUE) { CloseHandle(device_handle); found = true; @@ -131,16 +120,14 @@ static bool setup_device(void) { return false; } - if(!device) { + if(!device) device = xstrdup(adapterid); - } - if(!iface) { + if(!iface) iface = xstrdup(adaptername); - } - - snprintf(tapname, sizeof(tapname), USERMODEDEVICEDIR "%s" TAPSUFFIX, device); + snprintf(tapname, sizeof tapname, USERMODEDEVICEDIR "%s" TAPSUFFIX, device); + /* Now we are going to open this device twice: once for reading and once for writing. We do this because apparently it isn't possible to check for activity in the select() loop. Furthermore I don't really know how to do it the "Windows" way. */ @@ -151,9 +138,9 @@ static bool setup_device(void) { } /* The parent opens the tap device for writing. */ - - device_handle = CreateFile(tapname, GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, 0); - + + device_handle = CreateFile(tapname, GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM , 0); + if(device_handle == INVALID_HANDLE_VALUE) { logger(LOG_ERR, "Could not open Windows tap device %s (%s) for writing: %s", device, iface, winerror(GetLastError())); return false; @@ -163,7 +150,7 @@ static bool setup_device(void) { /* Get MAC address from tap device */ - if(!DeviceIoControl(device_handle, TAP_IOCTL_GET_MAC, mymac.x, sizeof(mymac.x), mymac.x, sizeof(mymac.x), &len, 0)) { + if(!DeviceIoControl(device_handle, TAP_IOCTL_GET_MAC, mymac.x, sizeof mymac.x, mymac.x, sizeof mymac.x, &len, 0)) { logger(LOG_ERR, "Could not get MAC address from Windows tap device %s (%s): %s", device, iface, winerror(GetLastError())); return false; } @@ -184,9 +171,9 @@ static bool setup_device(void) { if(!reader_pid) { /* The child opens the tap device for reading, blocking. It passes everything it reads to the socket. */ - + char buf[MTU]; - long lenin; + long inlen; CloseHandle(device_handle); @@ -209,24 +196,25 @@ static bool setup_device(void) { /* Pass packets */ for(;;) { - ReadFile(device_handle, buf, MTU, &lenin, NULL); - write(sp[1], buf, lenin); + ReadFile(device_handle, buf, MTU, &inlen, NULL); + write(sp[1], buf, inlen); } } read(device_fd, &gelukt, 1); - if(gelukt != 1) { logger(LOG_DEBUG, "Tap reader failed!"); return false; } + device_info = "Windows tap device"; + logger(LOG_INFO, "%s (%s) is a %s", device, iface, device_info); return true; } -static void close_device(void) { +void close_device(void) { close(sp[0]); close(sp[1]); CloseHandle(device_handle); @@ -237,32 +225,32 @@ static void close_device(void) { free(iface); } -static bool read_packet(vpn_packet_t *packet) { - int lenin; +bool read_packet(vpn_packet_t *packet) { + int inlen; - if((lenin = read(sp[0], packet->data, MTU)) <= 0) { + if((inlen = read(sp[0], packet->data, MTU)) <= 0) { logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, - device, strerror(errno)); + device, strerror(errno)); return false; } - - packet->len = lenin; + + packet->len = inlen; device_total_in += packet->len; ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, - device_info); + device_info); return true; } -static bool write_packet(vpn_packet_t *packet) { - long lenout; +bool write_packet(vpn_packet_t *packet) { + long outlen; ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + packet->len, device_info); - if(!WriteFile(device_handle, packet->data, packet->len, &lenout, NULL)) { + if(!WriteFile (device_handle, packet->data, packet->len, &outlen, NULL)) { logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, device, winerror(GetLastError())); return false; } @@ -272,16 +260,8 @@ static bool write_packet(vpn_packet_t *packet) { return true; } -static void dump_device_stats(void) { +void dump_device_stats(void) { logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); } - -const devops_t os_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, - .dump_stats = dump_device_stats, -}; diff --git a/src/device.h b/src/device.h index 6bfc44d..16a2486 100644 --- a/src/device.h +++ b/src/device.h @@ -1,10 +1,7 @@ -#ifndef TINC_DEVICE_H -#define TINC_DEVICE_H - /* - device.h -- generic header for device.c + net.h -- generic header for device.c Copyright (C) 2001-2005 Ivo Timmermans - 2001-2012 Guus Sliepen + 2001-2006 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,27 +18,24 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_DEVICE_H__ +#define __TINC_DEVICE_H__ + #include "net.h" extern int device_fd; extern char *device; - extern char *iface; -typedef struct devops_t { - bool (*setup)(void); - void (*close)(void); - bool (*read)(struct vpn_packet_t *packet); - bool (*write)(struct vpn_packet_t *packet); - void (*dump_stats)(void); -} devops_t; +extern uint64_t device_in_packets; +extern uint64_t device_in_bytes; +extern uint64_t device_out_packets; +extern uint64_t device_out_bytes; -extern const devops_t os_devops; -extern const devops_t dummy_devops; -extern const devops_t raw_socket_devops; -extern const devops_t multicast_devops; -extern const devops_t uml_devops; -extern const devops_t vde_devops; -extern devops_t devops; +extern bool setup_device(void); +extern void close_device(void); +extern bool read_packet(struct vpn_packet_t *); +extern bool write_packet(struct vpn_packet_t *); +extern void dump_device_stats(void); -#endif +#endif /* __TINC_DEVICE_H__ */ diff --git a/src/dropin.c b/src/dropin.c index 93511f1..eb17aca 100644 --- a/src/dropin.c +++ b/src/dropin.c @@ -1,7 +1,7 @@ /* dropin.c -- a set of drop-in replacements for libc functions Copyright (C) 2000-2005 Ivo Timmermans, - 2000-2016 Guus Sliepen + 2000-2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ #ifndef HAVE_DAEMON /* Replacement for the daemon() function. - + The daemon() function is for programs wishing to detach themselves from the controlling terminal and run in the background as system daemons. @@ -50,9 +50,8 @@ int daemon(int nochdir, int noclose) { } /* If we are the parent, terminate */ - if(pid) { + if(pid) exit(0); - } /* Detach by becoming the new process group leader */ if(setsid() < 0) { @@ -87,6 +86,40 @@ int daemon(int nochdir, int noclose) { } #endif +#ifndef HAVE_GET_CURRENT_DIR_NAME +/* + Replacement for the GNU get_current_dir_name function: + + get_current_dir_name will malloc(3) an array big enough to hold the + current directory name. If the environment variable PWD is set, and + its value is correct, then that value will be returned. +*/ +char *get_current_dir_name(void) { + size_t size; + char *buf; + char *r; + + /* Start with 100 bytes. If this turns out to be insufficient to + contain the working directory, double the size. */ + size = 100; + buf = xmalloc(size); + + errno = 0; /* Success */ + r = getcwd(buf, size); + + /* getcwd returns NULL and sets errno to ERANGE if the bufferspace + is insufficient to contain the entire working directory. */ + while(r == NULL && errno == ERANGE) { + free(buf); + size <<= 1; /* double the size */ + buf = xmalloc(size); + r = getcwd(buf, size); + } + + return buf; +} +#endif + #ifndef HAVE_ASPRINTF int asprintf(char **buf, const char *fmt, ...) { int result; @@ -107,12 +140,10 @@ int vasprintf(char **buf, const char *fmt, va_list ap) { va_copy(aq, ap); status = vsnprintf(*buf, len, fmt, aq); - buf[len - 1] = 0; va_end(aq); - if(status >= 0) { + if(status >= 0) *buf = xrealloc(*buf, status + 1); - } if(status > len - 1) { len = status; diff --git a/src/dropin.h b/src/dropin.h index 012099b..3617b70 100644 --- a/src/dropin.h +++ b/src/dropin.h @@ -1,6 +1,3 @@ -#ifndef TINC_DROPIN_H -#define TINC_DROPIN_H - /* dropin.h -- header file for dropin.c Copyright (C) 2000-2005 Ivo Timmermans, @@ -21,11 +18,14 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __DROPIN_H__ +#define __DROPIN_H__ + #include "fake-getaddrinfo.h" #include "fake-getnameinfo.h" #ifndef HAVE_DAEMON -extern int daemon(int nochdir, int noclose); +extern int daemon(int, int); #endif #ifndef HAVE_GET_CURRENT_DIR_NAME @@ -33,16 +33,16 @@ extern char *get_current_dir_name(void); #endif #ifndef HAVE_ASPRINTF -extern int asprintf(char **buf, const char *fmt, ...); -extern int vasprintf(char **buf, const char *fmt, va_list ap); +extern int asprintf(char **, const char *, ...); +extern int vasprintf(char **, const char *, va_list ap); #endif #ifndef HAVE_GETTIMEOFDAY -extern int gettimeofday(struct timeval *tv, void *tz); +extern int gettimeofday(struct timeval *, void *); #endif #ifndef HAVE_USLEEP extern int usleep(long long usec); #endif -#endif +#endif /* __DROPIN_H__ */ diff --git a/src/dummy_device.c b/src/dummy_device.c deleted file mode 100644 index d1d751b..0000000 --- a/src/dummy_device.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - device.c -- Dummy device - Copyright (C) 2011 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "device.h" -#include "logger.h" -#include "net.h" -#include "xalloc.h" - -static const char *device_info = "dummy device"; - -static uint64_t device_total_in = 0; -static uint64_t device_total_out = 0; - -static bool setup_device(void) { - device = xstrdup("dummy"); - iface = xstrdup("dummy"); - logger(LOG_INFO, "%s (%s) is a %s", device, iface, device_info); - return true; -} - -static void close_device(void) { - free(device); - free(iface); -} - -static bool read_packet(vpn_packet_t *packet) { - (void)packet; - return false; -} - -static bool write_packet(vpn_packet_t *packet) { - device_total_out += packet->len; - return true; -} - -static void dump_device_stats(void) { - logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); - logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); - logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); -} - -const devops_t dummy_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, - .dump_stats = dump_device_stats, -}; diff --git a/src/edge.c b/src/edge.c index c30d6cc..f5aa099 100644 --- a/src/edge.c +++ b/src/edge.c @@ -20,7 +20,8 @@ #include "system.h" -#include "avl_tree.h" +#include "splay_tree.h" +#include "control_common.h" #include "edge.h" #include "logger.h" #include "netutl.h" @@ -28,7 +29,7 @@ #include "utils.h" #include "xalloc.h" -avl_tree_t *edge_weight_tree; /* Tree with all edges, sorted on weight */ +splay_tree_t *edge_weight_tree; /* Tree with all edges, sorted on weight */ static int edge_compare(const edge_t *a, const edge_t *b) { return strcmp(a->to->name, b->to->name); @@ -39,33 +40,31 @@ static int edge_weight_compare(const edge_t *a, const edge_t *b) { result = a->weight - b->weight; - if(result) { + if(result) return result; - } result = strcmp(a->from->name, b->from->name); - if(result) { + if(result) return result; - } return strcmp(a->to->name, b->to->name); } void init_edges(void) { - edge_weight_tree = avl_alloc_tree((avl_compare_t) edge_weight_compare, NULL); + edge_weight_tree = splay_alloc_tree((splay_compare_t) edge_weight_compare, NULL); } -avl_tree_t *new_edge_tree(void) { - return avl_alloc_tree((avl_compare_t) edge_compare, (avl_action_t) free_edge); +splay_tree_t *new_edge_tree(void) { + return splay_alloc_tree((splay_compare_t) edge_compare, (splay_action_t) free_edge); } -void free_edge_tree(avl_tree_t *edge_tree) { - avl_delete_tree(edge_tree); +void free_edge_tree(splay_tree_t *edge_tree) { + splay_delete_tree(edge_tree); } void exit_edges(void) { - avl_delete_tree(edge_weight_tree); + splay_delete_tree(edge_weight_tree); } /* Creation and deletion of connection elements */ @@ -81,53 +80,50 @@ void free_edge(edge_t *e) { } void edge_add(edge_t *e) { - avl_insert(edge_weight_tree, e); - avl_insert(e->from->edge_tree, e); + splay_insert(edge_weight_tree, e); + splay_insert(e->from->edge_tree, e); e->reverse = lookup_edge(e->to, e->from); - if(e->reverse) { + if(e->reverse) e->reverse->reverse = e; - } } void edge_del(edge_t *e) { - if(e->reverse) { + if(e->reverse) e->reverse->reverse = NULL; - } - avl_delete(edge_weight_tree, e); - avl_delete(e->from->edge_tree, e); + splay_delete(edge_weight_tree, e); + splay_delete(e->from->edge_tree, e); } edge_t *lookup_edge(node_t *from, node_t *to) { edge_t v; - + v.from = from; v.to = to; - return avl_search(from->edge_tree, &v); + return splay_search(from->edge_tree, &v); } -void dump_edges(void) { - avl_node_t *node, *node2; +bool dump_edges(connection_t *c) { + splay_node_t *node, *node2; node_t *n; edge_t *e; char *address; - logger(LOG_DEBUG, "Edges:"); - for(node = node_tree->head; node; node = node->next) { n = node->data; - for(node2 = n->edge_tree->head; node2; node2 = node2->next) { e = node2->data; address = sockaddr2hostname(&e->address); - logger(LOG_DEBUG, " %s to %s at %s options %x weight %d", - e->from->name, e->to->name, address, e->options, e->weight); + send_request(c, "%d %d %s to %s at %s options %x weight %d", + CONTROL, REQ_DUMP_EDGES, + e->from->name, e->to->name, address, + e->options, e->weight); free(address); } } - logger(LOG_DEBUG, "End of edges."); + return send_request(c, "%d %d", CONTROL, REQ_DUMP_EDGES); } diff --git a/src/edge.h b/src/edge.h index a7a6302..ea45f49 100644 --- a/src/edge.h +++ b/src/edge.h @@ -1,6 +1,3 @@ -#ifndef TINC_EDGE_H -#define TINC_EDGE_H - /* edge.h -- header for edge.c Copyright (C) 2001-2006 Guus Sliepen , @@ -21,7 +18,10 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "avl_tree.h" +#ifndef __TINC_EDGE_H__ +#define __TINC_EDGE_H__ + +#include "splay_tree.h" #include "connection.h" #include "net.h" #include "node.h" @@ -31,24 +31,24 @@ typedef struct edge_t { struct node_t *to; sockaddr_t address; - uint32_t options; /* options turned on for this edge */ - int weight; /* weight of this edge */ + uint32_t options; /* options turned on for this edge */ + int weight; /* weight of this edge */ - struct connection_t *connection; /* connection associated with this edge, if available */ - struct edge_t *reverse; /* edge in the opposite direction, if available */ + struct connection_t *connection; /* connection associated with this edge, if available */ + struct edge_t *reverse; /* edge in the opposite direction, if available */ } edge_t; -extern avl_tree_t *edge_weight_tree; /* Tree with all known edges sorted on weight */ +extern splay_tree_t *edge_weight_tree; /* Tree with all known edges sorted on weight */ extern void init_edges(void); extern void exit_edges(void); -extern edge_t *new_edge(void) __attribute__((__malloc__)); -extern void free_edge(edge_t *e); -extern avl_tree_t *new_edge_tree(void) __attribute__((__malloc__)); -extern void free_edge_tree(avl_tree_t *edge_tree); -extern void edge_add(edge_t *e); -extern void edge_del(edge_t *e); -extern edge_t *lookup_edge(struct node_t *from, struct node_t *to); -extern void dump_edges(void); +extern edge_t *new_edge(void) __attribute__ ((__malloc__)); +extern void free_edge(edge_t *); +extern splay_tree_t *new_edge_tree(void) __attribute__ ((__malloc__)); +extern void free_edge_tree(splay_tree_t *); +extern void edge_add(edge_t *); +extern void edge_del(edge_t *); +extern edge_t *lookup_edge(struct node_t *, struct node_t *); +extern bool dump_edges(struct connection_t *); -#endif +#endif /* __TINC_EDGE_H__ */ diff --git a/src/ethernet.h b/src/ethernet.h index 32f5553..eef5f42 100644 --- a/src/ethernet.h +++ b/src/ethernet.h @@ -1,6 +1,3 @@ -#ifndef TINC_ETHERNET_H -#define TINC_ETHERNET_H - /* ethernet.h -- missing Ethernet related definitions Copyright (C) 2005 Ivo Timmermans @@ -21,6 +18,9 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_ETHERNET_H__ +#define __TINC_ETHERNET_H__ + #ifndef ETH_ALEN #define ETH_ALEN 6 #endif @@ -41,16 +41,12 @@ #define ETH_P_IPV6 0x86DD #endif -#ifndef ETH_P_8021Q -#define ETH_P_8021Q 0x8100 -#endif - #ifndef HAVE_STRUCT_ETHER_HEADER struct ether_header { uint8_t ether_dhost[ETH_ALEN]; uint8_t ether_shost[ETH_ALEN]; uint16_t ether_type; -} __attribute__((__packed__)); +} __attribute__ ((__packed__)); #endif #ifndef HAVE_STRUCT_ARPHDR @@ -58,17 +54,17 @@ struct arphdr { uint16_t ar_hrd; uint16_t ar_pro; uint8_t ar_hln; - uint8_t ar_pln; - uint16_t ar_op; -} __attribute__((__packed__)); + uint8_t ar_pln; + uint16_t ar_op; +} __attribute__ ((__packed__)); -#define ARPOP_REQUEST 1 -#define ARPOP_REPLY 2 -#define ARPOP_RREQUEST 3 -#define ARPOP_RREPLY 4 -#define ARPOP_InREQUEST 8 -#define ARPOP_InREPLY 9 -#define ARPOP_NAK 10 +#define ARPOP_REQUEST 1 +#define ARPOP_REPLY 2 +#define ARPOP_RREQUEST 3 +#define ARPOP_RREPLY 4 +#define ARPOP_InREQUEST 8 +#define ARPOP_InREPLY 9 +#define ARPOP_NAK 10 #endif #ifndef HAVE_STRUCT_ETHER_ARP @@ -78,7 +74,7 @@ struct ether_arp { uint8_t arp_spa[4]; uint8_t arp_tha[ETH_ALEN]; uint8_t arp_tpa[4]; -} __attribute__((__packed__)); +} __attribute__ ((__packed__)); #define arp_hrd ea_hdr.ar_hrd #define arp_pro ea_hdr.ar_pro #define arp_hln ea_hdr.ar_hln @@ -86,4 +82,4 @@ struct ether_arp { #define arp_op ea_hdr.ar_op #endif -#endif +#endif /* __TINC_ETHERNET_H__ */ diff --git a/src/event.c b/src/event.c deleted file mode 100644 index 1223222..0000000 --- a/src/event.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - event.c -- event queue - Copyright (C) 2002-2009 Guus Sliepen , - 2002-2005 Ivo Timmermans - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "avl_tree.h" -#include "event.h" -#include "utils.h" -#include "xalloc.h" - -avl_tree_t *event_tree; -extern time_t now; - -static int id; - -static int event_compare(const event_t *a, const event_t *b) { - if(a->time > b->time) { - return 1; - } - - if(a->time < b->time) { - return -1; - } - - return a->id - b->id; -} - -void init_events(void) { - event_tree = avl_alloc_tree((avl_compare_t) event_compare, (avl_action_t) free_event); -} - -void exit_events(void) { - avl_delete_tree(event_tree); -} - -void expire_events(void) { - avl_node_t *node; - event_t *event; - time_t diff; - - /* - * Make all events appear expired by subtracting the difference between - * the expiration time of the last event and the current time. - */ - - if(!event_tree->tail) { - return; - } - - event = event_tree->tail->data; - - if(event->time <= now) { - return; - } - - diff = event->time - now; - - for(node = event_tree->head; node; node = node->next) { - event = node->data; - event->time -= diff; - } -} - -event_t *new_event(void) { - return xmalloc_and_zero(sizeof(event_t)); -} - -void free_event(event_t *event) { - free(event); -} - -void event_add(event_t *event) { - event->id = ++id; - avl_insert(event_tree, event); -} - -void event_del(event_t *event) { - avl_delete(event_tree, event); -} - -event_t *get_expired_event(void) { - event_t *event; - - if(event_tree->head) { - event = event_tree->head->data; - - if(event->time <= now) { - avl_node_t *node = event_tree->head; - avl_unlink_node(event_tree, node); - free(node); - return event; - } - } - - return NULL; -} - -event_t *peek_next_event(void) { - if(event_tree->head) { - return event_tree->head->data; - } - - return NULL; -} diff --git a/src/fake-gai-errnos.h b/src/fake-gai-errnos.h new file mode 100644 index 0000000..4ffabb6 --- /dev/null +++ b/src/fake-gai-errnos.h @@ -0,0 +1,19 @@ +/* + * fake library for ssh + * + * This file is included in getaddrinfo.c and getnameinfo.c. + * See getaddrinfo.c and getnameinfo.c. + */ + +/* for old netdb.h */ +#ifndef EAI_NODATA +#define EAI_NODATA 1 +#endif + +#ifndef EAI_MEMORY +#define EAI_MEMORY 2 +#endif + +#ifndef EAI_FAMILY +#define EAI_FAMILY 3 +#endif diff --git a/src/fake-getaddrinfo.c b/src/fake-getaddrinfo.c index 1ee11c5..df3d347 100644 --- a/src/fake-getaddrinfo.c +++ b/src/fake-getaddrinfo.c @@ -2,10 +2,10 @@ * fake library for ssh * * This file includes getaddrinfo(), freeaddrinfo() and gai_strerror(). - * These functions are defined in rfc2133. + * These funtions are defined in rfc2133. * * But these functions are not implemented correctly. The minimum subset - * is implemented for ssh use only. For example, this routine assumes + * is implemented for ssh use only. For exapmle, this routine assumes * that ai_family is AF_INET. Don't use it for another purpose. */ @@ -16,22 +16,20 @@ #include "fake-getaddrinfo.h" #include "xalloc.h" + #if !HAVE_DECL_GAI_STRERROR char *gai_strerror(int ecode) { - switch(ecode) { - case EAI_NODATA: - return "No address associated with hostname"; - - case EAI_MEMORY: - return "Memory allocation failure"; - - case EAI_FAMILY: - return "Address family not supported"; - - default: - return "Unknown error"; + switch (ecode) { + case EAI_NODATA: + return "No address associated with hostname"; + case EAI_MEMORY: + return "Memory allocation failure"; + case EAI_FAMILY: + return "Address family not supported"; + default: + return "Unknown error"; } -} +} #endif /* !HAVE_GAI_STRERROR */ #if !HAVE_DECL_FREEADDRINFO @@ -51,14 +49,14 @@ static struct addrinfo *malloc_ai(uint16_t port, uint32_t addr) { struct addrinfo *ai; ai = xmalloc_and_zero(sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); - + ai->ai_addr = (struct sockaddr *)(ai + 1); ai->ai_addrlen = sizeof(struct sockaddr_in); ai->ai_addr->sa_family = ai->ai_family = AF_INET; ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; - + return ai; } @@ -69,36 +67,32 @@ int getaddrinfo(const char *hostname, const char *servname, const struct addrinf int i; uint16_t port = 0; - if(hints && hints->ai_family != AF_INET && hints->ai_family != AF_UNSPEC) { + if(hints && hints->ai_family != AF_INET && hints->ai_family != AF_UNSPEC) return EAI_FAMILY; - } - if(servname) { + if (servname) port = htons(atoi(servname)); - } - if(hints && hints->ai_flags & AI_PASSIVE) { + if (hints && hints->ai_flags & AI_PASSIVE) { *res = malloc_ai(port, htonl(0x00000000)); return 0; } - - if(!hostname) { + + if (!hostname) { *res = malloc_ai(port, htonl(0x7f000001)); return 0; } - + hp = gethostbyname(hostname); - if(!hp || !hp->h_addr_list || !hp->h_addr_list[0]) { + if(!hp || !hp->h_addr_list || !hp->h_addr_list[0]) return EAI_NODATA; - } - for(i = 0; hp->h_addr_list[i]; i++) { + for (i = 0; hp->h_addr_list[i]; i++) { *res = malloc_ai(port, ((struct in_addr *)hp->h_addr_list[i])->s_addr); - if(prev) { + if(prev) prev->ai_next = *res; - } prev = *res; } diff --git a/src/fake-getaddrinfo.h b/src/fake-getaddrinfo.h index f10cb83..5af7491 100644 --- a/src/fake-getaddrinfo.h +++ b/src/fake-getaddrinfo.h @@ -1,17 +1,7 @@ -#ifndef TINC_FAKE_GETADDRINFO_H -#define TINC_FAKE_GETADDRINFO_H +#ifndef _FAKE_GETADDRINFO_H +#define _FAKE_GETADDRINFO_H -#ifndef EAI_NODATA -#define EAI_NODATA 1 -#endif - -#ifndef EAI_MEMORY -#define EAI_MEMORY 2 -#endif - -#ifndef EAI_FAMILY -#define EAI_FAMILY 3 -#endif +#include "fake-gai-errnos.h" #ifndef AI_PASSIVE # define AI_PASSIVE 1 @@ -30,19 +20,19 @@ #ifndef HAVE_STRUCT_ADDRINFO struct addrinfo { - int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ - int ai_family; /* PF_xxx */ - int ai_socktype; /* SOCK_xxx */ - int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ - size_t ai_addrlen; /* length of ai_addr */ - char *ai_canonname; /* canonical name for hostname */ - struct sockaddr *ai_addr; /* binary address */ - struct addrinfo *ai_next; /* next structure in linked list */ + int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for hostname */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ }; #endif /* !HAVE_STRUCT_ADDRINFO */ #if !HAVE_DECL_GETADDRINFO -int getaddrinfo(const char *hostname, const char *servname, +int getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res); #endif /* !HAVE_GETADDRINFO */ @@ -54,4 +44,4 @@ char *gai_strerror(int ecode); void freeaddrinfo(struct addrinfo *ai); #endif /* !HAVE_FREEADDRINFO */ -#endif +#endif /* _FAKE_GETADDRINFO_H */ diff --git a/src/fake-getnameinfo.c b/src/fake-getnameinfo.c index e51bce2..1eba492 100644 --- a/src/fake-getnameinfo.c +++ b/src/fake-getnameinfo.c @@ -2,10 +2,10 @@ * fake library for ssh * * This file includes getnameinfo(). - * These functions are defined in rfc2133. + * These funtions are defined in rfc2133. * * But these functions are not implemented correctly. The minimum subset - * is implemented for ssh use only. For example, this routine assumes + * is implemented for ssh use only. For exapmle, this routine assumes * that ai_family is AF_INET. Don't use it for another purpose. */ @@ -21,43 +21,33 @@ int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t host struct hostent *hp; int len; - if(sa->sa_family != AF_INET) { + if(sa->sa_family != AF_INET) return EAI_FAMILY; - } if(serv && servlen) { len = snprintf(serv, servlen, "%d", ntohs(sin->sin_port)); - - if(len < 0 || len >= servlen) { + if(len < 0 || len >= servlen) return EAI_MEMORY; - } } - if(!host || !hostlen) { + if(!host || !hostlen) return 0; - } if(flags & NI_NUMERICHOST) { len = snprintf(host, hostlen, "%s", inet_ntoa(sin->sin_addr)); - - if(len < 0 || len >= hostlen) { + if(len < 0 || len >= hostlen) return EAI_MEMORY; - } - return 0; } hp = gethostbyaddr((char *)&sin->sin_addr, sizeof(struct in_addr), AF_INET); - - if(!hp || !hp->h_name || !hp->h_name[0]) { + + if(!hp || !hp->h_name || !hp->h_name[0]) return EAI_NODATA; - } - + len = snprintf(host, hostlen, "%s", hp->h_name); - - if(len < 0 || len >= hostlen) { + if(len < 0 || len >= hostlen) return EAI_MEMORY; - } return 0; } diff --git a/src/fake-getnameinfo.h b/src/fake-getnameinfo.h index 4f24ad1..4389a8f 100644 --- a/src/fake-getnameinfo.h +++ b/src/fake-getnameinfo.h @@ -1,8 +1,8 @@ -#ifndef TINC_FAKE_GETNAMEINFO_H -#define TINC_FAKE_GETNAMEINFO_H +#ifndef _FAKE_GETNAMEINFO_H +#define _FAKE_GETNAMEINFO_H #if !HAVE_DECL_GETNAMEINFO -int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, +int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); #endif /* !HAVE_GETNAMEINFO */ @@ -13,4 +13,4 @@ int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, # define NI_MAXHOST 1025 #endif /* !NI_MAXHOST */ -#endif +#endif /* _FAKE_GETNAMEINFO_H */ diff --git a/src/gcrypt/cipher.c b/src/gcrypt/cipher.c new file mode 100644 index 0000000..6a2cc5a --- /dev/null +++ b/src/gcrypt/cipher.c @@ -0,0 +1,280 @@ +/* + cipher.c -- Symmetric block cipher handling + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include "cipher.h" +#include "logger.h" +#include "xalloc.h" + +static struct { + const char *name; + int algo; + int mode; + int nid; +} ciphertable[] = { + {"none", GCRY_CIPHER_NONE, GCRY_CIPHER_MODE_NONE, 0}, + + {NULL, GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_ECB, 92}, + {"blowfish", GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_CBC, 91}, + {NULL, GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_CFB, 93}, + {NULL, GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_OFB, 94}, + + {NULL, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 418}, + {"aes", GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CBC, 419}, + {NULL, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CFB, 421}, + {NULL, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_OFB, 420}, + + {NULL, GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_ECB, 422}, + {"aes192", GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_CBC, 423}, + {NULL, GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_CFB, 425}, + {NULL, GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_OFB, 424}, + + {NULL, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_ECB, 426}, + {"aes256", GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC, 427}, + {NULL, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CFB, 429}, + {NULL, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_OFB, 428}, +}; + +static bool nametocipher(const char *name, int *algo, int *mode) { + size_t i; + + for(i = 0; i < sizeof ciphertable / sizeof *ciphertable; i++) { + if(ciphertable[i].name && !strcasecmp(name, ciphertable[i].name)) { + *algo = ciphertable[i].algo; + *mode = ciphertable[i].mode; + return true; + } + } + + return false; +} + +static bool nidtocipher(int nid, int *algo, int *mode) { + size_t i; + + for(i = 0; i < sizeof ciphertable / sizeof *ciphertable; i++) { + if(nid == ciphertable[i].nid) { + *algo = ciphertable[i].algo; + *mode = ciphertable[i].mode; + return true; + } + } + + return false; +} + +static bool ciphertonid(int algo, int mode, int *nid) { + size_t i; + + for(i = 0; i < sizeof ciphertable / sizeof *ciphertable; i++) { + if(algo == ciphertable[i].algo && mode == ciphertable[i].mode) { + *nid = ciphertable[i].nid; + return true; + } + } + + return false; +} + +static bool cipher_open(cipher_t *cipher, int algo, int mode) { + gcry_error_t err; + + if(!ciphertonid(algo, mode, &cipher->nid)) { + logger(LOG_DEBUG, "Cipher %d mode %d has no corresponding nid!", algo, mode); + return false; + } + + if((err = gcry_cipher_open(&cipher->handle, algo, mode, 0))) { + logger(LOG_DEBUG, "Unable to intialise cipher %d mode %d: %s", algo, mode, gcry_strerror(err)); + return false; + } + + cipher->keylen = gcry_cipher_get_algo_keylen(algo); + cipher->blklen = gcry_cipher_get_algo_blklen(algo); + cipher->key = xmalloc(cipher->keylen + cipher->blklen); + cipher->padding = mode == GCRY_CIPHER_MODE_ECB || mode == GCRY_CIPHER_MODE_CBC; + + return true; +} + +bool cipher_open_by_name(cipher_t *cipher, const char *name) { + int algo, mode; + + if(!nametocipher(name, &algo, &mode)) { + logger(LOG_DEBUG, "Unknown cipher name '%s'!", name); + return false; + } + + return cipher_open(cipher, algo, mode); +} + +bool cipher_open_by_nid(cipher_t *cipher, int nid) { + int algo, mode; + + if(!nidtocipher(nid, &algo, &mode)) { + logger(LOG_DEBUG, "Unknown cipher ID %d!", nid); + return false; + } + + return cipher_open(cipher, algo, mode); +} + +bool cipher_open_blowfish_ofb(cipher_t *cipher) { + return cipher_open(cipher, GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_OFB); +} + +void cipher_close(cipher_t *cipher) { + if(cipher->handle) { + gcry_cipher_close(cipher->handle); + cipher->handle = NULL; + } + + if(cipher->key) { + free(cipher->key); + cipher->key = NULL; + } +} + +size_t cipher_keylength(const cipher_t *cipher) { + return cipher->keylen + cipher->blklen; +} + +void cipher_get_key(const cipher_t *cipher, void *key) { + memcpy(key, cipher->key, cipher->keylen + cipher->blklen); +} + +bool cipher_set_key(cipher_t *cipher, void *key, bool encrypt) { + memcpy(cipher->key, key, cipher->keylen + cipher->blklen); + + gcry_cipher_setkey(cipher->handle, cipher->key, cipher->keylen); + gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen); + + return true; +} + +bool cipher_set_key_from_rsa(cipher_t *cipher, void *key, size_t len, bool encrypt) { + memcpy(cipher->key, key + len - cipher->keylen, cipher->keylen + cipher->blklen); + memcpy(cipher->key + cipher->keylen, key + len - cipher->keylen - cipher->blklen, cipher->blklen); + + gcry_cipher_setkey(cipher->handle, cipher->key, cipher->keylen); + gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen); + + return true; +} + +bool cipher_regenerate_key(cipher_t *cipher, bool encrypt) { + gcry_create_nonce(cipher->key, cipher->keylen + cipher->blklen); + + gcry_cipher_setkey(cipher->handle, cipher->key, cipher->keylen); + gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen); + + return true; +} + +bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) { + gcry_error_t err; + uint8_t pad[cipher->blklen]; + + if(cipher->padding) { + if(!oneshot) + return false; + + size_t reqlen = ((inlen + cipher->blklen) / cipher->blklen) * cipher->blklen; + + if(*outlen < reqlen) { + logger(LOG_ERR, "Error while encrypting: not enough room for padding"); + return false; + } + + uint8_t padbyte = reqlen - inlen; + inlen = reqlen - cipher->blklen; + + for(int i = 0; i < cipher->blklen; i++) + if(i < cipher->blklen - padbyte) + pad[i] = ((uint8_t *)indata)[inlen + i]; + else + pad[i] = padbyte; + } + + if(oneshot) + gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen); + + if((err = gcry_cipher_encrypt(cipher->handle, outdata, *outlen, indata, inlen))) { + logger(LOG_ERR, "Error while encrypting: %s", gcry_strerror(err)); + return false; + } + + if(cipher->padding) { + if((err = gcry_cipher_encrypt(cipher->handle, outdata + inlen, cipher->blklen, pad, cipher->blklen))) { + logger(LOG_ERR, "Error while encrypting: %s", gcry_strerror(err)); + return false; + } + + inlen += cipher->blklen; + } + + *outlen = inlen; + return true; +} + +bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) { + gcry_error_t err; + + if(oneshot) + gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen); + + if((err = gcry_cipher_decrypt(cipher->handle, outdata, *outlen, indata, inlen))) { + logger(LOG_ERR, "Error while decrypting: %s", gcry_strerror(err)); + return false; + } + + if(cipher->padding) { + if(!oneshot) + return false; + + uint8_t padbyte = ((uint8_t *)outdata)[inlen - 1]; + + if(padbyte == 0 || padbyte > cipher->blklen || padbyte > inlen) { + logger(LOG_ERR, "Error while decrypting: invalid padding"); + return false; + } + + size_t origlen = inlen - padbyte; + + for(int i = inlen - 1; i >= origlen; i--) + if(((uint8_t *)outdata)[i] != padbyte) { + logger(LOG_ERR, "Error while decrypting: invalid padding"); + return false; + } + + *outlen = origlen; + } else + *outlen = inlen; + + return true; +} + +int cipher_get_nid(const cipher_t *cipher) { + return cipher->nid; +} + +bool cipher_active(const cipher_t *cipher) { + return cipher->nid != 0; +} diff --git a/src/gcrypt/cipher.h b/src/gcrypt/cipher.h new file mode 100644 index 0000000..8e4a2eb --- /dev/null +++ b/src/gcrypt/cipher.h @@ -0,0 +1,52 @@ +/* + cipher.h -- header file cipher.c + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_CIPHER_H__ +#define __TINC_CIPHER_H__ + +#include + +#define CIPHER_MAX_BLOCK_SIZE 32 +#define CIPHER_MAX_IV_SIZE 16 +#define CIPHER_MAX_KEY_SIZE 32 + +typedef struct cipher { + gcry_cipher_hd_t handle; + char *key; + int nid; + uint16_t keylen; + uint16_t blklen; + bool padding; +} cipher_t; + +extern bool cipher_open_by_name(struct cipher *, const char *); +extern bool cipher_open_by_nid(struct cipher *, int); +extern bool cipher_open_blowfish_ofb(struct cipher *); +extern void cipher_close(struct cipher *); +extern size_t cipher_keylength(const struct cipher *); +extern void cipher_get_key(const struct cipher *, void *); +extern bool cipher_set_key(struct cipher *, void *, bool); +extern bool cipher_set_key_from_rsa(struct cipher *, void *, size_t, bool); +extern bool cipher_regenerate_key(struct cipher *, bool); +extern bool cipher_encrypt(struct cipher *, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot); +extern bool cipher_decrypt(struct cipher *, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot); +extern int cipher_get_nid(const struct cipher *); +extern bool cipher_active(const struct cipher *); + +#endif diff --git a/src/gcrypt/crypto.c b/src/gcrypt/crypto.c new file mode 100644 index 0000000..dc92b3e --- /dev/null +++ b/src/gcrypt/crypto.c @@ -0,0 +1,34 @@ +/* + crypto.c -- Cryptographic miscellaneous functions and initialisation + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include + +#include "crypto.h" + +void crypto_init() { +} + +void crypto_exit() { +} + +void randomize(void *out, size_t outlen) { + gcry_create_nonce(out, outlen); +} diff --git a/src/gcrypt/crypto.h b/src/gcrypt/crypto.h new file mode 100644 index 0000000..8047bfb --- /dev/null +++ b/src/gcrypt/crypto.h @@ -0,0 +1,27 @@ +/* + crypto.h -- header for crypto.c + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_CRYPTO_H__ +#define __TINC_CRYPTO_H__ + +extern void crypto_init(); +extern void crypto_exit(); +extern void randomize(void *, size_t); + +#endif diff --git a/src/gcrypt/digest.c b/src/gcrypt/digest.c new file mode 100644 index 0000000..066600f --- /dev/null +++ b/src/gcrypt/digest.c @@ -0,0 +1,173 @@ +/* + digest.c -- Digest handling + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include "digest.h" +#include "logger.h" + +static struct { + const char *name; + int algo; + int nid; +} digesttable[] = { + {"none", GCRY_MD_NONE, 0}, + {"sha1", GCRY_MD_SHA1, 64}, + {"sha256", GCRY_MD_SHA256, 672}, + {"sha384", GCRY_MD_SHA384, 673}, + {"sha512", GCRY_MD_SHA512, 674}, +}; + +static bool nametodigest(const char *name, int *algo) { + int i; + + for(i = 0; i < sizeof digesttable / sizeof *digesttable; i++) { + if(digesttable[i].name && !strcasecmp(name, digesttable[i].name)) { + *algo = digesttable[i].algo; + return true; + } + } + + return false; +} + +static bool nidtodigest(int nid, int *algo) { + int i; + + for(i = 0; i < sizeof digesttable / sizeof *digesttable; i++) { + if(nid == digesttable[i].nid) { + *algo = digesttable[i].algo; + return true; + } + } + + return false; +} + +static bool digesttonid(int algo, int *nid) { + int i; + + for(i = 0; i < sizeof digesttable / sizeof *digesttable; i++) { + if(algo == digesttable[i].algo) { + *nid = digesttable[i].nid; + return true; + } + } + + return false; +} + +static bool digest_open(digest_t *digest, int algo, int maclength) { + if(!digesttonid(algo, &digest->nid)) { + logger(LOG_DEBUG, "Digest %d has no corresponding nid!", algo); + return false; + } + + unsigned int len = gcry_md_get_algo_dlen(algo); + + if(maclength > len || maclength < 0) + digest->maclength = len; + else + digest->maclength = maclength; + + digest->algo = algo; + digest->hmac = NULL; + + return true; +} + +bool digest_open_by_name(digest_t *digest, const char *name, int maclength) { + int algo; + + if(!nametodigest(name, &algo)) { + logger(LOG_DEBUG, "Unknown digest name '%s'!", name); + return false; + } + + return digest_open(digest, algo, maclength); +} + +bool digest_open_by_nid(digest_t *digest, int nid, int maclength) { + int algo; + + if(!nidtodigest(nid, &algo)) { + logger(LOG_DEBUG, "Unknown digest ID %d!", nid); + return false; + } + + return digest_open(digest, algo, maclength); +} + +bool digest_open_sha1(digest_t *digest, int maclength) { + return digest_open(digest, GCRY_MD_SHA1, maclength); +} + +void digest_close(digest_t *digest) { + if(digest->hmac) + gcry_md_close(digest->hmac); + digest->hmac = NULL; +} + +bool digest_set_key(digest_t *digest, const void *key, size_t len) { + if(!digest->hmac) + gcry_md_open(&digest->hmac, digest->algo, GCRY_MD_FLAG_HMAC); + if(!digest->hmac) + return false; + + return !gcry_md_setkey(digest->hmac, key, len); +} + +bool digest_create(digest_t *digest, const void *indata, size_t inlen, void *outdata) { + unsigned int len = gcry_md_get_algo_dlen(digest->algo); + + if(digest->hmac) { + char *tmpdata; + gcry_md_reset(digest->hmac); + gcry_md_write(digest->hmac, indata, inlen); + tmpdata = gcry_md_read(digest->hmac, digest->algo); + if(!tmpdata) + return false; + memcpy(outdata, tmpdata, digest->maclength); + } else { + char tmpdata[len]; + gcry_md_hash_buffer(digest->algo, tmpdata, indata, inlen); + memcpy(outdata, tmpdata, digest->maclength); + } + + return true; +} + +bool digest_verify(digest_t *digest, const void *indata, size_t inlen, const void *cmpdata) { + unsigned int len = digest->maclength; + char outdata[len]; + + return digest_create(digest, indata, inlen, outdata) && !memcmp(cmpdata, outdata, len); +} + +int digest_get_nid(const digest_t *digest) { + return digest->nid; +} + +size_t digest_length(const digest_t *digest) { + return digest->maclength; +} + +bool digest_active(const digest_t *digest) { + return digest->algo != GCRY_MD_NONE; +} diff --git a/src/gcrypt/digest.h b/src/gcrypt/digest.h new file mode 100644 index 0000000..1188496 --- /dev/null +++ b/src/gcrypt/digest.h @@ -0,0 +1,45 @@ +/* + digest.h -- header file digest.c + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_DIGEST_H__ +#define __TINC_DIGEST_H__ + +#include + +#define DIGEST_MAX_SIZE 64 + +typedef struct digest { + int algo; + int nid; + int maclength; + gcry_md_hd_t hmac; +} digest_t; + +extern bool digest_open_by_name(struct digest *, const char *name, int maclength); +extern bool digest_open_by_nid(struct digest *, int nid, int maclength); +extern bool digest_open_sha1(struct digest *, int maclength); +extern void digest_close(struct digest *); +extern bool digest_create(struct digest *, const void *indata, size_t inlen, void *outdata); +extern bool digest_verify(struct digest *, const void *indata, size_t inlen, const void *digestdata); +extern bool digest_set_key(struct digest *, const void *key, size_t len); +extern int digest_get_nid(const struct digest *); +extern size_t digest_length(const struct digest *); +extern bool digest_active(const struct digest *); + +#endif diff --git a/src/gcrypt/rsa.c b/src/gcrypt/rsa.c new file mode 100644 index 0000000..ceb1638 --- /dev/null +++ b/src/gcrypt/rsa.c @@ -0,0 +1,302 @@ +/* + rsa.c -- RSA key handling + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include + +#include "logger.h" +#include "rsa.h" + +// Base64 decoding table + +static const uint8_t b64d[128] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, + 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x3b, 0x3c, 0x3d, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, + 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, + 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, + 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, + 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, + 0xff, 0xff +}; + +// PEM encoding/decoding functions + +static bool pem_decode(FILE *fp, const char *header, uint8_t *buf, size_t size, size_t *outsize) { + bool decode = false; + char line[1024]; + uint16_t word = 0; + int shift = 10; + size_t i, j = 0; + + while(!feof(fp)) { + if(!fgets(line, sizeof line, fp)) + return false; + + if(!decode && !strncmp(line, "-----BEGIN ", 11)) { + if(!strncmp(line + 11, header, strlen(header))) + decode = true; + continue; + } + + if(decode && !strncmp(line, "-----END", 8)) { + break; + } + + if(!decode) + continue; + + for(i = 0; line[i] >= ' '; i++) { + if((signed char)line[i] < 0 || b64d[(int)line[i]] == 0xff) + break; + word |= b64d[(int)line[i]] << shift; + shift -= 6; + if(shift <= 2) { + if(j > size) { + errno = ENOMEM; + return false; + } + + buf[j++] = word >> 8; + word <<= 8; + shift += 8; + } + } + } + + if(outsize) + *outsize = j; + return true; +} + + +// BER decoding functions + +static int ber_read_id(unsigned char **p, size_t *buflen) { + if(*buflen <= 0) + return -1; + + if((**p & 0x1f) == 0x1f) { + int id = 0; + bool more; + while(*buflen > 0) { + id <<= 7; + id |= **p & 0x7f; + more = *(*p)++ & 0x80; + (*buflen)--; + if(!more) + break; + } + return id; + } else { + (*buflen)--; + return *(*p)++ & 0x1f; + } +} + +static size_t ber_read_len(unsigned char **p, size_t *buflen) { + if(*buflen <= 0) + return -1; + + if(**p & 0x80) { + size_t result = 0; + int len = *(*p)++ & 0x7f; + (*buflen)--; + if(len > *buflen) + return 0; + + while(len--) { + result <<= 8; + result |= *(*p)++; + (*buflen)--; + } + + return result; + } else { + (*buflen)--; + return *(*p)++; + } +} + + +static bool ber_read_sequence(unsigned char **p, size_t *buflen, size_t *result) { + int tag = ber_read_id(p, buflen); + size_t len = ber_read_len(p, buflen); + + if(tag == 0x10) { + if(result) + *result = len; + return true; + } else { + return false; + } +} + +static bool ber_read_mpi(unsigned char **p, size_t *buflen, gcry_mpi_t *mpi) { + int tag = ber_read_id(p, buflen); + size_t len = ber_read_len(p, buflen); + gcry_error_t err = 0; + + if(tag != 0x02 || len > *buflen) + return false; + + if(mpi) + err = gcry_mpi_scan(mpi, GCRYMPI_FMT_USG, *p, len, NULL); + + *p += len; + *buflen -= len; + + return mpi ? !err : true; +} + +bool rsa_set_hex_public_key(rsa_t *rsa, char *n, char *e) { + gcry_error_t err = 0; + + err = gcry_mpi_scan(&rsa->n, GCRYMPI_FMT_HEX, n, 0, NULL) + ?: gcry_mpi_scan(&rsa->e, GCRYMPI_FMT_HEX, e, 0, NULL); + + if(err) { + logger(LOG_ERR, "Error while reading RSA public key: %s", gcry_strerror(errno)); + return false; + } + + return true; +} + +bool rsa_set_hex_private_key(rsa_t *rsa, char *n, char *e, char *d) { + gcry_error_t err = 0; + + err = gcry_mpi_scan(&rsa->n, GCRYMPI_FMT_HEX, n, 0, NULL) + ?: gcry_mpi_scan(&rsa->e, GCRYMPI_FMT_HEX, e, 0, NULL) + ?: gcry_mpi_scan(&rsa->d, GCRYMPI_FMT_HEX, d, 0, NULL); + + if(err) { + logger(LOG_ERR, "Error while reading RSA public key: %s", gcry_strerror(errno)); + return false; + } + + return true; +} + +// Read PEM RSA keys + +bool rsa_read_pem_public_key(rsa_t *rsa, FILE *fp) { + uint8_t derbuf[8096], *derp = derbuf; + size_t derlen; + + if(!pem_decode(fp, "RSA PUBLIC KEY", derbuf, sizeof derbuf, &derlen)) { + logger(LOG_ERR, "Unable to read RSA public key: %s", strerror(errno)); + return NULL; + } + + if(!ber_read_sequence(&derp, &derlen, NULL) + || !ber_read_mpi(&derp, &derlen, &rsa->n) + || !ber_read_mpi(&derp, &derlen, &rsa->e) + || derlen) { + logger(LOG_ERR, "Error while decoding RSA public key"); + return NULL; + } + + return true; +} + +bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp) { + uint8_t derbuf[8096], *derp = derbuf; + size_t derlen; + + if(!pem_decode(fp, "RSA PRIVATE KEY", derbuf, sizeof derbuf, &derlen)) { + logger(LOG_ERR, "Unable to read RSA private key: %s", strerror(errno)); + return NULL; + } + + if(!ber_read_sequence(&derp, &derlen, NULL) + || !ber_read_mpi(&derp, &derlen, NULL) + || !ber_read_mpi(&derp, &derlen, &rsa->n) + || !ber_read_mpi(&derp, &derlen, &rsa->e) + || !ber_read_mpi(&derp, &derlen, &rsa->d) + || !ber_read_mpi(&derp, &derlen, NULL) // p + || !ber_read_mpi(&derp, &derlen, NULL) // q + || !ber_read_mpi(&derp, &derlen, NULL) + || !ber_read_mpi(&derp, &derlen, NULL) + || !ber_read_mpi(&derp, &derlen, NULL) // u + || derlen) { + logger(LOG_ERR, "Error while decoding RSA private key"); + return NULL; + } + + return true; +} + +size_t rsa_size(rsa_t *rsa) { + return (gcry_mpi_get_nbits(rsa->n) + 7) / 8; +} + +/* Well, libgcrypt has functions to handle RSA keys, but they suck. + * So we just use libgcrypt's mpi functions, and do the math ourselves. + */ + +// TODO: get rid of this macro, properly clean up gcry_ structures after use +#define check(foo) { gcry_error_t err = (foo); if(err) {logger(LOG_ERR, "gcrypt error %s/%s at %s:%d", gcry_strsource(err), gcry_strerror(err), __FILE__, __LINE__); return false; }} + +bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t len, void *out) { + gcry_mpi_t inmpi; + check(gcry_mpi_scan(&inmpi, GCRYMPI_FMT_USG, in, len, NULL)); + + gcry_mpi_t outmpi = gcry_mpi_new(len * 8); + gcry_mpi_powm(outmpi, inmpi, rsa->e, rsa->n); + + int pad = len - (gcry_mpi_get_nbits(outmpi) + 7) / 8; + while(pad--) + *(char *)out++ = 0; + + check(gcry_mpi_print(GCRYMPI_FMT_USG, out,len, NULL, outmpi)); + + return true; +} + +bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t len, void *out) { + gcry_mpi_t inmpi; + check(gcry_mpi_scan(&inmpi, GCRYMPI_FMT_USG, in, len, NULL)); + + gcry_mpi_t outmpi = gcry_mpi_new(len * 8); + gcry_mpi_powm(outmpi, inmpi, rsa->d, rsa->n); + + int pad = len - (gcry_mpi_get_nbits(outmpi) + 7) / 8; + while(pad--) + *(char *)out++ = 0; + + check(gcry_mpi_print(GCRYMPI_FMT_USG, out,len, NULL, outmpi)); + + return true; +} diff --git a/src/gcrypt/rsa.h b/src/gcrypt/rsa.h new file mode 100644 index 0000000..143f015 --- /dev/null +++ b/src/gcrypt/rsa.h @@ -0,0 +1,39 @@ +/* + rsa.h -- RSA key handling + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_RSA_H__ +#define __TINC_RSA_H__ + +#include + +typedef struct rsa { + gcry_mpi_t n; + gcry_mpi_t e; + gcry_mpi_t d; +} rsa_t; + +extern bool rsa_set_hex_public_key(rsa_t *rsa, char *n, char *e); +extern bool rsa_set_hex_private_key(rsa_t *rsa, char *n, char *e, char *d); +extern bool rsa_read_pem_public_key(rsa_t *rsa, FILE *fp); +extern bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp); +extern size_t rsa_size(rsa_t *rsa); +extern bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t len, void *out); +extern bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t len, void *out); + +#endif diff --git a/src/gcrypt/rsagen.c b/src/gcrypt/rsagen.c new file mode 100644 index 0000000..7d37d19 --- /dev/null +++ b/src/gcrypt/rsagen.c @@ -0,0 +1,220 @@ +/* + rsagen.c -- RSA key generation and export + Copyright (C) 2008 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include + +#include "rsagen.h" + +#if 0 +// Base64 encoding table + +static const char b64e[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +// PEM encoding + +static bool pem_encode(FILE *fp, const char *header, uint8_t *buf, size_t size) { + bool decode = false; + char line[1024]; + uint32_t word = 0; + int shift = 0; + size_t i, j = 0; + + fprintf(fp, "-----BEGIN %s-----\n", header); + + for(i = 0; i < size; i += 3) { + if(i <= size - 3) { + word = buf[i] << 16 | buf[i + 1] << 8 | buf[i + 2]; + } else { + word = buf[i] << 16; + if(i == size - 2) + word |= buf[i + 1] << 8; + } + + line[j++] = b64e[(word >> 18) ]; + line[j++] = b64e[(word >> 12) & 0x3f]; + line[j++] = b64e[(word >> 6) & 0x3f]; + line[j++] = b64e[(word ) & 0x3f]; + + if(j >= 64) { + line[j++] = '\n'; + line[j] = 0; + fputs(line, fp); + j = 0; + } + } + + if(size % 3 > 0) { + if(size % 3 > 1) + line[j++] = '='; + line[j++] = '='; + } + + if(j) { + line[j++] = '\n'; + line[j] = 0; + fputs(line, fp); + } + + fprintf(fp, "-----END %s-----\n", header); + + return true; +} + + +// BER encoding functions + +static bool ber_write_id(uint8_t **p, size_t *buflen, int id) { + if(*buflen <= 0) + return false; + + if(id >= 0x1f) { + while(id) { + if(*buflen <= 0) + return false; + + (*buflen)--; + **p = id & 0x7f; + id >>= 7; + if(id) + **p |= 0x80; + (*p)++; + } + } else { + (*buflen)--; + *(*p)++ = id; + } + + return true; +} + +static bool ber_write_len(uint8_t **p, size_t *buflen, size_t len) { + do { + if(*buflen <= 0) + return false; + + (*buflen)--; + **p = len & 0x7f; + len >>= 7; + if(len) + **p |= 0x80; + (*p)++; + } while(len); + + return true; +} + +static bool ber_write_sequence(uint8_t **p, size_t *buflen, uint8_t *seqbuf, size_t seqlen) { + if(!ber_write_id(p, buflen, 0x10) || !ber_write_len(p, buflen, seqlen) || *buflen < seqlen) + return false; + + memcpy(*p, seqbuf, seqlen); + *p += seqlen; + *buflen -= seqlen; + + return true; +} + +static bool ber_write_mpi(uint8_t **p, size_t *buflen, gcry_mpi_t mpi) { + uint8_t tmpbuf[1024]; + size_t tmplen = sizeof tmpbuf; + gcry_error_t err; + + err = gcry_mpi_aprint(GCRYMPI_FMT_USG, &tmpbuf, &tmplen, mpi); + if(err) + return false; + + if(!ber_write_id(p, buflen, 0x02) || !ber_write_len(p, buflen, tmplen) || *buflen < tmplen) + return false; + + memcpy(*p, tmpbuf, tmplen); + *p += tmplen; + *buflen -= tmplen; + + return true; +} + +// Write PEM RSA keys + +bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp) { + uint8_t derbuf1[8096]; + uint8_t derbuf2[8096]; + uint8_t *derp1 = derbuf1; + uint8_t *derp2 = derbuf2; + size_t derlen1 = sizeof derbuf1; + size_t derlen2 = sizeof derbuf2; + + if(!ber_write_mpi(&derp1, &derlen1, &rsa->n) + || !ber_write_mpi(&derp1, &derlen1, &rsa->e) + || !ber_write_sequence(&derp2, &derlen2, derbuf1, derlen1)) { + logger(LOG_ERR, "Error while encoding RSA public key"); + return false; + } + + if(!pem_encode(fp, "RSA PUBLIC KEY", derbuf2, derlen2)) { + logger(LOG_ERR, "Unable to write RSA public key: %s", strerror(errno)); + return false; + } + + return true; +} + +bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) { + uint8_t derbuf1[8096]; + uint8_t derbuf2[8096]; + uint8_t *derp1 = derbuf1; + uint8_t *derp2 = derbuf2; + size_t derlen1 = sizeof derbuf1; + size_t derlen2 = sizeof derbuf2; + + if(!ber_write_mpi(&derp1, &derlen1, &bits) + || ber_write_mpi(&derp1, &derlen1, &rsa->n) // modulus + || ber_write_mpi(&derp1, &derlen1, &rsa->e) // public exponent + || ber_write_mpi(&derp1, &derlen1, &rsa->d) // private exponent + || ber_write_mpi(&derp1, &derlen1, &p) + || ber_write_mpi(&derp1, &derlen1, &q) + || ber_write_mpi(&derp1, &derlen1, &exp1) + || ber_write_mpi(&derp1, &derlen1, &exp2) + || ber_write_mpi(&derp1, &derlen1, &coeff)) + logger(LOG_ERR, "Error while encoding RSA private key"); + return false; + } + + if(!pem_encode(fp, "RSA PRIVATE KEY", derbuf2, derlen2)) { + logger(LOG_ERR, "Unable to write RSA private key: %s", strerror(errno)); + return false; + } + + return true; +} +#endif + +bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp) { + return false; +} + +bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) { + return false; +} + +bool rsa_generate(rsa_t *rsa, size_t bits, unsigned long exponent) { + fprintf(stderr, "Generating RSA keys with libgcrypt not implemented yet\n"); + return false; +} diff --git a/src/gcrypt/rsagen.h b/src/gcrypt/rsagen.h new file mode 100644 index 0000000..422d156 --- /dev/null +++ b/src/gcrypt/rsagen.h @@ -0,0 +1,29 @@ +/* + rsagen.h -- RSA key generation and export + Copyright (C) 2008 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_RSAGEN_H__ +#define __TINC_RSAGEN_H__ + +#include "rsa.h" + +extern bool rsa_generate(rsa_t *rsa, size_t bits, unsigned long exponent); +extern bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp); +extern bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp); + +#endif diff --git a/src/getopt.c b/src/getopt.c index 741c7f2..a6782ed 100644 --- a/src/getopt.c +++ b/src/getopt.c @@ -4,7 +4,7 @@ before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97 - Free Software Foundation, Inc. + Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. @@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #endif #ifdef HAVE_CONFIG_H -#include "../config.h" +#include #endif #if !defined (__STDC__) || !__STDC__ @@ -69,12 +69,12 @@ with this program; if not, write to the Free Software Foundation, Inc., /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ +#ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ #include #include -#endif /* GNU C library. */ +#endif /* GNU C library. */ #ifdef VMS #include @@ -132,7 +132,7 @@ int optind = 1; causes problems with re-calling getopt as programs generally don't know that. */ -int getopt_initialized = 0; +int __getopt_initialized = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. @@ -183,41 +183,40 @@ int optopt = '?'; of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ -static enum { - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; -#ifdef __GNU_LIBRARY__ +#ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ #include -#define my_index strchr +#define my_index strchr #else /* Avoid depending on library functions or files whose names are inconsistent. */ -char *getenv(); +char *getenv (); static char * -my_index(str, chr) -const char *str; -int chr; +my_index (str, chr) + const char *str; + int chr; { - while(*str) { - if(*str == chr) { - return (char *) str; - } - - str++; - } - - return 0; + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; } /* If using GCC, we can safely declare strlen this way. @@ -228,7 +227,7 @@ int chr; #if !defined (__STDC__) || !__STDC__ /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ -extern int strlen(const char *); +extern int strlen (const char *); #endif /* not __STDC__ */ #endif /* __GNUC__ */ @@ -248,7 +247,7 @@ static int last_nonopt; indicating ARGV elements that should not be considered arguments. */ /* Defined in getopt_init.c */ -extern char *getopt_nonoption_flags; +extern char *__getopt_nonoption_flags; static int nonoption_flags_max_len; static int nonoption_flags_len; @@ -256,31 +255,32 @@ static int nonoption_flags_len; static int original_argc; static char *const *original_argv; -extern pid_t libc_pid; +extern pid_t __libc_pid; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void -__attribute__((__unused__)) -store_args_and_env(int argc, char *const *argv) { - /* XXX This is no good solution. We should rather copy the args so - that we can compare them later. But we must not use malloc(3). */ - original_argc = argc; - original_argv = argv; +__attribute__ ((__unused__)) +store_args_and_env (int argc, char *const *argv) +{ + /* XXX This is no good solution. We should rather copy the args so + that we can compare them later. But we must not use malloc(3). */ + original_argc = argc; + original_argv = argv; } -text_set_element(libc_subinit, store_args_and_env); +text_set_element (__libc_subinit, store_args_and_env); # define SWAP_FLAGS(ch1, ch2) \ - if (nonoption_flags_len > 0) \ - { \ - char tmp = getopt_nonoption_flags[ch1]; \ - getopt_nonoption_flags[ch1] = getopt_nonoption_flags[ch2]; \ - getopt_nonoption_flags[ch2] = tmp; \ - } -#else /* !_LIBC */ + if (nonoption_flags_len > 0) \ + { \ + char __tmp = __getopt_nonoption_flags[ch1]; \ + __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ + __getopt_nonoption_flags[ch2] = __tmp; \ + } +#else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) -#endif /* _LIBC */ +#endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) @@ -292,158 +292,161 @@ text_set_element(libc_subinit, store_args_and_env); the new indices of the non-options in ARGV after they are moved. */ #if defined (__STDC__) && __STDC__ -static void exchange(char **); +static void exchange (char **); #endif static void -exchange(argv) -char **argv; +exchange (argv) + char **argv; { - int bottom = first_nonopt; - int middle = last_nonopt; - int top = optind; - char *tem; + int bottom = first_nonopt; + int middle = last_nonopt; + int top = optind; + char *tem; - /* Exchange the shorter segment with the far end of the longer segment. - That puts the shorter segment into the right place. - It leaves the longer segment in the right place overall, - but it consists of two parts that need to be swapped next. */ + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ #ifdef _LIBC - - /* First make sure the handling of the `getopt_nonoption_flags' - string can work normally. Our top argument must be in the range - of the string. */ - if(nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { - /* We must extend the array. The user plays games with us and - presents new arguments. */ - char *new_str = malloc(top + 1); - - if(new_str == NULL) { - nonoption_flags_len = nonoption_flags_max_len = 0; - } else { - memcpy(new_str, getopt_nonoption_flags, nonoption_flags_max_len); - memset(&new_str[nonoption_flags_max_len], '\0', - top + 1 - nonoption_flags_max_len); - nonoption_flags_max_len = top + 1; - getopt_nonoption_flags = new_str; - } + /* First make sure the handling of the `__getopt_nonoption_flags' + string can work normally. Our top argument must be in the range + of the string. */ + if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) + { + /* We must extend the array. The user plays games with us and + presents new arguments. */ + char *new_str = malloc (top + 1); + if (new_str == NULL) + nonoption_flags_len = nonoption_flags_max_len = 0; + else + { + memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len); + memset (&new_str[nonoption_flags_max_len], '\0', + top + 1 - nonoption_flags_max_len); + nonoption_flags_max_len = top + 1; + __getopt_nonoption_flags = new_str; } - + } #endif - while(top > middle && middle > bottom) { - if(top - middle > middle - bottom) { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; - /* Swap it with the top part of the top segment. */ - for(i = 0; i < len; i++) { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - SWAP_FLAGS(bottom + i, top - (middle - bottom) + i); - } - - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } else { - /* Top segment is the short one. */ - int len = top - middle; - register int i; - - /* Swap it with the bottom part of the bottom segment. */ - for(i = 0; i < len; i++) { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - SWAP_FLAGS(bottom + i, middle + i); - } - - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; } + else + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; - /* Update records for the slots the non-options now occupy. */ + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + SWAP_FLAGS (bottom + i, middle + i); + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined (__STDC__) && __STDC__ -static const char *_getopt_initialize(int, char *const *, const char *); +static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * -_getopt_initialize(argc, argv, optstring) -int argc; -char *const *argv; -const char *optstring; +_getopt_initialize (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; { - /* Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ - first_nonopt = last_nonopt = optind; + first_nonopt = last_nonopt = optind; - nextchar = NULL; + nextchar = NULL; - posixly_correct = getenv("POSIXLY_CORRECT"); + posixly_correct = getenv ("POSIXLY_CORRECT"); - /* Determine how to handle the ordering of options and nonoptions. */ + /* Determine how to handle the ordering of options and nonoptions. */ - if(optstring[0] == '-') { - ordering = RETURN_IN_ORDER; - ++optstring; - } else if(optstring[0] == '+') { - ordering = REQUIRE_ORDER; - ++optstring; - } else if(posixly_correct != NULL) { - ordering = REQUIRE_ORDER; - } else { - ordering = PERMUTE; - } + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (posixly_correct != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; #ifdef _LIBC - - if(posixly_correct == NULL - && argc == original_argc && argv == original_argv) { - if(nonoption_flags_max_len == 0) { - if(getopt_nonoption_flags == NULL - || getopt_nonoption_flags[0] == '\0') { - nonoption_flags_max_len = -1; - } else { - const char *orig_str = getopt_nonoption_flags; - int len = nonoption_flags_max_len = strlen(orig_str); - - if(nonoption_flags_max_len < argc) { - nonoption_flags_max_len = argc; - } - - getopt_nonoption_flags = - (char *) malloc(nonoption_flags_max_len); - - if(getopt_nonoption_flags == NULL) { - nonoption_flags_max_len = -1; - } else { - memcpy(getopt_nonoption_flags, orig_str, len); - memset(&getopt_nonoption_flags[len], '\0', - nonoption_flags_max_len - len); - } - } + if (posixly_correct == NULL + && argc == original_argc && argv == original_argv) + { + if (nonoption_flags_max_len == 0) + { + if (__getopt_nonoption_flags == NULL + || __getopt_nonoption_flags[0] == '\0') + nonoption_flags_max_len = -1; + else + { + const char *orig_str = __getopt_nonoption_flags; + int len = nonoption_flags_max_len = strlen (orig_str); + if (nonoption_flags_max_len < argc) + nonoption_flags_max_len = argc; + __getopt_nonoption_flags = + (char *) malloc (nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + nonoption_flags_max_len = -1; + else + { + memcpy (__getopt_nonoption_flags, orig_str, len); + memset (&__getopt_nonoption_flags[len], '\0', + nonoption_flags_max_len - len); } - - nonoption_flags_len = nonoption_flags_max_len; - } else { - nonoption_flags_len = 0; + } } - + nonoption_flags_len = nonoption_flags_max_len; + } + else + nonoption_flags_len = 0; #endif - return optstring; + return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters @@ -503,476 +506,474 @@ const char *optstring; long-named options. */ int -_getopt_internal(argc, argv, optstring, longopts, longind, long_only) -int argc; -char *const *argv; -const char *optstring; -const struct option *longopts; -int *longind; -int long_only; +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) + int argc; + char *const *argv; + const char *optstring; + const struct option *longopts; + int *longind; + int long_only; { - optarg = NULL; + optarg = NULL; - if(optind == 0 || !getopt_initialized) { - if(optind == 0) { - optind = 1; /* Don't scan ARGV[0], the program name. */ - } + if (optind == 0 || !__getopt_initialized) + { + if (optind == 0) + optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize (argc, argv, optstring); + __getopt_initialized = 1; + } - optstring = _getopt_initialize(argc, argv, optstring); - getopt_initialized = 1; - } - - /* Test whether ARGV[optind] points to a non-option argument. - Either it does not have option syntax, or there is an environment flag - from the shell indicating it is not an option. The later information - is only used when the used in the GNU libc. */ + /* Test whether ARGV[optind] points to a non-option argument. + Either it does not have option syntax, or there is an environment flag + from the shell indicating it is not an option. The later information + is only used when the used in the GNU libc. */ #ifdef _LIBC -#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ - || (optind < nonoption_flags_len \ - && getopt_nonoption_flags[optind] == '1')) +#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ + || (optind < nonoption_flags_len \ + && __getopt_nonoption_flags[optind] == '1')) #else #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif - if(nextchar == NULL || *nextchar == '\0') { - /* Advance to the next ARGV-element. */ + if (nextchar == NULL || *nextchar == '\0') + { + /* Advance to the next ARGV-element. */ - /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been - moved back by the user (who may also have changed the arguments). */ - if(last_nonopt > optind) { - last_nonopt = optind; - } - - if(first_nonopt > optind) { - first_nonopt = optind; - } - - if(ordering == PERMUTE) { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if(first_nonopt != last_nonopt && last_nonopt != optind) { - exchange((char **) argv); - } else if(last_nonopt != optind) { - first_nonopt = optind; - } - - /* Skip any additional non-options - and extend the range of non-options previously skipped. */ - - while(optind < argc && NONOPTION_P) { - optind++; - } - - last_nonopt = optind; - } - - /* The special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if(optind != argc && !strcmp(argv[optind], "--")) { - optind++; - - if(first_nonopt != last_nonopt && last_nonopt != optind) { - exchange((char **) argv); - } else if(first_nonopt == last_nonopt) { - first_nonopt = optind; - } - - last_nonopt = argc; - - optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if(optind == argc) { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if(first_nonopt != last_nonopt) { - optind = first_nonopt; - } - - return -1; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if(NONOPTION_P) { - if(ordering == REQUIRE_ORDER) { - return -1; - } - - optarg = argv[optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Skip the initial punctuation. */ - - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); - } - - /* Decode the current option-ARGV-element. */ - - /* Check whether the ARGV-element is a long option. - - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. - - On the other hand, if there's a long option "fubar" and - the ARGV-element is "-fu", do consider that an abbreviation of - the long option, just like "--fu", and not "-f" with arg "u". - - This distinction seems to be the most useful approach. */ - - if(longopts != NULL - && (argv[optind][1] == '-' - || (long_only && (argv[optind][2] || !my_index(optstring, argv[optind][1]))))) { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = -1; - int option_index; - - for(nameend = nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for(p = longopts, option_index = 0; p->name; p++, option_index++) - if(!strncmp(p->name, nextchar, nameend - nextchar)) { - if((unsigned int)(nameend - nextchar) - == (unsigned int) strlen(p->name)) { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } else if(pfound == NULL) { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } else - /* Second or later nonexact match found. */ - { - ambig = 1; - } - } - - if(ambig && !exact) { - if(opterr) - fprintf(stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); - - nextchar += strlen(nextchar); - optind++; - optopt = 0; - return '?'; - } - - if(pfound != NULL) { - option_index = indfound; - optind++; - - if(*nameend) { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if(pfound->has_arg) { - optarg = nameend + 1; - } else { - if(opterr) { - if(argv[optind - 1][1] == '-') - /* --option */ - fprintf(stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - else - /* +option or -option */ - fprintf(stderr, - "%s: option `%c%s' doesn't allow an argument\n", - argv[0], argv[optind - 1][0], pfound->name); - } - - nextchar += strlen(nextchar); - - optopt = pfound->val; - return '?'; - } - } else if(pfound->has_arg == 1) { - if(optind < argc) { - optarg = argv[optind++]; - } else { - if(opterr) - fprintf(stderr, - "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - - nextchar += strlen(nextchar); - optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - - nextchar += strlen(nextchar); - - if(longind != NULL) { - *longind = option_index; - } - - if(pfound->flag) { - *(pfound->flag) = pfound->val; - return 0; - } - - return pfound->val; - } - - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if(!long_only || argv[optind][1] == '-' - || my_index(optstring, *nextchar) == NULL) { - if(opterr) { - if(argv[optind][1] == '-') - /* --option */ - fprintf(stderr, "%s: unrecognized option `--%s'\n", - argv[0], nextchar); - else - /* +option or -option */ - fprintf(stderr, "%s: unrecognized option `%c%s'\n", - argv[0], argv[optind][0], nextchar); - } - - nextchar = (char *) ""; - optind++; - optopt = 0; - return '?'; - } - } - - /* Look at and handle the next short option-character. */ + /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been + moved back by the user (who may also have changed the arguments). */ + if (last_nonopt > optind) + last_nonopt = optind; + if (first_nonopt > optind) + first_nonopt = optind; + if (ordering == PERMUTE) { - char c = *nextchar++; - char *temp = my_index(optstring, c); + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ - /* Increment `optind' when we start to process its last character. */ - if(*nextchar == '\0') { - ++optind; - } + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; - if(temp == NULL || c == ':') { - if(opterr) { - if(posixly_correct) - /* 1003.2 specifies the format of this message. */ - fprintf(stderr, "%s: illegal option -- %c\n", - argv[0], c); - else - fprintf(stderr, "%s: invalid option -- %c\n", - argv[0], c); - } + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ - optopt = c; - return '?'; - } - - /* Convenience. Treat POSIX -W foo same as long option --foo */ - if(temp[0] == 'W' && temp[1] == ';') { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - - /* This is an option that requires an argument. */ - if(*nextchar != '\0') { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } else if(optind == argc) { - if(opterr) { - /* 1003.2 specifies the format of this message. */ - fprintf(stderr, "%s: option requires an argument -- %c\n", - argv[0], c); - } - - optopt = c; - - if(optstring[0] == ':') { - c = ':'; - } else { - c = '?'; - } - - return c; - } else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - { - optarg = argv[optind++]; - } - - /* optarg is now the argument, see if it's in the - table of longopts. */ - - for(nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for(p = longopts, option_index = 0; p->name; p++, option_index++) - if(!strncmp(p->name, nextchar, nameend - nextchar)) { - if((unsigned int)(nameend - nextchar) == strlen(p->name)) { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } else if(pfound == NULL) { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } else - /* Second or later nonexact match found. */ - { - ambig = 1; - } - } - - if(ambig && !exact) { - if(opterr) - fprintf(stderr, "%s: option `-W %s' is ambiguous\n", - argv[0], argv[optind]); - - nextchar += strlen(nextchar); - optind++; - return '?'; - } - - if(pfound != NULL) { - option_index = indfound; - - if(*nameend) { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if(pfound->has_arg) { - optarg = nameend + 1; - } else { - if(opterr) - fprintf(stderr, - "%s: option `-W %s' doesn't allow an argument\n", - argv[0], pfound->name); - - nextchar += strlen(nextchar); - return '?'; - } - } else if(pfound->has_arg == 1) { - if(optind < argc) { - optarg = argv[optind++]; - } else { - if(opterr) - fprintf(stderr, - "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - - nextchar += strlen(nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - - nextchar += strlen(nextchar); - - if(longind != NULL) { - *longind = option_index; - } - - if(pfound->flag) { - *(pfound->flag) = pfound->val; - return 0; - } - - return pfound->val; - } - - nextchar = NULL; - return 'W'; /* Let the application handle it. */ - } - - if(temp[1] == ':') { - if(temp[2] == ':') { - /* This is an option that accepts an argument optionally. */ - if(*nextchar != '\0') { - optarg = nextchar; - optind++; - } else { - optarg = NULL; - } - - nextchar = NULL; - } else { - /* This is an option that requires an argument. */ - if(*nextchar != '\0') { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } else if(optind == argc) { - if(opterr) { - /* 1003.2 specifies the format of this message. */ - fprintf(stderr, - "%s: option requires an argument -- %c\n", - argv[0], c); - } - - optopt = c; - - if(optstring[0] == ':') { - c = ':'; - } else { - c = '?'; - } - } else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - { - optarg = argv[optind++]; - } - - nextchar = NULL; - } - } - - return c; + while (optind < argc && NONOPTION_P) + optind++; + last_nonopt = optind; } + + /* The special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return -1; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if (NONOPTION_P) + { + if (ordering == REQUIRE_ORDER) + return -1; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + + if (longopts != NULL + && (argv[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = -1; + int option_index; + + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) + == (unsigned int) strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, "%s: option `%s' is ambiguous\n", + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + optopt = 0; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (opterr) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + "%s: option `--%s' doesn't allow an argument\n", + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + "%s: option `%c%s' doesn't allow an argument\n", + argv[0], argv[optind - 1][0], pfound->name); + } + + nextchar += strlen (nextchar); + + optopt = pfound->val; + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, + "%s: option `%s' requires an argument\n", + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' + || my_index (optstring, *nextchar) == NULL) + { + if (opterr) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, "%s: unrecognized option `--%s'\n", + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, "%s: unrecognized option `%c%s'\n", + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + optopt = 0; + return '?'; + } + } + + /* Look at and handle the next short option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (opterr) + { + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, "%s: illegal option -- %c\n", + argv[0], c); + else + fprintf (stderr, "%s: invalid option -- %c\n", + argv[0], c); + } + optopt = c; + return '?'; + } + /* Convenience. Treat POSIX -W foo same as long option --foo */ + if (temp[0] == 'W' && temp[1] == ';') + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, "%s: option requires an argument -- %c\n", + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + + /* optarg is now the argument, see if it's in the + table of longopts. */ + + for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, "%s: option `-W %s' is ambiguous\n", + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (opterr) + fprintf (stderr, + "%s: option `-W %s' doesn't allow an argument\n", + argv[0], pfound->name); + + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, + "%s: option `%s' requires an argument\n", + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + nextchar = NULL; + return 'W'; /* Let the application handle it. */ + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = NULL; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, + "%s: option requires an argument -- %c\n", + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } } int -getopt(argc, argv, optstring) -int argc; -char *const *argv; -const char *optstring; +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; { - return _getopt_internal(argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); } -#endif /* Not ELIDE_CODE. */ +#endif /* Not ELIDE_CODE. */ #ifdef TEST @@ -980,72 +981,68 @@ const char *optstring; the above definition of `getopt'. */ int -main(argc, argv) -int argc; -char **argv; +main (argc, argv) + int argc; + char **argv; { - int c; - int digit_optind = 0; + int c; + int digit_optind = 0; - while(1) { - int this_option_optind = optind ? optind : 1; + while (1) + { + int this_option_optind = optind ? optind : 1; - c = getopt(argc, argv, "abc:d:0123456789"); + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == -1) + break; - if(c == -1) { - break; - } + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; - switch(c) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if(digit_optind != 0 && digit_optind != this_option_optind) { - printf("digits occur in two different argv-elements.\n"); - } + case 'a': + printf ("option a\n"); + break; - digit_optind = this_option_optind; - printf("option %c\n", c); - break; + case 'b': + printf ("option b\n"); + break; - case 'a': - printf("option a\n"); - break; + case 'c': + printf ("option c with value `%s'\n", optarg); + break; - case 'b': - printf("option b\n"); - break; + case '?': + break; - case 'c': - printf("option c with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf("?? getopt returned character code 0%o ??\n", c); - } + default: + printf ("?? getopt returned character code 0%o ??\n", c); } + } - if(optind < argc) { - printf("non-option ARGV-elements: "); + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } - while(optind < argc) { - printf("%s ", argv[optind++]); - } - - printf("\n"); - } - - exit(0); + exit (0); } #endif /* TEST */ diff --git a/src/getopt.h b/src/getopt.h index ab1d40b..ddf6fdd 100644 --- a/src/getopt.h +++ b/src/getopt.h @@ -1,6 +1,3 @@ -#ifndef TINC_GETOPT_H -#define TINC_GETOPT_H - /* Declarations for getopt. Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc. @@ -22,111 +19,115 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifdef cplusplus +#ifndef _GETOPT_H +#define _GETOPT_H 1 + +#ifdef __cplusplus extern "C" { #endif - /* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ - extern char *optarg; +extern char *optarg; - /* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. - On entry to `getopt', zero means this is the first call; initialize. + On entry to `getopt', zero means this is the first call; initialize. - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ - extern int optind; +extern int optind; - /* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ - extern int opterr; +extern int opterr; - /* Set to an option character which was unrecognized. */ +/* Set to an option character which was unrecognized. */ - extern int optopt; +extern int optopt; - /* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `getopt' - returns the contents of the `val' field. */ + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ - struct option { +struct option +{ #if defined (__STDC__) && __STDC__ - const char *name; + const char *name; #else - char *name; + char *name; #endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; - }; + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; - /* Names for the values of the `has_arg' field of `struct option'. */ +/* Names for the values of the `has_arg' field of `struct option'. */ -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 #if defined (__STDC__) && __STDC__ #ifdef __GNU_LIBRARY__ - /* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ - extern int getopt(int argc, char *const *argv, const char *shortopts); +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int argc, char *const *argv, const char *shortopts); #else /* not __GNU_LIBRARY__ */ - extern int getopt(); +extern int getopt (); #endif /* __GNU_LIBRARY__ */ - extern int getopt_long(int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); - extern int getopt_long_only(int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); +extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +extern int getopt_long_only (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind); - /* Internal only. Users should not call this directly. */ - extern int _getopt_internal(int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind, + int long_only); #else /* not __STDC__ */ - extern int getopt(); - extern int getopt_long(); - extern int getopt_long_only(); +extern int getopt (); +extern int getopt_long (); +extern int getopt_long_only (); - extern int _getopt_internal(); +extern int _getopt_internal (); #endif /* __STDC__ */ -#ifdef cplusplus +#ifdef __cplusplus } #endif -#endif +#endif /* _GETOPT_H */ diff --git a/src/getopt1.c b/src/getopt1.c index 3ccb150..86545f2 100644 --- a/src/getopt1.c +++ b/src/getopt1.c @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #ifdef HAVE_CONFIG_H -#include "../config.h" +#include #endif #include "getopt.h" @@ -60,19 +60,19 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #endif -#ifndef NULL +#ifndef NULL #define NULL 0 #endif int -getopt_long(argc, argv, options, long_options, opt_index) -int argc; -char *const *argv; -const char *options; -const struct option *long_options; -int *opt_index; +getopt_long (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; { - return _getopt_internal(argc, argv, options, long_options, opt_index, 0); + return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. @@ -81,115 +81,109 @@ int *opt_index; instead. */ int -getopt_long_only(argc, argv, options, long_options, opt_index) -int argc; -char *const *argv; -const char *options; -const struct option *long_options; -int *opt_index; +getopt_long_only (argc, argv, options, long_options, opt_index) + int argc; + char *const *argv; + const char *options; + const struct option *long_options; + int *opt_index; { - return _getopt_internal(argc, argv, options, long_options, opt_index, 1); + return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } -#endif /* Not ELIDE_CODE. */ +#endif /* Not ELIDE_CODE. */ #ifdef TEST #include int -main(argc, argv) -int argc; -char **argv; +main (argc, argv) + int argc; + char **argv; { - int c; - int digit_optind = 0; + int c; + int digit_optind = 0; - while(1) { - int this_option_optind = optind ? optind : 1; - int option_index = 0; - static struct option long_options[] = { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} - }; + while (1) + { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static struct option long_options[] = + { + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} + }; - c = getopt_long(argc, argv, "abc:d:0123456789", - long_options, &option_index); + c = getopt_long (argc, argv, "abc:d:0123456789", + long_options, &option_index); + if (c == -1) + break; - if(c == -1) { - break; - } + switch (c) + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; - switch(c) { - case 0: - printf("option %s", long_options[option_index].name); + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; - if(optarg) { - printf(" with arg %s", optarg); - } + case 'a': + printf ("option a\n"); + break; - printf("\n"); - break; + case 'b': + printf ("option b\n"); + break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if(digit_optind != 0 && digit_optind != this_option_optind) { - printf("digits occur in two different argv-elements.\n"); - } + case 'c': + printf ("option c with value `%s'\n", optarg); + break; - digit_optind = this_option_optind; - printf("option %c\n", c); - break; + case 'd': + printf ("option d with value `%s'\n", optarg); + break; - case 'a': - printf("option a\n"); - break; + case '?': + break; - case 'b': - printf("option b\n"); - break; - - case 'c': - printf("option c with value `%s'\n", optarg); - break; - - case 'd': - printf("option d with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf("?? getopt returned character code 0%o ??\n", c); - } + default: + printf ("?? getopt returned character code 0%o ??\n", c); } + } - if(optind < argc) { - printf("non-option ARGV-elements: "); + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } - while(optind < argc) { - printf("%s ", argv[optind++]); - } - - printf("\n"); - } - - exit(0); + exit (0); } #endif /* TEST */ diff --git a/src/graph.c b/src/graph.c index 3529d01..bb55dfd 100644 --- a/src/graph.c +++ b/src/graph.c @@ -1,6 +1,6 @@ /* graph.c -- graph algorithms - Copyright (C) 2001-2014 Guus Sliepen , + Copyright (C) 2001-2011 Guus Sliepen , 2001-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -44,8 +44,8 @@ #include "system.h" -#include "avl_tree.h" -#include "conf.h" +#include "splay_tree.h" +#include "config.h" #include "connection.h" #include "device.h" #include "edge.h" @@ -58,22 +58,18 @@ #include "subnet.h" #include "utils.h" #include "xalloc.h" - -static bool graph_changed = true; +#include "graph.h" /* Implementation of Kruskal's algorithm. - Running time: O(EN) + Running time: O(E) Please note that sorting on weight is already done by add_edge(). */ -static void mst_kruskal(void) { - avl_node_t *node, *next; +void mst_kruskal(void) { + splay_node_t *node, *next; edge_t *e; node_t *n; connection_t *c; - int nodes = 0; - int safe_edges = 0; - bool skipped; /* Clear MST status on connections */ @@ -82,12 +78,6 @@ static void mst_kruskal(void) { c->status.mst = false; } - /* Do we have something to do at all? */ - - if(!edge_weight_tree->head) { - return; - } - ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Running Kruskal's algorithm:"); /* Clear visited status on nodes */ @@ -95,73 +85,144 @@ static void mst_kruskal(void) { for(node = node_tree->head; node; node = node->next) { n = node->data; n->status.visited = false; - nodes++; - } - - /* Starting point */ - - for(node = edge_weight_tree->head; node; node = node->next) { - e = node->data; - - if(e->from->status.reachable) { - e->from->status.visited = true; - break; - } } /* Add safe edges */ - for(skipped = false, node = edge_weight_tree->head; node; node = next) { + for(node = edge_weight_tree->head; node; node = next) { next = node->next; e = node->data; - if(!e->reverse || e->from->status.visited == e->to->status.visited) { - skipped = true; + if(!e->reverse || (e->from->status.visited && e->to->status.visited)) continue; - } e->from->status.visited = true; e->to->status.visited = true; - if(e->connection) { + if(e->connection) e->connection->status.mst = true; - } - if(e->reverse->connection) { + if(e->reverse->connection) e->reverse->connection->status.mst = true; - } - - safe_edges++; ifdebug(SCARY_THINGS) logger(LOG_DEBUG, " Adding edge %s - %s weight %d", e->from->name, - e->to->name, e->weight); + e->to->name, e->weight); + } +} - if(skipped) { - skipped = false; - next = edge_weight_tree->head; - continue; +/* Implementation of Dijkstra's algorithm. + Running time: O(N^2) +*/ + +static void sssp_dijkstra(void) { + splay_node_t *node, *to; + edge_t *e; + node_t *n, *m; + list_t *todo_list; + list_node_t *lnode, *nnode; + bool indirect; + + todo_list = list_alloc(NULL); + + ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Running Dijkstra's algorithm:"); + + /* Clear visited status on nodes */ + + for(node = node_tree->head; node; node = node->next) { + n = node->data; + n->status.visited = false; + n->status.indirect = true; + n->distance = -1; + } + + /* Begin with myself */ + + myself->status.indirect = false; + myself->nexthop = myself; + myself->via = myself; + myself->distance = 0; + list_insert_head(todo_list, myself); + + /* Loop while todo_list is filled */ + + while(todo_list->head) { + n = NULL; + nnode = NULL; + + /* Select node from todo_list with smallest distance */ + + for(lnode = todo_list->head; lnode; lnode = lnode->next) { + m = lnode->data; + if(!n || m->status.indirect < n->status.indirect || m->distance < n->distance) { + n = m; + nnode = lnode; + } + } + + /* Mark this node as visited and remove it from the todo_list */ + + n->status.visited = true; + list_unlink_node(todo_list, nnode); + + /* Update distance of neighbours and add them to the todo_list */ + + for(to = n->edge_tree->head; to; to = to->next) { /* "to" is the edge connected to "from" */ + e = to->data; + + if(e->to->status.visited || !e->reverse) + continue; + + /* Situation: + + / + / + ----->(n)---e-->(e->to) + \ + \ + + Where e is an edge, (n) and (e->to) are nodes. + n->address is set to the e->address of the edge left of n to n. + We are currently examining the edge e right of n from n: + + - If edge e provides for better reachability of e->to, update e->to. + */ + + if(e->to->distance < 0) + list_insert_tail(todo_list, e->to); + + indirect = n->status.indirect || e->options & OPTION_INDIRECT || ((n != myself) && sockaddrcmp(&n->address, &e->reverse->address)); + + if(e->to->distance >= 0 && (!e->to->status.indirect || indirect) && e->to->distance <= n->distance + e->weight) + continue; + + e->to->distance = n->distance + e->weight; + e->to->status.indirect = indirect; + e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop; + e->to->via = indirect ? n->via : e->to; + e->to->options = e->options; + + if(e->to->address.sa.sa_family == AF_UNSPEC && e->address.sa.sa_family != AF_UNKNOWN) + update_node_udp(e->to, &e->address); + + ifdebug(SCARY_THINGS) logger(LOG_DEBUG, " Updating edge %s - %s weight %d distance %d", e->from->name, + e->to->name, e->weight, e->to->distance); } } - ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Done, counted %d nodes and %d safe edges.", nodes, - safe_edges); + list_free(todo_list); } /* Implementation of a simple breadth-first search algorithm. Running time: O(E) */ -static void sssp_bfs(void) { - avl_node_t *node, *next, *to; +void sssp_bfs(void) { + splay_node_t *node, *to; edge_t *e; node_t *n; list_t *todo_list; list_node_t *from, *todonext; bool indirect; - char *name; - char *address, *port; - char *envp[8] = {NULL}; - int i; todo_list = list_alloc(NULL); @@ -178,29 +239,27 @@ static void sssp_bfs(void) { myself->status.visited = true; myself->status.indirect = false; myself->nexthop = myself; - myself->prevedge = NULL; myself->via = myself; list_insert_head(todo_list, myself); /* Loop while todo_list is filled */ - for(from = todo_list->head; from; from = todonext) { /* "from" is the node from which we start */ + for(from = todo_list->head; from; from = todonext) { /* "from" is the node from which we start */ n = from->data; - for(to = n->edge_tree->head; to; to = to->next) { /* "to" is the edge connected to "from" */ + for(to = n->edge_tree->head; to; to = to->next) { /* "to" is the edge connected to "from" */ e = to->data; - if(!e->reverse) { + if(!e->reverse) continue; - } /* Situation: - / - / + / + / ----->(n)---e-->(e->to) - \ - \ + \ + \ Where e is an edge, (n) and (e->to) are nodes. n->address is set to the e->address of the edge left of n to n. @@ -214,25 +273,17 @@ static void sssp_bfs(void) { indirect = n->status.indirect || e->options & OPTION_INDIRECT; if(e->to->status.visited - && (!e->to->status.indirect || indirect)) { + && (!e->to->status.indirect || indirect)) continue; - } - - // Only update nexthop the first time we visit this node. - - if(!e->to->status.visited) { - e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop; - } e->to->status.visited = true; e->to->status.indirect = indirect; - e->to->prevedge = e; + e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop; e->to->via = indirect ? n->via : e->to; e->to->options = e->options; - if(e->to->address.sa.sa_family == AF_UNSPEC && e->address.sa.sa_family != AF_UNKNOWN) { + if(e->to->address.sa.sa_family == AF_UNSPEC && e->address.sa.sa_family != AF_UNKNOWN) update_node_udp(e->to, &e->address); - } list_insert_tail(todo_list, e->to); } @@ -242,6 +293,15 @@ static void sssp_bfs(void) { } list_free(todo_list); +} + +static void check_reachability(void) { + splay_node_t *node, *next; + node_t *n; + char *name; + char *address, *port; + char *envp[7]; + int i; /* Check reachability status. */ @@ -254,10 +314,10 @@ static void sssp_bfs(void) { if(n->status.reachable) { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Node %s (%s) became reachable", - n->name, n->hostname); + n->name, n->hostname); } else { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Node %s (%s) became unreachable", - n->name, n->hostname); + n->name, n->hostname); } /* TODO: only clear status.validkey if node is unreachable? */ @@ -269,122 +329,45 @@ static void sssp_bfs(void) { n->minmtu = 0; n->mtuprobes = 0; - if(n->mtuevent) { - event_del(n->mtuevent); - n->mtuevent = NULL; - } + if(timeout_initialized(&n->mtuevent)) + event_del(&n->mtuevent); - xasprintf(&envp[0], "NETNAME=%s", netname ? netname : ""); - xasprintf(&envp[1], "DEVICE=%s", device ? device : ""); - xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : ""); + xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); + xasprintf(&envp[1], "DEVICE=%s", device ? : ""); + xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); xasprintf(&envp[3], "NODE=%s", n->name); sockaddr2str(&n->address, &address, &port); xasprintf(&envp[4], "REMOTEADDRESS=%s", address); xasprintf(&envp[5], "REMOTEPORT=%s", port); - xasprintf(&envp[6], "NAME=%s", myself->name); + envp[6] = NULL; execute_script(n->status.reachable ? "host-up" : "host-down", envp); xasprintf(&name, - n->status.reachable ? "hosts/%s-up" : "hosts/%s-down", - n->name); + n->status.reachable ? "hosts/%s-up" : "hosts/%s-down", + n->name); execute_script(name, envp); free(name); free(address); free(port); - for(i = 0; i < 7; i++) { + for(i = 0; i < 6; i++) free(envp[i]); - } subnet_update(n, NULL, n->status.reachable); - if(!n->status.reachable) { + if(!n->status.reachable) update_node_udp(n, NULL); - memset(&n->status, 0, sizeof(n->status)); - n->options = 0; - } else if(n->connection) { + else if(n->connection) send_ans_key(n); - } } } } void graph(void) { subnet_cache_flush(); - sssp_bfs(); + sssp_dijkstra(); + check_reachability(); mst_kruskal(); - graph_changed = true; -} - - - -/* Dump nodes and edges to a graphviz file. - - The file can be converted to an image with - dot -Tpng graph_filename -o image_filename.png -Gconcentrate=true -*/ - -void dump_graph(void) { - avl_node_t *node; - node_t *n; - edge_t *e; - char *filename = NULL, *tmpname = NULL; - FILE *file, *pipe = NULL; - - if(!graph_changed || !get_config_string(lookup_config(config_tree, "GraphDumpFile"), &filename)) { - return; - } - - graph_changed = false; - - ifdebug(PROTOCOL) logger(LOG_NOTICE, "Dumping graph"); - - if(filename[0] == '|') { - file = pipe = popen(filename + 1, "w"); - } else { - xasprintf(&tmpname, "%s.new", filename); - file = fopen(tmpname, "w"); - } - - if(!file) { - logger(LOG_ERR, "Unable to open graph dump file %s: %s", filename, strerror(errno)); - free(filename); - free(tmpname); - return; - } - - fprintf(file, "digraph {\n"); - - /* dump all nodes first */ - for(node = node_tree->head; node; node = node->next) { - n = node->data; - fprintf(file, " %s [label = \"%s\"];\n", n->name, n->name); - } - - /* now dump all edges */ - for(node = edge_weight_tree->head; node; node = node->next) { - e = node->data; - fprintf(file, " %s -> %s;\n", e->from->name, e->to->name); - } - - fprintf(file, "}\n"); - - if(pipe) { - pclose(pipe); - } else { - fclose(file); -#ifdef HAVE_MINGW - unlink(filename); -#endif - - if(rename(tmpname, filename)) { - logger(LOG_ERR, "Could not rename %s to %s: %s\n", tmpname, filename, strerror(errno)); - } - - free(tmpname); - } - - free(filename); } diff --git a/src/graph.h b/src/graph.h index fafffcb..fb41096 100644 --- a/src/graph.h +++ b/src/graph.h @@ -1,9 +1,6 @@ -#ifndef TINC_GRAPH_H -#define TINC_GRAPH_H - /* graph.h -- header for graph.c - Copyright (C) 2001-2012 Guus Sliepen , + Copyright (C) 2001-2006 Guus Sliepen , 2001-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -21,7 +18,10 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_GRAPH_H__ +#define __TINC_GRAPH_H__ + extern void graph(void); extern void dump_graph(void); -#endif +#endif /* __TINC_GRAPH_H__ */ diff --git a/src/ipv4.h b/src/ipv4.h index 7979f7d..940c239 100644 --- a/src/ipv4.h +++ b/src/ipv4.h @@ -1,10 +1,7 @@ -#ifndef TINC_IPV4_H -#define TINC_IPV4_H - /* ipv4.h -- missing IPv4 related definitions Copyright (C) 2005 Ivo Timmermans - 2006-2012 Guus Sliepen + 2006 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +18,9 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_IPV4_H__ +#define __TINC_IPV4_H__ + #ifndef AF_INET #define AF_INET 2 #endif @@ -41,14 +41,6 @@ #define ICMP_NET_UNKNOWN 6 #endif -#ifndef ICMP_TIME_EXCEEDED -#define ICMP_TIME_EXCEEDED 11 -#endif - -#ifndef ICMP_EXC_TTL -#define ICMP_EXC_TTL 0 -#endif - #ifndef ICMP_NET_UNREACH #define ICMP_NET_UNREACH 0 #endif @@ -64,15 +56,15 @@ #ifndef HAVE_STRUCT_IP struct ip { #if __BYTE_ORDER == __LITTLE_ENDIAN - unsigned int ip_hl: 4; - unsigned int ip_v: 4; + unsigned int ip_hl:4; + unsigned int ip_v:4; #else - unsigned int ip_v: 4; - unsigned int ip_hl: 4; + unsigned int ip_v:4; + unsigned int ip_hl:4; #endif uint8_t ip_tos; uint16_t ip_len; - uint16_t ip_id; + uint16_t ip_id; uint16_t ip_off; #define IP_RF 0x8000 #define IP_DF 0x4000 @@ -81,7 +73,7 @@ struct ip { uint8_t ip_p; uint16_t ip_sum; struct in_addr ip_src, ip_dst; -} __attribute__((__packed__)); +} __attribute__ ((__packed__)); #endif #ifndef IP_OFFMASK @@ -143,7 +135,7 @@ struct icmp { #define icmp_radv icmp_dun.id_radv #define icmp_mask icmp_dun.id_mask #define icmp_data icmp_dun.id_data -} __attribute__((__packed__)); +} __attribute__ ((__packed__)); #endif -#endif +#endif /* __TINC_IPV4_H__ */ diff --git a/src/ipv6.h b/src/ipv6.h index 1642278..d98001d 100644 --- a/src/ipv6.h +++ b/src/ipv6.h @@ -1,10 +1,7 @@ -#ifndef TINC_IPV6_H -#define TINC_IPV6_H - /* ipv6.h -- missing IPv6 related definitions Copyright (C) 2005 Ivo Timmermans - 2006-2012 Guus Sliepen + 2006 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +18,9 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_IPV6_H__ +#define __TINC_IPV6_H__ + #ifndef AF_INET6 #define AF_INET6 10 #endif @@ -36,7 +36,7 @@ struct in6_addr { uint16_t u6_addr16[8]; uint32_t u6_addr32[4]; } in6_u; -} __attribute__((__packed__)); +} __attribute__ ((__packed__)); #define s6_addr in6_u.u6_addr8 #define s6_addr16 in6_u.u6_addr16 #define s6_addr32 in6_u.u6_addr32 @@ -49,14 +49,14 @@ struct sockaddr_in6 { uint32_t sin6_flowinfo; struct in6_addr sin6_addr; uint32_t sin6_scope_id; -} __attribute__((__packed__)); +} __attribute__ ((__packed__)); #endif #ifndef IN6_IS_ADDR_V4MAPPED #define IN6_IS_ADDR_V4MAPPED(a) \ - ((((const uint32_t *) (a))[0] == 0) \ - && (((const uint32_t *) (a))[1] == 0) \ - && (((const uint32_t *) (a))[2] == htonl (0xffff))) + ((((__const uint32_t *) (a))[0] == 0) \ + && (((__const uint32_t *) (a))[1] == 0) \ + && (((__const uint32_t *) (a))[2] == htonl (0xffff))) #endif #ifndef HAVE_STRUCT_IP6_HDR @@ -72,7 +72,7 @@ struct ip6_hdr { } ip6_ctlun; struct in6_addr ip6_src; struct in6_addr ip6_dst; -} __attribute__((__packed__)); +} __attribute__ ((__packed__)); #define ip6_vfc ip6_ctlun.ip6_un2_vfc #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen @@ -91,14 +91,12 @@ struct icmp6_hdr { uint16_t icmp6_un_data16[2]; uint8_t icmp6_un_data8[4]; } icmp6_dataun; -} __attribute__((__packed__)); +} __attribute__ ((__packed__)); #define ICMP6_DST_UNREACH_NOROUTE 0 #define ICMP6_DST_UNREACH 1 #define ICMP6_PACKET_TOO_BIG 2 -#define ICMP6_TIME_EXCEEDED 3 #define ICMP6_DST_UNREACH_ADMIN 1 #define ICMP6_DST_UNREACH_ADDR 3 -#define ICMP6_TIME_EXCEED_TRANSIT 0 #define ND_NEIGHBOR_SOLICIT 135 #define ND_NEIGHBOR_ADVERT 136 #define icmp6_data32 icmp6_dataun.icmp6_un_data32 @@ -111,7 +109,7 @@ struct icmp6_hdr { struct nd_neighbor_solicit { struct icmp6_hdr nd_ns_hdr; struct in6_addr nd_ns_target; -} __attribute__((__packed__)); +} __attribute__ ((__packed__)); #define ND_OPT_SOURCE_LINKADDR 1 #define ND_OPT_TARGET_LINKADDR 2 #define nd_ns_type nd_ns_hdr.icmp6_type @@ -124,7 +122,7 @@ struct nd_neighbor_solicit { struct nd_opt_hdr { uint8_t nd_opt_type; uint8_t nd_opt_len; -} __attribute__((__packed__)); +} __attribute__ ((__packed__)); #endif -#endif +#endif /* __TINC_IPV6_H__ */ diff --git a/src/linux/device.c b/src/linux/device.c index 38debe8..d36f3f6 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction with Linux ethertap and tun/tap device Copyright (C) 2001-2005 Ivo Timmermans, - 2001-2014 Guus Sliepen + 2001-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,25 +18,21 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "../system.h" +#include "system.h" -#ifdef HAVE_LINUX_IF_TUN_H #include #define DEFAULT_DEVICE "/dev/net/tun" -#else -#define DEFAULT_DEVICE "/dev/tap0" -#endif -#include "../conf.h" -#include "../device.h" -#include "../logger.h" -#include "../net.h" -#include "../route.h" -#include "../utils.h" -#include "../xalloc.h" +#include "conf.h" +#include "device.h" +#include "logger.h" +#include "net.h" +#include "route.h" +#include "utils.h" +#include "xalloc.h" +#include "device.h" typedef enum device_type_t { - DEVICE_TYPE_ETHERTAP, DEVICE_TYPE_TUN, DEVICE_TYPE_TAP, } device_type_t; @@ -45,27 +41,22 @@ int device_fd = -1; static device_type_t device_type; char *device = NULL; char *iface = NULL; -static char *type = NULL; static char ifrname[IFNAMSIZ]; -static const char *device_info; +static char *device_info; -static uint64_t device_total_in = 0; -static uint64_t device_total_out = 0; +uint64_t device_in_packets = 0; +uint64_t device_in_bytes = 0; +uint64_t device_out_packets = 0; +uint64_t device_out_bytes = 0; -static bool setup_device(void) { - struct ifreq ifr; - bool t1q = false; - - if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { +bool setup_device(void) { + if(!get_config_string(lookup_config(config_tree, "Device"), &device)) device = xstrdup(DEFAULT_DEVICE); - } if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) #ifdef HAVE_LINUX_IF_TUN_H - if(netname != NULL) { + if (netname != NULL) iface = xstrdup(netname); - } - #else iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device); #endif @@ -76,79 +67,38 @@ static bool setup_device(void) { return false; } -#ifdef FD_CLOEXEC - fcntl(device_fd, F_SETFD, FD_CLOEXEC); -#endif + struct ifreq ifr = {{{0}}}; -#ifdef HAVE_LINUX_IF_TUN_H - /* Ok now check if this is an old ethertap or a new tun/tap thingie */ - - memset(&ifr, 0, sizeof(ifr)); - - get_config_string(lookup_config(config_tree, "DeviceType"), &type); - - if(type && strcasecmp(type, "tun") && strcasecmp(type, "tap")) { - logger(LOG_ERR, "Unknown device type %s!", type); - return false; - } - - if((type && !strcasecmp(type, "tun")) || (!type && routing_mode == RMODE_ROUTER)) { + if(routing_mode == RMODE_ROUTER) { ifr.ifr_flags = IFF_TUN; device_type = DEVICE_TYPE_TUN; device_info = "Linux tun/tap device (tun mode)"; } else { - if(routing_mode == RMODE_ROUTER) { - overwrite_mac = true; - } - ifr.ifr_flags = IFF_TAP | IFF_NO_PI; device_type = DEVICE_TYPE_TAP; device_info = "Linux tun/tap device (tap mode)"; } #ifdef IFF_ONE_QUEUE - /* Set IFF_ONE_QUEUE flag... */ - if(get_config_bool(lookup_config(config_tree, "IffOneQueue"), &t1q) && t1q) { - ifr.ifr_flags |= IFF_ONE_QUEUE; - } + bool t1q = false; + if(get_config_bool(lookup_config(config_tree, "IffOneQueue"), &t1q) && t1q) + ifr.ifr_flags |= IFF_ONE_QUEUE; #endif - if(iface) { + if(iface) strncpy(ifr.ifr_name, iface, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ - 1] = 0; - } if(!ioctl(device_fd, TUNSETIFF, &ifr)) { strncpy(ifrname, ifr.ifr_name, IFNAMSIZ); - ifrname[IFNAMSIZ - 1] = 0; - free(iface); + if(iface) free(iface); iface = xstrdup(ifrname); - } else if(errno == EPERM || errno == EBUSY) { - logger(LOG_ERR, "Error while trying to configure %s: %s", device, strerror(errno)); - return false; } else if(!ioctl(device_fd, (('T' << 8) | 202), &ifr)) { logger(LOG_WARNING, "Old ioctl() request was needed for %s", device); strncpy(ifrname, ifr.ifr_name, IFNAMSIZ); - ifrname[IFNAMSIZ - 1] = 0; - free(iface); + if(iface) free(iface); iface = xstrdup(ifrname); - } else -#endif - { - if(routing_mode == RMODE_ROUTER) { - overwrite_mac = true; - } - - device_info = "Linux ethertap device"; - device_type = DEVICE_TYPE_ETHERTAP; - free(iface); - iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device); - } - - if(overwrite_mac && !ioctl(device_fd, SIOCGIFHWADDR, &ifr)) { - memcpy(mymac.x, ifr.ifr_hwaddr.sa_data, ETH_ALEN); } logger(LOG_INFO, "%s is a %s", device, device_info); @@ -156,116 +106,84 @@ static bool setup_device(void) { return true; } -static void close_device(void) { +void close_device(void) { close(device_fd); - free(type); free(device); free(iface); } -static bool read_packet(vpn_packet_t *packet) { - int lenin; - +bool read_packet(vpn_packet_t *packet) { + int inlen; + switch(device_type) { - case DEVICE_TYPE_TUN: - lenin = read(device_fd, packet->data + 10, MTU - 10); + case DEVICE_TYPE_TUN: + inlen = read(device_fd, packet->data + 10, MTU - 10); - if(lenin <= 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", - device_info, device, strerror(errno)); - return false; - } + if(inlen <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", + device_info, device, strerror(errno)); + return false; + } - memset(packet->data, 0, 12); - packet->len = lenin + 10; - break; + packet->len = inlen + 10; + break; + case DEVICE_TYPE_TAP: + inlen = read(device_fd, packet->data, MTU); - case DEVICE_TYPE_TAP: - lenin = read(device_fd, packet->data, MTU); + if(inlen <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", + device_info, device, strerror(errno)); + return false; + } - if(lenin <= 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", - device_info, device, strerror(errno)); - return false; - } - - packet->len = lenin; - break; - - case DEVICE_TYPE_ETHERTAP: - lenin = read(device_fd, packet->data - 2, MTU + 2); - - if(lenin <= 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", - device_info, device, strerror(errno)); - return false; - } - - packet->len = lenin - 2; - break; + packet->len = inlen; + break; + default: + abort(); } - device_total_in += packet->len; + device_in_packets++; + device_in_bytes += packet->len; ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, - device_info); + device_info); return true; } -static bool write_packet(vpn_packet_t *packet) { +bool write_packet(vpn_packet_t *packet) { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + packet->len, device_info); switch(device_type) { - case DEVICE_TYPE_TUN: - packet->data[10] = packet->data[11] = 0; - - if(write(device_fd, packet->data + 10, packet->len - 10) < 0) { - logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, - strerror(errno)); - return false; - } - - break; - - case DEVICE_TYPE_TAP: - if(write(device_fd, packet->data, packet->len) < 0) { - logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, - strerror(errno)); - return false; - } - - break; - - case DEVICE_TYPE_ETHERTAP: - memcpy(packet->data - 2, &packet->len, 2); - - if(write(device_fd, packet->data - 2, packet->len + 2) < 0) { - logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, - strerror(errno)); - return false; - } - - break; + case DEVICE_TYPE_TUN: + packet->data[10] = packet->data[11] = 0; + if(write(device_fd, packet->data + 10, packet->len - 10) < 0) { + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, + strerror(errno)); + return false; + } + break; + case DEVICE_TYPE_TAP: + if(write(device_fd, packet->data, packet->len) < 0) { + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, + strerror(errno)); + return false; + } + break; + default: + abort(); } - device_total_out += packet->len; + device_out_packets++; + device_out_bytes += packet->len; return true; } -static void dump_device_stats(void) { +void dump_device_stats(void) { logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); - logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); - logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_in_bytes); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_out_bytes); } - -const devops_t os_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, - .dump_stats = dump_device_stats, -}; diff --git a/src/list.c b/src/list.c index a807c6d..9b67791 100644 --- a/src/list.c +++ b/src/list.c @@ -43,9 +43,8 @@ list_node_t *list_alloc_node(void) { } void list_free_node(list_t *list, list_node_t *node) { - if(node->data && list->delete) { + if(node->data && list->delete) list->delete(node->data); - } free(node); } @@ -62,11 +61,10 @@ list_node_t *list_insert_head(list_t *list, void *data) { node->next = list->head; list->head = node; - if(node->next) { + if(node->next) node->next->prev = node; - } else { + else list->tail = node; - } list->count++; @@ -83,11 +81,50 @@ list_node_t *list_insert_tail(list_t *list, void *data) { node->prev = list->tail; list->tail = node; - if(node->prev) { + if(node->prev) node->prev->next = node; - } else { + else + list->head = node; + + list->count++; + + return node; +} + +list_node_t *list_insert_after(list_t *list, list_node_t *after, void *data) { + list_node_t *node; + + node = list_alloc_node(); + + node->data = data; + node->next = after->next; + node->prev = after; + after->next = node; + + if(node->next) + node->next->prev = node; + else + list->tail = node; + + list->count++; + + return node; +} + +list_node_t *list_insert_before(list_t *list, list_node_t *before, void *data) { + list_node_t *node; + + node = list_alloc_node(); + + node->data = data; + node->next = before; + node->prev = before->prev; + before->prev = node; + + if(node->prev) + node->prev->next = node; + else list->head = node; - } list->count++; @@ -95,17 +132,15 @@ list_node_t *list_insert_tail(list_t *list, void *data) { } void list_unlink_node(list_t *list, list_node_t *node) { - if(node->prev) { + if(node->prev) node->prev->next = node->next; - } else { + else list->head = node->next; - } - if(node->next) { + if(node->next) node->next->prev = node->prev; - } else { + else list->tail = node->prev; - } list->count--; } @@ -126,19 +161,17 @@ void list_delete_tail(list_t *list) { /* Head/tail lookup */ void *list_get_head(list_t *list) { - if(list->head) { + if(list->head) return list->head->data; - } else { + else return NULL; - } } void *list_get_tail(list_t *list) { - if(list->tail) { + if(list->tail) return list->tail->data; - } else { + else return NULL; - } } /* Fast list deletion */ @@ -170,9 +203,7 @@ void list_foreach(list_t *list, list_action_t action) { for(node = list->head; node; node = next) { next = node->next; - - if(node->data) { + if(node->data) action(node->data); - } } } diff --git a/src/list.h b/src/list.h index b2a9b3d..4fe48db 100644 --- a/src/list.h +++ b/src/list.h @@ -1,6 +1,3 @@ -#ifndef TINC_LIST_H -#define TINC_LIST_H - /* list.h -- header file for list.c Copyright (C) 2000-2005 Ivo Timmermans @@ -21,6 +18,9 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_LIST_H__ +#define __TINC_LIST_H__ + typedef struct list_node_t { struct list_node_t *prev; struct list_node_t *next; @@ -45,34 +45,36 @@ typedef struct list_t { /* (De)constructors */ -extern list_t *list_alloc(list_action_t) __attribute__((__malloc__)); -extern void list_free(list_t *list); +extern list_t *list_alloc(list_action_t) __attribute__ ((__malloc__)); +extern void list_free(list_t *); extern list_node_t *list_alloc_node(void); -extern void list_free_node(list_t *list, list_node_t *node); +extern void list_free_node(list_t *, list_node_t *); /* Insertion and deletion */ -extern list_node_t *list_insert_head(list_t *list, void *data); -extern list_node_t *list_insert_tail(list_t *list, void *data); +extern list_node_t *list_insert_head(list_t *, void *); +extern list_node_t *list_insert_tail(list_t *, void *); +extern list_node_t *list_insert_after(list_t *, list_node_t *, void *); +extern list_node_t *list_insert_before(list_t *, list_node_t *, void *); -extern void list_unlink_node(list_t *list, list_node_t *node); -extern void list_delete_node(list_t *list, list_node_t *node); +extern void list_unlink_node(list_t *, list_node_t *); +extern void list_delete_node(list_t *, list_node_t *); -extern void list_delete_head(list_t *list); -extern void list_delete_tail(list_t *list); +extern void list_delete_head(list_t *); +extern void list_delete_tail(list_t *); /* Head/tail lookup */ -extern void *list_get_head(list_t *list); -extern void *list_get_tail(list_t *list); +extern void *list_get_head(list_t *); +extern void *list_get_tail(list_t *); /* Fast list deletion */ -extern void list_delete_list(list_t *list); +extern void list_delete_list(list_t *); /* Traversing */ -extern void list_foreach(list_t *list, list_action_t action); -extern void list_foreach_node(list_t *list, list_action_node_t action); +extern void list_foreach(list_t *, list_action_t); +extern void list_foreach_node(list_t *, list_action_node_t); -#endif +#endif /* __TINC_LIST_H__ */ diff --git a/src/logger.c b/src/logger.c index 8d4aea1..08f9795 100644 --- a/src/logger.c +++ b/src/logger.c @@ -1,6 +1,6 @@ /* logger.c -- logging code - Copyright (C) 2004-2016 Guus Sliepen + Copyright (C) 2004-2006 Guus Sliepen 2004-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -36,58 +36,48 @@ static const char *logident = NULL; void openlogger(const char *ident, logmode_t mode) { logident = ident; logmode = mode; - + switch(mode) { - case LOGMODE_STDERR: - logpid = getpid(); - break; - - case LOGMODE_FILE: - logpid = getpid(); - logfile = fopen(logfilename, "a"); - - if(!logfile) { - fprintf(stderr, "Could not open log file %s: %s\n", logfilename, strerror(errno)); - logmode = LOGMODE_NULL; - } - - break; - - case LOGMODE_SYSLOG: + case LOGMODE_STDERR: + logpid = getpid(); + break; + case LOGMODE_FILE: + logpid = getpid(); + logfile = fopen(logfilename, "a"); + if(!logfile) { + fprintf(stderr, "Could not open log file %s: %s\n", logfilename, strerror(errno)); + logmode = LOGMODE_NULL; + } + break; + case LOGMODE_SYSLOG: #ifdef HAVE_MINGW - loghandle = RegisterEventSource(NULL, logident); - - if(!loghandle) { - fprintf(stderr, "Could not open log handle!"); - logmode = LOGMODE_NULL; - } - - break; + loghandle = RegisterEventSource(NULL, logident); + if(!loghandle) { + fprintf(stderr, "Could not open log handle!"); + logmode = LOGMODE_NULL; + } + break; #else #ifdef HAVE_SYSLOG_H - openlog(logident, LOG_CONS | LOG_PID, LOG_DAEMON); - break; + openlog(logident, LOG_CONS | LOG_PID, LOG_DAEMON); + break; #endif #endif - - case LOGMODE_NULL: - break; + case LOGMODE_NULL: + break; } } void reopenlogger() { - if(logmode != LOGMODE_FILE) { + if(logmode != LOGMODE_FILE) return; - } fflush(logfile); FILE *newfile = fopen(logfilename, "a"); - if(!newfile) { - logger(LOG_ERR, "Unable to reopen log file %s: %s", logfilename, strerror(errno)); + logger(LOG_ERR, "Unable to reopen log file %s: %s\n", logfilename, strerror(errno)); return; } - fclose(logfile); logfile = newfile; } @@ -100,48 +90,43 @@ void logger(int priority, const char *format, ...) { va_start(ap, format); switch(logmode) { - case LOGMODE_STDERR: - vfprintf(stderr, format, ap); - fprintf(stderr, "\n"); - fflush(stderr); - break; - - case LOGMODE_FILE: - now = time(NULL); - strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", localtime(&now)); - fprintf(logfile, "%s %s[%ld]: ", timestr, logident, (long)logpid); - vfprintf(logfile, format, ap); - fprintf(logfile, "\n"); - fflush(logfile); - break; - - case LOGMODE_SYSLOG: + case LOGMODE_STDERR: + vfprintf(stderr, format, ap); + fprintf(stderr, "\n"); + fflush(stderr); + break; + case LOGMODE_FILE: + now = time(NULL); + strftime(timestr, sizeof timestr, "%Y-%m-%d %H:%M:%S", localtime(&now)); + fprintf(logfile, "%s %s[%ld]: ", timestr, logident, (long)logpid); + vfprintf(logfile, format, ap); + fprintf(logfile, "\n"); + fflush(logfile); + break; + case LOGMODE_SYSLOG: #ifdef HAVE_MINGW - { - char message[4096]; - const char *messages[] = {message}; - vsnprintf(message, sizeof(message), format, ap); - message[sizeof(message) - 1] = 0; - ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL); - } - + { + char message[4096]; + const char *messages[] = {message}; + vsnprintf(message, sizeof message, format, ap); + ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL); + } #else #ifdef HAVE_SYSLOG_H #ifdef HAVE_VSYSLOG - vsyslog(priority, format, ap); + vsyslog(priority, format, ap); #else - { - char message[4096]; - vsnprintf(message, sizeof(message), format, ap); - syslog(priority, "%s", message); - } + { + char message[4096]; + vsnprintf(message, sizeof message, format, ap); + syslog(priority, "%s", message); + } #endif - break; + break; #endif #endif - - case LOGMODE_NULL: - break; + case LOGMODE_NULL: + break; } va_end(ap); @@ -149,23 +134,22 @@ void logger(int priority, const char *format, ...) { void closelogger(void) { switch(logmode) { - case LOGMODE_FILE: - fclose(logfile); - break; - - case LOGMODE_SYSLOG: + case LOGMODE_FILE: + fclose(logfile); + break; + case LOGMODE_SYSLOG: #ifdef HAVE_MINGW - DeregisterEventSource(loghandle); - break; + DeregisterEventSource(loghandle); + break; #else #ifdef HAVE_SYSLOG_H - closelog(); - break; + closelog(); + break; #endif #endif - - case LOGMODE_NULL: - case LOGMODE_STDERR: - break; + case LOGMODE_NULL: + case LOGMODE_STDERR: + break; + break; } } diff --git a/src/logger.h b/src/logger.h index 5a17ffb..ff2cb34 100644 --- a/src/logger.h +++ b/src/logger.h @@ -1,36 +1,17 @@ -#ifndef TINC_LOGGER_H -#define TINC_LOGGER_H - -/* - logger.h -- header file for logger.c - Copyright (C) 2003-2016 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ +#ifndef __TINC_LOGGER_H__ +#define __TINC_LOGGER_H__ typedef enum debug_t { - DEBUG_NOTHING = 0, /* Quiet mode, only show starting/stopping of the daemon */ + DEBUG_NOTHING = 0, /* Quiet mode, only show starting/stopping of the daemon */ DEBUG_ALWAYS = 0, - DEBUG_CONNECTIONS = 1, /* Show (dis)connects of other tinc daemons via TCP */ - DEBUG_ERROR = 2, /* Show error messages received from other hosts */ - DEBUG_STATUS = 2, /* Show status messages received from other hosts */ - DEBUG_PROTOCOL = 3, /* Show the requests that are sent/received */ - DEBUG_META = 4, /* Show contents of every request that is sent/received */ - DEBUG_TRAFFIC = 5, /* Show network traffic information */ - DEBUG_PACKET = 6, /* Show contents of each packet that is being sent/received */ - DEBUG_SCARY_THINGS = 10, /* You have been warned */ + DEBUG_CONNECTIONS = 1, /* Show (dis)connects of other tinc daemons via TCP */ + DEBUG_ERROR = 2, /* Show error messages received from other hosts */ + DEBUG_STATUS = 2, /* Show status messages received from other hosts */ + DEBUG_PROTOCOL = 3, /* Show the requests that are sent/received */ + DEBUG_META = 4, /* Show contents of every request that is sent/received */ + DEBUG_TRAFFIC = 5, /* Show network traffic information */ + DEBUG_PACKET = 6, /* Show contents of each packet that is being sent/received */ + DEBUG_SCARY_THINGS = 10 /* You have been warned */ } debug_t; typedef enum logmode_t { @@ -65,11 +46,11 @@ enum { #endif extern debug_t debug_level; -extern void openlogger(const char *ident, logmode_t mode); +extern void openlogger(const char *, logmode_t); extern void reopenlogger(void); -extern void logger(int priority, const char *format, ...) __attribute__((__format__(printf, 2, 3))); +extern void logger(int, const char *, ...) __attribute__ ((__format__(printf, 2, 3))); extern void closelogger(void); #define ifdebug(l) if(debug_level >= DEBUG_##l) -#endif +#endif /* __TINC_LOGGER_H__ */ diff --git a/src/meta.c b/src/meta.c index ee55ecd..29dd824 100644 --- a/src/meta.c +++ b/src/meta.c @@ -1,6 +1,6 @@ /* meta.c -- handle the meta communication - Copyright (C) 2000-2017 Guus Sliepen , + Copyright (C) 2000-2009 Guus Sliepen , 2000-2005 Ivo Timmermans 2006 Scott Lamb @@ -21,125 +21,60 @@ #include "system.h" -#include -#include - -#include "avl_tree.h" +#include "splay_tree.h" +#include "cipher.h" #include "connection.h" #include "logger.h" #include "meta.h" #include "net.h" #include "protocol.h" -#include "proxy.h" #include "utils.h" #include "xalloc.h" bool send_meta(connection_t *c, const char *buffer, int length) { - int outlen; - int result; + if(!c) { + logger(LOG_ERR, "send_meta() called with NULL pointer!"); + abort(); + } ifdebug(META) logger(LOG_DEBUG, "Sending %d bytes of metadata to %s (%s)", length, - c->name, c->hostname); - - if(!c->outbuflen) { - c->last_flushed_time = now; - } - - /* Find room in connection's buffer */ - if(length + c->outbuflen > c->outbufsize) { - c->outbufsize = length + c->outbuflen; - c->outbuf = xrealloc(c->outbuf, c->outbufsize); - } - - if(length + c->outbuflen + c->outbufstart > c->outbufsize) { - memmove(c->outbuf, c->outbuf + c->outbufstart, c->outbuflen); - c->outbufstart = 0; - } + c->name, c->hostname); /* Add our data to buffer */ if(c->status.encryptout) { - /* Check encryption limits */ - if((uint64_t)length > c->outbudget) { - ifdebug(META) logger(LOG_ERR, "Byte limit exceeded for encryption to %s (%s)", c->name, c->hostname); + size_t outlen = length; + + if(!cipher_encrypt(&c->outcipher, buffer, length, buffer_prepare(&c->outbuf, length), &outlen, false) || outlen != length) { + logger(LOG_ERR, "Error while encrypting metadata to %s (%s)", + c->name, c->hostname); return false; - } else { - c->outbudget -= length; } - result = EVP_EncryptUpdate(c->outctx, (unsigned char *)c->outbuf + c->outbufstart + c->outbuflen, - &outlen, (unsigned char *)buffer, length); - - if(!result || outlen < length) { - logger(LOG_ERR, "Error while encrypting metadata to %s (%s): %s", - c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); - return false; - } else if(outlen > length) { - logger(LOG_EMERG, "Encrypted data too long! Heap corrupted!"); - abort(); - } - - c->outbuflen += outlen; } else { - memcpy(c->outbuf + c->outbufstart + c->outbuflen, buffer, length); - c->outbuflen += length; + buffer_add(&c->outbuf, buffer, length); } - return true; -} + event_add(&c->outevent, NULL); -bool flush_meta(connection_t *c) { - int result; - - ifdebug(META) logger(LOG_DEBUG, "Flushing %d bytes to %s (%s)", - c->outbuflen, c->name, c->hostname); - - while(c->outbuflen) { - result = send(c->socket, c->outbuf + c->outbufstart, c->outbuflen, 0); - - if(result <= 0) { - if(!errno || errno == EPIPE) { - ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection closed by %s (%s)", - c->name, c->hostname); - } else if(errno == EINTR) { - continue; - } else if(sockwouldblock(sockerrno)) { - ifdebug(META) logger(LOG_DEBUG, "Flushing %d bytes to %s (%s) would block", - c->outbuflen, c->name, c->hostname); - return true; - } else { - logger(LOG_ERR, "Flushing meta data to %s (%s) failed: %s", c->name, - c->hostname, sockstrerror(sockerrno)); - } - - return false; - } - - c->outbufstart += result; - c->outbuflen -= result; - } - - c->outbufstart = 0; /* avoid unnecessary memmoves */ return true; } void broadcast_meta(connection_t *from, const char *buffer, int length) { - avl_node_t *node; + splay_node_t *node; connection_t *c; for(node = connection_tree->head; node; node = node->next) { c = node->data; - if(c != from && c->status.active) { + if(c != from && c->status.active) send_meta(c, buffer, length); - } } } bool receive_meta(connection_t *c) { - int oldlen, i, result; - int lenin, lenout, reqlen; - bool decrypted = false; + int inlen; char inbuf[MAXBUFSIZE]; + char *bufp = inbuf, *endp; /* Strategy: - Read as much as possible from the TCP socket in one go. @@ -150,109 +85,79 @@ bool receive_meta(connection_t *c) { - If not, keep stuff in buffer and exit. */ - lenin = recv(c->socket, c->buffer + c->buflen, MAXBUFSIZE - c->buflen, 0); - - if(lenin <= 0) { - if(!lenin || !errno) { - ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection closed by %s (%s)", - c->name, c->hostname); - } else if(sockwouldblock(sockerrno)) { - return true; - } else - logger(LOG_ERR, "Metadata socket read error for %s (%s): %s", - c->name, c->hostname, sockstrerror(sockerrno)); + buffer_compact(&c->inbuf, MAXBUFSIZE); + if(sizeof inbuf <= c->inbuf.len) { + logger(LOG_ERR, "Input buffer full for %s (%s)", c->name, c->hostname); return false; } - oldlen = c->buflen; - c->buflen += lenin; + inlen = recv(c->socket, inbuf, sizeof inbuf - c->inbuf.len, 0); - while(lenin > 0) { - reqlen = 0; + if(inlen <= 0) { + if(!inlen || !errno) { + ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection closed by %s (%s)", + c->name, c->hostname); + } else if(sockwouldblock(sockerrno)) + return true; + else + logger(LOG_ERR, "Metadata socket read error for %s (%s): %s", + c->name, c->hostname, sockstrerror(sockerrno)); + return false; + } - /* Is it proxy metadata? */ + do { + if(!c->status.decryptin) { + endp = memchr(bufp, '\n', inlen); + if(endp) + endp++; + else + endp = bufp + inlen; - if(c->allow_request == PROXY) { - reqlen = receive_proxy_meta(c); + buffer_add(&c->inbuf, bufp, endp - bufp); - if(reqlen < 0) { - return false; - } - - goto consume; - } - - /* Decrypt */ - - if(c->status.decryptin && !decrypted) { - /* Check decryption limits */ - if((uint64_t)lenin > c->inbudget) { - ifdebug(META) logger(LOG_ERR, "Byte limit exceeded for decryption from %s (%s)", c->name, c->hostname); - return false; - } else { - c->inbudget -= lenin; - } - - result = EVP_DecryptUpdate(c->inctx, (unsigned char *)inbuf, &lenout, (unsigned char *)c->buffer + oldlen, lenin); - - if(!result || lenout != lenin) { - logger(LOG_ERR, "Error while decrypting metadata from %s (%s): %s", - c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); - return false; - } - - memcpy(c->buffer + oldlen, inbuf, lenin); - decrypted = true; - } - - /* Are we receiving a TCPpacket? */ - - if(c->tcplen) { - if(c->tcplen <= c->buflen) { - if(c->allow_request != ALL) { - logger(LOG_ERR, "Got unauthorized TCP packet from %s (%s)", c->name, c->hostname); - return false; - } - - receive_tcppacket(c, c->buffer, c->tcplen); - reqlen = c->tcplen; - c->tcplen = 0; - } + inlen -= endp - bufp; + bufp = endp; } else { - /* Otherwise we are waiting for a request */ + size_t outlen = inlen; + ifdebug(META) logger(LOG_DEBUG, "Received encrypted %d bytes", inlen); - for(i = oldlen; i < c->buflen; i++) { - if(c->buffer[i] == '\n') { - c->buffer[i] = '\0'; /* replace end-of-line by end-of-string so we can use sscanf */ - c->reqlen = reqlen = i + 1; + if(!cipher_decrypt(&c->incipher, bufp, inlen, buffer_prepare(&c->inbuf, inlen), &outlen, false) || inlen != outlen) { + logger(LOG_ERR, "Error while decrypting metadata from %s (%s)", + c->name, c->hostname); + return false; + } + + inlen = 0; + } + + while(c->inbuf.len) { + /* Are we receiving a TCPpacket? */ + + if(c->tcplen) { + char *tcpbuffer = buffer_read(&c->inbuf, c->tcplen); + if(tcpbuffer) { + receive_tcppacket(c, tcpbuffer, c->tcplen); + c->tcplen = 0; + continue; + } else { break; } } - if(reqlen && !receive_request(c)) { - return false; + /* Otherwise we are waiting for a request */ + + char *request = buffer_readline(&c->inbuf); + if(request) { + bool result = receive_request(c, request); + if(!result) + return false; + continue; + } else { + break; } } - -consume: - - if(reqlen) { - c->buflen -= reqlen; - lenin -= reqlen - oldlen; - memmove(c->buffer, c->buffer + reqlen, c->buflen); - oldlen = 0; - continue; - } else { - break; - } - } - - if(c->buflen >= MAXBUFSIZE) { - logger(LOG_ERR, "Metadata read buffer overflow for %s (%s)", - c->name, c->hostname); - return false; - } + } while(inlen); return true; } diff --git a/src/meta.h b/src/meta.h index 36914f1..bc81a6a 100644 --- a/src/meta.h +++ b/src/meta.h @@ -1,6 +1,3 @@ -#ifndef TINC_META_H -#define TINC_META_H - /* meta.h -- header for meta.c Copyright (C) 2000-2006 Guus Sliepen , @@ -21,11 +18,13 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_META_H__ +#define __TINC_META_H__ + #include "connection.h" -extern bool send_meta(struct connection_t *c, const char *buffer, int length); -extern void broadcast_meta(struct connection_t *c, const char *buffer, int length); -extern bool flush_meta(struct connection_t *c); -extern bool receive_meta(struct connection_t *c); +extern bool send_meta(struct connection_t *, const char *, int); +extern void broadcast_meta(struct connection_t *, const char *, int); +extern bool receive_meta(struct connection_t *); -#endif +#endif /* __TINC_META_H__ */ diff --git a/src/mingw/common.h b/src/mingw/common.h index 41b9dc5..6e5e75c 100644 --- a/src/mingw/common.h +++ b/src/mingw/common.h @@ -37,7 +37,7 @@ //============= #define TAP_CONTROL_CODE(request,method) \ - CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS) + CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS) #define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE (1, METHOD_BUFFERED) #define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE (2, METHOD_BUFFERED) diff --git a/src/mingw/device.c b/src/mingw/device.c index 321c515..bdca842 100644 --- a/src/mingw/device.c +++ b/src/mingw/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction with Windows tap driver in a MinGW environment Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2016 Guus Sliepen + 2002-2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,87 +18,72 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "../system.h" +#include "system.h" #include #include -#include "../conf.h" -#include "../device.h" -#include "../logger.h" -#include "../net.h" -#include "../route.h" -#include "../utils.h" -#include "../xalloc.h" +#include "conf.h" +#include "device.h" +#include "logger.h" +#include "net.h" +#include "route.h" +#include "utils.h" +#include "xalloc.h" -#include "common.h" +#include "mingw/common.h" int device_fd = -1; static HANDLE device_handle = INVALID_HANDLE_VALUE; char *device = NULL; char *iface = NULL; -static const char *device_info = "Windows tap device"; +static char *device_info = NULL; static uint64_t device_total_in = 0; static uint64_t device_total_out = 0; extern char *myport; -OVERLAPPED r_overlapped; -OVERLAPPED w_overlapped; static DWORD WINAPI tapreader(void *bla) { int status; - DWORD len; + long len; + OVERLAPPED overlapped; vpn_packet_t packet; - int errors = 0; logger(LOG_DEBUG, "Tap reader running"); /* Read from tap device and send to parent */ - r_overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); for(;;) { - ResetEvent(r_overlapped.hEvent); + overlapped.Offset = 0; + overlapped.OffsetHigh = 0; + ResetEvent(overlapped.hEvent); - status = ReadFile(device_handle, packet.data, MTU, &len, &r_overlapped); + status = ReadFile(device_handle, packet.data, MTU, &len, &overlapped); if(!status) { if(GetLastError() == ERROR_IO_PENDING) { - WaitForSingleObject(r_overlapped.hEvent, INFINITE); - - if(!GetOverlappedResult(device_handle, &r_overlapped, &len, FALSE)) { + WaitForSingleObject(overlapped.hEvent, INFINITE); + if(!GetOverlappedResult(device_handle, &overlapped, &len, FALSE)) continue; - } } else { logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, - device, strerror(errno)); - errors++; - - if(errors >= 10) { - EnterCriticalSection(&mutex); - running = false; - LeaveCriticalSection(&mutex); - } - - usleep(1000000); - continue; + device, strerror(errno)); + return -1; } } - errors = 0; + EnterCriticalSection(&mutex); packet.len = len; packet.priority = 0; - - EnterCriticalSection(&mutex); route(myself, &packet); LeaveCriticalSection(&mutex); } - - return 0; } -static bool setup_device(void) { +bool setup_device(void) { HKEY key, key2; int i; @@ -106,7 +91,7 @@ static bool setup_device(void) { char adapterid[1024]; char adaptername[1024]; char tapname[1024]; - DWORD len; + long len; unsigned long status; bool found = false; @@ -117,10 +102,6 @@ static bool setup_device(void) { get_config_string(lookup_config(config_tree, "Device"), &device); get_config_string(lookup_config(config_tree, "Interface"), &iface); - if(device && iface) { - logger(LOG_WARNING, "Warning: both Device and Interface specified, results may not be as expected"); - } - /* Open registry and look for network adapters */ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWORK_CONNECTIONS_KEY, 0, KEY_READ, &key)) { @@ -128,51 +109,44 @@ static bool setup_device(void) { return false; } - for(i = 0; ; i++) { - len = sizeof(adapterid); - - if(RegEnumKeyEx(key, i, adapterid, &len, 0, 0, 0, NULL)) { + for (i = 0; ; i++) { + len = sizeof adapterid; + if(RegEnumKeyEx(key, i, adapterid, &len, 0, 0, 0, NULL)) break; - } /* Find out more about this adapter */ - snprintf(regpath, sizeof(regpath), "%s\\%s\\Connection", NETWORK_CONNECTIONS_KEY, adapterid); + snprintf(regpath, sizeof regpath, "%s\\%s\\Connection", NETWORK_CONNECTIONS_KEY, adapterid); - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, regpath, 0, KEY_READ, &key2)) { + if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, regpath, 0, KEY_READ, &key2)) continue; - } - len = sizeof(adaptername); - err = RegQueryValueEx(key2, "Name", 0, 0, (LPBYTE)adaptername, &len); + len = sizeof adaptername; + err = RegQueryValueEx(key2, "Name", 0, 0, adaptername, &len); RegCloseKey(key2); - if(err) { + if(err) continue; - } if(device) { if(!strcmp(device, adapterid)) { found = true; break; - } else { + } else continue; - } } if(iface) { if(!strcmp(iface, adaptername)) { found = true; break; - } else { + } else continue; - } } - snprintf(tapname, sizeof(tapname), USERMODEDEVICEDIR "%s" TAPSUFFIX, adapterid); + snprintf(tapname, sizeof tapname, USERMODEDEVICEDIR "%s" TAPSUFFIX, adapterid); device_handle = CreateFile(tapname, GENERIC_WRITE | GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0); - if(device_handle != INVALID_HANDLE_VALUE) { found = true; break; @@ -186,21 +160,19 @@ static bool setup_device(void) { return false; } - if(!device) { + if(!device) device = xstrdup(adapterid); - } - if(!iface) { + if(!iface) iface = xstrdup(adaptername); - } /* Try to open the corresponding tap device */ if(device_handle == INVALID_HANDLE_VALUE) { - snprintf(tapname, sizeof(tapname), USERMODEDEVICEDIR "%s" TAPSUFFIX, device); + snprintf(tapname, sizeof tapname, USERMODEDEVICEDIR "%s" TAPSUFFIX, device); device_handle = CreateFile(tapname, GENERIC_WRITE | GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0); } - + if(device_handle == INVALID_HANDLE_VALUE) { logger(LOG_ERR, "%s (%s) is not a usable Windows tap device: %s", device, iface, winerror(GetLastError())); return false; @@ -208,7 +180,7 @@ static bool setup_device(void) { /* Get MAC address from tap device */ - if(!DeviceIoControl(device_handle, TAP_IOCTL_GET_MAC, mymac.x, sizeof(mymac.x), mymac.x, sizeof(mymac.x), &len, 0)) { + if(!DeviceIoControl(device_handle, TAP_IOCTL_GET_MAC, mymac.x, sizeof mymac.x, mymac.x, sizeof mymac.x, &len, 0)) { logger(LOG_ERR, "Could not get MAC address from Windows tap device %s (%s): %s", device, iface, winerror(GetLastError())); return false; } @@ -217,11 +189,6 @@ static bool setup_device(void) { overwrite_mac = 1; } - /* Create overlapped events for tap I/O */ - - r_overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - w_overlapped.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); - /* Start the tap reader */ thread = CreateThread(NULL, 0, tapreader, NULL, 0, NULL); @@ -234,72 +201,36 @@ static bool setup_device(void) { /* Set media status for newer TAP-Win32 devices */ status = true; - DeviceIoControl(device_handle, TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof(status), &status, sizeof(status), &len, NULL); + DeviceIoControl(device_handle, TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof status, &status, sizeof status, &len, NULL); + + device_info = "Windows tap device"; logger(LOG_INFO, "%s (%s) is a %s", device, iface, device_info); return true; } -static void close_device(void) { +void close_device(void) { CloseHandle(device_handle); free(device); free(iface); } -static bool read_packet(vpn_packet_t *packet) { +bool read_packet(vpn_packet_t *packet) { return false; } -static bool write_packet(vpn_packet_t *packet) { - DWORD lenout; - static vpn_packet_t queue; +bool write_packet(vpn_packet_t *packet) { + long outlen; + OVERLAPPED overlapped = {0}; ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + packet->len, device_info); - /* Check if there is something in progress */ - - if(queue.len) { - DWORD size; - BOOL success = GetOverlappedResult(device_handle, &w_overlapped, &size, FALSE); - - if(success) { - ResetEvent(&w_overlapped); - queue.len = 0; - } else { - int err = GetLastError(); - - if(err != ERROR_IO_INCOMPLETE) { - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Error completing previously queued write: %s", winerror(err)); - ResetEvent(&w_overlapped); - queue.len = 0; - } else { - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Previous overlapped write still in progress"); - // drop this packet - return true; - } - } - } - - /* Otherwise, try to write. */ - - memcpy(queue.data, packet->data, packet->len); - - if(!WriteFile(device_handle, queue.data, packet->len, &lenout, &w_overlapped)) { - int err = GetLastError(); - - if(err != ERROR_IO_PENDING) { - logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, device, winerror(err)); - return false; - } - - // Write is being done asynchronously. - queue.len = packet->len; - } else { - // Write was completed immediately. - ResetEvent(&w_overlapped); + if(!WriteFile(device_handle, packet->data, packet->len, &outlen, &overlapped)) { + logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, device, winerror(GetLastError())); + return false; } device_total_out += packet->len; @@ -307,16 +238,8 @@ static bool write_packet(vpn_packet_t *packet) { return true; } -static void dump_device_stats(void) { +void dump_device_stats(void) { logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); } - -const devops_t os_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, - .dump_stats = dump_device_stats, -}; diff --git a/src/multicast_device.c b/src/multicast_device.c deleted file mode 100644 index 93a40c4..0000000 --- a/src/multicast_device.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - device.c -- multicast socket - Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2014 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "conf.h" -#include "device.h" -#include "net.h" -#include "logger.h" -#include "netutl.h" -#include "utils.h" -#include "route.h" -#include "xalloc.h" - -static const char *device_info = "multicast socket"; - -static uint64_t device_total_in = 0; -static uint64_t device_total_out = 0; - -static struct addrinfo *ai = NULL; -static mac_t ignore_src = {{0}}; - -static bool setup_device(void) { - char *host; - char *port; - char *space; - int ttl = 1; - - get_config_string(lookup_config(config_tree, "Interface"), &iface); - - if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { - logger(LOG_ERR, "Device variable required for %s", device_info); - return false; - } - - host = xstrdup(device); - space = strchr(host, ' '); - - if(!space) { - logger(LOG_ERR, "Port number required for %s", device_info); - free(host); - return false; - } - - *space++ = 0; - port = space; - space = strchr(port, ' '); - - if(space) { - *space++ = 0; - ttl = atoi(space); - } - - ai = str2addrinfo(host, port, SOCK_DGRAM); - - if(!ai) { - free(host); - return false; - } - - device_fd = socket(ai->ai_family, SOCK_DGRAM, IPPROTO_UDP); - - if(device_fd < 0) { - logger(LOG_ERR, "Creating socket failed: %s", sockstrerror(sockerrno)); - free(host); - return false; - } - -#ifdef FD_CLOEXEC - fcntl(device_fd, F_SETFD, FD_CLOEXEC); -#endif - - static const int one = 1; - setsockopt(device_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one)); - - if(bind(device_fd, ai->ai_addr, ai->ai_addrlen)) { - closesocket(device_fd); - logger(LOG_ERR, "Can't bind to %s %s: %s", host, port, sockstrerror(sockerrno)); - free(host); - return false; - } - - switch(ai->ai_family) { -#ifdef IP_ADD_MEMBERSHIP - - case AF_INET: { - struct ip_mreq mreq; - struct sockaddr_in in; - memcpy(&in, ai->ai_addr, sizeof(in)); - mreq.imr_multiaddr.s_addr = in.sin_addr.s_addr; - mreq.imr_interface.s_addr = htonl(INADDR_ANY); - - if(setsockopt(device_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq))) { - logger(LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno)); - closesocket(device_fd); - free(host); - return false; - } - -#ifdef IP_MULTICAST_LOOP - setsockopt(device_fd, IPPROTO_IP, IP_MULTICAST_LOOP, (const void *)&one, sizeof(one)); -#endif -#ifdef IP_MULTICAST_TTL - setsockopt(device_fd, IPPROTO_IP, IP_MULTICAST_TTL, (void *)&ttl, sizeof(ttl)); -#endif - } - break; -#endif - -#ifdef IPV6_JOIN_GROUP - - case AF_INET6: { - struct ipv6_mreq mreq; - struct sockaddr_in6 in6; - memcpy(&in6, ai->ai_addr, sizeof(in6)); - memcpy(&mreq.ipv6mr_multiaddr, &in6.sin6_addr, sizeof(mreq.ipv6mr_multiaddr)); - mreq.ipv6mr_interface = in6.sin6_scope_id; - - if(setsockopt(device_fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, (void *)&mreq, sizeof(mreq))) { - logger(LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno)); - closesocket(device_fd); - free(host); - return false; - } - -#ifdef IPV6_MULTICAST_LOOP - setsockopt(device_fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (const void *)&one, sizeof(one)); -#endif -#ifdef IPV6_MULTICAST_HOPS - setsockopt(device_fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (void *)&ttl, sizeof(ttl)); -#endif - } - break; -#endif - - default: - logger(LOG_ERR, "Multicast for address family %x unsupported", ai->ai_family); - closesocket(device_fd); - free(host); - return false; - } - - free(host); - logger(LOG_INFO, "%s is a %s", device, device_info); - - return true; -} - -static void close_device(void) { - close(device_fd); - - free(device); - free(iface); - - if(ai) { - freeaddrinfo(ai); - } -} - -static bool read_packet(vpn_packet_t *packet) { - int lenin; - - if((lenin = recv(device_fd, (void *)packet->data, MTU, 0)) <= 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, - device, strerror(errno)); - return false; - } - - if(!memcmp(&ignore_src, packet->data + 6, sizeof(ignore_src))) { - ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Ignoring loopback packet of %d bytes from %s", lenin, device_info); - packet->len = 0; - return true; - } - - packet->len = lenin; - - device_total_in += packet->len; - - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, - device_info); - - return true; -} - -static bool write_packet(vpn_packet_t *packet) { - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); - - if(sendto(device_fd, (void *)packet->data, packet->len, 0, ai->ai_addr, ai->ai_addrlen) < 0) { - logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, - strerror(errno)); - return false; - } - - device_total_out += packet->len; - - memcpy(&ignore_src, packet->data + 6, sizeof(ignore_src)); - - return true; -} - -static void dump_device_stats(void) { - logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); - logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); - logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); -} - -const devops_t multicast_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, - .dump_stats = dump_device_stats, -}; - -#if 0 - -static bool not_supported(void) { - logger(LOG_ERR, "Raw socket device not supported on this platform"); - return false; -} - -const devops_t multicast_devops = { - .setup = not_supported, - .close = NULL, - .read = NULL, - .write = NULL, - .dump_stats = NULL, -}; -#endif diff --git a/src/net.c b/src/net.c index 37ae116..f9020b3 100644 --- a/src/net.c +++ b/src/net.c @@ -1,9 +1,9 @@ /* net.c -- most of the network code Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2015 Guus Sliepen + 2000-2011 Guus Sliepen 2006 Scott Lamb - 2011 Loïc Grenié + 2011 Loïc Grenié This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,14 +22,11 @@ #include "system.h" -#include - #include "utils.h" -#include "avl_tree.h" +#include "splay_tree.h" #include "conf.h" #include "connection.h" #include "device.h" -#include "event.h" #include "graph.h" #include "logger.h" #include "meta.h" @@ -37,25 +34,17 @@ #include "netutl.h" #include "process.h" #include "protocol.h" -#include "route.h" #include "subnet.h" #include "xalloc.h" -bool do_purge = false; -volatile bool running = false; -#ifdef HAVE_PSELECT -bool graph_dump = false; -#endif - -time_t now = 0; int contradicting_add_edge = 0; int contradicting_del_edge = 0; static int sleeptime = 10; /* Purge edges and subnets of unreachable nodes. Use carefully. */ -static void purge(void) { - avl_node_t *nnode, *nnext, *enode, *enext, *snode, *snext; +void purge(void) { + splay_node_t *nnode, *nnext, *enode, *enext, *snode, *snext; node_t *n; edge_t *e; subnet_t *s; @@ -70,26 +59,21 @@ static void purge(void) { if(!n->status.reachable) { ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Purging node %s (%s)", n->name, - n->hostname); + n->hostname); for(snode = n->subnet_tree->head; snode; snode = snext) { snext = snode->next; s = snode->data; - send_del_subnet(everyone, s); - - if(!strictsubnets) { + send_del_subnet(broadcast, s); + if(!strictsubnets) subnet_del(n, s); - } } for(enode = n->edge_tree->head; enode; enode = enext) { enext = enode->next; e = enode->data; - - if(!tunnelserver) { - send_del_edge(everyone, e); - } - + if(!tunnelserver) + send_del_edge(broadcast, e); edge_del(e); } } @@ -106,96 +90,17 @@ static void purge(void) { enext = enode->next; e = enode->data; - if(e->to == n) { + if(e->to == n) break; - } } if(!enode && (!strictsubnets || !n->subnet_tree->head)) /* in strictsubnets mode do not delete nodes with subnets */ - { node_del(n); - } } } } -/* - put all file descriptors in an fd_set array - While we're at it, purge stuff that needs to be removed. -*/ -static int build_fdset(fd_set *readset, fd_set *writeset) { - avl_node_t *node, *next; - connection_t *c; - int i, max = 0; - - FD_ZERO(readset); - FD_ZERO(writeset); - - for(node = connection_tree->head; node; node = next) { - next = node->next; - c = node->data; - - if(c->status.remove) { - connection_del(c); - - if(!connection_tree->head) { - purge(); - } - } else { - FD_SET(c->socket, readset); - - if(c->outbuflen > 0 || c->status.connecting) { - FD_SET(c->socket, writeset); - } - - if(c->socket > max) { - max = c->socket; - } - } - } - - for(i = 0; i < listen_sockets; i++) { - FD_SET(listen_socket[i].tcp, readset); - - if(listen_socket[i].tcp > max) { - max = listen_socket[i].tcp; - } - - FD_SET(listen_socket[i].udp, readset); - - if(listen_socket[i].udp > max) { - max = listen_socket[i].udp; - } - } - - if(device_fd >= 0) { - FD_SET(device_fd, readset); - } - - if(device_fd > max) { - max = device_fd; - } - - return max; -} - -/* Put a misbehaving connection in the tarpit */ -void tarpit(int fd) { - static int pits[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; - static int next_pit = 0; - - if(pits[next_pit] != -1) { - closesocket(pits[next_pit]); - } - - pits[next_pit++] = fd; - - if(next_pit >= (int)(sizeof pits / sizeof pits[0])) { - next_pit = 0; - } -} - /* Terminate a connection: - Close the socket @@ -204,41 +109,19 @@ void tarpit(int fd) { - Deactivate the host */ void terminate_connection(connection_t *c, bool report) { - if(c->status.remove) { - return; - } - ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Closing connection with %s (%s)", - c->name, c->hostname); + c->name, c->hostname); - c->status.remove = true; c->status.active = false; - if(c->node) { + if(c->node) c->node->connection = NULL; - } - - if(c->socket) { - if(c->status.tarpit) { - tarpit(c->socket); - } else { - closesocket(c->socket); - } - } if(c->edge) { - if(!c->node) { - logger(LOG_ERR, "Connection to %s (%s) has an edge but node is NULL!", c->name, c->hostname); - // And that should never happen. - abort(); - } - - if(report && !tunnelserver) { - send_del_edge(everyone, c->edge); - } + if(report && !tunnelserver) + send_del_edge(broadcast, c->edge); edge_del(c->edge); - c->edge = NULL; /* Run MST and SSSP algorithms */ @@ -249,32 +132,20 @@ void terminate_connection(connection_t *c, bool report) { if(report && !c->node->status.reachable) { edge_t *e; e = lookup_edge(c->node, myself); - if(e) { - if(!tunnelserver) { - send_del_edge(everyone, e); - } - + if(!tunnelserver) + send_del_edge(broadcast, e); edge_del(e); } } } - free_connection_partially(c); - /* Check if this was our outgoing connection */ - if(c->outgoing) { - c->status.remove = false; - do_outgoing_connection(c); - } + if(c->outgoing) + retry_outgoing(c->outgoing); -#ifndef HAVE_MINGW - /* Clean up dead proxy processes */ - - while(waitpid(-1, NULL, WNOHANG) > 0); - -#endif + connection_del(c); } /* @@ -285,9 +156,10 @@ void terminate_connection(connection_t *c, bool report) { end does not reply in time, we consider them dead and close the connection. */ -static void check_dead_connections(void) { - avl_node_t *node, *next; +static void timeout_handler(int fd, short events, void *event) { + splay_node_t *node, *next; connection_t *c; + time_t now = time(NULL); for(node = connection_tree->head; node; node = next) { next = node->next; @@ -297,124 +169,182 @@ static void check_dead_connections(void) { if(c->status.active) { if(c->status.pinged) { ifdebug(CONNECTIONS) logger(LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds", - c->name, c->hostname, (long)(now - c->last_ping_time)); - c->status.timeout = true; + c->name, c->hostname, now - c->last_ping_time); terminate_connection(c, true); + continue; } else if(c->last_ping_time + pinginterval <= now) { send_ping(c); } } else { - if(c->status.remove) { - logger(LOG_WARNING, "Old connection_t for %s (%s) status %04x still lingering, deleting...", - c->name, c->hostname, bitfield_to_int(&c->status, sizeof(c->status))); - connection_del(c); - continue; - } - - ifdebug(CONNECTIONS) logger(LOG_WARNING, "Timeout from %s (%s) during authentication", - c->name, c->hostname); - if(c->status.connecting) { + ifdebug(CONNECTIONS) + logger(LOG_WARNING, "Timeout while connecting to %s (%s)", c->name, c->hostname); c->status.connecting = false; closesocket(c->socket); do_outgoing_connection(c); } else { - c->status.tarpit = true; + ifdebug(CONNECTIONS) logger(LOG_WARNING, "Timeout from %s (%s) during authentication", c->name, c->hostname); terminate_connection(c, false); - } - } - } - - if(c->outbuflen > 0 && c->last_flushed_time + pingtimeout <= now) { - if(c->status.active) { - ifdebug(CONNECTIONS) logger(LOG_INFO, - "%s (%s) could not flush for %ld seconds (%d bytes remaining)", - c->name, c->hostname, (long)(now - c->last_flushed_time), c->outbuflen); - c->status.timeout = true; - terminate_connection(c, true); - } - } - } -} - -/* - check all connections to see if anything - happened on their sockets -*/ -static void check_network_activity(fd_set *readset, fd_set *writeset) { - connection_t *c; - avl_node_t *node; - int result, i; - socklen_t len = sizeof(result); - vpn_packet_t packet; - static int errors = 0; - - /* check input from kernel */ - if(device_fd >= 0 && FD_ISSET(device_fd, readset)) { - if(devops.read(&packet)) { - if(packet.len) { - errors = 0; - packet.priority = 0; - route(myself, &packet); - } - } else { - usleep(errors * 50000); - errors++; - - if(errors > 10) { - logger(LOG_ERR, "Too many errors from %s, exiting!", device); - running = false; - } - } - } - - /* check meta connections */ - for(node = connection_tree->head; node; node = node->next) { - c = node->data; - - if(c->status.remove) { - continue; - } - - if(FD_ISSET(c->socket, writeset)) { - if(c->status.connecting) { - c->status.connecting = false; - getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&result, &len); - - if(!result) { - finish_connecting(c); - } else { - ifdebug(CONNECTIONS) logger(LOG_DEBUG, - "Error while connecting to %s (%s): %s", - c->name, c->hostname, sockstrerror(result)); - closesocket(c->socket); - do_outgoing_connection(c); continue; } } + } + } - if(!flush_meta(c)) { - terminate_connection(c, c->status.active); - continue; - } + if(contradicting_del_edge > 100 && contradicting_add_edge > 100) { + logger(LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime); + usleep(sleeptime * 1000000LL); + sleeptime *= 2; + if(sleeptime < 0) + sleeptime = 3600; + } else { + sleeptime /= 2; + if(sleeptime < 10) + sleeptime = 10; + } + + contradicting_add_edge = 0; + contradicting_del_edge = 0; + + event_add(event, &(struct timeval){pingtimeout, 0}); +} + +void handle_meta_connection_data(int fd, short events, void *data) { + connection_t *c = data; + int result; + socklen_t len = sizeof result; + + if(c->status.connecting) { + c->status.connecting = false; + + getsockopt(c->socket, SOL_SOCKET, SO_ERROR, &result, &len); + + if(!result) + finish_connecting(c); + else { + ifdebug(CONNECTIONS) logger(LOG_DEBUG, + "Error while connecting to %s (%s): %s", + c->name, c->hostname, sockstrerror(result)); + closesocket(c->socket); + do_outgoing_connection(c); + return; + } + } + + if (!receive_meta(c)) { + terminate_connection(c, c->status.active); + return; + } +} + +static void sigterm_handler(int signal, short events, void *data) { + logger(LOG_NOTICE, "Got %s signal", strsignal(signal)); + event_loopexit(NULL); +} + +static void sighup_handler(int signal, short events, void *data) { + logger(LOG_NOTICE, "Got %s signal", strsignal(signal)); + reopenlogger(); + reload_configuration(); +} + +static void sigalrm_handler(int signal, short events, void *data) { + logger(LOG_NOTICE, "Got %s signal", strsignal(signal)); + retry(); +} + +int reload_configuration(void) { + connection_t *c; + splay_node_t *node, *next; + char *fname; + struct stat s; + static time_t last_config_check = 0; + + /* Reread our own configuration file */ + + exit_configuration(&config_tree); + init_configuration(&config_tree); + + if(!read_server_config()) { + logger(LOG_ERR, "Unable to reread configuration file, exitting."); + event_loopexit(NULL); + return EINVAL; + } + + /* Close connections to hosts that have a changed or deleted host config file */ + + for(node = connection_tree->head; node; node = next) { + c = node->data; + next = node->next; + + if(c->outgoing) { + free(c->outgoing->name); + if(c->outgoing->ai) + freeaddrinfo(c->outgoing->ai); + free(c->outgoing); + c->outgoing = NULL; + } + + xasprintf(&fname, "%s/hosts/%s", confbase, c->name); + if(stat(fname, &s) || s.st_mtime > last_config_check) + terminate_connection(c, c->status.active); + free(fname); + } + + last_config_check = time(NULL); + + /* If StrictSubnet is set, expire deleted Subnets and read new ones in */ + + if(strictsubnets) { + subnet_t *subnet; + + + for(node = subnet_tree->head; node; node = node->next) { + subnet = node->data; + subnet->expires = 1; } - if(FD_ISSET(c->socket, readset)) { - if(!receive_meta(c)) { - c->status.tarpit = true; - terminate_connection(c, c->status.active); - continue; + load_all_subnets(); + + for(node = subnet_tree->head; node; node = next) { + next = node->next; + subnet = node->data; + if(subnet->expires == 1) { + send_del_subnet(broadcast, subnet); + if(subnet->owner->status.reachable) + subnet_update(subnet->owner, subnet, false); + subnet_del(subnet->owner, subnet); + } else if(subnet->expires == -1) { + subnet->expires = 0; + } else { + send_add_subnet(broadcast, subnet); + if(subnet->owner->status.reachable) + subnet_update(subnet->owner, subnet, true); } } } - for(i = 0; i < listen_sockets; i++) { - if(FD_ISSET(listen_socket[i].udp, readset)) { - handle_incoming_vpn_data(i); - } + /* Try to make outgoing connections */ + + try_outgoing_connections(); - if(FD_ISSET(listen_socket[i].tcp, readset)) { - handle_new_meta_connection(listen_socket[i].tcp); + return 0; +} + +void retry(void) { + connection_t *c; + splay_node_t *node; + + for(node = connection_tree->head; node; node = node->next) { + c = node->data; + + if(c->outgoing && !c->node) { + if(timeout_initialized(&c->outgoing->ev)) + event_del(&c->outgoing->ev); + if(c->status.connecting) + close(c->socket); + c->outgoing->timeout = 0; + do_outgoing_connection(c); } } } @@ -423,289 +353,40 @@ static void check_network_activity(fd_set *readset, fd_set *writeset) { this is where it all happens... */ int main_loop(void) { - fd_set readset, writeset; -#ifdef HAVE_PSELECT - struct timespec tv; - sigset_t omask, block_mask; - time_t next_event; -#else - struct timeval tv; + struct event timeout_event; + + timeout_set(&timeout_event, timeout_handler, &timeout_event); + event_add(&timeout_event, &(struct timeval){pingtimeout, 0}); + +#ifndef HAVE_MINGW + struct event sighup_event; + struct event sigterm_event; + struct event sigquit_event; + struct event sigalrm_event; + + signal_set(&sighup_event, SIGHUP, sighup_handler, NULL); + signal_add(&sighup_event, NULL); + signal_set(&sigterm_event, SIGTERM, sigterm_handler, NULL); + signal_add(&sigterm_event, NULL); + signal_set(&sigquit_event, SIGQUIT, sigterm_handler, NULL); + signal_add(&sigquit_event, NULL); + signal_set(&sigalrm_event, SIGALRM, sigalrm_handler, NULL); + signal_add(&sigalrm_event, NULL); #endif - int r, maxfd; - time_t last_ping_check, last_config_check, last_graph_dump; - event_t *event; - last_ping_check = now; - last_config_check = now; - last_graph_dump = now; - - srand(now); - -#ifdef HAVE_PSELECT - - if(lookup_config(config_tree, "GraphDumpFile")) { - graph_dump = true; + if(event_loop(0) < 0) { + logger(LOG_ERR, "Error while waiting for input: %s", strerror(errno)); + return 1; } - /* Block SIGHUP & SIGALRM */ - sigemptyset(&block_mask); - sigaddset(&block_mask, SIGHUP); - sigaddset(&block_mask, SIGALRM); - sigprocmask(SIG_BLOCK, &block_mask, &omask); +#ifndef HAVE_MINGW + signal_del(&sighup_event); + signal_del(&sigterm_event); + signal_del(&sigquit_event); + signal_del(&sigalrm_event); #endif - running = true; - - while(running) { -#ifdef HAVE_PSELECT - next_event = last_ping_check + pingtimeout; - - if(graph_dump && next_event > last_graph_dump + 60) { - next_event = last_graph_dump + 60; - } - - if((event = peek_next_event()) && next_event > event->time) { - next_event = event->time; - } - - if(next_event <= now) { - tv.tv_sec = 0; - } else { - tv.tv_sec = next_event - now; - } - - tv.tv_nsec = 0; -#else - tv.tv_sec = 1; - tv.tv_usec = 0; -#endif - - maxfd = build_fdset(&readset, &writeset); - -#ifdef HAVE_MINGW - LeaveCriticalSection(&mutex); -#endif -#ifdef HAVE_PSELECT - r = pselect(maxfd + 1, &readset, &writeset, NULL, &tv, &omask); -#else - r = select(maxfd + 1, &readset, &writeset, NULL, &tv); -#endif - now = time(NULL); -#ifdef HAVE_MINGW - EnterCriticalSection(&mutex); -#endif - - if(r < 0) { - if(!sockwouldblock(sockerrno)) { - logger(LOG_ERR, "Error while waiting for input: %s", sockstrerror(sockerrno)); - dump_connections(); - return 1; - } - } - - if(r > 0) { - check_network_activity(&readset, &writeset); - } - - if(do_purge) { - purge(); - do_purge = false; - } - - /* Let's check if everybody is still alive */ - - if(last_ping_check + pingtimeout <= now) { - check_dead_connections(); - last_ping_check = now; - - if(routing_mode == RMODE_SWITCH) { - age_subnets(); - } - - age_past_requests(); - - /* Should we regenerate our key? */ - - if(keyexpires <= now) { - avl_node_t *node; - node_t *n; - - ifdebug(STATUS) logger(LOG_INFO, "Expiring symmetric keys"); - - for(node = node_tree->head; node; node = node->next) { - n = node->data; - - if(n->inkey) { - free(n->inkey); - n->inkey = NULL; - } - } - - send_key_changed(); - keyexpires = now + keylifetime; - } - - /* Detect ADD_EDGE/DEL_EDGE storms that are caused when - * two tinc daemons with the same name are on the VPN. - * If so, sleep a while. If this happens multiple times - * in a row, sleep longer. */ - - if(contradicting_del_edge > 100 && contradicting_add_edge > 100) { - logger(LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime); - usleep(sleeptime * 1000000LL); - sleeptime *= 2; - - if(sleeptime < 0) { - sleeptime = 3600; - } - } else { - sleeptime /= 2; - - if(sleeptime < 10) { - sleeptime = 10; - } - } - - contradicting_add_edge = 0; - contradicting_del_edge = 0; - } - - if(sigalrm) { - avl_node_t *node; - logger(LOG_INFO, "Flushing event queue"); - expire_events(); - - for(node = connection_tree->head; node; node = node->next) { - connection_t *c = node->data; - - if(c->status.active) { - send_ping(c); - } - } - - sigalrm = false; - } - - while((event = get_expired_event())) { - event->handler(event->data); - free_event(event); - } - - if(sighup) { - connection_t *c; - avl_node_t *node, *next; - char *fname; - struct stat s; - - sighup = false; - - reopenlogger(); - - /* Reread our own configuration file */ - - exit_configuration(&config_tree); - init_configuration(&config_tree); - - if(!read_server_config()) { - logger(LOG_ERR, "Unable to reread configuration file, exitting."); - return 1; - } - - /* Cancel non-active outgoing connections */ - - for(node = connection_tree->head; node; node = next) { - next = node->next; - c = node->data; - - c->outgoing = NULL; - - if(c->status.connecting) { - terminate_connection(c, false); - connection_del(c); - } - } - - /* Wipe list of outgoing connections */ - - for(list_node_t *node = outgoing_list->head; node; node = node->next) { - outgoing_t *outgoing = node->data; - - if(outgoing->event) { - event_del(outgoing->event); - } - } - - list_delete_list(outgoing_list); - - /* Close connections to hosts that have a changed or deleted host config file */ - - for(node = connection_tree->head; node; node = node->next) { - c = node->data; - - xasprintf(&fname, "%s/hosts/%s", confbase, c->name); - - if(stat(fname, &s) || s.st_mtime > last_config_check) { - terminate_connection(c, c->status.active); - } - - free(fname); - } - - last_config_check = now; - - /* If StrictSubnet is set, expire deleted Subnets and read new ones in */ - - if(strictsubnets) { - subnet_t *subnet; - - for(node = subnet_tree->head; node; node = node->next) { - subnet = node->data; - subnet->expires = 1; - } - - load_all_subnets(); - - for(node = subnet_tree->head; node; node = next) { - next = node->next; - subnet = node->data; - - if(subnet->expires == 1) { - send_del_subnet(everyone, subnet); - - if(subnet->owner->status.reachable) { - subnet_update(subnet->owner, subnet, false); - } - - subnet_del(subnet->owner, subnet); - } else if(subnet->expires == -1) { - subnet->expires = 0; - } else { - send_add_subnet(everyone, subnet); - - if(subnet->owner->status.reachable) { - subnet_update(subnet->owner, subnet, true); - } - } - } - } - - /* Try to make outgoing connections */ - - try_outgoing_connections(); - } - - /* Dump graph if wanted every 60 seconds*/ - - if(last_graph_dump + 60 <= now) { - dump_graph(); - last_graph_dump = now; - } - } - -#ifdef HAVE_PSELECT - /* Restore SIGHUP & SIGALARM mask */ - sigprocmask(SIG_SETMASK, &omask, NULL); -#endif + event_del(&timeout_event); return 0; } diff --git a/src/net.h b/src/net.h index a9becb6..c511a5f 100644 --- a/src/net.h +++ b/src/net.h @@ -1,10 +1,7 @@ -#ifndef TINC_NET_H -#define TINC_NET_H - /* net.h -- header for net.c Copyright (C) 1998-2005 Ivo Timmermans - 2000-2015 Guus Sliepen + 2000-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,20 +18,23 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include +#ifndef __TINC_NET_H__ +#define __TINC_NET_H__ #include "ipv6.h" +#include "cipher.h" +#include "digest.h" #ifdef ENABLE_JUMBOGRAMS -#define MTU 9018 /* 9000 bytes payload + 14 bytes ethernet header + 4 bytes VLAN tag */ +#define MTU 9018 /* 9000 bytes payload + 14 bytes ethernet header + 4 bytes VLAN tag */ #else -#define MTU 1518 /* 1500 bytes payload + 14 bytes ethernet header + 4 bytes VLAN tag */ +#define MTU 1518 /* 1500 bytes payload + 14 bytes ethernet header + 4 bytes VLAN tag */ #endif -#define MAXSIZE (MTU + 4 + EVP_MAX_BLOCK_LENGTH + EVP_MAX_MD_SIZE + MTU/64 + 20) /* MTU + seqno + padding + HMAC + compressor overhead */ -#define MAXBUFSIZE ((MAXSIZE > 2048 ? MAXSIZE : 2048) + 128) /* Enough room for a request with a MAXSIZEd packet or a 8192 bits RSA key */ +#define MAXSIZE (MTU + 4 + CIPHER_MAX_BLOCK_SIZE + DIGEST_MAX_SIZE + MTU/64 + 20) /* MTU + seqno + padding + HMAC + compressor overhead */ +#define MAXBUFSIZE ((MAXSIZE > 2048 ? MAXSIZE : 2048) + 128) /* Enough room for a request with a MAXSIZEd packet or a 8192 bits RSA key */ -#define MAXSOCKETS 128 /* Overkill... */ +#define MAXSOCKETS 8 /* Probably overkill... */ typedef struct mac_t { uint8_t x[6]; @@ -48,7 +48,7 @@ typedef struct ipv6_t { uint16_t x[8]; } ipv6_t; -typedef uint16_t length_t; +typedef short length_t; #define AF_UNKNOWN 255 @@ -77,17 +77,18 @@ typedef union sockaddr_t { #endif typedef struct vpn_packet_t { - length_t len; /* the actual number of bytes in the `data' field */ - int priority; /* priority or TOS */ - uint32_t seqno; /* 32 bits sequence number (network byte order of course) */ + length_t len; /* the actual number of bytes in the `data' field */ + int priority; /* priority or TOS */ + uint32_t seqno; /* 32 bits sequence number (network byte order of course) */ uint8_t data[MAXSIZE]; } vpn_packet_t; typedef struct listen_socket_t { + struct event ev_tcp; + struct event ev_udp; int tcp; int udp; sockaddr_t sa; - int priority; } listen_socket_t; #include "conf.h" @@ -99,7 +100,7 @@ typedef struct outgoing_t { struct config_t *cfg; struct addrinfo *ai; struct addrinfo *aip; - struct event *event; + struct event ev; } outgoing_t; extern list_t *outgoing_list; @@ -108,49 +109,49 @@ extern int maxoutbufsize; extern int seconds_till_retry; extern int addressfamily; extern unsigned replaywin; -extern bool localdiscovery; extern listen_socket_t listen_socket[MAXSOCKETS]; extern int listen_sockets; -extern int keyexpires; extern int keylifetime; extern int udp_rcvbuf; extern int udp_sndbuf; extern bool do_prune; -extern bool do_purge; extern char *myport; -extern time_t now; extern int contradicting_add_edge; extern int contradicting_del_edge; -extern volatile bool running; - /* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */ #include "connection.h" #include "node.h" -extern void retry_outgoing(outgoing_t *outgoing); -extern void handle_incoming_vpn_data(int sock); -extern void finish_connecting(struct connection_t *c); -extern void do_outgoing_connection(struct connection_t *c); -extern bool handle_new_meta_connection(int sock); -extern int setup_listen_socket(const sockaddr_t *sa); -extern int setup_vpn_in_socket(const sockaddr_t *sa); -extern void send_packet(const struct node_t *n, vpn_packet_t *packet); -extern void receive_tcppacket(struct connection_t *c, const char *buffer, length_t len); -extern void broadcast_packet(const struct node_t *, vpn_packet_t *packet); -extern char *get_name(void); +extern void retry_outgoing(outgoing_t *); +extern void handle_incoming_vpn_data(int, short, void *); +extern void finish_connecting(struct connection_t *); +extern bool do_outgoing_connection(struct connection_t *); +extern void handle_new_meta_connection(int, short, void *); +extern int setup_listen_socket(const sockaddr_t *); +extern int setup_vpn_in_socket(const sockaddr_t *); +extern void send_packet(struct node_t *, vpn_packet_t *); +extern void receive_tcppacket(struct connection_t *, const char *, int); +extern void broadcast_packet(const struct node_t *, vpn_packet_t *); extern bool setup_network(void); -extern void setup_outgoing_connection(struct outgoing_t *outgoing); +extern void setup_outgoing_connection(struct outgoing_t *); extern void try_outgoing_connections(void); extern void close_network_connections(void); extern int main_loop(void); -extern void terminate_connection(struct connection_t *c, bool report); -extern void flush_queue(struct node_t *n); -extern bool read_rsa_public_key(struct connection_t *c); -extern void send_mtu_probe(struct node_t *n); +extern void terminate_connection(struct connection_t *, bool); +extern void flush_queue(struct node_t *); +extern bool node_read_ecdsa_public_key(struct node_t *); +extern bool read_ecdsa_public_key(struct connection_t *); +extern bool read_rsa_public_key(struct connection_t *); +extern void send_mtu_probe(struct node_t *); +extern void handle_device_data(int, short, void *); +extern void handle_meta_connection_data(int, short, void *); +extern void regenerate_key(void); +extern void purge(void); +extern void retry(void); +extern int reload_configuration(void); extern void load_all_subnets(void); -extern void tarpit(int fd); #ifndef HAVE_MINGW #define closesocket(s) close(s) @@ -158,4 +159,4 @@ extern void tarpit(int fd); extern CRITICAL_SECTION mutex; #endif -#endif +#endif /* __TINC_NET_H__ */ diff --git a/src/net_packet.c b/src/net_packet.c index 938b3b6..3627f31 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -1,7 +1,7 @@ /* net_packet.c -- Handles in- and outgoing VPN packets Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2016 Guus Sliepen + 2000-2011 Guus Sliepen 2010 Timothy Redaelli 2010 Brandon Black @@ -36,12 +36,14 @@ #include LZO1X_H #endif -#include "avl_tree.h" +#include "splay_tree.h" +#include "cipher.h" #include "conf.h" #include "connection.h" +#include "crypto.h" +#include "digest.h" #include "device.h" #include "ethernet.h" -#include "event.h" #include "graph.h" #include "logger.h" #include "net.h" @@ -53,7 +55,6 @@ #include "xalloc.h" int keylifetime = 0; -int keyexpires = 0; #ifdef HAVE_LZO static char lzo_wrkmem[LZO1X_999_MEM_COMPRESS > LZO1X_1_MEM_COMPRESS ? LZO1X_999_MEM_COMPRESS : LZO1X_1_MEM_COMPRESS]; #endif @@ -61,33 +62,21 @@ static char lzo_wrkmem[LZO1X_999_MEM_COMPRESS > LZO1X_1_MEM_COMPRESS ? LZO1X_999 static void send_udppacket(node_t *, vpn_packet_t *); unsigned replaywin = 16; -bool localdiscovery = false; #define MAX_SEQNO 1073741824 -/* mtuprobes == 1..30: initial discovery, send bursts with 1 second interval - mtuprobes == 31: sleep pinginterval seconds - mtuprobes == 32: send 1 burst, sleep pingtimeout second - mtuprobes == 33: no response from other side, restart PMTU discovery process +// mtuprobes == 1..30: initial discovery, send bursts with 1 second interval +// mtuprobes == 31: sleep pinginterval seconds +// mtuprobes == 32: send 1 burst, sleep pingtimeout second +// mtuprobes == 33: no response from other side, restart PMTU discovery process - Probes are sent in batches of at least three, with random sizes between the - lower and upper boundaries for the MTU thus far discovered. - - After the initial discovery, a fourth packet is added to each batch with a - size larger than the currently known PMTU, to test if the PMTU has increased. - - In case local discovery is enabled, another packet is added to each batch, - which will be broadcast to the local network. - -*/ - -void send_mtu_probe(node_t *n) { +static void send_mtu_probe_handler(int fd, short events, void *data) { + node_t *n = data; vpn_packet_t packet; int len, i; int timeout = 1; - + n->mtuprobes++; - n->mtuevent = NULL; if(!n->status.reachable || !n->status.validkey) { ifdebug(TRAFFIC) logger(LOG_INFO, "Trying to send MTU probe to unreachable or rekeying node %s (%s)", n->name, n->hostname); @@ -114,12 +103,10 @@ void send_mtu_probe(node_t *n) { } if(n->mtuprobes == 30 || (n->mtuprobes < 30 && n->minmtu >= n->maxmtu)) { - if(n->minmtu > n->maxmtu) { + if(n->minmtu > n->maxmtu) n->minmtu = n->maxmtu; - } else { + else n->maxmtu = n->minmtu; - } - n->mtu = n->minmtu; ifdebug(TRAFFIC) logger(LOG_INFO, "Fixing MTU of %s (%s) to %d after %d probes", n->name, n->hostname, n->mtu, n->mtuprobes); n->mtuprobes = 31; @@ -132,32 +119,19 @@ void send_mtu_probe(node_t *n) { timeout = pingtimeout; } - for(i = 0; i < 4 + localdiscovery; i++) { - if(i == 0) { - if(n->mtuprobes < 30 || n->maxmtu + 8 >= MTU) { - continue; - } - - len = n->maxmtu + 8; - } else if(n->maxmtu <= n->minmtu) { + for(i = 0; i < 3; i++) { + if(n->maxmtu <= n->minmtu) len = n->maxmtu; - } else { + else len = n->minmtu + 1 + rand() % (n->maxmtu - n->minmtu); - } - if(len < 64) { + if(len < 64) len = 64; - } - + memset(packet.data, 0, 14); - RAND_bytes(packet.data + 14, len - 14); + randomize(packet.data + 14, len - 14); packet.len = len; - - if(i >= 4 && n->mtuprobes <= 10) { - packet.priority = -1; - } else { - packet.priority = 0; - } + packet.priority = 0; ifdebug(TRAFFIC) logger(LOG_INFO, "Sending MTU probe length %d to %s (%s)", len, n->name, n->hostname); @@ -165,14 +139,16 @@ void send_mtu_probe(node_t *n) { } end: - n->mtuevent = new_event(); - n->mtuevent->handler = (event_handler_t)send_mtu_probe; - n->mtuevent->data = n; - n->mtuevent->time = now + timeout; - event_add(n->mtuevent); + event_add(&n->mtuevent, &(struct timeval){timeout, 0}); } -void mtu_probe_h(node_t *n, vpn_packet_t *packet, length_t len) { +void send_mtu_probe(node_t *n) { + if(!timeout_initialized(&n->mtuevent)) + timeout_set(&n->mtuevent, send_mtu_probe_handler, n); + send_mtu_probe_handler(0, 0, n); +} + +static void mtu_probe_h(node_t *n, vpn_packet_t *packet, length_t len) { ifdebug(TRAFFIC) logger(LOG_INFO, "Got MTU probe length %d from %s (%s)", packet->len, n->name, n->hostname); if(!packet->data[0]) { @@ -180,27 +156,16 @@ void mtu_probe_h(node_t *n, vpn_packet_t *packet, length_t len) { send_udppacket(n, packet); } else { if(n->mtuprobes > 30) { - if(len == n->maxmtu + 8) { - ifdebug(TRAFFIC) logger(LOG_INFO, "Increase in PMTU to %s (%s) detected, restarting PMTU discovery", n->name, n->hostname); - n->maxmtu = MTU; - n->mtuprobes = 10; - return; - } - - if(n->minmtu) { + if(n->minmtu) n->mtuprobes = 30; - } else { + else n->mtuprobes = 1; - } } - if(len > n->maxmtu) { + if(len > n->maxmtu) len = n->maxmtu; - } - - if(n->minmtu < len) { + if(n->minmtu < len) n->minmtu = len; - } } } @@ -214,28 +179,27 @@ static length_t compress_packet(uint8_t *dest, const uint8_t *source, length_t l lzo1x_1_compress(source, len, dest, &lzolen, lzo_wrkmem); return lzolen; #else - return 0; + return -1; #endif } else if(level < 10) { #ifdef HAVE_ZLIB unsigned long destlen = MAXSIZE; - - if(compress2(dest, &destlen, source, len, level) == Z_OK) { + if(compress2(dest, &destlen, source, len, level) == Z_OK) return destlen; - } else + else #endif - return 0; + return -1; } else { #ifdef HAVE_LZO lzo_uint lzolen = MAXSIZE; lzo1x_999_compress(source, len, dest, &lzolen, lzo_wrkmem); return lzolen; #else - return 0; + return -1; #endif } - - return 0; + + return -1; } static length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t len, int level) { @@ -245,25 +209,20 @@ static length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t } else if(level > 9) { #ifdef HAVE_LZO lzo_uint lzolen = MAXSIZE; - - if(lzo1x_decompress_safe(source, len, dest, &lzolen, NULL) == LZO_E_OK) { + if(lzo1x_decompress_safe(source, len, dest, &lzolen, NULL) == LZO_E_OK) return lzolen; - } else + else #endif - return 0; + return -1; } - #ifdef HAVE_ZLIB else { unsigned long destlen = MAXSIZE; - - if(uncompress(dest, &destlen, source, len) == Z_OK) { + if(uncompress(dest, &destlen, source, len) == Z_OK) return destlen; - } else { - return 0; - } + else + return -1; } - #endif return -1; @@ -273,104 +232,91 @@ static length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t static void receive_packet(node_t *n, vpn_packet_t *packet) { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Received packet of %d bytes from %s (%s)", - packet->len, n->name, n->hostname); + packet->len, n->name, n->hostname); + + n->in_packets++; + n->in_bytes += packet->len; route(n, packet); } -static bool try_mac(const node_t *n, const vpn_packet_t *inpkt) { - unsigned char hmac[EVP_MAX_MD_SIZE]; - - if(!n->indigest || !n->inmaclength || !n->inkey || inpkt->len < sizeof(inpkt->seqno) + n->inmaclength) { +static bool try_mac(node_t *n, const vpn_packet_t *inpkt) { + if(!digest_active(&n->indigest) || inpkt->len < sizeof inpkt->seqno + digest_length(&n->indigest)) return false; - } - HMAC(n->indigest, n->inkey, n->inkeylength, (unsigned char *) &inpkt->seqno, inpkt->len - n->inmaclength, (unsigned char *)hmac, NULL); - - return !memcmp_constant_time(hmac, (char *) &inpkt->seqno + inpkt->len - n->inmaclength, n->inmaclength); + return digest_verify(&n->indigest, &inpkt->seqno, inpkt->len - n->indigest.maclength, (const char *)&inpkt->seqno + inpkt->len - n->indigest.maclength); } static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) { vpn_packet_t pkt1, pkt2; vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 }; int nextpkt = 0; - vpn_packet_t *outpkt; - int outlen, outpad; - unsigned char hmac[EVP_MAX_MD_SIZE]; + vpn_packet_t *outpkt = pkt[0]; + size_t outlen; - if(!n->inkey) { + if(!cipher_active(&n->incipher)) { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Got packet from %s (%s) but he hasn't got our key yet", - n->name, n->hostname); + n->name, n->hostname); return; } /* Check packet length */ - if(inpkt->len < sizeof(inpkt->seqno) + n->inmaclength) { + if(inpkt->len < sizeof inpkt->seqno + digest_length(&n->indigest)) { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Got too short packet from %s (%s)", - n->name, n->hostname); + n->name, n->hostname); return; } /* Check the message authentication code */ - if(n->indigest && n->inmaclength) { - inpkt->len -= n->inmaclength; - HMAC(n->indigest, n->inkey, n->inkeylength, - (unsigned char *) &inpkt->seqno, inpkt->len, (unsigned char *)hmac, NULL); - - if(memcmp_constant_time(hmac, (char *) &inpkt->seqno + inpkt->len, n->inmaclength)) { - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Got unauthenticated packet from %s (%s)", - n->name, n->hostname); + if(digest_active(&n->indigest)) { + inpkt->len -= n->indigest.maclength; + if(!digest_verify(&n->indigest, &inpkt->seqno, inpkt->len, (const char *)&inpkt->seqno + inpkt->len)) { + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Got unauthenticated packet from %s (%s)", n->name, n->hostname); return; } } - /* Decrypt the packet */ - if(n->incipher) { + if(cipher_active(&n->incipher)) { outpkt = pkt[nextpkt++]; + outlen = MAXSIZE; - if(!EVP_DecryptInit_ex(n->inctx, NULL, NULL, NULL, NULL) - || !EVP_DecryptUpdate(n->inctx, (unsigned char *) &outpkt->seqno, &outlen, - (unsigned char *) &inpkt->seqno, inpkt->len) - || !EVP_DecryptFinal_ex(n->inctx, (unsigned char *) &outpkt->seqno + outlen, &outpad)) { - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Error decrypting packet from %s (%s): %s", - n->name, n->hostname, ERR_error_string(ERR_get_error(), NULL)); + if(!cipher_decrypt(&n->incipher, &inpkt->seqno, inpkt->len, &outpkt->seqno, &outlen, true)) { + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Error decrypting packet from %s (%s)", n->name, n->hostname); return; } - - outpkt->len = outlen + outpad; + + outpkt->len = outlen; inpkt = outpkt; } /* Check the sequence number */ - inpkt->len -= sizeof(inpkt->seqno); + inpkt->len -= sizeof inpkt->seqno; inpkt->seqno = ntohl(inpkt->seqno); if(replaywin) { if(inpkt->seqno != n->received_seqno + 1) { if(inpkt->seqno >= n->received_seqno + replaywin * 8) { if(n->farfuture++ < replaywin >> 2) { - ifdebug(TRAFFIC) logger(LOG_WARNING, "Packet from %s (%s) is %d seqs in the future, dropped (%u)", - n->name, n->hostname, inpkt->seqno - n->received_seqno - 1, n->farfuture); + logger(LOG_WARNING, "Packet from %s (%s) is %d seqs in the future, dropped (%u)", + n->name, n->hostname, inpkt->seqno - n->received_seqno - 1, n->farfuture); return; } - - ifdebug(TRAFFIC) logger(LOG_WARNING, "Lost %d packets from %s (%s)", - inpkt->seqno - n->received_seqno - 1, n->name, n->hostname); + logger(LOG_WARNING, "Lost %d packets from %s (%s)", + inpkt->seqno - n->received_seqno - 1, n->name, n->hostname); memset(n->late, 0, replaywin); - } else if(inpkt->seqno <= n->received_seqno) { + } else if (inpkt->seqno <= n->received_seqno) { if((n->received_seqno >= replaywin * 8 && inpkt->seqno <= n->received_seqno - replaywin * 8) || !(n->late[(inpkt->seqno / 8) % replaywin] & (1 << inpkt->seqno % 8))) { - ifdebug(TRAFFIC) logger(LOG_WARNING, "Got late or replayed packet from %s (%s), seqno %d, last received %d", - n->name, n->hostname, inpkt->seqno, n->received_seqno); + logger(LOG_WARNING, "Got late or replayed packet from %s (%s), seqno %d, last received %d", + n->name, n->hostname, inpkt->seqno, n->received_seqno); return; } } else { - for(uint32_t i = n->received_seqno + 1; i < inpkt->seqno; i++) { + for(int i = n->received_seqno + 1; i < inpkt->seqno; i++) n->late[(i / 8) % replaywin] |= 1 << i % 8; - } } } @@ -378,13 +324,11 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) { n->late[(inpkt->seqno / 8) % replaywin] &= ~(1 << inpkt->seqno % 8); } - if(inpkt->seqno > n->received_seqno) { + if(inpkt->seqno > n->received_seqno) n->received_seqno = inpkt->seqno; - } - - if(n->received_seqno > MAX_SEQNO) { - keyexpires = 0; - } + + if(n->received_seqno > MAX_SEQNO) + regenerate_key(); /* Decompress the packet */ @@ -393,41 +337,33 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) { if(n->incompression) { outpkt = pkt[nextpkt++]; - if(!(outpkt->len = uncompress_packet(outpkt->data, inpkt->data, inpkt->len, n->incompression))) { + if((outpkt->len = uncompress_packet(outpkt->data, inpkt->data, inpkt->len, n->incompression)) < 0) { ifdebug(TRAFFIC) logger(LOG_ERR, "Error while uncompressing packet from %s (%s)", - n->name, n->hostname); + n->name, n->hostname); return; } inpkt = outpkt; - origlen -= MTU / 64 + 20; + origlen -= MTU/64 + 20; } inpkt->priority = 0; - if(!inpkt->data[12] && !inpkt->data[13]) { + if(!inpkt->data[12] && !inpkt->data[13]) mtu_probe_h(n, inpkt, origlen); - } else { + else receive_packet(n, inpkt); - } } -void receive_tcppacket(connection_t *c, const char *buffer, length_t len) { +void receive_tcppacket(connection_t *c, const char *buffer, int len) { vpn_packet_t outpkt; - if(len > sizeof(outpkt.data)) { - return; - } - outpkt.len = len; - - if(c->options & OPTION_TCPONLY) { + if(c->options & OPTION_TCPONLY) outpkt.priority = 0; - } else { + else outpkt.priority = -1; - } - memcpy(outpkt.data, buffer, len); receive_packet(c->node, &outpkt); @@ -439,9 +375,13 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { vpn_packet_t *inpkt = origpkt; int nextpkt = 0; vpn_packet_t *outpkt; - int origlen; - int outlen, outpad; - int origpriority; + int origlen = origpkt->len; + size_t outlen; +#if defined(SOL_IP) && defined(IP_TOS) + static int priority = 0; + int origpriority = origpkt->priority; +#endif + int sock; if(!n->status.reachable) { ifdebug(TRAFFIC) logger(LOG_INFO, "Trying to send UDP packet to unreachable node %s (%s)", n->name, n->hostname); @@ -451,9 +391,11 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { /* Make sure we have a valid key */ if(!n->status.validkey) { + time_t now = time(NULL); + ifdebug(TRAFFIC) logger(LOG_INFO, - "No valid key known yet for %s (%s), forwarding via TCP", - n->name, n->hostname); + "No valid key known yet for %s (%s), forwarding via TCP", + n->name, n->hostname); if(n->last_req_key + 10 <= now) { send_req_key(n); @@ -467,29 +409,25 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { if(n->options & OPTION_PMTU_DISCOVERY && inpkt->len > n->minmtu && (inpkt->data[12] | inpkt->data[13])) { ifdebug(TRAFFIC) logger(LOG_INFO, - "Packet for %s (%s) larger than minimum MTU, forwarding via %s", - n->name, n->hostname, n != n->nexthop ? n->nexthop->name : "TCP"); + "Packet for %s (%s) larger than minimum MTU, forwarding via %s", + n->name, n->hostname, n != n->nexthop ? n->nexthop->name : "TCP"); - if(n != n->nexthop) { + if(n != n->nexthop) send_packet(n->nexthop, origpkt); - } else { + else send_tcppacket(n->nexthop->connection, origpkt); - } return; } - origlen = inpkt->len; - origpriority = inpkt->priority; - /* Compress the packet */ if(n->outcompression) { outpkt = pkt[nextpkt++]; - if(!(outpkt->len = compress_packet(outpkt->data, inpkt->data, inpkt->len, n->outcompression))) { + if((outpkt->len = compress_packet(outpkt->data, inpkt->data, inpkt->len, n->outcompression)) < 0) { ifdebug(TRAFFIC) logger(LOG_ERR, "Error while compressing packet to %s (%s)", - n->name, n->hostname); + n->name, n->hostname); return; } @@ -499,127 +437,59 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { /* Add sequence number */ inpkt->seqno = htonl(++(n->sent_seqno)); - inpkt->len += sizeof(inpkt->seqno); + inpkt->len += sizeof inpkt->seqno; /* Encrypt the packet */ - if(n->outcipher) { + if(cipher_active(&n->outcipher)) { outpkt = pkt[nextpkt++]; + outlen = MAXSIZE; - if(!EVP_EncryptInit_ex(n->outctx, NULL, NULL, NULL, NULL) - || !EVP_EncryptUpdate(n->outctx, (unsigned char *) &outpkt->seqno, &outlen, - (unsigned char *) &inpkt->seqno, inpkt->len) - || !EVP_EncryptFinal_ex(n->outctx, (unsigned char *) &outpkt->seqno + outlen, &outpad)) { - ifdebug(TRAFFIC) logger(LOG_ERR, "Error while encrypting packet to %s (%s): %s", - n->name, n->hostname, ERR_error_string(ERR_get_error(), NULL)); + if(!cipher_encrypt(&n->outcipher, &inpkt->seqno, inpkt->len, &outpkt->seqno, &outlen, true)) { + ifdebug(TRAFFIC) logger(LOG_ERR, "Error while encrypting packet to %s (%s)", n->name, n->hostname); goto end; } - outpkt->len = outlen + outpad; + outpkt->len = outlen; inpkt = outpkt; } /* Add the message authentication code */ - if(n->outdigest && n->outmaclength) { - HMAC(n->outdigest, n->outkey, n->outkeylength, (unsigned char *) &inpkt->seqno, - inpkt->len, (unsigned char *) &inpkt->seqno + inpkt->len, NULL); - inpkt->len += n->outmaclength; + if(digest_active(&n->outdigest)) { + digest_create(&n->outdigest, &inpkt->seqno, inpkt->len, (char *)&inpkt->seqno + inpkt->len); + inpkt->len += digest_length(&n->outdigest); } /* Determine which socket we have to use */ - if(n->address.sa.sa_family != listen_socket[n->sock].sa.sa.sa_family) { - for(int sock = 0; sock < listen_sockets; sock++) { - if(n->address.sa.sa_family == listen_socket[sock].sa.sa.sa_family) { - n->sock = sock; - break; - } - } - } + for(sock = 0; sock < listen_sockets; sock++) + if(n->address.sa.sa_family == listen_socket[sock].sa.sa.sa_family) + break; + + if(sock >= listen_sockets) + sock = 0; /* If none is available, just use the first and hope for the best. */ /* Send the packet */ - struct sockaddr *sa; - socklen_t sl; - int sock; - sockaddr_t broadcast; - - /* Overloaded use of priority field: -1 means local broadcast */ - - if(origpriority == -1 && n->prevedge) { - sock = rand() % listen_sockets; - memset(&broadcast, 0, sizeof(broadcast)); - - if(listen_socket[sock].sa.sa.sa_family == AF_INET6) { - broadcast.in6.sin6_family = AF_INET6; - broadcast.in6.sin6_addr.s6_addr[0x0] = 0xff; - broadcast.in6.sin6_addr.s6_addr[0x1] = 0x02; - broadcast.in6.sin6_addr.s6_addr[0xf] = 0x01; - broadcast.in6.sin6_port = n->prevedge->address.in.sin_port; - broadcast.in6.sin6_scope_id = listen_socket[sock].sa.in6.sin6_scope_id; - } else { - broadcast.in.sin_family = AF_INET; - broadcast.in.sin_addr.s_addr = -1; - broadcast.in.sin_port = n->prevedge->address.in.sin_port; - } - - sa = &broadcast.sa; - sl = SALEN(broadcast.sa); - } else { - if(origpriority == -1) { - origpriority = 0; - } - - sa = &(n->address.sa); - sl = SALEN(n->address.sa); - sock = n->sock; +#if defined(SOL_IP) && defined(IP_TOS) + if(priorityinheritance && origpriority != priority + && listen_socket[sock].sa.sa.sa_family == AF_INET) { + priority = origpriority; + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Setting outgoing packet priority to %d", priority); + if(setsockopt(listen_socket[sock].udp, SOL_IP, IP_TOS, &priority, sizeof priority)) /* SO_PRIORITY doesn't seem to work */ + logger(LOG_ERR, "System call `%s' failed: %s", "setsockopt", strerror(errno)); } - - if(priorityinheritance && origpriority != listen_socket[n->sock].priority) { - listen_socket[n->sock].priority = origpriority; - - switch(listen_socket[n->sock].sa.sa.sa_family) { -#if defined(IP_TOS) - - case AF_INET: - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Setting IPv4 outgoing packet priority to %d", origpriority); - - if(setsockopt(listen_socket[n->sock].udp, IPPROTO_IP, IP_TOS, (void *)&origpriority, sizeof(origpriority))) { /* SO_PRIORITY doesn't seem to work */ - logger(LOG_ERR, "System call `%s' failed: %s", "setsockopt", strerror(errno)); - } - - break; -#endif -#if defined(IPV6_TCLASS) - - case AF_INET6: - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Setting IPv6 outgoing packet priority to %d", origpriority); - - if(setsockopt(listen_socket[n->sock].udp, IPPROTO_IPV6, IPV6_TCLASS, (void *)&origpriority, sizeof(origpriority))) { - logger(LOG_ERR, "System call `%s' failed: %s", "setsockopt", strerror(errno)); - } - - break; #endif - default: - break; - } - } - - if(sendto(listen_socket[sock].udp, (char *) &inpkt->seqno, inpkt->len, 0, sa, sl) < 0 && !sockwouldblock(sockerrno)) { + if(sendto(listen_socket[sock].udp, (char *) &inpkt->seqno, inpkt->len, 0, &(n->address.sa), SALEN(n->address.sa)) < 0 && !sockwouldblock(sockerrno)) { if(sockmsgsize(sockerrno)) { - if(n->maxmtu >= origlen) { + if(n->maxmtu >= origlen) n->maxmtu = origlen - 1; - } - - if(n->mtu >= origlen) { + if(n->mtu >= origlen) n->mtu = origlen - 1; - } - } else { - ifdebug(TRAFFIC) logger(LOG_WARNING, "Error sending packet to %s (%s): %s", n->name, n->hostname, sockstrerror(sockerrno)); - } + } else + logger(LOG_ERR, "Error sending packet to %s (%s): %s", n->name, n->hostname, sockstrerror(sockerrno)); } end: @@ -629,170 +499,154 @@ end: /* send a packet to the given vpn ip. */ -void send_packet(const node_t *n, vpn_packet_t *packet) { +void send_packet(node_t *n, vpn_packet_t *packet) { node_t *via; if(n == myself) { - if(overwrite_mac) { - memcpy(packet->data, mymac.x, ETH_ALEN); - } - - devops.write(packet); + if(overwrite_mac) + memcpy(packet->data, mymac.x, ETH_ALEN); + n->out_packets++; + n->out_bytes += packet->len; + write_packet(packet); return; } ifdebug(TRAFFIC) logger(LOG_ERR, "Sending packet of %d bytes to %s (%s)", - packet->len, n->name, n->hostname); + packet->len, n->name, n->hostname); if(!n->status.reachable) { ifdebug(TRAFFIC) logger(LOG_INFO, "Node %s (%s) is not reachable", - n->name, n->hostname); + n->name, n->hostname); return; } + n->out_packets++; + n->out_bytes += packet->len; + via = (packet->priority == -1 || n->via == myself) ? n->nexthop : n->via; if(via != n) ifdebug(TRAFFIC) logger(LOG_INFO, "Sending packet to %s via %s (%s)", - n->name, via->name, n->via->hostname); + n->name, via->name, n->via->hostname); if(packet->priority == -1 || ((myself->options | via->options) & OPTION_TCPONLY)) { - if(!send_tcppacket(via->connection, packet)) { + if(!send_tcppacket(via->connection, packet)) terminate_connection(via->connection, true); - } - } else { + } else send_udppacket(via, packet); - } } /* Broadcast a packet using the minimum spanning tree */ void broadcast_packet(const node_t *from, vpn_packet_t *packet) { - avl_node_t *node; + splay_node_t *node; connection_t *c; - node_t *n; - - // Always give ourself a copy of the packet. - if(from != myself) { - send_packet(myself, packet); - } - - // In TunnelServer mode, do not forward broadcast packets. - // The MST might not be valid and create loops. - if(tunnelserver || broadcast_mode == BMODE_NONE) { - return; - } ifdebug(TRAFFIC) logger(LOG_INFO, "Broadcasting packet of %d bytes from %s (%s)", - packet->len, from->name, from->hostname); + packet->len, from->name, from->hostname); - switch(broadcast_mode) { - // In MST mode, broadcast packets travel via the Minimum Spanning Tree. - // This guarantees all nodes receive the broadcast packet, and - // usually distributes the sending of broadcast packets over all nodes. - case BMODE_MST: - for(node = connection_tree->head; node; node = node->next) { - c = node->data; + if(from != myself) { + send_packet(myself, packet); - if(c->status.active && c->status.mst && c != from->nexthop->connection) { - send_packet(c->node, packet); - } - } + // In TunnelServer mode, do not forward broadcast packets. + // The MST might not be valid and create loops. + if(tunnelserver) + return; + } - break; + for(node = connection_tree->head; node; node = node->next) { + c = node->data; - // In direct mode, we send copies to each node we know of. - // However, this only reaches nodes that can be reached in a single hop. - // We don't have enough information to forward broadcast packets in this case. - case BMODE_DIRECT: - if(from != myself) { - break; - } - - for(node = node_udp_tree->head; node; node = node->next) { - n = node->data; - - if(n->status.reachable && n != myself && ((n->via == myself && n->nexthop == n) || n->via == n)) { - send_packet(n, packet); - } - } - - break; - - default: - break; + if(c->status.active && c->status.mst && c != from->nexthop->connection) + send_packet(c->node, packet); } } static node_t *try_harder(const sockaddr_t *from, const vpn_packet_t *pkt) { - avl_node_t *node; + splay_node_t *node; edge_t *e; node_t *n = NULL; + bool hard = false; static time_t last_hard_try = 0; + time_t now = time(NULL); + + if(last_hard_try == now) + return NULL; + else + last_hard_try = now; for(node = edge_weight_tree->head; node; node = node->next) { e = node->data; - if(e->to == myself) { + if(e->to == myself) continue; + + if(sockaddrcmp_noport(from, &e->address)) { + if(last_hard_try == now) + continue; + hard = true; } - if(last_hard_try == now && sockaddrcmp_noport(from, &e->address)) { + if(!try_mac(e->to, pkt)) continue; - } - - if(!try_mac(e->to, pkt)) { - continue; - } n = e->to; break; } - last_hard_try = now; + if(hard) + last_hard_try = now; + return n; } -void handle_incoming_vpn_data(int sock) { +void handle_incoming_vpn_data(int sock, short events, void *data) { vpn_packet_t pkt; char *hostname; sockaddr_t from; - socklen_t fromlen = sizeof(from); + socklen_t fromlen = sizeof from; node_t *n; + int len; - ssize_t len = recvfrom(listen_socket[sock].udp, (char *) &pkt.seqno, MAXSIZE, 0, &from.sa, &fromlen); + len = recvfrom(sock, (char *) &pkt.seqno, MAXSIZE, 0, &from.sa, &fromlen); - if(len <= 0 || len > UINT16_MAX) { - if(len >= 0) { - logger(LOG_ERR, "Receiving packet with invalid size"); - } else if(!sockwouldblock(sockerrno)) { + if(len <= 0 || len > MAXSIZE) { + if(!sockwouldblock(sockerrno)) logger(LOG_ERR, "Receiving packet failed: %s", sockstrerror(sockerrno)); - } - return; } pkt.len = len; - sockaddrunmap(&from); /* Some braindead IPv6 implementations do stupid things. */ + + sockaddrunmap(&from); /* Some braindead IPv6 implementations do stupid things. */ n = lookup_node_udp(&from); if(!n) { n = try_harder(&from, &pkt); - - if(n) { + if(n) update_node_udp(n, &from); - } else ifdebug(PROTOCOL) { + else ifdebug(PROTOCOL) { hostname = sockaddr2hostname(&from); logger(LOG_WARNING, "Received UDP packet from unknown source %s", hostname); free(hostname); return; - } else { - return; } + else + return; } - n->sock = sock; - receive_udppacket(n, &pkt); } + +void handle_device_data(int sock, short events, void *data) { + vpn_packet_t packet; + + packet.priority = 0; + + if(read_packet(&packet)) { + myself->in_packets++; + myself->in_bytes += packet.len; + route(myself, &packet); + } +} diff --git a/src/net_setup.c b/src/net_setup.c index cac7455..91f7609 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -1,7 +1,7 @@ /* net_setup.c -- Setup. Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen + 2000-2010 Guus Sliepen 2006 Scott Lamb 2010 Brandon Black @@ -22,219 +22,165 @@ #include "system.h" -#include -#include -#include -#include -#include - -#include "avl_tree.h" +#include "splay_tree.h" +#include "cipher.h" #include "conf.h" #include "connection.h" +#include "control.h" #include "device.h" -#include "event.h" +#include "digest.h" +#include "ecdsa.h" #include "graph.h" #include "logger.h" #include "net.h" #include "netutl.h" #include "process.h" #include "protocol.h" -#include "proxy.h" #include "route.h" +#include "rsa.h" #include "subnet.h" #include "utils.h" #include "xalloc.h" char *myport; -devops_t devops; +static struct event device_ev; -#ifndef HAVE_RSA_SET0_KEY -int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) { - BN_free(r->n); - r->n = n; - BN_free(r->e); - r->e = e; - BN_free(r->d); - r->d = d; - return 1; -} -#endif +bool node_read_ecdsa_public_key(node_t *n) { + if(ecdsa_active(&n->ecdsa)) + return true; -bool read_rsa_public_key(connection_t *c) { + splay_tree_t *config_tree; FILE *fp; - char *pubname; - char *hcfname; - char *key; - BIGNUM *n = NULL; - BIGNUM *e = NULL; + char *fname; + char *p; + bool result = false; - if(!c->rsa_key) { - c->rsa_key = RSA_new(); -// RSA_blinding_on(c->rsa_key, NULL); + xasprintf(&fname, "%s/hosts/%s", confbase, n->name); + + init_configuration(&config_tree); + if(!read_config_file(config_tree, fname)) + goto exit; + + /* First, check for simple ECDSAPublicKey statement */ + + if(get_config_string(lookup_config(config_tree, "ECDSAPublicKey"), &p)) { + result = ecdsa_set_base64_public_key(&n->ecdsa, p); + free(p); + goto exit; } - /* First, check for simple PublicKey statement */ + /* Else, check for ECDSAPublicKeyFile statement and read it */ - if(get_config_string(lookup_config(c->config_tree, "PublicKey"), &key)) { - if((size_t)BN_hex2bn(&n, key) != strlen(key)) { - free(key); - logger(LOG_ERR, "Invalid PublicKey for %s!", c->name); - return false; - } + free(fname); - free(key); - BN_hex2bn(&e, "FFFF"); - - if(!n || !e || RSA_set0_key(c->rsa_key, n, e, NULL) != 1) { - BN_free(e); - BN_free(n); - logger(LOG_ERR, "RSA_set0_key() failed with PublicKey for %s!", c->name); - return false; - } - - return true; - } - - /* Else, check for PublicKeyFile statement and read it */ - - if(get_config_string(lookup_config(c->config_tree, "PublicKeyFile"), &pubname)) { - fp = fopen(pubname, "r"); - - if(!fp) { - logger(LOG_ERR, "Error reading RSA public key file `%s': %s", pubname, strerror(errno)); - free(pubname); - return false; - } - - c->rsa_key = PEM_read_RSAPublicKey(fp, &c->rsa_key, NULL, NULL); - fclose(fp); - - if(c->rsa_key) { - free(pubname); - return true; /* Woohoo. */ - } - - /* If it fails, try PEM_read_RSA_PUBKEY. */ - fp = fopen(pubname, "r"); - - if(!fp) { - logger(LOG_ERR, "Error reading RSA public key file `%s': %s", pubname, strerror(errno)); - free(pubname); - return false; - } - - c->rsa_key = PEM_read_RSA_PUBKEY(fp, &c->rsa_key, NULL, NULL); - fclose(fp); - - if(c->rsa_key) { -// RSA_blinding_on(c->rsa_key, NULL); - free(pubname); - return true; - } - - logger(LOG_ERR, "Reading RSA public key file `%s' failed: %s", pubname, strerror(errno)); - free(pubname); - return false; - } - - /* Else, check if a harnessed public key is in the config file */ - - xasprintf(&hcfname, "%s/hosts/%s", confbase, c->name); - fp = fopen(hcfname, "r"); - - if(!fp) { - logger(LOG_ERR, "Error reading RSA public key file `%s': %s", hcfname, strerror(errno)); - free(hcfname); - return false; - } - - c->rsa_key = PEM_read_RSAPublicKey(fp, &c->rsa_key, NULL, NULL); - fclose(fp); - - if(c->rsa_key) { - free(hcfname); - return true; - } - - /* Try again with PEM_read_RSA_PUBKEY. */ - - fp = fopen(hcfname, "r"); - - if(!fp) { - logger(LOG_ERR, "Error reading RSA public key file `%s': %s", hcfname, strerror(errno)); - free(hcfname); - return false; - } - - free(hcfname); - c->rsa_key = PEM_read_RSA_PUBKEY(fp, &c->rsa_key, NULL, NULL); -// RSA_blinding_on(c->rsa_key, NULL); - fclose(fp); - - if(c->rsa_key) { - return true; - } - - logger(LOG_ERR, "No public key for %s specified!", c->name); - - return false; -} - -static bool read_rsa_private_key(void) { - FILE *fp; - char *fname, *key, *pubkey; - BIGNUM *n = NULL; - BIGNUM *e = NULL; - BIGNUM *d = NULL; - - if(get_config_string(lookup_config(config_tree, "PrivateKey"), &key)) { - myself->connection->rsa_key = RSA_new(); - -// RSA_blinding_on(myself->connection->rsa_key, NULL); - if((size_t)BN_hex2bn(&d, key) != strlen(key)) { - logger(LOG_ERR, "Invalid PrivateKey for myself!"); - free(key); - return false; - } - - free(key); - - if(!get_config_string(lookup_config(config_tree, "PublicKey"), &pubkey)) { - BN_free(d); - logger(LOG_ERR, "PrivateKey used but no PublicKey found!"); - return false; - } - - if((size_t)BN_hex2bn(&n, pubkey) != strlen(pubkey)) { - free(pubkey); - BN_free(d); - logger(LOG_ERR, "Invalid PublicKey for myself!"); - return false; - } - - free(pubkey); - BN_hex2bn(&e, "FFFF"); - - if(!n || !e || !d || RSA_set0_key(myself->connection->rsa_key, n, e, d) != 1) { - BN_free(d); - BN_free(e); - BN_free(n); - logger(LOG_ERR, "RSA_set0_key() failed with PrivateKey for myself!"); - return false; - } - - return true; - } - - if(!get_config_string(lookup_config(config_tree, "PrivateKeyFile"), &fname)) { - xasprintf(&fname, "%s/rsa_key.priv", confbase); - } + if(!get_config_string(lookup_config(config_tree, "ECDSAPublicKeyFile"), &fname)) + xasprintf(&fname, "%s/hosts/%s", confbase, n->name); fp = fopen(fname, "r"); if(!fp) { - logger(LOG_ERR, "Error reading RSA private key file `%s': %s", - fname, strerror(errno)); + logger(LOG_ERR, "Error reading ECDSA public key file `%s': %s", fname, strerror(errno)); + goto exit; + } + + result = ecdsa_read_pem_public_key(&n->ecdsa, fp); + fclose(fp); + +exit: + exit_configuration(&config_tree); + free(fname); + return result; +} + +bool read_ecdsa_public_key(connection_t *c) { + FILE *fp; + char *fname; + char *p; + bool result; + + /* First, check for simple ECDSAPublicKey statement */ + + if(get_config_string(lookup_config(c->config_tree, "ECDSAPublicKey"), &p)) { + result = ecdsa_set_base64_public_key(&c->ecdsa, p); + free(p); + return result; + } + + /* Else, check for ECDSAPublicKeyFile statement and read it */ + + if(!get_config_string(lookup_config(c->config_tree, "ECDSAPublicKeyFile"), &fname)) + xasprintf(&fname, "%s/hosts/%s", confbase, c->name); + + fp = fopen(fname, "r"); + + if(!fp) { + logger(LOG_ERR, "Error reading ECDSA public key file `%s': %s", + fname, strerror(errno)); + free(fname); + return false; + } + + result = ecdsa_read_pem_public_key(&c->ecdsa, fp); + fclose(fp); + + if(!result) + logger(LOG_ERR, "Reading ECDSA public key file `%s' failed: %s", fname, strerror(errno)); + free(fname); + return result; +} + +bool read_rsa_public_key(connection_t *c) { + FILE *fp; + char *fname; + char *n; + bool result; + + /* First, check for simple PublicKey statement */ + + if(get_config_string(lookup_config(c->config_tree, "PublicKey"), &n)) { + result = rsa_set_hex_public_key(&c->rsa, n, "FFFF"); + free(n); + return result; + } + + /* Else, check for PublicKeyFile statement and read it */ + + if(!get_config_string(lookup_config(c->config_tree, "PublicKeyFile"), &fname)) + xasprintf(&fname, "%s/hosts/%s", confbase, c->name); + + fp = fopen(fname, "r"); + + if(!fp) { + logger(LOG_ERR, "Error reading RSA public key file `%s': %s", + fname, strerror(errno)); + free(fname); + return false; + } + + result = rsa_read_pem_public_key(&c->rsa, fp); + fclose(fp); + + if(!result) + logger(LOG_ERR, "Reading RSA public key file `%s' failed: %s", fname, strerror(errno)); + free(fname); + return result; +} + +static bool read_ecdsa_private_key(void) { + FILE *fp; + char *fname; + bool result; + + /* Check for PrivateKeyFile statement and read it */ + + if(!get_config_string(lookup_config(config_tree, "ECDSAPrivateKeyFile"), &fname)) + xasprintf(&fname, "%s/ecdsa_key.priv", confbase); + + fp = fopen(fname, "r"); + + if(!fp) { + logger(LOG_ERR, "Error reading ECDSA private key file `%s': %s", + fname, strerror(errno)); free(fname); return false; } @@ -242,28 +188,97 @@ static bool read_rsa_private_key(void) { #if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) struct stat s; - if(!fstat(fileno(fp), &s)) { - if(s.st_mode & ~0100700) { - logger(LOG_WARNING, "Warning: insecure file permissions for RSA private key file `%s'!", fname); - } - } else { - logger(LOG_WARNING, "Could not stat RSA private key file `%s': %s'", fname, strerror(errno)); - } - -#endif - - myself->connection->rsa_key = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL); - fclose(fp); - - if(!myself->connection->rsa_key) { - logger(LOG_ERR, "Reading RSA private key file `%s' failed: %s", - fname, strerror(errno)); + if(fstat(fileno(fp), &s)) { + logger(LOG_ERR, "Could not stat ECDSA private key file `%s': %s'", fname, strerror(errno)); free(fname); return false; } + if(s.st_mode & ~0100700) + logger(LOG_WARNING, "Warning: insecure file permissions for ECDSA private key file `%s'!", fname); +#endif + + result = ecdsa_read_pem_private_key(&myself->connection->ecdsa, fp); + fclose(fp); + + if(!result) + logger(LOG_ERR, "Reading ECDSA private key file `%s' failed: %s", fname, strerror(errno)); free(fname); - return true; + return result; +} + +static bool read_rsa_private_key(void) { + FILE *fp; + char *fname; + char *n, *d; + bool result; + + /* First, check for simple PrivateKey statement */ + + if(get_config_string(lookup_config(config_tree, "PrivateKey"), &d)) { + if(!get_config_string(lookup_config(config_tree, "PublicKey"), &n)) { + logger(LOG_ERR, "PrivateKey used but no PublicKey found!"); + free(d); + return false; + } + result = rsa_set_hex_private_key(&myself->connection->rsa, n, "FFFF", d); + free(n); + free(d); + return true; + } + + /* Else, check for PrivateKeyFile statement and read it */ + + if(!get_config_string(lookup_config(config_tree, "PrivateKeyFile"), &fname)) + xasprintf(&fname, "%s/rsa_key.priv", confbase); + + fp = fopen(fname, "r"); + + if(!fp) { + logger(LOG_ERR, "Error reading RSA private key file `%s': %s", + fname, strerror(errno)); + free(fname); + return false; + } + +#if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) + struct stat s; + + if(fstat(fileno(fp), &s)) { + logger(LOG_ERR, "Could not stat RSA private key file `%s': %s'", fname, strerror(errno)); + free(fname); + return false; + } + + if(s.st_mode & ~0100700) + logger(LOG_WARNING, "Warning: insecure file permissions for RSA private key file `%s'!", fname); +#endif + + result = rsa_read_pem_private_key(&myself->connection->rsa, fp); + fclose(fp); + + if(!result) + logger(LOG_ERR, "Reading RSA private key file `%s' failed: %s", fname, strerror(errno)); + free(fname); + return result; +} + +static struct event keyexpire_event; + +static void keyexpire_handler(int fd, short events, void *data) { + regenerate_key(); +} + +void regenerate_key(void) { + if(timeout_initialized(&keyexpire_event)) { + ifdebug(STATUS) logger(LOG_INFO, "Expiring symmetric keys"); + event_del(&keyexpire_event); + send_key_changed(); + } else { + timeout_set(&keyexpire_event, keyexpire_handler, NULL); + } + + event_add(&keyexpire_event, &(struct timeval){keylifetime, 0}); } /* @@ -274,14 +289,14 @@ void load_all_subnets(void) { struct dirent *ent; char *dname; char *fname; - avl_tree_t *config_tree; + splay_tree_t *config_tree; config_t *cfg; subnet_t *s, *s2; node_t *n; + bool result; xasprintf(&dname, "%s/hosts", confbase); dir = opendir(dname); - if(!dir) { logger(LOG_ERR, "Could not open %s: %s", dname, strerror(errno)); free(dname); @@ -289,21 +304,21 @@ void load_all_subnets(void) { } while((ent = readdir(dir))) { - if(!check_id(ent->d_name)) { + if(!check_id(ent->d_name)) continue; - } n = lookup_node(ent->d_name); -#ifdef _DIRENT_HAVE_D_TYPE + #ifdef _DIRENT_HAVE_D_TYPE //if(ent->d_type != DT_REG) - // continue; -#endif + // continue; + #endif xasprintf(&fname, "%s/hosts/%s", confbase, ent->d_name); init_configuration(&config_tree); - read_config_options(config_tree, ent->d_name); - read_config_file(config_tree, fname); + result = read_config_file(config_tree, fname); free(fname); + if(!result) + continue; if(!n) { n = new_node(); @@ -312,9 +327,8 @@ void load_all_subnets(void) { } for(cfg = lookup_config(config_tree, "Subnet"); cfg; cfg = lookup_config_next(config_tree, cfg)) { - if(!get_config_subnet(cfg, &s)) { + if(!get_config_subnet(cfg, &s)) continue; - } if((s2 = lookup_subnet(n, s))) { s2->expires = -1; @@ -329,71 +343,20 @@ void load_all_subnets(void) { closedir(dir); } -char *get_name(void) { - char *name = NULL; - - get_config_string(lookup_config(config_tree, "Name"), &name); - - if(!name) { - return NULL; - } - - if(*name == '$') { - char *envname = getenv(name + 1); - char hostname[32] = ""; - - if(!envname) { - if(strcmp(name + 1, "HOST")) { - fprintf(stderr, "Invalid Name: environment variable %s does not exist\n", name + 1); - free(name); - return false; - } - - if(gethostname(hostname, sizeof(hostname)) || !*hostname) { - fprintf(stderr, "Could not get hostname: %s\n", strerror(errno)); - free(name); - return false; - } - - hostname[31] = 0; - envname = hostname; - } - - free(name); - name = xstrdup(envname); - - for(char *c = name; *c; c++) - if(!isalnum(*c)) { - *c = '_'; - } - } - - if(!check_id(name)) { - logger(LOG_ERR, "Invalid name for myself!"); - free(name); - return false; - } - - return name; -} - /* Configure node_t myself and set up the local sockets (listen only) */ static bool setup_myself(void) { config_t *cfg; subnet_t *subnet; - char *name, *hostname, *mode, *afname, *cipher, *digest, *type; + char *name, *hostname, *mode, *afname, *cipher, *digest; char *fname = NULL; char *address = NULL; - char *proxy = NULL; - char *space; - char *envp[5] = {0}; + char *envp[5]; struct addrinfo *ai, *aip, hint = {0}; bool choice; int i, err; int replaywin_int; - bool port_specified = false; myself = new_node(); myself->connection = new_connection(); @@ -402,14 +365,19 @@ static bool setup_myself(void) { myself->connection->hostname = xstrdup("MYSELF"); myself->connection->options = 0; - myself->connection->protocol_version = PROT_CURRENT; + myself->connection->protocol_major = PROT_MAJOR; + myself->connection->protocol_minor = PROT_MINOR; - if(!(name = get_name())) { + if(!get_config_string(lookup_config(config_tree, "Name"), &name)) { /* Not acceptable */ logger(LOG_ERR, "Name for tinc daemon required!"); return false; } - /* Read tinc.conf and our own host config file */ + if(!check_id(name)) { + logger(LOG_ERR, "Invalid name for myself!"); + free(name); + return false; + } myself->name = name; myself->connection->name = xstrdup(name); @@ -418,118 +386,34 @@ static bool setup_myself(void) { read_config_file(config_tree, fname); free(fname); - if(!read_rsa_private_key()) { + get_config_bool(lookup_config(config_tree, "ExperimentalProtocol"), &experimental); + + if(experimental && !read_ecdsa_private_key()) return false; - } - if(!get_config_string(lookup_config(config_tree, "Port"), &myport)) { + if(!read_rsa_private_key()) + return false; + + if(!get_config_string(lookup_config(config_tree, "Port"), &myport)) myport = xstrdup("655"); - } else { - port_specified = true; - } - - /* Ensure myport is numeric */ if(!atoi(myport)) { struct addrinfo *ai = str2addrinfo("localhost", myport, SOCK_DGRAM); sockaddr_t sa; - - if(!ai || !ai->ai_addr) { + if(!ai || !ai->ai_addr) return false; - } - free(myport); memcpy(&sa, ai->ai_addr, ai->ai_addrlen); sockaddr2str(&sa, NULL, &myport); } - if(get_config_string(lookup_config(config_tree, "Proxy"), &proxy)) { - if((space = strchr(proxy, ' '))) { - *space++ = 0; - } - - if(!strcasecmp(proxy, "none")) { - proxytype = PROXY_NONE; - } else if(!strcasecmp(proxy, "socks4")) { - proxytype = PROXY_SOCKS4; - } else if(!strcasecmp(proxy, "socks4a")) { - proxytype = PROXY_SOCKS4A; - } else if(!strcasecmp(proxy, "socks5")) { - proxytype = PROXY_SOCKS5; - } else if(!strcasecmp(proxy, "http")) { - proxytype = PROXY_HTTP; - } else if(!strcasecmp(proxy, "exec")) { - proxytype = PROXY_EXEC; - } else { - logger(LOG_ERR, "Unknown proxy type %s!", proxy); - free(proxy); - return false; - } - - switch(proxytype) { - case PROXY_NONE: - default: - break; - - case PROXY_EXEC: - if(!space || !*space) { - logger(LOG_ERR, "Argument expected for proxy type exec!"); - free(proxy); - return false; - } - - proxyhost = xstrdup(space); - break; - - case PROXY_SOCKS4: - case PROXY_SOCKS4A: - case PROXY_SOCKS5: - case PROXY_HTTP: - proxyhost = space; - - if(space && (space = strchr(space, ' '))) { - *space++ = 0, proxyport = space; - } - - if(space && (space = strchr(space, ' '))) { - *space++ = 0, proxyuser = space; - } - - if(space && (space = strchr(space, ' '))) { - *space++ = 0, proxypass = space; - } - - if(!proxyhost || !*proxyhost || !proxyport || !*proxyport) { - logger(LOG_ERR, "Host and port argument expected for proxy!"); - free(proxy); - return false; - } - - proxyhost = xstrdup(proxyhost); - proxyport = xstrdup(proxyport); - - if(proxyuser && *proxyuser) { - proxyuser = xstrdup(proxyuser); - } - - if(proxypass && *proxypass) { - proxypass = xstrdup(proxypass); - } - - break; - } - - free(proxy); - } - /* Read in all the subnets specified in the host configuration file */ cfg = lookup_config(config_tree, "Subnet"); while(cfg) { - if(!get_config_subnet(cfg, &subnet)) { + if(!get_config_subnet(cfg, &subnet)) return false; - } subnet_add(myself, subnet); @@ -538,131 +422,75 @@ static bool setup_myself(void) { /* Check some options */ - if(get_config_bool(lookup_config(config_tree, "IndirectData"), &choice) && choice) { + if(get_config_bool(lookup_config(config_tree, "IndirectData"), &choice) && choice) myself->options |= OPTION_INDIRECT; - } - if(get_config_bool(lookup_config(config_tree, "TCPOnly"), &choice) && choice) { + if(get_config_bool(lookup_config(config_tree, "TCPOnly"), &choice) && choice) myself->options |= OPTION_TCPONLY; - } - if(myself->options & OPTION_TCPONLY) { + if(myself->options & OPTION_TCPONLY) myself->options |= OPTION_INDIRECT; - } get_config_bool(lookup_config(config_tree, "DirectOnly"), &directonly); get_config_bool(lookup_config(config_tree, "StrictSubnets"), &strictsubnets); get_config_bool(lookup_config(config_tree, "TunnelServer"), &tunnelserver); - get_config_bool(lookup_config(config_tree, "LocalDiscovery"), &localdiscovery); strictsubnets |= tunnelserver; if(get_config_string(lookup_config(config_tree, "Mode"), &mode)) { - if(!strcasecmp(mode, "router")) { + if(!strcasecmp(mode, "router")) routing_mode = RMODE_ROUTER; - } else if(!strcasecmp(mode, "switch")) { + else if(!strcasecmp(mode, "switch")) routing_mode = RMODE_SWITCH; - } else if(!strcasecmp(mode, "hub")) { + else if(!strcasecmp(mode, "hub")) routing_mode = RMODE_HUB; - } else { + else { logger(LOG_ERR, "Invalid routing mode!"); - free(mode); return false; } - free(mode); } if(get_config_string(lookup_config(config_tree, "Forwarding"), &mode)) { - if(!strcasecmp(mode, "off")) { + if(!strcasecmp(mode, "off")) forwarding_mode = FMODE_OFF; - } else if(!strcasecmp(mode, "internal")) { + else if(!strcasecmp(mode, "internal")) forwarding_mode = FMODE_INTERNAL; - } else if(!strcasecmp(mode, "kernel")) { + else if(!strcasecmp(mode, "kernel")) forwarding_mode = FMODE_KERNEL; - } else { + else { logger(LOG_ERR, "Invalid forwarding mode!"); - free(mode); return false; } - free(mode); } - choice = !(myself->options & OPTION_TCPONLY); - get_config_bool(lookup_config(config_tree, "PMTUDiscovery"), &choice); - - if(choice) { - myself->options |= OPTION_PMTU_DISCOVERY; - } - choice = true; - get_config_bool(lookup_config(config_tree, "ClampMSS"), &choice); + get_config_bool(lookup_config(config_tree, "PMTUDiscovery"), &choice); + if(choice) + myself->options |= OPTION_PMTU_DISCOVERY; - if(choice) { + choice = true; + get_config_bool(lookup_config(config_tree, "ClampMSS"), &choice); + if(choice) myself->options |= OPTION_CLAMP_MSS; - } get_config_bool(lookup_config(config_tree, "PriorityInheritance"), &priorityinheritance); - get_config_bool(lookup_config(config_tree, "DecrementTTL"), &decrement_ttl); - - if(get_config_string(lookup_config(config_tree, "Broadcast"), &mode)) { - if(!strcasecmp(mode, "no")) { - broadcast_mode = BMODE_NONE; - } else if(!strcasecmp(mode, "yes") || !strcasecmp(mode, "mst")) { - broadcast_mode = BMODE_MST; - } else if(!strcasecmp(mode, "direct")) { - broadcast_mode = BMODE_DIRECT; - } else { - logger(LOG_ERR, "Invalid broadcast mode!"); - free(mode); - return false; - } - - free(mode); - } #if !defined(SOL_IP) || !defined(IP_TOS) - - if(priorityinheritance) { - logger(LOG_WARNING, "%s not supported on this platform for IPv4 connection", "PriorityInheritance"); - } - + if(priorityinheritance) + logger(LOG_WARNING, "%s not supported on this platform", "PriorityInheritance"); #endif -#if !defined(IPPROTO_IPV6) || !defined(IPV6_TCLASS) - - if(priorityinheritance) { - logger(LOG_WARNING, "%s not supported on this platform for IPv6 connection", "PriorityInheritance"); - } - -#endif - - if(!get_config_int(lookup_config(config_tree, "MACExpire"), &macexpire)) { + if(!get_config_int(lookup_config(config_tree, "MACExpire"), &macexpire)) macexpire = 600; - } if(get_config_int(lookup_config(config_tree, "MaxTimeout"), &maxtimeout)) { if(maxtimeout <= 0) { logger(LOG_ERR, "Bogus maximum timeout!"); return false; } - } else { + } else maxtimeout = 900; - } - - if(get_config_int(lookup_config(config_tree, "MinTimeout"), &mintimeout)) { - if(mintimeout < 0) { - logger(LOG_ERR, "Bogus minimum timeout!"); - return false; - } - - if(mintimeout > maxtimeout) { - logger(LOG_WARNING, "Minimum timeout (%d s) cannot be larger than maximum timeout (%d s). Correcting !", mintimeout, maxtimeout); - mintimeout = maxtimeout; - } - } else { - mintimeout = 0; - } if(get_config_int(lookup_config(config_tree, "UDPRcvBuf"), &udp_rcvbuf)) { if(udp_rcvbuf <= 0) { @@ -683,23 +511,20 @@ static bool setup_myself(void) { logger(LOG_ERR, "ReplayWindow cannot be negative!"); return false; } - replaywin = (unsigned)replaywin_int; } if(get_config_string(lookup_config(config_tree, "AddressFamily"), &afname)) { - if(!strcasecmp(afname, "IPv4")) { + if(!strcasecmp(afname, "IPv4")) addressfamily = AF_INET; - } else if(!strcasecmp(afname, "IPv6")) { + else if(!strcasecmp(afname, "IPv6")) addressfamily = AF_INET6; - } else if(!strcasecmp(afname, "any")) { + else if(!strcasecmp(afname, "any")) addressfamily = AF_UNSPEC; - } else { + else { logger(LOG_ERR, "Invalid address family!"); - free(afname); return false; } - free(afname); } @@ -707,92 +532,37 @@ static bool setup_myself(void) { /* Generate packet encryption key */ - if(get_config_string(lookup_config(config_tree, "Cipher"), &cipher)) { - if(!strcasecmp(cipher, "none")) { - myself->incipher = NULL; - } else { - myself->incipher = EVP_get_cipherbyname(cipher); + if(!get_config_string(lookup_config(config_tree, "Cipher"), &cipher)) + cipher = xstrdup("blowfish"); - if(!myself->incipher) { - logger(LOG_ERR, "Unrecognized cipher type!"); - free(cipher); - return false; - } - } - - free(cipher); - } else { - myself->incipher = EVP_aes_256_cbc(); + if(!cipher_open_by_name(&myself->incipher, cipher)) { + logger(LOG_ERR, "Unrecognized cipher type!"); + return false; } - if(myself->incipher) { - myself->inkeylength = EVP_CIPHER_key_length(myself->incipher) + EVP_CIPHER_iv_length(myself->incipher); - } else { - myself->inkeylength = 1; - } - - /* We need to use a stream mode for the meta protocol. Use AES for this, - but try to match the key size with the one from the cipher selected - by Cipher. - - If Cipher is set to none, still use a low level of encryption for the - meta protocol. - */ - - int keylen = myself->incipher ? EVP_CIPHER_key_length(myself->incipher) : 0; - - if(keylen <= 16) { - myself->connection->outcipher = EVP_aes_128_cfb(); - } else if(keylen <= 24) { - myself->connection->outcipher = EVP_aes_192_cfb(); - } else { - myself->connection->outcipher = EVP_aes_256_cfb(); - } - - if(!get_config_int(lookup_config(config_tree, "KeyExpire"), &keylifetime)) { + if(!get_config_int(lookup_config(config_tree, "KeyExpire"), &keylifetime)) keylifetime = 3600; - } - keyexpires = now + keylifetime; + regenerate_key(); /* Check if we want to use message authentication codes... */ - if(get_config_string(lookup_config(config_tree, "Digest"), &digest)) { - if(!strcasecmp(digest, "none")) { - myself->indigest = NULL; - } else { - myself->indigest = EVP_get_digestbyname(digest); + if(!get_config_string(lookup_config(config_tree, "Digest"), &digest)) + digest = xstrdup("sha1"); - if(!myself->indigest) { - logger(LOG_ERR, "Unrecognized digest type!"); - free(digest); - return false; - } - } + int maclength = 4; + get_config_int(lookup_config(config_tree, "MACLength"), &maclength); - free(digest); - } else { - myself->indigest = EVP_sha256(); + if(maclength < 0) { + logger(LOG_ERR, "Bogus MAC length!"); + return false; } - myself->connection->outdigest = EVP_sha256(); - - if(get_config_int(lookup_config(config_tree, "MACLength"), &myself->inmaclength)) { - if(myself->indigest) { - if(myself->inmaclength > EVP_MD_size(myself->indigest)) { - logger(LOG_ERR, "MAC length exceeds size of digest!"); - return false; - } else if(myself->inmaclength < 0) { - logger(LOG_ERR, "Bogus MAC length!"); - return false; - } - } - } else { - myself->inmaclength = 4; + if(!digest_open_by_name(&myself->indigest, digest, maclength)) { + logger(LOG_ERR, "Unrecognized digest type!"); + return false; } - myself->connection->outmaclength = 0; - /* Compression */ if(get_config_int(lookup_config(config_tree, "Compression"), &myself->incompression)) { @@ -800,9 +570,8 @@ static bool setup_myself(void) { logger(LOG_ERR, "Bogus compression level!"); return false; } - } else { + } else myself->incompression = 0; - } myself->connection->outcompression = 0; @@ -815,59 +584,35 @@ static bool setup_myself(void) { graph(); - if(strictsubnets) { + if(strictsubnets) load_all_subnets(); - } /* Open device */ - devops = os_devops; - - if(get_config_string(lookup_config(config_tree, "DeviceType"), &type)) { - if(!strcasecmp(type, "dummy")) { - devops = dummy_devops; - } else if(!strcasecmp(type, "raw_socket")) { - devops = raw_socket_devops; - } else if(!strcasecmp(type, "multicast")) { - devops = multicast_devops; - } - -#ifdef ENABLE_UML - else if(!strcasecmp(type, "uml")) { - devops = uml_devops; - } - -#endif -#ifdef ENABLE_VDE - else if(!strcasecmp(type, "vde")) { - devops = vde_devops; - } - -#endif - free(type); - } - - if(!devops.setup()) { + if(!setup_device()) return false; + + if(device_fd >= 0) { + event_set(&device_ev, device_fd, EV_READ|EV_PERSIST, handle_device_data, NULL); + + if (event_add(&device_ev, NULL) < 0) { + logger(LOG_ERR, "event_add failed: %s", strerror(errno)); + close_device(); + return false; + } } /* Run tinc-up script to further initialize the tap interface */ - xasprintf(&envp[0], "NETNAME=%s", netname ? netname : ""); - xasprintf(&envp[1], "DEVICE=%s", device ? device : ""); - xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : ""); + xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); + xasprintf(&envp[1], "DEVICE=%s", device ? : ""); + xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); xasprintf(&envp[3], "NAME=%s", myself->name); + envp[4] = NULL; -#ifdef HAVE_MINGW - Sleep(1000); -#endif -#ifdef HAVE_CYGWIN - sleep(1); -#endif execute_script("tinc-up", envp); - for(i = 0; i < 4; i++) { + for(i = 0; i < 4; i++) free(envp[i]); - } /* Run subnet-up scripts for our own subnets */ @@ -875,150 +620,80 @@ static bool setup_myself(void) { /* Open sockets */ - if(!do_detach && getenv("LISTEN_FDS")) { - sockaddr_t sa; - socklen_t salen; + get_config_string(lookup_config(config_tree, "BindToAddress"), &address); - listen_sockets = atoi(getenv("LISTEN_FDS")); -#ifdef HAVE_UNSETENV - unsetenv("LISTEN_FDS"); -#endif + hint.ai_family = addressfamily; + hint.ai_socktype = SOCK_STREAM; + hint.ai_protocol = IPPROTO_TCP; + hint.ai_flags = AI_PASSIVE; - if(listen_sockets > MAXSOCKETS) { - logger(LOG_ERR, "Too many listening sockets"); - return false; - } + err = getaddrinfo(address, myport, &hint, &ai); - for(i = 0; i < listen_sockets; i++) { - salen = sizeof(sa); - - if(getsockname(i + 3, &sa.sa, &salen) < 0) { - logger(LOG_ERR, "Could not get address of listen fd %d: %s", i + 3, sockstrerror(errno)); - return false; - } - - listen_socket[i].tcp = i + 3; - -#ifdef FD_CLOEXEC - fcntl(i + 3, F_SETFD, FD_CLOEXEC); -#endif - - listen_socket[i].udp = setup_vpn_in_socket(&sa); - - if(listen_socket[i].udp < 0) { - return false; - } - - ifdebug(CONNECTIONS) { - hostname = sockaddr2hostname(&sa); - logger(LOG_NOTICE, "Listening on %s", hostname); - free(hostname); - } - - memcpy(&listen_socket[i].sa, &sa, salen); - } - } else { - listen_sockets = 0; - cfg = lookup_config(config_tree, "BindToAddress"); - - do { - get_config_string(cfg, &address); - - if(cfg) { - cfg = lookup_config_next(config_tree, cfg); - } - - char *port = myport; - - if(address) { - char *space = strchr(address, ' '); - - if(space) { - *space++ = 0; - port = space; - } - - if(!strcmp(address, "*")) { - *address = 0; - } - } - - hint.ai_family = addressfamily; - hint.ai_socktype = SOCK_STREAM; - hint.ai_protocol = IPPROTO_TCP; - hint.ai_flags = AI_PASSIVE; - -#if HAVE_DECL_RES_INIT - // ensure glibc reloads /etc/resolv.conf. - res_init(); -#endif - err = getaddrinfo(address && *address ? address : NULL, port, &hint, &ai); - free(address); - - if(err || !ai) { - logger(LOG_ERR, "System call `%s' failed: %s", "getaddrinfo", - gai_strerror(err)); - return false; - } - - for(aip = ai; aip; aip = aip->ai_next) { - if(listen_sockets >= MAXSOCKETS) { - logger(LOG_ERR, "Too many listening sockets"); - return false; - } - - listen_socket[listen_sockets].tcp = - setup_listen_socket((sockaddr_t *) aip->ai_addr); - - if(listen_socket[listen_sockets].tcp < 0) { - continue; - } - - listen_socket[listen_sockets].udp = - setup_vpn_in_socket((sockaddr_t *) aip->ai_addr); - - if(listen_socket[listen_sockets].udp < 0) { - continue; - } - - ifdebug(CONNECTIONS) { - hostname = sockaddr2hostname((sockaddr_t *) aip->ai_addr); - logger(LOG_NOTICE, "Listening on %s", hostname); - free(hostname); - } - - memcpy(&listen_socket[listen_sockets].sa, aip->ai_addr, aip->ai_addrlen); - listen_sockets++; - } - - freeaddrinfo(ai); - } while(cfg); + if(err || !ai) { + logger(LOG_ERR, "System call `%s' failed: %s", "getaddrinfo", + gai_strerror(err)); + return false; } - if(!listen_sockets) { + listen_sockets = 0; + + for(aip = ai; aip; aip = aip->ai_next) { + listen_socket[listen_sockets].tcp = + setup_listen_socket((sockaddr_t *) aip->ai_addr); + + if(listen_socket[listen_sockets].tcp < 0) + continue; + + listen_socket[listen_sockets].udp = + setup_vpn_in_socket((sockaddr_t *) aip->ai_addr); + + if(listen_socket[listen_sockets].udp < 0) { + close(listen_socket[listen_sockets].tcp); + continue; + } + + event_set(&listen_socket[listen_sockets].ev_tcp, + listen_socket[listen_sockets].tcp, + EV_READ|EV_PERSIST, + handle_new_meta_connection, NULL); + if(event_add(&listen_socket[listen_sockets].ev_tcp, NULL) < 0) { + logger(LOG_ERR, "event_add failed: %s", strerror(errno)); + abort(); + } + + event_set(&listen_socket[listen_sockets].ev_udp, + listen_socket[listen_sockets].udp, + EV_READ|EV_PERSIST, + handle_incoming_vpn_data, NULL); + if(event_add(&listen_socket[listen_sockets].ev_udp, NULL) < 0) { + logger(LOG_ERR, "event_add failed: %s", strerror(errno)); + abort(); + } + + ifdebug(CONNECTIONS) { + hostname = sockaddr2hostname((sockaddr_t *) aip->ai_addr); + logger(LOG_NOTICE, "Listening on %s", hostname); + free(hostname); + } + + memcpy(&listen_socket[listen_sockets].sa, aip->ai_addr, aip->ai_addrlen); + listen_sockets++; + + if(listen_sockets >= MAXSOCKETS) { + logger(LOG_WARNING, "Maximum of %d listening sockets reached", MAXSOCKETS); + break; + } + } + + freeaddrinfo(ai); + + if(listen_sockets) + logger(LOG_NOTICE, "Ready"); + else { logger(LOG_ERR, "Unable to create any listening socket!"); return false; } - /* If no Port option was specified, set myport to the port used by the first listening socket. */ - - if(!port_specified) { - sockaddr_t sa; - socklen_t salen = sizeof(sa); - - if(!getsockname(listen_socket[0].udp, &sa.sa, &salen)) { - free(myport); - sockaddr2str(&sa, NULL, &myport); - - if(!myport) { - myport = xstrdup("655"); - } - } - } - - /* Done. */ - - logger(LOG_NOTICE, "Ready"); return true; } @@ -1026,9 +701,6 @@ static bool setup_myself(void) { initialize network */ bool setup_network(void) { - now = time(NULL); - - init_events(); init_connections(); init_subnets(); init_nodes(); @@ -1039,25 +711,19 @@ bool setup_network(void) { if(pinginterval < 1) { pinginterval = 86400; } - } else { + } else pinginterval = 60; - } - if(!get_config_int(lookup_config(config_tree, "PingTimeout"), &pingtimeout)) { + if(!get_config_int(lookup_config(config_tree, "PingTimeout"), &pingtimeout)) pingtimeout = 5; - } - - if(pingtimeout < 1 || pingtimeout > pinginterval) { + if(pingtimeout < 1 || pingtimeout > pinginterval) pingtimeout = pinginterval; - } - if(!get_config_int(lookup_config(config_tree, "MaxOutputBufferSize"), &maxoutbufsize)) { + if(!get_config_int(lookup_config(config_tree, "MaxOutputBufferSize"), &maxoutbufsize)) maxoutbufsize = 10 * MTU; - } - if(!setup_myself()) { + if(!setup_myself()) return false; - } return true; } @@ -1066,9 +732,9 @@ bool setup_network(void) { close all open network connections */ void close_network_connections(void) { - avl_node_t *node, *next; + splay_node_t *node, *next; connection_t *c; - char *envp[5] = {0}; + char *envp[5]; int i; for(node = connection_tree->head; node; node = next) { @@ -1078,14 +744,6 @@ void close_network_connections(void) { terminate_connection(c, false); } - for(list_node_t *node = outgoing_list->head; node; node = node->next) { - outgoing_t *outgoing = node->data; - - if(outgoing->event) { - event_del(outgoing->event); - } - } - list_delete_list(outgoing_list); if(myself && myself->connection) { @@ -1095,33 +753,32 @@ void close_network_connections(void) { } for(i = 0; i < listen_sockets; i++) { + event_del(&listen_socket[i].ev_tcp); + event_del(&listen_socket[i].ev_udp); close(listen_socket[i].tcp); close(listen_socket[i].udp); } - xasprintf(&envp[0], "NETNAME=%s", netname ? netname : ""); - xasprintf(&envp[1], "DEVICE=%s", device ? device : ""); - xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : ""); + xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); + xasprintf(&envp[1], "DEVICE=%s", device ? : ""); + xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); xasprintf(&envp[3], "NAME=%s", myself->name); + envp[4] = NULL; exit_requests(); exit_edges(); exit_subnets(); exit_nodes(); exit_connections(); - exit_events(); execute_script("tinc-down", envp); - if(myport) { - free(myport); - } + if(myport) free(myport); - for(i = 0; i < 4; i++) { + for(i = 0; i < 4; i++) free(envp[i]); - } - devops.close(); + close_device(); return; } diff --git a/src/net_socket.c b/src/net_socket.c index 6195c16..a1dfcd3 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -1,7 +1,7 @@ /* net_socket.c -- Handle various kinds of sockets. Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen + 2000-2010 Guus Sliepen 2006 Scott Lamb 2009 Florian Forster @@ -22,26 +22,25 @@ #include "system.h" -#include "avl_tree.h" +#include "splay_tree.h" #include "conf.h" #include "connection.h" -#include "event.h" #include "logger.h" #include "meta.h" #include "net.h" #include "netutl.h" #include "protocol.h" -#include "proxy.h" #include "utils.h" #include "xalloc.h" +#include + /* Needed on Mac OS/X */ #ifndef SOL_TCP #define SOL_TCP IPPROTO_TCP #endif int addressfamily = AF_UNSPEC; -int mintimeout = 0; int maxtimeout = 900; int seconds_till_retry = 5; int udp_rcvbuf = 0; @@ -62,29 +61,22 @@ static void configure_tcp(connection_t *c) { if(fcntl(c->socket, F_SETFL, flags | O_NONBLOCK) < 0) { logger(LOG_ERR, "fcntl for %s: %s", c->hostname, strerror(errno)); } - #elif defined(WIN32) unsigned long arg = 1; if(ioctlsocket(c->socket, FIONBIO, &arg) != 0) { - logger(LOG_ERR, "ioctlsocket for %s: %s", c->hostname, sockstrerror(sockerrno)); + logger(LOG_ERR, "ioctlsocket for %s: %d", c->hostname, sockstrerror(sockerrno)); } - #endif #if defined(SOL_TCP) && defined(TCP_NODELAY) option = 1; - setsockopt(c->socket, SOL_TCP, TCP_NODELAY, (void *)&option, sizeof(option)); + setsockopt(c->socket, SOL_TCP, TCP_NODELAY, (void *)&option, sizeof option); #endif -#if defined(IP_TOS) && defined(IPTOS_LOWDELAY) +#if defined(SOL_IP) && defined(IP_TOS) && defined(IPTOS_LOWDELAY) option = IPTOS_LOWDELAY; - setsockopt(c->socket, IPPROTO_IP, IP_TOS, (void *)&option, sizeof(option)); -#endif - -#if defined(IPV6_TCLASS) && defined(IPTOS_LOWDELAY) - option = IPTOS_LOWDELAY; - setsockopt(c->socket, IPPROTO_IPV6, IPV6_TCLASS, (void *)&option, sizeof(option)); + setsockopt(c->socket, SOL_IP, IP_TOS, (void *)&option, sizeof option); #endif } @@ -96,23 +88,20 @@ static bool bind_to_interface(int sd) { int status; #endif /* defined(SOL_SOCKET) && defined(SO_BINDTODEVICE) */ - if(!get_config_string(lookup_config(config_tree, "BindToInterface"), &iface)) { + if(!get_config_string (lookup_config (config_tree, "BindToInterface"), &iface)) return true; - } #if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE) memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ); ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0; - free(iface); status = setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr)); - if(status) { - logger(LOG_ERR, "Can't bind to interface %s: %s", ifr.ifr_ifrn.ifrn_name, strerror(errno)); + logger(LOG_ERR, "Can't bind to interface %s: %s", iface, + strerror(errno)); return false; } - #else /* if !defined(SOL_SOCKET) || !defined(SO_BINDTODEVICE) */ logger(LOG_WARNING, "%s not supported on this platform", "BindToInterface"); #endif @@ -120,6 +109,63 @@ static bool bind_to_interface(int sd) { return true; } +static bool bind_to_address(connection_t *c) { + char *node; + struct addrinfo *ai_list; + struct addrinfo *ai_ptr; + struct addrinfo ai_hints; + int status; + + assert(c != NULL); + assert(c->socket >= 0); + + node = NULL; + if(!get_config_string(lookup_config(config_tree, "BindToAddress"), + &node)) + return true; + + assert(node != NULL); + + memset(&ai_hints, 0, sizeof(ai_hints)); + ai_hints.ai_family = c->address.sa.sa_family; + /* We're called from `do_outgoing_connection' only. */ + ai_hints.ai_socktype = SOCK_STREAM; + ai_hints.ai_protocol = IPPROTO_TCP; + + ai_list = NULL; + + status = getaddrinfo(node, /* service = */ NULL, + &ai_hints, &ai_list); + if(status) { + logger(LOG_WARNING, "Error looking up %s port %s: %s", + node, "any", gai_strerror(status)); + free(node); + return false; + } + assert(ai_list != NULL); + + status = -1; + for(ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next) { + status = bind(c->socket, + ai_list->ai_addr, ai_list->ai_addrlen); + if(!status) + break; + } + + + if(status) { + logger(LOG_ERR, "Can't bind to %s/tcp: %s", node, sockstrerror(sockerrno)); + } else ifdebug(CONNECTIONS) { + logger(LOG_DEBUG, "Successfully bound outgoing " + "TCP socket to %s", node); + } + + free(node); + freeaddrinfo(ai_list); + + return status ? false : true; +} + int setup_listen_socket(const sockaddr_t *sa) { int nfd; char *addrstr; @@ -133,40 +179,30 @@ int setup_listen_socket(const sockaddr_t *sa) { return -1; } -#ifdef FD_CLOEXEC - fcntl(nfd, F_SETFD, FD_CLOEXEC); -#endif - /* Optimize TCP settings */ option = 1; - setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof(option)); + setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof option); -#if defined(IPV6_V6ONLY) - - if(sa->sa.sa_family == AF_INET6) { - setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option)); - } - -#else -#warning IPV6_V6ONLY not defined +#if defined(SOL_IPV6) && defined(IPV6_V6ONLY) + if(sa->sa.sa_family == AF_INET6) + setsockopt(nfd, SOL_IPV6, IPV6_V6ONLY, (void *)&option, sizeof option); #endif - if(get_config_string(lookup_config(config_tree, "BindToInterface"), &iface)) { + if(get_config_string + (lookup_config(config_tree, "BindToInterface"), &iface)) { #if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE) struct ifreq ifr; - memset(&ifr, 0, sizeof(ifr)); + memset(&ifr, 0, sizeof ifr); strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ); - ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0; - free(iface); - if(setsockopt(nfd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr))) { + if(setsockopt(nfd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof ifr)) { closesocket(nfd); - logger(LOG_ERR, "Can't bind to interface %s: %s", ifr.ifr_ifrn.ifrn_name, strerror(sockerrno)); + logger(LOG_ERR, "Can't bind to interface %s: %s", iface, + strerror(sockerrno)); return -1; } - #else logger(LOG_WARNING, "%s not supported on this platform", "BindToInterface"); #endif @@ -201,10 +237,6 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { return -1; } -#ifdef FD_CLOEXEC - fcntl(nfd, F_SETFD, FD_CLOEXEC); -#endif - #ifdef O_NONBLOCK { int flags = fcntl(nfd, F_GETFL); @@ -212,14 +244,13 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0) { closesocket(nfd); logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", - strerror(errno)); + strerror(errno)); return -1; } } #elif defined(WIN32) { unsigned long arg = 1; - if(ioctlsocket(nfd, FIONBIO, &arg) != 0) { closesocket(nfd); logger(LOG_ERR, "Call to `%s' failed: %s", "ioctlsocket", sockstrerror(sockerrno)); @@ -229,62 +260,52 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { #endif option = 1; - setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof(option)); - setsockopt(nfd, SOL_SOCKET, SO_BROADCAST, (void *)&option, sizeof(option)); + setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof option); - if(udp_rcvbuf && setsockopt(nfd, SOL_SOCKET, SO_RCVBUF, (void *)&udp_rcvbuf, sizeof(udp_rcvbuf))) { + if(udp_rcvbuf && setsockopt(nfd, SOL_SOCKET, SO_RCVBUF, (void *)&udp_rcvbuf, sizeof(udp_rcvbuf))) logger(LOG_WARNING, "Can't set UDP SO_RCVBUF to %i: %s", udp_rcvbuf, strerror(errno)); - } - if(udp_sndbuf && setsockopt(nfd, SOL_SOCKET, SO_SNDBUF, (void *)&udp_sndbuf, sizeof(udp_sndbuf))) { + if(udp_sndbuf && setsockopt(nfd, SOL_SOCKET, SO_SNDBUF, (void *)&udp_sndbuf, sizeof(udp_sndbuf))) logger(LOG_WARNING, "Can't set UDP SO_SNDBUF to %i: %s", udp_sndbuf, strerror(errno)); - } - -#if defined(IPV6_V6ONLY) - - if(sa->sa.sa_family == AF_INET6) { - setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option)); - } +#if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) + if(sa->sa.sa_family == AF_INET6) + setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof option); #endif #if defined(IP_DONTFRAG) && !defined(IP_DONTFRAGMENT) #define IP_DONTFRAGMENT IP_DONTFRAG #endif -#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO) - +#if defined(SOL_IP) && defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DO) if(myself->options & OPTION_PMTU_DISCOVERY) { option = IP_PMTUDISC_DO; - setsockopt(nfd, IPPROTO_IP, IP_MTU_DISCOVER, (void *)&option, sizeof(option)); + setsockopt(nfd, SOL_IP, IP_MTU_DISCOVER, (void *)&option, sizeof(option)); } - -#elif defined(IP_DONTFRAGMENT) - +#elif defined(IPPROTO_IP) && defined(IP_DONTFRAGMENT) if(myself->options & OPTION_PMTU_DISCOVERY) { option = 1; setsockopt(nfd, IPPROTO_IP, IP_DONTFRAGMENT, (void *)&option, sizeof(option)); } - +#else +#warning No way to disable IPv4 fragmentation #endif -#if defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DO) - +#if defined(SOL_IPV6) && defined(IPV6_MTU_DISCOVER) && defined(IPV6_PMTUDISC_DO) if(myself->options & OPTION_PMTU_DISCOVERY) { option = IPV6_PMTUDISC_DO; - setsockopt(nfd, IPPROTO_IPV6, IPV6_MTU_DISCOVER, (void *)&option, sizeof(option)); + setsockopt(nfd, SOL_IPV6, IPV6_MTU_DISCOVER, (void *)&option, sizeof(option)); } - -#elif defined(IPV6_DONTFRAG) - +#elif defined(IPPROTO_IPV6) && defined(IPV6_DONTFRAG) if(myself->options & OPTION_PMTU_DISCOVERY) { option = 1; setsockopt(nfd, IPPROTO_IPV6, IPV6_DONTFRAG, (void *)&option, sizeof(option)); } - +#else +#warning No way to disable IPv6 fragmentation #endif - if(!bind_to_interface(nfd)) { + if (!bind_to_interface(nfd)) { closesocket(nfd); return -1; } @@ -300,109 +321,37 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { return nfd; } /* int setup_vpn_in_socket */ +static void retry_outgoing_handler(int fd, short events, void *data) { + setup_outgoing_connection(data); +} + void retry_outgoing(outgoing_t *outgoing) { outgoing->timeout += 5; - if(outgoing->timeout < mintimeout) { - outgoing->timeout = mintimeout; - } - - if(outgoing->timeout > maxtimeout) { + if(outgoing->timeout > maxtimeout) outgoing->timeout = maxtimeout; - } - if(outgoing->event) { - event_del(outgoing->event); - } - - outgoing->event = new_event(); - outgoing->event->handler = (event_handler_t) setup_outgoing_connection; - outgoing->event->time = now + outgoing->timeout; - outgoing->event->data = outgoing; - event_add(outgoing->event); + timeout_set(&outgoing->ev, retry_outgoing_handler, outgoing); + event_add(&outgoing->ev, &(struct timeval){outgoing->timeout, 0}); ifdebug(CONNECTIONS) logger(LOG_NOTICE, - "Trying to re-establish outgoing connection in %d seconds", - outgoing->timeout); + "Trying to re-establish outgoing connection in %d seconds", + outgoing->timeout); } void finish_connecting(connection_t *c) { ifdebug(CONNECTIONS) logger(LOG_INFO, "Connected to %s (%s)", c->name, c->hostname); - c->last_ping_time = now; + configure_tcp(c); + + c->last_ping_time = time(NULL); + c->status.connecting = false; send_id(c); } -static void do_outgoing_pipe(connection_t *c, char *command) { -#ifndef HAVE_MINGW - int fd[2]; - - if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) { - logger(LOG_ERR, "Could not create socketpair: %s\n", strerror(errno)); - return; - } - - if(fork()) { - c->socket = fd[0]; - close(fd[1]); - ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Using proxy %s", command); - return; - } - - close(0); - close(1); - close(fd[0]); - dup2(fd[1], 0); - dup2(fd[1], 1); - close(fd[1]); - - // Other filedescriptors should be closed automatically by CLOEXEC - - char *host = NULL; - char *port = NULL; - - sockaddr2str(&c->address, &host, &port); - setenv("REMOTEADDRESS", host, true); - setenv("REMOTEPORT", port, true); - setenv("NODE", c->name, true); - setenv("NAME", myself->name, true); - - if(netname) { - setenv("NETNAME", netname, true); - } - - int result = system(command); - - if(result < 0) { - logger(LOG_ERR, "Could not execute %s: %s\n", command, strerror(errno)); - } else if(result) { - logger(LOG_ERR, "%s exited with non-zero status %d", command, result); - } - - exit(result); -#else - logger(LOG_ERR, "Proxy type exec not supported on this platform!"); - return; -#endif -} - -static bool is_valid_host_port(const char *host, const char *port) { - for(const char *p = host; *p; p++) - if(!isalnum(*p) && *p != '-' && *p != '.') { - return false; - } - - for(const char *p = port; *p; p++) - if(!isalnum(*p)) { - return false; - } - - return true; -} - -void do_outgoing_connection(connection_t *c) { - struct addrinfo *proxyai = NULL; +bool do_outgoing_connection(connection_t *c) { + char *address, *port, *space; int result; if(!c->outgoing) { @@ -411,58 +360,38 @@ void do_outgoing_connection(connection_t *c) { } begin: - if(!c->outgoing->ai) { if(!c->outgoing->cfg) { ifdebug(CONNECTIONS) logger(LOG_ERR, "Could not set up a meta connection to %s", - c->name); - c->status.remove = true; + c->name); retry_outgoing(c->outgoing); c->outgoing = NULL; - return; + connection_del(c); + return false; } - char *address, *port, *space; - get_config_string(c->outgoing->cfg, &address); space = strchr(address, ' '); - if(space) { port = xstrdup(space + 1); *space = 0; } else { - if(!get_config_string(lookup_config(c->config_tree, "Port"), &port)) { + if(!get_config_string(lookup_config(c->config_tree, "Port"), &port)) port = xstrdup("655"); - } } c->outgoing->ai = str2addrinfo(address, port, SOCK_STREAM); - - // If we cannot resolve the address, maybe we are using a proxy that can? - if(!c->outgoing->ai && proxytype != PROXY_NONE && is_valid_host_port(address, port)) { - memset(&c->address, 0, sizeof(c->address)); - c->address.sa.sa_family = AF_UNKNOWN; - c->address.unknown.address = address; - c->address.unknown.port = port; - } else { - free(address); - free(port); - } + free(address); + free(port); c->outgoing->aip = c->outgoing->ai; c->outgoing->cfg = lookup_config_next(c->config_tree, c->outgoing->cfg); - - if(!c->outgoing->ai && proxytype != PROXY_NONE) { - goto connect; - } } if(!c->outgoing->aip) { - if(c->outgoing->ai) { + if(c->outgoing->ai) freeaddrinfo(c->outgoing->ai); - } - c->outgoing->ai = NULL; goto begin; } @@ -470,106 +399,42 @@ begin: memcpy(&c->address, c->outgoing->aip->ai_addr, c->outgoing->aip->ai_addrlen); c->outgoing->aip = c->outgoing->aip->ai_next; -connect: - - if(c->hostname) { + if(c->hostname) free(c->hostname); - } c->hostname = sockaddr2hostname(&c->address); ifdebug(CONNECTIONS) logger(LOG_INFO, "Trying to connect to %s (%s)", c->name, - c->hostname); + c->hostname); - if(!proxytype) { - c->socket = socket(c->address.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); - } else if(proxytype == PROXY_EXEC) { - c->status.proxy_passed = true; - do_outgoing_pipe(c, proxyhost); - } else { - proxyai = str2addrinfo(proxyhost, proxyport, SOCK_STREAM); - - if(!proxyai) { - goto begin; - } - - ifdebug(CONNECTIONS) logger(LOG_INFO, "Using proxy at %s port %s", proxyhost, proxyport); - c->socket = socket(proxyai->ai_family, SOCK_STREAM, IPPROTO_TCP); - } + c->socket = socket(c->address.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); if(c->socket == -1) { ifdebug(CONNECTIONS) logger(LOG_ERR, "Creating socket for %s failed: %s", c->hostname, sockstrerror(sockerrno)); goto begin; } - if(proxytype != PROXY_EXEC) { - configure_tcp(c); - } - -#ifdef FD_CLOEXEC - fcntl(c->socket, F_SETFD, FD_CLOEXEC); +#if defined(SOL_IPV6) && defined(IPV6_V6ONLY) + int option = 1; + if(c->address.sa.sa_family == AF_INET6) + setsockopt(c->socket, SOL_IPV6, IPV6_V6ONLY, (void *)&option, sizeof option); #endif - if(proxytype != PROXY_EXEC) { -#if defined(IPV6_V6ONLY) - int option = 1; + bind_to_interface(c->socket); + bind_to_address(c); - if(c->address.sa.sa_family == AF_INET6) { - setsockopt(c->socket, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option)); - } + /* Optimize TCP settings */ -#endif - - bind_to_interface(c->socket); - - int b = -1; - - for(int i = 0; i < listen_sockets; i++) { - if(listen_socket[i].sa.sa.sa_family == c->address.sa.sa_family) { - if(b == -1) { - b = i; - } else { - b = -1; - break; - } - } - } - - if(b != -1) { - sockaddr_t sa = listen_socket[b].sa; - - if(sa.sa.sa_family == AF_INET) { - sa.in.sin_port = 0; - } else if(sa.sa.sa_family == AF_INET6) { - sa.in6.sin6_port = 0; - } - - if(bind(c->socket, &sa.sa, SALEN(sa.sa))) { - char *addrstr = sockaddr2hostname(&sa); - logger(LOG_ERR, "Can't bind to %s/tcp: %s", addrstr, sockstrerror(sockerrno)); - free(addrstr); - } - } - } + configure_tcp(c); /* Connect */ - if(!proxytype) { - result = connect(c->socket, &c->address.sa, SALEN(c->address.sa)); - } else if(proxytype == PROXY_EXEC) { - result = 0; - } else { - result = connect(c->socket, proxyai->ai_addr, proxyai->ai_addrlen); - freeaddrinfo(proxyai); - } - - now = time(NULL); + result = connect(c->socket, &c->address.sa, SALEN(c->address.sa)); if(result == -1) { if(sockinprogress(sockerrno)) { - c->last_ping_time = now; c->status.connecting = true; - return; + return true; } closesocket(c->socket); @@ -581,14 +446,32 @@ connect: finish_connecting(c); - return; + return true; +} + +static void handle_meta_write(int sock, short events, void *data) { + ifdebug(META) logger(LOG_DEBUG, "handle_meta_write() called"); + + connection_t *c = data; + + ssize_t outlen = send(c->socket, c->outbuf.data + c->outbuf.offset, c->outbuf.len - c->outbuf.offset, 0); + if(outlen <= 0) { + logger(LOG_ERR, "Onoes, outlen = %d (%s)", (int)outlen, strerror(errno)); + terminate_connection(c, c->status.active); + return; + } + + buffer_read(&c->outbuf, outlen); + if(!c->outbuf.len && event_initialized(&c->outevent)) + event_del(&c->outevent); } void setup_outgoing_connection(outgoing_t *outgoing) { connection_t *c; node_t *n; - outgoing->event = NULL; + if(event_initialized(&outgoing->ev)) + event_del(&outgoing->ev); n = lookup_node(outgoing->name); @@ -608,66 +491,43 @@ void setup_outgoing_connection(outgoing_t *outgoing) { c->outcompression = myself->connection->outcompression; init_configuration(&c->config_tree); - - if(!read_connection_config(c)) { - free_connection(c); - outgoing->timeout = maxtimeout; - retry_outgoing(outgoing); - return; - } + read_connection_config(c); outgoing->cfg = lookup_config(c->config_tree, "Address"); if(!outgoing->cfg) { logger(LOG_ERR, "No address specified for %s", c->name); free_connection(c); - outgoing->timeout = maxtimeout; - retry_outgoing(outgoing); return; } c->outgoing = outgoing; - c->last_ping_time = now; + c->last_ping_time = time(NULL); connection_add(c); - do_outgoing_connection(c); + if (do_outgoing_connection(c)) { + event_set(&c->inevent, c->socket, EV_READ | EV_PERSIST, handle_meta_connection_data, c); + event_set(&c->outevent, c->socket, EV_WRITE | EV_PERSIST, handle_meta_write, c); + event_add(&c->inevent, NULL); + } } /* accept a new tcp connect and create a new connection */ -bool handle_new_meta_connection(int sock) { - static const int max_accept_burst = 10; - static int last_accept_burst; - static int last_accept_time; +void handle_new_meta_connection(int sock, short events, void *data) { connection_t *c; sockaddr_t sa; int fd; - socklen_t len = sizeof(sa); + socklen_t len = sizeof sa; fd = accept(sock, &sa.sa, &len); if(fd < 0) { logger(LOG_ERR, "Accepting a new connection failed: %s", sockstrerror(sockerrno)); - return false; - } - - if(last_accept_time == now) { - last_accept_burst++; - - if(last_accept_burst >= max_accept_burst) { - if(last_accept_burst == max_accept_burst) { - ifdebug(CONNECTIONS) logger(LOG_WARNING, "Throttling incoming connections"); - } - - tarpit(fd); - return false; - } - } else { - last_accept_burst = 0; - last_accept_time = now; + return; } sockaddrunmap(&sa); @@ -682,27 +542,28 @@ bool handle_new_meta_connection(int sock) { c->address = sa; c->hostname = sockaddr2hostname(&sa); c->socket = fd; - c->last_ping_time = now; + c->last_ping_time = time(NULL); ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection from %s", c->hostname); + event_set(&c->inevent, c->socket, EV_READ | EV_PERSIST, handle_meta_connection_data, c); + event_set(&c->outevent, c->socket, EV_WRITE | EV_PERSIST, handle_meta_write, c); + event_add(&c->inevent, NULL); + configure_tcp(c); connection_add(c); c->allow_request = ID; - - return true; + send_id(c); } static void free_outgoing(outgoing_t *outgoing) { - if(outgoing->ai) { + if(outgoing->ai) freeaddrinfo(outgoing->ai); - } - if(outgoing->name) { + if(outgoing->name) free(outgoing->name); - } free(outgoing); } @@ -711,21 +572,21 @@ void try_outgoing_connections(void) { static config_t *cfg = NULL; char *name; outgoing_t *outgoing; - + outgoing_list = list_alloc((list_action_t)free_outgoing); - + for(cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) { get_config_string(cfg, &name); if(!check_id(name)) { logger(LOG_ERR, - "Invalid name for outgoing connection in %s line %d", - cfg->file, cfg->line); + "Invalid name for outgoing connection in %s line %d", + cfg->file, cfg->line); free(name); continue; } - outgoing = xmalloc_and_zero(sizeof(*outgoing)); + outgoing = xmalloc_and_zero(sizeof *outgoing); outgoing->name = name; list_insert_tail(outgoing_list, outgoing); setup_outgoing_connection(outgoing); diff --git a/src/netutl.c b/src/netutl.c index abe3d87..8db252d 100644 --- a/src/netutl.c +++ b/src/netutl.c @@ -1,7 +1,7 @@ /* netutl.c -- some supporting network utility code Copyright (C) 1998-2005 Ivo Timmermans - 2000-2016 Guus Sliepen + 2000-2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,21 +33,17 @@ bool hostnames = false; Return NULL on failure. */ struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype) { - struct addrinfo *ai = NULL, hint = {0}; + struct addrinfo *ai, hint = {0}; int err; hint.ai_family = addressfamily; hint.ai_socktype = socktype; -#if HAVE_DECL_RES_INIT - // ensure glibc reloads /etc/resolv.conf. - res_init(); -#endif err = getaddrinfo(address, service, &hint, &ai); if(err) { logger(LOG_WARNING, "Error looking up %s port %s: %s", address, - service, gai_strerror(err)); + service, gai_strerror(err)); return NULL; } @@ -55,7 +51,7 @@ struct addrinfo *str2addrinfo(const char *address, const char *service, int sock } sockaddr_t str2sockaddr(const char *address, const char *port) { - struct addrinfo *ai = NULL, hint = {0}; + struct addrinfo *ai, hint = {0}; sockaddr_t result; int err; @@ -67,7 +63,7 @@ sockaddr_t str2sockaddr(const char *address, const char *port) { if(err || !ai) { ifdebug(SCARY_THINGS) - logger(LOG_DEBUG, "Unknown type address %s port %s", address, port); + logger(LOG_DEBUG, "Unknown type address %s port %s", address, port); result.sa.sa_family = AF_UNKNOWN; result.unknown.address = xstrdup(address); result.unknown.port = xstrdup(port); @@ -87,38 +83,28 @@ void sockaddr2str(const sockaddr_t *sa, char **addrstr, char **portstr) { int err; if(sa->sa.sa_family == AF_UNKNOWN) { - if(addrstr) { - *addrstr = xstrdup(sa->unknown.address); - } - - if(portstr) { - *portstr = xstrdup(sa->unknown.port); - } - + *addrstr = xstrdup(sa->unknown.address); + *portstr = xstrdup(sa->unknown.port); return; } - err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); + err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof address, port, sizeof port, NI_NUMERICHOST | NI_NUMERICSERV); if(err) { logger(LOG_ERR, "Error while translating addresses: %s", - gai_strerror(err)); + gai_strerror(err)); abort(); } scopeid = strchr(address, '%'); - if(scopeid) { - *scopeid = '\0'; /* Descope. */ - } + if(scopeid) + *scopeid = '\0'; /* Descope. */ - if(addrstr) { + if(addrstr) *addrstr = xstrdup(address); - } - - if(portstr) { + if(portstr) *portstr = xstrdup(port); - } } char *sockaddr2hostname(const sockaddr_t *sa) { @@ -132,12 +118,11 @@ char *sockaddr2hostname(const sockaddr_t *sa) { return str; } - err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port), - hostnames ? 0 : (NI_NUMERICHOST | NI_NUMERICSERV)); - + err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof address, port, sizeof port, + hostnames ? 0 : (NI_NUMERICHOST | NI_NUMERICSERV)); if(err) { logger(LOG_ERR, "Error while looking up hostname: %s", - gai_strerror(err)); + gai_strerror(err)); } xasprintf(&str, "%s port %s", address, port); @@ -150,27 +135,26 @@ int sockaddrcmp_noport(const sockaddr_t *a, const sockaddr_t *b) { result = a->sa.sa_family - b->sa.sa_family; - if(result) { + if(result) return result; - } - switch(a->sa.sa_family) { - case AF_UNSPEC: - return 0; + switch (a->sa.sa_family) { + case AF_UNSPEC: + return 0; - case AF_UNKNOWN: - return strcmp(a->unknown.address, b->unknown.address); + case AF_UNKNOWN: + return strcmp(a->unknown.address, b->unknown.address); - case AF_INET: - return memcmp(&a->in.sin_addr, &b->in.sin_addr, sizeof(a->in.sin_addr)); + case AF_INET: + return memcmp(&a->in.sin_addr, &b->in.sin_addr, sizeof(a->in.sin_addr)); - case AF_INET6: - return memcmp(&a->in6.sin6_addr, &b->in6.sin6_addr, sizeof(a->in6.sin6_addr)); + case AF_INET6: + return memcmp(&a->in6.sin6_addr, &b->in6.sin6_addr, sizeof(a->in6.sin6_addr)); - default: - logger(LOG_ERR, "sockaddrcmp() was called with unknown address family %d, exitting!", - a->sa.sa_family); - abort(); + default: + logger(LOG_ERR, "sockaddrcmp() was called with unknown address family %d, exitting!", + a->sa.sa_family); + abort(); } } @@ -179,45 +163,41 @@ int sockaddrcmp(const sockaddr_t *a, const sockaddr_t *b) { result = a->sa.sa_family - b->sa.sa_family; - if(result) { + if(result) return result; - } - switch(a->sa.sa_family) { - case AF_UNSPEC: - return 0; + switch (a->sa.sa_family) { + case AF_UNSPEC: + return 0; - case AF_UNKNOWN: - result = strcmp(a->unknown.address, b->unknown.address); + case AF_UNKNOWN: + result = strcmp(a->unknown.address, b->unknown.address); - if(result) { - return result; - } + if(result) + return result; - return strcmp(a->unknown.port, b->unknown.port); + return strcmp(a->unknown.port, b->unknown.port); - case AF_INET: - result = memcmp(&a->in.sin_addr, &b->in.sin_addr, sizeof(a->in.sin_addr)); + case AF_INET: + result = memcmp(&a->in.sin_addr, &b->in.sin_addr, sizeof a->in.sin_addr); - if(result) { - return result; - } + if(result) + return result; - return memcmp(&a->in.sin_port, &b->in.sin_port, sizeof(a->in.sin_port)); + return memcmp(&a->in.sin_port, &b->in.sin_port, sizeof a->in.sin_port); - case AF_INET6: - result = memcmp(&a->in6.sin6_addr, &b->in6.sin6_addr, sizeof(a->in6.sin6_addr)); + case AF_INET6: + result = memcmp(&a->in6.sin6_addr, &b->in6.sin6_addr, sizeof a->in6.sin6_addr); - if(result) { - return result; - } + if(result) + return result; - return memcmp(&a->in6.sin6_port, &b->in6.sin6_port, sizeof(a->in6.sin6_port)); + return memcmp(&a->in6.sin6_port, &b->in6.sin6_port, sizeof a->in6.sin6_port); - default: - logger(LOG_ERR, "sockaddrcmp() was called with unknown address family %d, exitting!", - a->sa.sa_family); - abort(); + default: + logger(LOG_ERR, "sockaddrcmp() was called with unknown address family %d, exitting!", + a->sa.sa_family); + abort(); } } @@ -237,7 +217,7 @@ void sockaddrfree(sockaddr_t *a) { free(a->unknown.port); } } - + void sockaddrunmap(sockaddr_t *sa) { if(sa->sa.sa_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&sa->in6.sin6_addr)) { sa->in.sin_addr.s_addr = ((uint32_t *) & sa->in6.sin6_addr)[3]; @@ -245,31 +225,6 @@ void sockaddrunmap(sockaddr_t *sa) { } } -void sockaddr_setport(sockaddr_t *sa, const char *port) { - uint16_t portnum = htons(atoi(port)); - - if(!portnum) { - return; - } - - switch(sa->sa.sa_family) { - case AF_INET: - sa->in.sin_port = portnum; - break; - - case AF_INET6: - sa->in6.sin6_port = portnum; - break; - - case AF_UNKNOWN: - free(sa->unknown.port); - sa->unknown.port = xstrdup(port); - - default: - return; - } -} - /* Subnet mask handling */ int maskcmp(const void *va, const void *vb, int masklen) { @@ -279,15 +234,13 @@ int maskcmp(const void *va, const void *vb, int masklen) { for(m = masklen, i = 0; m >= 8; m -= 8, i++) { result = a[i] - b[i]; - - if(result) { + if(result) return result; - } } if(m) return (a[i] & (0x100 - (1 << (8 - m)))) - - (b[i] & (0x100 - (1 << (8 - m)))); + (b[i] & (0x100 - (1 << (8 - m)))); return 0; } @@ -299,13 +252,11 @@ void mask(void *va, int masklen, int len) { i = masklen / 8; masklen %= 8; - if(masklen) { + if(masklen) a[i++] &= (0x100 - (1 << (8 - masklen))); - } - for(; i < len; i++) { + for(; i < len; i++) a[i] = 0; - } } void maskcpy(void *va, const void *vb, int masklen, int len) { @@ -313,18 +264,16 @@ void maskcpy(void *va, const void *vb, int masklen, int len) { char *a = va; const char *b = vb; - for(m = masklen, i = 0; m >= 8; m -= 8, i++) { + for(m = masklen, i = 0; m >= 8; m -= 8, i++) a[i] = b[i]; - } if(m) { a[i] = b[i] & (0x100 - (1 << (8 - m))); i++; } - for(; i < len; i++) { + for(; i < len; i++) a[i] = 0; - } } bool maskcheck(const void *va, int masklen, int len) { @@ -334,14 +283,12 @@ bool maskcheck(const void *va, int masklen, int len) { i = masklen / 8; masklen %= 8; - if(masklen && a[i++] & (0xff >> masklen)) { + if(masklen && a[i++] & (0xff >> masklen)) return false; - } for(; i < len; i++) - if(a[i] != 0) { + if(a[i] != 0) return false; - } return true; } diff --git a/src/netutl.h b/src/netutl.h index cc3ccab..7fc41e8 100644 --- a/src/netutl.h +++ b/src/netutl.h @@ -1,10 +1,7 @@ -#ifndef TINC_NETUTL_H -#define TINC_NETUTL_H - /* netutl.h -- header file for netutl.c Copyright (C) 1998-2005 Ivo Timmermans - 2000-2016 Guus Sliepen + 2000-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,23 +18,25 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_NETUTL_H__ +#define __TINC_NETUTL_H__ + #include "net.h" extern bool hostnames; -extern struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype); -extern sockaddr_t str2sockaddr(const char *address, const char *port); -extern void sockaddr2str(const sockaddr_t *sa, char **addrstr, char **portstr); -extern char *sockaddr2hostname(const sockaddr_t *sa); -extern int sockaddrcmp(const sockaddr_t *a, const sockaddr_t *b); -extern int sockaddrcmp_noport(const sockaddr_t *a, const sockaddr_t *b); -extern void sockaddrunmap(sockaddr_t *sa); -extern void sockaddrfree(sockaddr_t *sa); -extern void sockaddrcpy(sockaddr_t *dest, const sockaddr_t *src); -extern void sockaddr_setport(sockaddr_t *sa, const char *port); -extern int maskcmp(const void *a, const void *b, int masklen); -extern void maskcpy(void *dest, const void *src, int masklen, int len); -extern void mask(void *mask, int masklen, int len); -extern bool maskcheck(const void *mask, int masklen, int len); +extern struct addrinfo *str2addrinfo(const char *, const char *, int); +extern sockaddr_t str2sockaddr(const char *, const char *); +extern void sockaddr2str(const sockaddr_t *, char **, char **); +extern char *sockaddr2hostname(const sockaddr_t *); +extern int sockaddrcmp(const sockaddr_t *, const sockaddr_t *); +extern int sockaddrcmp_noport(const sockaddr_t *, const sockaddr_t *); +extern void sockaddrunmap(sockaddr_t *); +extern void sockaddrfree(sockaddr_t *); +extern void sockaddrcpy(sockaddr_t *, const sockaddr_t *); +extern int maskcmp(const void *, const void *, int); +extern void maskcpy(void *, const void *, int, int); +extern void mask(void *, int, int); +extern bool maskcheck(const void *, int, int); -#endif +#endif /* __TINC_NETUTL_H__ */ diff --git a/src/node.c b/src/node.c index 03be21c..38123e2 100644 --- a/src/node.c +++ b/src/node.c @@ -1,6 +1,6 @@ /* node.c -- node tree management - Copyright (C) 2001-2016 Guus Sliepen , + Copyright (C) 2001-2011 Guus Sliepen , 2001-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -20,7 +20,8 @@ #include "system.h" -#include "avl_tree.h" +#include "control_common.h" +#include "splay_tree.h" #include "logger.h" #include "net.h" #include "netutl.h" @@ -28,8 +29,8 @@ #include "utils.h" #include "xalloc.h" -avl_tree_t *node_tree; /* Known nodes, sorted by name */ -avl_tree_t *node_udp_tree; /* Known nodes, sorted by address and port */ +splay_tree_t *node_tree; /* Known nodes, sorted by name */ +splay_tree_t *node_udp_tree; /* Known nodes, sorted by address and port */ node_t *myself; @@ -38,35 +39,32 @@ static int node_compare(const node_t *a, const node_t *b) { } static int node_udp_compare(const node_t *a, const node_t *b) { - return sockaddrcmp(&a->address, &b->address); + int result; + + result = sockaddrcmp(&a->address, &b->address); + + if(result) + return result; + + return (a->name && b->name) ? strcmp(a->name, b->name) : 0; } void init_nodes(void) { - node_tree = avl_alloc_tree((avl_compare_t) node_compare, (avl_action_t) free_node); - node_udp_tree = avl_alloc_tree((avl_compare_t) node_udp_compare, NULL); + node_tree = splay_alloc_tree((splay_compare_t) node_compare, (splay_action_t) free_node); + node_udp_tree = splay_alloc_tree((splay_compare_t) node_udp_compare, NULL); } void exit_nodes(void) { - avl_delete_tree(node_udp_tree); - avl_delete_tree(node_tree); + splay_delete_tree(node_udp_tree); + splay_delete_tree(node_tree); } node_t *new_node(void) { - node_t *n = xmalloc_and_zero(sizeof(*n)); - - if(replaywin) { - n->late = xmalloc_and_zero(replaywin); - } + node_t *n = xmalloc_and_zero(sizeof *n); + if(replaywin) n->late = xmalloc_and_zero(replaywin); n->subnet_tree = new_subnet_tree(); n->edge_tree = new_edge_tree(); - n->inctx = EVP_CIPHER_CTX_new(); - n->outctx = EVP_CIPHER_CTX_new(); - - if(!n->inctx || !n->outctx) { - abort(); - } - n->mtu = MTU; n->maxmtu = MTU; @@ -74,52 +72,43 @@ node_t *new_node(void) { } void free_node(node_t *n) { - if(n->inkey) { - free(n->inkey); - } - - if(n->outkey) { - free(n->outkey); - } - - if(n->subnet_tree) { + if(n->subnet_tree) free_subnet_tree(n->subnet_tree); - } - if(n->edge_tree) { + if(n->edge_tree) free_edge_tree(n->edge_tree); - } sockaddrfree(&n->address); - EVP_CIPHER_CTX_free(n->outctx); - EVP_CIPHER_CTX_free(n->inctx); + cipher_close(&n->incipher); + digest_close(&n->indigest); + cipher_close(&n->outcipher); + digest_close(&n->outdigest); - if(n->mtuevent) { - event_del(n->mtuevent); - } + ecdh_free(&n->ecdh); + ecdsa_free(&n->ecdsa); - if(n->hostname) { + if(timeout_initialized(&n->mtuevent)) + event_del(&n->mtuevent); + + if(n->hostname) free(n->hostname); - } - if(n->name) { + if(n->name) free(n->name); - } - if(n->late) { + if(n->late) free(n->late); - } free(n); } void node_add(node_t *n) { - avl_insert(node_tree, n); + splay_insert(node_tree, n); } void node_del(node_t *n) { - avl_node_t *node, *next; + splay_node_t *node, *next; edge_t *e; subnet_t *s; @@ -135,25 +124,25 @@ void node_del(node_t *n) { edge_del(e); } - avl_delete(node_udp_tree, n); - avl_delete(node_tree, n); + splay_delete(node_udp_tree, n); + splay_delete(node_tree, n); } node_t *lookup_node(char *name) { - node_t n = {0}; + node_t n = {NULL}; n.name = name; - return avl_search(node_tree, &n); + return splay_search(node_tree, &n); } node_t *lookup_node_udp(const sockaddr_t *sa) { - node_t n = {0}; + node_t n = {NULL}; n.address = *sa; n.name = NULL; - return avl_search(node_udp_tree, &n); + return splay_search(node_udp_tree, &n); } void update_node_udp(node_t *n, const sockaddr_t *sa) { @@ -162,38 +151,48 @@ void update_node_udp(node_t *n, const sockaddr_t *sa) { return; } - avl_delete(node_udp_tree, n); + splay_delete(node_udp_tree, n); - if(n->hostname) { + if(n->hostname) free(n->hostname); - } if(sa) { n->address = *sa; n->hostname = sockaddr2hostname(&n->address); - avl_insert(node_udp_tree, n); + splay_insert(node_udp_tree, n); ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s set to %s", n->name, n->hostname); } else { - memset(&n->address, 0, sizeof(n->address)); + memset(&n->address, 0, sizeof n->address); n->hostname = NULL; ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s cleared", n->name); } } -void dump_nodes(void) { - avl_node_t *node; +bool dump_nodes(connection_t *c) { + splay_node_t *node; node_t *n; - logger(LOG_DEBUG, "Nodes:"); - for(node = node_tree->head; node; node = node->next) { n = node->data; - logger(LOG_DEBUG, " %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s pmtu %d (min %d max %d)", - n->name, n->hostname, n->outcipher ? EVP_CIPHER_nid(n->outcipher) : 0, - n->outdigest ? EVP_MD_type(n->outdigest) : 0, n->outmaclength, n->outcompression, - n->options, bitfield_to_int(&n->status, sizeof(n->status)), n->nexthop ? n->nexthop->name : "-", - n->via ? n->via->name : "-", n->mtu, n->minmtu, n->maxmtu); + send_request(c, "%d %d %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s distance %d pmtu %hd (min %hd max %hd)", CONTROL, REQ_DUMP_NODES, + n->name, n->hostname, cipher_get_nid(&n->outcipher), + digest_get_nid(&n->outdigest), (int)digest_length(&n->outdigest), n->outcompression, + n->options, bitfield_to_int(&n->status, sizeof n->status), n->nexthop ? n->nexthop->name : "-", + n->via ? n->via->name ?: "-" : "-", n->distance, n->mtu, n->minmtu, n->maxmtu); } - logger(LOG_DEBUG, "End of nodes."); + return send_request(c, "%d %d", CONTROL, REQ_DUMP_NODES); +} + +bool dump_traffic(connection_t *c) { + splay_node_t *node; + node_t *n; + + for(node = node_tree->head; node; node = node->next) { + n = node->data; + send_request(c, "%d %d %s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, CONTROL, REQ_DUMP_TRAFFIC, + n->name, n->in_packets, n->in_bytes, n->out_packets, n->out_bytes); + } + + return send_request(c, "%d %d", CONTROL, REQ_DUMP_TRAFFIC); } diff --git a/src/node.h b/src/node.h index b360fe5..0ce7542 100644 --- a/src/node.h +++ b/src/node.h @@ -1,9 +1,6 @@ -#ifndef TINC_NODE_H -#define TINC_NODE_H - /* node.h -- header for node.c - Copyright (C) 2001-2016 Guus Sliepen , + Copyright (C) 2001-2010 Guus Sliepen , 2001-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -21,86 +18,90 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "avl_tree.h" +#ifndef __TINC_NODE_H__ +#define __TINC_NODE_H__ + +#include "splay_tree.h" +#include "cipher.h" #include "connection.h" -#include "event.h" +#include "digest.h" +#include "ecdh.h" #include "subnet.h" typedef struct node_status_t { - unsigned int unused_active: 1; /* 1 if active (not used for nodes) */ - unsigned int validkey: 1; /* 1 if we currently have a valid key for him */ - unsigned int unused_waitingforkey: 1; /* 1 if we already sent out a request */ - unsigned int visited: 1; /* 1 if this node has been visited by one of the graph algorithms */ - unsigned int reachable: 1; /* 1 if this node is reachable in the graph */ - unsigned int indirect: 1; /* 1 if this node is not directly reachable by us */ - unsigned int unused: 26; + unsigned int unused_active:1; /* 1 if active (not used for nodes) */ + unsigned int validkey:1; /* 1 if we currently have a valid key for him */ + unsigned int unused_waitingforkey:1; /* 1 if we already sent out a request */ + unsigned int visited:1; /* 1 if this node has been visited by one of the graph algorithms */ + unsigned int reachable:1; /* 1 if this node is reachable in the graph */ + unsigned int indirect:1; /* 1 if this node is not directly reachable by us */ + unsigned int ecdh:1; /* 1 if this node supports ECDH key exchange */ + unsigned int unused:25; } node_status_t; typedef struct node_t { - char *name; /* name of this node */ - uint32_t options; /* options turned on for this node */ + char *name; /* name of this node */ + uint32_t options; /* options turned on for this node */ - int sock; /* Socket to use for outgoing UDP packets */ - sockaddr_t address; /* his real (internet) ip to send UDP packets to */ - char *hostname; /* the hostname of its real ip */ + sockaddr_t address; /* his real (internet) ip to send UDP packets to */ + char *hostname; /* the hostname of its real ip */ node_status_t status; time_t last_req_key; - const EVP_CIPHER *incipher; /* Cipher type for UDP packets received from him */ - char *inkey; /* Cipher key and iv */ - int inkeylength; /* Cipher key and iv length */ - EVP_CIPHER_CTX *inctx; /* Cipher context */ + ecdsa_t ecdsa; /* His public ECDSA key */ + ecdh_t ecdh; /* State for ECDH key exchange */ - const EVP_CIPHER *outcipher; /* Cipher type for UDP packets sent to him*/ - char *outkey; /* Cipher key and iv */ - int outkeylength; /* Cipher key and iv length */ - EVP_CIPHER_CTX *outctx; /* Cipher context */ + cipher_t incipher; /* Cipher for UDP packets */ + digest_t indigest; /* Digest for UDP packets */ - const EVP_MD *indigest; /* Digest type for MAC of packets received from him */ - int inmaclength; /* Length of MAC */ + cipher_t outcipher; /* Cipher for UDP packets */ + digest_t outdigest; /* Digest for UDP packets */ - const EVP_MD *outdigest; /* Digest type for MAC of packets sent to him*/ - int outmaclength; /* Length of MAC */ + int incompression; /* Compressionlevel, 0 = no compression */ + int outcompression; /* Compressionlevel, 0 = no compression */ - int incompression; /* Compressionlevel, 0 = no compression */ - int outcompression; /* Compressionlevel, 0 = no compression */ + int distance; + struct node_t *nexthop; /* nearest node from us to him */ + struct node_t *via; /* next hop for UDP packets */ - struct node_t *nexthop; /* nearest node from us to him */ - struct edge_t *prevedge; /* nearest node from him to us */ - struct node_t *via; /* next hop for UDP packets */ + splay_tree_t *subnet_tree; /* Pointer to a tree of subnets belonging to this node */ - avl_tree_t *subnet_tree; /* Pointer to a tree of subnets belonging to this node */ + splay_tree_t *edge_tree; /* Edges with this node as one of the endpoints */ - avl_tree_t *edge_tree; /* Edges with this node as one of the endpoints */ + struct connection_t *connection; /* Connection associated with this node (if a direct connection exists) */ - struct connection_t *connection; /* Connection associated with this node (if a direct connection exists) */ + uint32_t sent_seqno; /* Sequence number last sent to this node */ + uint32_t received_seqno; /* Sequence number last received from this node */ + uint32_t farfuture; /* Packets in a row that have arrived from the far future */ + unsigned char* late; /* Bitfield marking late packets */ - uint32_t sent_seqno; /* Sequence number last sent to this node */ - uint32_t received_seqno; /* Sequence number last received from this node */ - uint32_t farfuture; /* Packets in a row that have arrived from the far future */ - unsigned char *late; /* Bitfield marking late packets */ + length_t mtu; /* Maximum size of packets to send to this node */ + length_t minmtu; /* Probed minimum MTU */ + length_t maxmtu; /* Probed maximum MTU */ + int mtuprobes; /* Number of probes */ + struct event mtuevent; /* Probe event */ - length_t mtu; /* Maximum size of packets to send to this node */ - length_t minmtu; /* Probed minimum MTU */ - length_t maxmtu; /* Probed maximum MTU */ - int mtuprobes; /* Number of probes */ - event_t *mtuevent; /* Probe event */ + uint64_t in_packets; + uint64_t in_bytes; + uint64_t out_packets; + uint64_t out_bytes; } node_t; extern struct node_t *myself; -extern avl_tree_t *node_tree; -extern avl_tree_t *node_udp_tree; +extern splay_tree_t *node_tree; +extern splay_tree_t *node_udp_tree; extern void init_nodes(void); extern void exit_nodes(void); -extern node_t *new_node(void) __attribute__((__malloc__)); -extern void free_node(node_t *n); -extern void node_add(node_t *n); -extern void node_del(node_t *n); -extern node_t *lookup_node(char *name); -extern node_t *lookup_node_udp(const sockaddr_t *sa); -extern void update_node_udp(node_t *n, const sockaddr_t *sa); -extern void dump_nodes(void); +extern node_t *new_node(void) __attribute__ ((__malloc__)); +extern void free_node(node_t *); +extern void node_add(node_t *); +extern void node_del(node_t *); +extern node_t *lookup_node(char *); +extern node_t *lookup_node_udp(const sockaddr_t *); +extern bool dump_nodes(struct connection_t *); +extern bool dump_traffic(struct connection_t *); +extern void update_node_udp(node_t *, const sockaddr_t *); -#endif +#endif /* __TINC_NODE_H__ */ diff --git a/src/openssl/cipher.c b/src/openssl/cipher.c new file mode 100644 index 0000000..86a1aca --- /dev/null +++ b/src/openssl/cipher.c @@ -0,0 +1,146 @@ +/* + cipher.c -- Symmetric block cipher handling + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include +#include + +#include "cipher.h" +#include "logger.h" +#include "xalloc.h" + +static bool cipher_open(cipher_t *cipher) { + EVP_CIPHER_CTX_init(&cipher->ctx); + + return true; +} + +bool cipher_open_by_name(cipher_t *cipher, const char *name) { + cipher->cipher = EVP_get_cipherbyname(name); + + if(cipher->cipher) + return cipher_open(cipher); + + logger(LOG_ERR, "Unknown cipher name '%s'!", name); + return false; +} + +bool cipher_open_by_nid(cipher_t *cipher, int nid) { + cipher->cipher = EVP_get_cipherbynid(nid); + + if(cipher->cipher) + return cipher_open(cipher); + + logger(LOG_ERR, "Unknown cipher nid %d!", nid); + return false; +} + +bool cipher_open_blowfish_ofb(cipher_t *cipher) { + cipher->cipher = EVP_bf_ofb(); + return cipher_open(cipher); +} + +void cipher_close(cipher_t *cipher) { + EVP_CIPHER_CTX_cleanup(&cipher->ctx); +} + +size_t cipher_keylength(const cipher_t *cipher) { + return cipher->cipher->key_len + cipher->cipher->iv_len; +} + +bool cipher_set_key(cipher_t *cipher, void *key, bool encrypt) { + bool result; + + if(encrypt) + result = EVP_EncryptInit_ex(&cipher->ctx, cipher->cipher, NULL, (unsigned char *)key, (unsigned char *)key + cipher->cipher->key_len); + else + result = EVP_DecryptInit_ex(&cipher->ctx, cipher->cipher, NULL, (unsigned char *)key, (unsigned char *)key + cipher->cipher->key_len); + + if(result) + return true; + + logger(LOG_ERR, "Error while setting key: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; +} + +bool cipher_set_key_from_rsa(cipher_t *cipher, void *key, size_t len, bool encrypt) { + bool result; + + if(encrypt) + result = EVP_EncryptInit_ex(&cipher->ctx, cipher->cipher, NULL, (unsigned char *)key + len - cipher->cipher->key_len, (unsigned char *)key + len - cipher->cipher->iv_len - cipher->cipher->key_len); + else + result = EVP_DecryptInit_ex(&cipher->ctx, cipher->cipher, NULL, (unsigned char *)key + len - cipher->cipher->key_len, (unsigned char *)key + len - cipher->cipher->iv_len - cipher->cipher->key_len); + + if(result) + return true; + + logger(LOG_ERR, "Error while setting key: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; +} + +bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) { + if(oneshot) { + int len, pad; + if(EVP_EncryptInit_ex(&cipher->ctx, NULL, NULL, NULL, NULL) + && EVP_EncryptUpdate(&cipher->ctx, (unsigned char *)outdata, &len, indata, inlen) + && EVP_EncryptFinal(&cipher->ctx, (unsigned char *)outdata + len, &pad)) { + *outlen = len + pad; + return true; + } + } else { + int len; + if(EVP_EncryptUpdate(&cipher->ctx, outdata, &len, indata, inlen)) { + *outlen = len; + return true; + } + } + + logger(LOG_ERR, "Error while encrypting: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; +} + +bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) { + if(oneshot) { + int len, pad; + if(EVP_DecryptInit_ex(&cipher->ctx, NULL, NULL, NULL, NULL) + && EVP_DecryptUpdate(&cipher->ctx, (unsigned char *)outdata, &len, indata, inlen) + && EVP_DecryptFinal(&cipher->ctx, (unsigned char *)outdata + len, &pad)) { + *outlen = len + pad; + return true; + } + } else { + int len; + if(EVP_EncryptUpdate(&cipher->ctx, outdata, &len, indata, inlen)) { + *outlen = len; + return true; + } + } + + logger(LOG_ERR, "Error while decrypting: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; +} + +int cipher_get_nid(const cipher_t *cipher) { + return cipher->cipher ? cipher->cipher->nid : 0; +} + +bool cipher_active(const cipher_t *cipher) { + return cipher->cipher && cipher->cipher->nid != 0; +} diff --git a/src/openssl/cipher.h b/src/openssl/cipher.h new file mode 100644 index 0000000..380384a --- /dev/null +++ b/src/openssl/cipher.h @@ -0,0 +1,46 @@ +/* + cipher.h -- header file cipher.c + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_CIPHER_H__ +#define __TINC_CIPHER_H__ + +#include + +#define CIPHER_MAX_BLOCK_SIZE EVP_MAX_BLOCK_LENGTH +#define CIPHER_MAX_KEY_SIZE EVP_MAX_KEY_LENGTH +#define CIPHER_MAX_IV_SIZE EVP_MAX_IV_LENGTH + +typedef struct cipher { + EVP_CIPHER_CTX ctx; + const EVP_CIPHER *cipher; +} cipher_t; + +extern bool cipher_open_by_name(cipher_t *, const char *); +extern bool cipher_open_by_nid(cipher_t *, int); +extern bool cipher_open_blowfish_ofb(cipher_t *); +extern void cipher_close(cipher_t *); +extern size_t cipher_keylength(const cipher_t *); +extern bool cipher_set_key(cipher_t *, void *, bool); +extern bool cipher_set_key_from_rsa(cipher_t *, void *, size_t, bool); +extern bool cipher_encrypt(cipher_t *, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool); +extern bool cipher_decrypt(cipher_t *, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool); +extern int cipher_get_nid(const cipher_t *); +extern bool cipher_active(const cipher_t *); + +#endif diff --git a/src/openssl/crypto.c b/src/openssl/crypto.c new file mode 100644 index 0000000..db921d6 --- /dev/null +++ b/src/openssl/crypto.c @@ -0,0 +1,43 @@ +/* + crypto.c -- Cryptographic miscellaneous functions and initialisation + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include +#include +#include + +#include "crypto.h" + +void crypto_init(void) { + RAND_load_file("/dev/urandom", 1024); + + ENGINE_load_builtin_engines(); + ENGINE_register_all_complete(); + + OpenSSL_add_all_algorithms(); +} + +void crypto_exit(void) { + EVP_cleanup(); +} + +void randomize(void *out, size_t outlen) { + RAND_pseudo_bytes(out, outlen); +} diff --git a/src/openssl/crypto.h b/src/openssl/crypto.h new file mode 100644 index 0000000..8047bfb --- /dev/null +++ b/src/openssl/crypto.h @@ -0,0 +1,27 @@ +/* + crypto.h -- header for crypto.c + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_CRYPTO_H__ +#define __TINC_CRYPTO_H__ + +extern void crypto_init(); +extern void crypto_exit(); +extern void randomize(void *, size_t); + +#endif diff --git a/src/openssl/digest.c b/src/openssl/digest.c new file mode 100644 index 0000000..09ed666 --- /dev/null +++ b/src/openssl/digest.c @@ -0,0 +1,124 @@ +/* + digest.c -- Digest handling + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" +#include "utils.h" +#include "xalloc.h" + +#include +#include + +#include "digest.h" +#include "logger.h" + +static void set_maclength(digest_t *digest, int maclength) { + int digestlen = EVP_MD_size(digest->digest); + + if(maclength > digestlen || maclength < 0) + digest->maclength = digestlen; + else + digest->maclength = maclength; +} + +bool digest_open_by_name(digest_t *digest, const char *name, int maclength) { + digest->digest = EVP_get_digestbyname(name); + digest->key = NULL; + + if(!digest->digest) { + logger(LOG_DEBUG, "Unknown digest name '%s'!", name); + return false; + } + + set_maclength(digest, maclength); + return true; +} + +bool digest_open_by_nid(digest_t *digest, int nid, int maclength) { + digest->digest = EVP_get_digestbynid(nid); + digest->key = NULL; + + if(!digest->digest) { + logger(LOG_DEBUG, "Unknown digest nid %d!", nid); + return false; + } + + set_maclength(digest, maclength); + return true; +} + +bool digest_open_sha1(digest_t *digest, int maclength) { + digest->digest = EVP_sha1(); + digest->key = NULL; + + set_maclength(digest, maclength); + return true; +} + +bool digest_set_key(digest_t *digest, const void *key, size_t len) { + digest->key = xrealloc(digest->key, len); + memcpy(digest->key, key, len); + digest->keylength = len; + return true; +} + +void digest_close(digest_t *digest) { + if(digest->key) + free(digest->key); + digest->key = NULL; +} + +bool digest_create(digest_t *digest, const void *indata, size_t inlen, void *outdata) { + size_t len = EVP_MD_size(digest->digest); + unsigned char tmpdata[len]; + + if(digest->key) { + HMAC(digest->digest, digest->key, digest->keylength, indata, inlen, tmpdata, NULL); + } else { + EVP_MD_CTX ctx; + + if(!EVP_DigestInit(&ctx, digest->digest) + || !EVP_DigestUpdate(&ctx, indata, inlen) + || !EVP_DigestFinal(&ctx, tmpdata, NULL)) { + logger(LOG_DEBUG, "Error creating digest: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; + } + } + + memcpy(outdata, tmpdata, digest->maclength); + return true; +} + +bool digest_verify(digest_t *digest, const void *indata, size_t inlen, const void *cmpdata) { + size_t len = digest->maclength; + unsigned char outdata[len]; + + return digest_create(digest, indata, inlen, outdata) && !memcmp(cmpdata, outdata, digest->maclength); +} + +int digest_get_nid(const digest_t *digest) { + return digest->digest ? digest->digest->type : 0; +} + +size_t digest_length(const digest_t *digest) { + return digest->maclength; +} + +bool digest_active(const digest_t *digest) { + return digest->digest && digest->digest->type != 0; +} diff --git a/src/openssl/digest.h b/src/openssl/digest.h new file mode 100644 index 0000000..f3855c9 --- /dev/null +++ b/src/openssl/digest.h @@ -0,0 +1,45 @@ +/* + digest.h -- header file digest.c + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_DIGEST_H__ +#define __TINC_DIGEST_H__ + +#include + +#define DIGEST_MAX_SIZE EVP_MAX_MD_SIZE + +typedef struct digest { + const EVP_MD *digest; + int maclength; + int keylength; + char *key; +} digest_t; + +extern bool digest_open_by_name(struct digest *, const char *name, int maclength); +extern bool digest_open_by_nid(struct digest *, int nid, int maclength); +extern bool digest_open_sha1(struct digest *, int maclength); +extern void digest_close(struct digest *); +extern bool digest_create(struct digest *, const void *indata, size_t inlen, void *outdata); +extern bool digest_verify(struct digest *, const void *indata, size_t inlen, const void *digestdata); +extern bool digest_set_key(struct digest *, const void *key, size_t len); +extern int digest_get_nid(const struct digest *); +extern size_t digest_length(const struct digest *); +extern bool digest_active(const struct digest *); + +#endif diff --git a/src/openssl/ecdh.c b/src/openssl/ecdh.c new file mode 100644 index 0000000..4dd399f --- /dev/null +++ b/src/openssl/ecdh.c @@ -0,0 +1,84 @@ +/* + ecdh.c -- Diffie-Hellman key exchange handling + Copyright (C) 2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" +#include "utils.h" +#include "xalloc.h" + +#include +#include +#include + +#include "ecdh.h" +#include "logger.h" + +bool ecdh_generate_public(ecdh_t *ecdh, void *pubkey) { + *ecdh = EC_KEY_new_by_curve_name(NID_secp521r1); + if(!EC_KEY_generate_key(*ecdh)) { + logger(LOG_ERR, "Generating EC key failed: %s", ERR_error_string(ERR_get_error(), NULL)); + abort(); + } + + const EC_POINT *point = EC_KEY_get0_public_key(*ecdh); + if(!point) { + logger(LOG_ERR, "Getting public key failed: %s", ERR_error_string(ERR_get_error(), NULL)); + abort(); + } + + size_t result = EC_POINT_point2oct(EC_KEY_get0_group(*ecdh), point, POINT_CONVERSION_COMPRESSED, pubkey, ECDH_SIZE, NULL); + if(!result) { + logger(LOG_ERR, "Converting EC_POINT to binary failed: %s", ERR_error_string(ERR_get_error(), NULL)); + abort(); + } + + return true; +} + +bool ecdh_compute_shared(ecdh_t *ecdh, const void *pubkey, void *shared) { + EC_POINT *point = EC_POINT_new(EC_KEY_get0_group(*ecdh)); + if(!point) { + logger(LOG_ERR, "EC_POINT_new() failed: %s", ERR_error_string(ERR_get_error(), NULL)); + abort(); + } + + int result = EC_POINT_oct2point(EC_KEY_get0_group(*ecdh), point, pubkey, ECDH_SIZE, NULL); + if(!result) { + logger(LOG_ERR, "Converting binary to EC_POINT failed: %s", ERR_error_string(ERR_get_error(), NULL)); + abort(); + } + + result = ECDH_compute_key(shared, ECDH_SIZE, point, *ecdh, NULL); + EC_POINT_free(point); + EC_KEY_free(*ecdh); + *ecdh = NULL; + + if(!result) { + logger(LOG_ERR, "Computing Elliptic Curve Diffie-Hellman shared key failed: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; + } + + return true; +} + +void ecdh_free(ecdh_t *ecdh) { + if(*ecdh) { + EC_KEY_free(*ecdh); + *ecdh = NULL; + } +} diff --git a/src/proxy.h b/src/openssl/ecdh.h similarity index 58% rename from src/proxy.h rename to src/openssl/ecdh.h index a96fc3d..ef7de6e 100644 --- a/src/proxy.h +++ b/src/openssl/ecdh.h @@ -1,9 +1,6 @@ -#ifndef TINC_PROXY_H -#define TINC_PROXY_H - /* - proxy.h -- header for proxy.c - Copyright (C) 2015 Guus Sliepen + ecdh.h -- header file for ecdh.c + Copyright (C) 2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,24 +17,18 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "connection.h" +#ifndef __TINC_ECDH_H__ +#define __TINC_ECDH_H__ -typedef enum proxytype_t { - PROXY_NONE = 0, - PROXY_SOCKS4, - PROXY_SOCKS4A, - PROXY_SOCKS5, - PROXY_HTTP, - PROXY_EXEC, -} proxytype_t; +#include -extern proxytype_t proxytype; -extern char *proxyhost; -extern char *proxyport; -extern char *proxyuser; -extern char *proxypass; +#define ECDH_SIZE 67 +#define ECDH_SHARED_SIZE 66 -extern bool send_proxyrequest(struct connection_t *c); -extern int receive_proxy_meta(struct connection_t *c); +typedef EC_KEY *ecdh_t; + +extern bool ecdh_generate_public(ecdh_t *ecdh, void *pubkey); +extern bool ecdh_compute_shared(ecdh_t *ecdh, const void *pubkey, void *shared); +extern void ecdh_free(ecdh_t *ecdh); #endif diff --git a/src/openssl/ecdsa.c b/src/openssl/ecdsa.c new file mode 100644 index 0000000..43464d8 --- /dev/null +++ b/src/openssl/ecdsa.c @@ -0,0 +1,130 @@ +/* + ecdsa.c -- ECDSA key handling + Copyright (C) 2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include +#include + +#include "logger.h" +#include "ecdsa.h" +#include "utils.h" + +// Get and set ECDSA keys +// +bool ecdsa_set_base64_public_key(ecdsa_t *ecdsa, const char *p) { + *ecdsa = EC_KEY_new_by_curve_name(NID_secp521r1); + + int len = strlen(p); + unsigned char pubkey[len / 4 * 3 + 3]; + const unsigned char *ppubkey = pubkey; + len = b64decode(p, pubkey, len); + + if(!o2i_ECPublicKey(ecdsa, &ppubkey, len)) { + logger(LOG_DEBUG, "o2i_ECPublicKey failed: %s", ERR_error_string(ERR_get_error(), NULL)); + abort(); + } + + return true; +} + +char *ecdsa_get_base64_public_key(ecdsa_t *ecdsa) { + unsigned char *pubkey = NULL; + int len = i2o_ECPublicKey(*ecdsa, &pubkey); + + char *base64 = malloc(len * 4 / 3 + 5); + b64encode(pubkey, base64, len); + + free(pubkey); + + return base64; +} + +// Read PEM ECDSA keys + +bool ecdsa_read_pem_public_key(ecdsa_t *ecdsa, FILE *fp) { + *ecdsa = PEM_read_EC_PUBKEY(fp, ecdsa, NULL, NULL); + + if(*ecdsa) + return true; + + logger(LOG_ERR, "Unable to read ECDSA public key: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; +} + +bool ecdsa_read_pem_private_key(ecdsa_t *ecdsa, FILE *fp) { + *ecdsa = PEM_read_ECPrivateKey(fp, NULL, NULL, NULL); + + if(*ecdsa) + return true; + + logger(LOG_ERR, "Unable to read ECDSA private key: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; +} + +size_t ecdsa_size(ecdsa_t *ecdsa) { + return ECDSA_size(*ecdsa); +} + +// TODO: standardise output format? + +bool ecdsa_sign(ecdsa_t *ecdsa, const void *in, size_t len, void *sig) { + unsigned int siglen = ECDSA_size(*ecdsa); + + char hash[SHA512_DIGEST_LENGTH]; + SHA512(in, len, hash); + + memset(sig, 0, siglen); + + if(!ECDSA_sign(0, hash, sizeof hash, sig, &siglen, *ecdsa)) { + logger(LOG_DEBUG, "ECDSA_sign() failed: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; + } + + if(siglen != ECDSA_size(*ecdsa)) { + logger(LOG_ERR, "Signature length %d != %d", siglen, ECDSA_size(*ecdsa)); + } + + return true; +} + +bool ecdsa_verify(ecdsa_t *ecdsa, const void *in, size_t len, const void *sig) { + unsigned int siglen = ECDSA_size(*ecdsa); + + char hash[SHA512_DIGEST_LENGTH]; + SHA512(in, len, hash); + + if(!ECDSA_verify(0, hash, sizeof hash, sig, siglen, *ecdsa)) { + logger(LOG_DEBUG, "ECDSA_verify() failed: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; + } + + return true; +} + +bool ecdsa_active(ecdsa_t *ecdsa) { + return *ecdsa; +} + +void ecdsa_free(ecdsa_t *ecdsa) { + if(*ecdsa) { + EC_KEY_free(*ecdsa); + *ecdsa = NULL; + } +} diff --git a/src/openssl/ecdsa.h b/src/openssl/ecdsa.h new file mode 100644 index 0000000..04f9eb9 --- /dev/null +++ b/src/openssl/ecdsa.h @@ -0,0 +1,37 @@ +/* + ecdsa.h -- ECDSA key handling + Copyright (C) 2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_ECDSA_H__ +#define __TINC_ECDSA_H__ + +#include + +typedef EC_KEY *ecdsa_t; + +extern bool ecdsa_set_base64_public_key(ecdsa_t *ecdsa, const char *p); +extern char *ecdsa_get_base64_public_key(ecdsa_t *ecdsa); +extern bool ecdsa_read_pem_public_key(ecdsa_t *ecdsa, FILE *fp); +extern bool ecdsa_read_pem_private_key(ecdsa_t *ecdsa, FILE *fp); +extern size_t ecdsa_size(ecdsa_t *ecdsa); +extern bool ecdsa_sign(ecdsa_t *ecdsa, const void *in, size_t inlen, void *out); +extern bool ecdsa_verify(ecdsa_t *ecdsa, const void *in, size_t inlen, const void *out); +extern bool ecdsa_active(ecdsa_t *ecdsa); +extern void ecdsa_free(ecdsa_t *ecdsa); + +#endif diff --git a/src/openssl/ecdsagen.c b/src/openssl/ecdsagen.c new file mode 100644 index 0000000..86b79a2 --- /dev/null +++ b/src/openssl/ecdsagen.c @@ -0,0 +1,75 @@ +/* + ecdsagen.c -- ECDSA key generation and export + Copyright (C) 2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include +#include +#include + +#include "ecdsagen.h" +#include "utils.h" + +// Generate ECDSA key + +bool ecdsa_generate(ecdsa_t *ecdsa) { + *ecdsa = EC_KEY_new_by_curve_name(NID_secp521r1); + + if(!EC_KEY_generate_key(*ecdsa)) { + fprintf(stderr, "Generating EC key failed: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; + } + + EC_KEY_set_asn1_flag(*ecdsa, OPENSSL_EC_NAMED_CURVE); + EC_KEY_set_conv_form(*ecdsa, POINT_CONVERSION_COMPRESSED); + + return true; +} + +// Write PEM ECDSA keys + +bool ecdsa_write_pem_public_key(ecdsa_t *ecdsa, FILE *fp) { + BIO *out = BIO_new(BIO_s_file()); + BIO_set_fp(out,fp,BIO_NOCLOSE); + PEM_write_bio_EC_PUBKEY(out, *ecdsa); + BIO_free(out); + return true; +} + +bool ecdsa_write_pem_private_key(ecdsa_t *ecdsa, FILE *fp) { + BIO *out = BIO_new(BIO_s_file()); + BIO_set_fp(out,fp,BIO_NOCLOSE); + PEM_write_bio_ECPrivateKey(out, *ecdsa, NULL, NULL, 0, NULL, NULL); + BIO_free(out); + return true; +} + +// Convert ECDSA public key to base64 format + +char *ecdsa_get_base64_public_key(ecdsa_t *ecdsa) { + unsigned char *pubkey = NULL; + int len = i2o_ECPublicKey(*ecdsa, &pubkey); + + char *base64 = malloc(len * 4 / 3 + 5); + b64encode(pubkey, base64, len); + + free(pubkey); + + return base64; +} diff --git a/src/openssl/ecdsagen.h b/src/openssl/ecdsagen.h new file mode 100644 index 0000000..8a40e45 --- /dev/null +++ b/src/openssl/ecdsagen.h @@ -0,0 +1,30 @@ +/* + ecdsagen.h -- ECDSA key generation and export + Copyright (C) 2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_ECDSAGEN_H__ +#define __TINC_ECDSAGEN_H__ + +#include "ecdsa.h" + +extern bool ecdsa_generate(ecdsa_t *ecdsa); +extern bool ecdsa_write_pem_public_key(ecdsa_t *ecdsa, FILE *fp); +extern bool ecdsa_write_pem_private_key(ecdsa_t *ecdsa, FILE *fp); +extern char *ecdsa_get_base64_public_key(ecdsa_t *ecdsa); + +#endif diff --git a/src/openssl/prf.c b/src/openssl/prf.c new file mode 100644 index 0000000..df7f445 --- /dev/null +++ b/src/openssl/prf.c @@ -0,0 +1,76 @@ +/* + prf.c -- Pseudo-Random Function for key material generation + Copyright (C) 2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include "digest.h" +#include "prf.h" + +/* Generate key material from a master secret and a seed, based on RFC 4346 section 5. + We use SHA512 and Whirlpool instead of MD5 and SHA1. + */ + +static bool prf_xor(int nid, char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, ssize_t outlen) { + digest_t digest; + + if(!digest_open_by_nid(&digest, nid, -1)) + return false; + + if(!digest_set_key(&digest, secret, secretlen)) + return false; + + size_t len = digest_length(&digest); + + /* Data is what the "inner" HMAC function processes. + It consists of the previous HMAC result plus the seed. + */ + + char data[len + seedlen]; + memset(data, 0, len); + memcpy(data + len, seed, seedlen); + + char hash[len]; + + while(outlen > 0) { + /* Inner HMAC */ + digest_create(&digest, data, len + seedlen, data); + + /* Outer HMAC */ + digest_create(&digest, data, len + seedlen, hash); + + /* XOR the results of the outer HMAC into the out buffer */ + for(int i = 0; i < len && i < outlen; i++) + *out++ ^= hash[i]; + + outlen -= len; + } + + digest_close(&digest); + return true; +} + +bool prf(char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen) { + /* Split secret in half, generate outlen bits with two different hash algorithms, + and XOR the results. */ + + memset(out, 0, outlen); + + return prf_xor(NID_sha512, secret, (secretlen + 1) / 2, seed, seedlen, out, outlen) + && prf_xor(NID_whirlpool, secret + secretlen / 2, (secretlen + 1) / 2, seed, seedlen, out, outlen); +} diff --git a/src/openssl/prf.h b/src/openssl/prf.h new file mode 100644 index 0000000..264d198 --- /dev/null +++ b/src/openssl/prf.h @@ -0,0 +1,25 @@ +/* + prf.h -- header file for prf.c + Copyright (C) 2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_PRF_H__ +#define __TINC_PRF_H__ + +extern bool prf(char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen); + +#endif diff --git a/src/openssl/rsa.c b/src/openssl/rsa.c new file mode 100644 index 0000000..c3ea692 --- /dev/null +++ b/src/openssl/rsa.c @@ -0,0 +1,101 @@ +/* + rsa.c -- RSA key handling + Copyright (C) 2007 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include +#include + +#include "logger.h" +#include "rsa.h" + +// Set RSA keys + +bool rsa_set_hex_public_key(rsa_t *rsa, char *n, char *e) { + *rsa = RSA_new(); + BN_hex2bn(&(*rsa)->n, n); + BN_hex2bn(&(*rsa)->e, e); + return true; +} + +bool rsa_set_hex_private_key(rsa_t *rsa, char *n, char *e, char *d) { + *rsa = RSA_new(); + BN_hex2bn(&(*rsa)->n, n); + BN_hex2bn(&(*rsa)->e, e); + BN_hex2bn(&(*rsa)->d, d); + return true; +} + +// Read PEM RSA keys + +bool rsa_read_pem_public_key(rsa_t *rsa, FILE *fp) { + *rsa = PEM_read_RSAPublicKey(fp, rsa, NULL, NULL); + + if(*rsa) + return true; + + *rsa = PEM_read_RSA_PUBKEY(fp, rsa, NULL, NULL); + + if(*rsa) + return true; + + logger(LOG_ERR, "Unable to read RSA public key: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; +} + +bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp) { + *rsa = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL); + + if(*rsa) + return true; + + logger(LOG_ERR, "Unable to read RSA private key: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; +} + +size_t rsa_size(rsa_t *rsa) { + return RSA_size(*rsa); +} + +bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t len, void *out) { + if(RSA_public_encrypt(len, in, out, *rsa, RSA_NO_PADDING) == len) + return true; + + logger(LOG_ERR, "Unable to perform RSA encryption: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; +} + +bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t len, void *out) { + if(RSA_private_decrypt(len, in, out, *rsa, RSA_NO_PADDING) == len) + return true; + + logger(LOG_ERR, "Unable to perform RSA decryption: %s", ERR_error_string(ERR_get_error(), NULL)); + return false; +} + +bool rsa_active(rsa_t *rsa) { + return *rsa; +} + +void rsa_free(rsa_t *rsa) { + if(*rsa) { + RSA_free(*rsa); + *rsa = NULL; + } +} diff --git a/src/event.h b/src/openssl/rsa.h similarity index 50% rename from src/event.h rename to src/openssl/rsa.h index 6d521bb..10fe346 100644 --- a/src/event.h +++ b/src/openssl/rsa.h @@ -1,10 +1,6 @@ -#ifndef TINC_EVENT_H -#define TINC_EVENT_H - /* - event.h -- header for event.c - Copyright (C) 2002-2009 Guus Sliepen , - 2002-2005 Ivo Timmermans + rsa.h -- RSA key handling + Copyright (C) 2007 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,27 +17,22 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "avl_tree.h" +#ifndef __TINC_RSA_H__ +#define __TINC_RSA_H__ -extern avl_tree_t *event_tree; +#include -typedef void (*event_handler_t)(void *); +typedef RSA *rsa_t; -typedef struct event { - time_t time; - int id; - event_handler_t handler; - void *data; -} event_t; +extern bool rsa_set_hex_public_key(rsa_t *rsa, char *n, char *e); +extern bool rsa_set_hex_private_key(rsa_t *rsa, char *n, char *e, char *d); +extern bool rsa_read_pem_public_key(rsa_t *rsa, FILE *fp); +extern bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp); +extern size_t rsa_size(rsa_t *rsa); +extern bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t inlen, void *out); +extern bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t inlen, void *out); +extern bool rsa_active(rsa_t *rsa); +extern void rsa_free(rsa_t *rsa); -extern void init_events(void); -extern void exit_events(void); -extern void expire_events(void); -extern event_t *new_event(void) __attribute__((__malloc__)); -extern void free_event(event_t *event); -extern void event_add(event_t *event); -extern void event_del(event_t *event); -extern event_t *get_expired_event(void); -extern event_t *peek_next_event(void); #endif diff --git a/src/openssl/rsagen.c b/src/openssl/rsagen.c new file mode 100644 index 0000000..0f4a4fa --- /dev/null +++ b/src/openssl/rsagen.c @@ -0,0 +1,83 @@ +/* + rsagen.c -- RSA key generation and export + Copyright (C) 2008 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include +#include + +#include "logger.h" +#include "rsagen.h" + +/* This function prettyprints the key generation process */ + +static void indicator(int a, int b, void *p) { + switch (a) { + case 0: + fprintf(stderr, "."); + break; + + case 1: + fprintf(stderr, "+"); + break; + + case 2: + fprintf(stderr, "-"); + break; + + case 3: + switch (b) { + case 0: + fprintf(stderr, " p\n"); + break; + + case 1: + fprintf(stderr, " q\n"); + break; + + default: + fprintf(stderr, "?"); + } + break; + + default: + fprintf(stderr, "?"); + } +} + +// Generate RSA key + +bool rsa_generate(rsa_t *rsa, size_t bits, unsigned long exponent) { + *rsa = RSA_generate_key(bits, exponent, indicator, NULL); + + return *rsa; +} + +// Write PEM RSA keys + +bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp) { + PEM_write_RSAPublicKey(fp, *rsa); + + return true; +} + +bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) { + PEM_write_RSAPrivateKey(fp, *rsa, NULL, NULL, 0, NULL, NULL); + return true; +} diff --git a/src/openssl/rsagen.h b/src/openssl/rsagen.h new file mode 100644 index 0000000..422d156 --- /dev/null +++ b/src/openssl/rsagen.h @@ -0,0 +1,29 @@ +/* + rsagen.h -- RSA key generation and export + Copyright (C) 2008 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_RSAGEN_H__ +#define __TINC_RSAGEN_H__ + +#include "rsa.h" + +extern bool rsa_generate(rsa_t *rsa, size_t bits, unsigned long exponent); +extern bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp); +extern bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp); + +#endif diff --git a/src/pidfile.c b/src/pidfile.c deleted file mode 100644 index dd17267..0000000 --- a/src/pidfile.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - pidfile.c - interact with pidfiles - Copyright (c) 1995 Martin Schulze - - This file is part of the sysklogd package, a kernel and system log daemon. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -/* left unaltered for tinc -- Ivo Timmermans */ -/* - * Sat Aug 19 13:24:33 MET DST 1995: Martin Schulze - * First version (v0.2) released - */ - -#include "system.h" - -#include "pidfile.h" - -#ifndef HAVE_MINGW -/* read_pid - * - * Reads the specified pidfile and returns the read pid. - * 0 is returned if either there's no pidfile, it's empty - * or no pid can be read. - */ -pid_t read_pid(const char *pidfile) { - FILE *f; - long pid; - - if(!(f = fopen(pidfile, "r"))) { - return 0; - } - - if(fscanf(f, "%20ld", &pid) != 1) { - pid = 0; - } - - fclose(f); - return (pid_t)pid; -} - -/* check_pid - * - * Reads the pid using read_pid and looks up the pid in the process - * table (using /proc) to determine if the process already exists. If - * so the pid is returned, otherwise 0. - */ -pid_t check_pid(const char *pidfile) { - pid_t pid = read_pid(pidfile); - - /* Amazing ! _I_ am already holding the pid file... */ - if((!pid) || (pid == getpid())) { - return 0; - } - - /* - * The 'standard' method of doing this is to try and do a 'fake' kill - * of the process. If an ESRCH error is returned the process cannot - * be found -- GW - */ - /* But... errno is usually changed only on error.. */ - errno = 0; - - if(kill(pid, 0) && errno == ESRCH) { - return 0; - } - - return pid; -} - -/* write_pid - * - * Writes the pid to the specified file. If that fails 0 is - * returned, otherwise the pid. - */ -pid_t write_pid(const char *pidfile) { - FILE *f; - int fd; - pid_t pid; - - if((fd = open(pidfile, O_RDWR | O_CREAT, 0644)) == -1) { - return 0; - } - - if((f = fdopen(fd, "r+")) == NULL) { - close(fd); - return 0; - } - -#ifdef HAVE_FLOCK - - if(flock(fd, LOCK_EX | LOCK_NB) == -1) { - fclose(f); - return 0; - } - -#endif - - pid = getpid(); - - if(!fprintf(f, "%ld\n", (long)pid)) { - fclose(f); - return 0; - } - - fflush(f); - -#ifdef HAVE_FLOCK - - if(flock(fd, LOCK_UN) == -1) { - fclose(f); - return 0; - } - -#endif - fclose(f); - - return pid; -} - -/* remove_pid - * - * Remove the the specified file. The result from unlink(2) - * is returned - */ -int remove_pid(const char *pidfile) { - return unlink(pidfile); -} -#endif diff --git a/src/pidfile.h b/src/pidfile.h deleted file mode 100644 index 7d71cc2..0000000 --- a/src/pidfile.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef TINC_PIDFILE_H -#define TINC_PIDFILE_H - -/* - pidfile.h - interact with pidfiles - Copyright (c) 1995 Martin Schulze - - This file is part of the sysklogd package, a kernel and system log daemon. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#ifndef HAVE_MINGW -/* read_pid - * - * Reads the specified pidfile and returns the read pid. - * 0 is returned if either there's no pidfile, it's empty - * or no pid can be read. - */ -extern pid_t read_pid(const char *pidfile); - -/* check_pid - * - * Reads the pid using read_pid and looks up the pid in the process - * table (using /proc) to determine if the process already exists. If - * so 1 is returned, otherwise 0. - */ -extern pid_t check_pid(const char *pidfile); - -/* write_pid - * - * Writes the pid to the specified file. If that fails 0 is - * returned, otherwise the pid. - */ -extern pid_t write_pid(const char *pidfile); - -/* remove_pid - * - * Remove the the specified file. The result from unlink(2) - * is returned - */ -extern int remove_pid(const char *pidfile); -#endif - -#endif diff --git a/src/process.c b/src/process.c index 13d1007..a7d0f26 100644 --- a/src/process.c +++ b/src/process.c @@ -1,7 +1,7 @@ /* process.c -- process management functions Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2015 Guus Sliepen + 2000-2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,12 +22,12 @@ #include "conf.h" #include "connection.h" +#include "control.h" #include "device.h" #include "edge.h" #include "logger.h" #include "net.h" #include "node.h" -#include "pidfile.h" #include "process.h" #include "subnet.h" #include "utils.h" @@ -35,18 +35,12 @@ /* If zero, don't detach from the terminal. */ bool do_detach = true; -bool sighup = false; bool sigalrm = false; extern char *identname; -extern char *pidfilename; extern char **g_argv; extern bool use_logfile; -#ifndef HAVE_MINGW -static sigset_t emptysigset; -#endif - /* Some functions the less gifted operating systems might lack... */ #ifdef HAVE_MINGW @@ -59,54 +53,49 @@ static SC_HANDLE service = NULL; static SERVICE_STATUS status = {0}; static SERVICE_STATUS_HANDLE statushandle = 0; -bool install_service(void) { +static bool install_service(void) { char command[4096] = "\""; char **argp; bool space; SERVICE_DESCRIPTION description = {"Virtual Private Network daemon"}; manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if(!manager) { logger(LOG_ERR, "Could not open service manager: %s", winerror(GetLastError())); return false; } if(!strchr(program_name, '\\')) { - GetCurrentDirectory(sizeof(command) - 1, command + 1); - strncat(command, "\\", sizeof(command) - strlen(command)); + GetCurrentDirectory(sizeof command - 1, command + 1); + strncat(command, "\\", sizeof command - strlen(command)); } - strncat(command, program_name, sizeof(command) - strlen(command)); + strncat(command, program_name, sizeof command - strlen(command)); - strncat(command, "\"", sizeof(command) - strlen(command)); + strncat(command, "\"", sizeof command - strlen(command)); for(argp = g_argv + 1; *argp; argp++) { space = strchr(*argp, ' '); - strncat(command, " ", sizeof(command) - strlen(command)); + strncat(command, " ", sizeof command - strlen(command)); + + if(space) + strncat(command, "\"", sizeof command - strlen(command)); + + strncat(command, *argp, sizeof command - strlen(command)); - if(space) { - strncat(command, "\"", sizeof(command) - strlen(command)); - } - - strncat(command, *argp, sizeof(command) - strlen(command)); - - if(space) { - strncat(command, "\"", sizeof(command) - strlen(command)); - } + if(space) + strncat(command, "\"", sizeof command - strlen(command)); } service = CreateService(manager, identname, identname, - SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, - command, NULL, NULL, NULL, NULL, NULL); - + SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, + command, NULL, NULL, NULL, NULL, NULL); + if(!service) { DWORD lasterror = GetLastError(); logger(LOG_ERR, "Could not create %s service: %s", identname, winerror(lasterror)); - - if(lasterror != ERROR_SERVICE_EXISTS) { + if(lasterror != ERROR_SERVICE_EXISTS) return false; - } } if(service) { @@ -116,106 +105,67 @@ bool install_service(void) { service = OpenService(manager, identname, SERVICE_ALL_ACCESS); } - if(!StartService(service, 0, NULL)) { + if(!StartService(service, 0, NULL)) logger(LOG_WARNING, "Could not start %s service: %s", identname, winerror(GetLastError())); - } else { + else logger(LOG_INFO, "%s service started", identname); - } - - return true; -} - -bool remove_service(void) { - manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - - if(!manager) { - logger(LOG_ERR, "Could not open service manager: %s", winerror(GetLastError())); - return false; - } - - service = OpenService(manager, identname, SERVICE_ALL_ACCESS); - - if(!service) { - logger(LOG_ERR, "Could not open %s service: %s", identname, winerror(GetLastError())); - return false; - } - - if(!ControlService(service, SERVICE_CONTROL_STOP, &status)) { - logger(LOG_ERR, "Could not stop %s service: %s", identname, winerror(GetLastError())); - } else { - logger(LOG_INFO, "%s service stopped", identname); - } - - if(!DeleteService(service)) { - logger(LOG_ERR, "Could not remove %s service: %s", identname, winerror(GetLastError())); - return false; - } - - logger(LOG_INFO, "%s service removed", identname); return true; } DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID boe, LPVOID bah) { switch(request) { - case SERVICE_CONTROL_INTERROGATE: - SetServiceStatus(statushandle, &status); - return NO_ERROR; - - case SERVICE_CONTROL_STOP: - logger(LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_STOP"); - break; - - case SERVICE_CONTROL_SHUTDOWN: - logger(LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_SHUTDOWN"); - break; - - default: - logger(LOG_WARNING, "Got unexpected request %d", (int)request); - return ERROR_CALL_NOT_IMPLEMENTED; - } - - if(running) { - running = false; - status.dwWaitHint = 30000; - status.dwCurrentState = SERVICE_STOP_PENDING; - SetServiceStatus(statushandle, &status); - return NO_ERROR; - } else { - status.dwWaitHint = 0; - status.dwCurrentState = SERVICE_STOPPED; - SetServiceStatus(statushandle, &status); - exit(1); + case SERVICE_CONTROL_INTERROGATE: + SetServiceStatus(statushandle, &status); + return NO_ERROR; + case SERVICE_CONTROL_STOP: + logger(LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_STOP"); + break; + case SERVICE_CONTROL_SHUTDOWN: + logger(LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_SHUTDOWN"); + break; + default: + logger(LOG_WARNING, "Got unexpected request %d", request); + return ERROR_CALL_NOT_IMPLEMENTED; } + event_loopexit(NULL); + status.dwWaitHint = 30000; + status.dwCurrentState = SERVICE_STOP_PENDING; + SetServiceStatus(statushandle, &status); + return NO_ERROR; } -VOID WINAPI run_service(DWORD argc, LPTSTR *argv) { +VOID WINAPI run_service(DWORD argc, LPTSTR* argv) { + int err = 1; extern int main2(int argc, char **argv); - status.dwServiceType = SERVICE_WIN32; + + status.dwServiceType = SERVICE_WIN32; status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; - status.dwWin32ExitCode = 0; - status.dwServiceSpecificExitCode = 0; - status.dwCheckPoint = 0; + status.dwWin32ExitCode = 0; + status.dwServiceSpecificExitCode = 0; + status.dwCheckPoint = 0; - statushandle = RegisterServiceCtrlHandlerEx(identname, controlhandler, NULL); + statushandle = RegisterServiceCtrlHandlerEx(identname, controlhandler, NULL); - if(!statushandle) { + if (!statushandle) { logger(LOG_ERR, "System call `%s' failed: %s", "RegisterServiceCtrlHandlerEx", winerror(GetLastError())); + err = 1; } else { - status.dwWaitHint = 30000; - status.dwCurrentState = SERVICE_START_PENDING; + status.dwWaitHint = 30000; + status.dwCurrentState = SERVICE_START_PENDING; SetServiceStatus(statushandle, &status); - status.dwWaitHint = 0; + status.dwWaitHint = 0; status.dwCurrentState = SERVICE_RUNNING; SetServiceStatus(statushandle, &status); - main2(argc, argv); + err = main2(argc, argv); status.dwWaitHint = 0; - status.dwCurrentState = SERVICE_STOPPED; + status.dwCurrentState = SERVICE_STOPPED; + //status.dwWin32ExitCode = err; SetServiceStatus(statushandle, &status); } @@ -231,39 +181,9 @@ bool init_service(void) { if(!StartServiceCtrlDispatcher(services)) { if(GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) { return false; - } else { + } + else logger(LOG_ERR, "System call `%s' failed: %s", "StartServiceCtrlDispatcher", winerror(GetLastError())); - } - } - - return true; -} -#endif - -#ifndef HAVE_MINGW -/* - check for an existing tinc for this net, and write pid to pidfile -*/ -static bool write_pidfile(void) { - pid_t pid; - - pid = check_pid(pidfilename); - - if(pid) { - if(netname) - fprintf(stderr, "A tincd is already running for net `%s' with pid %ld.\n", - netname, (long)pid); - else { - fprintf(stderr, "A tincd is already running with pid %ld.\n", (long)pid); - } - - return false; - } - - /* if it's locked, write-protected, or whatever */ - if(!write_pid(pidfilename)) { - fprintf(stderr, "Couldn't write pid file %s: %s\n", pidfilename, strerror(errno)); - return false; } return true; @@ -271,193 +191,72 @@ static bool write_pidfile(void) { #endif /* - kill older tincd for this net -*/ -bool kill_other(int signal) { -#ifndef HAVE_MINGW - pid_t pid; - - pid = read_pid(pidfilename); - - if(!pid) { - if(netname) - fprintf(stderr, "No other tincd is running for net `%s'.\n", - netname); - else { - fprintf(stderr, "No other tincd is running.\n"); - } - - return false; - } - - errno = 0; /* No error, sometimes errno is only changed on error */ - - /* ESRCH is returned when no process with that pid is found */ - if(kill(pid, signal) && errno == ESRCH) { - if(netname) - fprintf(stderr, "The tincd for net `%s' is no longer running. ", - netname); - else { - fprintf(stderr, "The tincd is no longer running. "); - } - - fprintf(stderr, "Removing stale lock file.\n"); - remove_pid(pidfilename); - } - - return true; -#else - return remove_service(); -#endif -} - -/* - Detach from current terminal, write pidfile, kill parent + Detach from current terminal */ bool detach(void) { - setup_signals(); - - /* First check if we can open a fresh new pidfile */ - #ifndef HAVE_MINGW - - if(!write_pidfile()) { - return false; - } - - /* If we succeeded in doing that, detach */ + signal(SIGPIPE, SIG_IGN); + signal(SIGUSR1, SIG_IGN); + signal(SIGUSR2, SIG_IGN); + signal(SIGWINCH, SIG_IGN); closelogger(); #endif if(do_detach) { #ifndef HAVE_MINGW - if(daemon(0, 0)) { fprintf(stderr, "Couldn't detach from terminal: %s", - strerror(errno)); + strerror(errno)); return false; } - - /* Now UPDATE the pid in the pidfile, because we changed it... */ - - if(!write_pid(pidfilename)) { - fprintf(stderr, "Could not write pid file %s: %s\n", pidfilename, strerror(errno)); - return false; - } - #else - - if(!statushandle) { + if(!statushandle) exit(install_service()); - } - #endif } - openlogger(identname, use_logfile ? LOGMODE_FILE : (do_detach ? LOGMODE_SYSLOG : LOGMODE_STDERR)); + openlogger(identname, use_logfile?LOGMODE_FILE:(do_detach?LOGMODE_SYSLOG:LOGMODE_STDERR)); - logger(LOG_NOTICE, "tincd %s starting, debug level %d", - VERSION, debug_level); + logger(LOG_NOTICE, "tincd %s (%s %s) starting, debug level %d", + VERSION, __DATE__, __TIME__, debug_level); return true; } -#ifdef HAVE_PUTENV -void unputenv(char *p) { - char *e = strchr(p, '='); - - if(!e) { - return; - } - - int len = e - p; -#ifndef HAVE_UNSETENV -#ifdef HAVE_MINGW - // Windows requires putenv("FOO=") to unset %FOO% - len++; -#endif -#endif - char var[len + 1]; - memcpy(var, p, len); - var[len] = 0; -#ifdef HAVE_UNSETENV - unsetenv(var); -#else - // We must keep what we putenv() around in memory. - // To do this without memory leaks, keep things in a list and reuse if possible. - static list_t list = {}; - - for(list_node_t *node = list.head; node; node = node->next) { - char *data = node->data; - - if(!strcmp(data, var)) { - putenv(data); - return; - } - } - - char *data = xstrdup(var); - list_insert_tail(&list, data); - putenv(data); -#endif -} -#else -void putenv(const char *p) {} -void unputenv(const char *p) {} -#endif - bool execute_script(const char *name, char **envp) { #ifdef HAVE_SYSTEM + int status, len; char *scriptname; - char *interpreter = NULL; - config_t *cfg_interpreter; - int status, len, i; + int i; - cfg_interpreter = lookup_config(config_tree, "ScriptsInterpreter"); #ifndef HAVE_MINGW len = xasprintf(&scriptname, "\"%s/%s\"", confbase, name); #else - - if(cfg_interpreter) { - len = xasprintf(&scriptname, "\"%s/%s\"", confbase, name); - } else { - len = xasprintf(&scriptname, "\"%s/%s.bat\"", confbase, name); - } - + len = xasprintf(&scriptname, "\"%s/%s.bat\"", confbase, name); #endif - - if(len < 0) { + if(len < 0) return false; - } scriptname[len - 1] = '\0'; +#ifndef HAVE_TUNEMU /* First check if there is a script */ + if(access(scriptname + 1, F_OK)) { free(scriptname); return true; } - - // Custom scripts interpreter - if(get_config_string(cfg_interpreter, &interpreter)) { - // Force custom scripts interpreter allowing execution of scripts on android without execution flag (such as on /sdcard) - free(scriptname); - len = xasprintf(&scriptname, "%s \"%s/%s\"", interpreter, confbase, name); - free(interpreter); - - if(len < 0) { - return false; - } - } +#endif ifdebug(STATUS) logger(LOG_INFO, "Executing script %s", name); +#ifdef HAVE_PUTENV /* Set environment */ - - for(i = 0; envp[i]; i++) { + + for(i = 0; envp[i]; i++) putenv(envp[i]); - } +#endif scriptname[len - 1] = '\"'; status = system(scriptname); @@ -467,212 +266,36 @@ bool execute_script(const char *name, char **envp) { /* Unset environment */ for(i = 0; envp[i]; i++) { - unputenv(envp[i]); + char *e = strchr(envp[i], '='); + if(e) { + char p[e - envp[i] + 1]; + strncpy(p, envp[i], e - envp[i]); + p[e - envp[i]] = '\0'; + putenv(p); + } } - if(status != -1) { #ifdef WEXITSTATUS - - if(WIFEXITED(status)) { /* Child exited by itself */ + if(status != -1) { + if(WIFEXITED(status)) { /* Child exited by itself */ if(WEXITSTATUS(status)) { logger(LOG_ERR, "Script %s exited with non-zero status %d", - name, WEXITSTATUS(status)); + name, WEXITSTATUS(status)); return false; } - } else if(WIFSIGNALED(status)) { /* Child was killed by a signal */ + } else if(WIFSIGNALED(status)) { /* Child was killed by a signal */ logger(LOG_ERR, "Script %s was killed by signal %d (%s)", - name, WTERMSIG(status), strsignal(WTERMSIG(status))); + name, WTERMSIG(status), strsignal(WTERMSIG(status))); return false; - } else { /* Something strange happened */ + } else { /* Something strange happened */ logger(LOG_ERR, "Script %s terminated abnormally", name); return false; } - -#endif } else { logger(LOG_ERR, "System call `%s' failed: %s", "system", strerror(errno)); return false; } - +#endif #endif return true; } - - -/* - Signal handlers. -*/ - -#ifndef HAVE_MINGW -static RETSIGTYPE sigterm_handler(int a) { - (void)a; - logger(LOG_NOTICE, "Got %s signal", "TERM"); - - if(running) { - running = false; - } else { - exit(1); - } -} - -static RETSIGTYPE sigquit_handler(int a) { - (void)a; - logger(LOG_NOTICE, "Got %s signal", "QUIT"); - - if(running) { - running = false; - } else { - exit(1); - } -} - -static RETSIGTYPE fatal_signal_square(int a) { - logger(LOG_ERR, "Got another fatal signal %d (%s): not restarting.", a, - strsignal(a)); - exit(1); -} - -static RETSIGTYPE fatal_signal_handler(int a) { - struct sigaction act; - logger(LOG_ERR, "Got fatal signal %d (%s)", a, strsignal(a)); - - if(do_detach) { - logger(LOG_NOTICE, "Trying to re-execute in 5 seconds..."); - - act.sa_handler = fatal_signal_square; - act.sa_mask = emptysigset; - act.sa_flags = 0; - sigaction(SIGSEGV, &act, NULL); - - close_network_connections(); - sleep(5); - remove_pid(pidfilename); - execvp(g_argv[0], g_argv); - } else { - logger(LOG_NOTICE, "Not restarting."); - exit(1); - } -} - -static RETSIGTYPE sighup_handler(int a) { - (void)a; - logger(LOG_NOTICE, "Got %s signal", "HUP"); - sighup = true; -} - -static RETSIGTYPE sigint_handler(int a) { - (void)a; - static int saved_debug_level = -1; - - logger(LOG_NOTICE, "Got %s signal", "INT"); - - if(saved_debug_level != -1) { - logger(LOG_NOTICE, "Reverting to old debug level (%d)", - saved_debug_level); - debug_level = saved_debug_level; - saved_debug_level = -1; - } else { - logger(LOG_NOTICE, - "Temporarily setting debug level to 5. Kill me with SIGINT again to go back to level %d.", - debug_level); - saved_debug_level = debug_level; - debug_level = 5; - } -} - -static RETSIGTYPE sigalrm_handler(int a) { - (void)a; - logger(LOG_NOTICE, "Got %s signal", "ALRM"); - sigalrm = true; -} - -static RETSIGTYPE sigusr1_handler(int a) { - (void)a; - dump_connections(); -} - -static RETSIGTYPE sigusr2_handler(int a) { - (void)a; - devops.dump_stats(); - dump_nodes(); - dump_edges(); - dump_subnets(); -} - -static RETSIGTYPE sigwinch_handler(int a) { - (void)a; - do_purge = true; -} - -static RETSIGTYPE unexpected_signal_handler(int a) { - (void)a; - logger(LOG_WARNING, "Got unexpected signal %d (%s)", a, strsignal(a)); -} - -static RETSIGTYPE ignore_signal_handler(int a) { - (void)a; - ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Ignored signal %d (%s)", a, strsignal(a)); -} - -static struct { - int signal; - void (*handler)(int); -} sighandlers[] = { - {SIGHUP, sighup_handler}, - {SIGTERM, sigterm_handler}, - {SIGQUIT, sigquit_handler}, - {SIGSEGV, fatal_signal_handler}, - {SIGBUS, fatal_signal_handler}, - {SIGILL, fatal_signal_handler}, - {SIGPIPE, ignore_signal_handler}, - {SIGINT, sigint_handler}, - {SIGUSR1, sigusr1_handler}, - {SIGUSR2, sigusr2_handler}, - {SIGCHLD, ignore_signal_handler}, - {SIGALRM, sigalrm_handler}, - {SIGWINCH, sigwinch_handler}, - {SIGABRT, SIG_DFL}, - {0, NULL} -}; -#endif - -void setup_signals(void) { -#ifndef HAVE_MINGW - int i; - struct sigaction act; - - sigemptyset(&emptysigset); - act.sa_handler = NULL; - act.sa_mask = emptysigset; - act.sa_flags = 0; - - /* Set a default signal handler for every signal, errors will be - ignored. */ - for(i = 1; i < NSIG; i++) { - if(!do_detach) { - act.sa_handler = SIG_DFL; - } else { - act.sa_handler = unexpected_signal_handler; - } - - sigaction(i, &act, NULL); - } - - /* If we didn't detach, allow coredumps */ - if(!do_detach) { - sighandlers[3].handler = SIG_DFL; - } - - /* Then, for each known signal that we want to catch, assign a - handler to the signal, with error checking this time. */ - for(i = 0; sighandlers[i].signal; i++) { - act.sa_handler = sighandlers[i].handler; - - if(sigaction(sighandlers[i].signal, &act, NULL) < 0) - fprintf(stderr, "Installing signal handler for signal %d (%s) failed: %s\n", - sighandlers[i].signal, strsignal(sighandlers[i].signal), - strerror(errno)); - } - -#endif -} diff --git a/src/process.h b/src/process.h index e775ac3..ea7815e 100644 --- a/src/process.h +++ b/src/process.h @@ -1,6 +1,3 @@ -#ifndef TINC_PROCESS_H -#define TINC_PROCESS_H - /* process.h -- header file for process.c Copyright (C) 1999-2005 Ivo Timmermans, @@ -21,17 +18,19 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_PROCESS_H__ +#define __TINC_PROCESS_H__ + extern bool do_detach; -extern bool sighup; extern bool sigalrm; extern void setup_signals(void); -extern bool execute_script(const char *name, char **envp); +extern bool execute_script(const char *, char **); extern bool detach(void); -extern bool kill_other(int signal); +extern bool kill_other(int); #ifdef HAVE_MINGW extern bool init_service(void); #endif -#endif +#endif /* __TINC_PROCESS_H__ */ diff --git a/src/protocol.c b/src/protocol.c index 4f74d3b..63163a0 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -1,7 +1,7 @@ /* protocol.c -- handle the meta-protocol, basic functions Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2016 Guus Sliepen + 2000-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,35 +30,35 @@ bool tunnelserver = false; bool strictsubnets = false; +bool experimental = false; /* Jumptable for the request handlers */ -static bool (*request_handlers[])(connection_t *) = { - id_h, metakey_h, challenge_h, chal_reply_h, ack_h, - NULL, NULL, NULL, - ping_h, pong_h, - add_subnet_h, del_subnet_h, - add_edge_h, del_edge_h, - key_changed_h, req_key_h, ans_key_h, tcppacket_h, +static bool (*request_handlers[])(connection_t *, char *) = { + id_h, metakey_h, challenge_h, chal_reply_h, ack_h, + status_h, error_h, termreq_h, + ping_h, pong_h, + add_subnet_h, del_subnet_h, + add_edge_h, del_edge_h, + key_changed_h, req_key_h, ans_key_h, tcppacket_h, control_h, }; /* Request names */ static char (*request_name[]) = { - "ID", "METAKEY", "CHALLENGE", "CHAL_REPLY", "ACK", - "STATUS", "ERROR", "TERMREQ", - "PING", "PONG", - "ADD_SUBNET", "DEL_SUBNET", - "ADD_EDGE", "DEL_EDGE", "KEY_CHANGED", "REQ_KEY", "ANS_KEY", "PACKET", + "ID", "METAKEY", "CHALLENGE", "CHAL_REPLY", "ACK", + "STATUS", "ERROR", "TERMREQ", + "PING", "PONG", + "ADD_SUBNET", "DEL_SUBNET", + "ADD_EDGE", "DEL_EDGE", "KEY_CHANGED", "REQ_KEY", "ANS_KEY", "PACKET", "CONTROL", }; -static avl_tree_t *past_request_tree; +static splay_tree_t *past_request_tree; bool check_id(const char *id) { for(; *id; id++) - if(!isalnum(*id) && *id != '_') { + if(!isalnum(*id) && *id != '_') return false; - } return true; } @@ -68,104 +68,97 @@ bool check_id(const char *id) { bool send_request(connection_t *c, const char *format, ...) { va_list args; - char buffer[MAXBUFSIZE]; - int len, request = 0; + char request[MAXBUFSIZE]; + int len; /* Use vsnprintf instead of vxasprintf: faster, no memory fragmentation, cleanup is automatic, and there is a limit on the input buffer anyway */ va_start(args, format); - len = vsnprintf(buffer, sizeof(buffer), format, args); - buffer[sizeof(buffer) - 1] = 0; + len = vsnprintf(request, MAXBUFSIZE, format, args); va_end(args); - if(len < 0 || (size_t)len > sizeof(buffer) - 1) { + if(len < 0 || len > MAXBUFSIZE - 1) { logger(LOG_ERR, "Output buffer overflow while sending request to %s (%s)", - c->name, c->hostname); + c->name, c->hostname); return false; } ifdebug(PROTOCOL) { - sscanf(buffer, "%d", &request); ifdebug(META) - logger(LOG_DEBUG, "Sending %s to %s (%s): %s", - request_name[request], c->name, c->hostname, buffer); + logger(LOG_DEBUG, "Sending %s to %s (%s): %s", + request_name[atoi(request)], c->name, c->hostname, request); else - logger(LOG_DEBUG, "Sending %s to %s (%s)", request_name[request], - c->name, c->hostname); + logger(LOG_DEBUG, "Sending %s to %s (%s)", request_name[atoi(request)], + c->name, c->hostname); } - buffer[len++] = '\n'; + request[len++] = '\n'; - if(c == everyone) { - broadcast_meta(NULL, buffer, len); + if(c == broadcast) { + broadcast_meta(NULL, request, len); return true; - } else { - return send_meta(c, buffer, len); - } + } else + return send_meta(c, request, len); } -void forward_request(connection_t *from) { - int request; - +void forward_request(connection_t *from, char *request) { + /* Note: request is not zero terminated anymore after a call to this function! */ ifdebug(PROTOCOL) { - sscanf(from->buffer, "%d", &request); ifdebug(META) - logger(LOG_DEBUG, "Forwarding %s from %s (%s): %s", - request_name[request], from->name, from->hostname, - from->buffer); + logger(LOG_DEBUG, "Forwarding %s from %s (%s): %s", + request_name[atoi(request)], from->name, from->hostname, request); else logger(LOG_DEBUG, "Forwarding %s from %s (%s)", - request_name[request], from->name, from->hostname); + request_name[atoi(request)], from->name, from->hostname); } - from->buffer[from->reqlen - 1] = '\n'; - - broadcast_meta(from, from->buffer, from->reqlen); + int len = strlen(request); + request[len++] = '\n'; + broadcast_meta(from, request, len); } -bool receive_request(connection_t *c) { - int request; +bool receive_request(connection_t *c, char *request) { + int reqno = atoi(request); - if(sscanf(c->buffer, "%d", &request) == 1) { - if((request < 0) || (request >= LAST) || !request_handlers[request]) { + if(reqno || *request == '0') { + if((reqno < 0) || (reqno >= LAST) || !request_handlers[reqno]) { ifdebug(META) - logger(LOG_DEBUG, "Unknown request from %s (%s): %s", - c->name, c->hostname, c->buffer); + logger(LOG_DEBUG, "Unknown request from %s (%s): %s", + c->name, c->hostname, request); else logger(LOG_ERR, "Unknown request from %s (%s)", - c->name, c->hostname); + c->name, c->hostname); return false; } else { ifdebug(PROTOCOL) { ifdebug(META) - logger(LOG_DEBUG, "Got %s from %s (%s): %s", - request_name[request], c->name, c->hostname, - c->buffer); + logger(LOG_DEBUG, "Got %s from %s (%s): %s", + request_name[reqno], c->name, c->hostname, request); else logger(LOG_DEBUG, "Got %s from %s (%s)", - request_name[request], c->name, c->hostname); + request_name[reqno], c->name, c->hostname); } } - if((c->allow_request != ALL) && (c->allow_request != request)) { + if((c->allow_request != ALL) && (c->allow_request != reqno)) { logger(LOG_ERR, "Unauthorized request from %s (%s)", c->name, - c->hostname); + c->hostname); return false; } - if(!request_handlers[request](c)) { + if(!request_handlers[reqno](c, request)) { /* Something went wrong. Probably scriptkiddies. Terminate. */ logger(LOG_ERR, "Error while processing %s from %s (%s)", - request_name[request], c->name, c->hostname); + request_name[reqno], c->name, c->hostname); return false; } } else { logger(LOG_ERR, "Bogus data received from %s (%s)", - c->name, c->hostname); + c->name, c->hostname); return false; } @@ -177,55 +170,65 @@ static int past_request_compare(const past_request_t *a, const past_request_t *b } static void free_past_request(past_request_t *r) { - if(r->request) { + if(r->request) free(r->request); - } free(r); } -void init_requests(void) { - past_request_tree = avl_alloc_tree((avl_compare_t) past_request_compare, (avl_action_t) free_past_request); -} - -void exit_requests(void) { - avl_delete_tree(past_request_tree); -} +static struct event past_request_event; bool seen_request(char *request) { - past_request_t *new, p = {0}; + past_request_t *new, p = {NULL}; p.request = request; - if(avl_search(past_request_tree, &p)) { + if(splay_search(past_request_tree, &p)) { ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Already seen request"); return true; } else { - new = xmalloc(sizeof(*new)); + new = xmalloc(sizeof *new); new->request = xstrdup(request); - new->firstseen = now; - avl_insert(past_request_tree, new); + new->firstseen = time(NULL); + splay_insert(past_request_tree, new); + event_add(&past_request_event, &(struct timeval){10, 0}); return false; } } -void age_past_requests(void) { - avl_node_t *node, *next; +static void age_past_requests(int fd, short events, void *data) { + splay_node_t *node, *next; past_request_t *p; int left = 0, deleted = 0; + time_t now = time(NULL); for(node = past_request_tree->head; node; node = next) { next = node->next; p = node->data; - if(p->firstseen + pinginterval <= now) { - avl_delete_node(past_request_tree, node), deleted++; - } else { + if(p->firstseen + pinginterval <= now) + splay_delete_node(past_request_tree, node), deleted++; + else left++; - } } if(left || deleted) ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Aging past requests: deleted %d, left %d", - deleted, left); + deleted, left); + + if(left) + event_add(&past_request_event, &(struct timeval){10, 0}); +} + +void init_requests(void) { + past_request_tree = splay_alloc_tree((splay_compare_t) past_request_compare, (splay_action_t) free_past_request); + + timeout_set(&past_request_event, age_past_requests, NULL); +} + +void exit_requests(void) { + splay_delete_tree(past_request_tree); + + if(timeout_initialized(&past_request_event)) + event_del(&past_request_event); } diff --git a/src/protocol.h b/src/protocol.h index a055f28..2c97641 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -1,10 +1,7 @@ -#ifndef TINC_PROTOCOL_H -#define TINC_PROTOCOL_H - /* protocol.h -- header for protocol.c Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2015 Guus Sliepen + 2000-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,11 +18,13 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -/* Protocol version. Different versions are incompatible, - incompatible version have different protocols. - */ +#ifndef __TINC_PROTOCOL_H__ +#define __TINC_PROTOCOL_H__ -#define PROT_CURRENT 17 +/* Protocol version. Different major versions are incompatible. */ + +#define PROT_MAJOR 17 +#define PROT_MINOR 2 /* Silly Windows */ @@ -36,8 +35,7 @@ /* Request numbers */ typedef enum request_t { - PROXY = -2, - ALL = -1, /* Guardian for allow_request */ + ALL = -1, /* Guardian for allow_request */ ID = 0, METAKEY, CHALLENGE, CHAL_REPLY, ACK, STATUS, ERROR, TERMREQ, PING, PONG, @@ -45,7 +43,8 @@ typedef enum request_t { ADD_EDGE, DEL_EDGE, KEY_CHANGED, REQ_KEY, ANS_KEY, PACKET, - LAST /* Guardian for the highest request number */ + CONTROL, + LAST /* Guardian for the highest request number */ } request_t; typedef struct past_request_t { @@ -55,6 +54,7 @@ typedef struct past_request_t { extern bool tunnelserver; extern bool strictsubnets; +extern bool experimental; /* Maximum size of strings in a request. * scanf terminates %2048s with a NUL character, @@ -71,50 +71,57 @@ extern bool strictsubnets; /* Basic functions */ -extern bool send_request(struct connection_t *c, const char *format, ...) __attribute__((__format__(printf, 2, 3))); -extern void forward_request(struct connection_t *c); -extern bool receive_request(struct connection_t *c); -extern bool check_id(const char *name); +extern bool send_request(struct connection_t *, const char *, ...) __attribute__ ((__format__(printf, 2, 3))); +extern void forward_request(struct connection_t *, char *); +extern bool receive_request(struct connection_t *, char *); +extern bool check_id(const char *); extern void init_requests(void); extern void exit_requests(void); -extern bool seen_request(char *request); -extern void age_past_requests(void); +extern bool seen_request(char *); /* Requests */ -extern bool send_id(struct connection_t *c); -extern bool send_metakey(struct connection_t *c); -extern bool send_challenge(struct connection_t *c); -extern bool send_chal_reply(struct connection_t *c); -extern bool send_ack(struct connection_t *c); -extern bool send_ping(struct connection_t *c); -extern bool send_pong(struct connection_t *c); -extern bool send_add_subnet(struct connection_t *c, const struct subnet_t *subnet); -extern bool send_del_subnet(struct connection_t *c, const struct subnet_t *subnet); -extern bool send_add_edge(struct connection_t *c, const struct edge_t *e); -extern bool send_del_edge(struct connection_t *c, const struct edge_t *e); +extern bool send_id(struct connection_t *); +extern bool send_metakey(struct connection_t *); +extern bool send_metakey_ec(struct connection_t *); +extern bool send_challenge(struct connection_t *); +extern bool send_chal_reply(struct connection_t *); +extern bool send_ack(struct connection_t *); +extern bool send_status(struct connection_t *, int, const char *); +extern bool send_error(struct connection_t *, int,const char *); +extern bool send_termreq(struct connection_t *); +extern bool send_ping(struct connection_t *); +extern bool send_pong(struct connection_t *); +extern bool send_add_subnet(struct connection_t *, const struct subnet_t *); +extern bool send_del_subnet(struct connection_t *, const struct subnet_t *); +extern bool send_add_edge(struct connection_t *, const struct edge_t *); +extern bool send_del_edge(struct connection_t *, const struct edge_t *); extern void send_key_changed(void); -extern bool send_req_key(struct node_t *n); -extern bool send_ans_key(struct node_t *n); -extern bool send_tcppacket(struct connection_t *c, const struct vpn_packet_t *packet); +extern bool send_req_key(struct node_t *); +extern bool send_ans_key(struct node_t *); +extern bool send_tcppacket(struct connection_t *, const struct vpn_packet_t *); /* Request handlers */ -extern bool id_h(struct connection_t *c); -extern bool metakey_h(struct connection_t *c); -extern bool challenge_h(struct connection_t *c); -extern bool chal_reply_h(struct connection_t *c); -extern bool ack_h(struct connection_t *c); -extern bool ping_h(struct connection_t *c); -extern bool pong_h(struct connection_t *c); -extern bool add_subnet_h(struct connection_t *c); -extern bool del_subnet_h(struct connection_t *c); -extern bool add_edge_h(struct connection_t *c); -extern bool del_edge_h(struct connection_t *c); -extern bool key_changed_h(struct connection_t *c); -extern bool req_key_h(struct connection_t *c); -extern bool ans_key_h(struct connection_t *c); -extern bool tcppacket_h(struct connection_t *c); +extern bool id_h(struct connection_t *, char *); +extern bool metakey_h(struct connection_t *, char *); +extern bool challenge_h(struct connection_t *, char *); +extern bool chal_reply_h(struct connection_t *, char *); +extern bool ack_h(struct connection_t *, char *); +extern bool status_h(struct connection_t *, char *); +extern bool error_h(struct connection_t *, char *); +extern bool termreq_h(struct connection_t *, char *); +extern bool ping_h(struct connection_t *, char *); +extern bool pong_h(struct connection_t *, char *); +extern bool add_subnet_h(struct connection_t *, char *); +extern bool del_subnet_h(struct connection_t *, char *); +extern bool add_edge_h(struct connection_t *, char *); +extern bool del_edge_h(struct connection_t *, char *); +extern bool key_changed_h(struct connection_t *, char *); +extern bool req_key_h(struct connection_t *, char *); +extern bool ans_key_h(struct connection_t *, char *); +extern bool tcppacket_h(struct connection_t *, char *); +extern bool control_h(struct connection_t *, char *); -#endif +#endif /* __TINC_PROTOCOL_H__ */ diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 15807c3..4331e94 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -1,7 +1,7 @@ /* protocol_auth.c -- handle the meta-protocol, authentication Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2016 Guus Sliepen + 2000-2010 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,49 +20,64 @@ #include "system.h" -#include -#include -#include -#include - -#include "avl_tree.h" +#include "splay_tree.h" #include "conf.h" #include "connection.h" +#include "control.h" +#include "control_common.h" +#include "cipher.h" +#include "crypto.h" +#include "digest.h" #include "edge.h" #include "graph.h" #include "logger.h" -#include "meta.h" #include "net.h" #include "netutl.h" #include "node.h" +#include "prf.h" #include "protocol.h" -#include "proxy.h" +#include "rsa.h" #include "utils.h" #include "xalloc.h" bool send_id(connection_t *c) { - if(proxytype && c->outgoing && !c->status.proxy_passed) { - return send_proxyrequest(c); + gettimeofday(&c->start, NULL); + + int minor = 0; + + if(experimental) { + if(c->config_tree && !read_ecdsa_public_key(c)) + minor = 1; + else + minor = myself->connection->protocol_minor; } - return send_request(c, "%d %s %d", ID, myself->connection->name, - myself->connection->protocol_version); + return send_request(c, "%d %s %d.%d", ID, myself->connection->name, myself->connection->protocol_major, minor); } -bool id_h(connection_t *c) { +bool id_h(connection_t *c, char *request) { char name[MAX_STRING_SIZE]; - if(sscanf(c->buffer, "%*d " MAX_STRING " %d", name, &c->protocol_version) != 2) { + if(sscanf(request, "%*d " MAX_STRING " %d.%d", name, &c->protocol_major, &c->protocol_minor) < 2) { logger(LOG_ERR, "Got bad %s from %s (%s)", "ID", c->name, - c->hostname); + c->hostname); return false; } + /* Check if this is a control connection */ + + if(name[0] == '^' && !strcmp(name + 1, controlcookie)) { + c->status.control = true; + c->allow_request = CONTROL; + c->last_ping_time = time(NULL) + 3600; + return send_request(c, "%d %d %d", ACK, TINC_CTL_VERSION_CURRENT, getpid()); + } + /* Check if identity is a valid name */ - if(!check_id(name) || !strcmp(name, myself->name)) { + if(!check_id(name)) { logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ID", c->name, - c->hostname, "invalid name"); + c->hostname, "invalid name"); return false; } @@ -71,36 +86,27 @@ bool id_h(connection_t *c) { if(c->outgoing) { if(strcmp(c->name, name)) { logger(LOG_ERR, "Peer %s is %s instead of %s", c->hostname, name, - c->name); + c->name); return false; } } else { - if(c->name) { + if(c->name) free(c->name); - } - c->name = xstrdup(name); } /* Check if version matches */ - if(c->protocol_version != myself->connection->protocol_version) { - logger(LOG_ERR, "Peer %s (%s) uses incompatible version %d", - c->name, c->hostname, c->protocol_version); + if(c->protocol_major != myself->connection->protocol_major) { + logger(LOG_ERR, "Peer %s (%s) uses incompatible version %d.%d", + c->name, c->hostname, c->protocol_major, c->protocol_minor); return false; } if(bypass_security) { - if(!c->config_tree) { + if(!c->config_tree) init_configuration(&c->config_tree); - } - c->allow_request = ACK; - - if(!c->outgoing) { - send_id(c); - } - return send_ack(c); } @@ -109,66 +115,67 @@ bool id_h(connection_t *c) { if(!read_connection_config(c)) { logger(LOG_ERR, "Peer %s had unknown identity (%s)", c->hostname, - c->name); + c->name); return false; } + + if(experimental && c->protocol_minor >= 2) + if(!read_ecdsa_public_key(c)) + return false; + } else { + if(!ecdsa_active(&c->ecdsa)) + c->protocol_minor = 1; } - if(!read_rsa_public_key(c)) { - return false; - } + if(!experimental) + c->protocol_minor = 0; c->allow_request = METAKEY; - if(!c->outgoing) { - send_id(c); - } - - return send_metakey(c); + if(c->protocol_minor >= 2) + return send_metakey_ec(c); + else + return send_metakey(c); } -static uint64_t byte_budget(const EVP_CIPHER *cipher) { - /* Hopefully some failsafe way to calculate the maximum amount of bytes to - send/receive with a given cipher before we might run into birthday paradox - attacks. Because we might use different modes, the block size of the mode - might be 1 byte. In that case, use the IV length. Ensure the whole thing - is limited to what can be represented with a 64 bits integer. - */ +bool send_metakey_ec(connection_t *c) { + logger(LOG_DEBUG, "Sending ECDH metakey to %s", c->name); - int ivlen = EVP_CIPHER_iv_length(cipher); - int blklen = EVP_CIPHER_block_size(cipher); - int len = blklen > 1 ? blklen : ivlen > 1 ? ivlen : 8; - int bits = len * 4 - 1; - return bits < 64 ? UINT64_C(1) << bits : UINT64_MAX; + size_t siglen = ecdsa_size(&myself->connection->ecdsa); + + char key[(ECDH_SIZE + siglen) * 2 + 1]; + + // TODO: include nonce? Use relevant parts of SSH or TLS protocol + + if(!ecdh_generate_public(&c->ecdh, key)) + return false; + + if(!ecdsa_sign(&myself->connection->ecdsa, key, ECDH_SIZE, key + ECDH_SIZE)) + return false; + + b64encode(key, key, ECDH_SIZE + siglen); + + return send_request(c, "%d %s", METAKEY, key); } bool send_metakey(connection_t *c) { - bool x; - - int len = RSA_size(c->rsa_key); - - /* Allocate buffers for the meta key */ - - char buffer[2 * len + 1]; - - c->outkey = xrealloc(c->outkey, len); - - if(!c->outctx) { - c->outctx = EVP_CIPHER_CTX_new(); - - if(!c->outctx) { - abort(); - } - } - - /* Copy random data to the buffer */ - - if(1 != RAND_bytes((unsigned char *)c->outkey, len)) { - int err = ERR_get_error(); - logger(LOG_ERR, "Failed to generate meta key (%s)", ERR_error_string(err, NULL)); + if(!read_rsa_public_key(c)) return false; - } + if(!cipher_open_blowfish_ofb(&c->outcipher)) + return false; + + if(!digest_open_sha1(&c->outdigest, -1)) + return false; + + size_t len = rsa_size(&c->rsa); + char key[len]; + char enckey[len]; + char hexkey[2 * len + 1]; + + /* Create a random key */ + + randomize(key, len); /* The message we send must be smaller than the modulus of the RSA key. By definition, for a key of k bits, the following formula holds: @@ -180,13 +187,13 @@ bool send_metakey(connection_t *c) { This can be done by setting the most significant bit to zero. */ - c->outkey[0] &= 0x7F; + key[0] &= 0x7F; + + cipher_set_key_from_rsa(&c->outcipher, key, len, true); ifdebug(SCARY_THINGS) { - bin2hex(c->outkey, buffer, len); - buffer[len * 2] = '\0'; - logger(LOG_DEBUG, "Generated random meta key (unencrypted): %s", - buffer); + bin2hex(key, hexkey, len); + logger(LOG_DEBUG, "Generated random meta key (unencrypted): %s", hexkey); } /* Encrypt the random data @@ -196,144 +203,152 @@ bool send_metakey(connection_t *c) { with a length equal to that of the modulus of the RSA key. */ - if(RSA_public_encrypt(len, (unsigned char *)c->outkey, (unsigned char *)buffer, c->rsa_key, RSA_NO_PADDING) != len) { - logger(LOG_ERR, "Error during encryption of meta key for %s (%s): %s", - c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); + if(!rsa_public_encrypt(&c->rsa, key, len, enckey)) { + logger(LOG_ERR, "Error during encryption of meta key for %s (%s)", c->name, c->hostname); return false; } /* Convert the encrypted random data to a hexadecimal formatted string */ - bin2hex(buffer, buffer, len); - buffer[len * 2] = '\0'; + bin2hex(enckey, hexkey, len); /* Send the meta key */ - x = send_request(c, "%d %d %d %d %d %s", METAKEY, - c->outcipher ? EVP_CIPHER_nid(c->outcipher) : 0, - c->outdigest ? EVP_MD_type(c->outdigest) : 0, c->outmaclength, - c->outcompression, buffer); - - /* Further outgoing requests are encrypted with the key we just generated */ - - if(c->outcipher) { - if(!EVP_EncryptInit(c->outctx, c->outcipher, - (unsigned char *)c->outkey + len - EVP_CIPHER_key_length(c->outcipher), - (unsigned char *)c->outkey + len - EVP_CIPHER_key_length(c->outcipher) - - EVP_CIPHER_iv_length(c->outcipher))) { - logger(LOG_ERR, "Error during initialisation of cipher for %s (%s): %s", - c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); - return false; - } - - c->outbudget = byte_budget(c->outcipher); - c->status.encryptout = true; - } - - return x; + bool result = send_request(c, "%d %d %d %d %d %s", METAKEY, + cipher_get_nid(&c->outcipher), + digest_get_nid(&c->outdigest), c->outmaclength, + c->outcompression, hexkey); + + c->status.encryptout = true; + return result; } -bool metakey_h(connection_t *c) { - char buffer[MAX_STRING_SIZE]; - int cipher, digest, maclength, compression; - int len; +static bool metakey_ec_h(connection_t *c, const char *request) { + size_t siglen = ecdsa_size(&c->ecdsa); + char key[MAX_STRING_SIZE]; + char sig[siglen]; - if(sscanf(c->buffer, "%*d %d %d %d %d " MAX_STRING, &cipher, &digest, &maclength, &compression, buffer) != 5) { - logger(LOG_ERR, "Got bad %s from %s (%s)", "METAKEY", c->name, - c->hostname); + logger(LOG_DEBUG, "Got ECDH metakey from %s", c->name); + + if(sscanf(request, "%*d " MAX_STRING, key) != 1) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "METAKEY", c->name, c->hostname); return false; } - len = RSA_size(myself->connection->rsa_key); + int inlen = b64decode(key, key, sizeof key); - /* Check if the length of the meta key is all right */ - - if(strlen(buffer) != (size_t)len * 2) { + if(inlen != (ECDH_SIZE + siglen)) { logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong keylength"); return false; } - /* Allocate buffers for the meta key */ + if(!ecdsa_verify(&c->ecdsa, key, ECDH_SIZE, key + ECDH_SIZE)) { + logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "invalid ECDSA signature"); + return false; + } - c->inkey = xrealloc(c->inkey, len); + char shared[ECDH_SHARED_SIZE]; - if(!c->inctx) { - c->inctx = EVP_CIPHER_CTX_new(); + if(!ecdh_compute_shared(&c->ecdh, key, shared)) + return false; - if(!c->inctx) { - abort(); - } + /* Update our crypto end */ + + if(!cipher_open_by_name(&c->incipher, "aes-256-ofb")) + return false; + if(!digest_open_by_name(&c->indigest, "sha512", -1)) + return false; + if(!cipher_open_by_name(&c->outcipher, "aes-256-ofb")) + return false; + if(!digest_open_by_name(&c->outdigest, "sha512", -1)) + return false; + + size_t mykeylen = cipher_keylength(&c->incipher); + size_t hiskeylen = cipher_keylength(&c->outcipher); + + char *mykey; + char *hiskey; + char *seed; + + if(strcmp(myself->name, c->name) < 0) { + mykey = key; + hiskey = key + mykeylen * 2; + xasprintf(&seed, "tinc TCP key expansion %s %s", myself->name, c->name); + } else { + mykey = key + hiskeylen * 2; + hiskey = key; + xasprintf(&seed, "tinc TCP key expansion %s %s", c->name, myself->name); + } + + if(!prf(shared, ECDH_SHARED_SIZE, seed, strlen(seed), key, hiskeylen * 2 + mykeylen * 2)) + return false; + + free(seed); + + cipher_set_key(&c->incipher, mykey, false); + digest_set_key(&c->indigest, mykey + mykeylen, mykeylen); + + cipher_set_key(&c->outcipher, hiskey, true); + digest_set_key(&c->outdigest, hiskey + hiskeylen, hiskeylen); + + c->status.decryptin = true; + c->status.encryptout = true; + c->allow_request = CHALLENGE; + + return send_challenge(c); +} + +bool metakey_h(connection_t *c, char *request) { + if(c->protocol_minor >= 2) + return metakey_ec_h(c, request); + + char hexkey[MAX_STRING_SIZE]; + int cipher, digest, maclength, compression; + size_t len = rsa_size(&myself->connection->rsa); + char enckey[len]; + char key[len]; + + if(sscanf(request, "%*d %d %d %d %d " MAX_STRING, &cipher, &digest, &maclength, &compression, hexkey) != 5) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "METAKEY", c->name, c->hostname); + return false; } /* Convert the challenge from hexadecimal back to binary */ - if(!hex2bin(buffer, buffer, len)) { - logger(LOG_ERR, "Got bad %s from %s(%s): %s", "METAKEY", c->name, c->hostname, "invalid key"); + int inlen = hex2bin(hexkey, enckey, sizeof enckey); + + /* Check if the length of the meta key is all right */ + + if(inlen != len) { + logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong keylength"); return false; } /* Decrypt the meta key */ - if(RSA_private_decrypt(len, (unsigned char *)buffer, (unsigned char *)c->inkey, myself->connection->rsa_key, RSA_NO_PADDING) != len) { /* See challenge() */ - logger(LOG_ERR, "Error during decryption of meta key for %s (%s): %s", - c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); + if(!rsa_private_decrypt(&myself->connection->rsa, enckey, len, key)) { + logger(LOG_ERR, "Error during decryption of meta key for %s (%s)", c->name, c->hostname); return false; } ifdebug(SCARY_THINGS) { - bin2hex(c->inkey, buffer, len); - buffer[len * 2] = '\0'; - logger(LOG_DEBUG, "Received random meta key (unencrypted): %s", buffer); + bin2hex(key, hexkey, len); + logger(LOG_DEBUG, "Received random meta key (unencrypted): %s", hexkey); } - /* All incoming requests will now be encrypted. */ - /* Check and lookup cipher and digest algorithms */ - if(cipher) { - c->incipher = EVP_get_cipherbynid(cipher); - - if(!c->incipher) { - logger(LOG_ERR, "%s (%s) uses unknown cipher!", c->name, c->hostname); - return false; - } - - if(!EVP_DecryptInit(c->inctx, c->incipher, - (unsigned char *)c->inkey + len - EVP_CIPHER_key_length(c->incipher), - (unsigned char *)c->inkey + len - EVP_CIPHER_key_length(c->incipher) - - EVP_CIPHER_iv_length(c->incipher))) { - logger(LOG_ERR, "Error during initialisation of cipher from %s (%s): %s", - c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); - return false; - } - - c->inbudget = byte_budget(c->incipher); - c->status.decryptin = true; - } else { - logger(LOG_ERR, "%s (%s) uses null cipher!", c->name, c->hostname); + if(!cipher_open_by_nid(&c->incipher, cipher) || !cipher_set_key_from_rsa(&c->incipher, key, len, false)) { + logger(LOG_ERR, "Error during initialisation of cipher from %s (%s)", c->name, c->hostname); return false; } - c->inmaclength = maclength; - - if(digest) { - c->indigest = EVP_get_digestbynid(digest); - - if(!c->indigest) { - logger(LOG_ERR, "Node %s (%s) uses unknown digest!", c->name, c->hostname); - return false; - } - - if(c->inmaclength > EVP_MD_size(c->indigest) || c->inmaclength < 0) { - logger(LOG_ERR, "%s (%s) uses bogus MAC length!", c->name, c->hostname); - return false; - } - } else { - logger(LOG_ERR, "%s (%s) uses null digest!", c->name, c->hostname); + if(!digest_open_by_nid(&c->indigest, digest, -1)) { + logger(LOG_ERR, "Error during initialisation of digest from %s (%s)", c->name, c->hostname); return false; } - c->incompression = compression; + c->status.decryptin = true; c->allow_request = CHALLENGE; @@ -341,166 +356,87 @@ bool metakey_h(connection_t *c) { } bool send_challenge(connection_t *c) { - /* CHECKME: what is most reasonable value for len? */ + size_t len = c->protocol_minor >= 2 ? ECDH_SIZE : rsa_size(&c->rsa); + char buffer[len * 2 + 1]; - int len = RSA_size(c->rsa_key); - - /* Allocate buffers for the challenge */ - - char buffer[2 * len + 1]; - - c->hischallenge = xrealloc(c->hischallenge, len); + if(!c->hischallenge) + c->hischallenge = xrealloc(c->hischallenge, len); /* Copy random data to the buffer */ - if(1 != RAND_bytes((unsigned char *)c->hischallenge, len)) { - int err = ERR_get_error(); - logger(LOG_ERR, "Failed to generate challenge (%s)", ERR_error_string(err, NULL)); - return false; // Do not send predictable challenges, let connection attempt fail. - } + randomize(c->hischallenge, len); /* Convert to hex */ bin2hex(c->hischallenge, buffer, len); - buffer[len * 2] = '\0'; /* Send the challenge */ return send_request(c, "%d %s", CHALLENGE, buffer); } -bool challenge_h(connection_t *c) { +bool challenge_h(connection_t *c, char *request) { char buffer[MAX_STRING_SIZE]; - int len; + size_t len = c->protocol_minor >= 2 ? ECDH_SIZE : rsa_size(&myself->connection->rsa); + size_t digestlen = digest_length(&c->indigest); + char digest[digestlen]; - if(sscanf(c->buffer, "%*d " MAX_STRING, buffer) != 1) { - logger(LOG_ERR, "Got bad %s from %s (%s)", "CHALLENGE", c->name, - c->hostname); + if(sscanf(request, "%*d " MAX_STRING, buffer) != 1) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "CHALLENGE", c->name, c->hostname); return false; } - len = RSA_size(myself->connection->rsa_key); - - /* Check if the length of the challenge is all right */ - - if(strlen(buffer) != (size_t)len * 2) { - logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, - c->hostname, "wrong challenge length"); - return false; - } - - /* Allocate buffers for the challenge */ - - c->mychallenge = xrealloc(c->mychallenge, len); - /* Convert the challenge from hexadecimal back to binary */ - if(!hex2bin(buffer, c->mychallenge, len)) { - logger(LOG_ERR, "Got bad %s from %s(%s): %s", "CHALLENGE", c->name, c->hostname, "invalid challenge"); + int inlen = hex2bin(buffer, buffer, sizeof buffer); + + /* Check if the length of the challenge is all right */ + + if(inlen != len) { + logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge length"); return false; } c->allow_request = CHAL_REPLY; - /* Rest is done by send_chal_reply() */ - - if(c->outgoing) { - return send_chal_reply(c); - } else { - return true; - } -} - -bool send_chal_reply(connection_t *c) { - char hash[EVP_MAX_MD_SIZE * 2 + 1]; - EVP_MD_CTX *ctx; - /* Calculate the hash from the challenge we received */ - ctx = EVP_MD_CTX_create(); - - if(!ctx) { - abort(); - } - - if(!EVP_DigestInit(ctx, c->indigest) - || !EVP_DigestUpdate(ctx, c->mychallenge, RSA_size(myself->connection->rsa_key)) - || !EVP_DigestFinal(ctx, (unsigned char *)hash, NULL)) { - EVP_MD_CTX_destroy(ctx); - logger(LOG_ERR, "Error during calculation of response for %s (%s): %s", - c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); - return false; - } - - EVP_MD_CTX_destroy(ctx); + digest_create(&c->indigest, buffer, len, digest); /* Convert the hash to a hexadecimal formatted string */ - bin2hex(hash, hash, EVP_MD_size(c->indigest)); - hash[EVP_MD_size(c->indigest) * 2] = '\0'; + bin2hex(digest, buffer, digestlen); /* Send the reply */ - return send_request(c, "%d %s", CHAL_REPLY, hash); + return send_request(c, "%d %s", CHAL_REPLY, buffer); } -bool chal_reply_h(connection_t *c) { +bool chal_reply_h(connection_t *c, char *request) { char hishash[MAX_STRING_SIZE]; - char myhash[EVP_MAX_MD_SIZE]; - EVP_MD_CTX *ctx; - if(sscanf(c->buffer, "%*d " MAX_STRING, hishash) != 1) { + if(sscanf(request, "%*d " MAX_STRING, hishash) != 1) { logger(LOG_ERR, "Got bad %s from %s (%s)", "CHAL_REPLY", c->name, - c->hostname); - return false; - } - - /* Check if the length of the hash is all right */ - - if(strlen(hishash) != (size_t)EVP_MD_size(c->outdigest) * 2) { - logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, - c->hostname, "wrong challenge reply length"); + c->hostname); return false; } /* Convert the hash to binary format */ - if(!hex2bin(hishash, hishash, EVP_MD_size(c->outdigest))) { - logger(LOG_ERR, "Got bad %s from %s(%s): %s", "CHAL_REPLY", c->name, c->hostname, "invalid hash"); + int inlen = hex2bin(hishash, hishash, sizeof hishash); + + /* Check if the length of the hash is all right */ + + if(inlen != digest_length(&c->outdigest)) { + logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge reply length"); return false; } - /* Calculate the hash from the challenge we sent */ - ctx = EVP_MD_CTX_create(); - - if(!ctx) { - abort(); - } - - if(!EVP_DigestInit(ctx, c->outdigest) - || !EVP_DigestUpdate(ctx, c->hischallenge, RSA_size(c->rsa_key)) - || !EVP_DigestFinal(ctx, (unsigned char *)myhash, NULL)) { - EVP_MD_CTX_destroy(ctx); - logger(LOG_ERR, "Error during calculation of response from %s (%s): %s", - c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); - return false; - } - - EVP_MD_CTX_destroy(ctx); - - /* Verify the incoming hash with the calculated hash */ - - if(memcmp(hishash, myhash, EVP_MD_size(c->outdigest))) { - logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, - c->hostname, "wrong challenge reply"); - - ifdebug(SCARY_THINGS) { - bin2hex(myhash, hishash, SHA_DIGEST_LENGTH); - hishash[SHA_DIGEST_LENGTH * 2] = '\0'; - logger(LOG_DEBUG, "Expected challenge reply: %s", hishash); - } + /* Verify the hash */ + if(!digest_verify(&c->outdigest, c->hischallenge, c->protocol_minor >= 2 ? ECDH_SIZE : rsa_size(&c->rsa), hishash)) { + logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge reply"); return false; } @@ -508,16 +444,31 @@ bool chal_reply_h(connection_t *c) { Send an acknowledgement with the rest of the information needed. */ + free(c->hischallenge); + c->hischallenge = NULL; c->allow_request = ACK; - if(!c->outgoing) { - send_chal_reply(c); - } - return send_ack(c); } +static bool send_upgrade(connection_t *c) { + /* Special case when protocol_minor is 1: the other end is ECDSA capable, + * but doesn't know our key yet. So send it now. */ + + char *pubkey = ecdsa_get_base64_public_key(&myself->connection->ecdsa); + + if(!pubkey) + return false; + + bool result = send_request(c, "%d %s", ACK, pubkey); + free(pubkey); + return result; +} + bool send_ack(connection_t *c) { + if(c->protocol_minor == 1) + return send_upgrade(c); + /* ACK message contains rest of the information the other end needs to create node_t and edge_t structures. */ @@ -531,24 +482,19 @@ bool send_ack(connection_t *c) { /* Check some options */ - if((get_config_bool(lookup_config(c->config_tree, "IndirectData"), &choice) && choice) || myself->options & OPTION_INDIRECT) { + if((get_config_bool(lookup_config(c->config_tree, "IndirectData"), &choice) && choice) || myself->options & OPTION_INDIRECT) c->options |= OPTION_INDIRECT; - } - if((get_config_bool(lookup_config(c->config_tree, "TCPOnly"), &choice) && choice) || myself->options & OPTION_TCPONLY) { + if((get_config_bool(lookup_config(c->config_tree, "TCPOnly"), &choice) && choice) || myself->options & OPTION_TCPONLY) c->options |= OPTION_TCPONLY | OPTION_INDIRECT; - } - if(myself->options & OPTION_PMTU_DISCOVERY && !(c->options & OPTION_TCPONLY)) { + if(myself->options & OPTION_PMTU_DISCOVERY) c->options |= OPTION_PMTU_DISCOVERY; - } choice = myself->options & OPTION_CLAMP_MSS; get_config_bool(lookup_config(c->config_tree, "ClampMSS"), &choice); - - if(choice) { + if(choice) c->options |= OPTION_CLAMP_MSS; - } get_config_int(lookup_config(c->config_tree, "Weight"), &c->estimated_weight); @@ -556,7 +502,7 @@ bool send_ack(connection_t *c) { } static void send_everything(connection_t *c) { - avl_node_t *node, *node2; + splay_node_t *node, *node2; node_t *n; subnet_t *s; edge_t *e; @@ -587,16 +533,39 @@ static void send_everything(connection_t *c) { } } -bool ack_h(connection_t *c) { +static bool upgrade_h(connection_t *c, char *request) { + char pubkey[MAX_STRING_SIZE]; + + if(sscanf(request, "%*d " MAX_STRING, pubkey) != 1) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "ACK", c->name, c->hostname); + return false; + } + + if(ecdsa_active(&c->ecdsa) || read_ecdsa_public_key(c)) { + logger(LOG_INFO, "Already have ECDSA public key from %s (%s), not upgrading.", c->name, c->hostname); + return false; + } + + logger(LOG_INFO, "Got ECDSA public key from %s (%s), upgrading!", c->name, c->hostname); + append_config_file(c->name, "ECDSAPublicKey", pubkey); + c->allow_request = TERMREQ; + return send_termreq(c); +} + +bool ack_h(connection_t *c, char *request) { + if(c->protocol_minor == 1) + return upgrade_h(c, request); + char hisport[MAX_STRING_SIZE]; + char *hisaddress; int weight, mtu; uint32_t options; node_t *n; bool choice; - if(sscanf(c->buffer, "%*d " MAX_STRING " %d %x", hisport, &weight, &options) != 3) { + if(sscanf(request, "%*d " MAX_STRING " %d %x", hisport, &weight, &options) != 3) { logger(LOG_ERR, "Got bad %s from %s (%s)", "ACK", c->name, - c->hostname); + c->hostname); return false; } @@ -611,8 +580,17 @@ bool ack_h(connection_t *c) { } else { if(n->connection) { /* Oh dear, we already have a connection to this node. */ - ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Established a second connection with %s (%s), closing old connection", - n->name, n->hostname); + ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Established a second connection with %s (%s), closing old connection", n->connection->name, n->connection->hostname); + + if(n->connection->outgoing) { + if(c->outgoing) + logger(LOG_WARNING, "Two outgoing connections to the same node!"); + else + c->outgoing = n->connection->outgoing; + + n->connection->outgoing = NULL; + } + terminate_connection(n->connection, false); /* Run graph algorithm to purge key and make sure up/down scripts are rerun with new IP addresses and stuff */ graph(); @@ -621,37 +599,35 @@ bool ack_h(connection_t *c) { n->connection = c; c->node = n; - if(!(c->options & options & OPTION_PMTU_DISCOVERY)) { c->options &= ~OPTION_PMTU_DISCOVERY; options &= ~OPTION_PMTU_DISCOVERY; } - c->options |= options; - if(get_config_int(lookup_config(c->config_tree, "PMTU"), &mtu) && mtu < n->mtu) { + if(get_config_int(lookup_config(c->config_tree, "PMTU"), &mtu) && mtu < n->mtu) n->mtu = mtu; - } - if(get_config_int(lookup_config(config_tree, "PMTU"), &mtu) && mtu < n->mtu) { + if(get_config_int(lookup_config(config_tree, "PMTU"), &mtu) && mtu < n->mtu) n->mtu = mtu; - } if(get_config_bool(lookup_config(c->config_tree, "ClampMSS"), &choice)) { - if(choice) { + if(choice) c->options |= OPTION_CLAMP_MSS; - } else { + else c->options &= ~OPTION_CLAMP_MSS; - } } + if(c->protocol_minor > 0) + c->node->status.ecdh = true; + /* Activate this connection */ c->allow_request = ALL; c->status.active = true; ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection with %s (%s) activated", c->name, - c->hostname); + c->hostname); /* Send him everything we know */ @@ -662,8 +638,9 @@ bool ack_h(connection_t *c) { c->edge = new_edge(); c->edge->from = myself; c->edge->to = n; - sockaddrcpy(&c->edge->address, &c->address); - sockaddr_setport(&c->edge->address, hisport); + sockaddr2str(&c->address, &hisaddress, NULL); + c->edge->address = str2sockaddr(hisaddress, hisport); + free(hisaddress); c->edge->weight = (weight + c->estimated_weight) / 2; c->edge->connection = c; c->edge->options = c->options; @@ -672,11 +649,10 @@ bool ack_h(connection_t *c) { /* Notify everyone of the new edge */ - if(tunnelserver) { + if(tunnelserver) send_add_edge(c, c->edge); - } else { - send_add_edge(everyone, c->edge); - } + else + send_add_edge(broadcast, c->edge); /* Run MST and SSSP algorithms */ diff --git a/src/protocol_edge.c b/src/protocol_edge.c index a1cf640..1dd68d5 100644 --- a/src/protocol_edge.c +++ b/src/protocol_edge.c @@ -1,7 +1,7 @@ /* protocol_edge.c -- handle the meta-protocol, edges Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2016 Guus Sliepen + 2000-2009 Guus Sliepen 2009 Michael Tokarev This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ #include "system.h" -#include "avl_tree.h" +#include "splay_tree.h" #include "conf.h" #include "connection.h" #include "edge.h" @@ -42,15 +42,15 @@ bool send_add_edge(connection_t *c, const edge_t *e) { sockaddr2str(&e->address, &address, &port); x = send_request(c, "%d %x %s %s %s %s %x %d", ADD_EDGE, rand(), - e->from->name, e->to->name, address, port, - e->options, e->weight); + e->from->name, e->to->name, address, port, + e->options, e->weight); free(address); free(port); return x; } -bool add_edge_h(connection_t *c) { +bool add_edge_h(connection_t *c, char *request) { edge_t *e; node_t *from, *to; char from_name[MAX_STRING_SIZE]; @@ -61,24 +61,23 @@ bool add_edge_h(connection_t *c) { uint32_t options; int weight; - if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING" "MAX_STRING" "MAX_STRING" %x %d", - from_name, to_name, to_address, to_port, &options, &weight) != 6) { + if(sscanf(request, "%*d %*x "MAX_STRING" "MAX_STRING" "MAX_STRING" "MAX_STRING" %x %d", + from_name, to_name, to_address, to_port, &options, &weight) != 6) { logger(LOG_ERR, "Got bad %s from %s (%s)", "ADD_EDGE", c->name, - c->hostname); + c->hostname); return false; } /* Check if names are valid */ - if(!check_id(from_name) || !check_id(to_name) || !strcmp(from_name, to_name)) { + if(!check_id(from_name) || !check_id(to_name)) { logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_EDGE", c->name, - c->hostname, "invalid name"); + c->hostname, "invalid name"); return false; } - if(seen_request(c->buffer)) { + if(seen_request(request)) return true; - } /* Lookup nodes */ @@ -86,12 +85,12 @@ bool add_edge_h(connection_t *c) { to = lookup_node(to_name); if(tunnelserver && - from != myself && from != c->node && - to != myself && to != c->node) { + from != myself && from != c->node && + to != myself && to != c->node) { /* ignore indirect edge registrations for tunnelserver */ ifdebug(PROTOCOL) logger(LOG_WARNING, - "Ignoring indirect %s from %s (%s)", - "ADD_EDGE", c->name, c->hostname); + "Ignoring indirect %s from %s (%s)", + "ADD_EDGE", c->name, c->hostname); return true; } @@ -120,33 +119,20 @@ bool add_edge_h(connection_t *c) { if(e->weight != weight || e->options != options || sockaddrcmp(&e->address, &address)) { if(from == myself) { ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for ourself which does not match existing entry", - "ADD_EDGE", c->name, c->hostname); + "ADD_EDGE", c->name, c->hostname); send_add_edge(c, e); return true; } else { ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) which does not match existing entry", - "ADD_EDGE", c->name, c->hostname); - e->options = options; - - if(sockaddrcmp(&e->address, &address)) { - sockaddrfree(&e->address); - e->address = address; - } - - if(e->weight != weight) { - avl_node_t *node = avl_unlink(edge_weight_tree, e); - e->weight = weight; - avl_insert_node(edge_weight_tree, node); - } - - goto done; + "ADD_EDGE", c->name, c->hostname); + edge_del(e); + graph(); } - } else { + } else return true; - } } else if(from == myself) { ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for ourself which does not exist", - "ADD_EDGE", c->name, c->hostname); + "ADD_EDGE", c->name, c->hostname); contradicting_add_edge++; e = new_edge(); e->from = from; @@ -164,12 +150,10 @@ bool add_edge_h(connection_t *c) { e->weight = weight; edge_add(e); -done: /* Tell the rest about the new edge */ - if(!tunnelserver) { - forward_request(c); - } + if(!tunnelserver) + forward_request(c, request); /* Run MST before or after we tell the rest? */ @@ -180,32 +164,31 @@ done: bool send_del_edge(connection_t *c, const edge_t *e) { return send_request(c, "%d %x %s %s", DEL_EDGE, rand(), - e->from->name, e->to->name); + e->from->name, e->to->name); } -bool del_edge_h(connection_t *c) { +bool del_edge_h(connection_t *c, char *request) { edge_t *e; char from_name[MAX_STRING_SIZE]; char to_name[MAX_STRING_SIZE]; node_t *from, *to; - if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING, from_name, to_name) != 2) { + if(sscanf(request, "%*d %*x "MAX_STRING" "MAX_STRING, from_name, to_name) != 2) { logger(LOG_ERR, "Got bad %s from %s (%s)", "DEL_EDGE", c->name, - c->hostname); + c->hostname); return false; } /* Check if names are valid */ - if(!check_id(from_name) || !check_id(to_name) || !strcmp(from_name, to_name)) { + if(!check_id(from_name) || !check_id(to_name)) { logger(LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_EDGE", c->name, - c->hostname, "invalid name"); + c->hostname, "invalid name"); return false; } - if(seen_request(c->buffer)) { + if(seen_request(request)) return true; - } /* Lookup nodes */ @@ -213,24 +196,24 @@ bool del_edge_h(connection_t *c) { to = lookup_node(to_name); if(tunnelserver && - from != myself && from != c->node && - to != myself && to != c->node) { + from != myself && from != c->node && + to != myself && to != c->node) { /* ignore indirect edge registrations for tunnelserver */ ifdebug(PROTOCOL) logger(LOG_WARNING, - "Ignoring indirect %s from %s (%s)", - "DEL_EDGE", c->name, c->hostname); + "Ignoring indirect %s from %s (%s)", + "DEL_EDGE", c->name, c->hostname); return true; } if(!from) { ifdebug(PROTOCOL) logger(LOG_ERR, "Got %s from %s (%s) which does not appear in the edge tree", - "DEL_EDGE", c->name, c->hostname); + "DEL_EDGE", c->name, c->hostname); return true; } if(!to) { ifdebug(PROTOCOL) logger(LOG_ERR, "Got %s from %s (%s) which does not appear in the edge tree", - "DEL_EDGE", c->name, c->hostname); + "DEL_EDGE", c->name, c->hostname); return true; } @@ -240,23 +223,22 @@ bool del_edge_h(connection_t *c) { if(!e) { ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) which does not appear in the edge tree", - "DEL_EDGE", c->name, c->hostname); + "DEL_EDGE", c->name, c->hostname); return true; } if(e->from == myself) { ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for ourself", - "DEL_EDGE", c->name, c->hostname); + "DEL_EDGE", c->name, c->hostname); contradicting_del_edge++; - send_add_edge(c, e); /* Send back a correction */ + send_add_edge(c, e); /* Send back a correction */ return true; } /* Tell the rest about the deleted edge */ - if(!tunnelserver) { - forward_request(c); - } + if(!tunnelserver) + forward_request(c, request); /* Delete the edge */ @@ -270,12 +252,9 @@ bool del_edge_h(connection_t *c) { if(!to->status.reachable) { e = lookup_edge(to, myself); - if(e) { - if(!tunnelserver) { - send_del_edge(everyone, e); - } - + if(!tunnelserver) + send_del_edge(broadcast, e); edge_del(e); } } diff --git a/src/protocol_key.c b/src/protocol_key.c index 6140a53..5246e7d 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -1,7 +1,7 @@ /* protocol_key.c -- handle the meta-protocol, key exchange Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2016 Guus Sliepen + 2000-2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,16 +20,16 @@ #include "system.h" -#include -#include -#include - -#include "avl_tree.h" +#include "splay_tree.h" +#include "cipher.h" #include "connection.h" +#include "crypto.h" +#include "ecdh.h" #include "logger.h" #include "net.h" #include "netutl.h" #include "node.h" +#include "prf.h" #include "protocol.h" #include "utils.h" #include "xalloc.h" @@ -37,46 +37,38 @@ static bool mykeyused = false; void send_key_changed(void) { - avl_node_t *node; + splay_node_t *node; connection_t *c; - send_request(everyone, "%d %x %s", KEY_CHANGED, rand(), myself->name); + send_request(broadcast, "%d %x %s", KEY_CHANGED, rand(), myself->name); /* Immediately send new keys to directly connected nodes to keep UDP mappings alive */ for(node = connection_tree->head; node; node = node->next) { c = node->data; - - if(c->status.active && c->node && c->node->status.reachable) { + if(c->status.active && c->node && c->node->status.reachable) send_ans_key(c->node); - } } } -bool key_changed_h(connection_t *c) { +bool key_changed_h(connection_t *c, char *request) { char name[MAX_STRING_SIZE]; node_t *n; - if(sscanf(c->buffer, "%*d %*x " MAX_STRING, name) != 1) { + if(sscanf(request, "%*d %*x " MAX_STRING, name) != 1) { logger(LOG_ERR, "Got bad %s from %s (%s)", "KEY_CHANGED", - c->name, c->hostname); + c->name, c->hostname); return false; } - if(!check_id(name)) { - logger(LOG_ERR, "Got bad %s from %s (%s): %s", "KEY_CHANGED", c->name, c->hostname, "invalid name"); - return false; - } - - if(seen_request(c->buffer)) { + if(seen_request(request)) return true; - } n = lookup_node(name); if(!n) { logger(LOG_ERR, "Got %s from %s (%s) origin %s which does not exist", - "KEY_CHANGED", c->name, c->hostname, name); + "KEY_CHANGED", c->name, c->hostname, name); return true; } @@ -85,25 +77,25 @@ bool key_changed_h(connection_t *c) { /* Tell the others */ - if(!tunnelserver) { - forward_request(c); - } + if(!tunnelserver) + forward_request(c, request); return true; } bool send_req_key(node_t *to) { - return send_request(to->nexthop->connection, "%d %s %s", REQ_KEY, myself->name, to->name); + return send_request(to->nexthop->connection, "%d %s %s %d", REQ_KEY, myself->name, to->name, experimental ? 1 : 0); } -bool req_key_h(connection_t *c) { +bool req_key_h(connection_t *c, char *request) { char from_name[MAX_STRING_SIZE]; char to_name[MAX_STRING_SIZE]; node_t *from, *to; + int kx_version = 0; - if(sscanf(c->buffer, "%*d " MAX_STRING " " MAX_STRING, from_name, to_name) != 2) { + if(sscanf(request, "%*d " MAX_STRING " " MAX_STRING " %d", from_name, to_name, &kx_version) < 2) { logger(LOG_ERR, "Got bad %s from %s (%s)", "REQ_KEY", c->name, - c->hostname); + c->hostname); return false; } @@ -116,7 +108,7 @@ bool req_key_h(connection_t *c) { if(!from) { logger(LOG_ERR, "Got %s from %s (%s) origin %s which does not exist in our connection list", - "REQ_KEY", c->name, c->hostname, from_name); + "REQ_KEY", c->name, c->hostname, from_name); return true; } @@ -124,89 +116,106 @@ bool req_key_h(connection_t *c) { if(!to) { logger(LOG_ERR, "Got %s from %s (%s) destination %s which does not exist in our connection list", - "REQ_KEY", c->name, c->hostname, to_name); + "REQ_KEY", c->name, c->hostname, to_name); return true; } /* Check if this key request is for us */ - if(to == myself) { /* Yes, send our own key back */ - if(!send_ans_key(from)) { - return false; + if(to == myself) { /* Yes, send our own key back */ + if(experimental && kx_version >= 1) { + logger(LOG_DEBUG, "Got ECDH key request from %s", from->name); + from->status.ecdh = true; } + send_ans_key(from); } else { - if(tunnelserver) { + if(tunnelserver) return true; - } if(!to->status.reachable) { logger(LOG_WARNING, "Got %s from %s (%s) destination %s which is not reachable", - "REQ_KEY", c->name, c->hostname, to_name); + "REQ_KEY", c->name, c->hostname, to_name); return true; } - send_request(to->nexthop->connection, "%s", c->buffer); + send_request(to->nexthop->connection, "%s", request); } return true; } +bool send_ans_key_ecdh(node_t *to) { + int siglen = ecdsa_size(&myself->connection->ecdsa); + char key[(ECDH_SIZE + siglen) * 2 + 1]; + + if(!ecdh_generate_public(&to->ecdh, key)) + return false; + + if(!ecdsa_sign(&myself->connection->ecdsa, key, ECDH_SIZE, key + ECDH_SIZE)) + return false; + + b64encode(key, key, ECDH_SIZE + siglen); + + char *pubkey = ecdsa_get_base64_public_key(&myself->connection->ecdsa); + + if(!pubkey) + return false; + + int result = send_request(to->nexthop->connection, "%d %s %s ECDH:%s:%s %d %d %zu %d", ANS_KEY, + myself->name, to->name, key, pubkey, + cipher_get_nid(&myself->incipher), + digest_get_nid(&myself->indigest), + digest_length(&myself->indigest), + myself->incompression); + + free(pubkey); + return result; +} + bool send_ans_key(node_t *to) { - // Set key parameters - to->incipher = myself->incipher; - to->inkeylength = myself->inkeylength; - to->indigest = myself->indigest; - to->inmaclength = myself->inmaclength; + if(experimental && to->status.ecdh) + return send_ans_key_ecdh(to); + + size_t keylen = cipher_keylength(&myself->incipher); + char key[keylen * 2 + 1]; + + cipher_open_by_nid(&to->incipher, cipher_get_nid(&myself->incipher)); + digest_open_by_nid(&to->indigest, digest_get_nid(&myself->indigest), digest_length(&myself->indigest)); to->incompression = myself->incompression; - // Allocate memory for key - to->inkey = xrealloc(to->inkey, to->inkeylength); + randomize(key, keylen); + cipher_set_key(&to->incipher, key, false); + digest_set_key(&to->indigest, key, keylen); - // Create a new key - if(1 != RAND_bytes((unsigned char *)to->inkey, to->inkeylength)) { - int err = ERR_get_error(); - logger(LOG_ERR, "Failed to generate random for key (%s)", ERR_error_string(err, NULL)); - return false; // Do not send insecure keys, let connection attempt fail. - } - - if(to->incipher) { - EVP_DecryptInit_ex(to->inctx, to->incipher, NULL, (unsigned char *)to->inkey, (unsigned char *)to->inkey + EVP_CIPHER_key_length(to->incipher)); - } + bin2hex(key, key, keylen); // Reset sequence number and late packet window mykeyused = true; to->received_seqno = 0; + if(replaywin) memset(to->late, 0, replaywin); - if(replaywin) { - memset(to->late, 0, replaywin); - } - - // Convert to hexadecimal and send - char key[2 * to->inkeylength + 1]; - bin2hex(to->inkey, key, to->inkeylength); - key[to->inkeylength * 2] = '\0'; - - return send_request(to->nexthop->connection, "%d %s %s %s %d %d %d %d", ANS_KEY, - myself->name, to->name, key, - to->incipher ? EVP_CIPHER_nid(to->incipher) : 0, - to->indigest ? EVP_MD_type(to->indigest) : 0, to->inmaclength, - to->incompression); + return send_request(to->nexthop->connection, "%d %s %s %s %d %d %zu %d", ANS_KEY, + myself->name, to->name, key, + cipher_get_nid(&to->incipher), + digest_get_nid(&to->indigest), + digest_length(&to->indigest), + to->incompression); } -bool ans_key_h(connection_t *c) { +bool ans_key_h(connection_t *c, char *request) { char from_name[MAX_STRING_SIZE]; char to_name[MAX_STRING_SIZE]; char key[MAX_STRING_SIZE]; - char address[MAX_STRING_SIZE] = ""; - char port[MAX_STRING_SIZE] = ""; - int cipher, digest, maclength, compression; + char address[MAX_STRING_SIZE] = ""; + char port[MAX_STRING_SIZE] = ""; + int cipher, digest, maclength, compression, keylen; node_t *from, *to; - if(sscanf(c->buffer, "%*d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %d %d %d "MAX_STRING" "MAX_STRING, - from_name, to_name, key, &cipher, &digest, &maclength, - &compression, address, port) < 7) { + if(sscanf(request, "%*d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %d %d %d "MAX_STRING" "MAX_STRING, + from_name, to_name, key, &cipher, &digest, &maclength, + &compression, address, port) < 7) { logger(LOG_ERR, "Got bad %s from %s (%s)", "ANS_KEY", c->name, - c->hostname); + c->hostname); return false; } @@ -219,7 +228,7 @@ bool ans_key_h(connection_t *c) { if(!from) { logger(LOG_ERR, "Got %s from %s (%s) origin %s which does not exist in our connection list", - "ANS_KEY", c->name, c->hostname, from_name); + "ANS_KEY", c->name, c->hostname, from_name); return true; } @@ -227,91 +236,50 @@ bool ans_key_h(connection_t *c) { if(!to) { logger(LOG_ERR, "Got %s from %s (%s) destination %s which does not exist in our connection list", - "ANS_KEY", c->name, c->hostname, to_name); + "ANS_KEY", c->name, c->hostname, to_name); return true; } /* Forward it if necessary */ if(to != myself) { - if(tunnelserver) { + if(tunnelserver) return true; - } if(!to->status.reachable) { logger(LOG_WARNING, "Got %s from %s (%s) destination %s which is not reachable", - "ANS_KEY", c->name, c->hostname, to_name); + "ANS_KEY", c->name, c->hostname, to_name); return true; } - if(!*address && from->address.sa.sa_family != AF_UNSPEC && to->minmtu) { + if(!*address && from->address.sa.sa_family != AF_UNSPEC) { char *address, *port; ifdebug(PROTOCOL) logger(LOG_DEBUG, "Appending reflexive UDP address to ANS_KEY from %s to %s", from->name, to->name); sockaddr2str(&from->address, &address, &port); - send_request(to->nexthop->connection, "%s %s %s", c->buffer, address, port); + send_request(to->nexthop->connection, "%s %s %s", request, address, port); free(address); free(port); return true; } - return send_request(to->nexthop->connection, "%s", c->buffer); - } - - /* Don't use key material until every check has passed. */ - from->status.validkey = false; - - /* Update our copy of the origin's packet key */ - from->outkey = xrealloc(from->outkey, strlen(key) / 2); - from->outkeylength = strlen(key) / 2; - - if(!hex2bin(key, from->outkey, from->outkeylength)) { - logger(LOG_ERR, "Got bad %s from %s(%s): %s", "ANS_KEY", from->name, from->hostname, "invalid key"); - return true; + return send_request(to->nexthop->connection, "%s", request); } /* Check and lookup cipher and digest algorithms */ - if(cipher) { - from->outcipher = EVP_get_cipherbynid(cipher); - - if(!from->outcipher) { - logger(LOG_ERR, "Node %s (%s) uses unknown cipher!", from->name, - from->hostname); - return true; - } - - if(from->outkeylength != EVP_CIPHER_key_length(from->outcipher) + EVP_CIPHER_iv_length(from->outcipher)) { - logger(LOG_ERR, "Node %s (%s) uses wrong keylength!", from->name, - from->hostname); - return true; - } - } else { - if(from->outkeylength != 1) { - logger(LOG_ERR, "Node %s (%s) uses wrong keylength!", from->name, from->hostname); - return true; - } - - from->outcipher = NULL; + if(!cipher_open_by_nid(&from->outcipher, cipher)) { + logger(LOG_ERR, "Node %s (%s) uses unknown cipher!", from->name, from->hostname); + return false; } - from->outmaclength = maclength; + if(!digest_open_by_nid(&from->outdigest, digest, maclength)) { + logger(LOG_ERR, "Node %s (%s) uses unknown digest!", from->name, from->hostname); + return false; + } - if(digest) { - from->outdigest = EVP_get_digestbynid(digest); - - if(!from->outdigest) { - logger(LOG_ERR, "Node %s (%s) uses unknown digest!", from->name, - from->hostname); - return true; - } - - if(from->outmaclength > EVP_MD_size(from->outdigest) || from->outmaclength < 0) { - logger(LOG_ERR, "Node %s (%s) uses bogus MAC length!", - from->name, from->hostname); - return true; - } - } else { - from->outdigest = NULL; + if(maclength != digest_length(&from->outdigest)) { + logger(LOG_ERR, "Node %s (%s) uses bogus MAC length!", from->name, from->hostname); + return false; } if(compression < 0 || compression > 11) { @@ -321,13 +289,113 @@ bool ans_key_h(connection_t *c) { from->outcompression = compression; - if(from->outcipher) - if(!EVP_EncryptInit_ex(from->outctx, from->outcipher, NULL, (unsigned char *)from->outkey, (unsigned char *)from->outkey + EVP_CIPHER_key_length(from->outcipher))) { - logger(LOG_ERR, "Error during initialisation of key from %s (%s): %s", - from->name, from->hostname, ERR_error_string(ERR_get_error(), NULL)); + /* ECDH or old-style key exchange? */ + + if(experimental && !strncmp(key, "ECDH:", 5)) { + char *pubkey = strchr(key + 5, ':'); + if(pubkey) + *pubkey++ = 0; + + /* Check if we already have an ECDSA public key for this node. + * If not, use the one from the key exchange, and store it. */ + + if(!node_read_ecdsa_public_key(from)) { + if(!pubkey) { + logger(LOG_ERR, "No ECDSA public key known for %s (%s), cannot verify ECDH key exchange!", from->name, from->hostname); + return true; + } + + if(!ecdsa_set_base64_public_key(&from->ecdsa, pubkey)) + return true; + + append_config_file(from->name, "ECDSAPublicKey", pubkey); + } + + int siglen = ecdsa_size(&from->ecdsa); + int keylen = b64decode(key + 5, key + 5, sizeof key - 5); + + if(keylen != ECDH_SIZE + siglen) { + logger(LOG_ERR, "Node %s (%s) uses wrong keylength! %d != %d", from->name, from->hostname, keylen, ECDH_SIZE + siglen); return true; } + if(ECDH_SHARED_SIZE < cipher_keylength(&from->outcipher)) { + logger(LOG_ERR, "ECDH key too short for cipher of %s!", from->name); + return true; + } + + if(!ecdsa_verify(&from->ecdsa, key + 5, ECDH_SIZE, key + 5 + ECDH_SIZE)) { + logger(LOG_ERR, "Possible intruder %s (%s): %s", from->name, from->hostname, "invalid ECDSA signature"); + return true; + } + + if(!from->ecdh) { + from->status.ecdh = true; + if(!send_ans_key(from)) + return true; + } + + char shared[ECDH_SHARED_SIZE * 2 + 1]; + + if(!ecdh_compute_shared(&from->ecdh, key + 5, shared)) + return true; + + /* Update our crypto end */ + + size_t mykeylen = cipher_keylength(&myself->incipher); + size_t hiskeylen = cipher_keylength(&from->outcipher); + + char *mykey; + char *hiskey; + char *seed; + + if(strcmp(myself->name, from->name) < 0) { + mykey = key; + hiskey = key + mykeylen * 2; + xasprintf(&seed, "tinc UDP key expansion %s %s", myself->name, from->name); + } else { + mykey = key + hiskeylen * 2; + hiskey = key; + xasprintf(&seed, "tinc UDP key expansion %s %s", from->name, myself->name); + } + + if(!prf(shared, ECDH_SHARED_SIZE, seed, strlen(seed), key, hiskeylen * 2 + mykeylen * 2)) + return true; + + free(seed); + + cipher_open_by_nid(&from->incipher, cipher_get_nid(&myself->incipher)); + digest_open_by_nid(&from->indigest, digest_get_nid(&myself->indigest), digest_length(&myself->indigest)); + from->incompression = myself->incompression; + + cipher_set_key(&from->incipher, mykey, false); + digest_set_key(&from->indigest, mykey + mykeylen, mykeylen); + + cipher_set_key(&from->outcipher, hiskey, true); + digest_set_key(&from->outdigest, hiskey + hiskeylen, hiskeylen); + + // Reset sequence number and late packet window + mykeyused = true; + from->received_seqno = 0; + if(replaywin) + memset(from->late, 0, replaywin); + + if(strcmp(myself->name, from->name) < 0) + memmove(key, key + mykeylen * 2, hiskeylen * 2); + } else { + keylen = hex2bin(key, key, sizeof key); + + if(keylen != cipher_keylength(&from->outcipher)) { + logger(LOG_ERR, "Node %s (%s) uses wrong keylength!", from->name, from->hostname); + return true; + } + + /* Update our copy of the origin's packet key */ + + cipher_set_key(&from->outcipher, key, true); + digest_set_key(&from->outdigest, key, keylen); + } + from->status.validkey = true; from->sent_seqno = 0; @@ -337,9 +405,8 @@ bool ans_key_h(connection_t *c) { update_node_udp(from, &sa); } - if(from->options & OPTION_PMTU_DISCOVERY && !from->mtuevent) { + if(from->options & OPTION_PMTU_DISCOVERY) send_mtu_probe(from); - } return true; } diff --git a/src/protocol_misc.c b/src/protocol_misc.c index 904ac3f..225d7b4 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -1,7 +1,7 @@ /* protocol_misc.c -- handle the meta-protocol, miscellaneous functions Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2012 Guus Sliepen + 2000-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,14 +31,70 @@ int maxoutbufsize = 0; +/* Status and error notification routines */ + +bool send_status(connection_t *c, int statusno, const char *statusstring) { + if(!statusstring) + statusstring = "Status"; + + return send_request(c, "%d %d %s", STATUS, statusno, statusstring); +} + +bool status_h(connection_t *c, char *request) { + int statusno; + char statusstring[MAX_STRING_SIZE]; + + if(sscanf(request, "%*d %d " MAX_STRING, &statusno, statusstring) != 2) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "STATUS", + c->name, c->hostname); + return false; + } + + ifdebug(STATUS) logger(LOG_NOTICE, "Status message from %s (%s): %d: %s", + c->name, c->hostname, statusno, statusstring); + + return true; +} + +bool send_error(connection_t *c, int err, const char *errstring) { + if(!errstring) + errstring = "Error"; + + return send_request(c, "%d %d %s", ERROR, err, errstring); +} + +bool error_h(connection_t *c, char *request) { + int err; + char errorstring[MAX_STRING_SIZE]; + + if(sscanf(request, "%*d %d " MAX_STRING, &err, errorstring) != 2) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "ERROR", + c->name, c->hostname); + return false; + } + + ifdebug(ERROR) logger(LOG_NOTICE, "Error message from %s (%s): %d: %s", + c->name, c->hostname, err, errorstring); + + return false; +} + +bool send_termreq(connection_t *c) { + return send_request(c, "%d", TERMREQ); +} + +bool termreq_h(connection_t *c, char *request) { + return false; +} + bool send_ping(connection_t *c) { c->status.pinged = true; - c->last_ping_time = now; + c->last_ping_time = time(NULL); return send_request(c, "%d", PING); } -bool ping_h(connection_t *c) { +bool ping_h(connection_t *c, char *request) { return send_pong(c); } @@ -46,22 +102,13 @@ bool send_pong(connection_t *c) { return send_request(c, "%d", PONG); } -bool pong_h(connection_t *c) { +bool pong_h(connection_t *c, char *request) { c->status.pinged = false; - /* Successful connection, reset timeout if this is an outgoing connection. */ + /* Succesful connection, reset timeout if this is an outgoing connection. */ - if(c->outgoing) { + if(c->outgoing) c->outgoing->timeout = 0; - c->outgoing->cfg = NULL; - - if(c->outgoing->ai) { - freeaddrinfo(c->outgoing->ai); - } - - c->outgoing->ai = NULL; - c->outgoing->aip = NULL; - } return true; } @@ -70,25 +117,23 @@ bool pong_h(connection_t *c) { bool send_tcppacket(connection_t *c, const vpn_packet_t *packet) { /* If there already is a lot of data in the outbuf buffer, discard this packet. - We use a very simple Random Early Drop algorithm. */ + We use a very simple Random Early Drop algorithm. */ - if(2.0 * c->outbuflen / (float)maxoutbufsize - 1 > (float)rand() / (float)RAND_MAX) { + if(2.0 * c->outbuf.len / (float)maxoutbufsize - 1 > (float)rand()/(float)RAND_MAX) return true; - } - if(!send_request(c, "%d %hd", PACKET, packet->len)) { + if(!send_request(c, "%d %hd", PACKET, packet->len)) return false; - } - return send_meta(c, (char *)packet->data, packet->len) && flush_meta(c); + return send_meta(c, (char *)packet->data, packet->len); } -bool tcppacket_h(connection_t *c) { - length_t len; +bool tcppacket_h(connection_t *c, char *request) { + short int len; - if(sscanf(c->buffer, "%*d %hu", &len) != 1) { + if(sscanf(request, "%*d %hd", &len) != 1) { logger(LOG_ERR, "Got bad %s from %s (%s)", "PACKET", c->name, - c->hostname); + c->hostname); return false; } diff --git a/src/protocol_subnet.c b/src/protocol_subnet.c index 2c4d08f..6f9e626 100644 --- a/src/protocol_subnet.c +++ b/src/protocol_subnet.c @@ -35,22 +35,21 @@ bool send_add_subnet(connection_t *c, const subnet_t *subnet) { char netstr[MAXNETSTR]; - if(!net2str(netstr, sizeof(netstr), subnet)) { + if(!net2str(netstr, sizeof netstr, subnet)) return false; - } return send_request(c, "%d %x %s %s", ADD_SUBNET, rand(), subnet->owner->name, netstr); } -bool add_subnet_h(connection_t *c) { +bool add_subnet_h(connection_t *c, char *request) { char subnetstr[MAX_STRING_SIZE]; char name[MAX_STRING_SIZE]; node_t *owner; - subnet_t s = {0}, *new, *old; + subnet_t s = {NULL}, *new, *old; - if(sscanf(c->buffer, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) { + if(sscanf(request, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) { logger(LOG_ERR, "Got bad %s from %s (%s)", "ADD_SUBNET", c->name, - c->hostname); + c->hostname); return false; } @@ -58,7 +57,7 @@ bool add_subnet_h(connection_t *c) { if(!check_id(name)) { logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_SUBNET", c->name, - c->hostname, "invalid name"); + c->hostname, "invalid name"); return false; } @@ -66,13 +65,12 @@ bool add_subnet_h(connection_t *c) { if(!str2net(&s, subnetstr)) { logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_SUBNET", c->name, - c->hostname, "invalid subnet string"); + c->hostname, "invalid subnet string"); return false; } - if(seen_request(c->buffer)) { + if(seen_request(request)) return true; - } /* Check if the owner of the new subnet is in the connection list */ @@ -81,7 +79,7 @@ bool add_subnet_h(connection_t *c) { if(tunnelserver && owner != myself && owner != c->node) { /* in case of tunnelserver, ignore indirect subnet registrations */ ifdebug(PROTOCOL) logger(LOG_WARNING, "Ignoring indirect %s from %s (%s) for %s", - "ADD_SUBNET", c->name, c->hostname, subnetstr); + "ADD_SUBNET", c->name, c->hostname, subnetstr); return true; } @@ -93,15 +91,14 @@ bool add_subnet_h(connection_t *c) { /* Check if we already know this subnet */ - if(lookup_subnet(owner, &s)) { + if(lookup_subnet(owner, &s)) return true; - } /* If we don't know this subnet, but we are the owner, retaliate with a DEL_SUBNET */ if(owner == myself) { ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for ourself", - "ADD_SUBNET", c->name, c->hostname); + "ADD_SUBNET", c->name, c->hostname); s.owner = myself; send_del_subnet(c, &s); return true; @@ -111,7 +108,7 @@ bool add_subnet_h(connection_t *c) { if(tunnelserver) { logger(LOG_WARNING, "Ignoring unauthorized %s from %s (%s): %s", - "ADD_SUBNET", c->name, c->hostname, subnetstr); + "ADD_SUBNET", c->name, c->hostname, subnetstr); return true; } @@ -119,8 +116,8 @@ bool add_subnet_h(connection_t *c) { if(strictsubnets) { logger(LOG_WARNING, "Ignoring unauthorized %s from %s (%s): %s", - "ADD_SUBNET", c->name, c->hostname, subnetstr); - forward_request(c); + "ADD_SUBNET", c->name, c->hostname, subnetstr); + forward_request(c, request); return true; } @@ -129,19 +126,18 @@ bool add_subnet_h(connection_t *c) { *(new = new_subnet()) = s; subnet_add(owner, new); - if(owner->status.reachable) { + if(owner->status.reachable) subnet_update(owner, new, true); - } /* Tell the rest */ - forward_request(c); + if(!tunnelserver) + forward_request(c, request); /* Fast handoff of roaming MAC addresses */ - if(s.type == SUBNET_MAC && owner != myself && (old = lookup_subnet(myself, &s)) && old->expires) { - old->expires = now; - } + if(s.type == SUBNET_MAC && owner != myself && (old = lookup_subnet(myself, &s)) && old->expires) + old->expires = 1; return true; } @@ -149,22 +145,21 @@ bool add_subnet_h(connection_t *c) { bool send_del_subnet(connection_t *c, const subnet_t *s) { char netstr[MAXNETSTR]; - if(!net2str(netstr, sizeof(netstr), s)) { + if(!net2str(netstr, sizeof netstr, s)) return false; - } return send_request(c, "%d %x %s %s", DEL_SUBNET, rand(), s->owner->name, netstr); } -bool del_subnet_h(connection_t *c) { +bool del_subnet_h(connection_t *c, char *request) { char subnetstr[MAX_STRING_SIZE]; char name[MAX_STRING_SIZE]; node_t *owner; - subnet_t s = {0}, *find; + subnet_t s = {NULL}, *find; - if(sscanf(c->buffer, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) { + if(sscanf(request, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) { logger(LOG_ERR, "Got bad %s from %s (%s)", "DEL_SUBNET", c->name, - c->hostname); + c->hostname); return false; } @@ -172,7 +167,7 @@ bool del_subnet_h(connection_t *c) { if(!check_id(name)) { logger(LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_SUBNET", c->name, - c->hostname, "invalid name"); + c->hostname, "invalid name"); return false; } @@ -180,13 +175,12 @@ bool del_subnet_h(connection_t *c) { if(!str2net(&s, subnetstr)) { logger(LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_SUBNET", c->name, - c->hostname, "invalid subnet string"); + c->hostname, "invalid subnet string"); return false; } - if(seen_request(c->buffer)) { + if(seen_request(request)) return true; - } /* Check if the owner of the subnet being deleted is in the connection list */ @@ -195,13 +189,13 @@ bool del_subnet_h(connection_t *c) { if(tunnelserver && owner != myself && owner != c->node) { /* in case of tunnelserver, ignore indirect subnet deletion */ ifdebug(PROTOCOL) logger(LOG_WARNING, "Ignoring indirect %s from %s (%s) for %s", - "DEL_SUBNET", c->name, c->hostname, subnetstr); + "DEL_SUBNET", c->name, c->hostname, subnetstr); return true; } if(!owner) { ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for %s which is not in our node tree", - "DEL_SUBNET", c->name, c->hostname, name); + "DEL_SUBNET", c->name, c->hostname, name); return true; } @@ -213,12 +207,9 @@ bool del_subnet_h(connection_t *c) { if(!find) { ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for %s which does not appear in his subnet tree", - "DEL_SUBNET", c->name, c->hostname, name); - - if(strictsubnets) { - forward_request(c); - } - + "DEL_SUBNET", c->name, c->hostname, name); + if(strictsubnets) + forward_request(c, request); return true; } @@ -226,28 +217,25 @@ bool del_subnet_h(connection_t *c) { if(owner == myself) { ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for ourself", - "DEL_SUBNET", c->name, c->hostname); + "DEL_SUBNET", c->name, c->hostname); send_add_subnet(c, find); return true; } - if(tunnelserver) { + if(tunnelserver) return true; - } /* Tell the rest */ - forward_request(c); - - if(strictsubnets) { + if(!tunnelserver) + forward_request(c, request); + if(strictsubnets) return true; - } /* Finally, delete it. */ - if(owner->status.reachable) { + if(owner->status.reachable) subnet_update(owner, find, false); - } subnet_del(owner, find); diff --git a/src/proxy.c b/src/proxy.c deleted file mode 100644 index 979626c..0000000 --- a/src/proxy.c +++ /dev/null @@ -1,366 +0,0 @@ -/* - proxy.c -- Proxy handling functions. - Copyright (C) 2015-2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "connection.h" -#include "logger.h" -#include "meta.h" -#include "netutl.h" -#include "protocol.h" -#include "proxy.h" -#include "utils.h" // - -proxytype_t proxytype; -char *proxyhost; -char *proxyport; -char *proxyuser; -char *proxypass; - -static void update_address_ipv4(connection_t *c, void *address, void *port) { - sockaddrfree(&c->address); - memset(&c->address, 0, sizeof(c->address)); - c->address.sa.sa_family = AF_INET; - - if(address) { - memcpy(&c->address.in.sin_addr, address, sizeof(ipv4_t)); - } - - if(port) { - memcpy(&c->address.in.sin_port, port, sizeof(uint16_t)); - } - - // OpenSSH -D returns all zero address, set it to 0.0.0.1 to prevent spamming ourselves. - if(!memcmp(&c->address.in.sin_addr, "\0\0\0\0", 4)) { - memcpy(&c->address.in.sin_addr, "\0\0\0\01", 4); - } -} - -static void update_address_ipv6(connection_t *c, void *address, void *port) { - sockaddrfree(&c->address); - memset(&c->address, 0, sizeof(c->address)); - c->address.sa.sa_family = AF_INET6; - - if(address) { - memcpy(&c->address.in6.sin6_addr, address, sizeof(ipv6_t)); - } - - if(port) { - memcpy(&c->address.in6.sin6_port, port, sizeof(uint16_t)); - } - - // OpenSSH -D returns all zero address, set it to 0100:: to prevent spamming ourselves. - if(!memcmp(&c->address.in6.sin6_addr, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16)) { - memcpy(&c->address.in6.sin6_addr, "\01\0\0\0\0\0\0\0", 8); - } -} - -bool send_proxyrequest(connection_t *c) { - switch(proxytype) { - case PROXY_SOCKS4: - if(c->address.sa.sa_family != AF_INET) { - logger(LOG_ERR, "Can only connect to numeric IPv4 addresses through a SOCKS 4 proxy!"); - return false; - } - - // fallthrough - case PROXY_SOCKS4A: { - if(c->address.sa.sa_family != AF_INET && c->address.sa.sa_family != AF_UNKNOWN) { - logger(LOG_ERR, "Can only connect to IPv4 addresses or hostnames through a SOCKS 4a proxy!"); - return false; - } - - int len = 9; - - if(proxyuser) { - len += strlen(proxyuser); - } - - if(c->address.sa.sa_family == AF_UNKNOWN) { - len += 1 + strlen(c->address.unknown.address); - } - - char s4req[len]; - s4req[0] = 4; - s4req[1] = 1; - - if(c->address.sa.sa_family == AF_INET) { - memcpy(s4req + 2, &c->address.in.sin_port, 2); - memcpy(s4req + 4, &c->address.in.sin_addr, 4); - } else { - uint16_t port = htons(atoi(c->address.unknown.port)); - memcpy(s4req + 2, &port, 2); - memcpy(s4req + 4, "\0\0\0\1", 4); - strcpy(s4req + (9 + (proxyuser ? strlen(proxyuser) : 0)), c->address.unknown.address); - } - - if(proxyuser) { - strcpy(s4req + 8, proxyuser); - } else { - s4req[8] = 0; - } - - s4req[sizeof(s4req) - 1] = 0; - c->allow_request = PROXY; - return send_meta(c, s4req, sizeof(s4req)); - } - - case PROXY_SOCKS5: { - int len = 3 + 6; - - if(c->address.sa.sa_family == AF_INET) { - len += 4; - } else if(c->address.sa.sa_family == AF_INET6) { - len += 16; - } else if(c->address.sa.sa_family == AF_UNKNOWN) { - len += 1 + strlen(c->address.unknown.address); - } else { - logger(LOG_ERR, "Address family %x not supported for SOCKS 5 proxies!", c->address.sa.sa_family); - return false; - } - - if(proxypass) { - len += 3 + strlen(proxyuser) + strlen(proxypass); - } - - char s5req[len]; - int i = 0; - s5req[i++] = 5; - s5req[i++] = 1; - - if(proxypass) { - s5req[i++] = 2; - s5req[i++] = 1; - s5req[i++] = strlen(proxyuser); - strcpy(s5req + i, proxyuser); - i += strlen(proxyuser); - s5req[i++] = strlen(proxypass); - strcpy(s5req + i, proxypass); - i += strlen(proxypass); - } else { - s5req[i++] = 0; - } - - s5req[i++] = 5; - s5req[i++] = 1; - s5req[i++] = 0; - - if(c->address.sa.sa_family == AF_INET) { - s5req[i++] = 1; - memcpy(s5req + i, &c->address.in.sin_addr, 4); - i += 4; - memcpy(s5req + i, &c->address.in.sin_port, 2); - i += 2; - } else if(c->address.sa.sa_family == AF_INET6) { - s5req[i++] = 4; - memcpy(s5req + i, &c->address.in6.sin6_addr, 16); - i += 16; - memcpy(s5req + i, &c->address.in6.sin6_port, 2); - i += 2; - } else if(c->address.sa.sa_family == AF_UNKNOWN) { - s5req[i++] = 3; - int len = strlen(c->address.unknown.address); - s5req[i++] = len; - memcpy(s5req + i, c->address.unknown.address, len); - i += len; - uint16_t port = htons(atoi(c->address.unknown.port)); - memcpy(s5req + i, &port, 2); - i += 2; - } else { - logger(LOG_ERR, "Unknown address family while trying to connect to SOCKS5 proxy"); - return false; - } - - if(i > len) { - abort(); - } - - c->allow_request = PROXY; - return send_meta(c, s5req, sizeof(s5req)); - } - - case PROXY_HTTP: { - char *host; - char *port; - - sockaddr2str(&c->address, &host, &port); - send_request(c, "CONNECT %s:%s HTTP/1.1\r\n\r", host, port); - free(host); - free(port); - c->allow_request = PROXY; - return true; - } - - case PROXY_EXEC: - abort(); - - default: - logger(LOG_ERR, "Unknown proxy type"); - return false; - } -} - -int receive_proxy_meta(connection_t *c) { - switch(proxytype) { - case PROXY_SOCKS4: - case PROXY_SOCKS4A: - if(c->buflen < 8) { - return 0; - } - - if(c->buffer[0] == 0 && c->buffer[1] == 0x5a) { - if(c->address.sa.sa_family == AF_UNKNOWN) { - update_address_ipv4(c, c->buffer + 4, c->buffer + 2); - } - - ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Proxy request granted"); - c->allow_request = ID; - c->status.proxy_passed = true; - send_id(c); - return 8; - } else { - logger(LOG_ERR, "Proxy request rejected"); - return -1; - } - - case PROXY_SOCKS5: - if(c->buflen < 2) { - return 0; - } - - if(c->buffer[0] != 0x05 || c->buffer[1] == (char)0xff) { - logger(LOG_ERR, "Proxy authentication method rejected"); - return -1; - } - - int offset = 2; - - if(c->buffer[1] == 0x02) { - if(c->buflen < 4) { - return 0; - } - - if(c->buffer[2] != 0x05 || c->buffer[3] != 0x00) { - logger(LOG_ERR, "Proxy username/password rejected"); - return -1; - } - - offset += 2; - } - - if(c->buflen - offset < 7) { - return 0; - } - - if(c->buffer[offset] != 0x05 || c->buffer[offset + 1] != 0x00) { - logger(LOG_ERR, "Proxy request rejected"); - return -1; - } - - int replen = offset + 6; - - switch(c->buffer[offset + 3]) { - case 0x01: // IPv4 - if(c->address.sa.sa_family == AF_UNKNOWN) { - update_address_ipv4(c, c->buffer + offset + 4, c->buffer + offset + 8); - } - - replen += 4; - break; - - case 0x03: // Hostname - if(c->address.sa.sa_family == AF_UNKNOWN) { - update_address_ipv4(c, "\0\0\0\1", "\0\0"); - } - - replen += ((uint8_t *)c->buffer)[offset + 4]; - break; - - case 0x04: // IPv6 - if(c->address.sa.sa_family == AF_UNKNOWN) { - update_address_ipv6(c, c->buffer + offset + 4, c->buffer + offset + 20); - } - - replen += 16; - break; - - default: - logger(LOG_ERR, "Proxy reply malformed"); - return -1; - } - - if(c->buflen < replen) { - return 0; - } else { - ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Proxy request granted"); - c->allow_request = ID; - c->status.proxy_passed = true; - send_id(c); - return replen; - } - - case PROXY_HTTP: { - char *p = memchr(c->buffer, '\n', c->buflen); - - if(!p || p - c->buffer >= c->buflen) { - return 0; - } - - while((p = memchr(p + 1, '\n', c->buflen - (p + 1 - c->buffer)))) { - if(p > c->buffer + 3 && !memcmp(p - 3, "\r\n\r\n", 4)) { - break; - } - } - - if(!p) { - return 0; - } - - if(c->buflen < 9) { - return 0; - } - - if(!strncasecmp(c->buffer, "HTTP/1.1 ", 9)) { - if(!strncmp(c->buffer + 9, "200", 3)) { - if(c->address.sa.sa_family == AF_UNKNOWN) { - update_address_ipv4(c, "\0\0\0\1", "\0\0"); - } - - logger(LOG_DEBUG, "Proxy request granted"); - replen = p + 1 - c->buffer; - c->allow_request = ID; - c->status.proxy_passed = true; - send_id(c); - return replen; - } else { - p = memchr(c->buffer, '\n', c->buflen); - p[-1] = 0; - logger(LOG_ERR, "Proxy request rejected: %s", c->buffer + 9); - return false; - } - } else { - logger(LOG_ERR, "Proxy reply malformed"); - return -1; - } - } - - default: - abort(); - } -} diff --git a/src/raw_socket_device.c b/src/raw_socket/device.c similarity index 61% rename from src/raw_socket_device.c rename to src/raw_socket/device.c index f4ed694..410e46e 100644 --- a/src/raw_socket_device.c +++ b/src/raw_socket/device.c @@ -1,7 +1,7 @@ /* device.c -- raw socket Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2014 Guus Sliepen + 2002-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,9 +20,7 @@ #include "system.h" -#ifdef HAVE_NETPACKET_PACKET_H #include -#endif #include "conf.h" #include "device.h" @@ -32,51 +30,49 @@ #include "route.h" #include "xalloc.h" -#if defined(PF_PACKET) && defined(ETH_P_ALL) && defined(AF_PACKET) && defined(SIOCGIFINDEX) -static const char *device_info = "raw_socket"; +int device_fd = -1; +char *device = NULL; +char *iface = NULL; +static char ifrname[IFNAMSIZ]; +static char *device_info; static uint64_t device_total_in = 0; static uint64_t device_total_out = 0; -static bool setup_device(void) { +bool setup_device(void) { struct ifreq ifr; struct sockaddr_ll sa; - if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) { + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) iface = xstrdup("eth0"); - } - if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { + if(!get_config_string(lookup_config(config_tree, "Device"), &device)) device = xstrdup(iface); - } + + device_info = "raw socket"; if((device_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) { logger(LOG_ERR, "Could not open %s: %s", device_info, - strerror(errno)); + strerror(errno)); return false; } -#ifdef FD_CLOEXEC - fcntl(device_fd, F_SETFD, FD_CLOEXEC); -#endif - - memset(&ifr, 0, sizeof(ifr)); + memset(&ifr, 0, sizeof ifr); strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ); - ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0; - if(ioctl(device_fd, SIOCGIFINDEX, &ifr)) { close(device_fd); - logger(LOG_ERR, "Can't find interface %s: %s", ifr.ifr_ifrn.ifrn_name, strerror(errno)); + logger(LOG_ERR, "Can't find interface %s: %s", iface, + strerror(errno)); return false; } - memset(&sa, 0, sizeof(sa)); + memset(&sa, '0', sizeof sa); sa.sll_family = AF_PACKET; sa.sll_protocol = htons(ETH_P_ALL); sa.sll_ifindex = ifr.ifr_ifindex; - if(bind(device_fd, (struct sockaddr *) &sa, (socklen_t) sizeof(sa))) { - logger(LOG_ERR, "Could not bind %s to %s: %s", device, ifr.ifr_ifrn.ifrn_name, strerror(errno)); + if(bind(device_fd, (struct sockaddr *) &sa, (socklen_t) sizeof sa)) { + logger(LOG_ERR, "Could not bind %s to %s: %s", device, iface, strerror(errno)); return false; } @@ -85,39 +81,39 @@ static bool setup_device(void) { return true; } -static void close_device(void) { +void close_device(void) { close(device_fd); free(device); free(iface); } -static bool read_packet(vpn_packet_t *packet) { - int lenin; +bool read_packet(vpn_packet_t *packet) { + int inlen; - if((lenin = read(device_fd, packet->data, MTU)) <= 0) { + if((inlen = read(device_fd, packet->data, MTU)) <= 0) { logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, - device, strerror(errno)); + device, strerror(errno)); return false; } - packet->len = lenin; + packet->len = inlen; device_total_in += packet->len; ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, - device_info); + device_info); return true; } -static bool write_packet(vpn_packet_t *packet) { +bool write_packet(vpn_packet_t *packet) { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + packet->len, device_info); if(write(device_fd, packet->data, packet->len) < 0) { logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, - strerror(errno)); + strerror(errno)); return false; } @@ -126,32 +122,8 @@ static bool write_packet(vpn_packet_t *packet) { return true; } -static void dump_device_stats(void) { +void dump_device_stats(void) { logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); } - -const devops_t raw_socket_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, - .dump_stats = dump_device_stats, -}; - -#else - -static bool not_supported(void) { - logger(LOG_ERR, "Raw socket device not supported on this platform"); - return false; -} - -const devops_t raw_socket_devops = { - .setup = not_supported, - .close = NULL, - .read = NULL, - .write = NULL, - .dump_stats = NULL, -}; -#endif diff --git a/src/route.c b/src/route.c index 850a146..0b2d22e 100644 --- a/src/route.c +++ b/src/route.c @@ -1,8 +1,7 @@ /* route.c -- routing Copyright (C) 2000-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen - 2015-2016 Vittorio Gambaletta + 2000-2010 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,12 +20,14 @@ #include "system.h" -#include "avl_tree.h" +#include "splay_tree.h" #include "connection.h" +#include "control_common.h" #include "ethernet.h" #include "ipv4.h" #include "ipv6.h" #include "logger.h" +#include "meta.h" #include "net.h" #include "protocol.h" #include "route.h" @@ -35,13 +36,12 @@ rmode_t routing_mode = RMODE_ROUTER; fmode_t forwarding_mode = FMODE_INTERNAL; -bmode_t broadcast_mode = BMODE_MST; -bool decrement_ttl = false; bool directonly = false; bool priorityinheritance = false; int macexpire = 600; bool overwrite_mac = false; mac_t mymac = {{0xFE, 0xFD, 0, 0, 0, 0}}; +bool pcap = false; /* Sizes of various headers */ @@ -58,6 +58,8 @@ static const size_t opt_size = sizeof(struct nd_opt_hdr); #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif +static struct event age_subnets_event; + /* RFC 1071 */ static uint16_t inet_checksum(void *data, int len, uint16_t prevsum) { @@ -68,14 +70,12 @@ static uint16_t inet_checksum(void *data, int len, uint16_t prevsum) { checksum += *p++; len -= 2; } - - if(len) { + + if(len) checksum += *(uint8_t *)p; - } - while(checksum >> 16) { + while(checksum >> 16) checksum = (checksum & 0xFFFF) + (checksum >> 16); - } return ~checksum; } @@ -83,17 +83,16 @@ static uint16_t inet_checksum(void *data, int len, uint16_t prevsum) { static bool ratelimit(int frequency) { static time_t lasttime = 0; static int count = 0; - + time_t now = time(NULL); + if(lasttime == now) { - if(count >= frequency) { + if(++count > frequency) return true; - } } else { lasttime = now; count = 0; } - count++; return false; } @@ -101,32 +100,175 @@ static bool checklength(node_t *source, vpn_packet_t *packet, length_t length) { if(packet->len < length) { ifdebug(TRAFFIC) logger(LOG_WARNING, "Got too short packet from %s (%s)", source->name, source->hostname); return false; - } else { + } else return true; +} + +static void clamp_mss(const node_t *source, const node_t *via, vpn_packet_t *packet) { + if(!source || !via || !(via->options & OPTION_CLAMP_MSS)) + return; + + uint16_t mtu = source->mtu; + if(via != myself && via->mtu < mtu) + mtu = via->mtu; + + /* Find TCP header */ + int start = 0; + uint16_t type = packet->data[12] << 8 | packet->data[13]; + + if(type == ETH_P_IP && packet->data[23] == 6) + start = 14 + (packet->data[14] & 0xf) * 4; + else if(type == ETH_P_IPV6 && packet->data[20] == 6) + start = 14 + 40; + + if(!start || packet->len <= start + 20) + return; + + /* Use data offset field to calculate length of options field */ + int len = ((packet->data[start + 12] >> 4) - 5) * 4; + + if(packet->len < start + 20 + len) + return; + + /* Search for MSS option header */ + for(int i = 0; i < len;) { + if(packet->data[start + 20 + i] == 0) + break; + + if(packet->data[start + 20 + i] == 1) { + i++; + continue; + } + + if(i > len - 2 || i > len - packet->data[start + 21 + i]) + break; + + if(packet->data[start + 20 + i] != 2) { + if(packet->data[start + 21 + i] < 2) + break; + i += packet->data[start + 21 + i]; + continue; + } + + if(packet->data[start + 21] != 4) + break; + + /* Found it */ + uint16_t oldmss = packet->data[start + 22 + i] << 8 | packet->data[start + 23 + i]; + uint16_t newmss = mtu - start - 20; + uint16_t csum = packet->data[start + 16] << 8 | packet->data[start + 17]; + + if(oldmss <= newmss) + break; + + ifdebug(TRAFFIC) logger(LOG_INFO, "Clamping MSS of packet from %s to %s to %d", source->name, via->name, newmss); + + /* Update the MSS value and the checksum */ + packet->data[start + 22 + i] = newmss >> 8; + packet->data[start + 23 + i] = newmss & 0xff; + csum ^= 0xffff; + csum -= oldmss; + csum += newmss; + csum ^= 0xffff; + packet->data[start + 16] = csum >> 8; + packet->data[start + 17] = csum & 0xff; + break; } } static void swap_mac_addresses(vpn_packet_t *packet) { mac_t tmp; - memcpy(&tmp, &packet->data[0], sizeof(tmp)); - memcpy(&packet->data[0], &packet->data[6], sizeof(tmp)); - memcpy(&packet->data[6], &tmp, sizeof(tmp)); + memcpy(&tmp, &packet->data[0], sizeof tmp); + memcpy(&packet->data[0], &packet->data[6], sizeof tmp); + memcpy(&packet->data[6], &tmp, sizeof tmp); +} + +static void age_subnets(int fd, short events, void *data) { + subnet_t *s; + connection_t *c; + splay_node_t *node, *next, *node2; + bool left = false; + time_t now = time(NULL); + + for(node = myself->subnet_tree->head; node; node = next) { + next = node->next; + s = node->data; + if(s->expires && s->expires < now) { + ifdebug(TRAFFIC) { + char netstr[MAXNETSTR]; + if(net2str(netstr, sizeof netstr, s)) + logger(LOG_INFO, "Subnet %s expired", netstr); + } + + for(node2 = connection_tree->head; node2; node2 = node2->next) { + c = node2->data; + if(c->status.active) + send_del_subnet(c, s); + } + + subnet_del(myself, s); + } else { + if(s->expires) + left = true; + } + } + + if(left) + event_add(&age_subnets_event, &(struct timeval){10, 0}); +} + +static void learn_mac(mac_t *address) { + subnet_t *subnet; + splay_node_t *node; + connection_t *c; + + subnet = lookup_subnet_mac(myself, address); + + /* If we don't know this MAC address yet, store it */ + + if(!subnet) { + ifdebug(TRAFFIC) logger(LOG_INFO, "Learned new MAC address %hx:%hx:%hx:%hx:%hx:%hx", + address->x[0], address->x[1], address->x[2], address->x[3], + address->x[4], address->x[5]); + + subnet = new_subnet(); + subnet->type = SUBNET_MAC; + subnet->expires = time(NULL) + macexpire; + subnet->net.mac.address = *address; + subnet->weight = 10; + subnet_add(myself, subnet); + subnet_update(myself, subnet, true); + + /* And tell all other tinc daemons it's our MAC */ + + for(node = connection_tree->head; node; node = node->next) { + c = node->data; + if(c->status.active) + send_add_subnet(c, subnet); + } + + if(!timeout_initialized(&age_subnets_event)) + timeout_set(&age_subnets_event, age_subnets, NULL); + event_add(&age_subnets_event, &(struct timeval){10, 0}); + } else { + if(subnet->expires) + subnet->expires = time(NULL) + macexpire; + } } /* RFC 792 */ -static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, length_t ether_size, uint8_t type, uint8_t code) { +static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, uint8_t type, uint8_t code) { struct ip ip = {0}; struct icmp icmp = {0}; - + struct in_addr ip_src; struct in_addr ip_dst; uint32_t oldlen; - if(ratelimit(3)) { + if(ratelimit(3)) return; - } - + /* Swap Ethernet source and destination addresses */ swap_mac_addresses(packet); @@ -136,51 +278,24 @@ static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, length_ memcpy(&ip, packet->data + ether_size, ip_size); /* Remember original source and destination */ - + ip_src = ip.ip_src; ip_dst = ip.ip_dst; - /* Try to reply with an IP address assigned to the local machine */ - - if(type == ICMP_TIME_EXCEEDED && code == ICMP_EXC_TTL) { - int sockfd = socket(AF_INET, SOCK_DGRAM, 0); - - if(sockfd != -1) { - struct sockaddr_in addr; - memset(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - addr.sin_addr = ip.ip_src; - - if(!connect(sockfd, (const struct sockaddr *) &addr, sizeof(addr))) { - memset(&addr, 0, sizeof(addr)); - addr.sin_family = AF_INET; - socklen_t addrlen = sizeof(addr); - - if(!getsockname(sockfd, (struct sockaddr *) &addr, &addrlen) && addrlen <= sizeof(addr)) { - ip_dst = addr.sin_addr; - } - } - - close(sockfd); - } - } - oldlen = packet->len - ether_size; - if(type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { + if(type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) icmp.icmp_nextmtu = htons(packet->len - ether_size); - } - if(oldlen >= IP_MSS - ip_size - icmp_size) { + if(oldlen >= IP_MSS - ip_size - icmp_size) oldlen = IP_MSS - ip_size - icmp_size; - } - + /* Copy first part of original contents to ICMP message */ - + memmove(packet->data + ether_size + ip_size + icmp_size, packet->data + ether_size, oldlen); /* Fill in IPv4 header */ - + ip.ip_v = 4; ip.ip_hl = ip_size / 4; ip.ip_tos = 0; @@ -194,13 +309,13 @@ static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, length_ ip.ip_dst = ip_src; ip.ip_sum = inet_checksum(&ip, ip_size, ~0); - + /* Fill in ICMP header */ - + icmp.icmp_type = type; icmp.icmp_code = code; icmp.icmp_cksum = 0; - + icmp.icmp_cksum = inet_checksum(&icmp, icmp_size, ~0); icmp.icmp_cksum = inet_checksum(packet->data + ether_size + ip_size + icmp_size, oldlen, icmp.icmp_cksum); @@ -208,369 +323,27 @@ static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, length_ memcpy(packet->data + ether_size, &ip, ip_size); memcpy(packet->data + ether_size + ip_size, &icmp, icmp_size); - + packet->len = ether_size + ip_size + icmp_size + oldlen; send_packet(source, packet); } -/* RFC 2463 */ - -static void route_ipv6_unreachable(node_t *source, vpn_packet_t *packet, length_t ether_size, uint8_t type, uint8_t code) { - struct ip6_hdr ip6; - struct icmp6_hdr icmp6 = {0}; - uint16_t checksum; - - struct { - struct in6_addr ip6_src; /* source address */ - struct in6_addr ip6_dst; /* destination address */ - uint32_t length; - uint32_t next; - } pseudo; - - if(ratelimit(3)) { - return; - } - - /* Swap Ethernet source and destination addresses */ - - swap_mac_addresses(packet); - - /* Copy headers from packet to structs on the stack */ - - memcpy(&ip6, packet->data + ether_size, ip6_size); - - /* Remember original source and destination */ - - pseudo.ip6_src = ip6.ip6_dst; - pseudo.ip6_dst = ip6.ip6_src; - - /* Try to reply with an IP address assigned to the local machine */ - - if(type == ICMP6_TIME_EXCEEDED && code == ICMP6_TIME_EXCEED_TRANSIT) { - int sockfd = socket(AF_INET6, SOCK_DGRAM, 0); - - if(sockfd != -1) { - struct sockaddr_in6 addr; - memset(&addr, 0, sizeof(addr)); - addr.sin6_family = AF_INET6; - addr.sin6_addr = ip6.ip6_src; - - if(!connect(sockfd, (const struct sockaddr *) &addr, sizeof(addr))) { - memset(&addr, 0, sizeof(addr)); - addr.sin6_family = AF_INET6; - socklen_t addrlen = sizeof(addr); - - if(!getsockname(sockfd, (struct sockaddr *) &addr, &addrlen) && addrlen <= sizeof(addr)) { - pseudo.ip6_src = addr.sin6_addr; - } - } - - close(sockfd); - } - } - - pseudo.length = packet->len - ether_size; - - if(type == ICMP6_PACKET_TOO_BIG) { - icmp6.icmp6_mtu = htonl(pseudo.length); - } - - if(pseudo.length >= IP_MSS - ip6_size - icmp6_size) { - pseudo.length = IP_MSS - ip6_size - icmp6_size; - } - - /* Copy first part of original contents to ICMP message */ - - memmove(packet->data + ether_size + ip6_size + icmp6_size, packet->data + ether_size, pseudo.length); - - /* Fill in IPv6 header */ - - ip6.ip6_flow = htonl(0x60000000UL); - ip6.ip6_plen = htons(icmp6_size + pseudo.length); - ip6.ip6_nxt = IPPROTO_ICMPV6; - ip6.ip6_hlim = 255; - ip6.ip6_src = pseudo.ip6_src; - ip6.ip6_dst = pseudo.ip6_dst; - - /* Fill in ICMP header */ - - icmp6.icmp6_type = type; - icmp6.icmp6_code = code; - icmp6.icmp6_cksum = 0; - - /* Create pseudo header */ - - pseudo.length = htonl(icmp6_size + pseudo.length); - pseudo.next = htonl(IPPROTO_ICMPV6); - - /* Generate checksum */ - - checksum = inet_checksum(&pseudo, sizeof(pseudo), ~0); - checksum = inet_checksum(&icmp6, icmp6_size, checksum); - checksum = inet_checksum(packet->data + ether_size + ip6_size + icmp6_size, ntohl(pseudo.length) - icmp6_size, checksum); - - icmp6.icmp6_cksum = checksum; - - /* Copy structs on stack back to packet */ - - memcpy(packet->data + ether_size, &ip6, ip6_size); - memcpy(packet->data + ether_size + ip6_size, &icmp6, icmp6_size); - - packet->len = ether_size + ip6_size + ntohl(pseudo.length); - - send_packet(source, packet); -} - -static bool do_decrement_ttl(node_t *source, vpn_packet_t *packet) { - uint16_t type = packet->data[12] << 8 | packet->data[13]; - length_t ethlen = ether_size; - - if(type == ETH_P_8021Q) { - type = packet->data[16] << 8 | packet->data[17]; - ethlen += 4; - } - - switch(type) { - case ETH_P_IP: - if(!checklength(source, packet, ethlen + ip_size)) { - return false; - } - - if(packet->data[ethlen + 8] <= 1) { - if(packet->data[ethlen + 11] != IPPROTO_ICMP || packet->data[ethlen + 32] != ICMP_TIME_EXCEEDED) { - route_ipv4_unreachable(source, packet, ethlen, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL); - } - - return false; - } - - uint16_t old = packet->data[ethlen + 8] << 8 | packet->data[ethlen + 9]; - packet->data[ethlen + 8]--; - uint16_t new = packet->data[ethlen + 8] << 8 | packet->data[ethlen + 9]; - - uint32_t checksum = packet->data[ethlen + 10] << 8 | packet->data[ethlen + 11]; - checksum += old + (~new & 0xFFFF); - - while(checksum >> 16) { - checksum = (checksum & 0xFFFF) + (checksum >> 16); - } - - packet->data[ethlen + 10] = checksum >> 8; - packet->data[ethlen + 11] = checksum & 0xff; - - return true; - - case ETH_P_IPV6: - if(!checklength(source, packet, ethlen + ip6_size)) { - return false; - } - - if(packet->data[ethlen + 7] <= 1) { - if(packet->data[ethlen + 6] != IPPROTO_ICMPV6 || packet->data[ethlen + 40] != ICMP6_TIME_EXCEEDED) { - route_ipv6_unreachable(source, packet, ethlen, ICMP6_TIME_EXCEEDED, ICMP6_TIME_EXCEED_TRANSIT); - } - - return false; - } - - packet->data[ethlen + 7]--; - - return true; - - default: - return true; - } -} - -static void clamp_mss(const node_t *source, const node_t *via, vpn_packet_t *packet) { - if(!source || !via || !(via->options & OPTION_CLAMP_MSS)) { - return; - } - - uint16_t mtu = source->mtu; - - if(via != myself && via->mtu < mtu) { - mtu = via->mtu; - } - - /* Find TCP header */ - int start = ether_size; - uint16_t type = packet->data[12] << 8 | packet->data[13]; - - if(type == ETH_P_8021Q) { - start += 4; - type = packet->data[16] << 8 | packet->data[17]; - } - - if(type == ETH_P_IP && packet->data[start + 9] == 6) { - start += (packet->data[start] & 0xf) * 4; - } else if(type == ETH_P_IPV6 && packet->data[start + 6] == 6) { - start += 40; - } else { - return; - } - - if(packet->len <= start + 20) { - return; - } - - /* Use data offset field to calculate length of options field */ - int len = ((packet->data[start + 12] >> 4) - 5) * 4; - - if(packet->len < start + 20 + len) { - return; - } - - /* Search for MSS option header */ - for(int i = 0; i < len;) { - if(packet->data[start + 20 + i] == 0) { - break; - } - - if(packet->data[start + 20 + i] == 1) { - i++; - continue; - } - - if(i > len - 2 || i > len - packet->data[start + 21 + i]) { - break; - } - - if(packet->data[start + 20 + i] != 2) { - if(packet->data[start + 21 + i] < 2) { - break; - } - - i += packet->data[start + 21 + i]; - continue; - } - - if(packet->data[start + 21] != 4) { - break; - } - - /* Found it */ - uint16_t oldmss = packet->data[start + 22 + i] << 8 | packet->data[start + 23 + i]; - uint16_t newmss = mtu - start - 20; - uint32_t csum = packet->data[start + 16] << 8 | packet->data[start + 17]; - - if(oldmss <= newmss) { - break; - } - - ifdebug(TRAFFIC) logger(LOG_INFO, "Clamping MSS of packet from %s to %s to %d", source->name, via->name, newmss); - - /* Update the MSS value and the checksum */ - packet->data[start + 22 + i] = newmss >> 8; - packet->data[start + 23 + i] = newmss & 0xff; - csum ^= 0xffff; - csum += oldmss ^ 0xffff; - csum += newmss; - csum = (csum & 0xffff) + (csum >> 16); - csum += csum >> 16; - csum ^= 0xffff; - packet->data[start + 16] = csum >> 8; - packet->data[start + 17] = csum; - break; - } -} - -static void learn_mac(mac_t *address) { - subnet_t *subnet; - avl_node_t *node; - connection_t *c; - - subnet = lookup_subnet_mac(myself, address); - - /* If we don't know this MAC address yet, store it */ - - if(!subnet) { - ifdebug(TRAFFIC) logger(LOG_INFO, "Learned new MAC address %x:%x:%x:%x:%x:%x", - address->x[0], address->x[1], address->x[2], address->x[3], - address->x[4], address->x[5]); - - subnet = new_subnet(); - subnet->type = SUBNET_MAC; - subnet->expires = now + macexpire; - subnet->net.mac.address = *address; - subnet->weight = 10; - subnet_add(myself, subnet); - subnet_update(myself, subnet, true); - - /* And tell all other tinc daemons it's our MAC */ - - for(node = connection_tree->head; node; node = node->next) { - c = node->data; - - if(c->status.active) { - send_add_subnet(c, subnet); - } - } - } - - if(subnet->expires) { - subnet->expires = now + macexpire; - } -} - -void age_subnets(void) { - subnet_t *s; - connection_t *c; - avl_node_t *node, *next, *node2; - - for(node = myself->subnet_tree->head; node; node = next) { - next = node->next; - s = node->data; - - if(s->expires && s->expires <= now) { - ifdebug(TRAFFIC) { - char netstr[MAXNETSTR]; - - if(net2str(netstr, sizeof(netstr), s)) { - logger(LOG_INFO, "Subnet %s expired", netstr); - } - } - - for(node2 = connection_tree->head; node2; node2 = node2->next) { - c = node2->data; - - if(c->status.active) { - send_del_subnet(c, s); - } - } - - subnet_update(myself, s, false); - subnet_del(myself, s); - } - } -} - -static void route_broadcast(node_t *source, vpn_packet_t *packet) { - if(decrement_ttl && source != myself) - if(!do_decrement_ttl(source, packet)) { - return; - } - - broadcast_packet(source, packet); -} - /* RFC 791 */ -static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet, length_t ether_size) { +static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet) { struct ip ip; vpn_packet_t fragment; int len, maxlen, todo; uint8_t *offset; uint16_t ip_off, origf; - + memcpy(&ip, packet->data + ether_size, ip_size); fragment.priority = packet->priority; - if(ip.ip_hl != ip_size / 4) { + if(ip.ip_hl != ip_size / 4) return; - } - + todo = ntohs(ip.ip_len) - ip_size; if(ether_size + ip_size + todo != packet->len) { @@ -585,7 +358,7 @@ static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet, length_t et ip_off = ntohs(ip.ip_off); origf = ip_off & ~IP_OFFMASK; ip_off &= IP_OFFMASK; - + while(todo) { len = todo > maxlen ? maxlen : todo; memcpy(fragment.data + ether_size + ip_size, offset, len); @@ -603,7 +376,7 @@ static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet, length_t et send_packet(dest, &fragment); ip_off += len / 8; - } + } } static void route_ipv4_unicast(node_t *source, vpn_packet_t *packet) { @@ -611,89 +384,149 @@ static void route_ipv4_unicast(node_t *source, vpn_packet_t *packet) { node_t *via; ipv4_t dest; - memcpy(&dest, &packet->data[30], sizeof(dest)); + memcpy(&dest, &packet->data[30], sizeof dest); subnet = lookup_subnet_ipv4(&dest); if(!subnet) { ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet from %s (%s): unknown IPv4 destination address %d.%d.%d.%d", - source->name, source->hostname, - dest.x[0], - dest.x[1], - dest.x[2], - dest.x[3]); + source->name, source->hostname, + dest.x[0], + dest.x[1], + dest.x[2], + dest.x[3]); - route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_UNKNOWN); + route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_NET_UNKNOWN); return; } - + if(subnet->owner == source) { ifdebug(TRAFFIC) logger(LOG_WARNING, "Packet looping back to %s (%s)!", source->name, source->hostname); return; } - if(!subnet->owner->status.reachable) { - route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_UNREACH); - return; - } + if(!subnet->owner->status.reachable) + return route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_NET_UNREACH); - if(forwarding_mode == FMODE_OFF && source != myself && subnet->owner != myself) { - route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_ANO); - return; - } + if(forwarding_mode == FMODE_OFF && source != myself && subnet->owner != myself) + return route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_NET_ANO); - if(decrement_ttl && source != myself && subnet->owner != myself) - if(!do_decrement_ttl(source, packet)) { - return; - } - - if(priorityinheritance) { + if(priorityinheritance) packet->priority = packet->data[15]; - } via = (subnet->owner->via == myself) ? subnet->owner->nexthop : subnet->owner->via; - - if(via == source) { - ifdebug(TRAFFIC) logger(LOG_ERR, "Routing loop for packet from %s (%s)!", source->name, source->hostname); - return; - } - - if(directonly && subnet->owner != via) { - route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_ANO); - return; - } + + if(directonly && subnet->owner != via) + return route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_NET_ANO); if(via && packet->len > MAX(via->mtu, 590) && via != myself) { ifdebug(TRAFFIC) logger(LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); - if(packet->data[20] & 0x40) { packet->len = MAX(via->mtu, 590); - route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED); + route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED); } else { - fragment_ipv4_packet(via, packet, ether_size); + fragment_ipv4_packet(via, packet); } return; } clamp_mss(source, via, packet); - + send_packet(subnet->owner, packet); } static void route_ipv4(node_t *source, vpn_packet_t *packet) { - if(!checklength(source, packet, ether_size + ip_size)) { + if(!checklength(source, packet, ether_size + ip_size)) return; - } - if(broadcast_mode && (((packet->data[30] & 0xf0) == 0xe0) || ( - packet->data[30] == 255 && - packet->data[31] == 255 && - packet->data[32] == 255 && - packet->data[33] == 255))) { - route_broadcast(source, packet); - } else { + if(((packet->data[30] & 0xf0) == 0xe0) || ( + packet->data[30] == 255 && + packet->data[31] == 255 && + packet->data[32] == 255 && + packet->data[33] == 255)) + broadcast_packet(source, packet); + else route_ipv4_unicast(source, packet); - } +} + +/* RFC 2463 */ + +static void route_ipv6_unreachable(node_t *source, vpn_packet_t *packet, uint8_t type, uint8_t code) { + struct ip6_hdr ip6; + struct icmp6_hdr icmp6 = {0}; + uint16_t checksum; + + struct { + struct in6_addr ip6_src; /* source address */ + struct in6_addr ip6_dst; /* destination address */ + uint32_t length; + uint32_t next; + } pseudo; + + if(ratelimit(3)) + return; + + /* Swap Ethernet source and destination addresses */ + + swap_mac_addresses(packet); + + /* Copy headers from packet to structs on the stack */ + + memcpy(&ip6, packet->data + ether_size, ip6_size); + + /* Remember original source and destination */ + + pseudo.ip6_src = ip6.ip6_dst; + pseudo.ip6_dst = ip6.ip6_src; + + pseudo.length = packet->len - ether_size; + + if(type == ICMP6_PACKET_TOO_BIG) + icmp6.icmp6_mtu = htonl(pseudo.length); + + if(pseudo.length >= IP_MSS - ip6_size - icmp6_size) + pseudo.length = IP_MSS - ip6_size - icmp6_size; + + /* Copy first part of original contents to ICMP message */ + + memmove(packet->data + ether_size + ip6_size + icmp6_size, packet->data + ether_size, pseudo.length); + + /* Fill in IPv6 header */ + + ip6.ip6_flow = htonl(0x60000000UL); + ip6.ip6_plen = htons(icmp6_size + pseudo.length); + ip6.ip6_nxt = IPPROTO_ICMPV6; + ip6.ip6_hlim = 255; + ip6.ip6_src = pseudo.ip6_src; + ip6.ip6_dst = pseudo.ip6_dst; + + /* Fill in ICMP header */ + + icmp6.icmp6_type = type; + icmp6.icmp6_code = code; + icmp6.icmp6_cksum = 0; + + /* Create pseudo header */ + + pseudo.length = htonl(icmp6_size + pseudo.length); + pseudo.next = htonl(IPPROTO_ICMPV6); + + /* Generate checksum */ + + checksum = inet_checksum(&pseudo, sizeof pseudo, ~0); + checksum = inet_checksum(&icmp6, icmp6_size, checksum); + checksum = inet_checksum(packet->data + ether_size + ip6_size + icmp6_size, ntohl(pseudo.length) - icmp6_size, checksum); + + icmp6.icmp6_cksum = checksum; + + /* Copy structs on stack back to packet */ + + memcpy(packet->data + ether_size, &ip6, ip6_size); + memcpy(packet->data + ether_size + ip6_size, &icmp6, icmp6_size); + + packet->len = ether_size + ip6_size + ntohl(pseudo.length); + + send_packet(source, packet); } static void route_ipv6_unicast(node_t *source, vpn_packet_t *packet) { @@ -701,22 +534,22 @@ static void route_ipv6_unicast(node_t *source, vpn_packet_t *packet) { node_t *via; ipv6_t dest; - memcpy(&dest, &packet->data[38], sizeof(dest)); + memcpy(&dest, &packet->data[38], sizeof dest); subnet = lookup_subnet_ipv6(&dest); if(!subnet) { ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet from %s (%s): unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", - source->name, source->hostname, - ntohs(dest.x[0]), - ntohs(dest.x[1]), - ntohs(dest.x[2]), - ntohs(dest.x[3]), - ntohs(dest.x[4]), - ntohs(dest.x[5]), - ntohs(dest.x[6]), - ntohs(dest.x[7])); + source->name, source->hostname, + ntohs(dest.x[0]), + ntohs(dest.x[1]), + ntohs(dest.x[2]), + ntohs(dest.x[3]), + ntohs(dest.x[4]), + ntohs(dest.x[5]), + ntohs(dest.x[6]), + ntohs(dest.x[7])); - route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR); + route_ipv6_unreachable(source, packet, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR); return; } @@ -725,47 +558,26 @@ static void route_ipv6_unicast(node_t *source, vpn_packet_t *packet) { return; } - if(!subnet->owner->status.reachable) { - route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOROUTE); - return; - } + if(!subnet->owner->status.reachable) + return route_ipv6_unreachable(source, packet, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOROUTE); - if(forwarding_mode == FMODE_OFF && source != myself && subnet->owner != myself) { - route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN); - return; - } - - if(decrement_ttl && source != myself && subnet->owner != myself) { - if(!do_decrement_ttl(source, packet)) { - return; - } - } - - if(priorityinheritance) { - packet->priority = ((packet->data[14] & 0x0f) << 4) | (packet->data[15] >> 4); - } + if(forwarding_mode == FMODE_OFF && source != myself && subnet->owner != myself) + return route_ipv6_unreachable(source, packet, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN); via = (subnet->owner->via == myself) ? subnet->owner->nexthop : subnet->owner->via; - - if(via == source) { - ifdebug(TRAFFIC) logger(LOG_ERR, "Routing loop for packet from %s (%s)!", source->name, source->hostname); - return; - } - - if(directonly && subnet->owner != via) { - route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN); - return; - } + + if(directonly && subnet->owner != via) + return route_ipv6_unreachable(source, packet, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN); if(via && packet->len > MAX(via->mtu, 1294) && via != myself) { ifdebug(TRAFFIC) logger(LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); packet->len = MAX(via->mtu, 1294); - route_ipv6_unreachable(source, packet, ether_size, ICMP6_PACKET_TOO_BIG, 0); + route_ipv6_unreachable(source, packet, ICMP6_PACKET_TOO_BIG, 0); return; } clamp_mss(source, via, packet); - + send_packet(subnet->owner, packet); } @@ -780,18 +592,17 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { bool has_opt; struct { - struct in6_addr ip6_src; /* source address */ - struct in6_addr ip6_dst; /* destination address */ + struct in6_addr ip6_src; /* source address */ + struct in6_addr ip6_dst; /* destination address */ uint32_t length; uint32_t next; } pseudo; - if(!checklength(source, packet, ether_size + ip6_size + ns_size)) { + if(!checklength(source, packet, ether_size + ip6_size + ns_size)) return; - } - + has_opt = packet->len >= ether_size + ip6_size + ns_size + opt_size + ETH_ALEN; - + if(source != myself) { ifdebug(TRAFFIC) logger(LOG_WARNING, "Got neighbor solicitation request from %s (%s) while in router mode!", source->name, source->hostname); return; @@ -801,21 +612,18 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { memcpy(&ip6, packet->data + ether_size, ip6_size); memcpy(&ns, packet->data + ether_size + ip6_size, ns_size); - - if(has_opt) { + if(has_opt) memcpy(&opt, packet->data + ether_size + ip6_size + ns_size, opt_size); - } /* First, snatch the source address from the neighbor solicitation packet */ - if(overwrite_mac) { + if(overwrite_mac) memcpy(mymac.x, packet->data + ETH_ALEN, ETH_ALEN); - } /* Check if this is a valid neighbor solicitation request */ if(ns.nd_ns_hdr.icmp6_type != ND_NEIGHBOR_SOLICIT || - (has_opt && opt.nd_opt_type != ND_OPT_SOURCE_LINKADDR)) { + (has_opt && opt.nd_opt_type != ND_OPT_SOURCE_LINKADDR)) { ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet: received unknown type neighbor solicitation request"); return; } @@ -824,20 +632,16 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { pseudo.ip6_src = ip6.ip6_src; pseudo.ip6_dst = ip6.ip6_dst; - - if(has_opt) { + if(has_opt) pseudo.length = htonl(ns_size + opt_size + ETH_ALEN); - } else { + else pseudo.length = htonl(ns_size); - } - pseudo.next = htonl(IPPROTO_ICMPV6); /* Generate checksum */ - checksum = inet_checksum(&pseudo, sizeof(pseudo), ~0); + checksum = inet_checksum(&pseudo, sizeof pseudo, ~0); checksum = inet_checksum(&ns, ns_size, checksum); - if(has_opt) { checksum = inet_checksum(&opt, opt_size, checksum); checksum = inet_checksum(packet->data + ether_size + ip6_size + ns_size + opt_size, ETH_ALEN, checksum); @@ -854,64 +658,53 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { if(!subnet) { ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet: neighbor solicitation request for unknown address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", - ntohs(((uint16_t *) &ns.nd_ns_target)[0]), - ntohs(((uint16_t *) &ns.nd_ns_target)[1]), - ntohs(((uint16_t *) &ns.nd_ns_target)[2]), - ntohs(((uint16_t *) &ns.nd_ns_target)[3]), - ntohs(((uint16_t *) &ns.nd_ns_target)[4]), - ntohs(((uint16_t *) &ns.nd_ns_target)[5]), - ntohs(((uint16_t *) &ns.nd_ns_target)[6]), - ntohs(((uint16_t *) &ns.nd_ns_target)[7])); + ntohs(((uint16_t *) &ns.nd_ns_target)[0]), + ntohs(((uint16_t *) &ns.nd_ns_target)[1]), + ntohs(((uint16_t *) &ns.nd_ns_target)[2]), + ntohs(((uint16_t *) &ns.nd_ns_target)[3]), + ntohs(((uint16_t *) &ns.nd_ns_target)[4]), + ntohs(((uint16_t *) &ns.nd_ns_target)[5]), + ntohs(((uint16_t *) &ns.nd_ns_target)[6]), + ntohs(((uint16_t *) &ns.nd_ns_target)[7])); return; } /* Check if it is for our own subnet */ - if(subnet->owner == myself) { - return; /* silently ignore */ - } - - if(decrement_ttl) - if(!do_decrement_ttl(source, packet)) { - return; - } + if(subnet->owner == myself) + return; /* silently ignore */ /* Create neighbor advertation reply */ - memcpy(packet->data, packet->data + ETH_ALEN, ETH_ALEN); /* copy destination address */ - packet->data[ETH_ALEN * 2 - 1] ^= 0xFF; /* mangle source address so it looks like it's not from us */ + memcpy(packet->data, packet->data + ETH_ALEN, ETH_ALEN); /* copy destination address */ + packet->data[ETH_ALEN * 2 - 1] ^= 0xFF; /* mangle source address so it looks like it's not from us */ - ip6.ip6_dst = ip6.ip6_src; /* swap destination and source protocol address */ + ip6.ip6_dst = ip6.ip6_src; /* swap destination and source protocoll address */ ip6.ip6_src = ns.nd_ns_target; - if(has_opt) { - memcpy(packet->data + ether_size + ip6_size + ns_size + opt_size, packet->data + ETH_ALEN, ETH_ALEN); /* add fake source hard addr */ - } + if(has_opt) + memcpy(packet->data + ether_size + ip6_size + ns_size + opt_size, packet->data + ETH_ALEN, ETH_ALEN); /* add fake source hard addr */ ns.nd_ns_cksum = 0; ns.nd_ns_type = ND_NEIGHBOR_ADVERT; - ns.nd_ns_reserved = htonl(0x40000000UL); /* Set solicited flag */ + ns.nd_ns_reserved = htonl(0x40000000UL); /* Set solicited flag */ opt.nd_opt_type = ND_OPT_TARGET_LINKADDR; /* Create pseudo header */ pseudo.ip6_src = ip6.ip6_src; pseudo.ip6_dst = ip6.ip6_dst; - - if(has_opt) { + if(has_opt) pseudo.length = htonl(ns_size + opt_size + ETH_ALEN); - } else { + else pseudo.length = htonl(ns_size); - } - pseudo.next = htonl(IPPROTO_ICMPV6); /* Generate checksum */ - checksum = inet_checksum(&pseudo, sizeof(pseudo), ~0); + checksum = inet_checksum(&pseudo, sizeof pseudo, ~0); checksum = inet_checksum(&ns, ns_size, checksum); - if(has_opt) { checksum = inet_checksum(&opt, opt_size, checksum); checksum = inet_checksum(packet->data + ether_size + ip6_size + ns_size + opt_size, ETH_ALEN, checksum); @@ -923,29 +716,25 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { memcpy(packet->data + ether_size, &ip6, ip6_size); memcpy(packet->data + ether_size + ip6_size, &ns, ns_size); - - if(has_opt) { + if(has_opt) memcpy(packet->data + ether_size + ip6_size + ns_size, &opt, opt_size); - } send_packet(source, packet); } static void route_ipv6(node_t *source, vpn_packet_t *packet) { - if(!checklength(source, packet, ether_size + ip6_size)) { + if(!checklength(source, packet, ether_size + ip6_size)) return; - } if(packet->data[20] == IPPROTO_ICMPV6 && checklength(source, packet, ether_size + ip6_size + icmp6_size) && packet->data[54] == ND_NEIGHBOR_SOLICIT) { route_neighborsol(source, packet); return; } - if(broadcast_mode && packet->data[38] == 255) { - route_broadcast(source, packet); - } else { + if(packet->data[38] == 255) + broadcast_packet(source, packet); + else route_ipv6_unicast(source, packet); - } } /* RFC 826 */ @@ -955,9 +744,8 @@ static void route_arp(node_t *source, vpn_packet_t *packet) { subnet_t *subnet; struct in_addr addr; - if(!checklength(source, packet, ether_size + arp_size)) { + if(!checklength(source, packet, ether_size + arp_size)) return; - } if(source != myself) { ifdebug(TRAFFIC) logger(LOG_WARNING, "Got ARP request from %s (%s) while in router mode!", source->name, source->hostname); @@ -966,9 +754,8 @@ static void route_arp(node_t *source, vpn_packet_t *packet) { /* First, snatch the source address from the ARP packet */ - if(overwrite_mac) { + if(overwrite_mac) memcpy(mymac.x, packet->data + ETH_ALEN, ETH_ALEN); - } /* Copy headers from packet to structs on the stack */ @@ -977,7 +764,7 @@ static void route_arp(node_t *source, vpn_packet_t *packet) { /* Check if this is a valid ARP request */ if(ntohs(arp.arp_hrd) != ARPHRD_ETHER || ntohs(arp.arp_pro) != ETH_P_IP || - arp.arp_hln != ETH_ALEN || arp.arp_pln != sizeof(addr) || ntohs(arp.arp_op) != ARPOP_REQUEST) { + arp.arp_hln != ETH_ALEN || arp.arp_pln != sizeof addr || ntohs(arp.arp_op) != ARPOP_REQUEST) { ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet: received unknown type ARP request"); return; } @@ -988,31 +775,25 @@ static void route_arp(node_t *source, vpn_packet_t *packet) { if(!subnet) { ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet: ARP request for unknown address %d.%d.%d.%d", - arp.arp_tpa[0], arp.arp_tpa[1], arp.arp_tpa[2], - arp.arp_tpa[3]); + arp.arp_tpa[0], arp.arp_tpa[1], arp.arp_tpa[2], + arp.arp_tpa[3]); return; } /* Check if it is for our own subnet */ - if(subnet->owner == myself) { - return; /* silently ignore */ - } + if(subnet->owner == myself) + return; /* silently ignore */ - if(decrement_ttl) - if(!do_decrement_ttl(source, packet)) { - return; - } + memcpy(packet->data, packet->data + ETH_ALEN, ETH_ALEN); /* copy destination address */ + packet->data[ETH_ALEN * 2 - 1] ^= 0xFF; /* mangle source address so it looks like it's not from us */ - memcpy(packet->data, packet->data + ETH_ALEN, ETH_ALEN); /* copy destination address */ - packet->data[ETH_ALEN * 2 - 1] ^= 0xFF; /* mangle source address so it looks like it's not from us */ + memcpy(&addr, arp.arp_tpa, sizeof addr); /* save protocol addr */ + memcpy(arp.arp_tpa, arp.arp_spa, sizeof addr); /* swap destination and source protocol address */ + memcpy(arp.arp_spa, &addr, sizeof addr); /* ... */ - memcpy(&addr, arp.arp_tpa, sizeof(addr)); /* save protocol addr */ - memcpy(arp.arp_tpa, arp.arp_spa, sizeof(addr)); /* swap destination and source protocol address */ - memcpy(arp.arp_spa, &addr, sizeof(addr)); /* ... */ - - memcpy(arp.arp_tha, arp.arp_sha, ETH_ALEN); /* set target hard/proto addr */ - memcpy(arp.arp_sha, packet->data + ETH_ALEN, ETH_ALEN); /* add fake source hard addr */ + memcpy(arp.arp_tha, arp.arp_sha, ETH_ALEN); /* set target hard/proto addr */ + memcpy(arp.arp_sha, packet->data + ETH_ALEN, ETH_ALEN); /* add fake source hard addr */ arp.arp_op = htons(ARPOP_REPLY); /* Copy structs on stack back to packet */ @@ -1030,17 +811,17 @@ static void route_mac(node_t *source, vpn_packet_t *packet) { if(source == myself) { mac_t src; - memcpy(&src, &packet->data[6], sizeof(src)); + memcpy(&src, &packet->data[6], sizeof src); learn_mac(&src); } /* Lookup destination address */ - memcpy(&dest, &packet->data[0], sizeof(dest)); + memcpy(&dest, &packet->data[0], sizeof dest); subnet = lookup_subnet_mac(NULL, &dest); if(!subnet) { - route_broadcast(source, packet); + broadcast_packet(source, packet); return; } @@ -1049,103 +830,95 @@ static void route_mac(node_t *source, vpn_packet_t *packet) { return; } - if(forwarding_mode == FMODE_OFF && source != myself && subnet->owner != myself) { + if(forwarding_mode == FMODE_OFF && source != myself && subnet->owner != myself) return; - } - - if(decrement_ttl && source != myself && subnet->owner != myself) - if(!do_decrement_ttl(source, packet)) { - return; - } - - uint16_t type = packet->data[12] << 8 | packet->data[13]; - - if(priorityinheritance) { - if(type == ETH_P_IP && packet->len >= ether_size + ip_size) { - packet->priority = packet->data[15]; - } else if(type == ETH_P_IPV6 && packet->len >= ether_size + ip6_size) { - packet->priority = ((packet->data[14] & 0x0f) << 4) | (packet->data[15] >> 4); - } - } // Handle packets larger than PMTU node_t *via = (subnet->owner->via == myself) ? subnet->owner->nexthop : subnet->owner->via; - if(directonly && subnet->owner != via) { + if(directonly && subnet->owner != via) return; - } - + if(via && packet->len > via->mtu && via != myself) { ifdebug(TRAFFIC) logger(LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); - length_t ethlen = 14; - - if(type == ETH_P_8021Q) { - type = packet->data[16] << 8 | packet->data[17]; - ethlen += 4; - } - - if(type == ETH_P_IP && packet->len > 576 + ethlen) { - if(packet->data[6 + ethlen] & 0x40) { + uint16_t type = packet->data[12] << 8 | packet->data[13]; + if(type == ETH_P_IP && packet->len > 590) { + if(packet->data[20] & 0x40) { packet->len = via->mtu; - route_ipv4_unreachable(source, packet, ethlen, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED); + route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED); } else { - fragment_ipv4_packet(via, packet, ethlen); + fragment_ipv4_packet(via, packet); } - return; - } else if(type == ETH_P_IPV6 && packet->len > 1280 + ethlen) { + } else if(type == ETH_P_IPV6 && packet->len > 1294) { packet->len = via->mtu; - route_ipv6_unreachable(source, packet, ethlen, ICMP6_PACKET_TOO_BIG, 0); + route_ipv6_unreachable(source, packet, ICMP6_PACKET_TOO_BIG, 0); return; } } clamp_mss(source, via, packet); - + send_packet(subnet->owner, packet); } +static void send_pcap(vpn_packet_t *packet) { + pcap = false; + for(splay_node_t *node = connection_tree->head; node; node = node->next) { + connection_t *c = node->data; + if(!c->status.pcap) + continue; + else + pcap = true; + if(send_request(c, "%d %d %d", CONTROL, REQ_PCAP, packet->len)) + send_meta(c, (char *)packet->data, packet->len); + } +} + void route(node_t *source, vpn_packet_t *packet) { + if(pcap) + send_pcap(packet); + if(forwarding_mode == FMODE_KERNEL && source != myself) { send_packet(myself, packet); return; } - if(!checklength(source, packet, ether_size)) { + if(!checklength(source, packet, ether_size)) return; - } - switch(routing_mode) { - case RMODE_ROUTER: { - uint16_t type = packet->data[12] << 8 | packet->data[13]; + switch (routing_mode) { + case RMODE_ROUTER: + { + uint16_t type = packet->data[12] << 8 | packet->data[13]; - switch(type) { - case ETH_P_ARP: - route_arp(source, packet); + switch (type) { + case ETH_P_ARP: + route_arp(source, packet); + break; + + case ETH_P_IP: + route_ipv4(source, packet); + break; + + case ETH_P_IPV6: + route_ipv6(source, packet); + break; + + default: + ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet from %s (%s): unknown type %hx", source->name, source->hostname, type); + break; + } + } break; - case ETH_P_IP: - route_ipv4(source, packet); + case RMODE_SWITCH: + route_mac(source, packet); break; - case ETH_P_IPV6: - route_ipv6(source, packet); + case RMODE_HUB: + broadcast_packet(source, packet); break; - - default: - ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet from %s (%s): unknown type %hx", source->name, source->hostname, type); - break; - } - } - break; - - case RMODE_SWITCH: - route_mac(source, packet); - break; - - case RMODE_HUB: - route_broadcast(source, packet); - break; } } diff --git a/src/route.h b/src/route.h index 5b9e808..5af2a09 100644 --- a/src/route.h +++ b/src/route.h @@ -1,10 +1,7 @@ -#ifndef TINC_ROUTE_H -#define TINC_ROUTE_H - /* route.h -- header file for route.c Copyright (C) 2000-2005 Ivo Timmermans - 2000-2012 Guus Sliepen + 2000-2006 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +18,9 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_ROUTE_H__ +#define __TINC_ROUTE_H__ + #include "net.h" #include "node.h" @@ -36,24 +36,16 @@ typedef enum fmode_t { FMODE_KERNEL, } fmode_t; -typedef enum bmode_t { - BMODE_NONE = 0, - BMODE_MST, - BMODE_DIRECT, -} bmode_t; - extern rmode_t routing_mode; extern fmode_t forwarding_mode; -extern bmode_t broadcast_mode; -extern bool decrement_ttl; extern bool directonly; extern bool overwrite_mac; extern bool priorityinheritance; extern int macexpire; +extern bool pcap; extern mac_t mymac; -extern void age_subnets(void); -extern void route(struct node_t *source, struct vpn_packet_t *packet); +extern void route(struct node_t *, struct vpn_packet_t *); -#endif +#endif /* __TINC_ROUTE_H__ */ diff --git a/src/solaris/device.c b/src/solaris/device.c index fa2e6e6..eac267a 100644 --- a/src/solaris/device.c +++ b/src/solaris/device.c @@ -1,8 +1,7 @@ /* device.c -- Interaction with Solaris tun device Copyright (C) 2001-2005 Ivo Timmermans, - 2002-2010 OpenVPN Technologies, Inc. - 2001-2017 Guus Sliepen + 2001-2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,299 +19,94 @@ */ -#include "../system.h" +#include "system.h" #include #include -#include +#include -#include "../conf.h" -#include "../device.h" -#include "../logger.h" -#include "../net.h" -#include "../route.h" -#include "../utils.h" -#include "../xalloc.h" +#include "conf.h" +#include "device.h" +#include "logger.h" +#include "net.h" +#include "utils.h" +#include "xalloc.h" -#ifndef TUNNEWPPA -#warning Missing net/if_tun.h, using hardcoded value for TUNNEWPPA -#define TUNNEWPPA (('T'<<16) | 0x0001) -#endif - -#define DEFAULT_TUN_DEVICE "/dev/tun" -#define DEFAULT_TAP_DEVICE "/dev/tap" -#define IP_DEVICE "/dev/udp" - -static enum { - DEVICE_TYPE_TUN, - DEVICE_TYPE_TAP, -} device_type = DEVICE_TYPE_TUN; +#define DEFAULT_DEVICE "/dev/tun" int device_fd = -1; -static int if_fd = -1; -static int ip_fd = -1; +int ip_fd = -1, if_fd = -1; char *device = NULL; char *iface = NULL; -static const char *device_info = NULL; +static char *device_info = NULL; -uint64_t device_total_in = 0; -uint64_t device_total_out = 0; +static uint64_t device_total_in = 0; +static uint64_t device_total_out = 0; -static bool setup_device(void) { - char *type; +bool setup_device(void) { + int ppa; + char *ptr; - if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { - if(routing_mode == RMODE_ROUTER) { - device = xstrdup(DEFAULT_TUN_DEVICE); - } else { - device = xstrdup(DEFAULT_TAP_DEVICE); - } - } + if(!get_config_string(lookup_config(config_tree, "Device"), &device)) + device = xstrdup(DEFAULT_DEVICE); - if(get_config_string(lookup_config(config_tree, "DeviceType"), &type)) { - if(!strcasecmp(type, "tun")) - /* use default */; - else if(!strcasecmp(type, "tap")) { - device_type = DEVICE_TYPE_TAP; - } else { - logger(LOG_ERR, "Unknown device type %s!", type); - return false; - } - } else { - if(strstr(device, "tap") || routing_mode != RMODE_ROUTER) { - device_type = DEVICE_TYPE_TAP; - } - } - - if(device_type == DEVICE_TYPE_TUN) { - device_info = "Solaris tun device"; - } else { - device_info = "Solaris tap device"; - } - - if(device_type == DEVICE_TYPE_TAP && routing_mode == RMODE_ROUTER) { - overwrite_mac = true; - } - - /* The following is black magic copied from OpenVPN. */ - - if((ip_fd = open(IP_DEVICE, O_RDWR, 0)) < 0) { - logger(LOG_ERR, "Could not open %s: %s\n", IP_DEVICE, strerror(errno)); + if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) { + logger(LOG_ERR, "Could not open %s: %s", device, strerror(errno)); return false; } - if((device_fd = open(device, O_RDWR, 0)) < 0) { - logger(LOG_ERR, "Could not open %s: %s\n", device, strerror(errno)); - return false; - } + ppa = 0; - /* Get unit number. */ - - char *ptr = device; - get_config_string(lookup_config(config_tree, "Interface"), &ptr); - - while(*ptr && !isdigit(*ptr)) { + ptr = device; + while(*ptr && !isdigit((int) *ptr)) ptr++; - } + ppa = atoi(ptr); - int ppa = atoi(ptr); + if((ip_fd = open("/dev/ip", O_RDWR, 0)) < 0) { + logger(LOG_ERR, "Could not open /dev/ip: %s", strerror(errno)); + return false; + } /* Assign a new PPA and get its unit number. */ - - struct strioctl strioc_ppa = { - .ic_cmd = TUNNEWPPA, - .ic_len = sizeof(ppa), - .ic_dp = (char *) &ppa, - }; - - if(!*ptr) { /* no number given, try dynamic */ - bool found = false; - - while(!found && ppa < 64) { - int new_ppa = ioctl(device_fd, I_STR, &strioc_ppa); - - if(new_ppa >= 0) { - ppa = new_ppa; - found = true; - break; - } - - ppa++; - } - - if(!found) { - logger(LOG_ERR, "Could not find free PPA for %s %s!", device_info, device); - return false; - } - } else { /* try this particular one */ - if((ppa = ioctl(device_fd, I_STR, &strioc_ppa)) < 0) { - logger(LOG_ERR, "Could not assign PPA %d for %s %s!", ppa, device_info, device); - return false; - } + if((ppa = ioctl(device_fd, TUNNEWPPA, ppa)) < 0) { + logger(LOG_ERR, "Can't assign new interface: %s", strerror(errno)); + return false; } if((if_fd = open(device, O_RDWR, 0)) < 0) { - logger(LOG_ERR, "Could not open %s: %s\n", device, strerror(errno)); + logger(LOG_ERR, "Could not open %s twice: %s", device, + strerror(errno)); return false; } if(ioctl(if_fd, I_PUSH, "ip") < 0) { - logger(LOG_ERR, "Could not push IP module onto %s %s!", device_info, device); + logger(LOG_ERR, "Can't push IP module: %s", strerror(errno)); return false; } - xasprintf(&iface, "%s%d", device_type == DEVICE_TYPE_TUN ? "tun" : "tap", ppa); - - { - /* Remove muxes just in case they are left over from a crashed tincd */ - struct lifreq ifr = {}; - strncpy(ifr.lifr_name, iface, sizeof(ifr.lifr_name)); - - if(ioctl(ip_fd, SIOCGLIFMUXID, &ifr) >= 0) { - int muxid = ifr.lifr_arp_muxid; - ioctl(ip_fd, I_PUNLINK, muxid); - muxid = ifr.lifr_ip_muxid; - ioctl(ip_fd, I_PUNLINK, muxid); - } - } - - if(device_type == DEVICE_TYPE_TUN) { - /* Assign ppa according to the unit number returned by tun device */ - if(ioctl(if_fd, IF_UNITSEL, (char *)&ppa) < 0) { - logger(LOG_ERR, "Could not set PPA %d on %s %s!", ppa, device_info, device); - return false; - } - } - - int arp_fd = -1; - - if(device_type == DEVICE_TYPE_TAP) { - struct lifreq ifr = {}; - - if(ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) { - logger(LOG_ERR, "Could not set flags on %s %s!", device_info, device); - return false; - } - - strncpy(ifr.lifr_name, iface, sizeof(ifr.lifr_name)); - ifr.lifr_ppa = ppa; - - /* Assign ppa according to the unit number returned by tun device */ - if(ioctl(if_fd, SIOCSLIFNAME, &ifr) < 0) { - logger(LOG_ERR, "Could not set PPA %d on %s %s!", ppa, device_info, device); - return false; - } - - if(ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) { - logger(LOG_ERR, "Could not set flags on %s %s!", device_info, device); - return false; - } - - /* Push arp module to if_fd */ - if(ioctl(if_fd, I_PUSH, "arp") < 0) { - logger(LOG_ERR, "Could not push ARP module onto %s %s!", device_info, device); - return false; - } - - /* Pop any modules on the stream */ - while(true) { - if(ioctl(ip_fd, I_POP, NULL) < 0) { - break; - } - } - - /* Push arp module to ip_fd */ - if(ioctl(ip_fd, I_PUSH, "arp") < 0) { - logger(LOG_ERR, "Could not push ARP module onto %s!", IP_DEVICE); - return false; - } - - /* Open arp_fd */ - if((arp_fd = open(device, O_RDWR, 0)) < 0) { - logger(LOG_ERR, "Could not open %s: %s\n", device, strerror(errno)); - return false; - } - - /* Push arp module to arp_fd */ - if(ioctl(arp_fd, I_PUSH, "arp") < 0) { - logger(LOG_ERR, "Could not push ARP module onto %s %s!", device_info, device); - return false; - } - - /* Set ifname to arp */ - struct strioctl strioc_if = { - .ic_cmd = SIOCSLIFNAME, - .ic_len = sizeof(ifr), - .ic_dp = (char *) &ifr, - }; - - if(ioctl(arp_fd, I_STR, &strioc_if) < 0) { - logger(LOG_ERR, "Could not set ifname to %s %s", device_info, device); - return false; - } - } - - int ip_muxid, arp_muxid; - - if((ip_muxid = ioctl(ip_fd, I_PLINK, if_fd)) < 0) { - logger(LOG_ERR, "Could not link %s %s to IP", device_info, device); + /* Assign ppa according to the unit number returned by tun device */ + if(ioctl(if_fd, IF_UNITSEL, (char *) &ppa) < 0) { + logger(LOG_ERR, "Can't set PPA %d: %s", ppa, strerror(errno)); return false; } - if(device_type == DEVICE_TYPE_TAP) { - if((arp_muxid = ioctl(ip_fd, I_PLINK, arp_fd)) < 0) { - logger(LOG_ERR, "Could not link %s %s to ARP", device_info, device); - return false; - } - - close(arp_fd); - } - - struct lifreq ifr = {}; - - strncpy(ifr.lifr_name, iface, sizeof(ifr.lifr_name)); - - ifr.lifr_ip_muxid = ip_muxid; - - if(device_type == DEVICE_TYPE_TAP) { - ifr.lifr_arp_muxid = arp_muxid; - } - - if(ioctl(ip_fd, SIOCSLIFMUXID, &ifr) < 0) { - if(device_type == DEVICE_TYPE_TAP) { - ioctl(ip_fd, I_PUNLINK, arp_muxid); - } - - ioctl(ip_fd, I_PUNLINK, ip_muxid); - logger(LOG_ERR, "Could not set multiplexor id for %s %s", device_info, device); + if(ioctl(ip_fd, I_LINK, if_fd) < 0) { + logger(LOG_ERR, "Can't link TUN device to IP: %s", strerror(errno)); return false; } - close(if_fd); + if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) + xasprintf(&iface, "tun%d", ppa); -#ifdef FD_CLOEXEC - fcntl(device_fd, F_SETFD, FD_CLOEXEC); - fcntl(ip_fd, F_SETFD, FD_CLOEXEC); -#endif + device_info = "Solaris tun device"; logger(LOG_INFO, "%s is a %s", device, device_info); return true; } -static void close_device(void) { - if(iface) { - struct lifreq ifr = {}; - strncpy(ifr.lifr_name, iface, sizeof(ifr.lifr_name)); - - if(ioctl(ip_fd, SIOCGLIFMUXID, &ifr) >= 0) { - int muxid = ifr.lifr_arp_muxid; - ioctl(ip_fd, I_PUNLINK, muxid); - muxid = ifr.lifr_ip_muxid; - ioctl(ip_fd, I_PUNLINK, muxid); - } - } - +void close_device(void) { + close(if_fd); close(ip_fd); close(device_fd); @@ -320,94 +114,49 @@ static void close_device(void) { free(iface); } -static bool read_packet(vpn_packet_t *packet) { - int result; - struct strbuf sbuf; - int f = 0; +bool read_packet(vpn_packet_t *packet) { + int inlen; - switch(device_type) { - case DEVICE_TYPE_TUN: - sbuf.maxlen = MTU - 14; - sbuf.buf = (char *)packet->data + 14; + if((inlen = read(device_fd, packet->data + 14, MTU - 14)) <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, + device, strerror(errno)); + return false; + } - if((result = getmsg(device_fd, NULL, &sbuf, &f)) < 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); - return false; - } - - switch(packet->data[14] >> 4) { + switch(packet->data[14] >> 4) { case 4: packet->data[12] = 0x08; packet->data[13] = 0x00; break; - case 6: packet->data[12] = 0x86; packet->data[13] = 0xDD; break; - default: - ifdebug(TRAFFIC) logger(LOG_ERR, "Unknown IP version %d while reading packet from %s %s", packet->data[14] >> 4, device_info, device); + ifdebug(TRAFFIC) logger(LOG_ERR, + "Unknown IP version %d while reading packet from %s %s", + packet->data[14] >> 4, device_info, device); return false; - } - - memset(packet->data, 0, 12); - packet->len = sbuf.len + 14; - break; - - case DEVICE_TYPE_TAP: - sbuf.maxlen = MTU; - sbuf.buf = (char *)packet->data; - - if((result = getmsg(device_fd, NULL, &sbuf, &f)) < 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); - return false; - } - - packet->len = sbuf.len; - break; - - default: - abort(); } + packet->len = inlen + 14; + device_total_in += packet->len; - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, + device_info); return true; } -static bool write_packet(vpn_packet_t *packet) { - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", packet->len, device_info); +bool write_packet(vpn_packet_t *packet) { + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", + packet->len, device_info); - struct strbuf sbuf; - - switch(device_type) { - case DEVICE_TYPE_TUN: - sbuf.len = packet->len - 14; - sbuf.buf = (char *)packet->data + 14; - - if(putmsg(device_fd, NULL, &sbuf, 0) < 0) { - logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); - return false; - } - - break; - - case DEVICE_TYPE_TAP: - sbuf.len = packet->len; - sbuf.buf = (char *)packet->data; - - if(putmsg(device_fd, NULL, &sbuf, 0) < 0) { - logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); - return false; - } - - break; - - default: - abort(); + if(write(device_fd, packet->data + 14, packet->len - 14) < 0) { + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, + device, strerror(errno)); + return false; } device_total_out += packet->len; @@ -415,16 +164,8 @@ static bool write_packet(vpn_packet_t *packet) { return true; } -static void dump_device_stats(void) { +void dump_device_stats(void) { logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); } - -const devops_t os_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, - .dump_stats = dump_device_stats, -}; diff --git a/src/splay_tree.c b/src/splay_tree.c new file mode 100644 index 0000000..135ba06 --- /dev/null +++ b/src/splay_tree.c @@ -0,0 +1,561 @@ +/* + splay_tree.c -- splay tree and linked list convenience + Copyright (C) 2004-2006 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include "splay_tree.h" +#include "xalloc.h" + +/* Splay operation */ + +static splay_node_t *splay_top_down(splay_tree_t *tree, const void *data, int *result) { + splay_node_t left = {NULL}, right = {NULL}; + splay_node_t *leftbottom = &left, *rightbottom = &right, *child, *grandchild; + splay_node_t *root = tree->root; + int c; + + if(!root) { + if(result) + *result = 0; + return NULL; + } + + while((c = tree->compare(data, root->data))) { + if(c < 0 && (child = root->left)) { + c = tree->compare(data, child->data); + + if(c < 0 && (grandchild = child->left)) { + rightbottom->left = child; + child->parent = rightbottom; + rightbottom = child; + + if((root->left = child->right)) + child->right->parent = root; + + child->right = root; + root->parent = child; + + child->left = NULL; + grandchild->parent = NULL; + + root = grandchild; + } else if (c > 0 && (grandchild = child->right)) { + leftbottom->right = child; + child->parent = leftbottom; + leftbottom = child; + + child->right = NULL; + grandchild->parent = NULL; + + rightbottom->left = root; + root->parent = rightbottom; + rightbottom = root; + + root->left = NULL; + + root = grandchild; + } else { + rightbottom->left = root; + root->parent = rightbottom; + rightbottom = root; + + root->left = NULL; + child->parent = NULL; + + root = child; + break; + } + } else if(c > 0 && (child = root->right)) { + c = tree->compare(data, child->data); + + if(c > 0 && (grandchild = child->right)) { + leftbottom->right = child; + child->parent = leftbottom; + leftbottom = child; + + if((root->right = child->left)) + child->left->parent = root; + + child->left = root; + root->parent = child; + + child->right = NULL; + grandchild->parent = NULL; + + root = grandchild; + } else if (c < 0 && (grandchild = child->left)) { + rightbottom->left = child; + child->parent = rightbottom; + rightbottom = child; + + child->left = NULL; + grandchild->parent = NULL; + + leftbottom->right = root; + root->parent = leftbottom; + leftbottom = root; + + root->right = NULL; + + root = grandchild; + } else { + leftbottom->right = root; + root->parent = leftbottom; + leftbottom = root; + + root->right = NULL; + child->parent = NULL; + + root = child; + break; + } + } else { + break; + } + } + + /* Merge trees */ + + if(left.right) { + if(root->left) { + leftbottom->right = root->left; + root->left->parent = leftbottom; + } + root->left = left.right; + left.right->parent = root; + } + + if(right.left) { + if(root->right) { + rightbottom->left = root->right; + root->right->parent = rightbottom; + } + root->right = right.left; + right.left->parent = root; + } + + /* Return result */ + + tree->root = root; + if(result) + *result = c; + + return tree->root; +} + +static void splay_bottom_up(splay_tree_t *tree, splay_node_t *node) { + splay_node_t *parent, *grandparent, *greatgrandparent; + + while((parent = node->parent)) { + if(!(grandparent = parent->parent)) { /* zig */ + if(node == parent->left) { + if((parent->left = node->right)) + parent->left->parent = parent; + node->right = parent; + } else { + if((parent->right = node->left)) + parent->right->parent = parent; + node->left = parent; + } + + parent->parent = node; + node->parent = NULL; + } else { + greatgrandparent = grandparent->parent; + + if(node == parent->left && parent == grandparent->left) { /* left zig-zig */ + if((grandparent->left = parent->right)) + grandparent->left->parent = grandparent; + parent->right = grandparent; + grandparent->parent = parent; + + if((parent->left = node->right)) + parent->left->parent = parent; + node->right = parent; + parent->parent = node; + } else if(node == parent->right && parent == grandparent->right) { /* right zig-zig */ + if((grandparent->right = parent->left)) + grandparent->right->parent = grandparent; + parent->left = grandparent; + grandparent->parent = parent; + + if((parent->right = node->left)) + parent->right->parent = parent; + node->left = parent; + parent->parent = node; + } else if(node == parent->right && parent == grandparent->left) { /* left-right zig-zag */ + if((parent->right = node->left)) + parent->right->parent = parent; + node->left = parent; + parent->parent = node; + + if((grandparent->left = node->right)) + grandparent->left->parent = grandparent; + node->right = grandparent; + grandparent->parent = node; + } else { /* right-left zig-zag */ + if((parent->left = node->right)) + parent->left->parent = parent; + node->right = parent; + parent->parent = node; + + if((grandparent->right = node->left)) + grandparent->right->parent = grandparent; + node->left = grandparent; + grandparent->parent = node; + } + + if((node->parent = greatgrandparent)) { + if(grandparent == greatgrandparent->left) + greatgrandparent->left = node; + else + greatgrandparent->right = node; + } + } + } + + tree->root = node; +} + +/* (De)constructors */ + +splay_tree_t *splay_alloc_tree(splay_compare_t compare, splay_action_t delete) { + splay_tree_t *tree; + + tree = xmalloc_and_zero(sizeof(splay_tree_t)); + tree->compare = compare; + tree->delete = delete; + + return tree; +} + +void splay_free_tree(splay_tree_t *tree) { + free(tree); +} + +splay_node_t *splay_alloc_node(void) { + return xmalloc_and_zero(sizeof(splay_node_t)); +} + +void splay_free_node(splay_tree_t *tree, splay_node_t *node) { + if(node->data && tree->delete) + tree->delete(node->data); + + free(node); +} + +/* Searching */ + +void *splay_search(splay_tree_t *tree, const void *data) { + splay_node_t *node; + + node = splay_search_node(tree, data); + + return node ? node->data : NULL; +} + +void *splay_search_closest(splay_tree_t *tree, const void *data, int *result) { + splay_node_t *node; + + node = splay_search_closest_node(tree, data, result); + + return node ? node->data : NULL; +} + +void *splay_search_closest_smaller(splay_tree_t *tree, const void *data) { + splay_node_t *node; + + node = splay_search_closest_smaller_node(tree, data); + + return node ? node->data : NULL; +} + +void *splay_search_closest_greater(splay_tree_t *tree, const void *data) { + splay_node_t *node; + + node = splay_search_closest_greater_node(tree, data); + + return node ? node->data : NULL; +} + +splay_node_t *splay_search_node(splay_tree_t *tree, const void *data) { + splay_node_t *node; + int result; + + node = splay_search_closest_node(tree, data, &result); + + return result ? NULL : node; +} + +splay_node_t *splay_search_closest_node_nosplay(const splay_tree_t *tree, const void *data, int *result) { + splay_node_t *node; + int c; + + node = tree->root; + + if(!node) { + if(result) + *result = 0; + return NULL; + } + + for(;;) { + c = tree->compare(data, node->data); + + if(c < 0) { + if(node->left) + node = node->left; + else + break; + } else if(c > 0) { + if(node->right) + node = node->right; + else + break; + } else { + break; + } + } + + if(result) + *result = c; + return node; +} + +splay_node_t *splay_search_closest_node(splay_tree_t *tree, const void *data, int *result) { + return splay_top_down(tree, data, result); +} + +splay_node_t *splay_search_closest_smaller_node(splay_tree_t *tree, const void *data) { + splay_node_t *node; + int result; + + node = splay_search_closest_node(tree, data, &result); + + if(result < 0) + node = node->prev; + + return node; +} + +splay_node_t *splay_search_closest_greater_node(splay_tree_t *tree, const void *data) { + splay_node_t *node; + int result; + + node = splay_search_closest_node(tree, data, &result); + + if(result > 0) + node = node->next; + + return node; +} + +/* Insertion and deletion */ + +splay_node_t *splay_insert(splay_tree_t *tree, void *data) { + splay_node_t *closest, *new; + int result; + + if(!tree->root) { + new = splay_alloc_node(); + new->data = data; + splay_insert_top(tree, new); + } else { + closest = splay_search_closest_node(tree, data, &result); + + if(!result) + return NULL; + + new = splay_alloc_node(); + new->data = data; + + if(result < 0) + splay_insert_before(tree, closest, new); + else + splay_insert_after(tree, closest, new); + } + + return new; +} + +splay_node_t *splay_insert_node(splay_tree_t *tree, splay_node_t *node) { + splay_node_t *closest; + int result; + + if(!tree->root) + splay_insert_top(tree, node); + else { + closest = splay_search_closest_node(tree, node->data, &result); + + if(!result) + return NULL; + + if(result < 0) + splay_insert_before(tree, closest, node); + else + splay_insert_after(tree, closest, node); + } + + return node; +} + +void splay_insert_top(splay_tree_t *tree, splay_node_t *node) { + node->prev = node->next = node->left = node->right = node->parent = NULL; + tree->head = tree->tail = tree->root = node; +} + +void splay_insert_before(splay_tree_t *tree, splay_node_t *before, splay_node_t *node) { + if(!before) { + if(tree->tail) + splay_insert_after(tree, tree->tail, node); + else + splay_insert_top(tree, node); + return; + } + + node->next = before; + if((node->prev = before->prev)) + before->prev->next = node; + else + tree->head = node; + before->prev = node; + + splay_bottom_up(tree, before); + + node->right = before; + before->parent = node; + if((node->left = before->left)) + before->left->parent = node; + before->left = NULL; + + node->parent = NULL; + tree->root = node; +} + +void splay_insert_after(splay_tree_t *tree, splay_node_t *after, splay_node_t *node) { + if(!after) { + if(tree->head) + splay_insert_before(tree, tree->head, node); + else + splay_insert_top(tree, node); + return; + } + + node->prev = after; + if((node->next = after->next)) + after->next->prev = node; + else + tree->tail = node; + after->next = node; + + splay_bottom_up(tree, after); + + node->left = after; + after->parent = node; + if((node->right = after->right)) + after->right->parent = node; + after->right = NULL; + + node->parent = NULL; + tree->root = node; +} + +splay_node_t *splay_unlink(splay_tree_t *tree, void *data) { + splay_node_t *node; + + node = splay_search_node(tree, data); + + if(node) + splay_unlink_node(tree, node); + + return node; +} + +void splay_unlink_node(splay_tree_t *tree, splay_node_t *node) { + if(node->prev) + node->prev->next = node->next; + else + tree->head = node->next; + + if(node->next) + node->next->prev = node->prev; + else + tree->tail = node->prev; + + splay_bottom_up(tree, node); + + if(node->prev) { + node->left->parent = NULL; + tree->root = node->left; + if((node->prev->right = node->right)) + node->right->parent = node->prev; + } else if(node->next) { + tree->root = node->right; + node->right->parent = NULL; + } else { + tree->root = NULL; + } +} + +void splay_delete_node(splay_tree_t *tree, splay_node_t *node) { + splay_unlink_node(tree, node); + splay_free_node(tree, node); +} + +void splay_delete(splay_tree_t *tree, void *data) { + splay_node_t *node; + + node = splay_search_node(tree, data); + + if(node) + splay_delete_node(tree, node); +} + +/* Fast tree cleanup */ + +void splay_delete_tree(splay_tree_t *tree) { + splay_node_t *node, *next; + + for(node = tree->head; node; node = next) { + next = node->next; + splay_free_node(tree, node); + } + + splay_free_tree(tree); +} + +/* Tree walking */ + +void splay_foreach(const splay_tree_t *tree, splay_action_t action) { + splay_node_t *node, *next; + + for(node = tree->head; node; node = next) { + next = node->next; + action(node->data); + } +} + +void splay_foreach_node(const splay_tree_t *tree, splay_action_t action) { + splay_node_t *node, *next; + + for(node = tree->head; node; node = next) { + next = node->next; + action(node); + } +} diff --git a/src/splay_tree.h b/src/splay_tree.h new file mode 100644 index 0000000..e4af0c4 --- /dev/null +++ b/src/splay_tree.h @@ -0,0 +1,107 @@ +/* + splay_tree.h -- header file for splay_tree.c + Copyright (C) 2004-2006 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + + +#ifndef __SPLAY_TREE_H__ +#define __SPLAY_TREE_H__ + +typedef struct splay_node_t { + + /* Linked list part */ + + struct splay_node_t *next; + struct splay_node_t *prev; + + /* Tree part */ + + struct splay_node_t *parent; + struct splay_node_t *left; + struct splay_node_t *right; + + /* Payload */ + + void *data; + +} splay_node_t; + +typedef int (*splay_compare_t)(const void *, const void *); +typedef void (*splay_action_t)(const void *); +typedef void (*splay_action_node_t)(const splay_node_t *); + +typedef struct splay_tree_t { + + /* Linked list part */ + + splay_node_t *head; + splay_node_t *tail; + + /* Tree part */ + + splay_node_t *root; + + splay_compare_t compare; + splay_action_t delete; + +} splay_tree_t; + +/* (De)constructors */ + +extern splay_tree_t *splay_alloc_tree(splay_compare_t, splay_action_t); +extern void splay_free_tree(splay_tree_t *); + +extern splay_node_t *splay_alloc_node(void); +extern void splay_free_node(splay_tree_t *tree, splay_node_t *); + +/* Insertion and deletion */ + +extern splay_node_t *splay_insert(splay_tree_t *, void *); +extern splay_node_t *splay_insert_node(splay_tree_t *, splay_node_t *); + +extern void splay_insert_top(splay_tree_t *, splay_node_t *); +extern void splay_insert_before(splay_tree_t *, splay_node_t *, splay_node_t *); +extern void splay_insert_after(splay_tree_t *, splay_node_t *, splay_node_t *); + +extern splay_node_t *splay_unlink(splay_tree_t *, void *); +extern void splay_unlink_node(splay_tree_t *tree, splay_node_t *); +extern void splay_delete(splay_tree_t *, void *); +extern void splay_delete_node(splay_tree_t *, splay_node_t *); + +/* Fast tree cleanup */ + +extern void splay_delete_tree(splay_tree_t *); + +/* Searching */ + +extern void *splay_search(splay_tree_t *, const void *); +extern void *splay_search_closest(splay_tree_t *, const void *, int *); +extern void *splay_search_closest_smaller(splay_tree_t *, const void *); +extern void *splay_search_closest_greater(splay_tree_t *, const void *); + +extern splay_node_t *splay_search_node(splay_tree_t *, const void *); +extern splay_node_t *splay_search_closest_node(splay_tree_t *, const void *, int *); +extern splay_node_t *splay_search_closest_node_nosplay(const splay_tree_t *, const void *, int *); +extern splay_node_t *splay_search_closest_smaller_node(splay_tree_t *, const void *); +extern splay_node_t *splay_search_closest_greater_node(splay_tree_t *, const void *); + +/* Tree walking */ + +extern void splay_foreach(const splay_tree_t *, splay_action_t); +extern void splay_foreach_node(const splay_tree_t *, splay_action_t); + +#endif diff --git a/src/subnet.c b/src/subnet.c index dc30b01..bf1bda2 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -1,6 +1,6 @@ /* subnet.c -- handle subnet lookups and lists - Copyright (C) 2000-2014 Guus Sliepen , + Copyright (C) 2000-2010 Guus Sliepen , 2000-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -20,7 +20,8 @@ #include "system.h" -#include "avl_tree.h" +#include "splay_tree.h" +#include "control_common.h" #include "device.h" #include "logger.h" #include "net.h" @@ -33,7 +34,7 @@ /* lists type of subnet */ -avl_tree_t *subnet_tree; +splay_tree_t *subnet_tree; /* Subnet lookup cache */ @@ -63,17 +64,15 @@ void subnet_cache_flush(void) { static int subnet_compare_mac(const subnet_t *a, const subnet_t *b) { int result; - result = memcmp(&a->net.mac.address, &b->net.mac.address, sizeof(mac_t)); + result = memcmp(&a->net.mac.address, &b->net.mac.address, sizeof a->net.mac.address); - if(result) { + if(result) return result; - } - + result = a->weight - b->weight; - if(result || !a->owner || !b->owner) { + if(result || !a->owner || !b->owner) return result; - } return strcmp(a->owner->name, b->owner->name); } @@ -83,21 +82,18 @@ static int subnet_compare_ipv4(const subnet_t *a, const subnet_t *b) { result = b->net.ipv4.prefixlength - a->net.ipv4.prefixlength; - if(result) { + if(result) return result; - } result = memcmp(&a->net.ipv4.address, &b->net.ipv4.address, sizeof(ipv4_t)); - if(result) { + if(result) return result; - } - + result = a->weight - b->weight; - if(result || !a->owner || !b->owner) { + if(result || !a->owner || !b->owner) return result; - } return strcmp(a->owner->name, b->owner->name); } @@ -107,21 +103,18 @@ static int subnet_compare_ipv6(const subnet_t *a, const subnet_t *b) { result = b->net.ipv6.prefixlength - a->net.ipv6.prefixlength; - if(result) { + if(result) return result; - } - + result = memcmp(&a->net.ipv6.address, &b->net.ipv6.address, sizeof(ipv6_t)); - if(result) { + if(result) return result; - } - + result = a->weight - b->weight; - if(result || !a->owner || !b->owner) { + if(result || !a->owner || !b->owner) return result; - } return strcmp(a->owner->name, b->owner->name); } @@ -131,23 +124,19 @@ int subnet_compare(const subnet_t *a, const subnet_t *b) { result = a->type - b->type; - if(result) { + if(result) return result; - } - switch(a->type) { + switch (a->type) { case SUBNET_MAC: return subnet_compare_mac(a, b); - case SUBNET_IPV4: return subnet_compare_ipv4(a, b); - case SUBNET_IPV6: return subnet_compare_ipv6(a, b); - default: logger(LOG_ERR, "subnet_compare() was called with unknown subnet type %d, exitting!", - a->type); + a->type); exit(0); } @@ -157,21 +146,21 @@ int subnet_compare(const subnet_t *a, const subnet_t *b) { /* Initialising trees */ void init_subnets(void) { - subnet_tree = avl_alloc_tree((avl_compare_t) subnet_compare, (avl_action_t) free_subnet); + subnet_tree = splay_alloc_tree((splay_compare_t) subnet_compare, (splay_action_t) free_subnet); subnet_cache_flush(); } void exit_subnets(void) { - avl_delete_tree(subnet_tree); + splay_delete_tree(subnet_tree); } -avl_tree_t *new_subnet_tree(void) { - return avl_alloc_tree((avl_compare_t) subnet_compare, NULL); +splay_tree_t *new_subnet_tree(void) { + return splay_alloc_tree((splay_compare_t) subnet_compare, NULL); } -void free_subnet_tree(avl_tree_t *subnet_tree) { - avl_delete_tree(subnet_tree); +void free_subnet_tree(splay_tree_t *subnet_tree) { + splay_delete_tree(subnet_tree); } /* Allocating and freeing space for subnets */ @@ -189,15 +178,15 @@ void free_subnet(subnet_t *subnet) { void subnet_add(node_t *n, subnet_t *subnet) { subnet->owner = n; - avl_insert(subnet_tree, subnet); - avl_insert(n->subnet_tree, subnet); + splay_insert(subnet_tree, subnet); + splay_insert(n->subnet_tree, subnet); subnet_cache_flush(); } void subnet_del(node_t *n, subnet_t *subnet) { - avl_delete(n->subnet_tree, subnet); - avl_delete(subnet_tree, subnet); + splay_delete(n->subnet_tree, subnet); + splay_delete(subnet_tree, subnet); subnet_cache_flush(); } @@ -210,20 +199,17 @@ bool str2net(subnet_t *subnet, const char *subnetstr) { int weight = 10; if(sscanf(subnetstr, "%hu.%hu.%hu.%hu/%d#%d", - &x[0], &x[1], &x[2], &x[3], &l, &weight) >= 5) { - if(l < 0 || l > 32) { + &x[0], &x[1], &x[2], &x[3], &l, &weight) >= 5) { + if(l < 0 || l > 32) return false; - } subnet->type = SUBNET_IPV4; subnet->net.ipv4.prefixlength = l; subnet->weight = weight; for(i = 0; i < 4; i++) { - if(x[i] > 255) { + if(x[i] > 255) return false; - } - subnet->net.ipv4.address.x[i] = x[i]; } @@ -231,19 +217,17 @@ bool str2net(subnet_t *subnet, const char *subnetstr) { } if(sscanf(subnetstr, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx/%d#%d", - &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7], - &l, &weight) >= 9) { - if(l < 0 || l > 128) { + &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7], + &l, &weight) >= 9) { + if(l < 0 || l > 128) return false; - } subnet->type = SUBNET_IPV6; subnet->net.ipv6.prefixlength = l; subnet->weight = weight; - for(i = 0; i < 8; i++) { + for(i = 0; i < 8; i++) subnet->net.ipv6.address.x[i] = htons(x[i]); - } return true; } @@ -254,10 +238,8 @@ bool str2net(subnet_t *subnet, const char *subnetstr) { subnet->weight = weight; for(i = 0; i < 4; i++) { - if(x[i] > 255) { + if(x[i] > 255) return false; - } - subnet->net.ipv4.address.x[i] = x[i]; } @@ -265,119 +247,24 @@ bool str2net(subnet_t *subnet, const char *subnetstr) { } if(sscanf(subnetstr, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx#%d", - &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7], &weight) >= 8) { + &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7], &weight) >= 8) { subnet->type = SUBNET_IPV6; subnet->net.ipv6.prefixlength = 128; subnet->weight = weight; - for(i = 0; i < 8; i++) { + for(i = 0; i < 8; i++) subnet->net.ipv6.address.x[i] = htons(x[i]); - } return true; } if(sscanf(subnetstr, "%hx:%hx:%hx:%hx:%hx:%hx#%d", - &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &weight) >= 6) { + &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &weight) >= 6) { subnet->type = SUBNET_MAC; subnet->weight = weight; - for(i = 0; i < 6; i++) { + for(i = 0; i < 6; i++) subnet->net.mac.address.x[i] = x[i]; - } - - return true; - } - - // IPv6 short form - if(strstr(subnetstr, "::")) { - const char *p; - char *q; - int colons = 0; - - // Count number of colons - for(p = subnetstr; *p; p++) - if(*p == ':') { - colons++; - } - - if(colons > 7) { - return false; - } - - // Scan numbers before the double colon - p = subnetstr; - - for(i = 0; i < colons; i++) { - if(*p == ':') { - break; - } - - x[i] = strtoul(p, &q, 0x10); - - if(!q || p == q || *q != ':') { - return false; - } - - p = ++q; - } - - p++; - colons -= i; - - if(!i) { - p++; - colons--; - } - - if(!*p || *p == '/' || *p == '#') { - colons--; - } - - // Fill in the blanks - for(; i < 8 - colons; i++) { - x[i] = 0; - } - - // Scan the remaining numbers - for(; i < 8; i++) { - x[i] = strtoul(p, &q, 0x10); - - if(!q || p == q) { - return false; - } - - if(i == 7) { - p = q; - break; - } - - if(*q != ':') { - return false; - } - - p = ++q; - } - - l = 128; - - if(*p == '/') { - sscanf(p, "/%d#%d", &l, &weight); - } else if(*p == '#') { - sscanf(p, "#%d", &weight); - } - - if(l < 0 || l > 128) { - return false; - } - - subnet->type = SUBNET_IPV6; - subnet->net.ipv6.prefixlength = l; - subnet->weight = weight; - - for(i = 0; i < 8; i++) { - subnet->net.ipv6.address.x[i] = htons(x[i]); - } return true; } @@ -387,51 +274,51 @@ bool str2net(subnet_t *subnet, const char *subnetstr) { bool net2str(char *netstr, int len, const subnet_t *subnet) { if(!netstr || !subnet) { - logger(LOG_ERR, "net2str() was called with netstr=%p, subnet=%p!", (void *)netstr, (void *)subnet); + logger(LOG_ERR, "net2str() was called with netstr=%p, subnet=%p!", netstr, subnet); return false; } - switch(subnet->type) { - case SUBNET_MAC: - snprintf(netstr, len, "%x:%x:%x:%x:%x:%x#%d", - subnet->net.mac.address.x[0], - subnet->net.mac.address.x[1], - subnet->net.mac.address.x[2], - subnet->net.mac.address.x[3], - subnet->net.mac.address.x[4], - subnet->net.mac.address.x[5], - subnet->weight); - break; + switch (subnet->type) { + case SUBNET_MAC: + snprintf(netstr, len, "%hx:%hx:%hx:%hx:%hx:%hx#%d", + subnet->net.mac.address.x[0], + subnet->net.mac.address.x[1], + subnet->net.mac.address.x[2], + subnet->net.mac.address.x[3], + subnet->net.mac.address.x[4], + subnet->net.mac.address.x[5], + subnet->weight); + break; - case SUBNET_IPV4: - snprintf(netstr, len, "%u.%u.%u.%u/%d#%d", - subnet->net.ipv4.address.x[0], - subnet->net.ipv4.address.x[1], - subnet->net.ipv4.address.x[2], - subnet->net.ipv4.address.x[3], - subnet->net.ipv4.prefixlength, - subnet->weight); - break; + case SUBNET_IPV4: + snprintf(netstr, len, "%hu.%hu.%hu.%hu/%d#%d", + subnet->net.ipv4.address.x[0], + subnet->net.ipv4.address.x[1], + subnet->net.ipv4.address.x[2], + subnet->net.ipv4.address.x[3], + subnet->net.ipv4.prefixlength, + subnet->weight); + break; - case SUBNET_IPV6: - snprintf(netstr, len, "%x:%x:%x:%x:%x:%x:%x:%x/%d#%d", - ntohs(subnet->net.ipv6.address.x[0]), - ntohs(subnet->net.ipv6.address.x[1]), - ntohs(subnet->net.ipv6.address.x[2]), - ntohs(subnet->net.ipv6.address.x[3]), - ntohs(subnet->net.ipv6.address.x[4]), - ntohs(subnet->net.ipv6.address.x[5]), - ntohs(subnet->net.ipv6.address.x[6]), - ntohs(subnet->net.ipv6.address.x[7]), - subnet->net.ipv6.prefixlength, - subnet->weight); - break; + case SUBNET_IPV6: + snprintf(netstr, len, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx/%d#%d", + ntohs(subnet->net.ipv6.address.x[0]), + ntohs(subnet->net.ipv6.address.x[1]), + ntohs(subnet->net.ipv6.address.x[2]), + ntohs(subnet->net.ipv6.address.x[3]), + ntohs(subnet->net.ipv6.address.x[4]), + ntohs(subnet->net.ipv6.address.x[5]), + ntohs(subnet->net.ipv6.address.x[6]), + ntohs(subnet->net.ipv6.address.x[7]), + subnet->net.ipv6.prefixlength, + subnet->weight); + break; - default: - logger(LOG_ERR, - "net2str() was called with unknown subnet type %d, exiting!", - subnet->type); - exit(0); + default: + logger(LOG_ERR, + "net2str() was called with unknown subnet type %d, exiting!", + subnet->type); + exit(0); } return true; @@ -440,52 +327,44 @@ bool net2str(char *netstr, int len, const subnet_t *subnet) { /* Subnet lookup routines */ subnet_t *lookup_subnet(const node_t *owner, const subnet_t *subnet) { - return avl_search(owner->subnet_tree, subnet); + return splay_search(owner->subnet_tree, subnet); } subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) { subnet_t *p, *r = NULL; - avl_node_t *n; + splay_node_t *n; int i; // Check if this address is cached for(i = 0; i < 2; i++) { - if(!cache_mac_valid[i]) { + if(!cache_mac_valid[i]) continue; - } - - if(owner && cache_mac_subnet[i] && cache_mac_subnet[i]->owner != owner) { + if(owner && cache_mac_subnet[i] && cache_mac_subnet[i]->owner != owner) continue; - } - - if(!memcmp(address, &cache_mac_address[i], sizeof(*address))) { + if(!memcmp(address, &cache_mac_address[i], sizeof *address)) return cache_mac_subnet[i]; - } } // Search all subnets for a matching one for(n = owner ? owner->subnet_tree->head : subnet_tree->head; n; n = n->next) { p = n->data; - - if(!p || p->type != SUBNET_MAC) { + + if(!p || p->type != SUBNET_MAC) continue; - } - if(!memcmp(address, &p->net.mac.address, sizeof(*address))) { + if(!memcmp(address, &p->net.mac.address, sizeof *address)) { r = p; - - if(p->owner->status.reachable) { + if(p->owner->status.reachable) break; - } } } // Cache the result cache_mac_slot = !cache_mac_slot; - memcpy(&cache_mac_address[cache_mac_slot], address, sizeof(*address)); + memcpy(&cache_mac_address[cache_mac_slot], address, sizeof *address); cache_mac_subnet[cache_mac_slot] = r; cache_mac_valid[cache_mac_slot] = true; @@ -494,43 +373,37 @@ subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) { subnet_t *lookup_subnet_ipv4(const ipv4_t *address) { subnet_t *p, *r = NULL; - avl_node_t *n; + splay_node_t *n; int i; // Check if this address is cached for(i = 0; i < 2; i++) { - if(!cache_ipv4_valid[i]) { + if(!cache_ipv4_valid[i]) continue; - } - - if(!memcmp(address, &cache_ipv4_address[i], sizeof(*address))) { + if(!memcmp(address, &cache_ipv4_address[i], sizeof *address)) return cache_ipv4_subnet[i]; - } } // Search all subnets for a matching one for(n = subnet_tree->head; n; n = n->next) { p = n->data; - - if(!p || p->type != SUBNET_IPV4) { + + if(!p || p->type != SUBNET_IPV4) continue; - } if(!maskcmp(address, &p->net.ipv4.address, p->net.ipv4.prefixlength)) { r = p; - - if(p->owner->status.reachable) { + if(p->owner->status.reachable) break; - } } } // Cache the result cache_ipv4_slot = !cache_ipv4_slot; - memcpy(&cache_ipv4_address[cache_ipv4_slot], address, sizeof(*address)); + memcpy(&cache_ipv4_address[cache_ipv4_slot], address, sizeof *address); cache_ipv4_subnet[cache_ipv4_slot] = r; cache_ipv4_valid[cache_ipv4_slot] = true; @@ -539,43 +412,37 @@ subnet_t *lookup_subnet_ipv4(const ipv4_t *address) { subnet_t *lookup_subnet_ipv6(const ipv6_t *address) { subnet_t *p, *r = NULL; - avl_node_t *n; + splay_node_t *n; int i; // Check if this address is cached for(i = 0; i < 2; i++) { - if(!cache_ipv6_valid[i]) { + if(!cache_ipv6_valid[i]) continue; - } - - if(!memcmp(address, &cache_ipv6_address[i], sizeof(*address))) { + if(!memcmp(address, &cache_ipv6_address[i], sizeof *address)) return cache_ipv6_subnet[i]; - } } // Search all subnets for a matching one for(n = subnet_tree->head; n; n = n->next) { p = n->data; - - if(!p || p->type != SUBNET_IPV6) { + + if(!p || p->type != SUBNET_IPV6) continue; - } if(!maskcmp(address, &p->net.ipv6.address, p->net.ipv6.prefixlength)) { r = p; - - if(p->owner->status.reachable) { + if(p->owner->status.reachable) break; - } } } // Cache the result cache_ipv6_slot = !cache_ipv6_slot; - memcpy(&cache_ipv6_address[cache_ipv6_slot], address, sizeof(*address)); + memcpy(&cache_ipv6_address[cache_ipv6_slot], address, sizeof *address); cache_ipv6_subnet[cache_ipv6_slot] = r; cache_ipv6_valid[cache_ipv6_slot] = true; @@ -583,28 +450,25 @@ subnet_t *lookup_subnet_ipv6(const ipv6_t *address) { } void subnet_update(node_t *owner, subnet_t *subnet, bool up) { - avl_node_t *node; + splay_node_t *node; int i; - char *envp[10] = {NULL}; + char *envp[9] = {NULL}; char netstr[MAXNETSTR]; char *name, *address, *port; char empty[] = ""; // Prepare environment variables to be passed to the script - xasprintf(&envp[0], "NETNAME=%s", netname ? netname : ""); - xasprintf(&envp[1], "DEVICE=%s", device ? device : ""); - xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : ""); + xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); + xasprintf(&envp[1], "DEVICE=%s", device ? : ""); + xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); xasprintf(&envp[3], "NODE=%s", owner->name); - xasprintf(&envp[4], "NAME=%s", myself->name); if(owner != myself) { sockaddr2str(&owner->address, &address, &port); - // 5 and 6 are reserved for SUBNET and WEIGHT - xasprintf(&envp[7], "REMOTEADDRESS=%s", address); - xasprintf(&envp[8], "REMOTEPORT=%s", port); - free(port); - free(address); + // 4 and 5 are reserved for SUBNET and WEIGHT + xasprintf(&envp[6], "REMOTEADDRESS=%s", address); + xasprintf(&envp[7], "REMOTEPORT=%s", port); } name = up ? "subnet-up" : "subnet-down"; @@ -612,69 +476,59 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) { if(!subnet) { for(node = owner->subnet_tree->head; node; node = node->next) { subnet = node->data; - - if(!net2str(netstr, sizeof(netstr), subnet)) { + if(!net2str(netstr, sizeof netstr, subnet)) continue; - } - // Strip the weight from the subnet, and put it in its own environment variable char *weight = strchr(netstr, '#'); - - if(weight) { + if(weight) *weight++ = 0; - } else { + else weight = empty; - } // Prepare the SUBNET and WEIGHT variables - free(envp[5]); - free(envp[6]); - - xasprintf(&envp[5], "SUBNET=%s", netstr); - xasprintf(&envp[6], "WEIGHT=%s", weight); + if(envp[4]) + free(envp[4]); + if(envp[5]) + free(envp[5]); + xasprintf(&envp[4], "SUBNET=%s", netstr); + xasprintf(&envp[5], "WEIGHT=%s", weight); execute_script(name, envp); } } else { - if(net2str(netstr, sizeof(netstr), subnet)) { + if(net2str(netstr, sizeof netstr, subnet)) { // Strip the weight from the subnet, and put it in its own environment variable char *weight = strchr(netstr, '#'); - - if(weight) { + if(weight) *weight++ = 0; - } else { + else weight = empty; - } // Prepare the SUBNET and WEIGHT variables - xasprintf(&envp[5], "SUBNET=%s", netstr); - xasprintf(&envp[6], "WEIGHT=%s", weight); + xasprintf(&envp[4], "SUBNET=%s", netstr); + xasprintf(&envp[5], "WEIGHT=%s", weight); execute_script(name, envp); } } - for(i = 0; i < 9; i++) { + for(i = 0; envp[i] && i < 8; i++) free(envp[i]); - } } -void dump_subnets(void) { +bool dump_subnets(connection_t *c) { char netstr[MAXNETSTR]; subnet_t *subnet; - avl_node_t *node; - - logger(LOG_DEBUG, "Subnet list:"); + splay_node_t *node; for(node = subnet_tree->head; node; node = node->next) { subnet = node->data; - - if(!net2str(netstr, sizeof(netstr), subnet)) { + if(!net2str(netstr, sizeof netstr, subnet)) continue; - } - - logger(LOG_DEBUG, " %s owner %s", netstr, subnet->owner->name); + send_request(c, "%d %d %s owner %s", + CONTROL, REQ_DUMP_SUBNETS, + netstr, subnet->owner->name); } - logger(LOG_DEBUG, "End of subnet list."); + return send_request(c, "%d %d", CONTROL, REQ_DUMP_SUBNETS); } diff --git a/src/subnet.h b/src/subnet.h index 6fecca3..f22e6d5 100644 --- a/src/subnet.h +++ b/src/subnet.h @@ -1,6 +1,3 @@ -#ifndef TINC_SUBNET_H -#define TINC_SUBNET_H - /* subnet.h -- header for subnet.c Copyright (C) 2000-2009 Guus Sliepen , @@ -21,13 +18,16 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_SUBNET_H__ +#define __TINC_SUBNET_H__ + #include "net.h" typedef enum subnet_type_t { SUBNET_MAC = 0, SUBNET_IPV4, SUBNET_IPV6, - SUBNET_TYPES, /* Guardian */ + SUBNET_TYPES /* Guardian */ } subnet_type_t; typedef struct subnet_mac_t { @@ -47,11 +47,11 @@ typedef struct subnet_ipv6_t { #include "node.h" typedef struct subnet_t { - struct node_t *owner; /* the owner of this subnet */ + struct node_t *owner; /* the owner of this subnet */ - subnet_type_t type; /* subnet type (IPv4? IPv6? MAC? something even weirder?) */ - time_t expires; /* expiry time */ - int weight; /* weight (higher value is higher priority) */ + subnet_type_t type; /* subnet type (IPv4? IPv6? MAC? something even weirder?) */ + time_t expires; /* expiry time */ + int weight; /* weight (higher value is higher priority) */ /* And now for the actual subnet: */ @@ -64,24 +64,25 @@ typedef struct subnet_t { #define MAXNETSTR 64 -extern avl_tree_t *subnet_tree; +extern splay_tree_t *subnet_tree; -extern subnet_t *new_subnet(void) __attribute__((__malloc__)); -extern void free_subnet(subnet_t *subnet); +extern int subnet_compare(const struct subnet_t *, const struct subnet_t *); +extern subnet_t *new_subnet(void) __attribute__ ((__malloc__)); +extern void free_subnet(subnet_t *); extern void init_subnets(void); extern void exit_subnets(void); -extern avl_tree_t *new_subnet_tree(void) __attribute__((__malloc__)); -extern void free_subnet_tree(avl_tree_t *subnet_tree); -extern void subnet_add(struct node_t *owner, subnet_t *subnet); -extern void subnet_del(struct node_t *owner, subnet_t *subnet); -extern void subnet_update(struct node_t *owner, subnet_t *subnet, bool up); -extern bool net2str(char *netstr, int len, const subnet_t *subnet); -extern bool str2net(subnet_t *subnet, const char *netstr); -extern subnet_t *lookup_subnet(const struct node_t *owner, const subnet_t *subnet); -extern subnet_t *lookup_subnet_mac(const struct node_t *owner, const mac_t *address); -extern subnet_t *lookup_subnet_ipv4(const ipv4_t *address); -extern subnet_t *lookup_subnet_ipv6(const ipv6_t *address); -extern void dump_subnets(void); +extern splay_tree_t *new_subnet_tree(void) __attribute__ ((__malloc__)); +extern void free_subnet_tree(splay_tree_t *); +extern void subnet_add(struct node_t *, subnet_t *); +extern void subnet_del(struct node_t *, subnet_t *); +extern void subnet_update(struct node_t *, subnet_t *, bool); +extern bool net2str(char *, int, const subnet_t *); +extern bool str2net(subnet_t *, const char *); +extern subnet_t *lookup_subnet(const struct node_t *, const subnet_t *); +extern subnet_t *lookup_subnet_mac(const struct node_t *, const mac_t *); +extern subnet_t *lookup_subnet_ipv4(const ipv4_t *); +extern subnet_t *lookup_subnet_ipv6(const ipv6_t *); +extern bool dump_subnets(struct connection_t *); extern void subnet_cache_flush(void); -#endif +#endif /* __TINC_SUBNET_H__ */ diff --git a/src/tincctl.c b/src/tincctl.c new file mode 100644 index 0000000..c055db5 --- /dev/null +++ b/src/tincctl.c @@ -0,0 +1,833 @@ +/* + tincctl.c -- Controlling a running tincd + Copyright (C) 2007-2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include + +#include "xalloc.h" +#include "protocol.h" +#include "control_common.h" +#include "ecdsagen.h" +#include "rsagen.h" +#include "utils.h" +#include "tincctl.h" +#include "top.h" + +/* The name this program was run with. */ +static char *program_name = NULL; + +/* If nonzero, display usage information and exit. */ +static bool show_help = false; + +/* If nonzero, print the version on standard output and exit. */ +static bool show_version = false; + +static char *name = NULL; +static char *identname = NULL; /* program name for syslog */ +static char *pidfilename = NULL; /* pid file location */ +static char controlcookie[1024]; +char *netname = NULL; +char *confbase = NULL; + +#ifdef HAVE_MINGW +static struct WSAData wsa_state; +#endif + +static struct option const long_options[] = { + {"config", required_argument, NULL, 'c'}, + {"net", required_argument, NULL, 'n'}, + {"help", no_argument, NULL, 1}, + {"version", no_argument, NULL, 2}, + {"pidfile", required_argument, NULL, 5}, + {NULL, 0, NULL, 0} +}; + +static void usage(bool status) { + if(status) + fprintf(stderr, "Try `%s --help\' for more information.\n", + program_name); + else { + printf("Usage: %s [options] command\n\n", program_name); + printf("Valid options are:\n" + " -c, --config=DIR Read configuration options from DIR.\n" + " -n, --net=NETNAME Connect to net NETNAME.\n" + " --pidfile=FILENAME Read control cookie from FILENAME.\n" + " --help Display this help and exit.\n" + " --version Output version information and exit.\n" + "\n" + "Valid commands are:\n" + " start Start tincd.\n" + " stop Stop tincd.\n" + " restart Restart tincd.\n" + " reload Reload configuration of running tincd.\n" + " pid Show PID of currently running tincd.\n" + " generate-keys [bits] Generate new RSA and ECDSA public/private keypairs.\n" + " generate-rsa-keys [bits] Generate a new RSA public/private keypair.\n" + " generate-ecdsa-keys Generate a new ECDSA public/private keypair.\n" + " dump Dump a list of one of the following things:\n" + " nodes - all known nodes in the VPN\n" + " edges - all known connections in the VPN\n" + " subnets - all known subnets in the VPN\n" + " connections - all meta connections with ourself\n" + " graph - graph of the VPN in dotty format\n" + " purge Purge unreachable nodes\n" + " debug N Set debug level\n" + " retry Retry all outgoing connections\n" + " reload Partial reload of configuration\n" + " disconnect NODE Close meta connection with NODE\n" +#ifdef HAVE_CURSES + " top Show real-time statistics\n" +#endif + " pcap Dump traffic in pcap format\n" + "\n"); + printf("Report bugs to tinc@tinc-vpn.org.\n"); + } +} + +static bool parse_options(int argc, char **argv) { + int r; + int option_index = 0; + + while((r = getopt_long(argc, argv, "c:n:", long_options, &option_index)) != EOF) { + switch (r) { + case 0: /* long option */ + break; + + case 'c': /* config file */ + confbase = xstrdup(optarg); + break; + + case 'n': /* net name given */ + netname = xstrdup(optarg); + break; + + case 1: /* show help */ + show_help = true; + break; + + case 2: /* show version */ + show_version = true; + break; + + case 5: /* open control socket here */ + pidfilename = xstrdup(optarg); + break; + + case '?': + usage(true); + return false; + + default: + break; + } + } + + return true; +} + +FILE *ask_and_open(const char *filename, const char *what, const char *mode) { + FILE *r; + char *directory; + char buf[PATH_MAX]; + char buf2[PATH_MAX]; + + /* Check stdin and stdout */ + if(isatty(0) && isatty(1)) { + /* Ask for a file and/or directory name. */ + fprintf(stdout, "Please enter a file to save %s to [%s]: ", + what, filename); + fflush(stdout); + + if(fgets(buf, sizeof buf, stdin) == NULL) { + fprintf(stderr, "Error while reading stdin: %s\n", + strerror(errno)); + return NULL; + } + + size_t len = strlen(buf); + if(len) + buf[--len] = 0; + + if(len) + filename = buf; + } + +#ifdef HAVE_MINGW + if(filename[0] != '\\' && filename[0] != '/' && !strchr(filename, ':')) { +#else + if(filename[0] != '/') { +#endif + /* The directory is a relative path or a filename. */ + directory = get_current_dir_name(); + snprintf(buf2, sizeof buf2, "%s/%s", directory, filename); + filename = buf2; + } + + umask(0077); /* Disallow everything for group and other */ + + /* Open it first to keep the inode busy */ + + r = fopen(filename, mode); + + if(!r) { + fprintf(stderr, "Error opening file `%s': %s\n", filename, strerror(errno)); + return NULL; + } + + return r; +} + +/* + Generate a public/private ECDSA keypair, and ask for a file to store + them in. +*/ +static bool ecdsa_keygen() { + ecdsa_t key; + FILE *f; + char *filename; + + fprintf(stderr, "Generating ECDSA keypair:\n"); + + if(!ecdsa_generate(&key)) { + fprintf(stderr, "Error during key generation!\n"); + return false; + } else + fprintf(stderr, "Done.\n"); + + xasprintf(&filename, "%s/ecdsa_key.priv", confbase); + f = ask_and_open(filename, "private ECDSA key", "a"); + + if(!f) + return false; + +#ifdef HAVE_FCHMOD + /* Make it unreadable for others. */ + fchmod(fileno(f), 0600); +#endif + + if(ftell(f)) + fprintf(stderr, "Appending key to existing contents.\nMake sure only one key is stored in the file.\n"); + + ecdsa_write_pem_private_key(&key, f); + + fclose(f); + free(filename); + + if(name) + xasprintf(&filename, "%s/hosts/%s", confbase, name); + else + xasprintf(&filename, "%s/ecdsa_key.pub", confbase); + + f = ask_and_open(filename, "public ECDSA key", "a"); + + if(!f) + return false; + + if(ftell(f)) + fprintf(stderr, "Appending key to existing contents.\nMake sure only one key is stored in the file.\n"); + + char *pubkey = ecdsa_get_base64_public_key(&key); + fprintf(f, "ECDSAPublicKey = %s\n", pubkey); + free(pubkey); + + fclose(f); + free(filename); + + return true; +} + +/* + Generate a public/private RSA keypair, and ask for a file to store + them in. +*/ +static bool rsa_keygen(int bits) { + rsa_t key; + FILE *f; + char *filename; + + fprintf(stderr, "Generating %d bits keys:\n", bits); + + if(!rsa_generate(&key, bits, 0x10001)) { + fprintf(stderr, "Error during key generation!\n"); + return false; + } else + fprintf(stderr, "Done.\n"); + + xasprintf(&filename, "%s/rsa_key.priv", confbase); + f = ask_and_open(filename, "private RSA key", "a"); + + if(!f) + return false; + +#ifdef HAVE_FCHMOD + /* Make it unreadable for others. */ + fchmod(fileno(f), 0600); +#endif + + if(ftell(f)) + fprintf(stderr, "Appending key to existing contents.\nMake sure only one key is stored in the file.\n"); + + rsa_write_pem_private_key(&key, f); + + fclose(f); + free(filename); + + if(name) + xasprintf(&filename, "%s/hosts/%s", confbase, name); + else + xasprintf(&filename, "%s/rsa_key.pub", confbase); + + f = ask_and_open(filename, "public RSA key", "a"); + + if(!f) + return false; + + if(ftell(f)) + fprintf(stderr, "Appending key to existing contents.\nMake sure only one key is stored in the file.\n"); + + rsa_write_pem_public_key(&key, f); + + fclose(f); + free(filename); + + return true; +} + +/* + Set all files and paths according to netname +*/ +static void make_names(void) { +#ifdef HAVE_MINGW + HKEY key; + char installdir[1024] = ""; + long len = sizeof installdir; +#endif + + if(netname) + xasprintf(&identname, "tinc.%s", netname); + else + identname = xstrdup("tinc"); + +#ifdef HAVE_MINGW + if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) { + if(!RegQueryValueEx(key, NULL, 0, 0, installdir, &len)) { + if(!confbase) { + if(netname) + xasprintf(&confbase, "%s/%s", installdir, netname); + else + xasprintf(&confbase, "%s", installdir); + } + } + if(!pidfilename) + xasprintf(&pidfilename, "%s/pid", confbase); + RegCloseKey(key); + if(*installdir) + return; + } +#endif + + if(!pidfilename) + xasprintf(&pidfilename, "%s/run/%s.pid", LOCALSTATEDIR, identname); + + if(netname) { + if(!confbase) + xasprintf(&confbase, CONFDIR "/tinc/%s", netname); + else + fprintf(stderr, "Both netname and configuration directory given, using the latter...\n"); + } else { + if(!confbase) + xasprintf(&confbase, CONFDIR "/tinc"); + } +} + +static char buffer[4096]; +static size_t blen = 0; + +bool recvline(int fd, char *line, size_t len) { + char *newline = NULL; + + while(!(newline = memchr(buffer, '\n', blen))) { + int result = recv(fd, buffer + blen, sizeof buffer - blen, 0); + if(result == -1 && errno == EINTR) + continue; + else if(result <= 0) + return false; + blen += result; + } + + if(newline - buffer >= len) + return false; + + len = newline - buffer; + + memcpy(line, buffer, len); + line[len] = 0; + memmove(buffer, newline + 1, blen - len - 1); + blen -= len + 1; + + return true; +} + +bool recvdata(int fd, char *data, size_t len) { + while(blen < len) { + int result = recv(fd, buffer + blen, sizeof buffer - blen, 0); + if(result == -1 && errno == EINTR) + continue; + else if(result <= 0) + return false; + blen += result; + } + + memcpy(data, buffer, len); + memmove(buffer, buffer + len, blen - len); + blen -= len; + + return true; +} + +bool sendline(int fd, char *format, ...) { + static char buffer[4096]; + char *p = buffer; + int blen = 0; + va_list ap; + + va_start(ap, format); + blen = vsnprintf(buffer, sizeof buffer, format, ap); + va_end(ap); + + if(blen < 1 || blen >= sizeof buffer) + return false; + + buffer[blen] = '\n'; + blen++; + + while(blen) { + int result = send(fd, p, blen, 0); + if(result == -1 && errno == EINTR) + continue; + else if(result <= 0) + return false; + p += result; + blen -= result; + } + + return true; +} + +void pcap(int fd, FILE *out) { + sendline(fd, "%d %d", CONTROL, REQ_PCAP); + char data[9018]; + + struct { + uint32_t magic; + uint16_t major; + uint16_t minor; + uint32_t tz_offset; + uint32_t tz_accuracy; + uint32_t snaplen; + uint32_t ll_type; + } header = { + 0xa1b2c3d4, + 2, 4, + 0, 0, + sizeof data, + 1, + }; + + struct { + uint32_t tv_sec; + uint32_t tv_usec; + uint32_t len; + uint32_t origlen; + } packet; + + struct timeval tv; + + fwrite(&header, sizeof header, 1, out); + fflush(out); + + char line[32]; + while(recvline(fd, line, sizeof line)) { + int code, req, len; + int n = sscanf(line, "%d %d %d", &code, &req, &len); + gettimeofday(&tv, NULL); + if(n != 3 || code != CONTROL || req != REQ_PCAP || len < 0 || len > sizeof data) + break; + if(!recvdata(fd, data, len)) + break; + packet.tv_sec = tv.tv_sec; + packet.tv_usec = tv.tv_usec; + packet.len = len; + packet.origlen = len; + fwrite(&packet, sizeof packet, 1, out); + fwrite(data, len, 1, out); + fflush(out); + } +} + +#ifdef HAVE_MINGW +static bool remove_service(void) { + SC_HANDLE manager = NULL; + SC_HANDLE service = NULL; + SERVICE_STATUS status = {0}; + + manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if(!manager) { + fprintf(stderr, "Could not open service manager: %s\n", winerror(GetLastError())); + return false; + } + + service = OpenService(manager, identname, SERVICE_ALL_ACCESS); + + if(!service) { + fprintf(stderr, "Could not open %s service: %s\n", identname, winerror(GetLastError())); + return false; + } + + if(!ControlService(service, SERVICE_CONTROL_STOP, &status)) + fprintf(stderr, "Could not stop %s service: %s\n", identname, winerror(GetLastError())); + else + fprintf(stderr, "%s service stopped\n", identname); + + if(!DeleteService(service)) { + fprintf(stderr, "Could not remove %s service: %s\n", identname, winerror(GetLastError())); + return false; + } + + fprintf(stderr, "%s service removed\n", identname); + + return true; +} +#endif + +int main(int argc, char *argv[], char *envp[]) { + int fd; + int result; + char host[128]; + char port[128]; + int pid; + + program_name = argv[0]; + + if(!parse_options(argc, argv)) + return 1; + + make_names(); + + if(show_version) { + printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE, + VERSION, __DATE__, __TIME__, PROT_MAJOR, PROT_MINOR); + printf("Copyright (C) 1998-2009 Ivo Timmermans, Guus Sliepen and others.\n" + "See the AUTHORS file for a complete list.\n\n" + "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" + "and you are welcome to redistribute it under certain conditions;\n" + "see the file COPYING for details.\n"); + + return 0; + } + + if(show_help) { + usage(false); + return 0; + } + + if(optind >= argc) { + fprintf(stderr, "Not enough arguments.\n"); + usage(true); + return 1; + } + + // First handle commands that don't involve connecting to a running tinc daemon. + + if(!strcasecmp(argv[optind], "generate-rsa-keys")) { + return !rsa_keygen(optind > argc ? atoi(argv[optind + 1]) : 2048); + } + + if(!strcasecmp(argv[optind], "generate-ecdsa-keys")) { + return !ecdsa_keygen(); + } + + if(!strcasecmp(argv[optind], "generate-keys")) { + return !(rsa_keygen(optind > argc ? atoi(argv[optind + 1]) : 2048) && ecdsa_keygen()); + } + + if(!strcasecmp(argv[optind], "start")) { + argv[optind] = NULL; + execve(SBINDIR "/tincd", argv, envp); + fprintf(stderr, "Could not start tincd: %s", strerror(errno)); + return 1; + } + + /* + * Now handle commands that do involve connecting to a running tinc daemon. + * Authenticate the server by ensuring the parent directory can be + * traversed only by root. Note this is not totally race-free unless all + * ancestors are writable only by trusted users, which we don't verify. + */ + + FILE *f = fopen(pidfilename, "r"); + if(!f) { + fprintf(stderr, "Could not open pid file %s: %s\n", pidfilename, strerror(errno)); + return 1; + } + if(fscanf(f, "%20d %1024s %128s port %128s", &pid, controlcookie, host, port) != 4) { + fprintf(stderr, "Could not parse pid file %s\n", pidfilename); + return 1; + } + +#ifdef HAVE_MINGW + if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) { + fprintf(stderr, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError())); + return 1; + } +#endif + + struct addrinfo hints = { + .ai_family = AF_UNSPEC, + .ai_socktype = SOCK_STREAM, + .ai_protocol = IPPROTO_TCP, + .ai_flags = 0, + }; + + struct addrinfo *res = NULL; + + if(getaddrinfo(host, port, &hints, &res) || !res) { + fprintf(stderr, "Cannot resolve %s port %s: %s", host, port, strerror(errno)); + return 1; + } + + fd = socket(res->ai_family, SOCK_STREAM, IPPROTO_TCP); + if(fd < 0) { + fprintf(stderr, "Cannot create TCP socket: %s\n", sockstrerror(sockerrno)); + return 1; + } + +#ifdef HAVE_MINGW + unsigned long arg = 0; + + if(ioctlsocket(fd, FIONBIO, &arg) != 0) { + fprintf(stderr, "ioctlsocket failed: %s", sockstrerror(sockerrno)); + } +#endif + + if(connect(fd, res->ai_addr, res->ai_addrlen) < 0) { + fprintf(stderr, "Cannot connect to %s port %s: %s\n", host, port, sockstrerror(sockerrno)); + return 1; + } + + freeaddrinfo(res); + + char line[4096]; + char data[4096]; + int code, version, req; + + if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %s %d", &code, data, &version) != 3 || code != 0) { + fprintf(stderr, "Cannot read greeting from control socket: %s\n", + sockstrerror(sockerrno)); + return 1; + } + + sendline(fd, "%d ^%s %d", ID, controlcookie, TINC_CTL_VERSION_CURRENT); + + if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &version, &pid) != 3 || code != 4 || version != TINC_CTL_VERSION_CURRENT) { + fprintf(stderr, "Could not fully establish control socket connection\n"); + return 1; + } + + if(!strcasecmp(argv[optind], "pid")) { + printf("%d\n", pid); + return 0; + } + + if(!strcasecmp(argv[optind], "stop")) { +#ifndef HAVE_MINGW + sendline(fd, "%d %d", CONTROL, REQ_STOP); + if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_STOP || result) { + fprintf(stderr, "Could not stop tinc daemon\n"); + return 1; + } +#else + if(!remove_service()) + return 1; +#endif + return 0; + } + + if(!strcasecmp(argv[optind], "reload")) { + sendline(fd, "%d %d", CONTROL, REQ_RELOAD); + if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_RELOAD || result) { + fprintf(stderr, "Could not reload tinc daemon\n"); + return 1; + } + return 0; + } + + if(!strcasecmp(argv[optind], "restart")) { + sendline(fd, "%d %d", CONTROL, REQ_RESTART); + if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_RESTART || result) { + fprintf(stderr, "Could not restart tinc daemon\n"); + return 1; + } + return 0; + } + + if(!strcasecmp(argv[optind], "retry")) { + sendline(fd, "%d %d", CONTROL, REQ_RETRY); + if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_RETRY || result) { + fprintf(stderr, "Could not retry outgoing connections\n"); + return 1; + } + return 0; + } + + if(!strcasecmp(argv[optind], "dump")) { + if(argc < optind + 2) { + fprintf(stderr, "Not enough arguments.\n"); + usage(true); + return 1; + } + + bool do_graph = false; + + if(!strcasecmp(argv[optind+1], "nodes")) + sendline(fd, "%d %d", CONTROL, REQ_DUMP_NODES); + else if(!strcasecmp(argv[optind+1], "edges")) + sendline(fd, "%d %d", CONTROL, REQ_DUMP_EDGES); + else if(!strcasecmp(argv[optind+1], "subnets")) + sendline(fd, "%d %d", CONTROL, REQ_DUMP_SUBNETS); + else if(!strcasecmp(argv[optind+1], "connections")) + sendline(fd, "%d %d", CONTROL, REQ_DUMP_CONNECTIONS); + else if(!strcasecmp(argv[optind+1], "graph")) { + sendline(fd, "%d %d", CONTROL, REQ_DUMP_NODES); + sendline(fd, "%d %d", CONTROL, REQ_DUMP_EDGES); + do_graph = true; + printf("digraph {\n"); + } else { + fprintf(stderr, "Unknown dump type '%s'.\n", argv[optind+1]); + usage(true); + return 1; + } + + while(recvline(fd, line, sizeof line)) { + char node1[4096], node2[4096]; + int n = sscanf(line, "%d %d %s to %s", &code, &req, node1, node2); + if(n == 2) { + if(do_graph && req == REQ_DUMP_NODES) + continue; + else { + if(do_graph) + printf("}\n"); + return 0; + } + } + if(n < 2) + break; + + if(!do_graph) + printf("%s\n", line + 5); + else { + if(req == REQ_DUMP_NODES) + printf(" %s [label = \"%s\"];\n", node1, node1); + else + printf(" %s -> %s;\n", node1, node2); + } + } + + fprintf(stderr, "Error receiving dump\n"); + return 1; + } + + if(!strcasecmp(argv[optind], "purge")) { + sendline(fd, "%d %d", CONTROL, REQ_PURGE); + if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_PURGE || result) { + fprintf(stderr, "Could not purge tinc daemon\n"); + return 1; + } + return 0; + } + + if(!strcasecmp(argv[optind], "debug")) { + int debuglevel, origlevel; + + if(argc != optind + 2) { + fprintf(stderr, "Invalid arguments.\n"); + return 1; + } + debuglevel = atoi(argv[optind+1]); + + sendline(fd, "%d %d %d", CONTROL, REQ_SET_DEBUG, debuglevel); + if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &origlevel) != 3 || code != CONTROL || req != REQ_SET_DEBUG) { + fprintf(stderr, "Could not purge tinc daemon\n"); + return 1; + } + + fprintf(stderr, "Old level %d, new level %d\n", origlevel, debuglevel); + return 0; + } + + if(!strcasecmp(argv[optind], "connect")) { + if(argc != optind + 2) { + fprintf(stderr, "Invalid arguments.\n"); + return 1; + } + char *name = argv[optind + 1]; + + sendline(fd, "%d %d %s", CONTROL, REQ_CONNECT, name); + if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_CONNECT || result) { + fprintf(stderr, "Could not connect to %s\n", name); + return 1; + } + return 0; + } + + if(!strcasecmp(argv[optind], "disconnect")) { + if(argc != optind + 2) { + fprintf(stderr, "Invalid arguments.\n"); + return 1; + } + char *name = argv[optind + 1]; + + sendline(fd, "%d %d %s", CONTROL, REQ_DISCONNECT, name); + if(!recvline(fd, line, sizeof line) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_DISCONNECT || result) { + fprintf(stderr, "Could not disconnect %s\n", name); + return 1; + } + return 0; + } + +#ifdef HAVE_CURSES + if(!strcasecmp(argv[optind], "top")) { + top(fd); + return 0; + } +#endif + + if(!strcasecmp(argv[optind], "pcap")) { + pcap(fd, stdout); + return 0; + } + + fprintf(stderr, "Unknown command `%s'.\n", argv[optind]); + usage(true); + + close(fd); + + return 0; +} diff --git a/src/tincctl.h b/src/tincctl.h new file mode 100644 index 0000000..114b931 --- /dev/null +++ b/src/tincctl.h @@ -0,0 +1,27 @@ +/* + tincctl.h -- header for tincctl.c. + Copyright (C) 2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_TINCCTL_H__ +#define __TINC_TINCCTL_H__ + +extern bool sendline(int fd, char *format, ...); +extern bool recvline(int fd, char *line, size_t len); + +#endif + diff --git a/src/tincd.c b/src/tincd.c index b4704c4..8401b20 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -1,7 +1,7 @@ /* tincd.c -- the main file for tincd Copyright (C) 1998-2005 Ivo Timmermans - 2000-2018 Guus Sliepen + 2000-2011 Guus Sliepen 2008 Max Rijevski 2009 Michael Tokarev 2010 Julien Muchembled @@ -49,15 +49,11 @@ #include #endif -#ifdef HAVE_GETOPT_LONG #include -#else -#include "getopt.h" -#endif - -#include "pidfile.h" #include "conf.h" +#include "control.h" +#include "crypto.h" #include "device.h" #include "logger.h" #include "net.h" @@ -71,22 +67,16 @@ char *program_name = NULL; /* If nonzero, display usage information and exit. */ -bool show_help = false; +static bool show_help = false; /* If nonzero, print the version on standard output and exit. */ -bool show_version = false; - -/* If nonzero, it will attempt to kill a running tincd and exit. */ -int kill_tincd = 0; - -/* If nonzero, generate public/private keypair for this host/net. */ -int generate_keys = 0; +static bool show_version = false; /* If nonzero, use null ciphers and skip all key exchanges. */ bool bypass_security = false; /* If nonzero, disable swapping for this process. */ -bool do_mlock = false; +static bool do_mlock = false; /* If nonzero, chroot to netdir after startup. */ static bool do_chroot = false; @@ -97,21 +87,19 @@ static const char *switchuser = NULL; /* If nonzero, write log entries to a separate file. */ bool use_logfile = false; -char *identname = NULL; /* program name for syslog */ -char *pidfilename = NULL; /* pid file location */ -char *logfilename = NULL; /* log file location */ -char **g_argv; /* a copy of the cmdline arguments */ +char *identname = NULL; /* program name for syslog */ +char *logfilename = NULL; /* log file location */ +char *pidfilename = NULL; +char **g_argv; /* a copy of the cmdline arguments */ static int status = 1; static struct option const long_options[] = { {"config", required_argument, NULL, 'c'}, - {"kill", optional_argument, NULL, 'k'}, {"net", required_argument, NULL, 'n'}, {"help", no_argument, NULL, 1}, {"version", no_argument, NULL, 2}, {"no-detach", no_argument, NULL, 'D'}, - {"generate-keys", optional_argument, NULL, 'K'}, {"debug", optional_argument, NULL, 'd'}, {"bypass-security", no_argument, NULL, 3}, {"mlock", no_argument, NULL, 'L'}, @@ -119,7 +107,6 @@ static struct option const long_options[] = { {"user", required_argument, NULL, 'U'}, {"logfile", optional_argument, NULL, 4}, {"pidfile", required_argument, NULL, 5}, - {"option", required_argument, NULL, 'o'}, {NULL, 0, NULL, 0} }; @@ -132,23 +119,21 @@ int main2(int argc, char **argv); static void usage(bool status) { if(status) fprintf(stderr, "Try `%s --help\' for more information.\n", - program_name); + program_name); else { printf("Usage: %s [option]...\n\n", program_name); - printf(" -c, --config=DIR Read configuration options from DIR.\n" - " -D, --no-detach Don't fork and detach.\n" - " -d, --debug[=LEVEL] Increase debug level or set it to LEVEL.\n" - " -k, --kill[=SIGNAL] Attempt to kill a running tincd and exit.\n" - " -n, --net=NETNAME Connect to net NETNAME.\n" - " -K, --generate-keys[=BITS] Generate public/private RSA keypair.\n" - " -L, --mlock Lock tinc into main memory.\n" - " --logfile[=FILENAME] Write log entries to a logfile.\n" - " --pidfile=FILENAME Write PID to FILENAME.\n" - " -o, --option=[HOST.]KEY=VALUE Set global/host configuration value.\n" - " -R, --chroot chroot to NET dir at startup.\n" - " -U, --user=USER setuid to given USER at startup.\n" - " --help Display this help and exit.\n" - " --version Output version information and exit.\n\n"); + printf( " -c, --config=DIR Read configuration options from DIR.\n" + " -D, --no-detach Don't fork and detach.\n" + " -d, --debug[=LEVEL] Increase debug level or set it to LEVEL.\n" + " -n, --net=NETNAME Connect to net NETNAME.\n" + " -L, --mlock Lock tinc into main memory.\n" + " --logfile[=FILENAME] Write log entries to a logfile.\n" + " --pidfile=FILENAME Write PID and control socket cookie to FILENAME.\n" + " --bypass-security Disables meta protocol security, for debugging.\n" + " -o [HOST.]KEY=VALUE Set global/host configuration value.\n" + " -R, --chroot chroot to NET dir at startup.\n" + " -U, --user=USER setuid to given USER at startup.\n" " --help Display this help and exit.\n" + " --version Output version information and exit.\n\n"); printf("Report bugs to tinc@tinc-vpn.org.\n"); } } @@ -161,340 +146,87 @@ static bool parse_options(int argc, char **argv) { cmdline_conf = list_alloc((list_action_t)free_config); - while((r = getopt_long(argc, argv, "c:DLd::k::n:o:K::RU:", long_options, &option_index)) != EOF) { - switch(r) { - case 0: /* long option */ - break; + while((r = getopt_long(argc, argv, "c:DLd::n:o:RU:", long_options, &option_index)) != EOF) { + switch (r) { + case 0: /* long option */ + break; - case 'c': /* config file */ - if(confbase) { - fprintf(stderr, "Only one configuration directory can be given.\n"); - usage(true); - return false; - } + case 'c': /* config file */ + confbase = xstrdup(optarg); + break; - confbase = xstrdup(optarg); - break; + case 'D': /* no detach */ + do_detach = false; + break; - case 'D': /* no detach */ - do_detach = false; - break; - - case 'L': /* no detach */ + case 'L': /* no detach */ #ifndef HAVE_MLOCKALL - logger(LOG_ERR, "%s not supported on this platform", "mlockall()"); - return false; + logger(LOG_ERR, "%s not supported on this platform", "mlockall()"); + return false; #else - do_mlock = true; - break; + do_mlock = true; + break; #endif - case 'd': /* increase debug level */ - if(!optarg && optind < argc && *argv[optind] != '-') { - optarg = argv[optind++]; - } + case 'd': /* inc debug level */ + if(optarg) + debug_level = atoi(optarg); + else + debug_level++; + break; - if(optarg) { - debug_level = atoi(optarg); - } else { - debug_level++; - } + case 'n': /* net name given */ + /* netname "." is special: a "top-level name" */ + netname = strcmp(optarg, ".") != 0 ? + xstrdup(optarg) : NULL; + break; - break; + case 'o': /* option */ + cfg = parse_config_line(optarg, NULL, ++lineno); + if (!cfg) + return false; + list_insert_tail(cmdline_conf, cfg); + break; - case 'k': /* kill old tincds */ -#ifndef HAVE_MINGW - if(!optarg && optind < argc && *argv[optind] != '-') { - optarg = argv[optind++]; - } + case 'R': /* chroot to NETNAME dir */ + do_chroot = true; + break; - if(optarg) { - if(!strcasecmp(optarg, "HUP")) { - kill_tincd = SIGHUP; - } else if(!strcasecmp(optarg, "TERM")) { - kill_tincd = SIGTERM; - } else if(!strcasecmp(optarg, "KILL")) { - kill_tincd = SIGKILL; - } else if(!strcasecmp(optarg, "USR1")) { - kill_tincd = SIGUSR1; - } else if(!strcasecmp(optarg, "USR2")) { - kill_tincd = SIGUSR2; - } else if(!strcasecmp(optarg, "WINCH")) { - kill_tincd = SIGWINCH; - } else if(!strcasecmp(optarg, "INT")) { - kill_tincd = SIGINT; - } else if(!strcasecmp(optarg, "ALRM")) { - kill_tincd = SIGALRM; - } else if(!strcasecmp(optarg, "ABRT")) { - kill_tincd = SIGABRT; - } else { - kill_tincd = atoi(optarg); + case 'U': /* setuid to USER */ + switchuser = optarg; + break; - if(!kill_tincd) { - fprintf(stderr, "Invalid argument `%s'; SIGNAL must be a number or one of HUP, TERM, KILL, USR1, USR2, WINCH, INT or ALRM.\n", - optarg); - usage(true); - return false; - } - } - } else { - kill_tincd = SIGTERM; - } + case 1: /* show help */ + show_help = true; + break; -#else - kill_tincd = 1; -#endif - break; + case 2: /* show version */ + show_version = true; + break; - case 'n': /* net name given */ + case 3: /* bypass security */ + bypass_security = true; + break; - /* netname "." is special: a "top-level name" */ - if(netname) { - fprintf(stderr, "Only one netname can be given.\n"); + case 4: /* write log entries to a file */ + use_logfile = true; + if(optarg) + logfilename = xstrdup(optarg); + break; + + case 5: /* open control socket here */ + pidfilename = xstrdup(optarg); + break; + + case '?': usage(true); return false; - } - if(optarg && strcmp(optarg, ".")) { - netname = xstrdup(optarg); - } - - break; - - case 'o': /* option */ - cfg = parse_config_line(optarg, NULL, ++lineno); - - if(!cfg) { - return false; - } - - list_insert_tail(cmdline_conf, cfg); - break; - - case 'K': /* generate public/private keypair */ - if(!optarg && optind < argc && *argv[optind] != '-') { - optarg = argv[optind++]; - } - - if(optarg) { - generate_keys = atoi(optarg); - - if(generate_keys < 512) { - fprintf(stderr, "Invalid argument `%s'; BITS must be a number equal to or greater than 512.\n", - optarg); - usage(true); - return false; - } - - generate_keys &= ~7; /* Round it to bytes */ - } else { - generate_keys = 2048; - } - - break; - - case 'R': /* chroot to NETNAME dir */ - do_chroot = true; - break; - - case 'U': /* setuid to USER */ - switchuser = optarg; - break; - - case 1: /* show help */ - show_help = true; - break; - - case 2: /* show version */ - show_version = true; - break; - - case 3: /* bypass security */ - bypass_security = true; - break; - - case 4: /* write log entries to a file */ - use_logfile = true; - - if(!optarg && optind < argc && *argv[optind] != '-') { - optarg = argv[optind++]; - } - - if(optarg) { - if(logfilename) { - fprintf(stderr, "Only one logfile can be given.\n"); - usage(true); - return false; - } - - logfilename = xstrdup(optarg); - } - - break; - - case 5: /* write PID to a file */ - if(pidfilename) { - fprintf(stderr, "Only one pidfile can be given.\n"); - usage(true); - return false; - } - - pidfilename = xstrdup(optarg); - break; - - case '?': - usage(true); - return false; - - default: - break; + default: + break; } } - if(optind < argc) { - fprintf(stderr, "%s: unrecognized argument '%s'\n", argv[0], argv[optind]); - usage(true); - return false; - } - - return true; -} - -/* This function prettyprints the key generation process */ - -static int indicator(int a, int b, BN_GENCB *cb) { - (void)cb; - - switch(a) { - case 0: - fprintf(stderr, "."); - break; - - case 1: - fprintf(stderr, "+"); - break; - - case 2: - fprintf(stderr, "-"); - break; - - case 3: - switch(b) { - case 0: - fprintf(stderr, " p\n"); - break; - - case 1: - fprintf(stderr, " q\n"); - break; - - default: - fprintf(stderr, "?"); - } - - break; - - default: - fprintf(stderr, "?"); - } - - return 1; -} - -#ifndef HAVE_BN_GENCB_NEW -BN_GENCB *BN_GENCB_new(void) { - return xmalloc_and_zero(sizeof(BN_GENCB)); -} - -void BN_GENCB_free(BN_GENCB *cb) { - free(cb); -} -#endif - -/* - Generate a public/private RSA keypair, and ask for a file to store - them in. -*/ -static bool keygen(int bits) { - BIGNUM *e = NULL; - RSA *rsa_key; - FILE *f; - char filename[PATH_MAX]; - BN_GENCB *cb; - int result; - - fprintf(stderr, "Generating %d bits keys:\n", bits); - - cb = BN_GENCB_new(); - - if(!cb) { - abort(); - } - - BN_GENCB_set(cb, indicator, NULL); - - rsa_key = RSA_new(); - - if(BN_hex2bn(&e, "10001") == 0) { - abort(); - } - - if(!rsa_key || !e) { - abort(); - } - - result = RSA_generate_key_ex(rsa_key, bits, e, cb); - - BN_free(e); - BN_GENCB_free(cb); - - if(!result) { - fprintf(stderr, "Error during key generation!\n"); - RSA_free(rsa_key); - return false; - } else { - fprintf(stderr, "Done.\n"); - } - - snprintf(filename, sizeof(filename), "%s/rsa_key.priv", confbase); - f = ask_and_open(filename, "private RSA key"); - - if(!f) { - RSA_free(rsa_key); - return false; - } - -#ifdef HAVE_FCHMOD - /* Make it unreadable for others. */ - fchmod(fileno(f), 0600); -#endif - - fputc('\n', f); - PEM_write_RSAPrivateKey(f, rsa_key, NULL, NULL, 0, NULL, NULL); - fclose(f); - - char *name = get_name(); - - if(name) { - snprintf(filename, sizeof(filename), "%s/hosts/%s", confbase, name); - free(name); - } else { - snprintf(filename, sizeof(filename), "%s/rsa_key.pub", confbase); - } - - f = ask_and_open(filename, "public RSA key"); - - if(!f) { - RSA_free(rsa_key); - return false; - } - - fputc('\n', f); - PEM_write_RSAPublicKey(f, rsa_key); - fclose(f); - - RSA_free(rsa_key); - return true; } @@ -505,130 +237,103 @@ static void make_names(void) { #ifdef HAVE_MINGW HKEY key; char installdir[1024] = ""; - DWORD len = sizeof(installdir); + long len = sizeof installdir; #endif - if(netname) { + if(netname) xasprintf(&identname, "tinc.%s", netname); - } else { + else identname = xstrdup("tinc"); - } #ifdef HAVE_MINGW - if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) { - if(!RegQueryValueEx(key, NULL, 0, 0, (LPBYTE)installdir, &len)) { + if(!RegQueryValueEx(key, NULL, 0, 0, installdir, &len)) { + if(!logfilename) + xasprintf(&logfilename, "%s/log/%s.log", identname); if(!confbase) { - if(netname) { + if(netname) xasprintf(&confbase, "%s/%s", installdir, netname); - } else { + else xasprintf(&confbase, "%s", installdir); - } - } - - if(!logfilename) { - xasprintf(&logfilename, "%s/tinc.log", confbase); } + if(!pidfilename) + xasprintf(&pidfilename, "%s/pid", confbase); } - RegCloseKey(key); - - if(*installdir) { + if(*installdir) return; - } } - #endif - if(!pidfilename) { - xasprintf(&pidfilename, RUNSTATEDIR "/%s.pid", identname); - } - - if(!logfilename) { + if(!logfilename) xasprintf(&logfilename, LOCALSTATEDIR "/log/%s.log", identname); - } + + if(!pidfilename) + xasprintf(&pidfilename, LOCALSTATEDIR "/run/%s.pid", identname); if(netname) { - if(!confbase) { + if(!confbase) xasprintf(&confbase, CONFDIR "/tinc/%s", netname); - } else { + else logger(LOG_INFO, "Both netname and configuration directory given, using the latter..."); - } } else { - if(!confbase) { + if(!confbase) xasprintf(&confbase, CONFDIR "/tinc"); - } } } -static void free_names() { - free(identname); - free(netname); - free(pidfilename); - free(logfilename); - free(confbase); +static void free_names(void) { + if (identname) free(identname); + if (netname) free(netname); + if (pidfilename) free(pidfilename); + if (logfilename) free(logfilename); + if (confbase) free(confbase); } -static bool drop_privs() { +static bool drop_privs(void) { #ifdef HAVE_MINGW - - if(switchuser) { + if (switchuser) { logger(LOG_ERR, "%s not supported on this platform", "-U"); return false; } - - if(do_chroot) { + if (do_chroot) { logger(LOG_ERR, "%s not supported on this platform", "-R"); return false; } - #else uid_t uid = 0; - - if(switchuser) { + if (switchuser) { struct passwd *pw = getpwnam(switchuser); - - if(!pw) { + if (!pw) { logger(LOG_ERR, "unknown user `%s'", switchuser); return false; } - uid = pw->pw_uid; - - if(initgroups(switchuser, pw->pw_gid) != 0 || - setgid(pw->pw_gid) != 0) { + if (initgroups(switchuser, pw->pw_gid) != 0 || + setgid(pw->pw_gid) != 0) { logger(LOG_ERR, "System call `%s' failed: %s", "initgroups", strerror(errno)); return false; } - -#ifndef ANDROID -// Not supported in android NDK endgrent(); endpwent(); -#endif } - - if(do_chroot) { - tzset(); /* for proper timestamps in logs */ - - if(chroot(confbase) != 0 || chdir("/") != 0) { + if (do_chroot) { + tzset(); /* for proper timestamps in logs */ + if (chroot(confbase) != 0 || chdir("/") != 0) { logger(LOG_ERR, "System call `%s' failed: %s", "chroot", strerror(errno)); return false; } - free(confbase); confbase = xstrdup(""); } - - if(switchuser) - if(setuid(uid) != 0) { + if (switchuser) + if (setuid(uid) != 0) { logger(LOG_ERR, "System call `%s' failed: %s", "setuid", strerror(errno)); return false; } - #endif return true; } @@ -645,17 +350,19 @@ static bool drop_privs() { int main(int argc, char **argv) { program_name = argv[0]; - if(!parse_options(argc, argv)) { + if(!parse_options(argc, argv)) return 1; - } + + make_names(); if(show_version) { - printf("%s version %s\n", PACKAGE, VERSION); - printf("Copyright (C) 1998-2018 Ivo Timmermans, Guus Sliepen and others.\n" - "See the AUTHORS file for a complete list.\n\n" - "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" - "and you are welcome to redistribute it under certain conditions;\n" - "see the file COPYING for details.\n"); + printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE, + VERSION, __DATE__, __TIME__, PROT_MAJOR, PROT_MINOR); + printf("Copyright (C) 1998-2011 Ivo Timmermans, Guus Sliepen and others.\n" + "See the AUTHORS file for a complete list.\n\n" + "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" + "and you are welcome to redistribute it under certain conditions;\n" + "see the file COPYING for details.\n"); return 0; } @@ -665,98 +372,72 @@ int main(int argc, char **argv) { return 0; } - make_names(); - - if(kill_tincd) { - return !kill_other(kill_tincd); +#ifdef HAVE_MINGW + if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) { + logger(LOG_ERR, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError())); + return 1; } +#endif - openlogger("tinc", use_logfile ? LOGMODE_FILE : LOGMODE_STDERR); + openlogger("tinc", use_logfile?LOGMODE_FILE:LOGMODE_STDERR); + + if(!event_init()) { + logger(LOG_ERR, "Error initializing libevent!"); + return 1; + } g_argv = argv; - if(getenv("LISTEN_PID") && atoi(getenv("LISTEN_PID")) == getpid()) { - do_detach = false; - } - -#ifdef HAVE_UNSETENV - unsetenv("LISTEN_PID"); -#endif - init_configuration(&config_tree); /* Slllluuuuuuurrrrp! */ - if(RAND_load_file("/dev/urandom", 1024) != 1024) { - logger(LOG_ERR, "Error initializing RNG!"); + srand(time(NULL)); + crypto_init(); + + if(!read_server_config()) return 1; - } - - ENGINE_load_builtin_engines(); - ENGINE_register_all_complete(); - - OpenSSL_add_all_algorithms(); - - if(generate_keys) { - read_server_config(); - return !keygen(generate_keys); - } - - if(!read_server_config()) { - return 1; - } #ifdef HAVE_LZO - if(lzo_init() != LZO_E_OK) { logger(LOG_ERR, "Error initializing LZO compressor!"); return 1; } - #endif #ifdef HAVE_MINGW - - if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) { - logger(LOG_ERR, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError())); - return 1; - } - - if(!do_detach || !init_service()) { + if(!do_detach || !init_service()) return main2(argc, argv); - } else { + else return 1; - } } int main2(int argc, char **argv) { InitializeCriticalSection(&mutex); EnterCriticalSection(&mutex); #endif - char *priority = NULL; - if(!detach()) { + if(!detach()) return 1; - } #ifdef HAVE_MLOCKALL - /* Lock all pages into memory if requested. * This has to be done after daemon()/fork() so it works for child. * No need to do that in parent as it's very short-lived. */ if(do_mlock && mlockall(MCL_CURRENT | MCL_FUTURE) != 0) { logger(LOG_ERR, "System call `%s' failed: %s", "mlockall", - strerror(errno)); + strerror(errno)); return 1; } - #endif /* Setup sockets and open device. */ - if(!setup_network()) { - goto end; - } + if(!setup_network()) + goto end_nonet; + + if(!init_control()) + goto end_nonet; /* Initiate all outgoing connections. */ @@ -764,35 +445,36 @@ int main2(int argc, char **argv) { /* Change process priority */ - if(get_config_string(lookup_config(config_tree, "ProcessPriority"), &priority)) { - if(!strcasecmp(priority, "Normal")) { - if(setpriority(NORMAL_PRIORITY_CLASS) != 0) { - logger(LOG_ERR, "System call `%s' failed: %s", - "setpriority", strerror(errno)); - goto end; - } - } else if(!strcasecmp(priority, "Low")) { - if(setpriority(BELOW_NORMAL_PRIORITY_CLASS) != 0) { - logger(LOG_ERR, "System call `%s' failed: %s", - "setpriority", strerror(errno)); - goto end; - } - } else if(!strcasecmp(priority, "High")) { - if(setpriority(HIGH_PRIORITY_CLASS) != 0) { - logger(LOG_ERR, "System call `%s' failed: %s", - "setpriority", strerror(errno)); - goto end; - } - } else { - logger(LOG_ERR, "Invalid priority `%s`!", priority); - goto end; - } - } + char *priority = NULL; + + if(get_config_string(lookup_config(config_tree, "ProcessPriority"), &priority)) { + if(!strcasecmp(priority, "Normal")) { + if (setpriority(NORMAL_PRIORITY_CLASS) != 0) { + logger(LOG_ERR, "System call `%s' failed: %s", + "setpriority", strerror(errno)); + goto end; + } + } else if(!strcasecmp(priority, "Low")) { + if (setpriority(BELOW_NORMAL_PRIORITY_CLASS) != 0) { + logger(LOG_ERR, "System call `%s' failed: %s", + "setpriority", strerror(errno)); + goto end; + } + } else if(!strcasecmp(priority, "High")) { + if (setpriority(HIGH_PRIORITY_CLASS) != 0) { + logger(LOG_ERR, "System call `%s' failed: %s", + "setpriority", strerror(errno)); + goto end; + } + } else { + logger(LOG_ERR, "Invalid priority `%s`!", priority); + goto end; + } + } /* drop privileges */ - if(!drop_privs()) { + if (!drop_privs()) goto end; - } /* Start main loop. It only exits when tinc is killed. */ @@ -801,25 +483,19 @@ int main2(int argc, char **argv) { /* Shutdown properly. */ ifdebug(CONNECTIONS) - devops.dump_stats(); + dump_device_stats(); close_network_connections(); end: + exit_control(); + +end_nonet: logger(LOG_NOTICE, "Terminating"); -#ifndef HAVE_MINGW - remove_pid(pidfilename); -#endif - - free(priority); - - EVP_cleanup(); - ERR_free_strings(); - ENGINE_cleanup(); + crypto_exit(); exit_configuration(&config_tree); - list_delete_list(cmdline_conf); free_names(); return status; diff --git a/src/top.c b/src/top.c new file mode 100644 index 0000000..f14395e --- /dev/null +++ b/src/top.c @@ -0,0 +1,319 @@ +/* + top.c -- Show real-time statistics from a running tincd + Copyright (C) 2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#ifdef HAVE_CURSES + +#include + +#include "control_common.h" +#include "list.h" +#include "tincctl.h" +#include "top.h" +#include "xalloc.h" + +typedef struct nodestats_t { + char *name; + int i; + uint64_t in_packets; + uint64_t in_bytes; + uint64_t out_packets; + uint64_t out_bytes; + float in_packets_rate; + float in_bytes_rate; + float out_packets_rate; + float out_bytes_rate; + bool known; +} nodestats_t; + +static const char *const sortname[] = { + "name", + "in pkts", + "in bytes", + "out pkts", + "out bytes", + "tot pkts", + "tot bytes", +}; + +static int sortmode = 0; +static bool cumulative = false; + +static list_t node_list; +static struct timeval now, prev, diff; +static int delay = 1000; +static bool running = true; +static bool changed = true; +static const char *unit = "bytes"; +static float scale = 1; + +#ifndef timersub +#define timersub(a, b, c) do {(c)->tv_sec = (a)->tv_sec - (b)->tv_sec; (c)->tv_usec = (a)->tv_usec = (b)->tv_usec;} while(0) +#endif + +static void update(int fd) { + sendline(fd, "%d %d", CONTROL, REQ_DUMP_TRAFFIC); + gettimeofday(&now, NULL); + + timersub(&now, &prev, &diff); + prev = now; + float interval = diff.tv_sec + diff.tv_usec * 1e-6; + + char line[4096]; + char name[4096]; + int code; + int req; + uint64_t in_packets; + uint64_t in_bytes; + uint64_t out_packets; + uint64_t out_bytes; + + for(list_node_t *i = node_list.head; i; i = i->next) { + nodestats_t *node = i->data; + node->known = false; + } + + while(recvline(fd, line, sizeof line)) { + int n = sscanf(line, "%d %d %s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, &code, &req, name, &in_packets, &in_bytes, &out_packets, &out_bytes); + + if(n == 2) + break; + + if(n != 7) { + endwin(); + fprintf(stderr, "Error receiving traffic information\n"); + exit(1); + } + + nodestats_t *found = NULL; + + for(list_node_t *i = node_list.head; i; i = i->next) { + nodestats_t *node = i->data; + int result = strcmp(name, node->name); + if(result > 0) { + continue; + } if(result == 0) { + found = node; + break; + } else { + found = xmalloc_and_zero(sizeof *found); + found->name = xstrdup(name); + list_insert_before(&node_list, i, found); + changed = true; + break; + } + } + + if(!found) { + found = xmalloc_and_zero(sizeof *found); + found->name = xstrdup(name); + list_insert_tail(&node_list, found); + changed = true; + } + + found->known = true; + found->in_packets_rate = (in_packets - found->in_packets) / interval; + found->in_bytes_rate = (in_bytes - found->in_bytes) / interval; + found->out_packets_rate = (out_packets - found->out_packets) / interval; + found->out_bytes_rate = (out_bytes - found->out_bytes) / interval; + found->in_packets = in_packets; + found->in_bytes = in_bytes; + found->out_packets = out_packets; + found->out_bytes = out_bytes; + } +} + +static void redraw(void) { + erase(); + + mvprintw(0, 0, "Tinc %-16s Nodes: %4d Sort: %-10s %s", netname ?: "", node_list.count, sortname[sortmode], cumulative ? "Cumulative" : "Current"); + attrset(A_REVERSE); + mvprintw(2, 0, "Node IN pkts IN %s OUT pkts OUT %s", unit, unit); + chgat(-1, A_REVERSE, 0, NULL); + + static nodestats_t **sorted = 0; + static int n = 0; + if(changed) { + n = 0; + sorted = xrealloc(sorted, node_list.count * sizeof *sorted); + for(list_node_t *i = node_list.head; i; i = i->next) + sorted[n++] = i->data; + changed = false; + } + + for(int i = 0; i < n; i++) + sorted[i]->i = i; + + int cmpfloat(float a, float b) { + if(a < b) + return -1; + else if(a > b) + return 1; + else + return 0; + } + + int cmpu64(uint64_t a, uint64_t b) { + if(a < b) + return -1; + else if(a > b) + return 1; + else + return 0; + } + + int sortfunc(const void *a, const void *b) { + const nodestats_t *na = *(const nodestats_t **)a; + const nodestats_t *nb = *(const nodestats_t **)b; + switch(sortmode) { + case 1: + if(cumulative) + return -cmpu64(na->in_packets, nb->in_packets) ?: na->i - nb->i; + else + return -cmpfloat(na->in_packets_rate, nb->in_packets_rate) ?: na->i - nb->i; + case 2: + if(cumulative) + return -cmpu64(na->in_bytes, nb->in_bytes) ?: na->i - nb->i; + else + return -cmpfloat(na->in_bytes_rate, nb->in_bytes_rate) ?: na->i - nb->i; + case 3: + if(cumulative) + return -cmpu64(na->out_packets, nb->out_packets) ?: na->i - nb->i; + else + return -cmpfloat(na->out_packets_rate, nb->out_packets_rate) ?: na->i - nb->i; + case 4: + if(cumulative) + return -cmpu64(na->out_bytes, nb->out_bytes) ?: na->i - nb->i; + else + return -cmpfloat(na->out_bytes_rate, nb->out_bytes_rate) ?: na->i - nb->i; + case 5: + if(cumulative) + return -cmpu64(na->in_packets + na->out_packets, nb->in_packets + nb->out_packets) ?: na->i - nb->i; + else + return -cmpfloat(na->in_packets_rate + na->out_packets_rate, nb->in_packets_rate + nb->out_packets_rate) ?: na->i - nb->i; + case 6: + if(cumulative) + return -cmpu64(na->in_bytes + na->out_bytes, nb->in_bytes + nb->out_bytes) ?: na->i - nb->i; + else + return -cmpfloat(na->in_bytes_rate + na->out_bytes_rate, nb->in_bytes_rate + nb->out_bytes_rate) ?: na->i - nb->i; + default: + return strcmp(na->name, nb->name) ?: na->i - nb->i; + } + } + + qsort(sorted, n, sizeof *sorted, sortfunc); + + for(int i = 0, row = 3; i < n; i++, row++) { + nodestats_t *node = sorted[i]; + if(node->known) + if(node->in_packets_rate || node->out_packets_rate) + attrset(A_BOLD); + else + attrset(A_NORMAL); + else + attrset(A_DIM); + + if(cumulative) + mvprintw(row, 0, "%-16s %10"PRIu64" %10.0f %10"PRIu64" %10.0f", + node->name, node->in_packets, node->in_bytes * scale, node->out_packets, node->out_bytes * scale); + else + mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f", + node->name, node->in_packets_rate, node->in_bytes_rate * scale, node->out_packets_rate, node->out_bytes_rate * scale); + } + + attrset(A_NORMAL); + move(1, 0); + + refresh(); +} + +void top(int fd) { + initscr(); + timeout(delay); + + while(running) { + update(fd); + redraw(); + + switch(getch()) { + case 's': { + timeout(-1); + float input = delay * 1e-3; + mvprintw(1, 0, "Change delay from %.1fs to: ", input); + scanw("%f", &input); + if(input < 0.1) + input = 0.1; + delay = input * 1e3; + timeout(delay); + break; + } + case 'c': + cumulative = !cumulative; + break; + case 'n': + sortmode = 0; + break; + case 'i': + sortmode = 2; + break; + case 'I': + sortmode = 1; + break; + case 'o': + sortmode = 4; + break; + case 'O': + sortmode = 3; + break; + case 't': + sortmode = 6; + break; + case 'T': + sortmode = 5; + break; + case 'b': + unit = "bytes"; + scale = 1; + break; + case 'k': + unit = "kbyte"; + scale = 1e-3; + break; + case 'M': + unit = "Mbyte"; + scale = 1e-6; + break; + case 'G': + unit = "Gbyte"; + scale = 1e-9; + break; + case 'q': + case KEY_BREAK: + running = false; + break; + default: + break; + } + } + + endwin(); +} + +#endif diff --git a/src/top.h b/src/top.h new file mode 100644 index 0000000..b3a264d --- /dev/null +++ b/src/top.h @@ -0,0 +1,26 @@ +/* + top.h -- header for top.c. + Copyright (C) 2011 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TINC_TOP_H__ +#define __TINC_TOP_H__ + +extern void top(int fd); + +#endif + diff --git a/src/uml_device.c b/src/uml_socket/device.c similarity index 53% rename from src/uml_device.c rename to src/uml_socket/device.c index 66de431..d8f13a5 100644 --- a/src/uml_device.c +++ b/src/uml_socket/device.c @@ -1,7 +1,7 @@ /* device.c -- UML network socket Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2012 Guus Sliepen + 2002-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,17 +28,19 @@ #include "logger.h" #include "utils.h" #include "route.h" -#include "xalloc.h" +int device_fd = -1; static int listen_fd = -1; static int request_fd = -1; static int data_fd = -1; static int write_fd = -1; static int state = 0; -static const char *device_info = "UML network socket"; +char *device = NULL; +char *iface = NULL; +static char *device_info; extern char *identname; -extern volatile bool running; +extern bool running; static uint64_t device_total_in = 0; static uint64_t device_total_out = 0; @@ -46,15 +48,15 @@ static uint64_t device_total_out = 0; enum request_type { REQ_NEW_CONTROL }; static struct request { - uint32_t magic; - uint32_t version; - enum request_type type; - struct sockaddr_un sock; + uint32_t magic; + uint32_t version; + enum request_type type; + struct sockaddr_un sock; } request; static struct sockaddr_un data_sun; -static bool setup_device(void) { +bool setup_device(void) { struct sockaddr_un listen_sun; static const int one = 1; struct { @@ -64,23 +66,20 @@ static bool setup_device(void) { } name; struct timeval tv; - if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { - xasprintf(&device, RUNSTATEDIR "/%s.umlsocket", identname); - } + if(!get_config_string(lookup_config(config_tree, "Device"), &device)) + xasprintf(&device, LOCALSTATEDIR "/run/%s.umlsocket", identname); get_config_string(lookup_config(config_tree, "Interface"), &iface); + device_info = "UML network socket"; + if((write_fd = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) { logger(LOG_ERR, "Could not open write %s: %s", device_info, strerror(errno)); running = false; return false; } -#ifdef FD_CLOEXEC - fcntl(write_fd, F_SETFD, FD_CLOEXEC); -#endif - - setsockopt(write_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); + setsockopt(write_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one); if(fcntl(write_fd, F_SETFL, O_NONBLOCK) < 0) { logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); @@ -94,11 +93,7 @@ static bool setup_device(void) { return false; } -#ifdef FD_CLOEXEC - fcntl(data_fd, F_SETFD, FD_CLOEXEC); -#endif - - setsockopt(data_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); + setsockopt(data_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one); if(fcntl(data_fd, F_SETFL, O_NONBLOCK) < 0) { logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); @@ -111,9 +106,9 @@ static bool setup_device(void) { gettimeofday(&tv, NULL); name.usecs = tv.tv_usec; data_sun.sun_family = AF_UNIX; - memcpy(&data_sun.sun_path, &name, sizeof(name)); - - if(bind(data_fd, (struct sockaddr *)&data_sun, sizeof(data_sun)) < 0) { + memcpy(&data_sun.sun_path, &name, sizeof name); + + if(bind(data_fd, (struct sockaddr *)&data_sun, sizeof data_sun) < 0) { logger(LOG_ERR, "Could not bind data %s: %s", device_info, strerror(errno)); running = false; return false; @@ -121,15 +116,11 @@ static bool setup_device(void) { if((listen_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { logger(LOG_ERR, "Could not open %s: %s", device_info, - strerror(errno)); + strerror(errno)); return false; } -#ifdef FD_CLOEXEC - fcntl(device_fd, F_SETFD, FD_CLOEXEC); -#endif - - setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); + setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one); if(fcntl(listen_fd, F_SETFL, O_NONBLOCK) < 0) { logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); @@ -137,9 +128,8 @@ static bool setup_device(void) { } listen_sun.sun_family = AF_UNIX; - strncpy(listen_sun.sun_path, device, sizeof(listen_sun.sun_path)); - - if(bind(listen_fd, (struct sockaddr *)&listen_sun, sizeof(listen_sun)) < 0) { + strncpy(listen_sun.sun_path, device, sizeof listen_sun.sun_path); + if(bind(listen_fd, (struct sockaddr *)&listen_sun, sizeof listen_sun) < 0) { logger(LOG_ERR, "Could not bind %s to %s: %s", device_info, device, strerror(errno)); return false; } @@ -154,132 +144,118 @@ static bool setup_device(void) { logger(LOG_INFO, "%s is a %s", device, device_info); - if(routing_mode == RMODE_ROUTER) { + if(routing_mode == RMODE_ROUTER) overwrite_mac = true; - } return true; } void close_device(void) { - if(listen_fd >= 0) { + if(listen_fd >= 0) close(listen_fd); - } - if(request_fd >= 0) { + if(request_fd >= 0) close(request_fd); - } - if(data_fd >= 0) { + if(data_fd >= 0) close(data_fd); - } - if(write_fd >= 0) { + if(write_fd >= 0) close(write_fd); - } unlink(device); free(device); - free(iface); + if(iface) free(iface); } -static bool read_packet(vpn_packet_t *packet) { - int lenin; +bool read_packet(vpn_packet_t *packet) { + int inlen; switch(state) { - case 0: { - struct sockaddr sa; - socklen_t salen = sizeof(sa); + case 0: { + struct sockaddr sa; + int salen = sizeof sa; - request_fd = accept(listen_fd, &sa, &salen); + request_fd = accept(listen_fd, &sa, &salen); + if(request_fd < 0) { + logger(LOG_ERR, "Could not accept connection to %s %s: %s", device_info, device, strerror(errno)); + return false; + } + + if(fcntl(listen_fd, F_SETFL, O_NONBLOCK) < 0) { + logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); + running = false; + return false; + } + + close(listen_fd); + listen_fd = -1; + device_fd = request_fd; + state = 1; - if(request_fd < 0) { - logger(LOG_ERR, "Could not accept connection to %s %s: %s", device_info, device, strerror(errno)); return false; } -#ifdef FD_CLOEXEC - fcntl(request_fd, F_SETFD, FD_CLOEXEC); -#endif + case 1: { + if((inlen = read(request_fd, &request, sizeof request)) != sizeof request) { + logger(LOG_ERR, "Error while reading request from %s %s: %s", device_info, + device, strerror(errno)); + running = false; + return false; + } - if(fcntl(listen_fd, F_SETFL, O_NONBLOCK) < 0) { - logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); - running = false; + if(request.magic != 0xfeedface || request.version != 3 || request.type != REQ_NEW_CONTROL) { + logger(LOG_ERR, "Unknown magic %x, version %d, request type %d from %s %s", + request.magic, request.version, request.type, device_info, device); + running = false; + return false; + } + + if(connect(write_fd, &request.sock, sizeof request.sock) < 0) { + logger(LOG_ERR, "Could not bind write %s: %s", device_info, strerror(errno)); + running = false; + return false; + } + + write(request_fd, &data_sun, sizeof data_sun); + device_fd = data_fd; + + logger(LOG_INFO, "Connection with UML established"); + + state = 2; return false; } - close(listen_fd); - listen_fd = -1; - device_fd = request_fd; - state = 1; + case 2: { + if((inlen = read(data_fd, packet->data, MTU)) <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, + device, strerror(errno)); + running = false; + return false; + } - return false; - } + packet->len = inlen; - case 1: { - if((lenin = read(request_fd, &request, sizeof(request))) != sizeof request) { - logger(LOG_ERR, "Error while reading request from %s %s: %s", device_info, - device, strerror(errno)); - running = false; - return false; + device_total_in += packet->len; + + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, + device_info); + + return true; } - - if(request.magic != 0xfeedface || request.version != 3 || request.type != REQ_NEW_CONTROL) { - logger(LOG_ERR, "Unknown magic %x, version %d, request type %d from %s %s", - request.magic, request.version, request.type, device_info, device); - running = false; - return false; - } - - if(connect(write_fd, (struct sockaddr *)&request.sock, sizeof(request.sock)) < 0) { - logger(LOG_ERR, "Could not bind write %s: %s", device_info, strerror(errno)); - running = false; - return false; - } - - write(request_fd, &data_sun, sizeof(data_sun)); - device_fd = data_fd; - - logger(LOG_INFO, "Connection with UML established"); - - state = 2; - return false; - } - - case 2: { - if((lenin = read(data_fd, packet->data, MTU)) <= 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, - device, strerror(errno)); - running = false; - return false; - } - - packet->len = lenin; - - device_total_in += packet->len; - - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, - device_info); - - return true; - } - - default: - logger(LOG_ERR, "Invalid value for state variable in " __FILE__); - abort(); } } -static bool write_packet(vpn_packet_t *packet) { +bool write_packet(vpn_packet_t *packet) { if(state != 2) { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Dropping packet of %d bytes to %s: not connected to UML yet", - packet->len, device_info); + packet->len, device_info); return false; } ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + packet->len, device_info); if(write(write_fd, packet->data, packet->len) < 0) { if(errno != EINTR && errno != EAGAIN) { @@ -295,16 +271,8 @@ static bool write_packet(vpn_packet_t *packet) { return true; } -static void dump_device_stats(void) { +void dump_device_stats(void) { logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); } - -const devops_t uml_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, - .dump_stats = dump_device_stats, -}; diff --git a/src/utils.c b/src/utils.c index 70a5c99..022ac25 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,7 +1,7 @@ /* utils.c -- gathering of some stupid small functions Copyright (C) 1999-2005 Ivo Timmermans - 2000-2014 Guus Sliepen + 2000-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,34 +24,111 @@ #include "utils.h" static const char hexadecimals[] = "0123456789ABCDEF"; +static const char base64imals[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static int charhex2bin(char c) { - if(isdigit(c)) { + if(isdigit(c)) return c - '0'; - } else { + else return toupper(c) - 'A' + 10; - } } -bool hex2bin(char *src, char *dst, int length) { - for(int i = 0; i < length; i++) { - if(!isxdigit(src[i * 2]) || !isxdigit(src[i * 2 + 1])) { - return false; - } - - dst[i] = charhex2bin(src[i * 2]) * 16 + charhex2bin(src[i * 2 + 1]); - } - - return true; +static int charb64decode(char c) { + if(c >= 'a') + return c - 'a' + 26; + else if(c >= 'A') + return c - 'A'; + else if(c >= '0') + return c - '0' + 52; + else if(c == '+') + return 62; + else + return 63; } -void bin2hex(char *src, char *dst, int length) { +int hex2bin(const char *src, char *dst, int length) { int i; + for(i = 0; i < length && src[i * 2] && src[i * 2 + 1]; i++) + dst[i] = charhex2bin(src[i * 2]) * 16 + charhex2bin(src[i * 2 + 1]); + return i; +} +int bin2hex(const char *src, char *dst, int length) { + int i; for(i = length - 1; i >= 0; i--) { dst[i * 2 + 1] = hexadecimals[(unsigned char) src[i] & 15]; dst[i * 2] = hexadecimals[(unsigned char) src[i] >> 4]; } + dst[length * 2] = 0; + return length * 2; +} + +int b64decode(const char *src, char *dst, int length) { + int i; + uint32_t triplet = 0; + unsigned char *udst = dst; + + for(i = 0; i < length / 3 * 4 && src[i]; i++) { + triplet |= charb64decode(src[i]) << (6 * (i & 3)); + if((i & 3) == 3) { + udst[0] = triplet & 0xff; triplet >>= 8; + udst[1] = triplet & 0xff; triplet >>= 8; + udst[2] = triplet; + triplet = 0; + udst += 3; + } + } + if((i & 3) == 3) { + udst[0] = triplet & 0xff; triplet >>= 8; + udst[1] = triplet & 0xff; + return i / 4 * 3 + 2; + } else if((i & 3) == 2) { + udst[0] = triplet & 0xff; + return i / 4 * 3 + 1; + } else { + return i / 4 * 3; + } +} + +int b64encode(const char *src, char *dst, int length) { + uint32_t triplet; + const unsigned char *usrc = src; + int si = length / 3 * 3; + int di = length / 3 * 4; + + switch(length % 3) { + case 2: + triplet = usrc[si] | usrc[si + 1] << 8; + dst[di] = base64imals[triplet & 63]; triplet >>= 6; + dst[di + 1] = base64imals[triplet & 63]; triplet >>= 6; + dst[di + 2] = base64imals[triplet]; + dst[di + 3] = 0; + length = di + 2; + break; + case 1: + triplet = usrc[si]; + dst[di] = base64imals[triplet & 63]; triplet >>= 6; + dst[di + 1] = base64imals[triplet]; + dst[di + 2] = 0; + length = di + 1; + break; + default: + dst[di] = 0; + length = di; + break; + } + + while(si > 0) { + di -= 4; + si -= 3; + triplet = usrc[si] | usrc[si + 1] << 8 | usrc[si + 2] << 16; + dst[di] = base64imals[triplet & 63]; triplet >>= 6; + dst[di + 1] = base64imals[triplet & 63]; triplet >>= 6; + dst[di + 2] = base64imals[triplet & 63]; triplet >>= 6; + dst[di + 3] = base64imals[triplet]; + } + + return length; } #if defined(HAVE_MINGW) || defined(HAVE_CYGWIN) @@ -60,18 +137,15 @@ void bin2hex(char *src, char *dst, int length) { #endif const char *winerror(int err) { - static char buf[1024], *ptr; + static char buf[1024], *newline; - ptr = buf + sprintf(buf, "(%d) ", err); - - if(!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), ptr, sizeof(buf) - (ptr - buf), NULL)) { - strcpy(ptr, "(unable to format errormessage)"); + if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, sizeof(buf), NULL)) { + strncpy(buf, "(unable to format errormessage)", sizeof(buf)); }; - if((ptr = strchr(buf, '\r'))) { - *ptr = '\0'; - } + if((newline = strchr(buf, '\r'))) + *newline = '\0'; return buf; } @@ -79,27 +153,8 @@ const char *winerror(int err) { unsigned int bitfield_to_int(const void *bitfield, size_t size) { unsigned int value = 0; - - if(size > sizeof(value)) { - size = sizeof(value); - } - + if(size > sizeof value) + size = sizeof value; memcpy(&value, bitfield, size); return value; } - -/** - * As memcmp(), but constant-time. - * Returns 0 when data is equal, non-zero otherwise. - */ -int memcmp_constant_time(const void *a, const void *b, size_t size) { - const uint8_t *a1 = a, *b1 = b; - int ret = 0; - size_t i; - - for(i = 0; i < size; i++) { - ret |= *a1++ ^ *b1++; - } - - return ret; -} diff --git a/src/utils.h b/src/utils.h index 7952025..67c94f3 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,10 +1,7 @@ -#ifndef TINC_UTILS_H -#define TINC_UTILS_H - /* utils.h -- header file for utils.c Copyright (C) 1999-2005 Ivo Timmermans - 2000-2014 Guus Sliepen + 2000-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,30 +18,33 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -extern bool hex2bin(char *src, char *dst, int length); -extern void bin2hex(char *src, char *dst, int length); +#ifndef __TINC_UTILS_H__ +#define __TINC_UTILS_H__ -#if defined(HAVE_MINGW) || defined(HAVE_CYGWIN) -extern const char *winerror(int); -#endif +extern int hex2bin(const char *src, char *dst, int length); +extern int bin2hex(const char *src, char *dst, int length); + +extern int b64encode(const char *src, char *dst, int length); +extern int b64decode(const char *src, char *dst, int length); #ifdef HAVE_MINGW +extern const char *winerror(int); #define strerror(x) ((x)>0?strerror(x):winerror(GetLastError())) #define sockerrno WSAGetLastError() #define sockstrerror(x) winerror(x) #define sockwouldblock(x) ((x) == WSAEWOULDBLOCK || (x) == WSAEINTR) #define sockmsgsize(x) ((x) == WSAEMSGSIZE) #define sockinprogress(x) ((x) == WSAEINPROGRESS || (x) == WSAEWOULDBLOCK) +#define sockinuse(x) ((x) == WSAEADDRINUSE) #else #define sockerrno errno #define sockstrerror(x) strerror(x) #define sockwouldblock(x) ((x) == EWOULDBLOCK || (x) == EINTR) #define sockmsgsize(x) ((x) == EMSGSIZE) #define sockinprogress(x) ((x) == EINPROGRESS) +#define sockinuse(x) ((x) == EADDRINUSE) #endif extern unsigned int bitfield_to_int(const void *bitfield, size_t size); -int memcmp_constant_time(const void *a, const void *b, size_t size); - -#endif +#endif /* __TINC_UTILS_H__ */ diff --git a/src/vde_device.c b/src/vde_device.c deleted file mode 100644 index 6d854a6..0000000 --- a/src/vde_device.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - device.c -- VDE plug - Copyright (C) 2012 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include - -#include "conf.h" -#include "device.h" -#include "net.h" -#include "logger.h" -#include "utils.h" -#include "route.h" -#include "xalloc.h" - -static struct vdepluglib plug; -static struct vdeconn *conn = NULL; -static int port = 0; -static char *group = NULL; -static const char *device_info = "VDE socket"; - -extern char *identname; -extern volatile bool running; - -static uint64_t device_total_in = 0; -static uint64_t device_total_out = 0; - -static bool setup_device(void) { - libvdeplug_dynopen(plug); - - if(!plug.dl_handle) { - logger(LOG_ERR, "Could not open libvdeplug library!"); - return false; - } - - if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { - xasprintf(&device, RUNSTATEDIR "/vde.ctl"); - } - - get_config_string(lookup_config(config_tree, "Interface"), &iface); - - get_config_int(lookup_config(config_tree, "VDEPort"), &port); - - get_config_string(lookup_config(config_tree, "VDEGroup"), &group); - - struct vde_open_args args = { - .port = port, - .group = group, - .mode = 0700, - }; - - conn = plug.vde_open(device, identname, &args); - - if(!conn) { - logger(LOG_ERR, "Could not open VDE socket %s", device); - return false; - } - - device_fd = plug.vde_datafd(conn); - -#ifdef FD_CLOEXEC - fcntl(device_fd, F_SETFD, FD_CLOEXEC); -#endif - - logger(LOG_INFO, "%s is a %s", device, device_info); - - if(routing_mode == RMODE_ROUTER) { - overwrite_mac = true; - } - - return true; -} - -static void close_device(void) { - if(conn) { - plug.vde_close(conn); - } - - if(plug.dl_handle) { - libvdeplug_dynclose(plug); - } - - free(device); - - free(iface); -} - -static bool read_packet(vpn_packet_t *packet) { - int lenin = (ssize_t)plug.vde_recv(conn, packet->data, MTU, 0); - - if(lenin <= 0) { - logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); - running = false; - return false; - } - - packet->len = lenin; - device_total_in += packet->len; - ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info); - - return true; -} - -static bool write_packet(vpn_packet_t *packet) { - if((ssize_t)plug.vde_send(conn, packet->data, packet->len, 0) < 0) { - if(errno != EINTR && errno != EAGAIN) { - logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); - running = false; - } - - return false; - } - - device_total_out += packet->len; - - return true; -} - -static void dump_device_stats(void) { - logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); - logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); - logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); -} - -const devops_t vde_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, - .dump_stats = dump_device_stats, -}; diff --git a/src/xalloc.h b/src/xalloc.h index cda0871..42d0d95 100644 --- a/src/xalloc.h +++ b/src/xalloc.h @@ -1,10 +1,7 @@ -#ifndef TINC_XALLOC_H -#define TINC_XALLOC_H - /* - xalloc.h -- malloc and related functions with out of memory checking + xalloc.h -- malloc and related fuctions with out of memory checking Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. - Copyright (C) 2011-2017 Guus Sliepen + Copyright (C) 2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,74 +15,46 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., Foundation, - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + +#ifndef __TINC_XALLOC_H__ +#define __TINC_XALLOC_H__ -static inline void *xmalloc(size_t n) __attribute__((__malloc__)); static inline void *xmalloc(size_t n) { void *p = malloc(n); - - if(!p) { + if(!p) abort(); - } - return p; } -static inline void *xmalloc_and_zero(size_t n) __attribute__((__malloc__)); static inline void *xmalloc_and_zero(size_t n) { void *p = calloc(1, n); - - if(!p) { + if(!p) abort(); - } - return p; } static inline void *xrealloc(void *p, size_t n) { p = realloc(p, n); - - if(!p) { + if(!p) abort(); - } - return p; } -static inline char *xstrdup(const char *s) __attribute__((__malloc__)); static inline char *xstrdup(const char *s) { char *p = strdup(s); - - if(!p) { + if(!p) abort(); - } - return p; } static inline int xvasprintf(char **strp, const char *fmt, va_list ap) { -#ifdef HAVE_MINGW - char buf[1024]; - int result = vsnprintf(buf, sizeof(buf), fmt, ap); - - if(result < 0) { - abort(); - } - - *strp = xstrdup(buf); -#else int result = vasprintf(strp, fmt, ap); - - if(result < 0) { + if(result < 0) abort(); - } - -#endif return result; } -static inline int xasprintf(char **strp, const char *fmt, ...) __attribute__((__format__(printf, 2, 3))); static inline int xasprintf(char **strp, const char *fmt, ...) { va_list ap; va_start(ap, fmt); diff --git a/src/system.h b/system.h similarity index 85% rename from src/system.h rename to system.h index 14db7f5..5dc1daf 100644 --- a/src/system.h +++ b/system.h @@ -1,6 +1,3 @@ -#ifndef TINC_SYSTEM_H -#define TINC_SYSTEM_H - /* system.h -- system headers Copyright (C) 1998-2005 Ivo Timmermans @@ -21,20 +18,29 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __TINC_SYSTEM_H__ +#define __TINC_SYSTEM_H__ + #include "config.h" #include "have.h" +#ifndef HAVE_STDBOOL_H +typedef int bool; +#define true 1 +#define false 0 +#endif + #ifndef HAVE_STRSIGNAL # define strsignal(p) "" #endif /* Other functions */ -#include "dropin.h" +#include "src/dropin.h" #ifndef HAVE_SOCKLEN_T typedef int socklen_t; #endif -#endif +#endif /* __TINC_SYSTEM_H__ */ diff --git a/systemd/Makefile.am b/systemd/Makefile.am deleted file mode 100644 index dac2b73..0000000 --- a/systemd/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -EXTRA_DIST = tinc.service.in tinc@.service.in - -CLEANFILES = tinc.service tinc@.service - -if WITH_SYSTEMD -systemddir = @systemd_path@ -nodist_systemd_DATA = tinc.service tinc@.service -endif - -substitute = sed \ - -e s,'@sbindir\@',"$(sbindir)",g \ - -e s,'@sysconfdir\@',"$(sysconfdir)",g - -tinc.service: $(srcdir)/tinc.service.in - $(AM_V_GEN)$(substitute) $(srcdir)/tinc.service.in > $@ - -tinc@.service: $(srcdir)/tinc@.service.in - $(AM_V_GEN)$(substitute) $(srcdir)/tinc@.service.in > $@ diff --git a/systemd/tinc.service.in b/systemd/tinc.service.in deleted file mode 100644 index b671042..0000000 --- a/systemd/tinc.service.in +++ /dev/null @@ -1,20 +0,0 @@ -# This is a mostly empty service, but allows commands like stop, start, reload -# to propagate to all tinc@ service instances. - -[Unit] -Description=Tinc VPN -Documentation=info:tinc -Documentation=man:tinc(8) man:tinc.conf(5) -Documentation=http://tinc-vpn.org/docs/ -After=network.target -Wants=network.target - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/bin/true -ExecReload=/bin/true -WorkingDirectory=@sysconfdir@/tinc - -[Install] -WantedBy=multi-user.target diff --git a/systemd/tinc@.service.in b/systemd/tinc@.service.in deleted file mode 100644 index 8fbf551..0000000 --- a/systemd/tinc@.service.in +++ /dev/null @@ -1,20 +0,0 @@ -[Unit] -Description=Tinc net %i -Documentation=info:tinc -Documentation=man:tinc(8) man:tinc.conf(5) -Documentation=http://tinc-vpn.org/docs/ -PartOf=tinc.service -ReloadPropagatedFrom=tinc.service - -[Service] -Type=simple -WorkingDirectory=@sysconfdir@/tinc/%i -ExecStart=@sbindir@/tincd -n %i -D -ExecReload=@sbindir@/tincd -n %i -kHUP -KillMode=mixed -Restart=on-failure -RestartSec=5 -TimeoutStopSec=5 - -[Install] -WantedBy=tinc.service