Initialise 'psa' to NULL on every code path in the Pageant client
[u/mdw/putty] / proxy.h
CommitLineData
8eebd221 1/*
2 * Network proxy abstraction in PuTTY
3 *
4 * A proxy layer, if necessary, wedges itself between the
5 * network code and the higher level backend.
6 *
2d129d8e 7 * Supported proxies: HTTP CONNECT, generic telnet, SOCKS 4 & 5
8eebd221 8 */
9
10#ifndef PUTTY_PROXY_H
11#define PUTTY_PROXY_H
12
13#define PROXY_ERROR_GENERAL 8000
14#define PROXY_ERROR_UNEXPECTED 8001
15
16typedef struct Socket_proxy_tag * Proxy_Socket;
17
18struct Socket_proxy_tag {
7b6c9b99 19 const struct socket_function_table *fn;
8eebd221 20 /* the above variable absolutely *must* be the first in this structure */
21
22 char * error;
23
24 Socket sub_socket;
25 Plug plug;
26 SockAddr remote_addr;
27 int remote_port;
28
29 bufchain pending_output_data;
30 bufchain pending_oob_output_data;
31 int pending_flush;
32 bufchain pending_input_data;
bc06669b 33 int pending_eof;
8eebd221 34
35#define PROXY_STATE_NEW -1
36#define PROXY_STATE_ACTIVE 0
37
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
41 * proxy server.
42 */
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.
46 */
47
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
53
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.
59 */
60
61 int (*negotiate) (Proxy_Socket /* this */, int /* change type */);
62
63 /* current arguments of plug handlers
64 * (for use by proxy's negotiate function)
65 */
66
67 /* closing */
cbe2d68f 68 const char *closing_error_msg;
8eebd221 69 int closing_error_code;
70 int closing_calling_back;
71
72 /* receive */
73 int receive_urgent;
74 char *receive_data;
75 int receive_len;
76
77 /* sent */
78 int sent_bufsize;
79
80 /* accepting */
f7f9fb5c 81 OSSocket accepting_sock;
8eebd221 82
e8fa8f62 83 /* configuration, used to look up proxy settings */
4a693cfc 84 Conf *conf;
f33ba69e 85
86 /* CHAP transient data */
87 int chap_num_attributes;
88 int chap_num_attributes_processed;
89 int chap_current_attribute;
90 int chap_current_datalen;
8eebd221 91};
92
93typedef struct Plug_proxy_tag * Proxy_Plug;
94
95struct Plug_proxy_tag {
7b6c9b99 96 const struct plug_function_table *fn;
8eebd221 97 /* the above variable absolutely *must* be the first in this structure */
98
99 Proxy_Socket proxy_socket;
100
101};
102
103extern void proxy_activate (Proxy_Socket);
104
105extern int proxy_http_negotiate (Proxy_Socket, int);
106extern int proxy_telnet_negotiate (Proxy_Socket, int);
6971bbe7 107extern int proxy_socks4_negotiate (Proxy_Socket, int);
108extern int proxy_socks5_negotiate (Proxy_Socket, int);
8eebd221 109
0f0a2507 110/*
111 * This may be reused by local-command proxies on individual
112 * platforms.
113 */
4a693cfc 114char *format_telnet_command(SockAddr addr, int port, Conf *conf);
0f0a2507 115
f33ba69e 116/*
117 * These are implemented in cproxy.c or nocproxy.c, depending on
118 * whether encrypted proxy authentication is available.
119 */
120extern void proxy_socks5_offerencryptedauth(char *command, int *len);
121extern int proxy_socks5_handlechap (Proxy_Socket p);
122extern int proxy_socks5_selectchap(Proxy_Socket p);
123
8eebd221 124#endif