… | |
… | |
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. |
23 | |
24 | |
24 | #include <openssl/evp.h> |
25 | #include <openssl/evp.h> |
25 | #include <openssl/rsa.h> |
26 | #include <openssl/rsa.h> |
26 | |
27 | |
27 | #include "conf.h" |
28 | #include "conf.h" |
… | |
… | |
56 | time_t next_retry; // next connection retry |
57 | time_t next_retry; // next connection retry |
57 | time_t next_rekey; // next rekying (actually current reset + reestablishing) |
58 | time_t next_rekey; // next rekying (actually current reset + reestablishing) |
58 | time_t last_activity; // time of last packet received |
59 | time_t last_activity; // time of last packet received |
59 | |
60 | |
60 | u32 oseqno; |
61 | u32 oseqno; |
61 | u32 iseqno; |
62 | sliding_window iseqno; |
62 | u32 ismask; // bitmask with set bits for each received seqno (input seen mask) |
|
|
63 | |
63 | |
64 | pkt_queue queue; |
64 | pkt_queue queue; |
65 | |
65 | |
66 | crypto_ctx *octx, *ictx; |
66 | crypto_ctx *octx, *ictx; |
|
|
67 | |
|
|
68 | enum conf_node::connectmode connectmode; |
67 | |
69 | |
68 | void reset_dstaddr (); |
70 | void reset_dstaddr (); |
69 | |
71 | |
70 | void shutdown (); |
72 | void shutdown (); |
71 | void reset_connection (); |
73 | void reset_connection (); |
… | |
… | |
86 | connection(struct vpn *vpn_) |
88 | connection(struct vpn *vpn_) |
87 | : vpn(vpn_) |
89 | : vpn(vpn_) |
88 | { |
90 | { |
89 | octx = ictx = 0; |
91 | octx = ictx = 0; |
90 | retry_cnt = 0; |
92 | retry_cnt = 0; |
|
|
93 | connectmode = conf_node::C_ALWAYS; // initial setting |
91 | reset_connection (); |
94 | reset_connection (); |
92 | } |
95 | } |
93 | |
96 | |
94 | ~connection () |
97 | ~connection () |
95 | { |
98 | { |
… | |
… | |
116 | typedef vector<connection *> conns_vector; |
119 | typedef vector<connection *> conns_vector; |
117 | conns_vector conns; |
120 | conns_vector conns; |
118 | |
121 | |
119 | connection *find_router (); |
122 | connection *find_router (); |
120 | |
123 | |
121 | void send_vpn_packet (vpn_packet *pkt, SOCKADDR *sa); |
124 | void send_vpn_packet (vpn_packet *pkt, SOCKADDR *sa, int tos = IPTOS_RELIABILITY); |
122 | void reconnect_all (); |
125 | void reconnect_all (); |
123 | void shutdown_all (); |
126 | void shutdown_all (); |
124 | void connect_request (int id); |
127 | void connect_request (int id); |
125 | |
128 | |
126 | vpn (); |
129 | vpn (); |