… | |
… | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
15 | GNU General Public License for more details. |
16 | |
16 | |
17 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
18 | along with gvpe; if not, write to the Free Software |
18 | along with gvpe; if not, write to the Free Software |
19 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | */ |
20 | */ |
21 | |
21 | |
22 | #include "config.h" |
22 | #include "config.h" |
23 | |
23 | |
24 | #include <list> |
24 | #include <list> |
… | |
… | |
128 | { |
128 | { |
129 | slog (L_ERR, _("can't bind ipv4 socket on %s: %s"), (const char *)si, strerror (errno)); |
129 | slog (L_ERR, _("can't bind ipv4 socket on %s: %s"), (const char *)si, strerror (errno)); |
130 | exit (EXIT_FAILURE); |
130 | exit (EXIT_FAILURE); |
131 | } |
131 | } |
132 | |
132 | |
133 | ipv4_ev_watcher.start (ipv4_fd, EVENT_READ); |
133 | ipv4_ev_watcher.start (ipv4_fd, EV_READ); |
134 | } |
134 | } |
135 | |
135 | |
136 | udpv4_fd = -1; |
136 | udpv4_fd = -1; |
137 | |
137 | |
138 | if (THISNODE->protocols & PROT_UDPv4 && THISNODE->udp_port) |
138 | if (THISNODE->protocols & PROT_UDPv4 && THISNODE->udp_port) |
… | |
… | |
167 | { |
167 | { |
168 | slog (L_ERR, _("can't bind udpv4 on %s: %s"), (const char *)si, strerror (errno)); |
168 | slog (L_ERR, _("can't bind udpv4 on %s: %s"), (const char *)si, strerror (errno)); |
169 | exit (EXIT_FAILURE); |
169 | exit (EXIT_FAILURE); |
170 | } |
170 | } |
171 | |
171 | |
172 | udpv4_ev_watcher.start (udpv4_fd, EVENT_READ); |
172 | udpv4_ev_watcher.start (udpv4_fd, EV_READ); |
173 | } |
173 | } |
174 | |
174 | |
175 | icmpv4_fd = -1; |
175 | icmpv4_fd = -1; |
176 | |
176 | |
177 | #if ENABLE_ICMP |
177 | #if ENABLE_ICMP |
… | |
… | |
212 | { |
212 | { |
213 | slog (L_ERR, _("can't bind icmpv4 on %s: %s"), (const char *)si, strerror (errno)); |
213 | slog (L_ERR, _("can't bind icmpv4 on %s: %s"), (const char *)si, strerror (errno)); |
214 | exit (EXIT_FAILURE); |
214 | exit (EXIT_FAILURE); |
215 | } |
215 | } |
216 | |
216 | |
217 | icmpv4_ev_watcher.start (icmpv4_fd, EVENT_READ); |
217 | icmpv4_ev_watcher.start (icmpv4_fd, EV_READ); |
218 | } |
218 | } |
219 | #endif |
219 | #endif |
220 | |
220 | |
221 | tcpv4_fd = -1; |
221 | tcpv4_fd = -1; |
222 | |
222 | |
… | |
… | |
249 | { |
249 | { |
250 | slog (L_ERR, _("can't listen tcpv4 on %s: %s"), (const char *)si, strerror (errno)); |
250 | slog (L_ERR, _("can't listen tcpv4 on %s: %s"), (const char *)si, strerror (errno)); |
251 | exit (EXIT_FAILURE); |
251 | exit (EXIT_FAILURE); |
252 | } |
252 | } |
253 | |
253 | |
254 | tcpv4_ev_watcher.start (tcpv4_fd, EVENT_READ); |
254 | tcpv4_ev_watcher.start (tcpv4_fd, EV_READ); |
255 | } |
255 | } |
256 | #endif |
256 | #endif |
257 | |
257 | |
258 | #if ENABLE_DNS |
258 | #if ENABLE_DNS |
259 | if (THISNODE->protocols & PROT_DNSv4) |
259 | if (THISNODE->protocols & PROT_DNSv4) |
… | |
… | |
292 | { |
292 | { |
293 | slog (L_ERR, _("can't bind dnsv4 on %s: %s"), (const char *)si, strerror (errno)); |
293 | slog (L_ERR, _("can't bind dnsv4 on %s: %s"), (const char *)si, strerror (errno)); |
294 | exit (EXIT_FAILURE); |
294 | exit (EXIT_FAILURE); |
295 | } |
295 | } |
296 | |
296 | |
297 | dnsv4_ev_watcher.start (dnsv4_fd, EVENT_READ); |
297 | dnsv4_ev_watcher.start (dnsv4_fd, EV_READ); |
298 | } |
298 | } |
299 | #endif |
299 | #endif |
300 | |
300 | |
301 | ///////////////////////////////////////////////////////////////////////////// |
301 | ///////////////////////////////////////////////////////////////////////////// |
302 | |
302 | |
… | |
… | |
325 | { |
325 | { |
326 | slog (L_ERR, _("if-up command execution failed, exiting.")); |
326 | slog (L_ERR, _("if-up command execution failed, exiting.")); |
327 | exit (EXIT_FAILURE); |
327 | exit (EXIT_FAILURE); |
328 | } |
328 | } |
329 | |
329 | |
330 | tap_ev_watcher.start (tap->fd, EVENT_READ); |
330 | tap_ev_watcher.start (tap->fd, EV_READ); |
331 | |
331 | |
332 | return 0; |
332 | return 0; |
333 | } |
333 | } |
334 | |
334 | |
335 | bool |
335 | bool |
… | |
… | |
486 | |
486 | |
487 | return false; |
487 | return false; |
488 | } |
488 | } |
489 | |
489 | |
490 | void |
490 | void |
491 | vpn::ipv4_ev (io_watcher &w, short revents) |
491 | vpn::ipv4_ev (ev::io &w, int revents) |
492 | { |
492 | { |
493 | if (revents & EVENT_READ) |
493 | if (revents & EV_READ) |
494 | { |
494 | { |
495 | vpn_packet *pkt = new vpn_packet; |
495 | vpn_packet *pkt = new vpn_packet; |
496 | struct sockaddr_in sa; |
496 | struct sockaddr_in sa; |
497 | socklen_t sa_len = sizeof (sa); |
497 | socklen_t sa_len = sizeof (sa); |
498 | int len; |
498 | int len; |
… | |
… | |
527 | } |
527 | } |
528 | } |
528 | } |
529 | |
529 | |
530 | #if ENABLE_ICMP |
530 | #if ENABLE_ICMP |
531 | void |
531 | void |
532 | vpn::icmpv4_ev (io_watcher &w, short revents) |
532 | vpn::icmpv4_ev (ev::io &w, int revents) |
533 | { |
533 | { |
534 | if (revents & EVENT_READ) |
534 | if (revents & EV_READ) |
535 | { |
535 | { |
536 | vpn_packet *pkt = new vpn_packet; |
536 | vpn_packet *pkt = new vpn_packet; |
537 | struct sockaddr_in sa; |
537 | struct sockaddr_in sa; |
538 | socklen_t sa_len = sizeof (sa); |
538 | socklen_t sa_len = sizeof (sa); |
539 | int len; |
539 | int len; |
… | |
… | |
575 | } |
575 | } |
576 | } |
576 | } |
577 | #endif |
577 | #endif |
578 | |
578 | |
579 | void |
579 | void |
580 | vpn::udpv4_ev (io_watcher &w, short revents) |
580 | vpn::udpv4_ev (ev::io &w, int revents) |
581 | { |
581 | { |
582 | if (revents & EVENT_READ) |
582 | if (revents & EV_READ) |
583 | { |
583 | { |
584 | vpn_packet *pkt = new vpn_packet; |
584 | vpn_packet *pkt = new vpn_packet; |
585 | struct sockaddr_in sa; |
585 | struct sockaddr_in sa; |
586 | socklen_t sa_len = sizeof (sa); |
586 | socklen_t sa_len = sizeof (sa); |
587 | int len; |
587 | int len; |
… | |
… | |
612 | exit (EXIT_FAILURE); |
612 | exit (EXIT_FAILURE); |
613 | } |
613 | } |
614 | } |
614 | } |
615 | |
615 | |
616 | void |
616 | void |
617 | vpn::tap_ev (io_watcher &w, short revents) |
617 | vpn::tap_ev (ev::io &w, int revents) |
618 | { |
618 | { |
619 | if (revents & EVENT_READ) |
619 | if (revents & EV_READ) |
620 | { |
620 | { |
621 | /* process data */ |
621 | /* process data */ |
622 | tap_packet *pkt; |
622 | tap_packet *pkt; |
623 | |
623 | |
624 | pkt = tap->recv (); |
624 | pkt = tap->recv (); |
… | |
… | |
654 | else |
654 | else |
655 | abort (); |
655 | abort (); |
656 | } |
656 | } |
657 | |
657 | |
658 | void |
658 | void |
659 | vpn::event_cb (time_watcher &w) |
659 | vpn::event_cb (ev::timer &w, int) |
660 | { |
660 | { |
661 | if (events) |
661 | if (events) |
662 | { |
662 | { |
663 | if (events & EVENT_SHUTDOWN) |
663 | if (events & EVENT_SHUTDOWN) |
664 | { |
664 | { |
… | |
… | |
755 | } |
755 | } |
756 | |
756 | |
757 | void |
757 | void |
758 | vpn::dump_status () |
758 | vpn::dump_status () |
759 | { |
759 | { |
760 | slog (L_NOTICE, _("BEGIN status dump (%ld)"), (long)NOW); |
760 | slog (L_NOTICE, _("BEGIN status dump (%ld)"), (long)ev_now ()); |
761 | |
761 | |
762 | for (conns_vector::iterator c = conns.begin (); c != conns.end (); ++c) |
762 | for (conns_vector::iterator c = conns.begin (); c != conns.end (); ++c) |
763 | (*c)->dump_status (); |
763 | (*c)->dump_status (); |
764 | |
764 | |
765 | slog (L_NOTICE, _("END status dump")); |
765 | slog (L_NOTICE, _("END status dump")); |