1 #ifndef GATEWAY_H_INCLUDED
2 #define GATEWAY_H_INCLUDED
3 #define GATEWAY_H_VERSION "$Id: gateway.h,v 1.14 2009/05/13 18:20:54 fabiankeil Exp $"
4 /*********************************************************************
6 * File : $Source: /cvsroot/ijbswa/current/gateway.h,v $
8 * Purpose : Contains functions to connect to a server, possibly
9 * using a "gateway" (i.e. HTTP proxy and/or SOCKS4
10 * proxy). Also contains the list of gateway types.
12 * Copyright : Written by and Copyright (C) 2001 the SourceForge
13 * Privoxy team. http://www.privoxy.org/
15 * Based on the Internet Junkbuster originally written
16 * by and Copyright (C) 1997 Anonymous Coders and
17 * Junkbusters Corporation. http://www.junkbusters.com
19 * This program is free software; you can redistribute it
20 * and/or modify it under the terms of the GNU General
21 * Public License as published by the Free Software
22 * Foundation; either version 2 of the License, or (at
23 * your option) any later version.
25 * This program is distributed in the hope that it will
26 * be useful, but WITHOUT ANY WARRANTY; without even the
27 * implied warranty of MERCHANTABILITY or FITNESS FOR A
28 * PARTICULAR PURPOSE. See the GNU General Public
29 * License for more details.
31 * The GNU General Public License should be included with
32 * this file. If not, you can view it at
33 * http://www.gnu.org/copyleft/gpl.html
34 * or write to the Free Software Foundation, Inc., 59
35 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 * Revision 1.14 2009/05/13 18:20:54 fabiankeil
40 * There's no reason for keep_alive_timeout to be signed.
42 * Revision 1.13 2009/05/10 10:12:30 fabiankeil
43 * Initial keep-alive support for the client socket.
44 * Temporarily disable the server-side-only keep-alive code.
46 * Revision 1.12 2008/12/24 17:06:19 fabiankeil
47 * Keep a thread around to timeout alive connections
48 * even if no new requests are coming in.
50 * Revision 1.11 2008/11/13 09:08:42 fabiankeil
51 * Add new config option: keep-alive-timeout.
53 * Revision 1.10 2008/10/09 18:21:41 fabiankeil
54 * Flush work-in-progress changes to keep outgoing connections
55 * alive where possible. Incomplete and mostly #ifdef'd out.
57 * Revision 1.9 2006/07/18 14:48:46 david__schmidt
58 * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
59 * with what was really the latest development (the v_3_0_branch branch)
61 * Revision 1.7 2002/03/26 22:29:54 swa
62 * we have a new homepage!
64 * Revision 1.6 2002/03/25 22:12:45 oes
65 * Added fix for undefined INADDR_NONE on Solaris by Bart Schelstraete
67 * Revision 1.5 2002/03/24 13:25:43 swa
68 * name change related issues
70 * Revision 1.4 2002/03/09 20:03:52 jongfoster
71 * - Making various functions return int rather than size_t.
72 * (Undoing a recent change). Since size_t is unsigned on
73 * Windows, functions like read_socket that return -1 on
74 * error cannot return a size_t.
76 * THIS WAS A MAJOR BUG - it caused frequent, unpredictable
77 * crashes, and also frequently caused JB to jump to 100%
78 * CPU and stay there. (Because it thought it had just
79 * read ((unsigned)-1) == 4Gb of data...)
81 * - The signature of write_socket has changed, it now simply
82 * returns success=0/failure=nonzero.
84 * - Trying to get rid of a few warnings --with-debug on
85 * Windows, I've introduced a new type "jb_socket". This is
86 * used for the socket file descriptors. On Windows, this
87 * is SOCKET (a typedef for unsigned). Everywhere else, it's
88 * an int. The error value can't be -1 any more, so it's
89 * now JB_INVALID_SOCKET (which is -1 on UNIX, and in
90 * Windows it maps to the #define INVALID_SOCKET.)
92 * - The signature of bind_port has changed.
94 * Revision 1.3 2001/07/29 18:58:15 jongfoster
95 * Removing nested #includes, adding forward declarations for needed
96 * structures, and changing the #define _FILENAME_H to FILENAME_H_INCLUDED.
98 * Revision 1.2 2001/06/07 23:12:14 jongfoster
99 * Removing gateways[] list - no longer used.
100 * Replacing function pointer in struct gateway with a directly
101 * called function forwarded_connect(), which can do the common
102 * task of deciding whether to connect to the web server or HTTP
104 * Replacing struct gateway with struct forward_spec
106 * Revision 1.1.1.1 2001/05/15 13:58:54 oes
107 * Initial import of version 2.9.3 source tree
110 *********************************************************************/
121 extern jb_socket forwarded_connect(const struct forward_spec * fwd,
122 struct http_request *http,
123 struct client_state *csp);
124 #ifdef FEATURE_CONNECTION_KEEP_ALIVE
127 * Default number of seconds after which an
128 * open connection will no longer be reused.
130 #define DEFAULT_KEEP_ALIVE_TIMEOUT 180
132 extern void set_keep_alive_timeout(unsigned int timeout);
133 extern void initialize_reusable_connections(void);
134 extern void forget_connection(jb_socket sfd);
135 extern void remember_connection(jb_socket sfd,
136 const struct http_request *http,
137 const struct forward_spec *fwd,
138 unsigned int timeout);
139 extern int close_unusable_connections(void);
140 extern void mark_connection_closed(struct reusable_connection *closed_connection);
141 extern int connection_destination_matches(const struct reusable_connection *connection,
142 const struct http_request *http,
143 const struct forward_spec *fwd);
144 #endif /* FEATURE_CONNECTION_KEEP_ALIVE */
151 #define INADDR_NONE -1
155 * Revision control strings from this header and associated .c file
157 extern const char gateway_rcs[];
158 extern const char gateway_h_rcs[];
164 #endif /* ndef GATEWAY_H_INCLUDED */