Lines 61-66
static void print_table(struct pfr_table *, int, int);
Link Here
|
61 |
static void print_tstats(struct pfr_tstats *, int); |
61 |
static void print_tstats(struct pfr_tstats *, int); |
62 |
static int load_addr(struct pfr_buffer *, int, char *[], char *, int); |
62 |
static int load_addr(struct pfr_buffer *, int, char *[], char *, int); |
63 |
static void print_addrx(struct pfr_addr *, struct pfr_addr *, int); |
63 |
static void print_addrx(struct pfr_addr *, struct pfr_addr *, int); |
|
|
64 |
static int nonzero_astats(struct pfr_astats *); |
64 |
static void print_astats(struct pfr_astats *, int); |
65 |
static void print_astats(struct pfr_astats *, int); |
65 |
static void radix_perror(void); |
66 |
static void radix_perror(void); |
66 |
static void xprintf(int, const char *, ...); |
67 |
static void xprintf(int, const char *, ...); |
Lines 294-299
pfctl_table(int argc, char *argv[], char *tname, const char *command,
Link Here
|
294 |
if ((opts & PF_OPT_VERBOSE2) || a->pfra_fback) |
295 |
if ((opts & PF_OPT_VERBOSE2) || a->pfra_fback) |
295 |
print_addrx(a, NULL, |
296 |
print_addrx(a, NULL, |
296 |
opts & PF_OPT_USEDNS); |
297 |
opts & PF_OPT_USEDNS); |
|
|
298 |
} else if (!strcmp(command, "makezero")) { |
299 |
struct pfr_astats *as; |
300 |
b.pfrb_type = PFRB_ASTATS; |
301 |
b2.pfrb_type = PFRB_ADDRS; |
302 |
|
303 |
if (argc || file != NULL) |
304 |
usage(); |
305 |
|
306 |
do { |
307 |
pfr_buf_grow(&b, b.pfrb_size); |
308 |
b.pfrb_size = b.pfrb_msize; |
309 |
RVTEST(pfr_get_astats(&table, b.pfrb_caddr, |
310 |
&b.pfrb_size, flags)); |
311 |
} while (b.pfrb_size > b.pfrb_msize); |
312 |
|
313 |
PFRB_FOREACH(as, &b) |
314 |
if (nonzero_astats(as)) |
315 |
if (pfr_buf_add(&b2, &as->pfras_a)) |
316 |
err(1, "duplicate buffer"); |
317 |
|
318 |
if (opts & PF_OPT_VERBOSE) |
319 |
flags |= PFR_FLAG_FEEDBACK; |
320 |
if (b2.pfrb_size) |
321 |
RVTEST(pfr_clr_astats(&table, b2.pfrb_caddr, |
322 |
b2.pfrb_size, &nzero, flags)); |
323 |
else |
324 |
nzero = 0; |
325 |
xprintf(opts, "%d/%d addresses cleared", nzero, b.pfrb_size); |
326 |
if (opts & PF_OPT_VERBOSE) |
327 |
PFRB_FOREACH(a, &b2) |
328 |
if (opts & PF_OPT_VERBOSE2 || |
329 |
a->pfra_fback != PFR_FB_NONE) |
330 |
print_addrx(a, NULL, |
331 |
opts & PF_OPT_USEDNS); |
297 |
} else if (!strcmp(command, "show")) { |
332 |
} else if (!strcmp(command, "show")) { |
298 |
b.pfrb_type = (opts & PF_OPT_VERBOSE) ? |
333 |
b.pfrb_type = (opts & PF_OPT_VERBOSE) ? |
299 |
PFRB_ASTATS : PFRB_ADDRS; |
334 |
PFRB_ASTATS : PFRB_ADDRS; |
Lines 472-477
print_addrx(struct pfr_addr *ad, struct pfr_addr *rad, int dns)
Link Here
|
472 |
printf("\n"); |
520 |
printf("\n"); |
473 |
} |
521 |
} |
474 |
|
522 |
|
|
|
523 |
int |
524 |
nonzero_astats(struct pfr_astats *as) |
525 |
{ |
526 |
u_int64_t s = 0; |
527 |
for (int dir = 0; dir < PFR_DIR_MAX; dir++) |
528 |
for (int op = 0; op < PFR_OP_ADDR_MAX; op++) |
529 |
s |= as->pfras_packets[dir][op] | |
530 |
as->pfras_bytes[dir][op]; |
531 |
return !!s; |
532 |
} |
533 |
|
475 |
void |
534 |
void |
476 |
print_astats(struct pfr_astats *as, int dns) |
535 |
print_astats(struct pfr_astats *as, int dns) |
477 |
{ |
536 |
{ |