sysutils/pftop: fix build on fbsd >= 10 Ok@ wizdiff -r1.9 -r1.10 pkgsrc/sysutils/pftop/distinfo
(rumko)
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | $NetBSD: distinfo,v 1.9 2011/06/10 11:45:01 obache Exp $ | 1 | $NetBSD: distinfo,v 1.10 2015/01/14 20:39:42 rumko Exp $ | |
2 | 2 | |||
3 | SHA1 (pftop-0.7.tar.gz) = 651afa532cfc8cf59c3598704deb9bf3788ac9e9 | 3 | SHA1 (pftop-0.7.tar.gz) = 651afa532cfc8cf59c3598704deb9bf3788ac9e9 | |
4 | RMD160 (pftop-0.7.tar.gz) = 0e0c09e5feeb07deba8b540233dcb946ba0b4508 | 4 | RMD160 (pftop-0.7.tar.gz) = 0e0c09e5feeb07deba8b540233dcb946ba0b4508 | |
5 | Size (pftop-0.7.tar.gz) = 59765 bytes | 5 | Size (pftop-0.7.tar.gz) = 59765 bytes | |
6 | SHA1 (patch-aa) = ff5c522223472188933a6ccbe9725190dc8ec1b5 | 6 | SHA1 (patch-aa) = ff5c522223472188933a6ccbe9725190dc8ec1b5 | |
7 | SHA1 (patch-ab) = fccf6fe5348f24d00dbf26cbe1880b9298774c6b | 7 | SHA1 (patch-ab) = 863e4f5540e7e6d35a084b7f0331e79ca3a6e0b9 | |
8 | SHA1 (patch-ac) = 0bbbe06873c76393cc14c17f2f9a946ded71d068 | 8 | SHA1 (patch-ac) = 0bbbe06873c76393cc14c17f2f9a946ded71d068 | |
9 | SHA1 (patch-ad) = a2999c5c42d96baf6bde55c2925f83aadee17394 | 9 | SHA1 (patch-ad) = 73d3d7f8cb565d2f5955f7002b14e49df0f9b72d | |
10 | SHA1 (patch-ae) = 54619b846899a7c4f260191a772e41e1c07c178c | 10 | SHA1 (patch-ae) = 54619b846899a7c4f260191a772e41e1c07c178c | |
11 | SHA1 (patch-af) = 59b907b20fa215b3f0a1e690c9c71d2f7077e322 | 11 | SHA1 (patch-af) = 59b907b20fa215b3f0a1e690c9c71d2f7077e322 | |
12 | SHA1 (patch-ag) = 2e749dc45b2b91a1563bc1467b69775f595e4d03 | 12 | SHA1 (patch-ag) = 2e749dc45b2b91a1563bc1467b69775f595e4d03 | |
13 | SHA1 (patch-ah) = 7adca5a484de91bf89e66d10ab645912068cd1c2 | 13 | SHA1 (patch-ah) = 91d9e2f97ab974f5497b475200f17142715027b3 | |
14 | SHA1 (patch-ai) = 629c1668eab0d819e590fb62b7afa6c85709fd15 | 14 | SHA1 (patch-ai) = 629c1668eab0d819e590fb62b7afa6c85709fd15 | |
15 | SHA1 (patch-aj) = ad0ddcbadbcd342c4973f932a3b7042a1c97e66b | 15 | SHA1 (patch-aj) = 5e1638ffb28f64c7bcc79984764cadba6ee3d41e | |
16 | SHA1 (patch-ak) = 78622d902016fa559ae3090d9c8407337d7cd0ed | 16 | SHA1 (patch-ak) = 78622d902016fa559ae3090d9c8407337d7cd0ed | |
17 | SHA1 (patch-al) = 94f87c9655fd772e05e193da90617d12200a6ae5 | 17 | SHA1 (patch-al) = bf1c2592cb0d84fcb60ed7f2ae2ffc1d6ca309d2 |
@@ -1,93 +1,108 @@ | @@ -1,93 +1,108 @@ | |||
1 | $NetBSD: patch-ab,v 1.6 2011/02/09 22:51:38 rumko Exp $ | 1 | $NetBSD: patch-ab,v 1.7 2015/01/14 20:39:42 rumko Exp $ | |
2 | $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ | 2 | $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ | |
3 | 3 | |||
4 | * DragonFly compatibility | 4 | * DragonFly and FreeBSD compatibility | |
5 | * Patches to support PF > 4.1 taken from OpenBSD's ports | 5 | * Patches to support PF > 4.1 taken from OpenBSD's ports | |
6 | 6 | |||
7 | --- cache.c.old 2008-06-14 17:43:59.000000000 +0200 | 7 | --- cache.c.orig 2007-11-07 06:34:18.000000000 +0000 | |
8 | +++ cache.c 2008-06-15 01:15:37.000000000 +0200 | 8 | +++ cache.c | |
9 | @@ -23,7 +23,11 @@ | 9 | @@ -23,7 +23,11 @@ | |
10 | #include <netinet/in.h> | 10 | #include <netinet/in.h> | |
11 | 11 | |||
12 | #include <netinet/tcp_fsm.h> | 12 | #include <netinet/tcp_fsm.h> | |
13 | +#ifdef __DragonFly__ | 13 | +#ifdef __DragonFly__ | |
14 | +#include <net/pf/pfvar.h> | 14 | +#include <net/pf/pfvar.h> | |
15 | +#else | 15 | +#else | |
16 | #include <net/pfvar.h> | 16 | #include <net/pfvar.h> | |
17 | +#endif /* !__DragonFly__ */ | 17 | +#endif /* !__DragonFly__ */ | |
18 | #include <arpa/inet.h> | 18 | #include <arpa/inet.h> | |
19 | 19 | |||
20 | #include <stdio.h> | 20 | #include <stdio.h> | |
21 | @@ -40,6 +44,7 @@ | 21 | @@ -40,6 +44,7 @@ static __inline int sc_cmp(struct sc_ent | |
22 | 22 | |||
23 | /* initialize the tree and queue */ | 23 | /* initialize the tree and queue */ | |
24 | RB_HEAD(sc_tree, sc_ent) sctree; | 24 | RB_HEAD(sc_tree, sc_ent) sctree; | |
25 | +RB_PROTOTYPE(sc_tree, sc_ent, tlink, sc_cmp); | 25 | +RB_PROTOTYPE(sc_tree, sc_ent, tlink, sc_cmp); | |
26 | TAILQ_HEAD(sc_queue, sc_ent) scq1, scq2, scq_free; | 26 | TAILQ_HEAD(sc_queue, sc_ent) scq1, scq2, scq_free; | |
27 | RB_GENERATE(sc_tree, sc_ent, tlink, sc_cmp); | 27 | RB_GENERATE(sc_tree, sc_ent, tlink, sc_cmp); | |
28 | 28 | |||
29 | @@ -118,12 +123,17 @@ | 29 | @@ -118,12 +123,21 @@ add_state(pf_state_t *st) | |
30 | 30 | |||
31 | cache_size--; | 31 | cache_size--; | |
32 | 32 | |||
33 | +#ifdef HAVE_PFSYNC_STATE | 33 | +#ifdef HAVE_PFSYNC_STATE | |
34 | +#if defined(__FreeBSD__) && __FreeBSD_version > 1000017 | |||
35 | + ent->id = st->id; | |||
36 | +#else | |||
34 | + ent->id[0] = st->id[0]; | 37 | + ent->id[0] = st->id[0]; | |
35 | + ent->id[1] = st->id[1]; | 38 | + ent->id[1] = st->id[1]; | |
39 | +#endif | |||
36 | +#else | 40 | +#else | |
37 | ent->addr[0] = st->lan.addr; | 41 | ent->addr[0] = st->lan.addr; | |
38 | ent->port[0] = st->lan.port; | 42 | ent->port[0] = st->lan.port; | |
39 | ent->addr[1] = st->ext.addr; | 43 | ent->addr[1] = st->ext.addr; | |
40 | ent->port[1] = st->ext.port; | 44 | ent->port[1] = st->ext.port; | |
41 | ent->af = st->af; | 45 | ent->af = st->af; | |
42 | ent->proto = st->proto; | 46 | ent->proto = st->proto; | |
43 | +#endif | 47 | +#endif | |
44 | #ifdef HAVE_INOUT_COUNT | 48 | #ifdef HAVE_INOUT_COUNT | |
45 | ent->bytes = COUNTER(st->bytes[0]) + COUNTER(st->bytes[1]); | 49 | ent->bytes = COUNTER(st->bytes[0]) + COUNTER(st->bytes[1]); | |
46 | #else | 50 | #else | |
47 | @@ -147,13 +157,17 @@ | 51 | @@ -147,13 +161,21 @@ cache_state(pf_state_t *st) | |
48 | if (cache_max == 0) | 52 | if (cache_max == 0) | |
49 | return (NULL); | 53 | return (NULL); | |
50 | 54 | |||
51 | +#ifdef HAVE_PFSYNC_STATE | 55 | +#ifdef HAVE_PFSYNC_STATE | |
56 | +#if defined(__FreeBSD__) && __FreeBSD_version > 1000017 | |||
57 | + ent.id = st->id; | |||
58 | +#else | |||
52 | + ent.id[0] = st->id[0]; | 59 | + ent.id[0] = st->id[0]; | |
53 | + ent.id[1] = st->id[1]; | 60 | + ent.id[1] = st->id[1]; | |
61 | +#endif | |||
54 | +#else | 62 | +#else | |
55 | ent.addr[0] = st->lan.addr; | 63 | ent.addr[0] = st->lan.addr; | |
56 | ent.port[0] = st->lan.port; | 64 | ent.port[0] = st->lan.port; | |
57 | ent.addr[1] = st->ext.addr; | 65 | ent.addr[1] = st->ext.addr; | |
58 | ent.port[1] = st->ext.port; | 66 | ent.port[1] = st->ext.port; | |
59 | ent.af = st->af; | 67 | ent.af = st->af; | |
60 | ent.proto = st->proto; | 68 | ent.proto = st->proto; | |
61 | - | 69 | - | |
62 | +#endif | 70 | +#endif | |
63 | old = RB_FIND(sc_tree, &sctree, &ent); | 71 | old = RB_FIND(sc_tree, &sctree, &ent); | |
64 | 72 | |||
65 | if (old == NULL) { | 73 | if (old == NULL) { | |
66 | @@ -210,8 +224,18 @@ | 74 | @@ -210,8 +232,25 @@ cache_endupdate(void) | |
67 | static __inline int | 75 | static __inline int | |
68 | sc_cmp(struct sc_ent *a, struct sc_ent *b) | 76 | sc_cmp(struct sc_ent *a, struct sc_ent *b) | |
69 | { | 77 | { | |
70 | +#ifdef HAVE_PFSYNC_STATE | 78 | +#ifdef HAVE_PFSYNC_STATE | |
79 | +#if defined(__FreeBSD__) && __FreeBSD_version > 1000017 | |||
80 | + if (a->id > b->id) | |||
81 | + return (1); | |||
82 | + if (a->id < b->id) | |||
83 | + return (-1); | |||
84 | +#else | |||
71 | + if (a->id[0] > b->id[0]) | 85 | + if (a->id[0] > b->id[0]) | |
72 | + return (1); | 86 | + return (1); | |
73 | + if (a->id[0] < b->id[0]) | 87 | + if (a->id[0] < b->id[0]) | |
74 | + return (-1); | 88 | + return (-1); | |
75 | + if (a->id[1] > b->id[1]) | 89 | + if (a->id[1] > b->id[1]) | |
76 | + return (1); | 90 | + return (1); | |
77 | + if (a->id[1] < b->id[1]) | 91 | + if (a->id[1] < b->id[1]) | |
78 | + return (-1); | 92 | + return (-1); | |
93 | +#endif | |||
79 | +#else | 94 | +#else | |
80 | int diff; | 95 | int diff; | |
81 | - | 96 | - | |
82 | + | 97 | + | |
83 | if ((diff = a->proto - b->proto) != 0) | 98 | if ((diff = a->proto - b->proto) != 0) | |
84 | return (diff); | 99 | return (diff); | |
85 | if ((diff = a->af - b->af) != 0) | 100 | if ((diff = a->af - b->af) != 0) | |
86 | @@ -269,6 +293,6 @@ | 101 | @@ -269,6 +308,6 @@ sc_cmp(struct sc_ent *a, struct sc_ent * | |
87 | return (diff); | 102 | return (diff); | |
88 | if ((diff = a->port[1] - b->port[1]) != 0) | 103 | if ((diff = a->port[1] - b->port[1]) != 0) | |
89 | return (diff); | 104 | return (diff); | |
90 | - | 105 | - | |
91 | +#endif | 106 | +#endif | |
92 | return (0); | 107 | return (0); | |
93 | } | 108 | } |
@@ -1,26 +1,26 @@ | @@ -1,26 +1,26 @@ | |||
1 | $NetBSD: patch-ad,v 1.3 2011/02/09 22:51:38 rumko Exp $ | 1 | $NetBSD: patch-ad,v 1.4 2015/01/14 20:39:42 rumko Exp $ | |
2 | $OpenBSD: patch-engine_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ | 2 | $OpenBSD: patch-engine_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ | |
3 | 3 | |||
4 | * DragonFly compatibility | 4 | * DragonFly and FreeBSD compatibility | |
5 | * Patches to support PF > 4.1 taken from OpenBSD's ports. | 5 | * Patches to support PF > 4.1 taken from OpenBSD's ports. | |
6 | 6 | |||
7 | --- engine.c.orig 2007-11-07 07:35:44 +0100 | 7 | --- engine.c.orig 2007-11-07 07:35:44 +0100 | |
8 | +++ engine.c 2009-11-17 00:31:46 +0100 | 8 | +++ engine.c 2009-11-17 00:31:46 +0100 | |
9 | @@ -18,11 +18,18 @@ | 9 | @@ -18,11 +18,18 @@ | |
10 | 10 | |||
11 | 11 | |||
12 | #include <sys/types.h> | 12 | #include <sys/types.h> | |
13 | +#ifdef __DragonFly__ | 13 | +#if defined(__DragonFly__) || defined(__FreeBSD__) | |
14 | +#include "queue.h" | 14 | +#include "queue.h" | |
15 | +#else | 15 | +#else | |
16 | #include <sys/queue.h> | 16 | #include <sys/queue.h> | |
17 | +#endif | 17 | +#endif | |
18 | 18 | |||
19 | #include <ctype.h> | 19 | #include <ctype.h> | |
20 | #include <curses.h> | 20 | #include <curses.h> | |
21 | +#include <errno.h> | 21 | +#include <errno.h> | |
22 | +#include <poll.h> | 22 | +#include <poll.h> | |
23 | #include <signal.h> | 23 | #include <signal.h> | |
24 | +#include <stdarg.h> | 24 | +#include <stdarg.h> | |
25 | #include <stdlib.h> | 25 | #include <stdlib.h> | |
26 | #include <string.h> | 26 | #include <string.h> |
@@ -1,57 +1,57 @@ | @@ -1,57 +1,57 @@ | |||
1 | $NetBSD: patch-ah,v 1.3 2011/02/09 22:51:38 rumko Exp $ | 1 | $NetBSD: patch-ah,v 1.4 2015/01/14 20:39:42 rumko Exp $ | |
2 | $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ | 2 | $OpenBSD: patch-sf-gencode_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ | |
3 | 3 | |||
4 | * DragonFly compatibility | 4 | * DragonFly and FreeBSD compatibility | |
5 | * Patches to support PF > 4.1 taken from OpenBSD's ports. | 5 | * Patches to support PF > 4.1 taken from OpenBSD's ports. | |
6 | 6 | |||
7 | --- sf-gencode.c.orig 2007-11-07 07:34:18 +0100 | 7 | --- sf-gencode.c.orig 2007-11-07 06:34:18.000000000 +0000 | |
8 | +++ sf-gencode.c 2010-09-16 01:35:22 +0200 | 8 | +++ sf-gencode.c | |
9 | @@ -32,8 +32,12 @@ | 9 | @@ -32,8 +32,12 @@ | |
10 | #include <netinet/in.h> | 10 | #include <netinet/in.h> | |
11 | #include <netinet/if_ether.h> | 11 | #include <netinet/if_ether.h> | |
12 | 12 | |||
13 | -#include <net/if_pflog.h> | 13 | -#include <net/if_pflog.h> | |
14 | +#ifdef __DragonFly__ | 14 | +#ifdef __DragonFly__ | |
15 | +#include <sys/param.h> | 15 | +#include <sys/param.h> | |
16 | +#include <net/pf/pfvar.h> | 16 | +#include <net/pf/pfvar.h> | |
17 | +#else | 17 | +#else | |
18 | #include <net/pfvar.h> | 18 | #include <net/pfvar.h> | |
19 | +#endif /* !__DragonFly__ */ | 19 | +#endif /* !__DragonFly__ */ | |
20 | 20 | |||
21 | #include <netdb.h> | 21 | #include <netdb.h> | |
22 | #include <stdlib.h> | 22 | #include <stdlib.h> | |
23 | @@ -44,7 +48,7 @@ | 23 | @@ -44,7 +48,7 @@ | |
24 | 24 | |||
25 | #define INET6 | 25 | #define INET6 | |
26 | 26 | |||
27 | -#include <pcap-int.h> | 27 | -#include <pcap-int.h> | |
28 | +#include "pcap-int.h" | 28 | +#include "pcap-int.h" | |
29 | #include <pcap-namedb.h> | 29 | #include <pcap-namedb.h> | |
30 | #include "sf-gencode.h" | 30 | #include "sf-gencode.h" | |
31 | 31 | |||
32 | @@ -60,7 +64,11 @@ | 32 | @@ -60,7 +64,11 @@ static jmp_buf top_ctx; | |
33 | static char sf_errbuf[PFTOP_ERRBUF_SIZE]; | 33 | static char sf_errbuf[PFTOP_ERRBUF_SIZE]; | |
34 | 34 | |||
35 | /* VARARGS */ | 35 | /* VARARGS */ | |
36 | +#ifdef __DragonFly__ | 36 | +#if defined(__DragonFly__) || defined(__FreeBSD__) | |
37 | +void | 37 | +void | |
38 | +#else | 38 | +#else | |
39 | __dead void | 39 | __dead void | |
40 | +#endif | 40 | +#endif | |
41 | sf_error(const char *fmt, ...) | 41 | sf_error(const char *fmt, ...) | |
42 | { | 42 | { | |
43 | va_list ap; | 43 | va_list ap; | |
44 | @@ -474,6 +482,106 @@ | 44 | @@ -474,6 +482,106 @@ gen_proto(int proto) | |
45 | (bpf_int32)proto)); | 45 | (bpf_int32)proto)); | |
46 | } | 46 | } | |
47 | 47 | |||
48 | +#ifdef HAVE_PFSYNC_KEY | 48 | +#ifdef HAVE_PFSYNC_KEY | |
49 | +static struct block * | 49 | +static struct block * | |
50 | +gen_hostop(bpf_u_int32 addr, bpf_u_int32 mask, int dir) | 50 | +gen_hostop(bpf_u_int32 addr, bpf_u_int32 mask, int dir) | |
51 | +{ | 51 | +{ | |
52 | + struct block *b0, *b1, *b2, *bi, *bo; | 52 | + struct block *b0, *b1, *b2, *bi, *bo; | |
53 | + const static int isrc_off = offsetof(pf_state_t, key[PF_SK_STACK].addr[0].v4); | 53 | + const static int isrc_off = offsetof(pf_state_t, key[PF_SK_STACK].addr[0].v4); | |
54 | + const static int osrc_off = offsetof(pf_state_t, key[PF_SK_WIRE].addr[1].v4); | 54 | + const static int osrc_off = offsetof(pf_state_t, key[PF_SK_WIRE].addr[1].v4); | |
55 | + const static int idst_off = offsetof(pf_state_t, key[PF_SK_STACK].addr[1].v4); | 55 | + const static int idst_off = offsetof(pf_state_t, key[PF_SK_STACK].addr[1].v4); | |
56 | + const static int odst_off = offsetof(pf_state_t, key[PF_SK_WIRE].addr[0].v4); | 56 | + const static int odst_off = offsetof(pf_state_t, key[PF_SK_WIRE].addr[0].v4); | |
57 | + | 57 | + | |
@@ -138,46 +138,46 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/ | @@ -138,46 +138,46 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/ | |||
138 | + sf_error("Internal error: Invalid direcion specifier: %d", dir); | 138 | + sf_error("Internal error: Invalid direcion specifier: %d", dir); | |
139 | + } | 139 | + } | |
140 | + | 140 | + | |
141 | + b0 = gen_linktype(ETHERTYPE_IP); | 141 | + b0 = gen_linktype(ETHERTYPE_IP); | |
142 | + gen_and(b0, b1); | 142 | + gen_and(b0, b1); | |
143 | + | 143 | + | |
144 | + return b1; | 144 | + return b1; | |
145 | +} | 145 | +} | |
146 | + | 146 | + | |
147 | +#else | 147 | +#else | |
148 | static struct block * | 148 | static struct block * | |
149 | gen_hostop(bpf_u_int32 addr, bpf_u_int32 mask, int dir) | 149 | gen_hostop(bpf_u_int32 addr, bpf_u_int32 mask, int dir) | |
150 | { | 150 | { | |
151 | @@ -482,8 +590,10 @@ | 151 | @@ -482,8 +590,10 @@ gen_hostop(bpf_u_int32 addr, bpf_u_int32 | |
152 | const static int gwy_off = offsetof(pf_state_t, gwy.addr.v4); | 152 | const static int gwy_off = offsetof(pf_state_t, gwy.addr.v4); | |
153 | const static int ext_off = offsetof(pf_state_t, ext.addr.v4); | 153 | const static int ext_off = offsetof(pf_state_t, ext.addr.v4); | |
154 | 154 | |||
155 | +#if !defined(__DragonFly__) | 155 | +#if !defined(__DragonFly__) | |
156 | addr = ntohl(addr); | 156 | addr = ntohl(addr); | |
157 | mask = ntohl(mask); | 157 | mask = ntohl(mask); | |
158 | +#endif | 158 | +#endif | |
159 | 159 | |||
160 | switch (dir) { | 160 | switch (dir) { | |
161 | 161 | |||
162 | @@ -542,6 +652,7 @@ | 162 | @@ -542,6 +652,7 @@ gen_hostop(bpf_u_int32 addr, bpf_u_int32 | |
163 | 163 | |||
164 | return b1; | 164 | return b1; | |
165 | } | 165 | } | |
166 | +#endif | 166 | +#endif | |
167 | 167 | |||
168 | static struct block * | 168 | static struct block * | |
169 | gen_hostcmp6(u_int off, u_int32_t *a, u_int32_t *m) | 169 | gen_hostcmp6(u_int off, u_int32_t *a, u_int32_t *m) | |
170 | @@ -560,6 +671,105 @@ | 170 | @@ -560,6 +671,105 @@ gen_hostcmp6(u_int off, u_int32_t *a, u_ | |
171 | return b1; | 171 | return b1; | |
172 | } | 172 | } | |
173 | 173 | |||
174 | +#ifdef HAVE_PFSYNC_KEY | 174 | +#ifdef HAVE_PFSYNC_KEY | |
175 | +static struct block * | 175 | +static struct block * | |
176 | +gen_hostop6(struct in6_addr *addr, struct in6_addr *mask, int dir) | 176 | +gen_hostop6(struct in6_addr *addr, struct in6_addr *mask, int dir) | |
177 | + | 177 | + | |
178 | +{ | 178 | +{ | |
179 | + struct block *b0, *b1, *b2, *bi, *bo; | 179 | + struct block *b0, *b1, *b2, *bi, *bo; | |
180 | + u_int32_t *a, *m; | 180 | + u_int32_t *a, *m; | |
181 | + const static int isrc_off = offsetof(pf_state_t, key[PF_SK_STACK].addr[0].v6); | 181 | + const static int isrc_off = offsetof(pf_state_t, key[PF_SK_STACK].addr[0].v6); | |
182 | + const static int osrc_off = offsetof(pf_state_t, key[PF_SK_WIRE].addr[1].v6); | 182 | + const static int osrc_off = offsetof(pf_state_t, key[PF_SK_WIRE].addr[1].v6); | |
183 | + const static int idst_off = offsetof(pf_state_t, key[PF_SK_STACK].addr[1].v6); | 183 | + const static int idst_off = offsetof(pf_state_t, key[PF_SK_STACK].addr[1].v6); | |
@@ -263,53 +263,53 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/ | @@ -263,53 +263,53 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/ | |||
263 | + default: | 263 | + default: | |
264 | + sf_error("Internal error: Invalid direcion specifier: %d", dir); | 264 | + sf_error("Internal error: Invalid direcion specifier: %d", dir); | |
265 | + } | 265 | + } | |
266 | + | 266 | + | |
267 | + b0 = gen_linktype(ETHERTYPE_IPV6); | 267 | + b0 = gen_linktype(ETHERTYPE_IPV6); | |
268 | + gen_and(b0, b1); | 268 | + gen_and(b0, b1); | |
269 | + | 269 | + | |
270 | + return b1; | 270 | + return b1; | |
271 | +} | 271 | +} | |
272 | +#else | 272 | +#else | |
273 | static struct block * | 273 | static struct block * | |
274 | gen_hostop6(struct in6_addr *addr, struct in6_addr *mask, int dir) | 274 | gen_hostop6(struct in6_addr *addr, struct in6_addr *mask, int dir) | |
275 | { | 275 | { | |
276 | @@ -630,6 +840,7 @@ | 276 | @@ -630,6 +840,7 @@ gen_hostop6(struct in6_addr *addr, struc | |
277 | gen_and(b0, b1); | 277 | gen_and(b0, b1); | |
278 | return b1; | 278 | return b1; | |
279 | } | 279 | } | |
280 | +#endif | 280 | +#endif | |
281 | 281 | |||
282 | static const char * | 282 | static const char * | |
283 | get_modifier_by_id(int id) | 283 | get_modifier_by_id(int id) | |
284 | @@ -733,13 +944,17 @@ | 284 | @@ -733,13 +944,17 @@ gen_proto_abbrev(proto) | |
285 | b1 = gen_proto(IPPROTO_ESP); | 285 | b1 = gen_proto(IPPROTO_ESP); | |
286 | break; | 286 | break; | |
287 | 287 | |||
288 | +#ifdef IPPROTO_PFSYNC | 288 | +#ifdef IPPROTO_PFSYNC | |
289 | case Q_PFSYNC: | 289 | case Q_PFSYNC: | |
290 | b1 = gen_proto(IPPROTO_PFSYNC); | 290 | b1 = gen_proto(IPPROTO_PFSYNC); | |
291 | break; | 291 | break; | |
292 | +#endif /* IPPROTO_PFSYNC */ | 292 | +#endif /* IPPROTO_PFSYNC */ | |
293 | 293 | |||
294 | +#ifdef IPPROTO_CARP | 294 | +#ifdef IPPROTO_CARP | |
295 | case Q_CARP: | 295 | case Q_CARP: | |
296 | b1 = gen_proto(IPPROTO_CARP); | 296 | b1 = gen_proto(IPPROTO_CARP); | |
297 | break; | 297 | break; | |
298 | +#endif /* IPPROTO_CARP */ | 298 | +#endif /* IPPROTO_CARP */ | |
299 | 299 | |||
300 | default: | 300 | default: | |
301 | sf_error("Unknown protocol abbreviation"); | 301 | sf_error("Unknown protocol abbreviation"); | |
302 | @@ -748,6 +963,106 @@ | 302 | @@ -748,6 +963,106 @@ gen_proto_abbrev(proto) | |
303 | return b1; | 303 | return b1; | |
304 | } | 304 | } | |
305 | 305 | |||
306 | +#ifdef HAVE_PFSYNC_KEY | 306 | +#ifdef HAVE_PFSYNC_KEY | |
307 | +struct block * | 307 | +struct block * | |
308 | +gen_portop(int port, int proto, int dir) | 308 | +gen_portop(int port, int proto, int dir) | |
309 | +{ | 309 | +{ | |
310 | + struct block *b0, *b1, *b2, *bi, *bo; | 310 | + struct block *b0, *b1, *b2, *bi, *bo; | |
311 | + const static int isrc_off = offsetof(pf_state_t, key[PF_SK_STACK].port[0]); | 311 | + const static int isrc_off = offsetof(pf_state_t, key[PF_SK_STACK].port[0]); | |
312 | + const static int osrc_off = offsetof(pf_state_t, key[PF_SK_WIRE].port[1]); | 312 | + const static int osrc_off = offsetof(pf_state_t, key[PF_SK_WIRE].port[1]); | |
313 | + const static int idst_off = offsetof(pf_state_t, key[PF_SK_STACK].port[1]); | 313 | + const static int idst_off = offsetof(pf_state_t, key[PF_SK_STACK].port[1]); | |
314 | + const static int odst_off = offsetof(pf_state_t, key[PF_SK_WIRE].port[0]); | 314 | + const static int odst_off = offsetof(pf_state_t, key[PF_SK_WIRE].port[0]); | |
315 | + | 315 | + | |
@@ -396,40 +396,40 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/ | @@ -396,40 +396,40 @@ $OpenBSD: patch-sf-gencode_c,v 1.1 2008/ | |||
396 | + } | 396 | + } | |
397 | + | 397 | + | |
398 | + | 398 | + | |
399 | + | 399 | + | |
400 | + b0 = gen_proto(proto); | 400 | + b0 = gen_proto(proto); | |
401 | + gen_and(b0, b1); | 401 | + gen_and(b0, b1); | |
402 | + | 402 | + | |
403 | + return b1; | 403 | + return b1; | |
404 | +} | 404 | +} | |
405 | +#else | 405 | +#else | |
406 | struct block * | 406 | struct block * | |
407 | gen_portop(int port, int proto, int dir) | 407 | gen_portop(int port, int proto, int dir) | |
408 | { | 408 | { | |
409 | @@ -756,7 +1071,9 @@ | 409 | @@ -756,7 +1071,9 @@ gen_portop(int port, int proto, int dir) | |
410 | const static int gwy_off = offsetof(pf_state_t, gwy.port); | 410 | const static int gwy_off = offsetof(pf_state_t, gwy.port); | |
411 | const static int ext_off = offsetof(pf_state_t, ext.port); | 411 | const static int ext_off = offsetof(pf_state_t, ext.port); | |
412 | 412 | |||
413 | +#if !defined(__DragonFly__) | 413 | +#if !defined(__DragonFly__) | |
414 | port = ntohs(port); | 414 | port = ntohs(port); | |
415 | +#endif | 415 | +#endif | |
416 | 416 | |||
417 | switch (dir) { | 417 | switch (dir) { | |
418 | 418 | |||
419 | @@ -815,6 +1132,7 @@ | 419 | @@ -815,6 +1132,7 @@ gen_portop(int port, int proto, int dir) | |
420 | 420 | |||
421 | return b1; | 421 | return b1; | |
422 | } | 422 | } | |
423 | +#endif | 423 | +#endif | |
424 | 424 | |||
425 | static struct block * | 425 | static struct block * | |
426 | gen_port(int port, int ip_proto, int dir) | 426 | gen_port(int port, int ip_proto, int dir) | |
427 | @@ -1560,7 +1878,7 @@ | 427 | @@ -1560,7 +1878,7 @@ gen_ifname(char *ifname) | |
428 | /* NOTREACHED */ | 428 | /* NOTREACHED */ | |
429 | } | 429 | } | |
430 | 430 | |||
431 | - b0 = gen_bcmp(off, strlen(ifname), ifname); | 431 | - b0 = gen_bcmp(off, strlen(ifname), ifname); | |
432 | + b0 = gen_bcmp(off, strlen(ifname), (const u_char *)ifname); | 432 | + b0 = gen_bcmp(off, strlen(ifname), (const u_char *)ifname); | |
433 | return (b0); | 433 | return (b0); | |
434 | #else | 434 | #else | |
435 | sf_error("ifname not supported in this OpenBSD release"); | 435 | sf_error("ifname not supported in this OpenBSD release"); |
@@ -1,34 +1,36 @@ | @@ -1,34 +1,36 @@ | |||
1 | $NetBSD: patch-aj,v 1.2 2011/06/10 11:45:01 obache Exp $ | 1 | $NetBSD: patch-aj,v 1.3 2015/01/14 20:39:42 rumko Exp $ | |
2 | ||||
3 | DragonFly and FreeBSD compatibility. | |||
2 | 4 | |||
3 | --- sf-gencode.h.orig 2007-11-07 06:34:18.000000000 +0000 | 5 | --- sf-gencode.h.orig 2007-11-07 06:34:18.000000000 +0000 | |
4 | +++ sf-gencode.h | 6 | +++ sf-gencode.h | |
5 | @@ -169,8 +169,13 @@ struct arth *gen_loadage(void); | 7 | @@ -169,8 +169,13 @@ struct arth *gen_loadage(void); | |
6 | struct arth *gen_loadexpire(void); | 8 | struct arth *gen_loadexpire(void); | |
7 | 9 | |||
8 | void bpf_optimize(struct block **); | 10 | void bpf_optimize(struct block **); | |
9 | +#ifdef __DragonFly__ | 11 | +#if defined(__DragonFly__) || defined(__FreeBSD__) | |
10 | +void bpf_error(const char *, ...) | 12 | +void bpf_error(const char *, ...) | |
11 | + __attribute__((volatile, __format__ (printf, 1, 2))); | 13 | + __attribute__((volatile, __format__ (printf, 1, 2))); | |
12 | +#else | 14 | +#else | |
13 | __dead void bpf_error(const char *, ...) | 15 | __dead void bpf_error(const char *, ...) | |
14 | __attribute__((volatile, __format__ (printf, 1, 2))); | 16 | __attribute__((volatile, __format__ (printf, 1, 2))); | |
15 | +#endif | 17 | +#endif | |
16 | 18 | |||
17 | void finish_parse(struct block *); | 19 | void finish_parse(struct block *); | |
18 | char *sdup(const char *); | 20 | char *sdup(const char *); | |
19 | @@ -184,11 +189,14 @@ void sappend(struct slist *, struct slis | 21 | @@ -184,11 +189,14 @@ void sappend(struct slist *, struct slis | |
20 | #define JT(b) ((b)->et.succ) | 22 | #define JT(b) ((b)->et.succ) | |
21 | #define JF(b) ((b)->ef.succ) | 23 | #define JF(b) ((b)->ef.succ) | |
22 | 24 | |||
23 | +#ifdef __DragonFly__ | 25 | +#if defined(__DragonFly__) || defined(__FreeBSD__) | |
24 | +void sf_error(const char *fmt, ...); | 26 | +void sf_error(const char *fmt, ...); | |
25 | +#else | 27 | +#else | |
26 | __dead void sf_error(const char *fmt, ...); | 28 | __dead void sf_error(const char *fmt, ...); | |
27 | +#endif | 29 | +#endif | |
28 | const char *sf_get_error(void); | 30 | const char *sf_get_error(void); | |
29 | int sf_compile(struct bpf_program *, char *, int, bpf_u_int32); | 31 | int sf_compile(struct bpf_program *, char *, int, bpf_u_int32); | |
30 | void sf_freecode(struct bpf_program *); | 32 | void sf_freecode(struct bpf_program *); | |
31 | -void bpf_dump(struct bpf_program *, int); | 33 | -void bpf_dump(struct bpf_program *, int); | |
32 | 34 | |||
33 | extern int no_optimize; | 35 | extern int no_optimize; | |
34 | 36 |
@@ -1,26 +1,31 @@ | @@ -1,26 +1,31 @@ | |||
1 | $NetBSD: patch-al,v 1.1 2011/02/09 22:51:38 rumko Exp $ | 1 | $NetBSD: patch-al,v 1.2 2015/01/14 20:39:42 rumko Exp $ | |
2 | $OpenBSD: patch-cache_h,v 1.1 2008/06/13 00:38:12 canacar Exp $ | 2 | $OpenBSD: patch-cache_h,v 1.1 2008/06/13 00:38:12 canacar Exp $ | |
3 | 3 | |||
4 | FreeBSD compatibility. | |||
4 | Patches to support PF > 4.1 taken from OpenBSD's ports. | 5 | Patches to support PF > 4.1 taken from OpenBSD's ports. | |
5 | 6 | |||
6 | --- cache.h.orig Tue Nov 6 23:34:18 2007 | 7 | --- cache.h.orig 2007-11-07 06:34:18.000000000 +0000 | |
7 | +++ cache.h Wed Jun 11 19:50:07 2008 | 8 | +++ cache.h | |
8 | @@ -31,14 +31,20 @@ | 9 | @@ -31,14 +31,24 @@ | |
9 | struct sc_ent { | 10 | struct sc_ent { | |
10 | RB_ENTRY(sc_ent) tlink; | 11 | RB_ENTRY(sc_ent) tlink; | |
11 | TAILQ_ENTRY(sc_ent) qlink; | 12 | TAILQ_ENTRY(sc_ent) qlink; | |
12 | +#ifdef HAVE_PFSYNC_STATE | 13 | +#ifdef HAVE_PFSYNC_STATE | |
14 | +#if defined(__FreeBSD__) && __FreeBSD_version > 1000017 | |||
15 | + u_int64_t id; | |||
16 | +#else | |||
13 | + u_int32_t id[2]; | 17 | + u_int32_t id[2]; | |
18 | +#endif | |||
14 | +#else | 19 | +#else | |
15 | struct pf_addr addr[2]; | 20 | struct pf_addr addr[2]; | |
16 | +#endif | 21 | +#endif | |
17 | double peak; | 22 | double peak; | |
18 | double rate; | 23 | double rate; | |
19 | time_t t; | 24 | time_t t; | |
20 | u_int32_t bytes; | 25 | u_int32_t bytes; | |
21 | +#ifndef HAVE_PFSYNC_STATE | 26 | +#ifndef HAVE_PFSYNC_STATE | |
22 | u_int16_t port[2]; | 27 | u_int16_t port[2]; | |
23 | u_int8_t af; | 28 | u_int8_t af; | |
24 | u_int8_t proto; | 29 | u_int8_t proto; | |
25 | +#endif | 30 | +#endif | |
26 | }; | 31 | }; |