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.49 by pcg, Sun Aug 10 01:34:36 2008 UTC vs.
Revision 1.51 by pcg, Sun Aug 10 14:48:57 2008 UTC

122} 122}
123 123
124int 124int
125vpn::setup () 125vpn::setup ()
126{ 126{
127 int success = 0;
128
127 ipv4_tos = -1; 129 ipv4_tos = -1;
128 ipv4_fd = -1; 130 ipv4_fd = -1;
129 131
130 if (THISNODE->protocols & PROT_IPv4 && ::conf.ip_proto) 132 if (THISNODE->protocols & PROT_IPv4 && ::conf.ip_proto)
131 { 133 {
154 slog (L_ERR, _("can't bind ipv4 socket on %s: %s, exiting."), (const char *)si, strerror (errno)); 156 slog (L_ERR, _("can't bind ipv4 socket on %s: %s, exiting."), (const char *)si, strerror (errno));
155 exit (EXIT_FAILURE); 157 exit (EXIT_FAILURE);
156 } 158 }
157 159
158 ipv4_ev_watcher.start (ipv4_fd, EV_READ); 160 ipv4_ev_watcher.start (ipv4_fd, EV_READ);
161 ++success;
159 } 162 }
163 else
164 THISNODE->protocols &= ~PROT_IPv4;
160 165
161 udpv4_tos = -1; 166 udpv4_tos = -1;
162 udpv4_fd = -1; 167 udpv4_fd = -1;
163 168
164 if (THISNODE->protocols & PROT_UDPv4 && THISNODE->udp_port) 169 if (THISNODE->protocols & PROT_UDPv4 && THISNODE->udp_port)
194 slog (L_ERR, _("can't bind udpv4 on %s: %s, exiting."), (const char *)si, strerror (errno)); 199 slog (L_ERR, _("can't bind udpv4 on %s: %s, exiting."), (const char *)si, strerror (errno));
195 exit (EXIT_FAILURE); 200 exit (EXIT_FAILURE);
196 } 201 }
197 202
198 udpv4_ev_watcher.start (udpv4_fd, EV_READ); 203 udpv4_ev_watcher.start (udpv4_fd, EV_READ);
204 ++success;
199 } 205 }
206 else
207 THISNODE->protocols &= ~PROT_UDPv4;
200 208
201 icmpv4_tos = -1; 209 icmpv4_tos = -1;
202 icmpv4_fd = -1; 210 icmpv4_fd = -1;
203 211
204#if ENABLE_ICMP 212#if ENABLE_ICMP
240 slog (L_ERR, _("can't bind icmpv4 on %s: %s, exiting."), (const char *)si, strerror (errno)); 248 slog (L_ERR, _("can't bind icmpv4 on %s: %s, exiting."), (const char *)si, strerror (errno));
241 exit (EXIT_FAILURE); 249 exit (EXIT_FAILURE);
242 } 250 }
243 251
244 icmpv4_ev_watcher.start (icmpv4_fd, EV_READ); 252 icmpv4_ev_watcher.start (icmpv4_fd, EV_READ);
253 ++success;
245 } 254 }
246#endif 255#endif
247 256
248 tcpv4_fd = -1; 257 tcpv4_fd = -1;
249 258
277 slog (L_ERR, _("can't listen tcpv4 on %s: %s, exiting."), (const char *)si, strerror (errno)); 286 slog (L_ERR, _("can't listen tcpv4 on %s: %s, exiting."), (const char *)si, strerror (errno));
278 exit (EXIT_FAILURE); 287 exit (EXIT_FAILURE);
279 } 288 }
280 289
281 tcpv4_ev_watcher.start (tcpv4_fd, EV_READ); 290 tcpv4_ev_watcher.start (tcpv4_fd, EV_READ);
291 ++success;
282 } 292 }
293 else
294 THISNODE->protocols &= ~PROT_TCPv4;
283#endif 295#endif
284 296
285 dnsv4_tos = -1; 297 dnsv4_tos = -1;
286 dnsv4_fd = -1; 298 dnsv4_fd = -1;
287 299
323 slog (L_ERR, _("can't bind dnsv4 on %s: %s, exiting."), (const char *)si, strerror (errno)); 335 slog (L_ERR, _("can't bind dnsv4 on %s: %s, exiting."), (const char *)si, strerror (errno));
324 exit (EXIT_FAILURE); 336 exit (EXIT_FAILURE);
325 } 337 }
326 338
327 dnsv4_ev_watcher.start (dnsv4_fd, EV_READ); 339 dnsv4_ev_watcher.start (dnsv4_fd, EV_READ);
340 ++success;
328 } 341 }
329#endif 342#endif
330 343
331 ///////////////////////////////////////////////////////////////////////////// 344 /////////////////////////////////////////////////////////////////////////////
345
346 if (!success)
347 {
348 slog (L_ERR, _("no protocols enabled, exiting."));
349 exit (EXIT_FAILURE);
350 }
332 351
333 reconnect_all (); 352 reconnect_all ();
334 353
335 ///////////////////////////////////////////////////////////////////////////// 354 /////////////////////////////////////////////////////////////////////////////
336 355
724 743
725 conns.clear (); 744 conns.clear ();
726 745
727 connection_init (); 746 connection_init ();
728 747
729 for (configuration::node_vector::iterator i = conf.nodes.begin (); 748 for (configuration::node_vector::iterator i = conf.nodes.begin (); i != conf.nodes.end (); ++i)
730 i != conf.nodes.end (); ++i) 749 conns.push_back (new connection (this, *i));
731 { 750
732 connection *conn = new connection (this, *i); 751 for (conns_vector::iterator c = conns.begin (); c != conns.end (); ++c)
733 conns.push_back (conn);
734 conn->establish_connection (); 752 (*c)->establish_connection ();
735 }
736} 753}
737 754
738bool vpn::can_direct (conf_node *src, conf_node *dst) const 755bool vpn::can_direct (conf_node *src, conf_node *dst) const
739{ 756{
740 return src != dst 757 return src != dst
819 o->rekey (); 836 o->rekey ();
820 } 837 }
821 } 838 }
822} 839}
823 840
824void vpn::send_connect_request (int id) 841void vpn::send_connect_request (connection *c)
825{ 842{
826 connection *c = find_router_for (conns[id]); 843 connection *r = find_router_for (c);
827 844
828 if (c) 845 if (r)
829 { 846 {
830 slog (L_TRACE, _("%s: no way to connect, sending mediated connection request via %s."), 847 slog (L_TRACE, _("%s: no way to connect, sending mediated connection request via %s."),
831 conns[id]->conf->nodename, c->conf->nodename); 848 c->conf->nodename, r->conf->nodename);
832 c->send_connect_request (id); 849 r->send_connect_request (c->conf->id);
833 } 850 }
834 else 851 else
835 slog (L_DEBUG, _("%s: no way to connect and no router found: unable to connect."), conns[id]->conf->nodename); 852 slog (L_DEBUG, _("%s: no way to connect and no router found: unable to connect."),
853 c->conf->nodename);
836} 854}
837 855
838void 856void
839connection::dump_status () 857connection::dump_status ()
840{ 858{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines