… | |
… | |
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 | |
|
|
92 | inline const char * |
92 | const char *vpn::script_if_init () |
93 | vpn::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 | |
|
|
100 | inline const char * |
99 | const char *vpn::script_if_up () |
101 | vpn::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, |
… | |
… | |
501 | } |
503 | } |
502 | |
504 | |
503 | return false; |
505 | return false; |
504 | } |
506 | } |
505 | |
507 | |
506 | void |
508 | inline void |
507 | vpn::ipv4_ev (ev::io &w, int revents) |
509 | vpn::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 |
547 | void |
549 | inline void |
548 | vpn::icmpv4_ev (ev::io &w, int revents) |
550 | vpn::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 | |
595 | void |
597 | inline void |
596 | vpn::udpv4_ev (ev::io &w, int revents) |
598 | vpn::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 | |
632 | void |
634 | inline void |
633 | vpn::tap_ev (ev::io &w, int revents) |
635 | vpn::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 | |
674 | void |
676 | inline void |
675 | vpn::event_cb (ev::timer &w, int) |
677 | vpn::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) |