diff options
-rw-r--r-- | sbin/pfctl/pf_print_state.c | 15 | ||||
-rw-r--r-- | sbin/pfctl/pfctl.h | 4 | ||||
-rw-r--r-- | sbin/pfctl/pfctl_parser.c | 26 |
3 files changed, 26 insertions, 19 deletions
diff --git a/sbin/pfctl/pf_print_state.c b/sbin/pfctl/pf_print_state.c index 27fb9b19cb2..d8da757b586 100644 --- a/sbin/pfctl/pf_print_state.c +++ b/sbin/pfctl/pf_print_state.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_print_state.c,v 1.18 2003/01/07 00:21:08 dhartmei Exp $ */ +/* $OpenBSD: pf_print_state.c,v 1.19 2003/01/20 17:16:56 cedric Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -58,14 +58,21 @@ void print_name(struct pf_addr *, struct pf_addr *, sa_family_t); void -print_addr(struct pf_addr_wrap *addr, sa_family_t af) +print_addr(struct pf_addr_wrap *addr, sa_family_t af, int verbose) { char buf[48]; if (addr->type == PF_ADDR_DYNIFTL) printf("(%s)", addr->v.ifname); else if (addr->type == PF_ADDR_TABLE) - printf("<%s>", addr->v.tblname); + if (verbose) + if (addr->p.tblcnt == -1) + printf("<%s:*>", addr->v.tblname); + else + printf("<%s:%d>", addr->v.tblname, + addr->p.tblcnt); + else + printf("<%s>", addr->v.tblname); else { if (inet_ntop(af, &addr->v.a.addr, buf, sizeof(buf)) == NULL) printf("?"); @@ -126,7 +133,7 @@ print_host(struct pf_state_host *h, sa_family_t af, int opts) memset(&aw, 0, sizeof(aw)); aw.v.a.addr = h->addr; memset(&aw.v.a.mask, 0xff, sizeof(aw.v.a.mask)); - print_addr(&aw, af); + print_addr(&aw, af, opts & PF_OPT_VERBOSE2); } if (p) { diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h index dd37cffb94b..86a1e5ff855 100644 --- a/sbin/pfctl/pfctl.h +++ b/sbin/pfctl/pfctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl.h,v 1.5 2003/01/09 17:33:19 henning Exp $ */ +/* $OpenBSD: pfctl.h,v 1.6 2003/01/20 17:16:56 cedric Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -87,7 +87,7 @@ char *qid_to_qname(u_int32_t, const char *); void print_altq(const struct pf_altq *, unsigned); void print_queue(const struct pf_altq *, unsigned); -void print_addr(struct pf_addr_wrap *, sa_family_t); +void print_addr(struct pf_addr_wrap *, sa_family_t, int); void print_host(struct pf_state_host *, sa_family_t, int); void print_seq(struct pf_state_peer *); void print_state(struct pf_state *s, int); diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index fee7cce076f..50c407d2f89 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_parser.c,v 1.132 2003/01/19 09:31:34 camield Exp $ */ +/* $OpenBSD: pfctl_parser.c,v 1.133 2003/01/20 17:16:56 cedric Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -60,7 +60,7 @@ void print_uid (u_int8_t, uid_t, uid_t, const char *); void print_gid (u_int8_t, gid_t, gid_t, const char *); void print_flags (u_int8_t); void print_fromto(struct pf_rule_addr *, struct pf_rule_addr *, - u_int8_t, u_int8_t); + u_int8_t, u_int8_t, int); struct node_host *host_if(char *, int); struct node_host *host_v4(char *); @@ -361,7 +361,7 @@ print_flags(u_int8_t f) void print_fromto(struct pf_rule_addr *src, struct pf_rule_addr *dst, - sa_family_t af, u_int8_t proto) + sa_family_t af, u_int8_t proto, int verbose) { if (src->addr.type != PF_ADDR_NOROUTE && dst->addr.type != PF_ADDR_NOROUTE && @@ -380,7 +380,7 @@ print_fromto(struct pf_rule_addr *src, struct pf_rule_addr *dst, else { if (src->not) printf("! "); - print_addr(&src->addr, af); + print_addr(&src->addr, af, verbose); printf(" "); } if (src->port_op) @@ -397,7 +397,7 @@ print_fromto(struct pf_rule_addr *src, struct pf_rule_addr *dst, else { if (dst->not) printf("! "); - print_addr(&dst->addr, af); + print_addr(&dst->addr, af, verbose); printf(" "); } if (dst->port_op) @@ -446,14 +446,14 @@ print_pool(struct pf_pool *pool, u_int16_t p1, u_int16_t p2, case PF_NAT: case PF_RDR: case PF_BINAT: - print_addr(&pooladdr->addr.addr, af); + print_addr(&pooladdr->addr.addr, af, 0); break; case PF_PASS: if (PF_AZERO(&pooladdr->addr.addr.v.a.addr, af)) printf("%s", pooladdr->ifname); else { printf("(%s ", pooladdr->ifname); - print_addr(&pooladdr->addr.addr, af); + print_addr(&pooladdr->addr.addr, af, 0); printf(")"); } break; @@ -539,7 +539,7 @@ print_nat(struct pf_rule *n, int verbose) else printf("proto %u ", n->proto); } - print_fromto(&n->src, &n->dst, n->af, n->proto); + print_fromto(&n->src, &n->dst, n->af, n->proto, verbose); if (!n->anchorname[0] && (n->action == PF_NAT)) { printf("-> "); print_pool(&n->rpool, n->rpool.proxy_port[0], @@ -581,7 +581,7 @@ print_binat(struct pf_rule *b, int verbose) printf("from "); if (!PF_AZERO(&b->src.addr.v.a.addr, b->af) || !PF_AZERO(&b->src.addr.v.a.mask, b->af)) { - print_addr(&b->src.addr, b->af); + print_addr(&b->src.addr, b->af, verbose); printf(" "); } else printf("any "); @@ -590,7 +590,7 @@ print_binat(struct pf_rule *b, int verbose) !PF_AZERO(&b->dst.addr.v.a.mask, b->af)) { if (b->dst.not) printf("! "); - print_addr(&b->dst.addr, b->af); + print_addr(&b->dst.addr, b->af, verbose); printf(" "); } else printf("any "); @@ -638,7 +638,7 @@ print_rdr(struct pf_rule *r, int verbose) !PF_AZERO(&r->src.addr.v.a.mask, r->af)) { if (r->src.not) printf("! "); - print_addr(&r->src.addr, r->af); + print_addr(&r->src.addr, r->af, verbose); printf(" "); } else printf("any "); @@ -647,7 +647,7 @@ print_rdr(struct pf_rule *r, int verbose) !PF_AZERO(&r->dst.addr.v.a.mask, r->af)) { if (r->dst.not) printf("! "); - print_addr(&r->dst.addr, r->af); + print_addr(&r->dst.addr, r->af, verbose); printf(" "); } else printf("any "); @@ -851,7 +851,7 @@ print_filter(struct pf_rule *r, int verbose) else printf("proto %u ", r->proto); } - print_fromto(&r->src, &r->dst, r->af, r->proto); + print_fromto(&r->src, &r->dst, r->af, r->proto, verbose); if (r->uid.op) print_uid(r->uid.op, r->uid.uid[0], r->uid.uid[1], "user"); if (r->gid.op) |