Changeset View
Changeset View
Standalone View
Standalone View
sbin/ipfw/ipfw2.c
Show First 20 Lines • Show All 2,168 Lines • ▼ Show 20 Lines | else | ||||
bprintf(bp, "# DISABLED "); | bprintf(bp, "# DISABLED "); | ||||
} | } | ||||
if (init_show_state(&state, rule) != 0) { | if (init_show_state(&state, rule) != 0) { | ||||
warn("init_show_state() failed"); | warn("init_show_state() failed"); | ||||
return; | return; | ||||
} | } | ||||
bprintf(bp, "%05u ", rule->rulenum); | bprintf(bp, "%05u ", rule->rulenum); | ||||
/* only if counters are available */ | |||||
if (cntr != NULL) { | |||||
/* Print counters if enabled */ | /* Print counters if enabled */ | ||||
if (fo->pcwidth > 0 || fo->bcwidth > 0) { | if (fo->pcwidth > 0 || fo->bcwidth > 0) { | ||||
pr_u64(bp, &cntr->pcnt, fo->pcwidth); | pr_u64(bp, &cntr->pcnt, fo->pcwidth); | ||||
pr_u64(bp, &cntr->bcnt, fo->bcwidth); | pr_u64(bp, &cntr->bcnt, fo->bcwidth); | ||||
} | } | ||||
/* Print timestamp */ | /* Print timestamp */ | ||||
if (co->do_time == TIMESTAMP_NUMERIC) | if (co->do_time == TIMESTAMP_NUMERIC) | ||||
bprintf(bp, "%10u ", cntr->timestamp); | bprintf(bp, "%10u ", cntr->timestamp); | ||||
else if (co->do_time == TIMESTAMP_STRING) { | else if (co->do_time == TIMESTAMP_STRING) { | ||||
char timestr[30]; | char timestr[30]; | ||||
time_t t = (time_t)0; | time_t t = (time_t)0; | ||||
if (twidth == 0) { | if (twidth == 0) { | ||||
strcpy(timestr, ctime(&t)); | strcpy(timestr, ctime(&t)); | ||||
*strchr(timestr, '\n') = '\0'; | *strchr(timestr, '\n') = '\0'; | ||||
twidth = strlen(timestr); | twidth = strlen(timestr); | ||||
} | } | ||||
if (cntr->timestamp > 0) { | if (cntr->timestamp > 0) { | ||||
t = _long_to_time(cntr->timestamp); | t = _long_to_time(cntr->timestamp); | ||||
strcpy(timestr, ctime(&t)); | strcpy(timestr, ctime(&t)); | ||||
*strchr(timestr, '\n') = '\0'; | *strchr(timestr, '\n') = '\0'; | ||||
bprintf(bp, "%s ", timestr); | bprintf(bp, "%s ", timestr); | ||||
} else { | } else { | ||||
bprintf(bp, "%*s ", twidth, ""); | bprintf(bp, "%*s ", twidth, ""); | ||||
} | |||||
} | } | ||||
} | } | ||||
/* Print set number */ | /* Print set number */ | ||||
if (co->show_sets) | if (co->show_sets) | ||||
bprintf(bp, "set %d ", rule->set); | bprintf(bp, "set %d ", rule->set); | ||||
/* Print the optional "match probability" */ | /* Print the optional "match probability" */ | ||||
▲ Show 20 Lines • Show All 3,443 Lines • Show Last 20 Lines |