OSDN Git Service

Fix bugs of displaying icons in the local file list.
[ffftp/ffftp.git] / putty / PROXY.H
1 /*\r
2  * Network proxy abstraction in PuTTY\r
3  *\r
4  * A proxy layer, if necessary, wedges itself between the\r
5  * network code and the higher level backend.\r
6  *\r
7  * Supported proxies: HTTP CONNECT, generic telnet, SOCKS 4 & 5\r
8  */\r
9 \r
10 #ifndef PUTTY_PROXY_H\r
11 #define PUTTY_PROXY_H\r
12 \r
13 #define PROXY_ERROR_GENERAL 8000\r
14 #define PROXY_ERROR_UNEXPECTED 8001\r
15 \r
16 typedef struct Socket_proxy_tag * Proxy_Socket;\r
17 \r
18 struct Socket_proxy_tag {\r
19     const struct socket_function_table *fn;\r
20     /* the above variable absolutely *must* be the first in this structure */\r
21 \r
22     char * error;\r
23 \r
24     Socket sub_socket;\r
25     Plug plug;\r
26     SockAddr remote_addr;\r
27     int remote_port;\r
28 \r
29     bufchain pending_output_data;\r
30     bufchain pending_oob_output_data;\r
31     int pending_flush;\r
32     bufchain pending_input_data;\r
33 \r
34 #define PROXY_STATE_NEW    -1\r
35 #define PROXY_STATE_ACTIVE  0\r
36 \r
37     int state; /* proxy states greater than 0 are implementation\r
38                 * dependent, but represent various stages/states\r
39                 * of the initialization/setup/negotiation with the\r
40                 * proxy server.\r
41                 */\r
42     int freeze; /* should we freeze the underlying socket when\r
43                  * we are done with the proxy negotiation? this\r
44                  * simply caches the value of sk_set_frozen calls.\r
45                  */\r
46 \r
47 #define PROXY_CHANGE_NEW      -1\r
48 #define PROXY_CHANGE_CLOSING   0\r
49 #define PROXY_CHANGE_SENT      1\r
50 #define PROXY_CHANGE_RECEIVE   2\r
51 #define PROXY_CHANGE_ACCEPTING 3\r
52 \r
53     /* something has changed (a call from the sub socket\r
54      * layer into our Proxy Plug layer, or we were just\r
55      * created, etc), so the proxy layer needs to handle\r
56      * this change (the type of which is the second argument)\r
57      * and further the proxy negotiation process.\r
58      */\r
59 \r
60     int (*negotiate) (Proxy_Socket /* this */, int /* change type */);\r
61 \r
62     /* current arguments of plug handlers\r
63      * (for use by proxy's negotiate function)\r
64      */\r
65 \r
66     /* closing */\r
67     const char *closing_error_msg;\r
68     int closing_error_code;\r
69     int closing_calling_back;\r
70 \r
71     /* receive */\r
72     int receive_urgent;\r
73     char *receive_data;\r
74     int receive_len;\r
75 \r
76     /* sent */\r
77     int sent_bufsize;\r
78 \r
79     /* accepting */\r
80     OSSocket accepting_sock;\r
81 \r
82     /* configuration, used to look up proxy settings */\r
83     Config cfg;\r
84 \r
85     /* CHAP transient data */\r
86     int chap_num_attributes;\r
87     int chap_num_attributes_processed;\r
88     int chap_current_attribute;\r
89     int chap_current_datalen;\r
90 };\r
91 \r
92 typedef struct Plug_proxy_tag * Proxy_Plug;\r
93 \r
94 struct Plug_proxy_tag {\r
95     const struct plug_function_table *fn;\r
96     /* the above variable absolutely *must* be the first in this structure */\r
97 \r
98     Proxy_Socket proxy_socket;\r
99 \r
100 };\r
101 \r
102 extern void proxy_activate (Proxy_Socket);\r
103 \r
104 extern int proxy_http_negotiate (Proxy_Socket, int);\r
105 extern int proxy_telnet_negotiate (Proxy_Socket, int);\r
106 extern int proxy_socks4_negotiate (Proxy_Socket, int);\r
107 extern int proxy_socks5_negotiate (Proxy_Socket, int);\r
108 \r
109 /*\r
110  * This may be reused by local-command proxies on individual\r
111  * platforms.\r
112  */\r
113 char *format_telnet_command(SockAddr addr, int port, const Config *cfg);\r
114 \r
115 /*\r
116  * These are implemented in cproxy.c or nocproxy.c, depending on\r
117  * whether encrypted proxy authentication is available.\r
118  */\r
119 extern void proxy_socks5_offerencryptedauth(char *command, int *len);\r
120 extern int proxy_socks5_handlechap (Proxy_Socket p);\r
121 extern int proxy_socks5_selectchap(Proxy_Socket p);\r
122 \r
123 #endif\r