… | |
… | |
96 | //////////////////////////////////////////////////////////////////////////////////////// |
96 | //////////////////////////////////////////////////////////////////////////////////////// |
97 | |
97 | |
98 | // a very simple fifo pkt-queue |
98 | // a very simple fifo pkt-queue |
99 | class pkt_queue |
99 | class pkt_queue |
100 | { |
100 | { |
101 | tap_packet *queue[QUEUEDEPTH]; |
101 | net_packet *queue[QUEUEDEPTH]; |
102 | int i, j; |
102 | int i, j; |
103 | |
103 | |
104 | public: |
104 | public: |
105 | |
105 | |
106 | void put (tap_packet *p); |
106 | void put (net_packet *p); |
107 | tap_packet *get (); |
107 | net_packet *get (); |
108 | |
108 | |
109 | pkt_queue (); |
109 | pkt_queue (); |
110 | ~pkt_queue (); |
110 | ~pkt_queue (); |
111 | }; |
111 | }; |
112 | |
112 | |
… | |
… | |
123 | u32 oseqno; |
123 | u32 oseqno; |
124 | sliding_window iseqno; |
124 | sliding_window iseqno; |
125 | |
125 | |
126 | u8 protocol; |
126 | u8 protocol; |
127 | |
127 | |
128 | pkt_queue queue; |
128 | pkt_queue data_queue, vpn_queue; |
129 | |
129 | |
130 | crypto_ctx *octx, *ictx; |
130 | crypto_ctx *octx, *ictx; |
131 | |
131 | |
132 | enum conf_node::connectmode connectmode; |
132 | enum conf_node::connectmode connectmode; |
133 | u8 prot_minor; // minor number of other side |
133 | u8 prot_minor; // minor number of other side |
134 | |
134 | |
135 | void reset_si (); |
135 | void reset_si (); |
136 | const sockinfo &forward_si (const sockinfo &si) const; |
136 | const sockinfo &forward_si (const sockinfo &si) const; |
137 | |
137 | |
138 | void shutdown (); |
138 | void shutdown (); |
|
|
139 | void connection_established (); |
139 | void reset_connection (); |
140 | void reset_connection (); |
|
|
141 | |
140 | void establish_connection_cb (time_watcher &w); time_watcher establish_connection; |
142 | void establish_connection_cb (time_watcher &w); time_watcher establish_connection; |
141 | void rekey_cb (time_watcher &w); time_watcher rekey; // next rekying (actually current reset + reestablishing) |
143 | void rekey_cb (time_watcher &w); time_watcher rekey; // next rekying (actually current reset + reestablishing) |
142 | void keepalive_cb (time_watcher &w); time_watcher keepalive; // next keepalive probe |
144 | void keepalive_cb (time_watcher &w); time_watcher keepalive; // next keepalive probe |
143 | |
145 | |
|
|
146 | void send_connect_request (int id); |
144 | void send_auth_request (const sockinfo &si, bool initiate); |
147 | void send_auth_request (const sockinfo &si, bool initiate); |
145 | void send_auth_response (const sockinfo &si, const rsaid &id, const rsachallenge &chg); |
148 | void send_auth_response (const sockinfo &si, const rsaid &id, const rsachallenge &chg); |
146 | void send_connect_info (int rid, const sockinfo &rsi, u8 rprotocols); |
149 | void send_connect_info (int rid, const sockinfo &rsi, u8 rprotocols); |
147 | void send_reset (const sockinfo &dsi); |
150 | void send_reset (const sockinfo &dsi); |
148 | void send_ping (const sockinfo &dsi, u8 pong = 0); |
151 | void send_ping (const sockinfo &dsi, u8 pong = 0); |
149 | void send_data_packet (tap_packet *pkt, bool broadcast = false); |
152 | void send_data_packet (tap_packet *pkt, bool broadcast = false); |
|
|
153 | |
150 | void inject_data_packet (tap_packet *pkt, bool broadcast = false); |
154 | void inject_data_packet (tap_packet *pkt, bool broadcast = false); |
151 | void inject_vpn_packet (vpn_packet *pkt, int tos = 0); // for forwarding |
155 | void inject_vpn_packet (vpn_packet *pkt, int tos = 0); // for forwarding |
152 | void connect_request (int id); |
|
|
153 | |
156 | |
|
|
157 | void send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos = 0); |
154 | void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi); |
158 | void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi); |
155 | |
159 | |
156 | void script_node (); |
160 | void script_node (); |
157 | const char *script_node_up (); |
161 | const char *script_node_up (); |
158 | const char *script_node_down (); |
162 | const char *script_node_down (); |