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

Comparing gvpe/src/connection.C (file contents):
Revision 1.39 by pcg, Tue Oct 12 12:06:06 2004 UTC vs.
Revision 1.40 by pcg, Tue Mar 1 06:27:20 2005 UTC

627 protocol = best_protocol (THISNODE->protocols & conf->protocols); 627 protocol = best_protocol (THISNODE->protocols & conf->protocols);
628 628
629 // mask out protocols we cannot establish 629 // mask out protocols we cannot establish
630 if (!conf->udp_port) protocol &= ~PROT_UDPv4; 630 if (!conf->udp_port) protocol &= ~PROT_UDPv4;
631 if (!conf->tcp_port) protocol &= ~PROT_TCPv4; 631 if (!conf->tcp_port) protocol &= ~PROT_TCPv4;
632 if (!conf->dns_port) protocol &= ~PROT_DNSv4;
632 633
633 si.set (conf, protocol); 634 si.set (conf, protocol);
634} 635}
635 636
636// ensure sockinfo is valid, forward if necessary 637// ensure sockinfo is valid, forward if necessary
656} 657}
657 658
658void 659void
659connection::send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos) 660connection::send_vpn_packet (vpn_packet *pkt, const sockinfo &si, int tos)
660{ 661{
661 if (!vpn->send_vpn_packet (pkt, si, tos)) 662 bool ok;
663
664 switch (si.prot)
665 {
666 case PROT_IPv4:
667 ok = vpn->send_ipv4_packet (pkt, si, tos); break;
668 case PROT_UDPv4:
669 ok = vpn->send_udpv4_packet (pkt, si, tos); break;
670#if ENABLE_TCP
671 case PROT_TCPv4:
672 ok = vpn->send_tcpv4_packet (pkt, si, tos); break;
673#endif
674#if ENABLE_ICMP
675 case PROT_ICMPv4:
676 ok = vpn->send_icmpv4_packet (pkt, si, tos); break;
677#endif
678#if ENABLE_DNS
679 case PROT_DNSv4:
680 ok = send_dnsv4_packet (pkt, si, tos); break;
681#endif
682
683 default:
684 slog (L_CRIT, _("%s: FATAL: trying to send packet with unsupported protocol"), (const char *)si);
685 ok = false;
686 }
687
688 if (!ok)
662 reset_connection (); 689 reset_connection ();
663} 690}
664 691
665void 692void
666connection::send_ping (const sockinfo &si, u8 pong) 693connection::send_ping (const sockinfo &si, u8 pong)
1189 putenv ("STATE=down"); 1216 putenv ("STATE=down");
1190 1217
1191 return ::conf.script_node_up ? ::conf.script_node_down : "node-down"; 1218 return ::conf.script_node_up ? ::conf.script_node_down : "node-down";
1192} 1219}
1193 1220
1194connection::connection(struct vpn *vpn_) 1221connection::connection (struct vpn *vpn, conf_node *conf)
1195: vpn(vpn_) 1222: vpn(vpn), conf(conf)
1196, rekey (this, &connection::rekey_cb) 1223, rekey (this, &connection::rekey_cb)
1197, keepalive (this, &connection::keepalive_cb) 1224, keepalive (this, &connection::keepalive_cb)
1198, establish_connection (this, &connection::establish_connection_cb) 1225, establish_connection (this, &connection::establish_connection_cb)
1226#if ENABLE_DNS
1227, dnsv4_tw (this, &connection::dnsv4_cb)
1228#endif
1199{ 1229{
1200 octx = ictx = 0; 1230 octx = ictx = 0;
1201 retry_cnt = 0; 1231 retry_cnt = 0;
1202 1232
1233 if (!conf->protocols) // make sure some protocol is enabled
1234 conf->protocols = PROT_UDPv4;
1235
1203 connectmode = conf_node::C_ALWAYS; // initial setting 1236 connectmode = conf_node::C_ALWAYS; // initial setting
1204 reset_connection (); 1237 reset_connection ();
1205} 1238}
1206 1239
1207connection::~connection () 1240connection::~connection ()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines