1/*
2 *  OpenVPN -- An application to securely tunnel IP networks
3 *             over a single TCP/UDP port, with support for SSL/TLS-based
4 *             session authentication and key exchange,
5 *             packet encryption, packet authentication, and
6 *             packet compression.
7 *
8 *  Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
9 *
10 *  This program is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 2
12 *  as published by the Free Software Foundation.
13 *
14 *  This program is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this program (see the file COPYING included with this
21 *  distribution); if not, write to the Free Software Foundation, Inc.,
22 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 */
24
25/*
26 * 2004-01-30: Added Socks5 proxy support
27 *   (Christof Meerwald, http://cmeerw.org)
28 */
29
30#ifndef SOCKS_H
31#define SOCKS_H
32
33#ifdef ENABLE_SOCKS
34
35#include "buffer.h"
36
37struct openvpn_sockaddr;
38struct link_socket_actual;
39
40struct socks_proxy_info {
41  bool defined;
42  bool retry;
43
44  char server[128];
45  int port;
46  char authfile[256];
47};
48
49void socks_adjust_frame_parameters (struct frame *frame, int proto);
50
51struct socks_proxy_info *socks_proxy_new (const char *server,
52					  int port,
53					  const char *authfile,
54					  bool retry);
55
56void socks_proxy_close (struct socks_proxy_info *sp);
57
58void establish_socks_proxy_passthru (struct socks_proxy_info *p,
59				     socket_descriptor_t sd, /* already open to proxy */
60				     const char *host,       /* openvpn server remote */
61				     const int port,         /* openvpn server port */
62				     volatile int *signal_received);
63
64void establish_socks_proxy_udpassoc (struct socks_proxy_info *p,
65				     socket_descriptor_t ctrl_sd, /* already open to proxy */
66				     socket_descriptor_t udp_sd,
67				     struct openvpn_sockaddr *relay_addr,
68				     volatile int *signal_received);
69
70void socks_process_incoming_udp (struct buffer *buf,
71				struct link_socket_actual *from);
72
73int socks_process_outgoing_udp (struct buffer *buf,
74				const struct link_socket_actual *to);
75
76#endif
77#endif
78