Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

proxy.h

00001 /*
00002  * Network proxy abstraction in PuTTY
00003  *
00004  * A proxy layer, if necessary, wedges itself between the
00005  * network code and the higher level backend.
00006  *
00007  * Supported proxies: HTTP CONNECT, generic telnet
00008  * In progress: SOCKS
00009  */
00010 
00011 #ifndef PUTTY_PROXY_H
00012 #define PUTTY_PROXY_H
00013 
00014 #define PROXY_ERROR_GENERAL 8000
00015 #define PROXY_ERROR_UNEXPECTED 8001
00016 
00017 typedef struct Socket_proxy_tag * Proxy_Socket;
00018 
00019 struct Socket_proxy_tag {
00020     struct socket_function_table *fn;
00021     /* the above variable absolutely *must* be the first in this structure */
00022 
00023     char * error;
00024 
00025     Socket sub_socket;
00026     Plug plug;
00027     SockAddr remote_addr;
00028     int remote_port;
00029 
00030     bufchain pending_output_data;
00031     bufchain pending_oob_output_data;
00032     int pending_flush;
00033     bufchain pending_input_data;
00034 
00035 #define PROXY_STATE_NEW    -1
00036 #define PROXY_STATE_ACTIVE  0
00037 
00038     int state; /* proxy states greater than 0 are implementation
00039                 * dependent, but represent various stages/states
00040                 * of the initialization/setup/negotiation with the
00041                 * proxy server.
00042                 */
00043     int freeze; /* should we freeze the underlying socket when
00044                  * we are done with the proxy negotiation? this
00045                  * simply caches the value of sk_set_frozen calls.
00046                  */
00047 
00048 #define PROXY_CHANGE_NEW      -1
00049 #define PROXY_CHANGE_CLOSING   0
00050 #define PROXY_CHANGE_SENT      1
00051 #define PROXY_CHANGE_RECEIVE   2
00052 #define PROXY_CHANGE_ACCEPTING 3
00053 
00054     /* something has changed (a call from the sub socket
00055      * layer into our Proxy Plug layer, or we were just
00056      * created, etc), so the proxy layer needs to handle
00057      * this change (the type of which is the second argument)
00058      * and further the proxy negotiation process.
00059      */
00060 
00061     int (*negotiate) (Proxy_Socket /* this */, int /* change type */);
00062 
00063     /* current arguments of plug handlers
00064      * (for use by proxy's negotiate function)
00065      */
00066 
00067     /* closing */
00068     char *closing_error_msg;
00069     int closing_error_code;
00070     int closing_calling_back;
00071 
00072     /* receive */
00073     int receive_urgent;
00074     char *receive_data;
00075     int receive_len;
00076 
00077     /* sent */
00078     int sent_bufsize;
00079 
00080     /* accepting */
00081     void *accepting_sock;
00082 
00083 };
00084 
00085 typedef struct Plug_proxy_tag * Proxy_Plug;
00086 
00087 struct Plug_proxy_tag {
00088     struct plug_function_table *fn;
00089     /* the above variable absolutely *must* be the first in this structure */
00090 
00091     Proxy_Socket proxy_socket;
00092 
00093 };
00094 
00095 extern void proxy_activate (Proxy_Socket);
00096 
00097 extern int proxy_http_negotiate (Proxy_Socket, int);
00098 extern int proxy_telnet_negotiate (Proxy_Socket, int);
00099 extern int proxy_socks4_negotiate (Proxy_Socket, int);
00100 extern int proxy_socks5_negotiate (Proxy_Socket, int);
00101 
00102 #endif

Generated on Sun Feb 9 13:01:28 2003 for PuTTY by doxygen1.2.18