| 1 |
/* |
| 2 |
protocol.h -- header for protocol.C |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License as published by |
| 6 |
the Free Software Foundation; either version 2 of the License, or |
| 7 |
(at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef VPE_PROTOCOL_H__ |
| 20 |
#define VPE_PROTOCOL_H__ |
| 21 |
|
| 22 |
#include <netinet/in.h> |
| 23 |
|
| 24 |
#include <openssl/evp.h> |
| 25 |
#include <openssl/rsa.h> |
| 26 |
|
| 27 |
#include "conf.h" |
| 28 |
#include "iom.h" |
| 29 |
#include "util.h" |
| 30 |
#include "sockinfo.h" |
| 31 |
#include "device.h" |
| 32 |
#include "connection.h" |
| 33 |
|
| 34 |
struct vpn |
| 35 |
{ |
| 36 |
int udpv4_fd; |
| 37 |
int ipv4_fd; |
| 38 |
|
| 39 |
int events; |
| 40 |
|
| 41 |
enum { |
| 42 |
EVENT_RECONNECT = 1, |
| 43 |
EVENT_SHUTDOWN = 2, |
| 44 |
}; |
| 45 |
|
| 46 |
void event_cb (tstamp &ts); time_watcher event; |
| 47 |
|
| 48 |
tap_device *tap; |
| 49 |
|
| 50 |
typedef vector<connection *> conns_vector; |
| 51 |
conns_vector conns; |
| 52 |
|
| 53 |
connection *find_router (); |
| 54 |
|
| 55 |
void reconnect_all (); |
| 56 |
void shutdown_all (); |
| 57 |
void connect_request (int id); |
| 58 |
|
| 59 |
void tap_ev (short revents); io_watcher tap_ev_watcher; |
| 60 |
void ipv4_ev (short revents); io_watcher ipv4_ev_watcher; |
| 61 |
void udpv4_ev (short revents); io_watcher udpv4_ev_watcher; |
| 62 |
|
| 63 |
void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi); |
| 64 |
|
| 65 |
void send_udpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos = IPTOS_RELIABILITY); |
| 66 |
void send_ipv4_packet (vpn_packet *pkt, const sockinfo &si, int tos = IPTOS_RELIABILITY); |
| 67 |
|
| 68 |
vpn (); |
| 69 |
~vpn (); |
| 70 |
|
| 71 |
int setup (); |
| 72 |
|
| 73 |
void dump_status (); |
| 74 |
|
| 75 |
const char *script_if_up (int); |
| 76 |
}; |
| 77 |
|
| 78 |
#endif |
| 79 |
|