summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authormlaier <mlaier@FreeBSD.org>2004-02-28 17:32:53 +0000
committermlaier <mlaier@FreeBSD.org>2004-02-28 17:32:53 +0000
commitcfa84beb14b57fb04e0c99796c7b1ef9f4719274 (patch)
treec31333426907530b588b3b90bbec666e0c0bd647 /contrib
parent80dc4d1b917ca6fab4a6f9dd6a58da889fd7b4dc (diff)
downloadFreeBSD-src-cfa84beb14b57fb04e0c99796c7b1ef9f4719274.zip
FreeBSD-src-cfa84beb14b57fb04e0c99796c7b1ef9f4719274.tar.gz
Apply diff from the port.
Rather small diff for the userland (in contrast to the kernel): - Some header file location/differences - Clean compilation on 64bit arch (identified by bento a long time ago) - ALTQ not (yet) available. Leave a switch for patchsets and future ... - most files can be used from the vendor branch Approved by: bms(in general)
Diffstat (limited to 'contrib')
-rw-r--r--contrib/pf/authpf/authpf.c7
-rw-r--r--contrib/pf/ftp-proxy/ftp-proxy.c2
-rw-r--r--contrib/pf/pfctl/pfctl.c27
-rw-r--r--contrib/pf/pfctl/pfctl.h5
-rw-r--r--contrib/pf/pfctl/pfctl_altq.c39
-rw-r--r--contrib/pf/pfctl/pfctl_parser.c34
-rw-r--r--contrib/pf/pfctl/pfctl_parser.h25
-rw-r--r--contrib/pf/pfctl/pfctl_qstats.c23
-rw-r--r--contrib/pf/pfctl/pfctl_table.c13
-rw-r--r--contrib/pf/pflogd/pflogd.c13
10 files changed, 165 insertions, 23 deletions
diff --git a/contrib/pf/authpf/authpf.c b/contrib/pf/authpf/authpf.c
index 8828ffc..09d0ac3 100644
--- a/contrib/pf/authpf/authpf.c
+++ b/contrib/pf/authpf/authpf.c
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $OpenBSD: authpf.c,v 1.68 2003/08/21 19:13:23 frantzen Exp $ */
/*
@@ -49,6 +50,9 @@
#include "pathnames.h"
+#if defined(__FreeBSD__)
+#define __dead __volatile
+#endif
extern int symset(const char *, const char *, int);
static int read_config(FILE *);
@@ -285,6 +289,9 @@ dogdeath:
sleep(180); /* them lusers read reaaaaal slow */
die:
do_death(0);
+#if defined(__FreeBSD__)
+ return 0; /* gcc hack to prevent warning */
+#endif
}
/*
diff --git a/contrib/pf/ftp-proxy/ftp-proxy.c b/contrib/pf/ftp-proxy/ftp-proxy.c
index 88b6fd1..2c44431 100644
--- a/contrib/pf/ftp-proxy/ftp-proxy.c
+++ b/contrib/pf/ftp-proxy/ftp-proxy.c
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $OpenBSD: ftp-proxy.c,v 1.33 2003/08/22 21:50:34 david Exp $ */
/*
@@ -67,6 +68,7 @@
* - per-user rules perhaps.
*/
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
diff --git a/contrib/pf/pfctl/pfctl.c b/contrib/pf/pfctl/pfctl.c
index 0e52476..9a8fed8 100644
--- a/contrib/pf/pfctl/pfctl.c
+++ b/contrib/pf/pfctl/pfctl.c
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $OpenBSD: pfctl.c,v 1.188 2003/08/29 21:47:36 cedric Exp $ */
/*
@@ -36,6 +37,12 @@
#include <net/if.h>
#include <netinet/in.h>
+#if defined(__FreeBSD__)
+#include <inttypes.h>
+#include <net/route.h>
+#else
+#define PRIu64 "llu"
+#endif
#include <net/pfvar.h>
#include <arpa/inet.h>
#include <altq/altq.h>
@@ -194,6 +201,10 @@ pfctl_enable(int dev, int opts)
if (ioctl(dev, DIOCSTART)) {
if (errno == EEXIST)
errx(1, "pf already enabled");
+#if defined(__FreeBSD__)
+ else if (errno == ESRCH)
+ errx(1, "pfil registeration failed");
+#endif
else
err(1, "DIOCSTART");
}
@@ -543,8 +554,8 @@ pfctl_print_rule_counters(struct pf_rule *rule, int opts)
rule->qname, rule->qid, rule->pqname, rule->pqid);
}
if (opts & PF_OPT_VERBOSE)
- printf(" [ Evaluations: %-8llu Packets: %-8llu "
- "Bytes: %-10llu States: %-6u]\n",
+ printf(" [ Evaluations: %-8"PRIu64" Packets: %-8"PRIu64" "
+ "Bytes: %-10"PRIu64" States: %-6u]\n",
rule->evaluations, rule->packets,
rule->bytes, rule->states);
}
@@ -608,7 +619,7 @@ pfctl_show_rules(int dev, int opts, int format, char *anchorname,
case 1:
if (pr.rule.label[0]) {
printf("%s ", pr.rule.label);
- printf("%llu %llu %llu\n",
+ printf("%"PRIu64" %"PRIu64" %"PRIu64"\n",
pr.rule.evaluations, pr.rule.packets,
pr.rule.bytes);
}
@@ -640,7 +651,7 @@ pfctl_show_rules(int dev, int opts, int format, char *anchorname,
case 1:
if (pr.rule.label[0]) {
printf("%s ", pr.rule.label);
- printf("%llu %llu %llu\n",
+ printf("%"PRIu64" %"PRIu64" %"PRIu64"\n",
pr.rule.evaluations, pr.rule.packets,
pr.rule.bytes);
}
@@ -1222,6 +1233,9 @@ pfctl_clear_rule_counters(int dev, int opts)
int
pfctl_test_altqsupport(int dev, int opts)
{
+#if defined(__FreeBSD__) && !defined(ENABLE_ALTQ)
+ return (0);
+#else
struct pfioc_altq pa;
if (ioctl(dev, DIOCGETALTQS, &pa)) {
@@ -1234,6 +1248,7 @@ pfctl_test_altqsupport(int dev, int opts)
err(1, "DIOCGETALTQS");
}
return (1);
+#endif
}
int
@@ -1476,7 +1491,11 @@ main(int argc, char *argv[])
/* turn off options */
opts &= ~ (PF_OPT_DISABLE | PF_OPT_ENABLE);
clearopt = showopt = debugopt = NULL;
+#if defined(__FreeBSD__) && !defined(ENABLE_ALTQ)
+ altqsupport = 0;
+#else
altqsupport = 1;
+#endif
}
if (opts & PF_OPT_DISABLE)
diff --git a/contrib/pf/pfctl/pfctl.h b/contrib/pf/pfctl/pfctl.h
index 2149ac1..8b439b4 100644
--- a/contrib/pf/pfctl/pfctl.h
+++ b/contrib/pf/pfctl/pfctl.h
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $OpenBSD: pfctl.h,v 1.25 2003/08/29 21:47:36 cedric Exp $ */
/*
@@ -82,6 +83,10 @@ int pfctl_command_tables(int, char *[], char *, const char *, char *,
int pfctl_show_altq(int, int, int);
void warn_namespace_collision(const char *);
+#if defined(__FreeBSD__)
+extern int altqsupport;
+#endif
+
#ifndef DEFAULT_PRIORITY
#define DEFAULT_PRIORITY 1
#endif
diff --git a/contrib/pf/pfctl/pfctl_altq.c b/contrib/pf/pfctl/pfctl_altq.c
index efe92ab..807ecb5 100644
--- a/contrib/pf/pfctl/pfctl_altq.c
+++ b/contrib/pf/pfctl/pfctl_altq.c
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $OpenBSD: pfctl_altq.c,v 1.77 2003/08/22 21:50:34 david Exp $ */
/*
@@ -21,7 +22,9 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
+#if !defined(__FreeBSD__)
#include <sys/limits.h>
+#endif
#include <net/if.h>
#include <netinet/in.h>
@@ -74,7 +77,11 @@ static int gsc_add_seg(struct gen_sc *, double, double, double,
double);
static double sc_x2y(struct service_curve *, double);
+#if defined(__FreeBSD__)
+u_int32_t getifspeed(int, char *);
+#else
u_int32_t getifspeed(char *);
+#endif
u_long getifmtu(char *);
int eval_queue_opts(struct pf_altq *, struct node_queue_opt *,
u_int32_t);
@@ -239,7 +246,11 @@ eval_pfaltq(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw,
if (bw->bw_absolute > 0)
pa->ifbandwidth = bw->bw_absolute;
else
+#if defined(__FreeBSD__)
+ if ((rate = getifspeed(pf->dev, pa->ifname)) == 0) {
+#else
if ((rate = getifspeed(pa->ifname)) == 0) {
+#endif
fprintf(stderr, "cannot determine interface bandwidth "
"for %s, specify an absolute bandwidth\n",
pa->ifname);
@@ -869,7 +880,14 @@ print_hfsc_opts(const struct pf_altq *a, const struct node_queue_opt *qopts)
/*
* admission control using generalized service curve
*/
+#if defined(__FreeBSD__)
+#if defined(INFINITY)
+#undef INFINITY
+#endif
#define INFINITY HUGE_VAL /* positive infinity defined in <math.h> */
+#else
+#define INFINITY HUGE_VAL /* positive infinity defined in <math.h> */
+#endif
/* add a new service curve to a generalized service curve */
static void
@@ -1070,6 +1088,26 @@ rate2str(double rate)
return (buf);
}
+#if defined(__FreeBSD__)
+/*
+ * XXX
+ * FreeBSD do not have SIOCGIFDATA.
+ * To emulate this, DIOCGIFSPEED ioctl added to pf.
+ */
+u_int32_t
+getifspeed(int pfdev, char *ifname)
+{
+ struct pf_ifspeed io;
+
+ bzero(&io, sizeof io);
+ if (strlcpy(io.ifname, ifname, IFNAMSIZ) >=
+ sizeof(io.ifname))
+ errx(1, "getifspeed: strlcpy");
+ if (ioctl(pfdev, DIOCGIFSPEED, &io) == -1)
+ err(1, "DIOCGIFSPEED");
+ return ((u_int32_t)io.baudrate);
+}
+#else
u_int32_t
getifspeed(char *ifname)
{
@@ -1091,6 +1129,7 @@ getifspeed(char *ifname)
err(1, "close");
return ((u_int32_t)ifrdat.ifi_baudrate);
}
+#endif
u_long
getifmtu(char *ifname)
diff --git a/contrib/pf/pfctl/pfctl_parser.c b/contrib/pf/pfctl/pfctl_parser.c
index 7c051ac..de76cc7 100644
--- a/contrib/pf/pfctl/pfctl_parser.c
+++ b/contrib/pf/pfctl/pfctl_parser.c
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $OpenBSD: pfctl_parser.c,v 1.175 2003/09/18 20:27:58 cedric Exp $ */
/*
@@ -51,6 +52,13 @@
#include <err.h>
#include <ifaddrs.h>
+#if defined(__FreeBSD__)
+#include <inttypes.h>
+#else
+#define PRIu64 "llu"
+#define PRId64 "lld"
+#endif
+
#include "pfctl_parser.h"
#include "pfctl.h"
@@ -503,30 +511,30 @@ print_status(struct pf_status *s)
if (s->ifname[0] != 0) {
printf("Interface Stats for %-16s %5s %16s\n",
s->ifname, "IPv4", "IPv6");
- printf(" %-25s %14llu %16llu\n", "Bytes In",
+ printf(" %-25s %14"PRIu64" %16"PRIu64"\n", "Bytes In",
s->bcounters[0][0], s->bcounters[1][0]);
- printf(" %-25s %14llu %16llu\n", "Bytes Out",
+ printf(" %-25s %14"PRIu64" %16"PRIu64"\n", "Bytes Out",
s->bcounters[0][1], s->bcounters[1][1]);
printf(" Packets In\n");
- printf(" %-23s %14llu %16llu\n", "Passed",
+ printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Passed",
s->pcounters[0][0][PF_PASS],
s->pcounters[1][0][PF_PASS]);
- printf(" %-23s %14llu %16llu\n", "Blocked",
+ printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Blocked",
s->pcounters[0][0][PF_DROP],
s->pcounters[1][0][PF_DROP]);
printf(" Packets Out\n");
- printf(" %-23s %14llu %16llu\n", "Passed",
+ printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Passed",
s->pcounters[0][1][PF_PASS],
s->pcounters[1][1][PF_PASS]);
- printf(" %-23s %14llu %16llu\n\n", "Blocked",
+ printf(" %-23s %14"PRIu64" %16"PRIu64"\n\n", "Blocked",
s->pcounters[0][1][PF_DROP],
s->pcounters[1][1][PF_DROP]);
}
printf("%-27s %14s %16s\n", "State Table", "Total", "Rate");
printf(" %-25s %14u %14s\n", "current entries", s->states, "");
for (i = 0; i < FCNT_MAX; i++) {
- printf(" %-25s %14llu", pf_fcounters[i],
- (unsigned long long)s->fcounters[i]);
+ printf(" %-25s %14"PRIu64" ", pf_fcounters[i],
+ s->fcounters[i]);
if (runtime > 0)
printf("%14.1f/s\n",
(double)s->fcounters[i] / (double)runtime);
@@ -535,8 +543,8 @@ print_status(struct pf_status *s)
}
printf("Counters\n");
for (i = 0; i < PFRES_MAX; i++) {
- printf(" %-25s %14llu ", pf_reasons[i],
- (unsigned long long)s->counters[i]);
+ printf(" %-25s %14"PRIu64" ", pf_reasons[i],
+ s->counters[i]);
if (runtime > 0)
printf("%14.1f/s\n",
(double)s->counters[i] / (double)runtime);
@@ -1124,6 +1132,12 @@ host_v4(const char *s, int mask)
h->ifname = NULL;
h->af = AF_INET;
h->addr.v.a.addr.addr32[0] = ina.s_addr;
+#if defined(__FreeBSD__) && (__FreeBSD_version <= 501106)
+ /* inet_net_pton acts strange w/ multicast addresses, RFC1112 */
+ if (mask == -1 && h->addr.v.a.addr.addr8[0] >= 224 &&
+ h->addr.v.a.addr.addr8[0] < 240)
+ bits = 32;
+#endif
set_ipmask(h, bits);
h->next = NULL;
h->tail = h;
diff --git a/contrib/pf/pfctl/pfctl_parser.h b/contrib/pf/pfctl/pfctl_parser.h
index 88047e5..e866bd8 100644
--- a/contrib/pf/pfctl/pfctl_parser.h
+++ b/contrib/pf/pfctl/pfctl_parser.h
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $OpenBSD: pfctl_parser.h,v 1.67 2003/08/21 19:12:09 frantzen Exp $ */
/*
@@ -134,6 +135,30 @@ struct node_queue_opt {
} data;
};
+#if defined(__FreeBSD__)
+/*
+ * XXX
+ * Absolutely this is not correct location to define this.
+ * Should we use an another sperate header file?
+ */
+#define SIMPLEQ_HEAD STAILQ_HEAD
+#define SIMPLEQ_HEAD_INITIALIZER STAILQ_HEAD_INITIALIZER
+#define SIMPLEQ_ENTRY STAILQ_ENTRY
+#define SIMPLEQ_FIRST STAILQ_FIRST
+#define SIMPLEQ_END(head) NULL
+#define SIMPLEQ_EMPTY STAILQ_EMPTY
+#define SIMPLEQ_NEXT STAILQ_NEXT
+/*#define SIMPLEQ_FOREACH STAILQ_FOREACH*/
+#define SIMPLEQ_FOREACH(var, head, field) \
+ for((var) = SIMPLEQ_FIRST(head); \
+ (var) != SIMPLEQ_END(head); \
+ (var) = SIMPLEQ_NEXT(var, field))
+#define SIMPLEQ_INIT STAILQ_INIT
+#define SIMPLEQ_INSERT_HEAD STAILQ_INSERT_HEAD
+#define SIMPLEQ_INSERT_TAIL STAILQ_INSERT_TAIL
+#define SIMPLEQ_INSERT_AFTER STAILQ_INSERT_AFTER
+#define SIMPLEQ_REMOVE_HEAD STAILQ_REMOVE_HEAD
+#endif
SIMPLEQ_HEAD(node_tinithead, node_tinit);
struct node_tinit { /* table initializer */
SIMPLEQ_ENTRY(node_tinit) entries;
diff --git a/contrib/pf/pfctl/pfctl_qstats.c b/contrib/pf/pfctl/pfctl_qstats.c
index 23c431e..ea4b6f5 100644
--- a/contrib/pf/pfctl/pfctl_qstats.c
+++ b/contrib/pf/pfctl/pfctl_qstats.c
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $OpenBSD: pfctl_qstats.c,v 1.24 2003/07/31 09:46:08 kjc Exp $ */
/*
@@ -36,6 +37,12 @@
#include <altq/altq_priq.h>
#include <altq/altq_hfsc.h>
+#if defined(__FreeBSD__)
+#include <inttypes.h>
+#else
+#define PRIu64 "llu"
+#endif
+
#include "pfctl.h"
#include "pfctl_parser.h"
@@ -85,6 +92,10 @@ pfctl_show_altq(int dev, int opts, int verbose2)
{
struct pf_altq_node *root = NULL, *node;
+#if defined(__FreeBSD__)
+ if (!altqsupport)
+ return (-1);
+#endif
if (pfctl_update_qstats(dev, &root))
return (-1);
@@ -275,8 +286,8 @@ pfctl_print_altq_nodestat(int dev, const struct pf_altq_node *a)
void
print_cbqstats(struct queue_stats cur)
{
- printf(" [ pkts: %10llu bytes: %10llu "
- "dropped pkts: %6llu bytes: %6llu ]\n",
+ printf(" [ pkts: %10"PRIu64" bytes: %10"PRIu64" "
+ "dropped pkts: %6"PRIu64" bytes: %6"PRIu64" ]\n",
cur.data.cbq_stats.xmit_cnt.packets,
cur.data.cbq_stats.xmit_cnt.bytes,
cur.data.cbq_stats.drop_cnt.packets,
@@ -296,8 +307,8 @@ print_cbqstats(struct queue_stats cur)
void
print_priqstats(struct queue_stats cur)
{
- printf(" [ pkts: %10llu bytes: %10llu "
- "dropped pkts: %6llu bytes: %6llu ]\n",
+ printf(" [ pkts: %10"PRIu64" bytes: %10"PRIu64" "
+ "dropped pkts: %6"PRIu64" bytes: %6"PRIu64" ]\n",
cur.data.priq_stats.xmitcnt.packets,
cur.data.priq_stats.xmitcnt.bytes,
cur.data.priq_stats.dropcnt.packets,
@@ -316,8 +327,8 @@ print_priqstats(struct queue_stats cur)
void
print_hfscstats(struct queue_stats cur)
{
- printf(" [ pkts: %10llu bytes: %10llu "
- "dropped pkts: %6llu bytes: %6llu ]\n",
+ printf(" [ pkts: %10"PRIu64" bytes: %10"PRIu64" "
+ "dropped pkts: %6"PRIu64" bytes: %6"PRIu64" ]\n",
cur.data.hfsc_stats.xmit_cnt.packets,
cur.data.hfsc_stats.xmit_cnt.bytes,
cur.data.hfsc_stats.drop_cnt.packets,
diff --git a/contrib/pf/pfctl/pfctl_table.c b/contrib/pf/pfctl/pfctl_table.c
index 57bdf19..1764750 100644
--- a/contrib/pf/pfctl/pfctl_table.c
+++ b/contrib/pf/pfctl/pfctl_table.c
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $OpenBSD: pfctl_table.c,v 1.50 2003/08/29 21:47:36 cedric Exp $ */
/*
@@ -48,6 +49,12 @@
#include <string.h>
#include <time.h>
+#if defined(__FreeBSD__)
+#include <inttypes.h>
+#else
+#define PRIu64 "llu"
+#endif
+
#include "pfctl_parser.h"
#include "pfctl.h"
@@ -347,11 +354,11 @@ print_tstats(struct pfr_tstats *ts, int debug)
printf("\tReferences: [ Anchors: %-18d Rules: %-18d ]\n",
ts->pfrts_refcnt[PFR_REFCNT_ANCHOR],
ts->pfrts_refcnt[PFR_REFCNT_RULE]);
- printf("\tEvaluations: [ NoMatch: %-18llu Match: %-18llu ]\n",
+ printf("\tEvaluations: [ NoMatch: %-18"PRIu64" Match: %-18"PRIu64" ]\n",
ts->pfrts_nomatch, ts->pfrts_match);
for (dir = 0; dir < PFR_DIR_MAX; dir++)
for (op = 0; op < PFR_OP_TABLE_MAX; op++)
- printf("\t%-12s [ Packets: %-18llu Bytes: %-18llu ]\n",
+ printf("\t%-12s [ Packets: %-18"PRIu64" Bytes: %-18"PRIu64" ]\n",
stats_text[dir][op],
ts->pfrts_packets[dir][op],
ts->pfrts_bytes[dir][op]);
@@ -429,7 +436,7 @@ print_astats(struct pfr_astats *as, int dns)
printf("\tCleared: %s", ctime(&time));
for (dir = 0; dir < PFR_DIR_MAX; dir++)
for (op = 0; op < PFR_OP_ADDR_MAX; op++)
- printf("\t%-12s [ Packets: %-18llu Bytes: %-18llu ]\n",
+ printf("\t%-12s [ Packets: %-18"PRIu64" Bytes: %-18"PRIu64" ]\n",
stats_text[dir][op],
as->pfras_packets[dir][op],
as->pfras_bytes[dir][op]);
diff --git a/contrib/pf/pflogd/pflogd.c b/contrib/pf/pflogd/pflogd.c
index 9777f15..10d8816 100644
--- a/contrib/pf/pflogd/pflogd.c
+++ b/contrib/pf/pflogd/pflogd.c
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $OpenBSD: pflogd.c,v 1.21 2003/08/22 21:50:34 david Exp $ */
/*
@@ -44,7 +45,15 @@
#include <errno.h>
#include <stdarg.h>
#include <fcntl.h>
+#if defined(__FreeBSD__)
+#include "pidfile.h"
+#else
#include <util.h>
+#endif
+
+#if defined(__FreeBSD__)
+#define __dead __volatile
+#endif
#define DEF_SNAPLEN 116 /* default plus allow for larger header of pflog */
#define PCAP_TO_MS 500 /* pcap read timeout (ms) */
@@ -79,7 +88,11 @@ int reset_dump(void);
void sig_alrm(int);
void sig_close(int);
void sig_hup(int);
+#if defined(__FreeBSD__)
+__volatile void usage(void);
+#else
void usage(void);
+#endif
char *
OpenPOWER on IntegriCloud