svn commit: r203705 - in user/eri/pf45/head: contrib/pf/pfctl
sys/contrib/pf/net
Ermal Luçi
eri at FreeBSD.org
Tue Feb 9 15:23:16 UTC 2010
Author: eri
Date: Tue Feb 9 15:23:15 2010
New Revision: 203705
URL: http://svn.freebsd.org/changeset/base/203705
Log:
Cast some inputs to printf to avoid warnings on 64bit platforms.
Reported-by: Denny Lin
Modified:
user/eri/pf45/head/contrib/pf/pfctl/parse.y
user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c
user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.c
user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c
user/eri/pf45/head/sys/contrib/pf/net/pf.c
Modified: user/eri/pf45/head/contrib/pf/pfctl/parse.y
==============================================================================
--- user/eri/pf45/head/contrib/pf/pfctl/parse.y Tue Feb 9 14:56:10 2010 (r203704)
+++ user/eri/pf45/head/contrib/pf/pfctl/parse.y Tue Feb 9 15:23:15 2010 (r203705)
@@ -709,7 +709,7 @@ varstring : numberstring varstring {
numberstring : NUMBER {
char *s;
- if (asprintf(&s, "%lld", $1) == -1) {
+ if (asprintf(&s, "%lld", (int64_t)$1) == -1) {
yyerror("string: asprintf");
YYERROR;
}
@@ -2858,7 +2858,11 @@ host : STRING {
char *buf;
/* ie. for 10/8 parsing */
+#ifdef __FreeBSD__
+ if (asprintf(&buf, "%lld/%lld", (int64_t)$1, (int64_t)$3) == -1)
+#else
if (asprintf(&buf, "%lld/%lld", $1, $3) == -1)
+#endif
err(1, "host: asprintf");
if (($$ = host(buf)) == NULL) {
/* error. "any" is handled elsewhere */
Modified: user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c
==============================================================================
--- user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c Tue Feb 9 14:56:10 2010 (r203704)
+++ user/eri/pf45/head/contrib/pf/pfctl/pf_print_state.c Tue Feb 9 15:23:15 2010 (r203705)
@@ -322,10 +322,17 @@ print_state(struct pfsync_state *s, int
bcopy(s->bytes[0], &bytes[0], sizeof(u_int64_t));
bcopy(s->bytes[1], &bytes[1], sizeof(u_int64_t));
printf(", %llu:%llu pkts, %llu:%llu bytes",
+#ifdef __FreeBSD__
+ (unsigned long long)betoh64(packets[0]),
+ (unsigned long long)betoh64(packets[1]),
+ (unsigned long long)betoh64(bytes[0]),
+ (unsigned long long)betoh64(bytes[1]));
+#else
betoh64(packets[0]),
betoh64(packets[1]),
betoh64(bytes[0]),
betoh64(bytes[1]));
+#endif
if (ntohl(s->anchor) != -1)
printf(", anchor %u", ntohl(s->anchor));
if (ntohl(s->rule) != -1)
@@ -345,7 +352,11 @@ print_state(struct pfsync_state *s, int
bcopy(&s->id, &id, sizeof(u_int64_t));
printf(" id: %016llx creatorid: %08x",
+#ifdef __FreeBSD__
+ (unsigned long long)betoh64(id), ntohl(s->creatorid));
+#else
betoh64(id), ntohl(s->creatorid));
+#endif
printf("\n");
}
}
Modified: user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.c
==============================================================================
--- user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.c Tue Feb 9 14:56:10 2010 (r203704)
+++ user/eri/pf45/head/contrib/pf/pfctl/pfctl_parser.c Tue Feb 9 15:23:15 2010 (r203705)
@@ -575,7 +575,11 @@ print_status(struct pf_status *s, int op
s->src_nodes, "");
for (i = 0; i < SCNT_MAX; i++) {
printf(" %-25s %14lld ", pf_scounters[i],
+#ifdef __FreeBSD__
+ (int64_t)s->scounters[i]);
+#else
s->scounters[i]);
+#endif
if (runtime > 0)
printf("%14.1f/s\n",
(double)s->scounters[i] / (double)runtime);
Modified: user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c
==============================================================================
--- user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c Tue Feb 9 14:56:10 2010 (r203704)
+++ user/eri/pf45/head/sys/contrib/pf/net/if_pfsync.c Tue Feb 9 15:23:15 2010 (r203705)
@@ -2804,8 +2804,12 @@ pfsync_q_ins(struct pf_state *st, int q)
#if 1 || defined(PFSYNC_DEBUG)
if (sc->sc_len < PFSYNC_MINPKT)
+#ifdef __FreeBSD__
+ panic("pfsync pkt len is too low %ld", sc->sc_len);
+#else
panic("pfsync pkt len is too low %d", sc->sc_len);
#endif
+#endif
if (TAILQ_EMPTY(&sc->sc_qs[q]))
nlen += sizeof(struct pfsync_subheader);
Modified: user/eri/pf45/head/sys/contrib/pf/net/pf.c
==============================================================================
--- user/eri/pf45/head/sys/contrib/pf/net/pf.c Tue Feb 9 14:56:10 2010 (r203704)
+++ user/eri/pf45/head/sys/contrib/pf/net/pf.c Tue Feb 9 15:23:15 2010 (r203705)
@@ -1132,7 +1132,11 @@ pf_state_insert(struct pfi_kif *kif, str
#endif
printf("pf: state insert failed: "
"id: %016llx creatorid: %08x",
+#ifdef __FreeBSD__
+ (unsigned long long)betoh64(s->id), ntohl(s->creatorid));
+#else
betoh64(s->id), ntohl(s->creatorid));
+#endif
printf("\n");
}
pf_detach_state(s);
@@ -4396,8 +4400,13 @@ pf_tcp_track_full(struct pf_state_peer *
pf_print_flags(th->th_flags);
printf(" seq=%u (%u) ack=%u len=%u ackskew=%d "
"pkts=%llu:%llu dir=%s,%s\n", seq, orig_seq, ack,
+#ifdef __FreeBSD__
+ pd->p_len, ackskew, (unsigned long long)(*state)->packets[0],
+ (unsigned long long)(*state)->packets[1],
+#else
pd->p_len, ackskew, (*state)->packets[0],
(*state)->packets[1],
+#endif
pd->dir == PF_IN ? "in" : "out",
pd->dir == (*state)->direction ? "fwd" : "rev");
}
@@ -4460,7 +4469,12 @@ pf_tcp_track_full(struct pf_state_peer *
printf(" seq=%u (%u) ack=%u len=%u ackskew=%d "
"pkts=%llu:%llu dir=%s,%s\n",
seq, orig_seq, ack, pd->p_len, ackskew,
+#ifdef __FreeBSD__
+ (unsigned long long)(*state)->packets[0],
+ (unsigned long long)(*state)->packets[1],
+#else
(*state)->packets[0], (*state)->packets[1],
+#endif
pd->dir == PF_IN ? "in" : "out",
pd->dir == (*state)->direction ? "fwd" : "rev");
printf("pf: State failure on: %c %c %c %c | %c %c\n",
More information about the svn-src-user
mailing list