* In order for pftop to be built successfully with newer PF versions (> 4.1), additional patches are necessary which were taken from OpenBSD's ports as seen in PR pkg/44339 * Pftop compiled for another PF version will not work (properly), so to avoid any problems we must depend on the OS version ok@ wiz
93 lines
2 KiB
Text
93 lines
2 KiB
Text
$NetBSD: patch-ab,v 1.6 2011/02/09 22:51:38 rumko Exp $
|
|
$OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
|
|
|
|
* DragonFly compatibility
|
|
* Patches to support PF > 4.1 taken from OpenBSD's ports
|
|
|
|
--- cache.c.old 2008-06-14 17:43:59.000000000 +0200
|
|
+++ cache.c 2008-06-15 01:15:37.000000000 +0200
|
|
@@ -23,7 +23,11 @@
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/tcp_fsm.h>
|
|
+#ifdef __DragonFly__
|
|
+#include <net/pf/pfvar.h>
|
|
+#else
|
|
#include <net/pfvar.h>
|
|
+#endif /* !__DragonFly__ */
|
|
#include <arpa/inet.h>
|
|
|
|
#include <stdio.h>
|
|
@@ -40,6 +44,7 @@
|
|
|
|
/* initialize the tree and queue */
|
|
RB_HEAD(sc_tree, sc_ent) sctree;
|
|
+RB_PROTOTYPE(sc_tree, sc_ent, tlink, sc_cmp);
|
|
TAILQ_HEAD(sc_queue, sc_ent) scq1, scq2, scq_free;
|
|
RB_GENERATE(sc_tree, sc_ent, tlink, sc_cmp);
|
|
|
|
@@ -118,12 +123,17 @@
|
|
|
|
cache_size--;
|
|
|
|
+#ifdef HAVE_PFSYNC_STATE
|
|
+ ent->id[0] = st->id[0];
|
|
+ ent->id[1] = st->id[1];
|
|
+#else
|
|
ent->addr[0] = st->lan.addr;
|
|
ent->port[0] = st->lan.port;
|
|
ent->addr[1] = st->ext.addr;
|
|
ent->port[1] = st->ext.port;
|
|
ent->af = st->af;
|
|
ent->proto = st->proto;
|
|
+#endif
|
|
#ifdef HAVE_INOUT_COUNT
|
|
ent->bytes = COUNTER(st->bytes[0]) + COUNTER(st->bytes[1]);
|
|
#else
|
|
@@ -147,13 +157,17 @@
|
|
if (cache_max == 0)
|
|
return (NULL);
|
|
|
|
+#ifdef HAVE_PFSYNC_STATE
|
|
+ ent.id[0] = st->id[0];
|
|
+ ent.id[1] = st->id[1];
|
|
+#else
|
|
ent.addr[0] = st->lan.addr;
|
|
ent.port[0] = st->lan.port;
|
|
ent.addr[1] = st->ext.addr;
|
|
ent.port[1] = st->ext.port;
|
|
ent.af = st->af;
|
|
ent.proto = st->proto;
|
|
-
|
|
+#endif
|
|
old = RB_FIND(sc_tree, &sctree, &ent);
|
|
|
|
if (old == NULL) {
|
|
@@ -210,8 +224,18 @@
|
|
static __inline int
|
|
sc_cmp(struct sc_ent *a, struct sc_ent *b)
|
|
{
|
|
+#ifdef HAVE_PFSYNC_STATE
|
|
+ if (a->id[0] > b->id[0])
|
|
+ return (1);
|
|
+ if (a->id[0] < b->id[0])
|
|
+ return (-1);
|
|
+ if (a->id[1] > b->id[1])
|
|
+ return (1);
|
|
+ if (a->id[1] < b->id[1])
|
|
+ return (-1);
|
|
+#else
|
|
int diff;
|
|
-
|
|
+
|
|
if ((diff = a->proto - b->proto) != 0)
|
|
return (diff);
|
|
if ((diff = a->af - b->af) != 0)
|
|
@@ -269,6 +293,6 @@
|
|
return (diff);
|
|
if ((diff = a->port[1] - b->port[1]) != 0)
|
|
return (diff);
|
|
-
|
|
+#endif
|
|
return (0);
|
|
}
|