| 2604 | } |
| 2605 | |
| 2606 | static void |
| 2607 | prepare_format_opts(struct cmdline_opts *co, struct format_opts *fo, |
| 2608 | ipfw_obj_tlv *rtlv, int rcnt, caddr_t dynbase, size_t dynsz) |
| 2609 | { |
| 2610 | int bcwidth, pcwidth, width; |
| 2611 | int n; |
| 2612 | struct ip_fw_bcounter *cntr; |
| 2613 | struct ip_fw_rule *r; |
| 2614 | |
| 2615 | bcwidth = 0; |
| 2616 | pcwidth = 0; |
| 2617 | if (fo->show_counters != 0) { |
| 2618 | for (n = 0; n < rcnt; n++, |
| 2619 | rtlv = (ipfw_obj_tlv *)((caddr_t)rtlv + rtlv->length)) { |
| 2620 | cntr = (struct ip_fw_bcounter *)(rtlv + 1); |
| 2621 | r = (struct ip_fw_rule *)((caddr_t)cntr + cntr->size); |
| 2622 | /* skip rules from another set */ |
| 2623 | if (co->use_set && r->set != co->use_set - 1) |
| 2624 | continue; |
| 2625 | |
| 2626 | /* packet counter */ |
| 2627 | width = pr_u64(NULL, &cntr->pcnt, 0); |
| 2628 | if (width > pcwidth) |
| 2629 | pcwidth = width; |
| 2630 | |
| 2631 | /* byte counter */ |
| 2632 | width = pr_u64(NULL, &cntr->bcnt, 0); |
| 2633 | if (width > bcwidth) |
| 2634 | bcwidth = width; |
| 2635 | } |
| 2636 | } |
| 2637 | fo->bcwidth = bcwidth; |
| 2638 | fo->pcwidth = pcwidth; |
| 2639 | |
| 2640 | fo->dcnt = 0; |
| 2641 | if (co->do_dynamic && dynsz > 0) |
| 2642 | foreach_state(co, fo, dynbase, dynsz, prepare_format_dyn, NULL); |
| 2643 | } |
| 2644 | |
| 2645 | static int |
| 2646 | list_static_range(struct cmdline_opts *co, struct format_opts *fo, |
no test coverage detected