| 2779 | } |
| 2780 | |
| 2781 | static int |
| 2782 | ipfw_show_config(struct cmdline_opts *co, struct format_opts *fo, |
| 2783 | ipfw_cfg_lheader *cfg, size_t sz, int ac, char *av[]) |
| 2784 | { |
| 2785 | caddr_t dynbase; |
| 2786 | size_t dynsz; |
| 2787 | int rcnt; |
| 2788 | int exitval = EX_OK; |
| 2789 | int lac; |
| 2790 | char **lav; |
| 2791 | char *endptr; |
| 2792 | size_t readsz; |
| 2793 | struct buf_pr bp; |
| 2794 | ipfw_obj_ctlv *ctlv, *tstate; |
| 2795 | ipfw_obj_tlv *rbase; |
| 2796 | |
| 2797 | /* |
| 2798 | * Handle tablenames TLV first, if any |
| 2799 | */ |
| 2800 | tstate = NULL; |
| 2801 | rbase = NULL; |
| 2802 | dynbase = NULL; |
| 2803 | dynsz = 0; |
| 2804 | readsz = sizeof(*cfg); |
| 2805 | rcnt = 0; |
| 2806 | |
| 2807 | fo->set_mask = cfg->set_mask; |
| 2808 | |
| 2809 | ctlv = (ipfw_obj_ctlv *)(cfg + 1); |
| 2810 | if (ctlv->head.type == IPFW_TLV_TBLNAME_LIST) { |
| 2811 | object_sort_ctlv(ctlv); |
| 2812 | fo->tstate = ctlv; |
| 2813 | readsz += ctlv->head.length; |
| 2814 | ctlv = (ipfw_obj_ctlv *)((caddr_t)ctlv + ctlv->head.length); |
| 2815 | } |
| 2816 | |
| 2817 | if (cfg->flags & IPFW_CFG_GET_STATIC) { |
| 2818 | /* We've requested static rules */ |
| 2819 | if (ctlv->head.type == IPFW_TLV_RULE_LIST) { |
| 2820 | rbase = (ipfw_obj_tlv *)(ctlv + 1); |
| 2821 | rcnt = ctlv->count; |
| 2822 | readsz += ctlv->head.length; |
| 2823 | ctlv = (ipfw_obj_ctlv *)((caddr_t)ctlv + |
| 2824 | ctlv->head.length); |
| 2825 | } |
| 2826 | } |
| 2827 | |
| 2828 | if ((cfg->flags & IPFW_CFG_GET_STATES) && (readsz != sz)) { |
| 2829 | /* We may have some dynamic states */ |
| 2830 | dynsz = sz - readsz; |
| 2831 | /* Skip empty header */ |
| 2832 | if (dynsz != sizeof(ipfw_obj_ctlv)) |
| 2833 | dynbase = (caddr_t)ctlv; |
| 2834 | else |
| 2835 | dynsz = 0; |
| 2836 | } |
| 2837 | |
| 2838 | prepare_format_opts(co, fo, rbase, rcnt, dynbase, dynsz); |
no test coverage detected