-fixes
[oweals/gnunet.git] / src / gns / gnocksy / protocol.h
1
2
3 /* The socks phases */
4 enum
5 {
6   SOCKS5_INIT,
7   SOCKS5_REQUEST,
8   SOCKS5_DATA_TRANSFER
9 };
10
11 /* Client hello */
12 struct socks5_client_hello
13 {
14   uint8_t version;
15   uint8_t num_auth_methods;
16   char* auth_methods;
17 };
18
19 /* Client socks request */
20 struct socks5_client_request
21 {
22   uint8_t version;
23   uint8_t command;
24   uint8_t resvd;
25   uint8_t addr_type;
26   /* 
27    * followed by either an ip4/ipv6 address
28    * or a domain name with a length field in front
29    */
30 };
31
32 /* Server hello */
33 struct socks5_server_hello
34 {
35   uint8_t version;
36   uint8_t auth_method;
37 };
38
39 #define BUF_WAIT_FOR_CURL 0
40 #define BUF_WAIT_FOR_MHD  1
41
42 /* Struct used to store connection
43  * information
44  */
45 struct socks5_bridge
46 {
47   int fd;
48   struct socks5_bridge* remote_end;
49   struct sockaddr addr;
50   socklen_t addr_len;
51   char host[256];
52   int status;
53
54   /* This is an ssl bridge? */
55   int use_ssl;
56
57   /* if use_ssl=1 we have a daemon associated */
58   struct MHD_Daemon *ssl_daemon;
59   
60   /* http url + host */
61   char* full_url;
62
63   /* handle to curl */
64   CURL* curl;
65
66   /* is response html? */
67   int res_is_html;
68
69   /* buffer structures */
70   pthread_t thread;
71   pthread_mutex_t m_done;
72   int is_done;
73   pthread_mutex_t m_buf;
74   char MHD_CURL_BUF[CURL_MAX_WRITE_SIZE];
75   size_t MHD_CURL_BUF_SIZE;
76   int MHD_CURL_BUF_STATUS;
77 };
78
79 /* Server response to client requests */
80 struct socks5_server_response
81 {
82   uint8_t version;
83   uint8_t reply;
84   uint8_t reserved;
85   uint8_t addr_type;
86   uint8_t add_port[18];
87 };