diff options
-rw-r--r-- | usr.sbin/tcpdump/pf_print_state.c | 28 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-pfsync.c | 29 |
2 files changed, 30 insertions, 27 deletions
diff --git a/usr.sbin/tcpdump/pf_print_state.c b/usr.sbin/tcpdump/pf_print_state.c index ea0a02765b7..59bab3fdb2a 100644 --- a/usr.sbin/tcpdump/pf_print_state.c +++ b/usr.sbin/tcpdump/pf_print_state.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_print_state.c,v 1.1 2004/01/28 19:44:55 canacar Exp $ */ +/* $OpenBSD: pf_print_state.c,v 1.2 2004/02/10 20:26:49 mcbride Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -51,7 +51,7 @@ void print_name(struct pf_addr *, sa_family_t); void print_addr(struct pf_addr_wrap *addr, sa_family_t af, int verbose) { - switch(addr->type) { + switch (addr->type) { case PF_ADDR_DYNIFTL: printf("(%s", addr->v.ifname); if (addr->iflags & PFI_AFLAG_NETWORK) @@ -116,7 +116,7 @@ print_name(struct pf_addr *addr, sa_family_t af) switch (af) { case AF_INET: - host = getname((char *)&addr->v4); + host = getname((char *)&addr->v4); break; case AF_INET6: host = getname6((char *)&addr->v6); @@ -201,19 +201,19 @@ print_state(struct pf_state *s, int opts) if (s->proto == IPPROTO_TCP) { if (src->state <= TCPS_TIME_WAIT && dst->state <= TCPS_TIME_WAIT) - printf(" %s:%s\n", tcpstates[src->state], + printf("\n %s:%s", tcpstates[src->state], tcpstates[dst->state]); else if (src->state == PF_TCPS_PROXY_SRC || dst->state == PF_TCPS_PROXY_SRC) - printf(" PROXY:SRC\n"); + printf("\n PROXY:SRC"); else if (src->state == PF_TCPS_PROXY_DST || dst->state == PF_TCPS_PROXY_DST) - printf(" PROXY:DST\n"); + printf("\n PROXY:DST"); else - printf(" <BAD STATE LEVELS %u:%u>\n", + printf("\n <BAD STATE LEVELS %u:%u>", src->state, dst->state); if (opts & PF_OPT_VERBOSE) { - printf(" "); + printf("\n "); print_seq(src); if (src->wscale && dst->wscale) printf(" wscale %u", @@ -223,21 +223,20 @@ print_state(struct pf_state *s, int opts) if (src->wscale && dst->wscale) printf(" wscale %u", dst->wscale & PF_WSCALE_MASK); - printf("\n"); } } else if (s->proto == IPPROTO_UDP && src->state < PFUDPS_NSTATES && dst->state < PFUDPS_NSTATES) { const char *states[] = PFUDPS_NAMES; - printf(" %s:%s\n", states[src->state], states[dst->state]); + printf(" %s:%s", states[src->state], states[dst->state]); } else if (s->proto != IPPROTO_ICMP && src->state < PFOTHERS_NSTATES && dst->state < PFOTHERS_NSTATES) { /* XXX ICMP doesn't really have state levels */ const char *states[] = PFOTHERS_NAMES; - printf(" %s:%s\n", states[src->state], states[dst->state]); + printf(" %s:%s", states[src->state], states[dst->state]); } else { - printf(" %u:%u\n", src->state, dst->state); + printf(" %u:%u", src->state, dst->state); } if (opts & PF_OPT_VERBOSE) { @@ -245,7 +244,7 @@ print_state(struct pf_state *s, int opts) s->creation /= 60; min = s->creation % 60; s->creation /= 60; - printf(" age %.2u:%.2u:%.2u", s->creation, min, sec); + printf("\n age %.2u:%.2u:%.2u", s->creation, min, sec); sec = s->expire % 60; s->expire /= 60; min = s->expire % 60; @@ -261,10 +260,9 @@ print_state(struct pf_state *s, int opts) printf(", source-track"); if (s->nat_src_node != NULL) printf(", sticky-address"); - printf("\n"); } if (opts & PF_OPT_VERBOSE2) { - printf(" id: %016llx creatorid: %08x\n", + printf("\n id: %016llx creatorid: %08x", betoh64(s->id), ntohl(s->creatorid)); } } diff --git a/usr.sbin/tcpdump/print-pfsync.c b/usr.sbin/tcpdump/print-pfsync.c index 61b198fc7a0..0c9a12a4ef0 100644 --- a/usr.sbin/tcpdump/print-pfsync.c +++ b/usr.sbin/tcpdump/print-pfsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-pfsync.c,v 1.23 2004/02/10 09:21:55 mcbride Exp $ */ +/* $OpenBSD: print-pfsync.c,v 1.24 2004/02/10 20:26:50 mcbride Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff @@ -28,7 +28,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-pfsync.c,v 1.23 2004/02/10 09:21:55 mcbride Exp $"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-pfsync.c,v 1.24 2004/02/10 20:26:50 mcbride Exp $"; #endif #include <sys/param.h> @@ -84,8 +84,8 @@ pfsync_if_print(u_char *user, const struct pcap_pkthdr *h, out: if (xflag) { default_print((const u_char *)h, caplen); - putchar('\n'); } + putchar('\n'); } void @@ -96,7 +96,7 @@ pfsync_ip_print(const u_char *bp, u_int len, const u_char *bp2) if (vflag) printf("%s > %s: ", ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); + ipaddr_string(&ip->ip_dst)); else printf("%s: ", ipaddr_string(&ip->ip_src)); @@ -104,6 +104,7 @@ pfsync_ip_print(const u_char *bp, u_int len, const u_char *bp2) printf("[|pfsync]"); else pfsync_print(hdr, (len - sizeof(struct pfsync_header))); + putchar('\n'); } void @@ -114,7 +115,7 @@ pfsync_print(struct pfsync_header *hdr, int len) struct pfsync_state_del *d; struct pfsync_state_clr *c; struct pfsync_state_upd_req *r; - int i, flags; + int i, flags = 0; u_int64_t id; if (eflag) @@ -122,11 +123,10 @@ pfsync_print(struct pfsync_header *hdr, int len) hdr->version, hdr->count); if (hdr->action < PFSYNC_ACT_MAX) - printf("%s:\n", pfsync_acts[hdr->action]); + printf("%s:", pfsync_acts[hdr->action]); else - printf("%d?:\n", hdr->action); + printf("%d?:", hdr->action); - flags = 0; if (vflag) flags |= PF_OPT_VERBOSE; if (vflag > 1) @@ -138,7 +138,7 @@ pfsync_print(struct pfsync_header *hdr, int len) case PFSYNC_ACT_CLR: if (sizeof(*c) <= len) { c = (void *)((char *)hdr + PFSYNC_HDRLEN); - printf("\tcreatorid: %08x\n", htonl(c->creatorid)); + printf("\n\tcreatorid: %08x", htonl(c->creatorid)); } case PFSYNC_ACT_INS: case PFSYNC_ACT_UPD: @@ -174,22 +174,27 @@ pfsync_print(struct pfsync_header *hdr, int len) st.allow_opts = s->allow_opts; st.sync_flags = s->sync_flags; + putchar('\n'); print_state(&st, flags); + if (vflag > 1 && hdr->action == PFSYNC_ACT_UPD) + printf(" updates: %d", s->updates); } break; case PFSYNC_ACT_UPD_C: for (i = 1, u = (void *)((char *)hdr + PFSYNC_HDRLEN); i <= hdr->count && i * sizeof(*u) <= len; i++, u++) { bcopy(&u->id, &id, sizeof(id)); - printf("\tid: %016llx creatorid: %08x\n", + printf("\n\tid: %016llx creatorid: %08x", betoh64(id), ntohl(u->creatorid)); + if (vflag > 1) + printf(" updates: %d", u->updates); } break; case PFSYNC_ACT_DEL_C: for (i = 1, d = (void *)((char *)hdr + PFSYNC_HDRLEN); i <= hdr->count && i * sizeof(*d) <= len; i++, d++) { bcopy(&d->id, &id, sizeof(id)); - printf("\tid: %016llx creatorid: %08x\n", + printf("\n\tid: %016llx creatorid: %08x", betoh64(id), ntohl(d->creatorid)); } break; @@ -197,7 +202,7 @@ pfsync_print(struct pfsync_header *hdr, int len) for (i = 1, r = (void *)((char *)hdr + PFSYNC_HDRLEN); i <= hdr->count && i * sizeof(*r) <= len; i++, r++) { bcopy(&r->id, &id, sizeof(id)); - printf("\tid: %016llx creatorid: %08x\n", + printf("\n\tid: %016llx creatorid: %08x", betoh64(id), ntohl(r->creatorid)); } break; |