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.5 by pcg, Fri Mar 21 23:17:01 2003 UTC vs.
Revision 1.12 by pcg, Fri Mar 28 16:21:09 2003 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines