sysutils/pftop: fix build on fbsd >= 10

Ok@ wiz
This commit is contained in:
rumko 2015-01-14 20:39:42 +00:00
parent 004cb930ef
commit e2cb5fcef0
6 changed files with 63 additions and 41 deletions

View file

@ -1,17 +1,17 @@
$NetBSD: distinfo,v 1.9 2011/06/10 11:45:01 obache Exp $
$NetBSD: distinfo,v 1.10 2015/01/14 20:39:42 rumko Exp $
SHA1 (pftop-0.7.tar.gz) = 651afa532cfc8cf59c3598704deb9bf3788ac9e9
RMD160 (pftop-0.7.tar.gz) = 0e0c09e5feeb07deba8b540233dcb946ba0b4508
Size (pftop-0.7.tar.gz) = 59765 bytes
SHA1 (patch-aa) = ff5c522223472188933a6ccbe9725190dc8ec1b5
SHA1 (patch-ab) = fccf6fe5348f24d00dbf26cbe1880b9298774c6b
SHA1 (patch-ab) = 863e4f5540e7e6d35a084b7f0331e79ca3a6e0b9
SHA1 (patch-ac) = 0bbbe06873c76393cc14c17f2f9a946ded71d068
SHA1 (patch-ad) = a2999c5c42d96baf6bde55c2925f83aadee17394
SHA1 (patch-ad) = 73d3d7f8cb565d2f5955f7002b14e49df0f9b72d
SHA1 (patch-ae) = 54619b846899a7c4f260191a772e41e1c07c178c
SHA1 (patch-af) = 59b907b20fa215b3f0a1e690c9c71d2f7077e322
SHA1 (patch-ag) = 2e749dc45b2b91a1563bc1467b69775f595e4d03
SHA1 (patch-ah) = 7adca5a484de91bf89e66d10ab645912068cd1c2
SHA1 (patch-ah) = 91d9e2f97ab974f5497b475200f17142715027b3
SHA1 (patch-ai) = 629c1668eab0d819e590fb62b7afa6c85709fd15
SHA1 (patch-aj) = ad0ddcbadbcd342c4973f932a3b7042a1c97e66b
SHA1 (patch-aj) = 5e1638ffb28f64c7bcc79984764cadba6ee3d41e
SHA1 (patch-ak) = 78622d902016fa559ae3090d9c8407337d7cd0ed
SHA1 (patch-al) = 94f87c9655fd772e05e193da90617d12200a6ae5
SHA1 (patch-al) = bf1c2592cb0d84fcb60ed7f2ae2ffc1d6ca309d2

View file

@ -1,11 +1,11 @@
$NetBSD: patch-ab,v 1.6 2011/02/09 22:51:38 rumko Exp $
$NetBSD: patch-ab,v 1.7 2015/01/14 20:39:42 rumko Exp $
$OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
* DragonFly compatibility
* DragonFly and FreeBSD 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
--- cache.c.orig 2007-11-07 06:34:18.000000000 +0000
+++ cache.c
@@ -23,7 +23,11 @@
#include <netinet/in.h>
@ -18,7 +18,7 @@ $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
#include <arpa/inet.h>
#include <stdio.h>
@@ -40,6 +44,7 @@
@@ -40,6 +44,7 @@ static __inline int sc_cmp(struct sc_ent
/* initialize the tree and queue */
RB_HEAD(sc_tree, sc_ent) sctree;
@ -26,13 +26,17 @@ $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
TAILQ_HEAD(sc_queue, sc_ent) scq1, scq2, scq_free;
RB_GENERATE(sc_tree, sc_ent, tlink, sc_cmp);
@@ -118,12 +123,17 @@
@@ -118,12 +123,21 @@ add_state(pf_state_t *st)
cache_size--;
+#ifdef HAVE_PFSYNC_STATE
+#if defined(__FreeBSD__) && __FreeBSD_version > 1000017
+ ent->id = st->id;
+#else
+ ent->id[0] = st->id[0];
+ ent->id[1] = st->id[1];
+#endif
+#else
ent->addr[0] = st->lan.addr;
ent->port[0] = st->lan.port;
@ -44,13 +48,17 @@ $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
#ifdef HAVE_INOUT_COUNT
ent->bytes = COUNTER(st->bytes[0]) + COUNTER(st->bytes[1]);
#else
@@ -147,13 +157,17 @@
@@ -147,13 +161,21 @@ cache_state(pf_state_t *st)
if (cache_max == 0)
return (NULL);
+#ifdef HAVE_PFSYNC_STATE
+#if defined(__FreeBSD__) && __FreeBSD_version > 1000017
+ ent.id = st->id;
+#else
+ ent.id[0] = st->id[0];
+ ent.id[1] = st->id[1];
+#endif
+#else
ent.addr[0] = st->lan.addr;
ent.port[0] = st->lan.port;
@ -63,11 +71,17 @@ $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
old = RB_FIND(sc_tree, &sctree, &ent);
if (old == NULL) {
@@ -210,8 +224,18 @@
@@ -210,8 +232,25 @@ cache_endupdate(void)
static __inline int
sc_cmp(struct sc_ent *a, struct sc_ent *b)
{
+#ifdef HAVE_PFSYNC_STATE
+#if defined(__FreeBSD__) && __FreeBSD_version > 1000017
+ if (a->id > b->id)
+ return (1);
+ if (a->id < b->id)
+ return (-1);
+#else
+ if (a->id[0] > b->id[0])
+ return (1);
+ if (a->id[0] < b->id[0])
@ -76,6 +90,7 @@ $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
+ return (1);
+ if (a->id[1] < b->id[1])
+ return (-1);
+#endif
+#else
int diff;
-
@ -83,7 +98,7 @@ $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
if ((diff = a->proto - b->proto) != 0)
return (diff);
if ((diff = a->af - b->af) != 0)
@@ -269,6 +293,6 @@
@@ -269,6 +308,6 @@ sc_cmp(struct sc_ent *a, struct sc_ent *
return (diff);
if ((diff = a->port[1] - b->port[1]) != 0)
return (diff);

View file

@ -1,7 +1,7 @@
$NetBSD: patch-ad,v 1.3 2011/02/09 22:51:38 rumko Exp $
$NetBSD: patch-ad,v 1.4 2015/01/14 20:39:42 rumko Exp $
$OpenBSD: patch-engine_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
* DragonFly compatibility
* DragonFly and FreeBSD compatibility
* Patches to support PF > 4.1 taken from OpenBSD's ports.
--- engine.c.orig 2007-11-07 07:35:44 +0100
@ -10,7 +10,7 @@ $OpenBSD: patch-engine_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
#include <sys/types.h>
+#ifdef __DragonFly__
+#if defined(__DragonFly__) || defined(__FreeBSD__)
+#include "queue.h"
+#else
#include <sys/queue.h>

View file

@ -1,11 +1,11 @@
$NetBSD: patch-ah,v 1.3 2011/02/09 22:51:38 rumko Exp $
$NetBSD: patch-ah,v 1.4 2015/01/14 20:39:42 rumko Exp $
$OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
* DragonFly compatibility
* DragonFly and FreeBSD compatibility
* Patches to support PF > 4.1 taken from OpenBSD's ports.
--- sf-gencode.c.orig 2007-11-07 07:34:18 +0100
+++ sf-gencode.c 2010-09-16 01:35:22 +0200
--- sf-gencode.c.orig 2007-11-07 06:34:18.000000000 +0000
+++ sf-gencode.c
@@ -32,8 +32,12 @@
#include <netinet/in.h>
#include <netinet/if_ether.h>
@ -29,11 +29,11 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
#include <pcap-namedb.h>
#include "sf-gencode.h"
@@ -60,7 +64,11 @@
@@ -60,7 +64,11 @@ static jmp_buf top_ctx;
static char sf_errbuf[PFTOP_ERRBUF_SIZE];
/* VARARGS */
+#ifdef __DragonFly__
+#if defined(__DragonFly__) || defined(__FreeBSD__)
+void
+#else
__dead void
@ -41,7 +41,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
sf_error(const char *fmt, ...)
{
va_list ap;
@@ -474,6 +482,106 @@
@@ -474,6 +482,106 @@ gen_proto(int proto)
(bpf_int32)proto));
}
@ -148,7 +148,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
static struct block *
gen_hostop(bpf_u_int32 addr, bpf_u_int32 mask, int dir)
{
@@ -482,8 +590,10 @@
@@ -482,8 +590,10 @@ gen_hostop(bpf_u_int32 addr, bpf_u_int32
const static int gwy_off = offsetof(pf_state_t, gwy.addr.v4);
const static int ext_off = offsetof(pf_state_t, ext.addr.v4);
@ -159,7 +159,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
switch (dir) {
@@ -542,6 +652,7 @@
@@ -542,6 +652,7 @@ gen_hostop(bpf_u_int32 addr, bpf_u_int32
return b1;
}
@ -167,7 +167,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
static struct block *
gen_hostcmp6(u_int off, u_int32_t *a, u_int32_t *m)
@@ -560,6 +671,105 @@
@@ -560,6 +671,105 @@ gen_hostcmp6(u_int off, u_int32_t *a, u_
return b1;
}
@ -273,7 +273,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
static struct block *
gen_hostop6(struct in6_addr *addr, struct in6_addr *mask, int dir)
{
@@ -630,6 +840,7 @@
@@ -630,6 +840,7 @@ gen_hostop6(struct in6_addr *addr, struc
gen_and(b0, b1);
return b1;
}
@ -281,7 +281,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
static const char *
get_modifier_by_id(int id)
@@ -733,13 +944,17 @@
@@ -733,13 +944,17 @@ gen_proto_abbrev(proto)
b1 = gen_proto(IPPROTO_ESP);
break;
@ -299,7 +299,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
default:
sf_error("Unknown protocol abbreviation");
@@ -748,6 +963,106 @@
@@ -748,6 +963,106 @@ gen_proto_abbrev(proto)
return b1;
}
@ -406,7 +406,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
struct block *
gen_portop(int port, int proto, int dir)
{
@@ -756,7 +1071,9 @@
@@ -756,7 +1071,9 @@ gen_portop(int port, int proto, int dir)
const static int gwy_off = offsetof(pf_state_t, gwy.port);
const static int ext_off = offsetof(pf_state_t, ext.port);
@ -416,7 +416,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
switch (dir) {
@@ -815,6 +1132,7 @@
@@ -815,6 +1132,7 @@ gen_portop(int port, int proto, int dir)
return b1;
}
@ -424,7 +424,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $
static struct block *
gen_port(int port, int ip_proto, int dir)
@@ -1560,7 +1878,7 @@
@@ -1560,7 +1878,7 @@ gen_ifname(char *ifname)
/* NOTREACHED */
}

View file

@ -1,4 +1,6 @@
$NetBSD: patch-aj,v 1.2 2011/06/10 11:45:01 obache Exp $
$NetBSD: patch-aj,v 1.3 2015/01/14 20:39:42 rumko Exp $
DragonFly and FreeBSD compatibility.
--- sf-gencode.h.orig 2007-11-07 06:34:18.000000000 +0000
+++ sf-gencode.h
@ -6,7 +8,7 @@ $NetBSD: patch-aj,v 1.2 2011/06/10 11:45:01 obache Exp $
struct arth *gen_loadexpire(void);
void bpf_optimize(struct block **);
+#ifdef __DragonFly__
+#if defined(__DragonFly__) || defined(__FreeBSD__)
+void bpf_error(const char *, ...)
+ __attribute__((volatile, __format__ (printf, 1, 2)));
+#else
@ -20,7 +22,7 @@ $NetBSD: patch-aj,v 1.2 2011/06/10 11:45:01 obache Exp $
#define JT(b) ((b)->et.succ)
#define JF(b) ((b)->ef.succ)
+#ifdef __DragonFly__
+#if defined(__DragonFly__) || defined(__FreeBSD__)
+void sf_error(const char *fmt, ...);
+#else
__dead void sf_error(const char *fmt, ...);

View file

@ -1,16 +1,21 @@
$NetBSD: patch-al,v 1.1 2011/02/09 22:51:38 rumko Exp $
$NetBSD: patch-al,v 1.2 2015/01/14 20:39:42 rumko Exp $
$OpenBSD: patch-cache_h,v 1.1 2008/06/13 00:38:12 canacar Exp $
FreeBSD compatibility.
Patches to support PF > 4.1 taken from OpenBSD's ports.
--- cache.h.orig Tue Nov 6 23:34:18 2007
+++ cache.h Wed Jun 11 19:50:07 2008
@@ -31,14 +31,20 @@
--- cache.h.orig 2007-11-07 06:34:18.000000000 +0000
+++ cache.h
@@ -31,14 +31,24 @@
struct sc_ent {
RB_ENTRY(sc_ent) tlink;
TAILQ_ENTRY(sc_ent) qlink;
+#ifdef HAVE_PFSYNC_STATE
+#if defined(__FreeBSD__) && __FreeBSD_version > 1000017
+ u_int64_t id;
+#else
+ u_int32_t id[2];
+#endif
+#else
struct pf_addr addr[2];
+#endif