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

Function table_create

tools/ipfw/tables.c:405–508  ·  view source on GitHub ↗

* Creates new table * * ipfw table NAME create [ type { addr | iface | number | flow } ] * [ algo algoname ] [missing] [or-flush] */

Source from the content-addressed store, hash-verified

403 * [ algo algoname ] [missing] [or-flush]
404 */
405static void
406table_create(ipfw_obj_header *oh, int ac, char *av[])
407{
408 ipfw_xtable_info xi, xie;
409 int error, missing, orflush, tcmd, val;
410 uint32_t fset, fclear;
411 char *e, *p;
412 char tbuf[128];
413
414 missing = orflush = 0;
415 memset(&xi, 0, sizeof(xi));
416 while (ac > 0) {
417 tcmd = get_token(tablenewcmds, *av, "option");
418 ac--; av++;
419
420 switch (tcmd) {
421 case TOK_LIMIT:
422 NEED1("limit value required");
423 xi.limit = strtol(*av, NULL, 10);
424 ac--; av++;
425 break;
426 case TOK_TYPE:
427 NEED1("table type required");
428 /* Type may have suboptions after ':' */
429 if ((p = strchr(*av, ':')) != NULL)
430 *p++ = '\0';
431 val = match_token(tabletypes, *av);
432 if (val == -1) {
433 concat_tokens(tbuf, sizeof(tbuf), tabletypes,
434 ", ");
435 errx(EX_USAGE,
436 "Unknown tabletype: %s. Supported: %s",
437 *av, tbuf);
438 }
439 xi.type = val;
440 if (p != NULL) {
441 error = table_parse_type(val, p, &xi.tflags);
442 if (error != 0)
443 errx(EX_USAGE,
444 "Unsupported suboptions: %s", p);
445 }
446 ac--; av++;
447 break;
448 case TOK_VALTYPE:
449 NEED1("table value type required");
450 fset = fclear = 0;
451 val = fill_flags(tablevaltypes, *av, &e, &fset, &fclear);
452 if (val != -1) {
453 xi.vmask = fset;
454 ac--; av++;
455 break;
456 }
457 concat_tokens(tbuf, sizeof(tbuf), tablevaltypes, ", ");
458 errx(EX_USAGE, "Unknown value type: %s. Supported: %s",
459 e, tbuf);
460 break;
461 case TOK_ALGO:
462 NEED1("table algorithm name required");

Callers 1

ipfw_table_handlerFunction · 0.70

Calls 13

memsetFunction · 0.85
strtolFunction · 0.85
strchrFunction · 0.85
match_tokenFunction · 0.85
concat_tokensFunction · 0.85
table_parse_typeFunction · 0.85
fill_flagsFunction · 0.85
table_do_createFunction · 0.85
table_get_infoFunction · 0.85
strcmpFunction · 0.85
table_flushFunction · 0.85
get_tokenFunction · 0.70

Tested by

no test coverage detected