| 1426 | } |
| 1427 | |
| 1428 | static void |
| 1429 | tentry_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 |
no test coverage detected