1 /* 2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors 3 * 4 * Squid software is distributed under GPLv2+ license and includes 5 * contributions from numerous individuals and organizations. 6 * Please see the COPYING and CONTRIBUTORS files for details. 7 */ 8 9 #ifndef SQUID_DEFINES_H 10 #define SQUID_DEFINES_H 11 12 #ifndef TRUE 13 #define TRUE 1 14 #endif 15 #ifndef FALSE 16 #define FALSE 0 17 #endif 18 19 #ifndef BUFSIZ 20 #define BUFSIZ 4096 /* make unreasonable guess */ 21 #endif 22 23 #define BROWSERNAMELEN 128 24 25 #define ACL_SUNDAY 0x01 26 #define ACL_MONDAY 0x02 27 #define ACL_TUESDAY 0x04 28 #define ACL_WEDNESDAY 0x08 29 #define ACL_THURSDAY 0x10 30 #define ACL_FRIDAY 0x20 31 #define ACL_SATURDAY 0x40 32 #define ACL_ALLWEEK 0x7F 33 #define ACL_WEEKDAYS 0x3E 34 35 /* Select types. */ 36 #define COMM_SELECT_READ (0x1) 37 #define COMM_SELECT_WRITE (0x2) 38 39 #define DISK_OK (0) 40 #define DISK_ERROR (-1) 41 #define DISK_EOF (-2) 42 #define DISK_NO_SPACE_LEFT (-6) 43 44 #define DNS_INBUF_SZ 4096 45 46 #define FD_DESC_SZ 64 47 48 #define FQDN_LOOKUP_IF_MISS 0x01 49 #define FQDN_MAX_NAMES 5 50 51 #define HTTP_REPLY_FIELD_SZ 128 52 53 #define BUF_TYPE_8K 1 54 #define BUF_TYPE_MALLOC 2 55 56 #define ANONYMIZER_NONE 0 57 #define ANONYMIZER_STANDARD 1 58 #define ANONYMIZER_PARANOID 2 59 60 #define USER_IDENT_SZ 64 61 #define IDENT_NONE 0 62 #define IDENT_PENDING 1 63 #define IDENT_DONE 2 64 65 #define IP_LOOKUP_IF_MISS 0x01 66 67 #define MAX_MIME 4096 68 69 /* Mark a neighbor cache as dead if it doesn't answer this many pings */ 70 #define HIER_MAX_DEFICIT 20 71 72 #define ICP_FLAG_HIT_OBJ 0x80000000ul 73 #define ICP_FLAG_SRC_RTT 0x40000000ul 74 75 /* Version */ 76 #define ICP_VERSION_2 2 77 #define ICP_VERSION_3 3 78 #define ICP_VERSION_CURRENT ICP_VERSION_2 79 80 #define DIRECT_UNKNOWN 0 81 #define DIRECT_NO 1 82 #define DIRECT_MAYBE 2 83 #define DIRECT_YES 3 84 85 #define REDIRECT_AV_FACTOR 1000 86 87 #define REDIRECT_NONE 0 88 #define REDIRECT_PENDING 1 89 #define REDIRECT_DONE 2 90 91 #define AUTHENTICATE_AV_FACTOR 1000 92 /* AUTHENTICATION */ 93 94 #define NTLM_CHALLENGE_SZ 300 95 96 #define current_stacksize(stack) ((stack)->top - (stack)->base) 97 98 /* logfile status */ 99 #define LOG_ENABLE 1 100 #define LOG_DISABLE 0 101 102 #define SM_PAGE_SIZE 4096 103 #define MAX_CLIENT_BUF_SZ 4096 104 105 #define EBIT_SET(flag, bit) ((void)((flag) |= ((1L<<(bit))))) 106 #define EBIT_CLR(flag, bit) ((void)((flag) &= ~((1L<<(bit))))) 107 #define EBIT_TEST(flag, bit) ((flag) & ((1L<<(bit)))) 108 109 /* bit opearations on a char[] mask of unlimited length */ 110 #define CBIT_BIT(bit) (1<<((bit)%8)) 111 #define CBIT_BIN(mask, bit) (mask)[(bit)>>3] 112 #define CBIT_SET(mask, bit) ((void)(CBIT_BIN(mask, bit) |= CBIT_BIT(bit))) 113 #define CBIT_CLR(mask, bit) ((void)(CBIT_BIN(mask, bit) &= ~CBIT_BIT(bit))) 114 #define CBIT_TEST(mask, bit) (CBIT_BIN(mask, bit) & CBIT_BIT(bit)) 115 116 #define MAX_FILES_PER_DIR (1<<20) 117 118 #define MAX_URL 8192 119 #define MAX_LOGIN_SZ 128 120 121 #define PEER_MAX_ADDRESSES 10 122 #define RTT_AV_FACTOR 50 123 #define RTT_BACKGROUND_AV_FACTOR 25 /* Background pings need a smaller factor since they are sent less frequently */ 124 125 #define PEER_DEAD 0 126 #define PEER_ALIVE 1 127 128 #define AUTH_MSG_SZ 4096 129 #define HTTP_REPLY_BUF_SZ 4096 130 #define CLIENT_REQ_BUF_SZ 4096 131 132 #if !defined(ERROR_BUF_SZ) && defined(MAX_URL) 133 #define ERROR_BUF_SZ (MAX_URL << 2) 134 #endif 135 136 #if SQUID_SNMP 137 #define VIEWINCLUDED 1 138 #define VIEWEXCLUDED 2 139 #endif 140 141 #define STORE_META_OK 0x03 142 #define STORE_META_DIRTY 0x04 143 #define STORE_META_BAD 0x05 144 145 #define IPC_NONE 0 146 #define IPC_TCP_SOCKET 1 147 #define IPC_UDP_SOCKET 2 148 #define IPC_FIFO 3 149 #define IPC_UNIX_STREAM 4 150 #define IPC_UNIX_DGRAM 5 151 152 /* required for AF_UNIX below to be defined [on FreeBSD] */ 153 #if HAVE_SYS_SOCKET_H 154 #include <sys/socket.h> 155 #endif 156 157 #if HAVE_SOCKETPAIR && defined (AF_UNIX) 158 #define IPC_STREAM IPC_UNIX_STREAM 159 #define IPC_DGRAM IPC_UNIX_DGRAM 160 #else 161 #define IPC_STREAM IPC_TCP_SOCKET 162 #define IPC_DGRAM IPC_UDP_SOCKET 163 #endif 164 165 #define STORE_META_KEY STORE_META_KEY_MD5 166 167 #define STORE_META_TLD_START sizeof(int)+sizeof(char) 168 #define STORE_META_TLD_SIZE STORE_META_TLD_START 169 #define SwapMetaType(x) (char)x[0] 170 #define SwapMetaSize(x) &x[sizeof(char)] 171 #define SwapMetaData(x) &x[STORE_META_TLD_START] 172 #define STORE_HDR_METASIZE (4*sizeof(time_t)+2*sizeof(uint16_t)+sizeof(uint64_t)) 173 #define STORE_HDR_METASIZE_OLD (4*sizeof(time_t)+2*sizeof(uint16_t)+sizeof(size_t)) 174 175 #define COUNT_INTERVAL 60 176 /* 177 * keep 60 minutes' worth of per-minute readings (+ current reading) 178 */ 179 #define N_COUNT_HIST (3600 / COUNT_INTERVAL) + 1 180 /* 181 * keep 3 days' (72 hours) worth of hourly readings 182 */ 183 #define N_COUNT_HOUR_HIST (86400 * 3) / (60 * COUNT_INTERVAL) 184 185 /* handy to determine the #elements in a static array */ 186 #define countof(arr) (sizeof(arr)/sizeof(*arr)) 187 188 /* 189 * This many TCP connections must FAIL before we mark the 190 * peer as DEAD 191 */ 192 #define PEER_TCP_MAGIC_COUNT 10 193 194 #define URI_WHITESPACE_STRIP 0 195 #define URI_WHITESPACE_ALLOW 1 196 #define URI_WHITESPACE_ENCODE 2 197 #define URI_WHITESPACE_CHOP 3 198 #define URI_WHITESPACE_DENY 4 199 200 #ifndef O_TEXT 201 #define O_TEXT 0 202 #endif 203 #ifndef O_BINARY 204 #define O_BINARY 0 205 #endif 206 207 /* 208 * Macro to find file access mode 209 */ 210 #ifdef O_ACCMODE 211 #define FILE_MODE(x) ((x)&O_ACCMODE) 212 #else 213 #define FILE_MODE(x) ((x)&(O_RDONLY|O_WRONLY|O_RDWR)) 214 #endif 215 216 #define HTTP_REQBUF_SZ 4096 217 218 /* CygWin & Windows NT Port */ 219 #if _SQUID_WINDOWS_ 220 #define _WIN_SQUID_SERVICE_CONTROL_STOP SERVICE_CONTROL_STOP 221 #define _WIN_SQUID_SERVICE_CONTROL_SHUTDOWN SERVICE_CONTROL_SHUTDOWN 222 #define _WIN_SQUID_SERVICE_CONTROL_INTERROGATE SERVICE_CONTROL_INTERROGATE 223 #define _WIN_SQUID_SERVICE_CONTROL_ROTATE 128 224 #define _WIN_SQUID_SERVICE_CONTROL_RECONFIGURE 129 225 #define _WIN_SQUID_SERVICE_CONTROL_DEBUG 130 226 #define _WIN_SQUID_SERVICE_CONTROL_INTERRUPT 131 227 #define _WIN_SQUID_SERVICE_OPTION "--ntservice" 228 #define _WIN_SQUID_RUN_MODE_INTERACTIVE 0 229 #define _WIN_SQUID_RUN_MODE_SERVICE 1 230 #endif 231 232 #endif /* SQUID_DEFINES_H */ 233 234