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

Function ipfw_delete

tools/ipfw/ipfw2.c:3336–3414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3334
3335
3336void
3337ipfw_delete(char *av[])
3338{
3339 ipfw_range_tlv rt;
3340 char *sep;
3341 int i, j;
3342 int exitval = EX_OK;
3343 int do_set = 0;
3344
3345 av++;
3346 NEED1("missing rule specification");
3347 if ( *av && _substrcmp(*av, "set") == 0) {
3348 /* Do not allow using the following syntax:
3349 * ipfw set N delete set M
3350 */
3351 if (g_co.use_set)
3352 errx(EX_DATAERR, "invalid syntax");
3353 do_set = 1; /* delete set */
3354 av++;
3355 }
3356
3357 /* Rule number */
3358 while (*av && isdigit(**av)) {
3359 i = strtol(*av, &sep, 10);
3360 j = i;
3361 if (*sep== '-')
3362 j = strtol(sep + 1, NULL, 10);
3363 av++;
3364 if (g_co.do_nat) {
3365 exitval = ipfw_delete_nat(i);
3366 } else if (g_co.do_pipe) {
3367#ifdef DUMMYNET
3368 exitval = ipfw_delete_pipe(g_co.do_pipe, i);
3369#else
3370 exitval = EX_UNAVAILABLE;
3371#endif
3372 } else {
3373 memset(&rt, 0, sizeof(rt));
3374 if (do_set != 0) {
3375 rt.set = i & 31;
3376 rt.flags = IPFW_RCFLAG_SET;
3377 } else {
3378 rt.start_rule = i & 0xffff;
3379 rt.end_rule = j & 0xffff;
3380 if (rt.start_rule == 0 && rt.end_rule == 0)
3381 rt.flags |= IPFW_RCFLAG_ALL;
3382 else
3383 rt.flags |= IPFW_RCFLAG_RANGE;
3384 if (g_co.use_set != 0) {
3385 rt.set = g_co.use_set - 1;
3386 rt.flags |= IPFW_RCFLAG_SET;
3387 }
3388 }
3389 if (g_co.do_dynamic == 2)
3390 rt.flags |= IPFW_RCFLAG_DYNAMIC;
3391 i = do_range_cmd(IP_FW_XDEL, &rt);
3392 if (i != 0) {
3393 exitval = EX_UNAVAILABLE;

Callers 1

main.cFile · 0.85

Calls 7

_substrcmpFunction · 0.85
isdigitFunction · 0.85
strtolFunction · 0.85
ipfw_delete_natFunction · 0.85
ipfw_delete_pipeFunction · 0.85
memsetFunction · 0.85
do_range_cmdFunction · 0.85

Tested by

no test coverage detected