use limits.h and explicitly include sys/param.h where necessary

This commit is contained in:
naddy 2015-01-18 15:59:46 +00:00
parent 8fb83c298b
commit faf8fc4b2c
2 changed files with 60 additions and 35 deletions

View File

@ -1,7 +1,15 @@
$OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
--- pftop.c.orig Wed Nov 7 06:36:46 2007
+++ pftop.c Sat Oct 12 14:12:12 2013
@@ -127,6 +127,13 @@
$OpenBSD: patch-pftop_c,v 1.17 2015/01/18 15:59:46 naddy Exp $
--- pftop.c.orig Wed Nov 7 07:36:46 2007
+++ pftop.c Sun Jan 18 16:55:30 2015
@@ -55,6 +55,7 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
#include <netdb.h>
#include <signal.h>
#include <stdio.h>
@@ -127,6 +128,13 @@
#define PT_NOROUTE(x) (0)
#endif
@ -15,7 +23,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
/* view management */
int select_states(void);
int read_states(void);
@@ -445,11 +452,11 @@ sort_pkt_callback(const void *s1, const void *s2)
@@ -445,11 +453,11 @@ sort_pkt_callback(const void *s1, const void *s2)
int
sort_age_callback(const void *s1, const void *s2)
{
@ -31,7 +39,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
return -sortdir;
return 0;
}
@@ -457,11 +464,11 @@ sort_age_callback(const void *s1, const void *s2)
@@ -457,11 +465,11 @@ sort_age_callback(const void *s1, const void *s2)
int
sort_exp_callback(const void *s1, const void *s2)
{
@ -47,7 +55,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
return -sortdir;
return 0;
}
@@ -535,6 +542,8 @@ compare_addr(int af, const struct pf_addr *a, const st
@@ -535,6 +543,8 @@ compare_addr(int af, const struct pf_addr *a, const st
return 0;
}
@ -56,7 +64,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
#ifdef __GNUC__
__inline__
#endif
@@ -542,6 +551,113 @@ int
@@ -542,6 +552,113 @@ int
sort_addr_callback(const pf_state_t *s1,
const pf_state_t *s2, int dir)
{
@ -170,7 +178,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
const pf_state_host_t *a, *b;
int af, ret;
@@ -573,20 +689,6 @@ sort_addr_callback(const pf_state_t *s1,
@@ -573,20 +690,6 @@ sort_addr_callback(const pf_state_t *s1,
return -sortdir;
}
@ -191,7 +199,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
#ifdef __GNUC__
__inline__
#endif
@@ -625,7 +727,22 @@ sort_port_callback(const pf_state_t *s1,
@@ -625,7 +728,22 @@ sort_port_callback(const pf_state_t *s1,
return sortdir;
return -sortdir;
}
@ -214,7 +222,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
int
sort_sp_callback(const void *p1, const void *p2)
{
@@ -865,7 +982,48 @@ tb_print_addr(struct pf_addr * addr, struct pf_addr *
@@ -865,7 +983,48 @@ tb_print_addr(struct pf_addr * addr, struct pf_addr *
tbprintf("/%u", unmask(mask, af));
}
}
@ -263,7 +271,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
void
print_fld_host(field_def *fld, pf_state_host_t * h, int af)
{
@@ -889,6 +1047,7 @@ print_fld_host(field_def *fld, pf_state_host_t * h, in
@@ -889,6 +1048,7 @@ print_fld_host(field_def *fld, pf_state_host_t * h, in
print_fld_tb(fld);
}
@ -271,7 +279,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
void
print_fld_state(field_def *fld, unsigned int proto,
@@ -960,7 +1119,20 @@ print_state(pf_state_t * s, struct sc_ent * ent)
@@ -960,7 +1120,20 @@ print_state(pf_state_t * s, struct sc_ent * ent)
else
print_fld_uint(FLD_PROTO, s->proto);
@ -292,7 +300,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
print_fld_host(FLD_SRC, &s->lan, s->af);
print_fld_host(FLD_DEST, &s->ext, s->af);
} else {
@@ -972,6 +1144,7 @@ print_state(pf_state_t * s, struct sc_ent * ent)
@@ -972,6 +1145,7 @@ print_state(pf_state_t * s, struct sc_ent * ent)
(s->lan.port != s->gwy.port)) {
print_fld_host(FLD_GW, &s->gwy, s->af);
}
@ -300,7 +308,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
if (s->direction == PF_OUT)
print_fld_str(FLD_DIR, "Out");
@@ -979,8 +1152,8 @@ print_state(pf_state_t * s, struct sc_ent * ent)
@@ -979,8 +1153,8 @@ print_state(pf_state_t * s, struct sc_ent * ent)
print_fld_str(FLD_DIR, "In");
print_fld_state(FLD_STATE, s->proto, src->state, dst->state);
@ -311,7 +319,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
#ifdef HAVE_INOUT_COUNT
{
u_int64_t sz = COUNTER(s->bytes[0]) + COUNTER(s->bytes[1]);
@@ -988,18 +1161,18 @@ print_state(pf_state_t * s, struct sc_ent * ent)
@@ -988,18 +1162,18 @@ print_state(pf_state_t * s, struct sc_ent * ent)
print_fld_size(FLD_PKTS, COUNTER(s->packets[0]) +
COUNTER(s->packets[1]));
print_fld_size(FLD_BYTES, sz);
@ -335,7 +343,16 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
#else
#ifdef HAVE_RULE_NUMBER
print_fld_uint(FLD_RULE, s->rule.nr);
@@ -1458,8 +1631,9 @@ tb_print_flags(u_int8_t f)
@@ -1112,7 +1286,7 @@ read_anchor_rules(char *anchor)
#ifdef HAVE_RULESETS
struct anchor_name {
- char name[MAXPATHLEN];
+ char name[PATH_MAX];
struct anchor_name *next;
u_int32_t ref;
};
@@ -1458,8 +1632,9 @@ tb_print_flags(u_int8_t f)
void
print_rule(struct pf_rule *pr)
{
@ -347,7 +364,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
int numact = sizeof(actiontypes) / sizeof(char *);
#ifdef HAVE_PF_ROUTE
@@ -1475,8 +1649,12 @@ print_rule(struct pf_rule *pr)
@@ -1475,8 +1650,12 @@ print_rule(struct pf_rule *pr)
print_fld_str(FLD_LABEL, pr->label);
#endif
#ifdef HAVE_RULE_STATES
@ -360,7 +377,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
#ifdef HAVE_INOUT_COUNT_RULES
print_fld_size(FLD_PKTS, pr->packets[0] + pr->packets[1]);
@@ -1486,7 +1664,13 @@ print_rule(struct pf_rule *pr)
@@ -1486,7 +1665,13 @@ print_rule(struct pf_rule *pr)
print_fld_size(FLD_BYTES, pr->bytes);
#endif
print_fld_uint(FLD_RULE, pr->nr);
@ -375,7 +392,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
if (pr->quick)
print_fld_str(FLD_QUICK, "Quick");
@@ -1555,7 +1739,9 @@ print_rule(struct pf_rule *pr)
@@ -1555,7 +1740,9 @@ print_rule(struct pf_rule *pr)
#ifdef HAVE_PF_ROUTE
if (pr->rt > 0 && pr->rt < numroute) {
tbprintf("%s ", routetypes[pr->rt]);
@ -385,7 +402,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
tbprintf("... ");
}
#endif
@@ -1729,12 +1915,19 @@ pfctl_insert_altq_node(struct pf_altq_node **root,
@@ -1729,12 +1916,19 @@ pfctl_insert_altq_node(struct pf_altq_node **root,
prev->next = node;
}
}
@ -411,7 +428,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
}
}
@@ -1743,10 +1936,11 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
@@ -1743,10 +1937,11 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
{
struct pf_altq_node *node;
struct pfioc_altq pa;
@ -424,7 +441,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
*inserts = 0;
memset(&pa, 0, sizeof(pa));
@@ -1757,13 +1951,15 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
@@ -1757,13 +1952,15 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
strerror(errno));
return (-1);
}
@ -441,7 +458,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
}
if (pa.altq.qid > 0) {
pq.nr = nr;
@@ -1773,7 +1969,8 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
@@ -1773,7 +1970,8 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
if (ioctl(pf_dev, DIOCGETQSTATS, &pq)) {
msgprintf("Error Reading Queue (DIOCGETQSTATS): %s",
strerror(errno));
@ -451,7 +468,7 @@ $OpenBSD: patch-pftop_c,v 1.16 2013/10/12 13:12:43 sthen Exp $
}
qstats.valid = 1;
gettimeofday(&qstats.timestamp, NULL);
@@ -1794,7 +1991,10 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
@@ -1794,7 +1992,10 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
else
--num_queues;
}

View File

@ -1,7 +1,15 @@
$OpenBSD: patch-sf-gencode_c,v 1.2 2013/06/19 03:46:55 lteo Exp $
--- sf-gencode.c.orig Wed Nov 7 01:34:18 2007
+++ sf-gencode.c Thu Jun 13 14:28:14 2013
@@ -44,7 +44,7 @@
$OpenBSD: patch-sf-gencode_c,v 1.3 2015/01/18 15:59:46 naddy Exp $
--- sf-gencode.c.orig Wed Nov 7 07:34:18 2007
+++ sf-gencode.c Sun Jan 18 16:57:57 2015
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
+#include <sys/param.h> /* ALIGN */
#include <net/if.h>
@@ -44,7 +45,7 @@
#define INET6
@ -10,7 +18,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.2 2013/06/19 03:46:55 lteo Exp $
#include <pcap-namedb.h>
#include "sf-gencode.h"
@@ -474,9 +474,107 @@ gen_proto(int proto)
@@ -474,9 +475,107 @@ gen_proto(int proto)
(bpf_int32)proto));
}
@ -118,7 +126,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.2 2013/06/19 03:46:55 lteo Exp $
struct block *b0, *b1, *b2;
const static int lan_off = offsetof(pf_state_t, lan.addr.v4);
const static int gwy_off = offsetof(pf_state_t, gwy.addr.v4);
@@ -542,6 +640,7 @@ gen_hostop(bpf_u_int32 addr, bpf_u_int32 mask, int dir
@@ -542,6 +641,7 @@ gen_hostop(bpf_u_int32 addr, bpf_u_int32 mask, int dir
return b1;
}
@ -126,7 +134,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.2 2013/06/19 03:46:55 lteo Exp $
static struct block *
gen_hostcmp6(u_int off, u_int32_t *a, u_int32_t *m)
@@ -560,9 +659,108 @@ gen_hostcmp6(u_int off, u_int32_t *a, u_int32_t *m)
@@ -560,9 +660,108 @@ gen_hostcmp6(u_int off, u_int32_t *a, u_int32_t *m)
return b1;
}
@ -235,7 +243,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.2 2013/06/19 03:46:55 lteo Exp $
struct block *b0, *b1, *b2;
u_int32_t *a, *m;
@@ -630,6 +828,7 @@ gen_hostop6(struct in6_addr *addr, struct in6_addr *ma
@@ -630,6 +829,7 @@ gen_hostop6(struct in6_addr *addr, struct in6_addr *ma
gen_and(b0, b1);
return b1;
}
@ -243,7 +251,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.2 2013/06/19 03:46:55 lteo Exp $
static const char *
get_modifier_by_id(int id)
@@ -748,9 +947,107 @@ gen_proto_abbrev(proto)
@@ -748,9 +948,107 @@ gen_proto_abbrev(proto)
return b1;
}
@ -351,7 +359,7 @@ $OpenBSD: patch-sf-gencode_c,v 1.2 2013/06/19 03:46:55 lteo Exp $
struct block *b0, *b1, *b2;
const static int lan_off = offsetof(pf_state_t, lan.port);
const static int gwy_off = offsetof(pf_state_t, gwy.port);
@@ -815,6 +1112,7 @@ gen_portop(int port, int proto, int dir)
@@ -815,6 +1113,7 @@ gen_portop(int port, int proto, int dir)
return b1;
}