2 * Network proxy abstraction in PuTTY
4 * A proxy layer, if necessary, wedges itself between the
5 * network code and the higher level backend.
7 * Supported proxies: HTTP CONNECT, generic telnet
14 #define PROXY_ERROR_GENERAL 8000
15 #define PROXY_ERROR_UNEXPECTED 8001
17 typedef struct Socket_proxy_tag * Proxy_Socket;
19 struct Socket_proxy_tag {
20 struct socket_function_table *fn;
21 /* the above variable absolutely *must* be the first in this structure */
30 bufchain pending_output_data;
31 bufchain pending_oob_output_data;
33 bufchain pending_input_data;
35 #define PROXY_STATE_NEW -1
36 #define PROXY_STATE_ACTIVE 0
38 int state; /* proxy states greater than 0 are implementation
39 * dependent, but represent various stages/states
40 * of the initialization/setup/negotiation with the
43 int freeze; /* should we freeze the underlying socket when
44 * we are done with the proxy negotiation? this
45 * simply caches the value of sk_set_frozen calls.
48 #define PROXY_CHANGE_NEW -1
49 #define PROXY_CHANGE_CLOSING 0
50 #define PROXY_CHANGE_SENT 1
51 #define PROXY_CHANGE_RECEIVE 2
52 #define PROXY_CHANGE_ACCEPTING 3
54 /* something has changed (a call from the sub socket
55 * layer into our Proxy Plug layer, or we were just
56 * created, etc), so the proxy layer needs to handle
57 * this change (the type of which is the second argument)
58 * and further the proxy negotiation process.
61 int (*negotiate) (Proxy_Socket /* this */, int /* change type */);
63 /* current arguments of plug handlers
64 * (for use by proxy's negotiate function)
68 char *closing_error_msg;
69 int closing_error_code;
70 int closing_calling_back;
83 /* spin locks, for the critical switch from negotiating
84 * to active state. we have to dump all of our pending
85 * buffers without new events (read, writes, etc) corrupting
86 * things. we should not have built up a large amount of
87 * pending data during negotiation, so hopefully this will
88 * not have a large effect on performance.
103 typedef struct Plug_proxy_tag * Proxy_Plug;
105 struct Plug_proxy_tag {
106 struct plug_function_table *fn;
107 /* the above variable absolutely *must* be the first in this structure */
109 Proxy_Socket proxy_socket;
113 extern void proxy_activate (Proxy_Socket);
115 extern int proxy_http_negotiate (Proxy_Socket, int);
116 extern int proxy_telnet_negotiate (Proxy_Socket, int);
117 extern int proxy_socks_negotiate (Proxy_Socket, int);