MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ipfw_flush

Function ipfw_flush

tools/ipfw/ipfw2.c:5464–5503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5462}
5463
5464void
5465ipfw_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
5505static struct _s_x intcmds[] = {
5506 { "talist", TOK_TALIST },

Callers 1

main.cFile · 0.85

Calls 5

toupperFunction · 0.85
memsetFunction · 0.85
do_range_cmdFunction · 0.85
dummynet_flushFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected