1 | /* |
1 | /* |
2 | vpn.h -- header for vpn.C |
2 | vpn.h -- header for vpn.C |
3 | Copyright (C) 2003-2005 Marc Lehmann <gvpe@schmorp.de> |
3 | Copyright (C) 2003-2008 Marc Lehmann <gvpe@schmorp.de> |
4 | |
4 | |
5 | This file is part of GVPE. |
5 | This file is part of GVPE. |
6 | |
6 | |
7 | GVPE is free software; you can redistribute it and/or modify |
7 | GVPE is free software; you can redistribute it and/or modify it |
8 | it under the terms of the GNU General Public License as published by |
8 | under the terms of the GNU General Public License as published by the |
9 | the Free Software Foundation; either version 2 of the License, or |
9 | Free Software Foundation; either version 3 of the License, or (at your |
10 | (at your option) any later version. |
10 | option) any later version. |
11 | |
11 | |
12 | This program is distributed in the hope that it will be useful, |
12 | This program is distributed in the hope that it will be useful, but |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
15 | GNU General Public License for more details. |
15 | Public License for more details. |
16 | |
16 | |
17 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License along |
18 | along with gvpe; if not, write to the Free Software |
18 | with this program; if not, see <http://www.gnu.org/licenses/>. |
19 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | |
|
|
20 | Additional permission under GNU GPL version 3 section 7 |
|
|
21 | |
|
|
22 | If you modify this Program, or any covered work, by linking or |
|
|
23 | combining it with the OpenSSL project's OpenSSL library (or a modified |
|
|
24 | version of that library), containing parts covered by the terms of the |
|
|
25 | OpenSSL or SSLeay licenses, the licensors of this Program grant you |
|
|
26 | additional permission to convey the resulting work. Corresponding |
|
|
27 | Source for a non-source form of such a combination shall include the |
|
|
28 | source code for the parts of OpenSSL used as well as that of the |
|
|
29 | covered work. |
20 | */ |
30 | */ |
21 | |
31 | |
22 | #ifndef GVPE_VPN_H__ |
32 | #ifndef GVPE_VPN_H__ |
23 | #define GVPE_VPN_H__ |
33 | #define GVPE_VPN_H__ |
24 | |
34 | |
… | |
… | |
30 | struct vpn |
40 | struct vpn |
31 | { |
41 | { |
32 | int udpv4_fd , tcpv4_fd, ipv4_fd , icmpv4_fd , dnsv4_fd; |
42 | int udpv4_fd , tcpv4_fd, ipv4_fd , icmpv4_fd , dnsv4_fd; |
33 | int udpv4_tos, ipv4_tos, icmpv4_tos, dnsv4_tos; |
43 | int udpv4_tos, ipv4_tos, icmpv4_tos, dnsv4_tos; |
34 | |
44 | |
|
|
45 | #if 1 //D |
|
|
46 | int ipv42_fd, ipv42_tos; |
|
|
47 | void ipv42_ev (ev::io &w, int revents); ev::io ipv42_ev_watcher; |
|
|
48 | bool send_ipv42_packet (vpn_packet *pkt, const sockinfo &si, int tos); |
|
|
49 | #endif |
|
|
50 | |
35 | int events; |
51 | int events; |
36 | |
52 | |
37 | enum { |
53 | enum { |
38 | EVENT_RECONNECT = 1, |
54 | EVENT_RECONNECT = 1, |
39 | EVENT_SHUTDOWN = 2, |
55 | EVENT_SHUTDOWN = 2, |
… | |
… | |
44 | tap_device *tap; |
60 | tap_device *tap; |
45 | |
61 | |
46 | typedef vector<connection *> conns_vector; |
62 | typedef vector<connection *> conns_vector; |
47 | conns_vector conns; |
63 | conns_vector conns; |
48 | |
64 | |
49 | connection *find_router (); |
65 | // called when any conenction has been established |
50 | connection *find_forwarder (); |
66 | void connection_established (connection *c); |
|
|
67 | |
|
|
68 | // return true if src can connect directly to dst |
|
|
69 | bool can_direct (conf_node *src, conf_node *dst) const; |
|
|
70 | connection *find_router_for (const connection *dst); |
51 | |
71 | |
52 | void reconnect_all (); |
72 | void reconnect_all (); |
53 | void shutdown_all (); |
73 | void shutdown_all (); |
54 | |
74 | |
55 | void tap_ev (ev::io &w, int revents); ev::io tap_ev_watcher; |
75 | void tap_ev (ev::io &w, int revents); ev::io tap_ev_watcher; |
56 | void inject_data_packet (tap_packet *pkt, int dst); |
76 | void inject_data_packet (tap_packet *pkt, int dst); |
57 | |
77 | |
58 | void send_connect_request (int id); |
78 | void send_connect_request (connection *c); |
59 | |
79 | |
60 | void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi); |
80 | void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi); |
61 | bool send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos = 0); |
81 | bool send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos = 0); |
62 | |
82 | |
63 | #if ENABLE_TCP |
83 | #if ENABLE_TCP |
… | |
… | |
88 | bool send_ipv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); |
108 | bool send_ipv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); |
89 | |
109 | |
90 | vpn (); |
110 | vpn (); |
91 | ~vpn (); |
111 | ~vpn (); |
92 | |
112 | |
|
|
113 | int setup_socket (u8 prot, int family, int type, int proto); |
93 | int setup (); |
114 | int setup (); |
94 | |
115 | |
95 | void dump_status (); |
116 | void dump_status (); |
96 | |
117 | |
97 | void script_init_env (); |
118 | void script_init_env (); |