Tor 0.4.9.0-alpha-dev
socks_request_st.h
Go to the documentation of this file.
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-2021, The Tor Project, Inc. */
5/* See LICENSE for licensing information */
6
7/**
8 * @file socks_request_st.h
9 * @brief Client request structure.
10 **/
11
12#ifndef SOCKS_REQUEST_ST_H
13#define SOCKS_REQUEST_ST_H
14
16
17#define MAX_SOCKS_REPLY_LEN 1024
18
19#define SOCKS_NO_AUTH 0x00
20#define SOCKS_USER_PASS 0x02
21
22/** Please open a TCP connection to this addr:port. */
23#define SOCKS_COMMAND_CONNECT 0x01
24/** Please turn this FQDN into an IP address, privately. */
25#define SOCKS_COMMAND_RESOLVE 0xF0
26/** Please turn this IP address into an FQDN, privately. */
27#define SOCKS_COMMAND_RESOLVE_PTR 0xF1
28
29/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
30#define SOCKS_COMMAND_IS_CONNECT(c) (((c)==SOCKS_COMMAND_CONNECT) || 0)
31#define SOCKS_COMMAND_IS_RESOLVE(c) ((c)==SOCKS_COMMAND_RESOLVE || \
32 (c)==SOCKS_COMMAND_RESOLVE_PTR)
33
34/** State of a SOCKS request from a user to an OP. Also used to encode other
35 * information for non-socks user request (such as those on TransPort and
36 * DNSPort) */
38 /** Which version of SOCKS did the client use? One of "0, 4, 5" -- where
39 * 0 means that no socks handshake ever took place, and this is just a
40 * stub connection (e.g. see connection_ap_make_link()). */
42 /** If using socks5 authentication, which authentication type did we
43 * negotiate? currently we support 0 (no authentication) and 2
44 * (username/password). */
45 uint8_t auth_type;
46 /** What is this stream's goal? One of the SOCKS_COMMAND_* values */
47 uint8_t command;
48 /** Which kind of listener created this stream? */
50 size_t replylen; /**< Length of <b>reply</b>. */
51 uint8_t reply[MAX_SOCKS_REPLY_LEN]; /**< Write an entry into this string if
52 * we want to specify our own socks reply,
53 * rather than using the default socks4 or
54 * socks5 socks reply. We use this for the
55 * two-stage socks5 handshake.
56 */
57 char address[MAX_SOCKS_ADDR_LEN]; /**< What address did the client ask to
58 connect to/resolve? */
59 uint16_t port; /**< What port did the client ask to connect to? */
60 unsigned int has_finished : 1; /**< Has the SOCKS handshake finished? Used to
61 * make sure we send back a socks reply for
62 * every connection. */
63 unsigned int got_auth : 1; /**< Have we received any authentication data? */
64 /** If this is set, we will choose "no authentication" instead of
65 * "username/password" authentication if both are offered. Used as input to
66 * parse_socks. */
67 unsigned int socks_prefer_no_auth : 1;
68 /** If set, we can send back the extended error code in the reply. */
69 unsigned int socks_use_extended_errors : 1;
70 /** If non zero, this contains the extended error code that should be used
71 * if the port was configured to use them. */
73
74 /** Number of bytes in username; 0 if username is NULL */
76 /** Number of bytes in password; 0 if password is NULL */
77 uint8_t passwordlen;
78 /** The negotiated username value if any (for socks5), or the entire
79 * authentication string (for socks4). This value is NOT nul-terminated;
80 * see usernamelen for its length. */
81 char *username;
82 /** The negotiated password value if any (for socks5). This value is NOT
83 * nul-terminated; see passwordlen for its length. */
84 char *password;
85
86 uint8_t socks5_atyp; /* SOCKS5 address type */
87};
88
89#endif /* !defined(SOCKS_REQUEST_ST_H) */
Status codes used by the SOCKS5 protocol.
socks5_reply_status_t
Definition: socks5_status.h:20
unsigned int has_finished
unsigned int socks_prefer_no_auth
unsigned int got_auth
unsigned int socks_use_extended_errors
uint8_t reply[MAX_SOCKS_REPLY_LEN]
socks5_reply_status_t socks_extended_error_code
char address[MAX_SOCKS_ADDR_LEN]