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.43 by pcg, Tue Dec 4 15:01:12 2007 UTC vs.
Revision 1.45 by pcg, Thu Dec 6 00:35:29 2007 UTC

87 snprintf (ext, 16, "_%d", (*c)->conf->id); 87 snprintf (ext, 16, "_%d", (*c)->conf->id);
88 (*c)->script_init_env (ext); 88 (*c)->script_init_env (ext);
89 } 89 }
90} 90}
91 91
92inline const char *
92const char *vpn::script_if_init () 93vpn::script_if_init ()
93{ 94{
94 script_init_env (); 95 script_init_env ();
95 96
96 return tap->if_up (); 97 return tap->if_up ();
97} 98}
98 99
100inline const char *
99const char *vpn::script_if_up () 101vpn::script_if_up ()
100{ 102{
101 script_init_env (); 103 script_init_env ();
102 104
103 char *filename; 105 char *filename;
104 asprintf (&filename, 106 asprintf (&filename,
330 } 332 }
331 333
332 fcntl (tap->fd, F_SETFD, FD_CLOEXEC); 334 fcntl (tap->fd, F_SETFD, FD_CLOEXEC);
333 335
334 run_script_cb cb; 336 run_script_cb cb;
337 cb.set<vpn, &vpn::script_if_init> (this);
335 338
336 callback_set (cb, this, vpn, script_if_init);
337 if (tap->if_up () && 339 if (tap->if_up () &&
338 !run_script (cb, true)) 340 !run_script (cb, true))
339 { 341 {
340 slog (L_ERR, _("interface initialization command '%s' failed, exiting."), 342 slog (L_ERR, _("interface initialization command '%s' failed, exiting."),
341 tap->if_up ()); 343 tap->if_up ());
342 exit (EXIT_FAILURE); 344 exit (EXIT_FAILURE);
343 } 345 }
344 346
345 callback_set (cb, this, vpn, script_if_up); 347 cb.set<vpn, &vpn::script_if_up> (this);
346 if (!run_script (cb, true)) 348 if (!run_script (cb, true))
347 { 349 {
348 slog (L_ERR, _("if-up command execution failed, exiting.")); 350 slog (L_ERR, _("if-up command execution failed, exiting."));
349 exit (EXIT_FAILURE); 351 exit (EXIT_FAILURE);
350 } 352 }
501 } 503 }
502 504
503 return false; 505 return false;
504} 506}
505 507
506void 508inline void
507vpn::ipv4_ev (ev::io &w, int revents) 509vpn::ipv4_ev (ev::io &w, int revents)
508{ 510{
509 if (revents & EV_READ) 511 if (revents & EV_READ)
510 { 512 {
511 vpn_packet *pkt = new vpn_packet; 513 vpn_packet *pkt = new vpn_packet;
542 exit (EXIT_FAILURE); 544 exit (EXIT_FAILURE);
543 } 545 }
544} 546}
545 547
546#if ENABLE_ICMP 548#if ENABLE_ICMP
547void 549inline void
548vpn::icmpv4_ev (ev::io &w, int revents) 550vpn::icmpv4_ev (ev::io &w, int revents)
549{ 551{
550 if (revents & EV_READ) 552 if (revents & EV_READ)
551 { 553 {
552 vpn_packet *pkt = new vpn_packet; 554 vpn_packet *pkt = new vpn_packet;
590 exit (EXIT_FAILURE); 592 exit (EXIT_FAILURE);
591 } 593 }
592} 594}
593#endif 595#endif
594 596
595void 597inline void
596vpn::udpv4_ev (ev::io &w, int revents) 598vpn::udpv4_ev (ev::io &w, int revents)
597{ 599{
598 if (revents & EV_READ) 600 if (revents & EV_READ)
599 { 601 {
600 vpn_packet *pkt = new vpn_packet; 602 vpn_packet *pkt = new vpn_packet;
627 revents); 629 revents);
628 exit (EXIT_FAILURE); 630 exit (EXIT_FAILURE);
629 } 631 }
630} 632}
631 633
632void 634inline void
633vpn::tap_ev (ev::io &w, int revents) 635vpn::tap_ev (ev::io &w, int revents)
634{ 636{
635 if (revents & EV_READ) 637 if (revents & EV_READ)
636 { 638 {
637 /* process data */ 639 /* process data */
669 } 671 }
670 else 672 else
671 abort (); 673 abort ();
672} 674}
673 675
674void 676inline void
675vpn::event_cb (ev::timer &w, int) 677vpn::event_cb (ev::timer &w, int)
676{ 678{
677 if (events) 679 if (events)
678 { 680 {
679 if (events & EVENT_SHUTDOWN) 681 if (events & EVENT_SHUTDOWN)
780 782
781 slog (L_NOTICE, _("END status dump")); 783 slog (L_NOTICE, _("END status dump"));
782} 784}
783 785
784vpn::vpn (void) 786vpn::vpn (void)
787{
785: event (this, &vpn::event_cb) 788 event .set<vpn, &vpn::event_cb > (this);
786, udpv4_ev_watcher (this, &vpn::udpv4_ev) 789 udpv4_ev_watcher .set<vpn, &vpn::udpv4_ev > (this);
787, ipv4_ev_watcher (this, &vpn::ipv4_ev) 790 ipv4_ev_watcher .set<vpn, &vpn::ipv4_ev > (this);
788#if ENABLE_TCP 791#if ENABLE_TCP
789, tcpv4_ev_watcher (this, &vpn::tcpv4_ev) 792 tcpv4_ev_watcher .set<vpn, &vpn::tcpv4_ev > (this);
790#endif 793#endif
791#if ENABLE_ICMP 794#if ENABLE_ICMP
792, icmpv4_ev_watcher(this, &vpn::icmpv4_ev) 795 icmpv4_ev_watcher.set<vpn, &vpn::icmpv4_ev> (this);
793#endif 796#endif
794#if ENABLE_DNS 797#if ENABLE_DNS
795, dnsv4_ev_watcher (this, &vpn::dnsv4_ev) 798 dnsv4_ev_watcher .set<vpn, &vpn::dnsv4_ev > (this);
796#endif 799#endif
797, tap_ev_watcher (this, &vpn::tap_ev) 800 tap_ev_watcher .set<vpn, &vpn::tap_ev > (this);
798{
799} 801}
800 802
801vpn::~vpn () 803vpn::~vpn ()
802{ 804{
803} 805}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines