ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/vpn.h
(Generate patch)

Comparing gvpe/src/vpn.h (file contents):
Revision 1.7 by pcg, Tue Apr 8 02:00:54 2003 UTC vs.
Revision 1.32 by root, Sat Dec 17 22:05:34 2011 UTC

1/* 1/*
2 vpn.h -- header for vpn.C 2 vpn.h -- header for vpn.C
3 Copyright (C) 2003-2008 Marc Lehmann <gvpe@schmorp.de>
3 4
5 This file is part of GVPE.
6
4 This program is free software; you can redistribute it and/or modify 7 GVPE is free software; you can redistribute it and/or modify it
5 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
6 the Free Software Foundation; either version 2 of the License, or 9 Free Software Foundation; either version 3 of the License, or (at your
7 (at your option) any later version. 10 option) any later version.
8 11
9 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
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12 GNU General Public License for more details. 15 Public License for more details.
13 16
14 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
15 along with this program; if not, write to the Free Software 18 with this program; if not, see <http://www.gnu.org/licenses/>.
16 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 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.
17*/ 30*/
18 31
19#ifndef VPE_VPN_H__ 32#ifndef GVPE_VPN_H__
20#define VPE_VPN_H__ 33#define GVPE_VPN_H__
21
22#include <netinet/ip.h>
23 34
24#include "global.h" 35#include "global.h"
25#include "conf.h" 36#include "conf.h"
26#include "device.h" 37#include "device.h"
27#include "connection.h" 38#include "connection.h"
28 39
29struct vpn 40struct vpn
30 { 41{
31 int udpv4_fd, tcpv4_fd, ipv4_fd, icmpv4_fd; 42 int udpv4_fd , tcpv4_fd, ipv4_fd , icmpv4_fd , dnsv4_fd;
43 int udpv4_tos, ipv4_tos, icmpv4_tos, dnsv4_tos;
32 44
33 int events; 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
34 50
35 enum { 51 int events;
36 EVENT_RECONNECT = 1,
37 EVENT_SHUTDOWN = 2,
38 };
39 52
40 void event_cb (time_watcher &w); time_watcher event; 53 enum {
54 EVENT_RECONNECT = 1,
55 EVENT_SHUTDOWN = 2,
56 };
41 57
42 tap_device *tap; 58 void event_cb (ev::timer &w, int revents); ev::timer event;
43 59
44 typedef vector<connection *> conns_vector; 60 tap_device *tap;
45 conns_vector conns;
46 61
47 connection *find_router (); 62 typedef vector<connection *> conns_vector;
63 conns_vector conns;
48 64
49 void reconnect_all (); 65 // called when any conenction has been established
50 void shutdown_all (); 66 void connection_established (connection *c);
51 67
52 void tap_ev (io_watcher &w, short revents); io_watcher tap_ev_watcher; 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);
53 71
54 void send_connect_request (int id); 72 void reconnect_all ();
73 void shutdown_all ();
55 74
75 void tap_ev (ev::io &w, int revents); ev::io tap_ev_watcher;
76 void inject_data_packet (tap_packet *pkt, int dst);
77
78 void send_connect_request (connection *c);
79
56 void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi); 80 void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi);
57 bool send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos); 81 bool send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos = 0);
58 82
59#if ENABLE_TCP 83#if ENABLE_TCP
60 void tcpv4_ev (io_watcher &w, short revents); io_watcher tcpv4_ev_watcher; 84 void tcpv4_ev (ev::io &w, int revents); ev::io tcpv4_ev_watcher;
61 bool send_tcpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); 85 bool send_tcpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos);
62#endif 86#endif
63 87
64#if ENABLE_ICMP 88#if ENABLE_ICMP
65 void icmpv4_ev (io_watcher &w, short revents); io_watcher icmpv4_ev_watcher; 89 void icmpv4_ev (ev::io &w, int revents); ev::io icmpv4_ev_watcher;
66 bool send_icmpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); 90 bool send_icmpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos);
67#endif 91#endif
68 92
69 void udpv4_ev (io_watcher &w, short revents); io_watcher udpv4_ev_watcher; 93#if ENABLE_DNS
70 bool send_udpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); 94 vector<struct dns_snd *> dns_sndpq;
95 sockinfo dns_forwarder;
71 96
72 void ipv4_ev (io_watcher &w, short revents); io_watcher ipv4_ev_watcher; 97 void dnsv4_ev (ev::io &w, int revents); ev::io dnsv4_ev_watcher;
73 bool send_ipv4_packet (vpn_packet *pkt, const sockinfo &si, int tos); 98 void dnsv4_server (struct dns_packet &pkt);
99 void dnsv4_client (struct dns_packet &pkt);
74 100
75 vpn (); 101 bool send_dnsv4_packet (vpn_packet *pkt, const sockinfo &si, int tos);
76 ~vpn (); 102#endif
77 103
78 int setup (); 104 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);
79 106
80 void dump_status (); 107 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);
81 109
110 vpn ();
111 ~vpn ();
112
113 int setup_socket (u8 prot, int family, int type, int proto);
114 int setup ();
115
116 void dump_status ();
117
118 void script_init_env ();
119 const char *script_if_init ();
82 const char *script_if_up (); 120 const char *script_if_up ();
83 }; 121};
122
123extern vpn network; // THE vpn
84 124
85#endif 125#endif
86 126

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines