=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/systat/pftop.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/systat/pftop.c 2008/06/29 08:42:15 1.3 --- src/usr.bin/systat/pftop.c 2008/07/16 10:23:39 1.4 *************** *** 1,4 **** ! /* $Id: pftop.c,v 1.3 2008/06/29 08:42:15 mcbride Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar * Copyright (c) 2001 Daniel Hartmeier --- 1,4 ---- ! /* $Id: pftop.c,v 1.4 2008/07/16 10:23:39 canacar Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar * Copyright (c) 2001 Daniel Hartmeier *************** *** 30,37 **** * */ - #include "config.h" - #include #include #include --- 30,35 ---- *************** *** 42,53 **** #include #include - #ifdef HAVE_ALTQ #include #include #include #include - #endif #include #include --- 40,49 ---- *************** *** 72,130 **** #define DEFAULT_CACHE_SIZE 10000 - #ifndef HAVE_PROTO_NAMES - /* UDP state enumeration */ - #define PFUDPS_NSTATES 3 /* number of state levels */ - - #define PFUDPS_NAMES { \ - "NO TRAFFIC", \ - "SINGLE", \ - "MULTIPLE", \ - NULL \ - } - - /* Other protocol state enumeration */ - #define PFOTHERS_NSTATES 3 /* number of state levels */ - - #define PFOTHERS_NAMES { \ - "NO TRAFFIC", \ - "SINGLE", \ - "MULTIPLE", \ - NULL \ - } - #endif - - #ifdef HAVE_ADDR_WRAP - #ifdef HAVE_ADDR_TYPE /* XXX must also check type before use */ #define PT_ADDR(x) (&(x)->addr.v.a.addr) - #else - #define PT_ADDR(x) (&(x)->addr.addr) - #endif - #else - #define PT_ADDR(x) (&(x)->addr) - #endif - #ifdef HAVE_ADDR_MASK - #ifdef HAVE_ADDR_TYPE /* XXX must also check type before use */ #define PT_MASK(x) (&(x)->addr.v.a.mask) - #else - #define PT_MASK(x) (&(x)->addr.mask) - #endif - #else - #define PT_MASK(x) (&(x)->mask) - #endif - #ifdef HAVE_STATE_NOROUTE - #ifdef HAVE_ADDR_TYPE #define PT_NOROUTE(x) ((x)->addr.type == PF_ADDR_NOROUTE) - #else - #define PT_NOROUTE(x) ((x)->noroute) - #endif - #else - #define PT_NOROUTE(x) (0) - #endif /* view management */ int select_states(void); --- 68,80 ---- *************** *** 139,149 **** int print_header(void); int keyboard_callback(int ch); - #ifdef HAVE_ALTQ int select_queues(void); int read_queues(void); void print_queues(void); - #endif /* qsort callbacks */ int sort_size_callback(const void *s1, const void *s2); --- 89,97 ---- *************** *** 159,165 **** int pf_dev = -1; struct sc_ent **state_cache = NULL; ! pf_state_t *state_buf = NULL; int state_buf_len = 0; u_int32_t *state_ord = NULL; u_int32_t num_states = 0; --- 107,113 ---- int pf_dev = -1; struct sc_ent **state_cache = NULL; ! struct pfsync_state *state_buf = NULL; int state_buf_len = 0; u_int32_t *state_ord = NULL; u_int32_t num_states = 0; *************** *** 171,180 **** char *filter_string = NULL; int dumpfilter = 0; - #ifndef HAVE_RULE_LABELS - #define PF_RULE_LABEL_SIZE 20 - #endif - #define MIN_LABEL_SIZE 5 #define ANCHOR_FLD_SIZE 12 --- 119,124 ---- *************** *** 200,210 **** {"KS", 1, 1, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, {"IF", 4, 6, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, {"INFO", 40, 80, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, ! {"MAX", 3, 5, 2, FLD_ALIGN_RIGHT, -1, 0, FLD_FLAG_HIDDEN, 0}, {"RATE", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"AVG", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"PEAK", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, ! {"ANCHOR", 6, 16, 1, FLD_ALIGN_LEFT, -1, 0, FLD_FLAG_HIDDEN, 0}, {"QUEUE", 15, 30, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, {"BW", 4, 5, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"SCH", 3, 4, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, --- 144,154 ---- {"KS", 1, 1, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, {"IF", 4, 6, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, {"INFO", 40, 80, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, ! {"MAX", 3, 5, 2, FLD_ALIGN_RIGHT, -1, 0, 0}, {"RATE", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"AVG", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"PEAK", 5, 8, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, ! {"ANCHOR", 6, 16, 1, FLD_ALIGN_LEFT, -1, 0, 0}, {"QUEUE", 15, 30, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, {"BW", 4, 5, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0}, {"SCH", 3, 4, 1, FLD_ALIGN_LEFT, -1, 0, 0, 0}, *************** *** 339,350 **** print_rules, keyboard_callback, NULL, NULL }; - #ifdef HAVE_ALTQ struct view_manager queue_mgr = { "Queues", select_queues, read_queues, NULL, print_header, print_queues, keyboard_callback, NULL, NULL }; - #endif field_view views[] = { {view2, "states", '8', &state_mgr}, --- 283,292 ---- *************** *** 356,362 **** /* altq structures from pfctl */ - #ifdef HAVE_ALTQ union class_stats { class_stats_t cbq_stats; struct priq_classstats priq_stats; --- 298,303 ---- *************** *** 379,385 **** u_int8_t depth; u_int8_t visited; }; - #endif /* HAVE_ALTQ */ /* ordering functions */ --- 320,325 ---- *************** *** 387,401 **** int sort_size_callback(const void *s1, const void *s2) { - #ifdef HAVE_INOUT_COUNT u_int64_t b1 = COUNTER(state_buf[* (u_int32_t *) s1].bytes[0]) + COUNTER(state_buf[* (u_int32_t *) s1].bytes[1]); u_int64_t b2 = COUNTER(state_buf[* (u_int32_t *) s2].bytes[0]) + COUNTER(state_buf[* (u_int32_t *) s2].bytes[1]); - #else - u_int64_t b1 = COUNTER(state_buf[* (u_int32_t *) s1].bytes); - u_int64_t b2 = COUNTER(state_buf[* (u_int32_t *) s2].bytes); - #endif if (b2 > b1) return sortdir; if (b2 < b1) --- 327,336 ---- *************** *** 406,420 **** int sort_pkt_callback(const void *s1, const void *s2) { - #ifdef HAVE_INOUT_COUNT u_int64_t p1 = COUNTER(state_buf[* (u_int32_t *) s1].packets[0]) + COUNTER(state_buf[* (u_int32_t *) s1].packets[1]); u_int64_t p2 = COUNTER(state_buf[* (u_int32_t *) s2].packets[0]) + COUNTER(state_buf[* (u_int32_t *) s2].packets[1]); - #else - u_int64_t p1 = COUNTER(state_buf[* (u_int32_t *) s1].packets); - u_int64_t p2 = COUNTER(state_buf[* (u_int32_t *) s2].packets); - #endif if (p2 > p1) return sortdir; if (p2 < p1) --- 341,350 ---- *************** *** 515,528 **** return 0; } ! #ifdef HAVE_PFSYNC_KEY ! ! #ifdef __GNUC__ ! __inline__ ! #endif ! int ! sort_addr_callback(const pf_state_t *s1, ! const pf_state_t *s2, int dir) { const struct pf_addr *aa, *ab; u_int16_t pa, pb; --- 445,453 ---- return 0; } ! __inline int ! sort_addr_callback(const struct pfsync_state *s1, ! const struct pfsync_state *s2, int dir) { const struct pf_addr *aa, *ab; u_int16_t pa, pb; *************** *** 567,578 **** return -sortdir; } ! #ifdef __GNUC__ ! __inline__ ! #endif ! int ! sort_port_callback(const pf_state_t *s1, ! const pf_state_t *s2, int dir) { const struct pf_addr *aa, *ab; u_int16_t pa, pb; --- 492,500 ---- return -sortdir; } ! __inline int ! sort_port_callback(const struct pfsync_state *s1, ! const struct pfsync_state *s2, int dir) { const struct pf_addr *aa, *ab; u_int16_t pa, pb; *************** *** 621,733 **** return -sortdir; } - #else /* HAVE_PFSYNC_KEY */ - - #ifdef __GNUC__ - __inline__ - #endif int ! sort_addr_callback(const pf_state_t *s1, ! const pf_state_t *s2, int dir) { ! const pf_state_host_t *a, *b; ! int af, ret; ! ! af = s1->af; ! ! if (af > s2->af) ! return sortdir; ! if (af < s2->af) ! return -sortdir; ! ! if (s1->direction == dir) { ! a = &s1->lan; ! } else { ! a = &s1->ext; ! } ! ! if (s2->direction == dir) { ! b = &s2->lan; ! } else { ! b = &s2->ext; ! } ! ! ret = compare_addr(af, &a->addr, &b->addr); ! if (ret) ! return ret * sortdir; ! ! if (ntohs(a->port) > ntohs(b->port)) ! return sortdir; ! return -sortdir; } - #ifdef __GNUC__ - __inline__ - #endif int ! sort_port_callback(const pf_state_t *s1, ! const pf_state_t *s2, int dir) { ! const pf_state_host_t *a, *b; ! int af; ! ! af = s1->af; ! ! if (af > s2->af) ! return sortdir; ! if (af < s2->af) ! return -sortdir; ! ! if (s1->direction == dir) { ! a = &s1->lan; ! } else { ! a = &s1->ext; ! } ! ! if (s2->direction == dir) { ! b = &s2->lan; ! } else { ! b = &s2->ext; ! } ! ! if (ntohs(a->port) > ntohs(b->port)) ! return sortdir; ! if (ntohs(a->port) < ntohs(b->port)) ! return -sortdir; ! ! if (compare_addr(af, &a->addr, &b->addr) > 0) ! return sortdir; ! return -sortdir; ! } ! #endif /* HAVE_PFSYNC_KEY */ ! ! int sort_sa_callback(const void *p1, const void *p2) ! { ! pf_state_t *s1 = state_buf + (* (u_int32_t *) p1); ! pf_state_t *s2 = state_buf + (* (u_int32_t *) p2); ! return sort_addr_callback(s1, s2, PF_OUT); ! } ! ! int sort_da_callback(const void *p1, const void *p2) ! { ! pf_state_t *s1 = state_buf + (* (u_int32_t *) p1); ! pf_state_t *s2 = state_buf + (* (u_int32_t *) p2); return sort_addr_callback(s1, s2, PF_IN); } int sort_sp_callback(const void *p1, const void *p2) { ! pf_state_t *s1 = state_buf + (* (u_int32_t *) p1); ! pf_state_t *s2 = state_buf + (* (u_int32_t *) p2); return sort_port_callback(s1, s2, PF_OUT); } int sort_dp_callback(const void *p1, const void *p2) { ! pf_state_t *s1 = state_buf + (* (u_int32_t *) p1); ! pf_state_t *s2 = state_buf + (* (u_int32_t *) p2); return sort_port_callback(s1, s2, PF_IN); } --- 543,577 ---- return -sortdir; } int ! sort_sa_callback(const void *p1, const void *p2) { ! struct pfsync_state *s1 = state_buf + (* (u_int32_t *) p1); ! struct pfsync_state *s2 = state_buf + (* (u_int32_t *) p2); ! return sort_addr_callback(s1, s2, PF_OUT); } int ! sort_da_callback(const void *p1, const void *p2) { ! struct pfsync_state *s1 = state_buf + (* (u_int32_t *) p1); ! struct pfsync_state *s2 = state_buf + (* (u_int32_t *) p2); return sort_addr_callback(s1, s2, PF_IN); } int sort_sp_callback(const void *p1, const void *p2) { ! struct pfsync_state *s1 = state_buf + (* (u_int32_t *) p1); ! struct pfsync_state *s2 = state_buf + (* (u_int32_t *) p2); return sort_port_callback(s1, s2, PF_OUT); } int sort_dp_callback(const void *p1, const void *p2) { ! struct pfsync_state *s1 = state_buf + (* (u_int32_t *) p1); ! struct pfsync_state *s2 = state_buf + (* (u_int32_t *) p2); return sort_port_callback(s1, s2, PF_IN); } *************** *** 767,773 **** if (len >= state_buf_len) { len += NUM_STATE_INC; ! state_buf = realloc(state_buf, len * sizeof(pf_state_t)); state_ord = realloc(state_ord, len * sizeof(u_int32_t)); state_cache = realloc(state_cache, len * sizeof(struct sc_ent *)); --- 611,617 ---- if (len >= state_buf_len) { len += NUM_STATE_INC; ! state_buf = realloc(state_buf, len * sizeof(struct pfsync_state)); state_ord = realloc(state_ord, len * sizeof(u_int32_t)); state_cache = realloc(state_cache, len * sizeof(struct sc_ent *)); *************** *** 795,801 **** return -1; for (;;) { ! int sbytes = state_buf_len * sizeof(pf_state_t); ps.ps_len = sbytes; ps.ps_buf = (char *) state_buf; --- 639,645 ---- return -1; for (;;) { ! int sbytes = state_buf_len * sizeof(struct pfsync_state); ps.ps_len = sbytes; ps.ps_buf = (char *) state_buf; *************** *** 803,809 **** if (ioctl(pf_dev, DIOCGETSTATES, &ps) < 0) { error("DIOCGETSTATES"); } ! num_states_all = ps.ps_len / sizeof(pf_state_t); if (ps.ps_len < sbytes) break; --- 647,653 ---- if (ioctl(pf_dev, DIOCGETSTATES, &ps) < 0) { error("DIOCGETSTATES"); } ! num_states_all = ps.ps_len / sizeof(struct pfsync_state); if (ps.ps_len < sbytes) break; *************** *** 871,877 **** tbprintf("/%u", unmask(mask, af)); } } ! #ifdef HAVE_PFSYNC_KEY void print_fld_host2(field_def *fld, struct pfsync_state_key *ks, struct pfsync_state_key *kn, int idx, int af) --- 715,721 ---- tbprintf("/%u", unmask(mask, af)); } } ! void print_fld_host2(field_def *fld, struct pfsync_state_key *ks, struct pfsync_state_key *kn, int idx, int af) *************** *** 912,943 **** } } - #else - void - print_fld_host(field_def *fld, pf_state_host_t * h, int af) - { - u_int16_t p = ntohs(h->port); - if (fld == NULL) - return; - - if (fld->width < 3) { - print_fld_str(fld, "*"); - return; - } - - tb_start(); - tb_print_addr(&h->addr, NULL, af); - - if (af == AF_INET) - tbprintf(":%u", p); - else - tbprintf("[%u]", p); - - print_fld_tb(fld); - } - #endif - void print_fld_state(field_def *fld, unsigned int proto, unsigned int s1, unsigned int s2) --- 756,762 ---- *************** *** 988,997 **** } int ! print_state(pf_state_t * s, struct sc_ent * ent) { ! pf_state_peer_t *src, *dst; struct protoent *p; if (s->direction == PF_OUT) { src = &s->src; --- 807,817 ---- } int ! print_state(struct pfsync_state * s, struct sc_ent * ent) { ! struct pfsync_state_peer *src, *dst; struct protoent *p; + u_int64_t sz; if (s->direction == PF_OUT) { src = &s->src; *************** *** 1008,1014 **** else print_fld_uint(FLD_PROTO, s->proto); - #ifdef HAVE_PFSYNC_KEY if (s->direction == PF_OUT) { print_fld_host2(FLD_SRC, &s->key[PF_SK_WIRE], &s->key[PF_SK_STACK], 1, s->af); --- 828,833 ---- *************** *** 1020,1040 **** print_fld_host2(FLD_DEST, &s->key[PF_SK_STACK], &s->key[PF_SK_WIRE], 1, s->af); } - #else - if (s->direction == PF_OUT) { - print_fld_host(FLD_SRC, &s->lan, s->af); - print_fld_host(FLD_DEST, &s->ext, s->af); - } else { - print_fld_host(FLD_SRC, &s->ext, s->af); - print_fld_host(FLD_DEST, &s->lan, s->af); - } - if (PF_ANEQ(&s->lan.addr, &s->gwy.addr, s->af) || - (s->lan.port != s->gwy.port)) { - print_fld_host(FLD_GW, &s->gwy, s->af); - } - #endif - if (s->direction == PF_OUT) print_fld_str(FLD_DIR, "Out"); else --- 839,845 ---- *************** *** 1043,1072 **** print_fld_state(FLD_STATE, s->proto, src->state, dst->state); print_fld_age(FLD_AGE, ntohl(s->creation)); print_fld_age(FLD_EXP, ntohl(s->expire)); - #ifdef HAVE_INOUT_COUNT - { - u_int64_t sz = COUNTER(s->bytes[0]) + COUNTER(s->bytes[1]); ! print_fld_size(FLD_PKTS, COUNTER(s->packets[0]) + ! COUNTER(s->packets[1])); ! print_fld_size(FLD_BYTES, sz); ! print_fld_rate(FLD_SA, (s->creation) ? ! ((double)sz/ntohl((double)s->creation)) : -1); ! } ! #else ! print_fld_size(FLD_PKTS, s->packets); ! print_fld_size(FLD_BYTES, s->bytes); print_fld_rate(FLD_SA, (s->creation) ? ! ((double)s->bytes/ntohl((double)s->creation)) : -1); - #endif - #ifdef HAVE_PFSYNC_STATE print_fld_uint(FLD_RULE, s->rule); - #else - #ifdef HAVE_RULE_NUMBER - print_fld_uint(FLD_RULE, s->rule.nr); - #endif - #endif if (cachestates && ent != NULL) { print_fld_rate(FLD_SI, ent->rate); print_fld_rate(FLD_SP, ent->peak); --- 848,863 ---- print_fld_state(FLD_STATE, s->proto, src->state, dst->state); print_fld_age(FLD_AGE, ntohl(s->creation)); print_fld_age(FLD_EXP, ntohl(s->expire)); ! sz = COUNTER(s->bytes[0]) + COUNTER(s->bytes[1]); ! ! print_fld_size(FLD_PKTS, COUNTER(s->packets[0]) + ! COUNTER(s->packets[1])); ! print_fld_size(FLD_BYTES, sz); print_fld_rate(FLD_SA, (s->creation) ? ! ((double)sz/ntohl((double)s->creation)) : -1); print_fld_uint(FLD_RULE, s->rule); if (cachestates && ent != NULL) { print_fld_rate(FLD_SI, ent->rate); print_fld_rate(FLD_SP, ent->peak); *************** *** 1123,1145 **** } } - #ifdef HAVE_RULE_LABELS int label_length; - #endif int read_anchor_rules(char *anchor) { struct pfioc_rule pr; u_int32_t nr, num, off; if (pf_dev < 0) return (-1); memset(&pr, 0, sizeof(pr)); - #ifdef HAVE_RULESETS strlcpy(pr.anchor, anchor, sizeof(pr.anchor)); ! #endif if (ioctl(pf_dev, DIOCGETRULES, &pr)) { error("anchor %s: %s", anchor, strerror(errno)); return (-1); --- 914,934 ---- } } int label_length; int read_anchor_rules(char *anchor) { struct pfioc_rule pr; u_int32_t nr, num, off; + int len; if (pf_dev < 0) return (-1); memset(&pr, 0, sizeof(pr)); strlcpy(pr.anchor, anchor, sizeof(pr.anchor)); ! if (ioctl(pf_dev, DIOCGETRULES, &pr)) { error("anchor %s: %s", anchor, strerror(errno)); return (-1); *************** *** 1155,1179 **** error("DIOCGETRULE: %s", strerror(errno)); return (-1); } - #ifdef HAVE_RULESETS /* XXX overload pr.anchor, to store a pointer to * anchor name */ pr.rule.anchor = (struct pf_anchor *) anchor; ! #endif ! #ifdef HAVE_RULE_LABELS ! { ! int len = strlen(pr.rule.label); ! if (len > label_length) ! label_length = len; ! } ! #endif rules[off + nr] = pr.rule; } return (num); } - #ifdef HAVE_RULESETS struct anchor_name { char name[MAXPATHLEN]; struct anchor_name *next; --- 944,961 ---- error("DIOCGETRULE: %s", strerror(errno)); return (-1); } /* XXX overload pr.anchor, to store a pointer to * anchor name */ pr.rule.anchor = (struct pf_anchor *) anchor; ! len = strlen(pr.rule.label); ! if (len > label_length) ! label_length = len; rules[off + nr] = pr.rule; } return (num); } struct anchor_name { char name[MAXPATHLEN]; struct anchor_name *next; *************** *** 1308,1362 **** need_update = 1; } } - #endif int read_rules(void) { ! int ret; num_rules = 0; if (pf_dev == -1) return (-1); - #ifdef HAVE_RULE_LABELS label_length = MIN_LABEL_SIZE; - #endif - #ifdef HAVE_RULESETS reset_anchor_names(); ret = read_rulesets(NULL); compute_anchor_field(); - #else - ret = read_anchor_rules(NULL); - #endif ! #ifdef HAVE_RULE_LABELS ! { ! int nw, mw; ! nw = mw = label_length; ! if (nw > 16) ! nw = 16; ! if (FLD_LABEL->norm_width != nw || ! FLD_LABEL->max_width != mw) { ! FLD_LABEL->norm_width = nw; ! FLD_LABEL->max_width = mw; ! field_setup(); ! need_update = 1; ! } } - #endif num_disp = num_rules; return (ret); } - #ifdef HAVE_ADDR_WRAP void tb_print_addrw(struct pf_addr_wrap *addr, struct pf_addr *mask, u_int8_t af) { - #ifdef HAVE_ADDR_TYPE switch (addr->type) { case PF_ADDR_ADDRMASK: tb_print_addr(&addr->v.a.addr, mask, af); --- 1090,1130 ---- need_update = 1; } } int read_rules(void) { ! int ret, nw, mw; num_rules = 0; if (pf_dev == -1) return (-1); label_length = MIN_LABEL_SIZE; reset_anchor_names(); ret = read_rulesets(NULL); compute_anchor_field(); ! nw = mw = label_length; ! if (nw > 16) ! nw = 16; ! if (FLD_LABEL->norm_width != nw || ! FLD_LABEL->max_width != mw) { ! FLD_LABEL->norm_width = nw; ! FLD_LABEL->max_width = mw; ! field_setup(); ! need_update = 1; } num_disp = num_rules; return (ret); } void tb_print_addrw(struct pf_addr_wrap *addr, struct pf_addr *mask, u_int8_t af) { switch (addr->type) { case PF_ADDR_ADDRMASK: tb_print_addr(&addr->v.a.addr, mask, af); *************** *** 1374,1387 **** tbprintf("UNKNOWN"); break; } - #else - if (addr->addr_dyn != NULL) - tbprintf("(%s)", addr->addr.pfa.ifname); - else - tb_print_addr(&addr->addr, mask, af); - #endif } - #endif void tb_print_op(u_int8_t op, const char *a1, const char *a2) --- 1142,1148 ---- *************** *** 1390,1399 **** tbprintf("%s >< %s ", a1, a2); else if (op == PF_OP_XRG) tbprintf("%s <> %s ", a1, a2); - #ifdef HAVE_OP_RRG else if (op == PF_OP_RRG) tbprintf("%s:%s ", a1, a2); - #endif else if (op == PF_OP_EQ) tbprintf("= %s ", a1); else if (op == PF_OP_NE) --- 1151,1158 ---- *************** *** 1445,1461 **** PF_AZERO(PT_MASK(src), AF_INET6)) tbprintf("any "); else { - #ifdef HAVE_NEG if (src->neg) - #else - if (src->not) - #endif tbprintf("! "); - #ifdef HAVE_ADDR_WRAP tb_print_addrw(&src->addr, PT_MASK(src), af); - #else - tb_print_addr(&src->addr, PT_MASK(src), af); - #endif tbprintf(" "); } if (src->port_op) --- 1204,1212 ---- *************** *** 1470,1486 **** PF_AZERO(PT_MASK(dst), AF_INET6)) tbprintf("any "); else { - #ifdef HAVE_NEG if (dst->neg) - #else - if (dst->not) - #endif tbprintf("! "); - #ifdef HAVE_ADDR_WRAP tb_print_addrw(&dst->addr, PT_MASK(dst), af); - #else - tb_print_addr(&dst->addr, PT_MASK(dst), af); - #endif tbprintf(" "); } if (dst->port_op) --- 1221,1229 ---- *************** *** 1490,1496 **** } } - #ifdef HAVE_RULE_UGID void tb_print_ugid(u_int8_t op, unsigned u1, unsigned u2, const char *t, unsigned umax) --- 1233,1238 ---- *************** *** 1506,1512 **** else tb_print_op(op, a1, a2); } - #endif void tb_print_flags(u_int8_t f) --- 1248,1253 ---- *************** *** 1526,1558 **** "no Nat", "Binat", "no Binat", "Rdr", "no Rdr" }; int numact = sizeof(actiontypes) / sizeof(char *); - #ifdef HAVE_PF_ROUTE static const char *routetypes[] = { "", "fastroute", "route-to", "dup-to", "reply-to" }; int numroute = sizeof(routetypes) / sizeof(char *); - #endif if (pr == NULL) return; - #ifdef HAVE_RULE_LABELS print_fld_str(FLD_LABEL, pr->label); - #endif - #ifdef HAVE_RULE_STATES - #ifdef HAVE_PFSYNC_KEY print_fld_size(FLD_STATS, pr->states_tot); - #else - print_fld_size(FLD_STATS, pr->states); - #endif - #endif - #ifdef HAVE_INOUT_COUNT_RULES print_fld_size(FLD_PKTS, pr->packets[0] + pr->packets[1]); print_fld_size(FLD_BYTES, pr->bytes[0] + pr->bytes[1]); ! #else ! print_fld_size(FLD_PKTS, pr->packets); ! print_fld_size(FLD_BYTES, pr->bytes); ! #endif print_fld_uint(FLD_RULE, pr->nr); print_fld_str(FLD_DIR, pr->direction == PF_OUT ? "Out" : "In"); if (pr->quick) --- 1267,1285 ---- "no Nat", "Binat", "no Binat", "Rdr", "no Rdr" }; int numact = sizeof(actiontypes) / sizeof(char *); static const char *routetypes[] = { "", "fastroute", "route-to", "dup-to", "reply-to" }; int numroute = sizeof(routetypes) / sizeof(char *); if (pr == NULL) return; print_fld_str(FLD_LABEL, pr->label); print_fld_size(FLD_STATS, pr->states_tot); print_fld_size(FLD_PKTS, pr->packets[0] + pr->packets[1]); print_fld_size(FLD_BYTES, pr->bytes[0] + pr->bytes[1]); ! print_fld_uint(FLD_RULE, pr->nr); print_fld_str(FLD_DIR, pr->direction == PF_OUT ? "Out" : "In"); if (pr->quick) *************** *** 1586,1610 **** if (pr->ifname[0]) { tb_start(); - #ifdef HAVE_RULE_IFNOT if (pr->ifnot) tbprintf("!"); - #endif tbprintf("%s", pr->ifname); print_fld_tb(FLD_IF); } - #ifdef HAVE_MAX_STATES if (pr->max_states) print_fld_uint(FLD_STMAX, pr->max_states); ! #endif /* print info field */ tb_start(); - #ifdef HAVE_RULE_NATPASS if (pr->natpass) tbprintf("pass "); ! #endif if (pr->action == PF_DROP) { if (pr->rule_flag & PFRULE_RETURNRST) tbprintf("return-rst "); --- 1313,1333 ---- if (pr->ifname[0]) { tb_start(); if (pr->ifnot) tbprintf("!"); tbprintf("%s", pr->ifname); print_fld_tb(FLD_IF); } if (pr->max_states) print_fld_uint(FLD_STMAX, pr->max_states); ! /* print info field */ tb_start(); if (pr->natpass) tbprintf("pass "); ! if (pr->action == PF_DROP) { if (pr->rule_flag & PFRULE_RETURNRST) tbprintf("return-rst "); *************** *** 1620,1632 **** tbprintf("drop "); } - #ifdef HAVE_PF_ROUTE if (pr->rt > 0 && pr->rt < numroute) { tbprintf("%s ", routetypes[pr->rt]); if (pr->rt != PF_FASTROUTE) tbprintf("... "); } ! #endif if (pr->af) { if (pr->af == AF_INET) tbprintf("inet "); --- 1343,1354 ---- tbprintf("drop "); } if (pr->rt > 0 && pr->rt < numroute) { tbprintf("%s ", routetypes[pr->rt]); if (pr->rt != PF_FASTROUTE) tbprintf("... "); } ! if (pr->af) { if (pr->af == AF_INET) tbprintf("inet "); *************** *** 1635,1648 **** } tb_print_fromto(&pr->src, &pr->dst, pr->af, pr->proto); ! #ifdef HAVE_RULE_UGID if (pr->uid.op) tb_print_ugid(pr->uid.op, pr->uid.uid[0], pr->uid.uid[1], "user", UID_MAX); if (pr->gid.op) tb_print_ugid(pr->gid.op, pr->gid.gid[0], pr->gid.gid[1], "group", GID_MAX); - #endif if (pr->flags || pr->flagset) { tbprintf(" flags "); --- 1357,1369 ---- } tb_print_fromto(&pr->src, &pr->dst, pr->af, pr->proto); ! if (pr->uid.op) tb_print_ugid(pr->uid.op, pr->uid.uid[0], pr->uid.uid[1], "user", UID_MAX); if (pr->gid.op) tb_print_ugid(pr->gid.op, pr->gid.gid[0], pr->gid.gid[1], "group", GID_MAX); if (pr->flags || pr->flagset) { tbprintf(" flags "); *************** *** 1653,1662 **** tbprintf(" "); - #ifdef HAVE_RULE_TOS if (pr->tos) tbprintf("tos 0x%2.2x ", pr->tos); - #endif #ifdef PFRULE_FRAGMENT if (pr->rule_flag & PFRULE_FRAGMENT) tbprintf("fragment "); --- 1374,1381 ---- *************** *** 1671,1680 **** #endif if (pr->min_ttl) tbprintf("min-ttl %d ", pr->min_ttl); - #ifdef HAVE_MAX_MSS if (pr->max_mss) tbprintf("max-mss %d ", pr->max_mss); - #endif if (pr->allow_opts) tbprintf("allow-opts "); --- 1390,1397 ---- *************** *** 1696,1708 **** tbprintf("fragment reassemble "); } - #ifdef HAVE_ALTQ if (pr->qname[0] && pr->pqname[0]) tbprintf("queue(%s, %s) ", pr->qname, pr->pqname); else if (pr->qname[0]) tbprintf("queue %s ", pr->qname); ! #endif ! #ifdef HAVE_TAGS if (pr->tagname[0]) tbprintf("tag %s ", pr->tagname); if (pr->match_tagname[0]) { --- 1413,1423 ---- tbprintf("fragment reassemble "); } if (pr->qname[0] && pr->pqname[0]) tbprintf("queue(%s, %s) ", pr->qname, pr->pqname); else if (pr->qname[0]) tbprintf("queue %s ", pr->qname); ! if (pr->tagname[0]) tbprintf("tag %s ", pr->tagname); if (pr->match_tagname[0]) { *************** *** 1710,1722 **** tbprintf("! "); tbprintf("tagged %s ", pr->match_tagname); } ! #endif print_fld_tb(FLD_RINFO); - #ifdef HAVE_RULESETS /* XXX anchor field overloaded with anchor name */ print_fld_str(FLD_ANCHOR, (char *)pr->anchor); - #endif tb_end(); end_line(); --- 1425,1435 ---- tbprintf("! "); tbprintf("tagged %s ", pr->match_tagname); } ! print_fld_tb(FLD_RINFO); /* XXX anchor field overloaded with anchor name */ print_fld_str(FLD_ANCHOR, (char *)pr->anchor); tb_end(); end_line(); *************** *** 1737,1744 **** /* queue display */ - #ifdef HAVE_ALTQ - struct pf_altq_node * pfctl_find_altq_node(struct pf_altq_node *root, const char *qname, const char *ifname) --- 1450,1455 ---- *************** *** 2097,2104 **** } } - #endif /* HAVE_ALTQ */ - /* main program functions */ void --- 1808,1813 ---- *************** *** 2149,2159 **** update_cache(); - #ifdef HAVE_MAX_STATES show_field(FLD_STMAX); - #endif - #ifdef HAVE_RULESETS show_field(FLD_ANCHOR); - #endif - } --- 1858,1863 ----