Bump copyright date to 2019
[tor.git] / src / core / or / socks_request_st.h
blob5922870c6185f5d1c1511f40548039e830f754c8
1 /* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 #ifndef SOCKS_REQUEST_ST_H
8 #define SOCKS_REQUEST_ST_H
10 #define MAX_SOCKS_REPLY_LEN 1024
12 #define SOCKS_NO_AUTH 0x00
13 #define SOCKS_USER_PASS 0x02
15 /** Please open a TCP connection to this addr:port. */
16 #define SOCKS_COMMAND_CONNECT 0x01
17 /** Please turn this FQDN into an IP address, privately. */
18 #define SOCKS_COMMAND_RESOLVE 0xF0
19 /** Please turn this IP address into an FQDN, privately. */
20 #define SOCKS_COMMAND_RESOLVE_PTR 0xF1
22 /* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
23 #define SOCKS_COMMAND_IS_CONNECT(c) (((c)==SOCKS_COMMAND_CONNECT) || 0)
24 #define SOCKS_COMMAND_IS_RESOLVE(c) ((c)==SOCKS_COMMAND_RESOLVE || \
25 (c)==SOCKS_COMMAND_RESOLVE_PTR)
27 /** State of a SOCKS request from a user to an OP. Also used to encode other
28 * information for non-socks user request (such as those on TransPort and
29 * DNSPort) */
30 struct socks_request_t {
31 /** Which version of SOCKS did the client use? One of "0, 4, 5" -- where
32 * 0 means that no socks handshake ever took place, and this is just a
33 * stub connection (e.g. see connection_ap_make_link()). */
34 uint8_t socks_version;
35 /** If using socks5 authentication, which authentication type did we
36 * negotiate? currently we support 0 (no authentication) and 2
37 * (username/password). */
38 uint8_t auth_type;
39 /** What is this stream's goal? One of the SOCKS_COMMAND_* values */
40 uint8_t command;
41 /** Which kind of listener created this stream? */
42 uint8_t listener_type;
43 size_t replylen; /**< Length of <b>reply</b>. */
44 uint8_t reply[MAX_SOCKS_REPLY_LEN]; /**< Write an entry into this string if
45 * we want to specify our own socks reply,
46 * rather than using the default socks4 or
47 * socks5 socks reply. We use this for the
48 * two-stage socks5 handshake.
50 char address[MAX_SOCKS_ADDR_LEN]; /**< What address did the client ask to
51 connect to/resolve? */
52 uint16_t port; /**< What port did the client ask to connect to? */
53 unsigned int has_finished : 1; /**< Has the SOCKS handshake finished? Used to
54 * make sure we send back a socks reply for
55 * every connection. */
56 unsigned int got_auth : 1; /**< Have we received any authentication data? */
57 /** If this is set, we will choose "no authentication" instead of
58 * "username/password" authentication if both are offered. Used as input to
59 * parse_socks. */
60 unsigned int socks_prefer_no_auth : 1;
62 /** Number of bytes in username; 0 if username is NULL */
63 size_t usernamelen;
64 /** Number of bytes in password; 0 if password is NULL */
65 uint8_t passwordlen;
66 /** The negotiated username value if any (for socks5), or the entire
67 * authentication string (for socks4). This value is NOT nul-terminated;
68 * see usernamelen for its length. */
69 char *username;
70 /** The negotiated password value if any (for socks5). This value is NOT
71 * nul-terminated; see passwordlen for its length. */
72 char *password;
74 uint8_t socks5_atyp; /* SOCKS5 address type */
77 #endif