ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/vpn.h
Revision: 1.32
Committed: Sat Dec 17 22:05:34 2011 UTC (12 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.31: +6 -0 lines
Log Message:
ipv42_hack

File Contents

# User Rev Content
1 pcg 1.1 /*
2     vpn.h -- header for vpn.C
3 pcg 1.28 Copyright (C) 2003-2008 Marc Lehmann <gvpe@schmorp.de>
4 pcg 1.1
5 pcg 1.18 This file is part of GVPE.
6    
7 pcg 1.28 GVPE is free software; you can redistribute it and/or modify it
8     under the terms of the GNU General Public License as published by the
9     Free Software Foundation; either version 3 of the License, or (at your
10     option) any later version.
11    
12     This program is distributed in the hope that it will be useful, but
13     WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15     Public License for more details.
16    
17     You should have received a copy of the GNU General Public License along
18     with this program; if not, see <http://www.gnu.org/licenses/>.
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.
30 pcg 1.1 */
31    
32 pcg 1.22 #ifndef GVPE_VPN_H__
33     #define GVPE_VPN_H__
34 pcg 1.1
35 pcg 1.2 #include "global.h"
36 pcg 1.1 #include "conf.h"
37     #include "device.h"
38     #include "connection.h"
39    
40     struct vpn
41 pcg 1.26 {
42 pcg 1.27 int udpv4_fd , tcpv4_fd, ipv4_fd , icmpv4_fd , dnsv4_fd;
43     int udpv4_tos, ipv4_tos, icmpv4_tos, dnsv4_tos;
44 pcg 1.26
45 root 1.32 #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    
51 pcg 1.26 int events;
52    
53     enum {
54     EVENT_RECONNECT = 1,
55     EVENT_SHUTDOWN = 2,
56     };
57 pcg 1.1
58 pcg 1.26 void event_cb (ev::timer &w, int revents); ev::timer event;
59 pcg 1.1
60 pcg 1.26 tap_device *tap;
61 pcg 1.1
62 pcg 1.26 typedef vector<connection *> conns_vector;
63     conns_vector conns;
64 pcg 1.1
65 pcg 1.29 // called when any conenction has been established
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);
71 pcg 1.1
72 pcg 1.26 void reconnect_all ();
73     void shutdown_all ();
74 pcg 1.1
75 pcg 1.26 void tap_ev (ev::io &w, int revents); ev::io tap_ev_watcher;
76     void inject_data_packet (tap_packet *pkt, int dst);
77 pcg 1.1
78 pcg 1.30 void send_connect_request (connection *c);
79 pcg 1.2
80 pcg 1.26 void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi);
81     bool send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos = 0);
82 pcg 1.4
83 pcg 1.2 #if ENABLE_TCP
84 pcg 1.26 void tcpv4_ev (ev::io &w, int revents); ev::io tcpv4_ev_watcher;
85     bool send_tcpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos);
86 pcg 1.7 #endif
87    
88     #if ENABLE_ICMP
89 pcg 1.26 void icmpv4_ev (ev::io &w, int revents); ev::io icmpv4_ev_watcher;
90     bool send_icmpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos);
91 pcg 1.14 #endif
92    
93     #if ENABLE_DNS
94 pcg 1.26 vector<struct dns_snd *> dns_sndpq;
95     sockinfo dns_forwarder;
96 pcg 1.16
97 pcg 1.26 void dnsv4_ev (ev::io &w, int revents); ev::io dnsv4_ev_watcher;
98     void dnsv4_server (struct dns_packet &pkt);
99     void dnsv4_client (struct dns_packet &pkt);
100 pcg 1.21
101 pcg 1.26 bool send_dnsv4_packet (vpn_packet *pkt, const sockinfo &si, int tos);
102 pcg 1.2 #endif
103 pcg 1.1
104 pcg 1.26 void udpv4_ev (ev::io &w, int revents); ev::io udpv4_ev_watcher;
105     bool send_udpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos);
106 pcg 1.2
107 pcg 1.26 void ipv4_ev (ev::io &w, int revents); ev::io ipv4_ev_watcher;
108     bool send_ipv4_packet (vpn_packet *pkt, const sockinfo &si, int tos);
109 pcg 1.1
110 pcg 1.26 vpn ();
111     ~vpn ();
112 pcg 1.1
113 pcg 1.31 int setup_socket (u8 prot, int family, int type, int proto);
114 pcg 1.26 int setup ();
115 pcg 1.1
116 pcg 1.26 void dump_status ();
117 pcg 1.1
118 pcg 1.26 void script_init_env ();
119     const char *script_if_init ();
120     const char *script_if_up ();
121     };
122 pcg 1.10
123 pcg 1.12 extern vpn network; // THE vpn
124 pcg 1.1
125     #endif
126