OpenVPN
forward.h
Go to the documentation of this file.
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-2018 OpenVPN 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 along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 
31 #ifndef FORWARD_H
32 #define FORWARD_H
33 
34 #include "openvpn.h"
35 #include "occ.h"
36 #include "ping.h"
37 
38 #define TUN_OUT(c) (BLEN(&(c)->c2.to_tun) > 0)
39 #define LINK_OUT(c) (BLEN(&(c)->c2.to_link) > 0)
40 #define ANY_OUT(c) (TUN_OUT(c) || LINK_OUT(c))
41 
42 #ifdef ENABLE_FRAGMENT
43 #define TO_LINK_FRAG(c) ((c)->c2.fragment && fragment_outgoing_defined((c)->c2.fragment))
44 #else
45 #define TO_LINK_FRAG(c) (false)
46 #endif
47 
48 #define TO_LINK_DEF(c) (LINK_OUT(c) || TO_LINK_FRAG(c))
49 
50 #define IOW_TO_TUN (1<<0)
51 #define IOW_TO_LINK (1<<1)
52 #define IOW_READ_TUN (1<<2)
53 #define IOW_READ_LINK (1<<3)
54 #define IOW_SHAPER (1<<4)
55 #define IOW_CHECK_RESIDUAL (1<<5)
56 #define IOW_FRAG (1<<6)
57 #define IOW_MBUF (1<<7)
58 #define IOW_READ_TUN_FORCE (1<<8)
59 #define IOW_WAIT_SIGNAL (1<<9)
60 
61 #define IOW_READ (IOW_READ_TUN|IOW_READ_LINK)
62 
63 
64 void pre_select(struct context *c);
65 
66 void process_io(struct context *c);
67 
68 const char *wait_status_string(struct context *c, struct gc_arena *gc);
69 
70 void show_wait_status(struct context *c);
71 
72 
73 /**********************************************************************/
106 void encrypt_sign(struct context *c, bool comp_frag);
107 
108 int get_server_poll_remaining_time(struct event_timeout *server_poll_timeout);
109 
110 /**********************************************************************/
130 void read_incoming_link(struct context *c);
131 
158 bool process_incoming_link_part1(struct context *c, struct link_socket_info *lsi, bool floated);
159 
185 void process_incoming_link_part2(struct context *c, struct link_socket_info *lsi, const uint8_t *orig_buf);
186 
199 void process_outgoing_link(struct context *c);
200 
201 
202 /**************************************************************************/
215 void read_incoming_tun(struct context *c);
216 
217 
230 void process_incoming_tun(struct context *c);
231 
232 
245 void process_outgoing_tun(struct context *c);
246 
247 
248 /**************************************************************************/
249 
250 bool send_control_channel_string(struct context *c, const char *str, int msglevel);
251 
252 #define PIPV4_PASSTOS (1<<0)
253 #define PIP_MSSFIX (1<<1) /* v4 and v6 */
254 #define PIPV4_OUTGOING (1<<2)
255 #define PIPV4_EXTRACT_DHCP_ROUTER (1<<3)
256 #define PIPV4_CLIENT_NAT (1<<4)
257 
258 void process_ip_header(struct context *c, unsigned int flags, struct buffer *buf);
259 
260 #if P2MP
261 void schedule_exit(struct context *c, const int n_seconds, const int signal);
262 
263 #endif
264 
265 #endif /* FORWARD_H */
bool send_control_channel_string(struct context *c, const char *str, int msglevel)
Definition: forward.c:247
Contains all state information for one tunnel.
Definition: openvpn.h:498
void read_incoming_link(struct context *c)
Read a packet from the external network interface.
Definition: forward.c:707
void encrypt_sign(struct context *c, bool comp_frag)
Process a data channel packet that will be sent through a VPN tunnel.
Definition: forward.c:450
list flags
void process_io(struct context *c)
Definition: forward.c:1800
void pre_select(struct context *c)
Definition: forward.c:1538
void process_ip_header(struct context *c, unsigned int flags, struct buffer *buf)
Definition: forward.c:1211
void show_wait_status(struct context *c)
void process_outgoing_link(struct context *c)
Write a packet to the external network interface.
Definition: forward.c:1296
void read_incoming_tun(struct context *c)
Read a packet from the virtual tun/tap network interface.
Definition: forward.c:1017
unsigned __int8 uint8_t
Definition: config-msvc.h:122
Wrapper structure for dynamically allocated memory.
Definition: buffer.h:60
Garbage collection arena used to keep track of dynamically allocated memory.
Definition: buffer.h:116
void process_incoming_link_part2(struct context *c, struct link_socket_info *lsi, const uint8_t *orig_buf)
Continues processing a packet read from the external network interface.
Definition: forward.c:914
int get_server_poll_remaining_time(struct event_timeout *server_poll_timeout)
Definition: forward.c:338
bool process_incoming_link_part1(struct context *c, struct link_socket_info *lsi, bool floated)
Starts processing a packet read from the external network interface.
Definition: forward.c:775
void process_incoming_tun(struct context *c)
Process a packet read from the virtual tun/tap network interface.
Definition: forward.c:1158
const char * wait_status_string(struct context *c, struct gc_arena *gc)
void process_outgoing_tun(struct context *c)
Write a packet to the virtual tun/tap network interface.
Definition: forward.c:1447
void schedule_exit(struct context *c, const int n_seconds, const int signal)
Definition: forward.c:363