1 /* 2 * PLUGDAEMON. Copyright (c) 2012 Peter da Silva. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 3. The names of the program and author may not be used to endorse or 13 * promote products derived from this software without specific prior 14 * written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 17 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 18 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 19 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #define MAX_PROXIES 32 29 #define MAX_CLIENTS 16384 /* These are held for a whole timeout period */ 30 #define USAGE_FACTOR 4 /* expected # proxies per client */ 31 #define IO_SIZE 2048 /* size of reads and writes */ 32 #define GRAVESITES 1024 /* How many dead procs to expect in the main loop */ 33 #ifdef BIGHASH 34 #define HASH_SIZE 661 /* Largest prime below 666 */ 35 #else 36 #define HASH_SIZE 41 /* Largest prime below 42 */ 37 #endif 38 #define hash(n) ((n) % HASH_SIZE) /* Shupid hash algorithm */ 39 40 /* Random OS-Specific stuff */ 41 #define SA2ASCII_BUFSIZ 78 /* big enough for IPV6 addr + : + port */ 42 43 #ifdef sa_sigaction 44 # define SA_HANDLER sa_sigaction 45 #else 46 # define SA_HANDLER sa_handler 47 #endif 48 49 #ifdef __OpenBSD__ 50 # define SA_HANDLER_ARG2_T siginfo_t * 51 #endif 52 53 #ifdef __FreeBSD__ 54 # if __FreeBSD__ < 4 55 # define SA_HANDLER_ARG2_T int 56 # else 57 # define SA_HANDLER_ARG2_T siginfo_t * 58 # endif 59 #endif 60 61 /* Linux changes as per Anthony de Boer (ADB) */ 62 #ifdef __linux__ 63 # ifdef sa_sigaction 64 # define SA_HANDLER_ARG2_T siginfo_t * 65 # else 66 # define WAITER_ALTDEF 67 # endif 68 /* the symbol __GLIBC_PREREQ seems to have been added at the same time as 69 * in_addr_t + dietlibc changes by al 70 */ 71 # if (!(defined(__GLIBC_PREREQ) || defined(__dietlibc__))) 72 typedef unsigned long int in_addr_t; 73 # endif 74 #endif 75 76 /* dietlibc changes by al */ 77 #if defined(__dietlibc__) 78 typedef uint32_t u_long; 79 typedef unsigned short u_short; 80 #endif 81 82 83 /* Mac OS X 10.1.5 */ 84 #ifdef __APPLE__ 85 # include <AvailabilityMacros.h> 86 # ifndef MAC_OS_X_VERSION_10_2 87 typedef u_int32_t in_addr_t; 88 # else 89 # define SA_HANDLER_ARG2_T siginfo_t * 90 # endif 91 #endif 92 93 #if defined(__osf__) && defined(__alpha) 94 # define SA_HANDLER_ARG2_T struct siginfo * 95 #endif 96 97 #ifndef SA_HANDLER_ARG2_T 98 # define SA_HANDLER_ARG2_T int 99 #endif 100 101