MCPcopy Create free account
hub / github.com/F-Stack/f-stack / prepare_format_opts

Function prepare_format_opts

tools/ipfw/ipfw2.c:2606–2643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2604}
2605
2606static void
2607prepare_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
2645static int
2646list_static_range(struct cmdline_opts *co, struct format_opts *fo,

Callers 1

ipfw_show_configFunction · 0.85

Calls 2

pr_u64Function · 0.85
foreach_stateFunction · 0.85

Tested by

no test coverage detected