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

Comparing gvpe/src/protocol.h (file contents):
Revision 1.9 by pcg, Wed Mar 26 14:39:52 2003 UTC vs.
Revision 1.13 by pcg, Wed Apr 2 03:06:22 2003 UTC

18 18
19#ifndef VPE_PROTOCOL_H__ 19#ifndef VPE_PROTOCOL_H__
20#define VPE_PROTOCOL_H__ 20#define VPE_PROTOCOL_H__
21 21
22#include <netinet/in.h> 22#include <netinet/in.h>
23#include <netinet/ip.h> // for tos etc.
24 23
25#include <openssl/evp.h> 24#include <openssl/evp.h>
26#include <openssl/rsa.h> 25#include <openssl/rsa.h>
27 26
28#include "conf.h" 27#include "conf.h"
29#include "iom.h" 28#include "iom.h"
30#include "util.h" 29#include "util.h"
30#include "sockinfo.h"
31#include "device.h" 31#include "device.h"
32 32#include "connection.h"
33/* Protocol version. Different major versions are incompatible,
34 * different minor versions probably are compatible ;)
35 */
36
37#define PROTOCOL_MAJOR 0
38#define PROTOCOL_MINOR 0
39
40struct vpn;
41struct vpn_packet;
42
43struct rsaid {
44 u8 id[RSA_IDLEN]; // the challenge id
45};
46
47typedef u8 rsachallenge[RSA_KEYLEN - RSA_OVERHEAD]; // challenge data;
48typedef u8 rsaencrdata[RSA_KEYLEN]; // encrypted challenge
49typedef u8 rsaresponse[RSA_RESLEN]; // the encrypted ripemd160 hash
50
51struct crypto_ctx;
52
53// a very simple fifo pkt-queue
54class pkt_queue
55 {
56 tap_packet *queue[QUEUEDEPTH];
57 int i, j;
58
59 public:
60
61 void put (tap_packet *p);
62 tap_packet *get ();
63
64 pkt_queue ();
65 ~pkt_queue ();
66 };
67
68struct connection
69 {
70 conf_node *conf;
71 struct vpn *vpn;
72
73 SOCKADDR sa; // the current(!) destination ip to send packets to
74 int retry_cnt;
75
76 tstamp last_activity; // time of last packet received
77
78 u32 oseqno;
79 sliding_window iseqno;
80
81 pkt_queue queue;
82
83 crypto_ctx *octx, *ictx;
84
85 enum conf_node::connectmode connectmode;
86 u8 prot_minor; // minor number of other side
87
88 void reset_dstaddr ();
89
90 void shutdown ();
91 void reset_connection ();
92 void establish_connection_cb (tstamp &ts); time_watcher establish_connection;
93 void rekey_cb (tstamp &ts); time_watcher rekey; // next rekying (actually current reset + reestablishing)
94 void keepalive_cb (tstamp &ts); time_watcher keepalive; // next keepalive probe
95
96 void send_auth_request (SOCKADDR *sa, bool initiate);
97 void send_auth_response (SOCKADDR *sa, const rsaid &id, const rsachallenge &chg);
98 void send_reset (SOCKADDR *dsa);
99 void send_ping (SOCKADDR *dss, u8 pong = 0);
100 void send_data_packet (tap_packet *pkt, bool broadcast = false);
101 void inject_data_packet (tap_packet *pkt, bool broadcast = false);
102 void connect_request (int id);
103
104 void recv_vpn_packet (vpn_packet *pkt, SOCKADDR *rsa);
105
106 void script_node ();
107 const char *script_node_up (int);
108 const char *script_node_down (int);
109
110 connection(struct vpn *vpn_);
111 ~connection ();
112 };
113 33
114struct vpn 34struct vpn
115 { 35 {
116 int socket_fd; 36 int udpv4_fd;
37 int ipv4_fd;
38
117 int events; 39 int events;
118 40
119 enum { 41 enum {
120 EVENT_RECONNECT = 1, 42 EVENT_RECONNECT = 1,
121 EVENT_SHUTDOWN = 2, 43 EVENT_SHUTDOWN = 2,
128 typedef vector<connection *> conns_vector; 50 typedef vector<connection *> conns_vector;
129 conns_vector conns; 51 conns_vector conns;
130 52
131 connection *find_router (); 53 connection *find_router ();
132 54
133 void send_vpn_packet (vpn_packet *pkt, SOCKADDR *sa, int tos = IPTOS_RELIABILITY);
134 void reconnect_all (); 55 void reconnect_all ();
135 void shutdown_all (); 56 void shutdown_all ();
136 void connect_request (int id); 57 void connect_request (int id);
137 58
138 void vpn_ev (short revents); io_watcher vpn_ev_watcher; 59 void tap_ev (short revents); io_watcher tap_ev_watcher;
60 void ipv4_ev (short revents); io_watcher ipv4_ev_watcher;
139 void udp_ev (short revents); io_watcher udp_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);
140 67
141 vpn (); 68 vpn ();
142 ~vpn (); 69 ~vpn ();
143 70
144 int setup (); 71 int setup ();
145 72
73 void dump_status ();
74
146 const char *script_if_up (int); 75 const char *script_if_up (int);
147 }; 76 };
148 77
149#endif 78#endif
150 79

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines