BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /**
2 * @file socks_proto.h
3 * @author Ambroz Bizjak <ambrop7@gmail.com>
4 *
5 * @section LICENSE
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the author nor the
15 * names of its contributors may be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * @section DESCRIPTION
30 *
31 * Definitions for the SOCKS protocol.
32 */
33  
34 #ifndef BADVPN_MISC_SOCKS_PROTO_H
35 #define BADVPN_MISC_SOCKS_PROTO_H
36  
37 #include <stdint.h>
38  
39 #include <misc/packed.h>
40  
41 #define SOCKS_VERSION 0x05
42  
43 #define SOCKS_METHOD_NO_AUTHENTICATION_REQUIRED 0x00
44 #define SOCKS_METHOD_GSSAPI 0x01
45 #define SOCKS_METHOD_USERNAME_PASSWORD 0x02
46 #define SOCKS_METHOD_NO_ACCEPTABLE_METHODS 0xFF
47  
48 #define SOCKS_CMD_CONNECT 0x01
49 #define SOCKS_CMD_BIND 0x02
50 #define SOCKS_CMD_UDP_ASSOCIATE 0x03
51  
52 #define SOCKS_ATYP_IPV4 0x01
53 #define SOCKS_ATYP_DOMAINNAME 0x03
54 #define SOCKS_ATYP_IPV6 0x04
55  
56 #define SOCKS_REP_SUCCEEDED 0x00
57 #define SOCKS_REP_GENERAL_FAILURE 0x01
58 #define SOCKS_REP_CONNECTION_NOT_ALLOWED 0x02
59 #define SOCKS_REP_NETWORK_UNREACHABLE 0x03
60 #define SOCKS_REP_HOST_UNREACHABLE 0x04
61 #define SOCKS_REP_CONNECTION_REFUSED 0x05
62 #define SOCKS_REP_TTL_EXPIRED 0x06
63 #define SOCKS_REP_COMMAND_NOT_SUPPORTED 0x07
64 #define SOCKS_REP_ADDRESS_TYPE_NOT_SUPPORTED 0x08
65  
66 B_START_PACKED
67 struct socks_client_hello_header {
68 uint8_t ver;
69 uint8_t nmethods;
70 } B_PACKED;
71 B_END_PACKED
72  
73 B_START_PACKED
74 struct socks_client_hello_method {
75 uint8_t method;
76 } B_PACKED;
77 B_END_PACKED
78  
79 B_START_PACKED
80 struct socks_server_hello {
81 uint8_t ver;
82 uint8_t method;
83 } B_PACKED;
84 B_END_PACKED
85  
86 B_START_PACKED
87 struct socks_request_header {
88 uint8_t ver;
89 uint8_t cmd;
90 uint8_t rsv;
91 uint8_t atyp;
92 } B_PACKED;
93 B_END_PACKED
94  
95 B_START_PACKED
96 struct socks_reply_header {
97 uint8_t ver;
98 uint8_t rep;
99 uint8_t rsv;
100 uint8_t atyp;
101 } B_PACKED;
102 B_END_PACKED
103  
104 B_START_PACKED
105 struct socks_addr_ipv4 {
106 uint32_t addr;
107 uint16_t port;
108 } B_PACKED;
109 B_END_PACKED
110  
111 B_START_PACKED
112 struct socks_addr_ipv6 {
113 uint8_t addr[16];
114 uint16_t port;
115 } B_PACKED;
116 B_END_PACKED
117  
118 B_START_PACKED
119 struct socks_udp_header {
120 uint16_t rsv;
121 uint8_t frag;
122 uint8_t atyp;
123 } B_PACKED;
124 B_END_PACKED
125  
126 #endif