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

Comparing gvpe/src/vpn.C (file contents):
Revision 1.6 by pcg, Sun Apr 6 04:17:36 2003 UTC vs.
Revision 1.7 by pcg, Sun Apr 6 18:12:18 2003 UTC

185 185
186 return 0; 186 return 0;
187} 187}
188 188
189// send a vpn packet out to other hosts 189// send a vpn packet out to other hosts
190void 190bool
191vpn::send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos) 191vpn::send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos)
192{ 192{
193 switch (si.prot) 193 switch (si.prot)
194 { 194 {
195 case PROT_IPv4: 195 case PROT_IPv4:
196 send_ipv4_packet (pkt, si, tos); 196 return send_ipv4_packet (pkt, si, tos);
197 break;
198 197
199 case PROT_UDPv4: 198 case PROT_UDPv4:
200 send_udpv4_packet (pkt, si, tos); 199 return send_udpv4_packet (pkt, si, tos);
201 break;
202 200
203#if ENABLE_TCP 201#if ENABLE_TCP
204 case PROT_TCPv4: 202 case PROT_TCPv4:
205 send_tcpv4_packet (pkt, si, tos); 203 return send_tcpv4_packet (pkt, si, tos);
206 break;
207#endif 204#endif
208 205
209 default: 206 default:
210 slog (L_CRIT, _("%s: FATAL: trying to send packet with unsupported protocol"), (const char *)si); 207 slog (L_CRIT, _("%s: FATAL: trying to send packet with unsupported protocol"), (const char *)si);
211 abort (); 208 return false;
212 } 209 }
213} 210}
214 211
215void 212bool
216vpn::send_ipv4_packet (vpn_packet *pkt, const sockinfo &si, int tos) 213vpn::send_ipv4_packet (vpn_packet *pkt, const sockinfo &si, int tos)
217{ 214{
218 setsockopt (ipv4_fd, SOL_IP, IP_TOS, &tos, sizeof tos); 215 setsockopt (ipv4_fd, SOL_IP, IP_TOS, &tos, sizeof tos);
219 sendto (ipv4_fd, &((*pkt)[0]), pkt->len, 0, si.sav4 (), si.salenv4 ()); 216 sendto (ipv4_fd, &((*pkt)[0]), pkt->len, 0, si.sav4 (), si.salenv4 ());
220}
221 217
222void 218 return true;
219}
220
221bool
223vpn::send_udpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos) 222vpn::send_udpv4_packet (vpn_packet *pkt, const sockinfo &si, int tos)
224{ 223{
225 setsockopt (udpv4_fd, SOL_IP, IP_TOS, &tos, sizeof tos); 224 setsockopt (udpv4_fd, SOL_IP, IP_TOS, &tos, sizeof tos);
226 sendto (udpv4_fd, &((*pkt)[0]), pkt->len, 0, si.sav4 (), si.salenv4 ()); 225 sendto (udpv4_fd, &((*pkt)[0]), pkt->len, 0, si.sav4 (), si.salenv4 ());
226
227 return true;
227} 228}
228 229
229void 230void
230vpn::recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi) 231vpn::recv_vpn_packet (vpn_packet *pkt, const sockinfo &rsi)
231{ 232{
496 } 497 }
497 498
498 return router; 499 return router;
499} 500}
500 501
501void vpn::connect_request (int id) 502void vpn::send_connect_request (int id)
502{ 503{
503 connection *c = find_router (); 504 connection *c = find_router ();
504 505
505 if (c) 506 if (c)
506 c->connect_request (id); 507 c->send_connect_request (id);
507 //else // does not work, because all others must connect to the same router 508 else
508 // // no router found, aggressively connect to all routers 509 // no router found, aggressively connect to all routers
509 // for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i) 510 for (conns_vector::iterator i = conns.begin (); i != conns.end (); ++i)
510 // if ((*i)->conf->routerprio) 511 if ((*i)->conf->routerprio)
511 // (*i)->establish_connection (); 512 (*i)->establish_connection ();
512} 513}
513 514
514void 515void
515connection::dump_status () 516connection::dump_status ()
516{ 517{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines