… | |
… | |
71 | PT_PING, PT_PONG, // wasting namespace space? ;) |
71 | PT_PING, PT_PONG, // wasting namespace space? ;) |
72 | PT_AUTH_REQ, // authentification request |
72 | PT_AUTH_REQ, // authentification request |
73 | PT_AUTH_RES, // authentification response |
73 | PT_AUTH_RES, // authentification response |
74 | PT_CONNECT_REQ, // want other node to contact me |
74 | PT_CONNECT_REQ, // want other node to contact me |
75 | PT_CONNECT_INFO, // request connection to some node |
75 | PT_CONNECT_INFO, // request connection to some node |
76 | PT_DATA_BRIDGED, // uncompressed packet with foreign mac pot. larger than path mtu |
76 | PT_DATA_BRIDGED, // uncompressed packet with foreign mac pot. larger than path mtu (NYI) |
77 | PT_MAX |
77 | PT_MAX |
78 | }; |
78 | }; |
79 | |
79 | |
80 | u8 type; |
80 | u8 type; |
81 | u8 srcdst, src1, dst1; |
81 | u8 srcdst, src1, dst1; |
… | |
… | |
101 | //////////////////////////////////////////////////////////////////////////////////////// |
101 | //////////////////////////////////////////////////////////////////////////////////////// |
102 | |
102 | |
103 | // a very simple fifo pkt-queue |
103 | // a very simple fifo pkt-queue |
104 | class pkt_queue |
104 | class pkt_queue |
105 | { |
105 | { |
106 | net_packet *queue[QUEUEDEPTH]; |
|
|
107 | int i, j; |
106 | int i, j; |
|
|
107 | int max_queue; |
|
|
108 | double max_ttl; |
|
|
109 | |
|
|
110 | struct pkt { |
|
|
111 | ev_tstamp tstamp; |
|
|
112 | net_packet *pkt; |
|
|
113 | } *queue; |
|
|
114 | |
|
|
115 | void expire_cb (ev::timer &w, int revents); ev::timer expire; |
108 | |
116 | |
109 | public: |
117 | public: |
110 | |
118 | |
111 | void put (net_packet *p); |
119 | void put (net_packet *p); |
112 | net_packet *get (); |
120 | net_packet *get (); |
113 | |
121 | |
114 | pkt_queue (); |
122 | bool empty () |
|
|
123 | { |
|
|
124 | return i == j; |
|
|
125 | } |
|
|
126 | |
|
|
127 | pkt_queue (double max_ttl, int max_queue); |
115 | ~pkt_queue (); |
128 | ~pkt_queue (); |
116 | }; |
129 | }; |
117 | |
130 | |
118 | enum |
131 | enum |
119 | { |
132 | { |
… | |
… | |
129 | |
142 | |
130 | sockinfo si; // the current(!) destination ip to send packets to |
143 | sockinfo si; // the current(!) destination ip to send packets to |
131 | int retry_cnt; |
144 | int retry_cnt; |
132 | |
145 | |
133 | tstamp last_activity; // time of last packet received |
146 | tstamp last_activity; // time of last packet received |
|
|
147 | tstamp last_establish_attempt; |
134 | |
148 | |
135 | u32 oseqno; |
149 | u32 oseqno; |
136 | sliding_window iseqno; |
150 | sliding_window iseqno; |
137 | |
151 | |
138 | u8 protocol; |
152 | u8 protocol; |
… | |
… | |
168 | void send_connect_info (int rid, const sockinfo &rsi, u8 rprotocols); |
182 | void send_connect_info (int rid, const sockinfo &rsi, u8 rprotocols); |
169 | void send_reset (const sockinfo &dsi); |
183 | void send_reset (const sockinfo &dsi); |
170 | void send_ping (const sockinfo &dsi, u8 pong = 0); |
184 | void send_ping (const sockinfo &dsi, u8 pong = 0); |
171 | void send_data_packet (tap_packet *pkt); |
185 | void send_data_packet (tap_packet *pkt); |
172 | |
186 | |
|
|
187 | void post_inject_queue (); |
173 | void inject_data_packet (tap_packet *pkt, bool broadcast = false); |
188 | void inject_data_packet (tap_packet *pkt); |
174 | void inject_vpn_packet (vpn_packet *pkt, int tos = 0); // for forwarding |
189 | void inject_vpn_packet (vpn_packet *pkt, int tos = 0); // for forwarding |
175 | |
190 | |
176 | void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi); |
191 | void recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi); |
177 | void send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos = 0); |
192 | void send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos = 0); |
178 | |
193 | |