2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
29 #ifndef SQUID_PROTOS_H
30 #define SQUID_PROTOS_H
32 /* included for routines that have not moved out to their proper homes
36 /* for routines still in this file that take CacheManager parameters */
37 #include "ip/Address.h"
38 /* for parameters that still need these */
40 /* some parameters stil need this */
42 #include "anyp/ProtocolType.h"
44 #include "HttpHeader.h"
45 #include "HttpStatusCode.h"
49 class HttpRequestMethod
;
56 extern void fvdbCountVia(const char *key
);
57 extern void fvdbCountForw(const char *key
);
60 SQUIDCEXTERN
void headersLog(int cs
, int pq
, const HttpRequestMethod
& m
, void *data
);
62 extern int logTypeIsATcpHit(log_type
);
67 SQUIDCEXTERN
void configFreeMemory(void);
69 extern void self_destruct(void);
70 SQUIDCEXTERN
void add_http_port(char *portspec
);
71 extern int xatoi(const char *token
);
72 extern long xatol(const char *token
);
75 /* extra functions from cache_cf.c useful for lib modules */
76 SQUIDCEXTERN
void parse_int(int *var
);
77 SQUIDCEXTERN
void parse_onoff(int *var
);
78 SQUIDCEXTERN
void parse_eol(char *volatile *var
);
79 SQUIDCEXTERN
void parse_wordlist(wordlist
** list
);
80 SQUIDCEXTERN
void requirePathnameExists(const char *name
, const char *path
);
81 SQUIDCEXTERN
void parse_time_t(time_t * var
);
84 /* client_side.c - FD related client side routines */
86 SQUIDCEXTERN
void clientOpenListenSockets(void);
87 SQUIDCEXTERN
void clientHttpConnectionsClose(void);
88 SQUIDCEXTERN
void httpRequestFree(void *);
90 extern void clientAccessCheck(void *);
93 /* packs, then prints an object using debugs() */
94 SQUIDCEXTERN
void debugObj(int section
, int level
, const char *label
, void *obj
, ObjPackMethod pm
);
97 SQUIDCEXTERN
int file_open(const char *path
, int mode
);
98 SQUIDCEXTERN
void file_close(int fd
);
99 /* Adapter file_write for object callbacks */
103 FreeObject(void *address
)
105 O
*anObject
= static_cast <O
*>(address
);
109 SQUIDCEXTERN
void file_write(int, off_t
, void const *, int len
, DWCB
*, void *, FREE
*);
110 SQUIDCEXTERN
void file_write_mbuf(int fd
, off_t
, MemBuf mb
, DWCB
* handler
, void *handler_data
);
111 SQUIDCEXTERN
void file_read(int, char *, int, off_t
, DRCB
*, void *);
112 SQUIDCEXTERN
void disk_init(void);
114 extern void fd_close(int fd
);
115 extern void fd_open(int fd
, unsigned int type
, const char *);
116 extern void fd_note(int fd
, const char *);
117 extern void fd_bytes(int fd
, int len
, unsigned int type
);
118 extern void fdDumpOpen(void);
119 extern int fdUsageHigh(void);
120 extern void fdAdjustReserved(void);
125 \defgroup ServerProtocolFTPAPI Server-Side FTP API
126 \ingroup ServerProtocol
129 /// \ingroup ServerProtocolFTPAPI
130 SQUIDCEXTERN
void ftpStart(FwdState
*);
135 /// \ingroup ServerProtocolFTPAPI
136 SQUIDCEXTERN
const char *ftpUrlWith2f(HttpRequest
*);
142 \defgroup ServerProtocolWhoisAPI Server-Side WHOIS API
143 \ingroup ServerProtocol
146 /// \ingroup ServerProtocolWhoisAPI
147 SQUIDCEXTERN
void whoisStart(FwdState
*);
151 /* for http_hdr_type field */
152 SQUIDCEXTERN
int httpCachable(const HttpRequestMethod
&);
153 SQUIDCEXTERN
void httpStart(FwdState
*);
154 SQUIDCEXTERN mb_size_t
httpBuildRequestPrefix(HttpRequest
* request
,
155 HttpRequest
* orig_request
,
159 extern const char *httpMakeVaryMark(HttpRequest
* request
, HttpReply
const * reply
);
162 /* Http Header Tools */
163 class HttpHeaderFieldInfo
;
164 SQUIDCEXTERN HttpHeaderFieldInfo
*httpHeaderBuildFieldsInfo(const HttpHeaderFieldAttrs
* attrs
, int count
);
165 SQUIDCEXTERN
void httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo
* info
, int count
);
166 SQUIDCEXTERN http_hdr_type
httpHeaderIdByName(const char *name
, size_t name_len
, const HttpHeaderFieldInfo
* attrs
, int end
);
167 SQUIDCEXTERN http_hdr_type
httpHeaderIdByNameDef(const char *name
, int name_len
);
168 SQUIDCEXTERN
const char *httpHeaderNameById(int id
);
169 SQUIDCEXTERN
int httpHeaderHasConnDir(const HttpHeader
* hdr
, const char *directive
);
170 SQUIDCEXTERN
void strListAdd(String
* str
, const char *item
, char del
);
171 SQUIDCEXTERN
int strListIsMember(const String
* str
, const char *item
, char del
);
172 SQUIDCEXTERN
int strListIsSubstr(const String
* list
, const char *s
, char del
);
173 SQUIDCEXTERN
int strListGetItem(const String
* str
, char del
, const char **item
, int *ilen
, const char **pos
);
174 SQUIDCEXTERN
const char *getStringPrefix(const char *str
, const char *end
);
175 SQUIDCEXTERN
int httpHeaderParseInt(const char *start
, int *val
);
176 SQUIDCEXTERN
void httpHeaderPutStrf(HttpHeader
* hdr
, http_hdr_type id
, const char *fmt
,...) PRINTF_FORMAT_ARG3
;
180 /* store report about current header usage and other stats */
181 void httpHeaderStoreReport(StoreEntry
* e
);
182 SQUIDCEXTERN
void httpHdrMangleList(HttpHeader
*, HttpRequest
*, int req_or_rep
);
185 SQUIDCEXTERN PF snmpHandleUdp
;
186 SQUIDCEXTERN
void snmpInit(void);
187 SQUIDCEXTERN
void snmpOpenPorts(void);
188 SQUIDCEXTERN
void snmpClosePorts(void);
189 SQUIDCEXTERN
const char * snmpDebugOid(oid
* Name
, snint Len
, MemBuf
&outbuf
);
191 SQUIDCEXTERN
void addr2oid(Ip::Address
&addr
, oid
*Dest
);
192 SQUIDCEXTERN
void oid2addr(oid
*Dest
, Ip::Address
&addr
, u_int code
);
194 SQUIDCEXTERN
Ip::Address
*client_entry(Ip::Address
*current
);
195 extern variable_list
*snmp_basicFn(variable_list
*, snint
*);
196 extern variable_list
*snmp_confFn(variable_list
*, snint
*);
197 extern variable_list
*snmp_sysFn(variable_list
*, snint
*);
198 extern variable_list
*snmp_prfSysFn(variable_list
*, snint
*);
199 extern variable_list
*snmp_prfProtoFn(variable_list
*, snint
*);
200 extern variable_list
*snmp_prfPeerFn(variable_list
*, snint
*);
201 extern variable_list
*snmp_netIpFn(variable_list
*, snint
*);
202 extern variable_list
*snmp_netFqdnFn(variable_list
*, snint
*);
203 extern variable_list
*snmp_netDnsFn(variable_list
*, snint
*);
204 extern variable_list
*snmp_meshPtblFn(variable_list
*, snint
*);
205 extern variable_list
*snmp_meshCtblFn(variable_list
*, snint
*);
206 #endif /* SQUID_SNMP */
208 extern char *mime_get_header(const char *mime
, const char *header
);
209 extern char *mime_get_header_field(const char *mime
, const char *name
, const char *prefix
);
210 extern size_t headersEnd(const char *, size_t);
212 extern void mimeInit(char *filename
);
213 extern void mimeFreeMemory(void);
214 extern char *mimeGetContentEncoding(const char *fn
);
215 extern char *mimeGetContentType(const char *fn
);
216 extern char const *mimeGetIcon(const char *fn
);
217 extern const char *mimeGetIconURL(const char *fn
);
218 extern char mimeGetTransferMode(const char *fn
);
219 extern int mimeGetDownloadOption(const char *fn
);
220 extern int mimeGetViewOption(const char *fn
);
223 extern int mcastSetTtl(int, int);
224 extern IPH mcastJoinGroups
;
226 #include "comm/forward.h"
227 extern void getOutgoingAddress(HttpRequest
* request
, Comm::ConnectionPointer conn
);
228 extern Ip::Address
getOutgoingAddr(HttpRequest
* request
, struct peer
*dst_peer
);
230 SQUIDCEXTERN
void urnStart(HttpRequest
*, StoreEntry
*);
232 SQUIDCEXTERN
void redirectInit(void);
233 SQUIDCEXTERN
void redirectShutdown(void);
236 extern void shut_down(int);
237 extern void rotate_logs(int);
238 extern void reconfigure(int);
241 extern void start_announce(void *unused
);
242 extern void waisStart(FwdState
*);
244 SQUIDCEXTERN
void statInit(void);
245 SQUIDCEXTERN
void statFreeMemory(void);
246 SQUIDCEXTERN
double median_svc_get(int, int);
247 SQUIDCEXTERN
void pconnHistCount(int, int);
248 SQUIDCEXTERN
int stat5minClientRequests(void);
249 SQUIDCEXTERN
double stat5minCPUUsage(void);
250 SQUIDCEXTERN
double statRequestHitRatio(int minutes
);
251 SQUIDCEXTERN
double statRequestHitMemoryRatio(int minutes
);
252 SQUIDCEXTERN
double statRequestHitDiskRatio(int minutes
);
253 SQUIDCEXTERN
double statByteHitRatio(int minutes
);
256 SQUIDCEXTERN
void memClean(void);
257 SQUIDCEXTERN
void memInitModule(void);
258 SQUIDCEXTERN
void memCleanModule(void);
259 SQUIDCEXTERN
void memConfigure(void);
260 SQUIDCEXTERN
void *memAllocate(mem_type
);
261 SQUIDCEXTERN
void *memAllocString(size_t net_size
, size_t * gross_size
);
262 SQUIDCEXTERN
void *memAllocBuf(size_t net_size
, size_t * gross_size
);
263 SQUIDCEXTERN
void *memReallocBuf(void *buf
, size_t net_size
, size_t * gross_size
);
264 SQUIDCEXTERN
void memFree(void *, int type
);
265 void memFree2K(void *);
266 void memFree4K(void *);
267 void memFree8K(void *);
268 void memFree16K(void *);
269 void memFree32K(void *);
270 void memFree64K(void *);
271 SQUIDCEXTERN
void memFreeString(size_t size
, void *);
272 SQUIDCEXTERN
void memFreeBuf(size_t size
, void *);
273 SQUIDCEXTERN FREE
*memFreeBufFunc(size_t size
);
274 SQUIDCEXTERN
int memInUse(mem_type
);
275 SQUIDCEXTERN
void memDataInit(mem_type
, const char *, size_t, int, bool zeroOnPush
= true);
276 SQUIDCEXTERN
void memCheckInit(void);
280 SQUIDCEXTERN
void memConfigure(void);
282 /* ----------------------------------------------------------------- */
285 extern void storeReplSetup(void);
290 extern void storeLog(int tag
, const StoreEntry
* e
);
291 extern void storeLogRotate(void);
292 extern void storeLogClose(void);
293 extern void storeLogOpen(void);
299 SQUIDCEXTERN cache_key
*storeKeyDup(const cache_key
*);
300 SQUIDCEXTERN cache_key
*storeKeyCopy(cache_key
*, const cache_key
*);
301 SQUIDCEXTERN
void storeKeyFree(const cache_key
*);
302 SQUIDCEXTERN
const cache_key
*storeKeyScan(const char *);
303 SQUIDCEXTERN
const char *storeKeyText(const cache_key
*);
304 SQUIDCEXTERN
const cache_key
*storeKeyPublic(const char *, const HttpRequestMethod
&);
305 SQUIDCEXTERN
const cache_key
*storeKeyPublicByRequest(HttpRequest
*);
306 SQUIDCEXTERN
const cache_key
*storeKeyPublicByRequestMethod(HttpRequest
*, const HttpRequestMethod
&);
307 SQUIDCEXTERN
const cache_key
*storeKeyPrivate(const char *, const HttpRequestMethod
&, int);
308 SQUIDCEXTERN
int storeKeyHashBuckets(int);
309 SQUIDCEXTERN
int storeKeyNull(const cache_key
*);
310 SQUIDCEXTERN
void storeKeyInit(void);
311 SQUIDCEXTERN HASHHASH storeKeyHashHash
;
312 SQUIDCEXTERN HASHCMP storeKeyHashCmp
;
317 extern void storeDigestInit(void);
318 extern void storeDigestNoteStoreReady(void);
319 extern void storeDigestScheduleRebuild(void);
320 extern void storeDigestDel(const StoreEntry
* entry
);
321 extern void storeDigestReport(StoreEntry
*);
326 SQUIDCEXTERN
void storeRebuildStart(void);
328 SQUIDCEXTERN
void storeRebuildComplete(struct _store_rebuild_data
*);
329 SQUIDCEXTERN
void storeRebuildProgress(int sd_index
, int total
, int sofar
);
331 /// loads entry from disk; fills supplied memory buffer on success
332 extern bool storeRebuildLoadEntry(int fd
, int diskIndex
, MemBuf
&buf
, struct _store_rebuild_data
&counts
);
333 /// parses entry buffer and validates entry metadata; fills e on success
334 extern bool storeRebuildParseEntry(MemBuf
&buf
, StoreEntry
&e
, cache_key
*key
, struct _store_rebuild_data
&counts
, uint64_t expectedSize
);
335 /// checks whether the loaded entry should be kept; updates counters
336 extern bool storeRebuildKeepEntry(const StoreEntry
&e
, const cache_key
*key
, struct _store_rebuild_data
&counts
);
343 extern void storeSwapInStart(store_client
*);
348 SQUIDCEXTERN store_client
*storeClientListAdd(StoreEntry
* e
, void *data
);
349 SQUIDCEXTERN
int storeClientCopyPending(store_client
*, StoreEntry
* e
, void *data
);
350 SQUIDCEXTERN
int storeUnregister(store_client
* sc
, StoreEntry
* e
, void *data
)
352 SQUIDCEXTERN
int storePendingNClients(const StoreEntry
* e
);
353 SQUIDCEXTERN
int storeClientIsThisAClient(store_client
* sc
, void *someClient
);
356 SQUIDCEXTERN
const char *getMyHostname(void);
357 SQUIDCEXTERN
const char *uniqueHostname(void);
358 SQUIDCEXTERN
void safeunlink(const char *path
, int quiet
);
361 extern void death(int sig
);
362 extern void sigusr2_handle(int sig
);
363 extern void sig_child(int sig
);
364 extern void sig_shutdown(int sig
); ///< handles shutdown notifications from kids
365 SQUIDCEXTERN
void leave_suid(void);
366 SQUIDCEXTERN
void enter_suid(void);
367 SQUIDCEXTERN
void no_suid(void);
368 SQUIDCEXTERN
void writePidFile(void);
369 SQUIDCEXTERN
void setSocketShutdownLifetimes(int);
370 SQUIDCEXTERN
void setMaxFD(void);
371 SQUIDCEXTERN
void setSystemLimits(void);
372 extern void squid_signal(int sig
, SIGHDLR
*, int flags
);
373 SQUIDCEXTERN pid_t
readPidFile(void);
374 SQUIDCEXTERN
void keepCapabilities(void);
375 SQUIDCEXTERN
void BroadcastSignalIfAny(int& sig
);
376 /// whether the current process is the parent of all other Squid processes
377 SQUIDCEXTERN
bool IamMasterProcess();
379 whether the current process is dedicated to doing things that only
380 a single process should do, such as PID file maintenance and WCCP
382 SQUIDCEXTERN
bool IamPrimaryProcess();
383 /// whether the current process coordinates worker processes
384 SQUIDCEXTERN
bool IamCoordinatorProcess();
385 /// whether the current process handles HTTP transactions and such
386 SQUIDCEXTERN
bool IamWorkerProcess();
387 /// whether the current process is dedicated to managing a cache_dir
388 extern bool IamDiskProcess();
389 /// Whether we are running in daemon mode
390 SQUIDCEXTERN
bool InDaemonMode(); // try using specific Iam*() checks above first
391 /// Whether there should be more than one worker process running
392 SQUIDCEXTERN
bool UsingSmp(); // try using specific Iam*() checks above first
393 /// number of Kid processes as defined in src/ipc/Kid.h
394 SQUIDCEXTERN
int NumberOfKids();
395 /// a string describing this process roles such as worker or coordinator
396 extern String
ProcessRoles();
397 SQUIDCEXTERN
int DebugSignal
;
399 /* AYJ debugs function to show locations being reset with memset() */
400 SQUIDCEXTERN
void *xmemset(void *dst
, int, size_t);
402 SQUIDCEXTERN
void debug_trap(const char *);
403 SQUIDCEXTERN
void logsFlush(void);
404 SQUIDCEXTERN
const char *checkNullString(const char *p
);
406 SQUIDCEXTERN
void squid_getrusage(struct rusage
*r
);
408 SQUIDCEXTERN
double rusage_cputime(struct rusage
*r
);
410 SQUIDCEXTERN
int rusage_maxrss(struct rusage
*r
);
412 SQUIDCEXTERN
int rusage_pagefaults(struct rusage
*r
);
413 SQUIDCEXTERN
void releaseServerSockets(void);
414 SQUIDCEXTERN
void PrintRusage(void);
415 SQUIDCEXTERN
void dumpMallocStats(void);
418 SQUIDCEXTERN
bool unlinkdNeeded(void);
419 SQUIDCEXTERN
void unlinkdInit(void);
420 SQUIDCEXTERN
void unlinkdClose(void);
421 SQUIDCEXTERN
void unlinkdUnlink(const char *);
424 SQUIDCEXTERN
AnyP::ProtocolType
urlParseProtocol(const char *, const char *e
= NULL
);
425 SQUIDCEXTERN
void urlInitialize(void);
426 SQUIDCEXTERN HttpRequest
*urlParse(const HttpRequestMethod
&, char *, HttpRequest
*request
= NULL
);
427 SQUIDCEXTERN
const char *urlCanonical(HttpRequest
*);
428 SQUIDCEXTERN
char *urlCanonicalClean(const HttpRequest
*);
429 SQUIDCEXTERN
const char *urlCanonicalFakeHttps(const HttpRequest
* request
);
430 SQUIDCEXTERN
bool urlIsRelative(const char *);
431 SQUIDCEXTERN
char *urlMakeAbsolute(const HttpRequest
*, const char *);
432 SQUIDCEXTERN
char *urlRInternal(const char *host
, unsigned short port
, const char *dir
, const char *name
);
433 SQUIDCEXTERN
char *urlInternal(const char *dir
, const char *name
);
434 SQUIDCEXTERN
int matchDomainName(const char *host
, const char *domain
);
435 SQUIDCEXTERN
int urlCheckRequest(const HttpRequest
*);
436 SQUIDCEXTERN
int urlDefaultPort(AnyP::ProtocolType p
);
437 SQUIDCEXTERN
char *urlHostname(const char *url
);
438 SQUIDCEXTERN
void urlExtMethodConfigure(void);
440 SQUIDCEXTERN peer_t
parseNeighborType(const char *s
);
442 SQUIDCEXTERN
int stringHasWhitespace(const char *); //String.cc
443 SQUIDCEXTERN
int stringHasCntl(const char *); //String.cc
444 SQUIDCEXTERN
void linklistPush(link_list
**, void *); //list.cc
445 SQUIDCEXTERN
void *linklistShift(link_list
**); //list.cc
446 SQUIDCEXTERN
int xrename(const char *from
, const char *to
); //disk.cc
447 extern int isPowTen(int); //int.cc
449 SQUIDCEXTERN
char *strwordtok(char *buf
, char **t
); //String.cc
455 SQUIDCEXTERN pid_t
ipcCreate(int type
,
457 const char *const args
[],
459 Ip::Address
&local_addr
,
466 * prototypes for system functions missing from system includes
471 SQUIDCEXTERN
int getrusage(int, struct rusage
*);
472 SQUIDCEXTERN
int getpagesize(void);
473 #if !defined(_XPG4_2) && !(defined(__EXTENSIONS__) || \
474 (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)))
475 SQUIDCEXTERN
int gethostname(char *, int);
480 * hack to allow snmp access to the statistics counters
483 SQUIDCEXTERN StatCounters
*snmpStatGet(int);
486 /* CygWin & Windows NT Port */
489 SQUIDCEXTERN
int WIN32_Subsystem_Init(int *, char ***);
490 SQUIDCEXTERN
void WIN32_sendSignal(int);
491 SQUIDCEXTERN
void WIN32_Abort(int);
492 SQUIDCEXTERN
void WIN32_Exit(void);
493 SQUIDCEXTERN
void WIN32_SetServiceCommandLine(void);
494 SQUIDCEXTERN
void WIN32_InstallService(void);
495 SQUIDCEXTERN
void WIN32_RemoveService(void);
496 SQUIDCEXTERN
int SquidMain(int, char **);
497 #endif /* _SQUID_WINDOWS_ */
500 SQUIDCEXTERN
int WIN32_pipe(int[2]);
502 SQUIDCEXTERN
int WIN32_getrusage(int, struct rusage
*);
503 SQUIDCEXTERN
void WIN32_ExceptionHandlerInit(void);
505 SQUIDCEXTERN
int Win32__WSAFDIsSet(int fd
, fd_set
* set
);
506 SQUIDCEXTERN DWORD
WIN32_IpAddrChangeMonitorInit();
510 extern char *strtokFile(void);
514 #if HAVE_AUTH_MODULE_NEGOTIATE && HAVE_KRB5 && HAVE_GSSAPI
515 /* upstream proxy authentication */
516 SQUIDCEXTERN
char *peer_proxy_negotiate_auth(char *principal_name
, char *proxy
);
520 /* call to ensure the auth component schemes exist. */
521 extern void Init(void);
524 #endif /* USE_AUTH */
526 #endif /* SQUID_PROTOS_H */