| 2160 | }; |
| 2161 | |
| 2162 | static void |
| 2163 | show_static_rule(struct cmdline_opts *co, struct format_opts *fo, |
| 2164 | struct buf_pr *bp, struct ip_fw_rule *rule, struct ip_fw_bcounter *cntr) |
| 2165 | { |
| 2166 | static int twidth = 0; |
| 2167 | struct show_state state; |
| 2168 | ipfw_insn *cmd; |
| 2169 | size_t i; |
| 2170 | |
| 2171 | /* Print # DISABLED or skip the rule */ |
| 2172 | if ((fo->set_mask & (1 << rule->set)) == 0) { |
| 2173 | /* disabled mask */ |
| 2174 | if (!co->show_sets) |
| 2175 | return; |
| 2176 | else |
| 2177 | bprintf(bp, "# DISABLED "); |
| 2178 | } |
| 2179 | if (init_show_state(&state, rule) != 0) { |
| 2180 | warn("init_show_state() failed"); |
| 2181 | return; |
| 2182 | } |
| 2183 | bprintf(bp, "%05u ", rule->rulenum); |
| 2184 | |
| 2185 | /* Print counters if enabled */ |
| 2186 | if (fo->pcwidth > 0 || fo->bcwidth > 0) { |
| 2187 | pr_u64(bp, &cntr->pcnt, fo->pcwidth); |
| 2188 | pr_u64(bp, &cntr->bcnt, fo->bcwidth); |
| 2189 | } |
| 2190 | |
| 2191 | /* Print timestamp */ |
| 2192 | if (co->do_time == TIMESTAMP_NUMERIC) |
| 2193 | bprintf(bp, "%10u ", cntr->timestamp); |
| 2194 | else if (co->do_time == TIMESTAMP_STRING) { |
| 2195 | char timestr[30]; |
| 2196 | time_t t = (time_t)0; |
| 2197 | |
| 2198 | if (twidth == 0) { |
| 2199 | strcpy(timestr, ctime(&t)); |
| 2200 | *strchr(timestr, '\n') = '\0'; |
| 2201 | twidth = strlen(timestr); |
| 2202 | } |
| 2203 | if (cntr->timestamp > 0) { |
| 2204 | t = _long_to_time(cntr->timestamp); |
| 2205 | |
| 2206 | strcpy(timestr, ctime(&t)); |
| 2207 | *strchr(timestr, '\n') = '\0'; |
| 2208 | bprintf(bp, "%s ", timestr); |
| 2209 | } else { |
| 2210 | bprintf(bp, "%*s ", twidth, ""); |
| 2211 | } |
| 2212 | } |
| 2213 | |
| 2214 | /* Print set number */ |
| 2215 | if (co->show_sets) |
| 2216 | bprintf(bp, "set %d ", rule->set); |
| 2217 | |
| 2218 | /* Print the optional "match probability" */ |
| 2219 | cmd = print_opcode(bp, fo, &state, O_PROB); |
no test coverage detected