| 5462 | } |
| 5463 | |
| 5464 | void |
| 5465 | ipfw_flush(int force) |
| 5466 | { |
| 5467 | ipfw_range_tlv rt; |
| 5468 | |
| 5469 | if (!force && !g_co.do_quiet) { /* need to ask user */ |
| 5470 | int c; |
| 5471 | |
| 5472 | printf("Are you sure? [yn] "); |
| 5473 | fflush(stdout); |
| 5474 | do { |
| 5475 | c = toupper(getc(stdin)); |
| 5476 | while (c != '\n' && getc(stdin) != '\n') |
| 5477 | if (feof(stdin)) |
| 5478 | return; /* and do not flush */ |
| 5479 | } while (c != 'Y' && c != 'N'); |
| 5480 | printf("\n"); |
| 5481 | if (c == 'N') /* user said no */ |
| 5482 | return; |
| 5483 | } |
| 5484 | if (g_co.do_pipe) { |
| 5485 | #ifdef DUMMYNET |
| 5486 | dummynet_flush(); |
| 5487 | #else |
| 5488 | fprintf(stderr, "dummynet_flush not supported\n"); |
| 5489 | #endif |
| 5490 | return; |
| 5491 | } |
| 5492 | /* `ipfw set N flush` - is the same that `ipfw delete set N` */ |
| 5493 | memset(&rt, 0, sizeof(rt)); |
| 5494 | if (g_co.use_set != 0) { |
| 5495 | rt.set = g_co.use_set - 1; |
| 5496 | rt.flags = IPFW_RCFLAG_SET; |
| 5497 | } else |
| 5498 | rt.flags = IPFW_RCFLAG_ALL; |
| 5499 | if (do_range_cmd(IP_FW_XDEL, &rt) != 0) |
| 5500 | err(EX_UNAVAILABLE, "setsockopt(IP_FW_XDEL)"); |
| 5501 | if (!g_co.do_quiet) |
| 5502 | printf("Flushed all %s.\n", g_co.do_pipe ? "pipes" : "rules"); |
| 5503 | } |
| 5504 | |
| 5505 | static struct _s_x intcmds[] = { |
| 5506 | { "talist", TOK_TALIST }, |
no test coverage detected