ports/security/fragroute/files/patch-fragroute.c
Baptiste Daroussin b564653452 Only use libevent2
Remove libevent as libevent2 is providing a good compatibility interface as well
as providing better performances.
Remove custom patches from libevent2 and install libevent2 the regular way
Mark ports abusing private fields of the libevent1 API as broken
Import a patch from fedora to have honeyd working with libevent2
Remove most of the patches necessary to find the custom installation we used to
have for libevent2

With hat:	portmgr
2014-07-24 13:32:58 +00:00

78 lines
1.6 KiB
C

$NetBSD: patch-fragroute.c,v 1.1 2013/05/23 16:02:13 christos Exp $
In the unix case, don't use the obsolete libevent signal interface
--- fragroute.c.orig 2002-04-07 18:55:20.000000000 -0400
+++ fragroute.c 2013-05-23 11:59:52.000000000 -0400
@@ -36,10 +36,6 @@
static struct fr_ctx ctx;
-/* XXX - these should be in event.h */
-extern int (*event_sigcb)(void);
-extern int event_gotsig;
-
static void
usage(void)
{
@@ -136,6 +132,10 @@
}
#ifdef WIN32
+/* XXX - these should be in event.h */
+extern int (*event_sigcb)(void);
+extern int event_gotsig;
+
static BOOL CALLBACK
fragroute_signal(DWORD sig)
{
@@ -144,12 +144,25 @@
return (TRUE);
}
#else
+
static void
-fragroute_signal(int sig)
+fragroute_signal(evutil_socket_t fd, short what, void *arg)
{
+ int sig;
+ recv(fd, &sig, sizeof(sig), 0);
warnx("exiting on signal %d", sig);
- event_gotsig++;
+ exit(sig);
}
+
+static void
+addsignal(int sig) {
+ struct event sig_ev;
+ int got;
+
+ evsignal_set(&sig_ev, sig, fragroute_signal, &got);
+ evsignal_add(&sig_ev, NULL);
+}
+
#endif
static void
@@ -165,9 +178,6 @@
err(1, "couldn't initialize Winsock");
SetConsoleCtrlHandler(fragroute_signal, TRUE);
-#else
- signal(SIGINT, fragroute_signal);
- signal(SIGTERM, fragroute_signal);
#endif
if (addr_aton(dst, &ctx.dst) < 0)
err(1, "destination address invalid");
@@ -178,7 +188,12 @@
pkt_init(128);
event_init();
+#ifdef WIN32
event_sigcb = fragroute_close;
+#else
+ addsignal(SIGINT);
+ addsignal(SIGTERM);
+#endif
if ((ctx.arp = arp_open()) == NULL ||
(ctx.intf = intf_open()) == NULL ||