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

Function tentry_fill_key

tools/ipfw/tables.c:1428–1488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1426}
1427
1428static void
1429tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
1430 int add, uint8_t *ptype, uint32_t *pvmask, ipfw_xtable_info *xi)
1431{
1432 uint8_t type, tflags;
1433 uint32_t vmask;
1434 int error;
1435
1436 type = 0;
1437 tflags = 0;
1438 vmask = 0;
1439
1440 if (xi->tablename[0] == '\0')
1441 error = table_get_info(oh, xi);
1442 else
1443 error = 0;
1444
1445 if (error == 0) {
1446 if (g_co.test_only == 0) {
1447 /* Table found */
1448 type = xi->type;
1449 tflags = xi->tflags;
1450 vmask = xi->vmask;
1451 } else {
1452 /*
1453 * We're running `ipfw -n`
1454 * Compatibility layer: try to guess key type
1455 * before failing.
1456 */
1457 if (guess_key_type(key, &type) != 0) {
1458 /* Inknown key */
1459 errx(EX_USAGE, "Cannot guess "
1460 "key '%s' type", key);
1461 }
1462 vmask = IPFW_VTYPE_LEGACY;
1463 }
1464 } else {
1465 if (error != ESRCH)
1466 errx(EX_OSERR, "Error requesting table %s info",
1467 oh->ntlv.name);
1468 if (add == 0)
1469 errx(EX_DATAERR, "Table %s does not exist",
1470 oh->ntlv.name);
1471 /*
1472 * Table does not exist
1473 * Compatibility layer: try to guess key type before failing.
1474 */
1475 if (guess_key_type(key, &type) != 0) {
1476 /* Inknown key */
1477 errx(EX_USAGE, "Table %s does not exist, cannot guess "
1478 "key '%s' type", oh->ntlv.name, key);
1479 }
1480
1481 vmask = IPFW_VTYPE_LEGACY;
1482 }
1483
1484 tentry_fill_key_type(key, tent, type, tflags);
1485

Callers 2

table_modify_recordFunction · 0.85
table_do_lookupFunction · 0.85

Calls 3

table_get_infoFunction · 0.85
guess_key_typeFunction · 0.85
tentry_fill_key_typeFunction · 0.85

Tested by

no test coverage detected