Which more than halves the length of the function call...
fr_dict_root(dict)->name,
oid_str,
da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"),
+ fr_type_to_str(da->type),
flags);
if (print_values) {
fr_dict_root(dict)->name,
oid_str,
da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"),
+ fr_type_to_str(da->type),
flags,
enumv->name,
enumv->value);
/*
* Parse data types
*/
- type = fr_table_value_by_longest_prefix(&match_len, fr_value_box_type_table, in, inlen, FR_TYPE_NULL);
+ type = fr_table_value_by_longest_prefix(&match_len, fr_type_table, in, inlen, FR_TYPE_NULL);
if (fr_type_is_null(type)) {
RETURN_PARSE_ERROR(0);
}
p += 2;
fr_skip_whitespace(p);
- type = fr_table_value_by_longest_prefix(&match_len, fr_value_box_type_table, p, end - p, FR_TYPE_MAX);
+ type = fr_table_value_by_longest_prefix(&match_len, fr_type_table, p, end - p, FR_TYPE_MAX);
if (type == FR_TYPE_MAX) RETURN_PARSE_ERROR(0);
fr_value_box_init(out, type, NULL, false);
}
FR_PROTO_TRACE("Parent %s len %zu", parent->name, attr_len);
FR_PROTO_HEX_DUMP(data, attr_len, __FUNCTION__ );
- FR_PROTO_TRACE("Type \"%s\" (%u)", fr_table_str_by_value(fr_value_box_type_table, parent->type, "?Unknown?"), parent->type);
+ FR_PROTO_TRACE("Type \"%s\" (%u)", fr_type_to_str(parent->type), parent->type);
/*
* Special cases, attributes that either have odd formats, or need
switch (da->type) {
case FR_TYPE_STRUCTURAL:
fr_strerror_printf("%s: Called with structural type %s", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da_stack->da[depth]->type, "?Unknown?"));
+ fr_type_to_str(da_stack->da[depth]->type));
return PAIR_ENCODE_FATAL_ERROR;
default:
switch (da_stack->da[depth]->type) {
case FR_TYPE_STRUCTURAL:
fr_strerror_printf("%s: Called with structural type %s", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da_stack->da[depth]->type, "?Unknown?"));
+ fr_type_to_str(da_stack->da[depth]->type));
return PAIR_ENCODE_FATAL_ERROR;
default:
if (da_stack->da[depth]->type != FR_TYPE_TLV) {
fr_strerror_printf("%s: Expected type \"tlv\" got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da_stack->da[depth]->type, "?Unknown?"));
+ fr_type_to_str(da_stack->da[depth]->type));
return PAIR_ENCODE_FATAL_ERROR;
}
/*
* Add "type" to newly created keys.
*/
- MEM(type_name = json_object_new_string(fr_table_str_by_value(fr_value_box_type_table,
- vp->vp_type, "<INVALID>")));
+ MEM(type_name = json_object_new_string(fr_type_to_str(vp->vp_type)));
json_object_object_add_ex(vp_object, "type", type_name, JSON_C_OBJECT_KEY_IS_CONSTANT);
/*
MEM(name = json_object_new_string(fr_sbuff_start(&attr_name)));
json_object_object_add_ex(attrobj, "name", name, JSON_C_OBJECT_KEY_IS_CONSTANT);
- MEM(type_name = json_object_new_string(fr_table_str_by_value(fr_value_box_type_table,
- vp->vp_type, "<INVALID>")));
+ MEM(type_name = json_object_new_string(fr_type_to_str(vp->vp_type)));
json_object_object_add_ex(attrobj, "type", type_name, JSON_C_OBJECT_KEY_IS_CONSTANT);
}
fr_assert(type < FR_TYPE_MAX);
cf_log_err(cp, "type '%s' (%i) is not supported in the configuration files",
- fr_table_str_by_value(fr_value_box_type_table, type, "?Unknown?"), type);
+ fr_type_to_str(type), type);
goto error;
}
if (uppercase) {
fr_type_t type;
- type = fr_table_value_by_str(fr_value_box_type_table, argv->name, FR_TYPE_NULL);
+ type = fr_table_value_by_str(fr_type_table, argv->name, FR_TYPE_NULL);
switch (type) {
case FR_TYPE_MAX:
case FR_TYPE_NULL:
if (fr_value_box_cast(box, box, tmpl_rules_cast(vpt), NULL, &vp->data) < 0) {
if (request) RPEDEBUG("Failed casting %pV to type %s", box,
- fr_table_str_by_value(fr_value_box_type_table,
- tmpl_rules_cast(vpt), "??"));
+ fr_type_to_str(tmpl_rules_cast(vpt)));
goto done;
}
break;
fr_value_box_init_null(box);
if (fr_value_box_cast(request, box, cast_type, da, &vp->data) < 0) {
if (request) RPEDEBUG("Failed casting %pV to type %s", &vp->data,
- fr_table_str_by_value(fr_value_box_type_table,
- tmpl_rules_cast(vpt), "??"));
+ fr_type_to_str(tmpl_rules_cast(vpt)));
return false;
}
case COND_TYPE_MAP:
if (tmpl_rules_cast(c->data.map->lhs)) {
FR_SBUFF_IN_SPRINTF_RETURN(&our_out, "<%s>",
- fr_table_str_by_value(fr_value_box_type_table,
- tmpl_rules_cast(c->data.map->lhs), "??"));
+ fr_type_to_str(tmpl_rules_cast(c->data.map->lhs)));
}
FR_SBUFF_RETURN(map_print, &our_out, c->data.map);
break;
fr_assert(tmpl_is_data(vpt));
fr_assert_msg(fr_type_is_null(tmpl_rules_cast(vpt)) || (tmpl_rules_cast(vpt) == tmpl_value_type(vpt)),
"Cast mismatch, target was %s, but output was %s",
- fr_table_str_by_value(fr_value_box_type_table, tmpl_rules_cast(vpt), "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, tmpl_value_type(vpt), "<INVALID>"));
+ fr_type_to_str(tmpl_rules_cast(vpt)),
+ fr_type_to_str(tmpl_value_type(vpt)));
(void) tmpl_cast_set(vpt, FR_TYPE_NULL);
return 0;
}
if (da_stack->da[depth]->type != FR_TYPE_UINT32) {
fr_strerror_printf("Bad index attribute: Index attribute \"%s\" should be a integer, "
"but is a %s", da_stack->da[depth]->name,
- fr_table_str_by_value(fr_value_box_type_table, da_stack->da[depth]->type, "?Unknown?"));
+ fr_type_to_str(da_stack->da[depth]->type));
goto error;
}
FR_FAULT_LOG("\t[%u] %s %s %s%s%s%s (%p) attr %u",
i,
fr_table_str_by_value(attr_table, ar->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, ar->da->type, "<INVALID>"),
+ fr_type_to_str(ar->da->type),
ar->da->name,
ar->num != NUM_ANY ? "[" : "",
ar->num != NUM_ANY ? fr_table_str_by_value(attr_num_table, ar->num, buffer) : "",
return;
case TMPL_TYPE_DATA:
- FR_FAULT_LOG("\ttype : %s", fr_table_str_by_value(fr_value_box_type_table,
- tmpl_value_type(vpt), "<INVALID>"));
+ FR_FAULT_LOG("\ttype : %s", fr_type_to_str(tmpl_value_type(vpt)));
FR_FAULT_LOG("\tlen : %zu", tmpl_value_length(vpt));
FR_FAULT_LOG("\tvalue : %pV", tmpl_value(vpt));
fr_strerror_printf("Parent type of nested attribute %s must be of type "
"\"struct\", \"tlv\", \"vendor\", \"vsa\" or \"group\", got \"%s\"",
da->name,
- fr_table_str_by_value(fr_value_box_type_table,
- da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
fr_sbuff_set(name, &m_s);
goto error;
}
if (fr_sbuff_next_if_char(&our_in, '<')) {
fr_sbuff_marker(&m, &our_in);
- fr_sbuff_out_by_longest_prefix(&slen, &cast, fr_value_box_type_table, &our_in, FR_TYPE_NULL);
+ fr_sbuff_out_by_longest_prefix(&slen, &cast, fr_type_table, &our_in, FR_TYPE_NULL);
if (fr_type_is_null(cast)) {
fr_strerror_const("Unknown data type");
FR_SBUFF_ERROR_RETURN(&our_in);
switch (dst_type) {
default:
fr_strerror_printf("Forbidden data type '%s' in cast",
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "??"));
+ fr_type_to_str(dst_type));
return -1;
/*
if (!fr_type_cast(dst_type, src_type)) {
fr_strerror_printf("Cannot cast type '%s' to '%s'",
- fr_table_str_by_value(fr_value_box_type_table, src_type, "??"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "??"));
+ fr_type_to_str(src_type),
+ fr_type_to_str(dst_type));
return -1;
}
break;
if (type != da->type) {
fr_strerror_printf("Attribute %s of type %s already defined with type %s",
- da->name, fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"),
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<UNKNOWN>"));
+ da->name, fr_type_to_str(type),
+ fr_type_to_str(da->type));
return -1;
}
fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_ATTR "
"attribute \"%s\" (%s) not rooted in a dictionary",
file, line, tmpl_da(vpt)->name,
- fr_table_str_by_value(fr_value_box_type_table, tmpl_da(vpt)->type, "<INVALID>"));
+ fr_type_to_str(tmpl_da(vpt)->type));
}
da = tmpl_da(vpt);
"and global dictionary pointer %p \"%s\" (%s) differ",
file, line,
tmpl_da(vpt), tmpl_da(vpt)->name,
- fr_table_str_by_value(fr_value_box_type_table, tmpl_da(vpt)->type, "<INVALID>"),
+ fr_type_to_str(tmpl_da(vpt)->type),
da, da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
}
if (tmpl_list(vpt) >= PAIR_LIST_UNKNOWN) {
/* nothing */
}
- cast = fr_table_value_by_substr(fr_value_box_type_table, p, q - p, FR_TYPE_NULL);
+ cast = fr_table_value_by_substr(fr_type_table, p, q - p, FR_TYPE_NULL);
if (fr_type_is_null(cast)) {
return_P("Unknown data type");
}
if (tmpl_cast_in_place(map->rhs, tmpl_da(map->lhs)->type, tmpl_da(map->lhs)) < 0) {
cf_log_err(map->ci, "Failed to parse data type %s from string: %pV",
- fr_table_str_by_value(fr_value_box_type_table, tmpl_da(map->lhs)->type, "<UNKNOWN>"),
+ fr_type_to_str(tmpl_da(map->lhs)->type),
fr_box_strvalue_len(map->rhs->name, map->rhs->len));
return false;
} /* else the cast was successful */
if (tmpl_rules_cast(c->data.map->lhs) != FR_TYPE_NULL) {
cf_log_err(map->ci, "Cannot cast virtual attribute %s to %s", map->lhs->name,
- fr_table_str_by_value(fr_value_box_type_table, c->data.map->lhs->type, "<INVALID>"));
+ fr_type_to_str(c->data.map->lhs->type));
return false;
}
default:
cf_log_err(map->ci, "Sublists can only be assigned to structural attributes, not to type %s",
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
return false;
}
*/
if (tmpl_cast_in_place(map->rhs, type, tmpl_da(map->lhs)) < 0) {
cf_log_perr(map->ci, "Cannot convert RHS value (%s) to LHS attribute type (%s)",
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_STRING, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, tmpl_da(map->lhs)->type, "<INVALID>"));
+ fr_type_to_str(FR_TYPE_STRING),
+ fr_type_to_str(tmpl_da(map->lhs)->type));
return -1;
}
*/
if (tmpl_cast_in_place(map->rhs, type, tmpl_da(map->lhs)) < 0) {
cf_log_perr(map->ci, "Cannot convert RHS value (%s) to LHS attribute type (%s)",
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_STRING, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, tmpl_da(map->lhs)->type, "<INVALID>"));
+ fr_type_to_str(FR_TYPE_STRING),
+ fr_type_to_str(tmpl_da(map->lhs)->type));
return -1;
}
} /* else we can't precompile the data */
htype = fr_htrie_hint(type);
if (htype == FR_HTRIE_INVALID) {
cf_log_err(cs, "Invalid data type '%s' used for 'switch' statement",
- fr_table_str_by_value(fr_value_box_type_table, type, "???"));
+ fr_type_to_str(type));
goto error;
}
default:
fr_strerror_printf("Cannot assign '%s' type to structural type '%s'",
- fr_table_str_by_value(fr_value_box_type_table, rhs_box->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, state->lhs.vp->vp_type, "<INVALID>"));
+ fr_type_to_str(rhs_box->type),
+ fr_type_to_str(state->lhs.vp->vp_type));
return -1;
}
RIDEBUG3("attr : %u", vp->da->attr);
vendor = fr_dict_vendor_by_da(vp->da);
if (vendor) RIDEBUG2("vendor : %i (%s)", vendor->pen, vendor->name);
- RIDEBUG3("type : %s", fr_table_str_by_value(fr_value_box_type_table, vp->vp_type, "<INVALID>"));
+ RIDEBUG3("type : %s", fr_type_to_str(vp->vp_type));
if (fr_box_is_variable_size(&vp->data)) {
RIDEBUG3("length : %zu", vp->vp_length);
if (!RDEBUG_ENABLED4) continue;
- for (i = 0; i < fr_value_box_type_table_len; i++) {
+ for (i = 0; i < fr_type_table_len; i++) {
int pad;
fr_value_box_t *dst = NULL;
- type = &fr_value_box_type_table[i];
+ type = &fr_type_table[i];
if ((fr_type_t) type->value == vp->vp_type) goto next_type;
default:
error:
RPEDEBUG("Failed converting %pV (%s) to an integer", in_vb,
- fr_table_str_by_value(fr_value_box_type_table, in_vb->type, "???"));
+ fr_type_to_str(in_vb->type));
talloc_free(in_vb);
return XLAT_ACTION_FAIL;
xlat_exp_set_type(node, XLAT_BOX);
xlat_exp_set_name_buffer_shallow(node,
talloc_strdup(node,
- fr_table_str_by_value(fr_value_box_type_table,
- type, "<INVALID>")));
+ fr_type_to_str(type)));
fr_value_box_init(&node->data, FR_TYPE_UINT8, attr_cast_base, false);
node->data.vb_uint8 = type;
fr_sbuff_skip_whitespace(&in);
- fr_sbuff_out_by_longest_prefix(&slen, &cast_type, fr_value_box_type_table, &in, FR_TYPE_VOID);
+ fr_sbuff_out_by_longest_prefix(&slen, &cast_type, fr_type_table, &in, FR_TYPE_VOID);
if (cast_type == FR_TYPE_VOID) {
fr_sbuff_set(&in, &marker);
goto check_more;
if (vb->type != FR_TYPE_OCTETS) {
RWDEBUG("Skipping value \"%pV\", expected value of type %s, got type %s",
vb,
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_OCTETS, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, vb->type, "<INVALID>"));
+ fr_type_to_str(FR_TYPE_OCTETS),
+ fr_type_to_str(vb->type));
continue;
}
static int invalid_type(fr_type_t type)
{
fr_strerror_printf("Cannot perform mathematical operations on data type %s",
- fr_table_str_by_value(fr_value_box_type_table, type, "<INVALID>"));
+ fr_type_to_str(type));
return -1;
}
} else if (rcode == ERR_UNDERFLOW) {
fr_strerror_printf("Value underflows '%s' when calculating result.",
- fr_table_str_by_value(fr_value_box_type_table, type, "<INVALID>"));
+ fr_type_to_str(type));
} else if (rcode == ERR_OVERFLOW) {
fr_strerror_printf("Value overflows '%s' when calculating result.",
- fr_table_str_by_value(fr_value_box_type_table, type, "<INVALID>"));
+ fr_type_to_str(type));
} else if (rcode == ERR_INVALID) {
fr_strerror_printf("Invalid assignment operator '%s' for result type '%s'.",
fr_tokens[op],
- fr_table_str_by_value(fr_value_box_type_table, type, "<INVALID>"));
+ fr_type_to_str(type));
}
return rcode;
switch (in->type) {
default:
fr_strerror_printf("Cannot operate on ipaddr and %s",
- fr_table_str_by_value(fr_value_box_type_table, in->type, "<INVALID>"));
+ fr_type_to_str(in->type));
return -1;
case FR_TYPE_IPV4_PREFIX:
default:
fr_strerror_printf("Invalid input data type '%s' for logical 'and'",
- fr_table_str_by_value(fr_value_box_type_table, a->type, "<INVALID>"));
+ fr_type_to_str(a->type));
return -1;
}
switch (in->type) {
default:
fr_strerror_printf("Cannot operate on ipv6addr and %s",
- fr_table_str_by_value(fr_value_box_type_table, in->type, "<INVALID>"));
+ fr_type_to_str(in->type));
return -1;
case FR_TYPE_IPV6_PREFIX:
case T_OP_LT:
if (hint != FR_TYPE_BOOL) {
fr_strerror_printf("Invalid destination type '%s' for comparison operator",
- fr_table_str_by_value(fr_value_box_type_table, hint, "<INVALID>"));
+ fr_type_to_str(hint));
goto done;
}
if (hint == FR_TYPE_NULL) {
fr_strerror_printf("Cannot compare incompatible types (%s)... %s (%s)...",
- fr_table_str_by_value(fr_value_box_type_table, a->type, "<INVALID>"),
+ fr_type_to_str(a->type),
fr_tokens[op],
- fr_table_str_by_value(fr_value_box_type_table, b->type, "<INVALID>"));
+ fr_type_to_str(b->type));
goto done;
}
func = calc_type[hint];
if (!func) {
fr_strerror_printf("Cannot perform any operations for destination type %s",
- fr_table_str_by_value(fr_value_box_type_table, hint, "<INVALID>"));
+ fr_type_to_str(hint));
rcode = -1;
break;
}
ext = fr_dict_attr_ext(da, FR_DICT_ATTR_EXT_REF);
if (unlikely(!ext)) {
fr_strerror_printf("%s (%s) contains no 'ref' extension", da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<UNKNOWN>"));
+ fr_type_to_str(da->type));
return -1;
}
ext->ref = ref;
ext = fr_dict_attr_ext(da, FR_DICT_ATTR_EXT_CHILDREN);
if (unlikely(!ext)) {
fr_strerror_printf("%s (%s) contains no 'children' extension", da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<UNKNOWN>"));
+ fr_type_to_str(da->type));
return -1;
}
ext->children = children;
ext = fr_dict_attr_ext(da, FR_DICT_ATTR_EXT_CHILDREN);
if (unlikely(!ext)) {
fr_strerror_printf("%s (%s) contains no 'children' extension", da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<UNKNOWN>"));
+ fr_type_to_str(da->type));
return NULL;
}
return ext->children;
if (fr_type_is_non_leaf(da->type) || fr_type_is_non_leaf(fixup->da->type) ||
dict_attr_children(da) || dict_attr_children(fixup->da)) {
fr_strerror_printf("Reference MUST be to a simple data type of type '%s' at %s[%d]",
- fr_table_str_by_value(fr_value_box_type_table, fixup->da->type, "<UNKNOWN>"),
+ fr_type_to_str(fixup->da->type),
fr_cwd_strip(fixup->common.filename), fixup->common.line);
return -1;
}
if (!copied) {
fr_strerror_printf("Reference copied no VALUEs from type type '%s' at %s[%d]",
- fr_table_str_by_value(fr_value_box_type_table, fixup->da->type, "<UNKNOWN>"),
+ fr_type_to_str(fixup->da->type),
fr_cwd_strip(fixup->common.filename), fixup->common.line);
return -1;
}
our_uctx->prefix,
da->name,
da->attr,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"),
+ fr_type_to_str(da->type),
our_uctx->flags);
dict_attr_ext_debug(our_uctx->prefix, da); /* Print all the extension debug info */
FR_FAULT_LOG("ATTRIBUTE\t%-40s\t%-20s\t%s\t%s",
our_uctx->prefix,
our_uctx->oid,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "???"),
+ fr_type_to_str(da->type),
our_uctx->flags);
return 0;
/*
* find the type of the attribute.
*/
- type = fr_table_value_by_str(fr_value_box_type_table, name, FR_TYPE_NULL);
+ type = fr_type_from_str(name);
if (fr_type_is_null(type)) {
fr_strerror_printf("Unknown data type '%s'", name);
return -1;
(strncmp(key, "int", 3) == 0)) {
fr_type_t subtype;
- subtype = fr_table_value_by_str(fr_value_box_type_table, key, FR_TYPE_NULL);
+ subtype = fr_type_from_str(key);
if (fr_type_is_null(subtype)) {
unknown_type:
fr_strerror_printf("Unknown or unsupported %s type '%s'",
- fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"),
+ fr_type_to_str(type),
key);
return -1;
}
precision = fr_table_value_by_str(fr_time_precision_table, key, -1);
if (precision < 0) {
fr_strerror_printf("Unknown %s precision '%s'",
- fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"),
+ fr_type_to_str(type),
key);
return -1;
}
if (type != FR_TYPE_GROUP) {
fr_strerror_printf("The 'ref' flag cannot be used for type '%s'",
- fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"));
+ fr_type_to_str(type));
return -1;
}
default:
fr_strerror_printf("ENUMs can only be a leaf type, not %s",
- fr_table_str_by_value(fr_value_box_type_table, type, "?Unknown?"));
+ fr_type_to_str(type));
break;
}
*/
if (!fr_type_is_leaf(da->type)) {
fr_strerror_printf_push("Cannot define VALUE for attribute '%s' of data type '%s'", da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
return -1;
}
fr_strerror_printf_push("Invalid VALUE '%s' for attribute '%s' of data type '%s'",
argv[2],
da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
return -1;
}
if (da->type != FR_TYPE_TLV) {
fr_strerror_printf_push("Attribute '%s' should be a 'tlv', but is a '%s'",
argv[1],
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
goto error;
}
if (da->type != FR_TYPE_VSA) {
fr_strerror_printf_push("Invalid parent for BEGIN-VENDOR. "
"Attribute '%s' should be 'vsa' but is '%s'", p,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
goto error;
}
* fr_dict_attr_add(), because we know what we're doing, and
* that function does too many checks.
*/
- for (i = 0; i < fr_value_box_type_table_len; i++) {
+ for (i = 0; i < fr_type_table_len; i++) {
fr_dict_attr_t *n;
- fr_table_num_ordered_t const *p = &fr_value_box_type_table[i];
+ fr_table_num_ordered_t const *p = &fr_type_table[i];
switch (p->value) {
case FR_TYPE_NULL: /* Can't cast to NULL */
default:
fr_strerror_printf("Unknown vendors can only be parented by a vsa, not a %s",
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "?Unknown?"));
+ fr_type_to_str(parent->type));
return NULL;
}
}
fr_strerror_printf("%s: Cannot allocate unknown tlv attribute (%u) with parent type %s",
__FUNCTION__,
num,
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "<INVALID>"));
+ fr_type_to_str(parent->type));
return NULL;
}
fr_strerror_printf("%s: Cannot allocate unknown octets attribute (%u) with parent type %s",
__FUNCTION__,
num,
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "<INVALID>"));
+ fr_type_to_str(parent->type));
return NULL;
}
default:
fr_strerror_printf("Parent OID component (%s) specified a non-structural type (%s)",
our_parent->name,
- fr_table_str_by_value(fr_value_box_type_table,
- our_parent->type, "<INVALID>"));
+ fr_type_to_str(our_parent->type));
goto error;
}
} else {
*/
if (fr_sbuff_is_char(in, '.')) {
fr_strerror_printf("Interior OID component cannot proceed a %s type",
- fr_table_str_by_value(fr_value_box_type_table,
- our_parent->type, "<INVALID>"));
+ fr_type_to_str(our_parent->type));
goto error;
}
flags.is_raw = is_raw;
if (!dict_attr_can_have_children(parent)) {
fr_strerror_printf("Cannot add children to attribute '%s' of type %s",
parent->name,
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "?Unknown?"));
+ fr_type_to_str(parent->type));
return -1;
}
if ((parent->type == FR_TYPE_VSA) && (child->type != FR_TYPE_VENDOR)) {
fr_strerror_printf("Cannot add non-vendor children to attribute '%s' of type %s",
parent->name,
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "?Unknown?"));
+ fr_type_to_str(parent->type));
return -1;
}
((parent->type == FR_TYPE_VSA) || parent->flags.is_root)) {
fr_strerror_printf("Cannot insert attribute '%s' of type %s into %s",
da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"),
+ fr_type_to_str(da->type),
parent->name);
goto error;
}
fr_strerror_printf_push("Cannot add duplicate attribute with different type "
"(old attribute \"%s\" has type %s, new attribute \"%s\" has type %s)",
old->name,
- fr_table_str_by_value(fr_value_box_type_table, old->type, "?Unknown?"),
+ fr_type_to_str(old->type),
n->name,
- fr_table_str_by_value(fr_value_box_type_table, n->type, "?Unknown?"));
+ fr_type_to_str(n->type));
return -1;
}
ext = fr_dict_attr_ext(da, FR_DICT_ATTR_EXT_ENUMV);
if (!ext) {
fr_strerror_printf("VALUE cannot be defined for %s attributes",
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
return -1;
}
if (!coerce) {
fr_strerror_printf("%s: Type mismatch between attribute (%s) and enum (%s)",
__FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, value->type, "<INVALID>"));
+ fr_type_to_str(da->type),
+ fr_type_to_str(value->type));
return -1;
}
if (fr_value_box_cast(enumv, enum_value, da->type, NULL, value) < 0) {
fr_strerror_printf_push("%s: Failed coercing enum type (%s) to attribute type (%s)",
__FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, value->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(value->type),
+ fr_type_to_str(da->type));
return -1;
}
default:
fr_strerror_printf("Attribute is wrong type for auto-numbering, expected numeric type, got %s",
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
return -1;
}
fr_strerror_printf("Attribute '%s' is type %s and cannot contain child attributes. "
"Error at OID \"%.*s\"",
parent->name,
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "<UNKNOWN>"),
+ fr_type_to_str(parent->type),
(int)fr_sbuff_remaining(in),
fr_sbuff_current(in));
if (err) *err =FR_DICT_ATTR_NO_CHILDREN;
default:
fr_strerror_printf("Wrong type for vendor root, expected '%s', got '%s'",
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_VSA, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, vendor_root->type, "<INVALID>"));
+ fr_type_to_str(FR_TYPE_VSA),
+ fr_type_to_str(vendor_root->type));
return NULL;
}
if (vendor->type != FR_TYPE_VENDOR) {
fr_strerror_printf("Wrong type for vendor, expected '%s' got '%s'",
- fr_table_str_by_value(fr_value_box_type_table, vendor->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_VENDOR, "<INVALID>"));
+ fr_type_to_str(vendor->type),
+ fr_type_to_str(FR_TYPE_VENDOR));
return NULL;
}
ext = fr_dict_attr_ext(da, FR_DICT_ATTR_EXT_ENUMV);
if (!ext) {
fr_strerror_printf("VALUE cannot be defined for %s attributes",
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
return NULL;
}
ext = fr_dict_attr_ext(da, FR_DICT_ATTR_EXT_ENUMV);
if (!ext) {
fr_strerror_printf("VALUE cannot be defined for %s attributes",
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
return NULL;
}
if (da->type != p->type) {
fr_strerror_printf("Attribute '%s' should be type %s, but defined as type %s", da->name,
- fr_table_str_by_value(fr_value_box_type_table, p->type, "?Unknown?"),
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(p->type),
+ fr_type_to_str(da->type));
return -1;
}
fr_assert_msg(fr_dict_attr_has_ext(da, FR_DICT_ATTR_EXT_CHILDREN),
"CONSISTENCY CHECK FAILED %s[%u]: %s missing 'children' extension",
file, line,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
fr_assert_msg(fr_dict_attr_has_ext(da, FR_DICT_ATTR_EXT_NAMESPACE),
"CONSISTENCY CHECK FAILED %s[%u]: %s missing 'namespace' extension",
file, line,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
/*
* Check the namespace hash table is ok
switch (type) {
default:
fr_strerror_printf("The 'array' flag cannot be used with attributes of type '%s'",
- fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"));
+ fr_type_to_str(type));
return false;
case FR_TYPE_IPV4_ADDR:
default:
fr_strerror_printf("Type %s cannot hold extra flags",
- fr_table_str_by_value(fr_value_box_type_table, type, "?Unknown?"));
+ fr_type_to_str(type));
return false;
}
if ((flags->subtype == FLAG_LENGTH_UINT16) &&
((type != FR_TYPE_STRING) && (type != FR_TYPE_OCTETS) && (type != FR_TYPE_STRUCT))) {
fr_strerror_printf("The 'length' flag cannot be used used with type %s",
- fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"));
+ fr_type_to_str(type));
return false;
}
if ((flags->length != 2) && (flags->length != 4) && (flags->length != 8)) {
fr_strerror_printf("Invalid length %u for attribute of type '%s'",
- flags->length, fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"));
+ flags->length, fr_type_to_str(type));
return false;
}
(flags->flag_time_res != FR_TIME_RES_USEC) &&
(flags->flag_time_res != FR_TIME_RES_NSEC)) {
fr_strerror_printf("Invalid precision for attribute of type '%s'",
- fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"));
+ fr_type_to_str(type));
return false;
}
break;
if (parent->type != FR_TYPE_VSA) {
fr_strerror_printf("Attributes of type 'vendor' MUST have a parent of type 'vsa' "
"instead of '%s'",
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "?Unknown?"));
+ fr_type_to_str(parent->type));
return false;
}
*/
if (!v) {
fr_strerror_printf("Attributes of type '%s' require a parent attribute",
- fr_table_str_by_value(fr_value_box_type_table, type, "?Unknown?"));
+ fr_type_to_str(type));
return false;
}
case FR_TYPE_NULL:
fr_strerror_printf("Attributes of type '%s' cannot be used in dictionaries",
- fr_table_str_by_value(fr_value_box_type_table, type, "?Unknown?"));
+ fr_type_to_str(type));
return false;
default:
(flags->flag_time_res != FR_TIME_RES_MSEC) &&
(flags->flag_time_res != FR_TIME_RES_NSEC)) {
fr_strerror_printf("Invalid precision for attribute of type '%s'",
- fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"));
+ fr_type_to_str(type));
return false;
}
} else if (!flags->extra) {
default:
fr_strerror_printf("Attributes of type '%s' cannot have child attributes",
- fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"));
+ fr_type_to_str(type));
return false;
}
if (!fr_type_is_structural(dst->vp_type)) {
fr_strerror_printf("Cannot perform list assignment to non-structural type '%s'",
- fr_table_str_by_value(fr_value_box_type_table, dst->vp_type, "<INVALID>"));
+ fr_type_to_str(dst->vp_type));
return -1;
}
fr_strerror_printf("Invalid assignment operator %s for destination type %s",
fr_tokens[op],
- fr_table_str_by_value(fr_value_box_type_table, dst->vp_type, "<INVALID>"));
+ fr_type_to_str(dst->vp_type));
return -1;
}
default:
fr_strerror_printf("Pooled fr_pair_t can only be allocated for "
"'string' and 'octets' types not '%s'",
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
return NULL;
}
switch (vp->da->type) {
case FR_TYPE_STRUCTURAL:
fr_strerror_printf("Attributes of type '%s' are not yet supported",
- fr_table_str_by_value(fr_value_box_type_table, vp->da->type, "<INVALID>"));
+ fr_type_to_str(vp->da->type));
return -1;
default:
"dictionary pointer %p \"%s\" (%s) "
"and global dictionary pointer %p \"%s\" (%s) differ",
file, line, vp->da, vp->da->name,
- fr_table_str_by_value(fr_value_box_type_table, vp->da->type, "<INVALID>"),
+ fr_type_to_str(vp->da->type),
da, da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ fr_type_to_str(da->type));
}
}
fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: fr_pair_t (raw/unknown) attribute %p \"%s\" "
"data type incorrect. Expected %s, got %s",
file, line, vp->da, vp->da->name,
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_OCTETS, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, vp->data.type, "<INVALID>"));
+ fr_type_to_str(FR_TYPE_OCTETS),
+ fr_type_to_str(vp->data.type));
}
} else if (!fr_type_is_structural(vp->da->type) && (vp->da->type != vp->data.type)) {
char data_type_int[10], da_type_int[10];
fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: fr_pair_t attribute %p \"%s\" "
"data type (%s) does not match da type (%s)",
file, line, vp->da, vp->da->name,
- fr_table_str_by_value(fr_value_box_type_table, vp->data.type, data_type_int),
- fr_table_str_by_value(fr_value_box_type_table, vp->da->type, da_type_int));
+ fr_table_str_by_value(fr_type_table, vp->data.type, data_type_int),
+ fr_table_str_by_value(fr_type_table, vp->da->type, da_type_int));
}
}
fr_log(&default_log, L_DBG, file, line,
"stk: %s [%i] %s: %s, vendor: 0x%x (%u), attr: 0x%x (%u)",
(i == (int)depth) ? ">" : " ", i,
- fr_table_str_by_value(fr_value_box_type_table, da_stack->da[i]->type, "?Unknown?"),
+ fr_type_to_str(da_stack->da[i]->type),
da_stack->da[i]->name,
fr_dict_vendor_num_by_da(da_stack->da[i]), fr_dict_vendor_num_by_da(da_stack->da[i]),
da_stack->da[i]->attr, da_stack->da[i]->attr);
if (parent->type != FR_TYPE_STRUCT) {
fr_strerror_printf("%s: Expected type \"struct\" got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "?Unknown?"));
+ fr_type_to_str(parent->type));
return -1;
}
#include <freeradius-devel/util/types.h>
#include <freeradius-devel/util/value.h>
+/** Map data types to names representing those types
+ */
+fr_table_num_ordered_t const fr_type_table[] = {
+ { L("null"), FR_TYPE_NULL },
+ { L("string"), FR_TYPE_STRING },
+ { L("octets"), FR_TYPE_OCTETS },
+
+ { L("ipaddr"), FR_TYPE_IPV4_ADDR },
+ { L("ipv4addr"), FR_TYPE_IPV4_ADDR },
+ { L("ipv4prefix"), FR_TYPE_IPV4_PREFIX },
+ { L("ipv6addr"), FR_TYPE_IPV6_ADDR },
+ { L("ipv6prefix"), FR_TYPE_IPV6_PREFIX },
+ { L("ifid"), FR_TYPE_IFID },
+ { L("combo-ip"), FR_TYPE_COMBO_IP_ADDR },
+ { L("combo-prefix"), FR_TYPE_COMBO_IP_PREFIX },
+ { L("ether"), FR_TYPE_ETHERNET },
+
+ { L("bool"), FR_TYPE_BOOL },
+
+ { L("uint8"), FR_TYPE_UINT8 },
+ { L("uint16"), FR_TYPE_UINT16 },
+ { L("uint32"), FR_TYPE_UINT32 },
+ { L("uint64"), FR_TYPE_UINT64 },
+
+ { L("int8"), FR_TYPE_INT8 },
+ { L("int16"), FR_TYPE_INT16 },
+ { L("int32"), FR_TYPE_INT32 },
+ { L("int64"), FR_TYPE_INT64 },
+
+ { L("float32"), FR_TYPE_FLOAT32 },
+ { L("float64"), FR_TYPE_FLOAT64 },
+
+ { L("date"), FR_TYPE_DATE },
+ { L("time_delta"), FR_TYPE_TIME_DELTA },
+
+ { L("size"), FR_TYPE_SIZE },
+
+ { L("tlv"), FR_TYPE_TLV },
+ { L("struct"), FR_TYPE_STRUCT },
+
+ { L("vsa"), FR_TYPE_VSA },
+ { L("vendor"), FR_TYPE_VENDOR },
+ { L("group"), FR_TYPE_GROUP },
+
+ /*
+ * Alternative names
+ */
+ { L("cidr"), FR_TYPE_IPV4_PREFIX },
+ { L("byte"), FR_TYPE_UINT8 },
+ { L("short"), FR_TYPE_UINT16 },
+ { L("integer"), FR_TYPE_UINT32 },
+ { L("integer64"), FR_TYPE_UINT64 },
+ { L("decimal"), FR_TYPE_FLOAT64 },
+ { L("signed"), FR_TYPE_INT32 }
+};
+size_t fr_type_table_len = NUM_ELEMENTS(fr_type_table);
+
#define ARRAY_BEG(_type) { [_type] = true,
#define ARRAY_MID(_type) [_type] = true,
#define ARRAY_END(_type) [_type] = true }
*/
if (unlikely(type_promote_table[a][b] != type_promote_table[b][a])) {
fr_strerror_printf("Inverse type mapping inconsistent for a = %s, b = %s",
- fr_table_str_by_value(fr_value_box_type_table, a, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, b, "<INVALID>"));
+ fr_type_to_str(a),
+ fr_type_to_str(b));
return FR_TYPE_NULL;
}
if (unlikely(type_promote_table[a][b] == FR_TYPE_NULL)) {
fr_strerror_printf("No type promotions for a = %s, b = %s",
- fr_table_str_by_value(fr_value_box_type_table, a, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, b, "<INVALID>"));
+ fr_type_to_str(a),
+ fr_type_to_str(b));
return FR_TYPE_NULL;
}
#endif
#include <stdbool.h>
+#include <freeradius-devel/util/table.h>
/** Internal data types
*/
#define fr_type_is_non_leaf(_x) (fr_type_non_leaf[_x])
/** @} */
+extern fr_table_num_ordered_t const fr_type_table[];
+extern size_t fr_type_table_len;
+
+/** Return a static string containing the type name
+ *
+ * @param[in] type to return name for.
+ * @return name of the type
+ */
+static inline char const *fr_type_to_str(fr_type_t type)
+{
+ return fr_table_str_by_value(fr_type_table, type, "<INVALID>");
+}
+
+/** Return the constant value representing a type
+ *
+ * @param[in] type to return the constant value for.
+ * @return The constant type value or FR_TYPE_NULL if no type matches.
+ */
+static inline fr_type_t fr_type_from_str(char const *type)
+{
+ return fr_table_value_by_str(fr_type_table, type, FR_TYPE_NULL);
+}
+
bool fr_type_cast(fr_type_t dst, fr_type_t src);
fr_type_t fr_type_promote(fr_type_t a, fr_type_t b);
static_assert(SIZEOF_MEMBER(fr_value_box_t, vb_float64) == 8,
"vb_float64 has unexpected length");
-
-/** Map data types to names representing those types
- */
-fr_table_num_ordered_t const fr_value_box_type_table[] = {
- { L("null"), FR_TYPE_NULL },
- { L("string"), FR_TYPE_STRING },
- { L("octets"), FR_TYPE_OCTETS },
-
- { L("ipaddr"), FR_TYPE_IPV4_ADDR },
- { L("ipv4addr"), FR_TYPE_IPV4_ADDR },
- { L("ipv4prefix"), FR_TYPE_IPV4_PREFIX },
- { L("ipv6addr"), FR_TYPE_IPV6_ADDR },
- { L("ipv6prefix"), FR_TYPE_IPV6_PREFIX },
- { L("ifid"), FR_TYPE_IFID },
- { L("combo-ip"), FR_TYPE_COMBO_IP_ADDR },
- { L("combo-prefix"), FR_TYPE_COMBO_IP_PREFIX },
- { L("ether"), FR_TYPE_ETHERNET },
-
- { L("bool"), FR_TYPE_BOOL },
-
- { L("uint8"), FR_TYPE_UINT8 },
- { L("uint16"), FR_TYPE_UINT16 },
- { L("uint32"), FR_TYPE_UINT32 },
- { L("uint64"), FR_TYPE_UINT64 },
-
- { L("int8"), FR_TYPE_INT8 },
- { L("int16"), FR_TYPE_INT16 },
- { L("int32"), FR_TYPE_INT32 },
- { L("int64"), FR_TYPE_INT64 },
-
- { L("float32"), FR_TYPE_FLOAT32 },
- { L("float64"), FR_TYPE_FLOAT64 },
-
- { L("date"), FR_TYPE_DATE },
- { L("time_delta"), FR_TYPE_TIME_DELTA },
-
- { L("size"), FR_TYPE_SIZE },
-
- { L("tlv"), FR_TYPE_TLV },
- { L("struct"), FR_TYPE_STRUCT },
-
- { L("vsa"), FR_TYPE_VSA },
- { L("vendor"), FR_TYPE_VENDOR },
- { L("group"), FR_TYPE_GROUP },
-
- /*
- * Alternative names
- */
- { L("cidr"), FR_TYPE_IPV4_PREFIX },
- { L("byte"), FR_TYPE_UINT8 },
- { L("short"), FR_TYPE_UINT16 },
- { L("integer"), FR_TYPE_UINT32 },
- { L("integer64"), FR_TYPE_UINT64 },
- { L("decimal"), FR_TYPE_FLOAT64 },
- { L("signed"), FR_TYPE_INT32 }
-};
-size_t fr_value_box_type_table_len = NUM_ELEMENTS(fr_value_box_type_table);
-
/** How many bytes on-the-wire would a #fr_value_box_t value consume
*
* This is for the generic NETWORK format. For field sizes in the in-memory
unsupported:
fr_strerror_printf("%s: Cannot encode type \"%s\"",
__FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, value->type, "<INVALID>"));
+ fr_type_to_str(value->type));
return FR_VALUE_BOX_NET_ERROR;
}
if (len < min) {
fr_strerror_printf("Got truncated value parsing type \"%s\". "
"Expected length >= %zu bytes, got %zu bytes",
- fr_table_str_by_value(fr_value_box_type_table, type, "<INVALID>"),
+ fr_type_to_str(type),
min, len);
return -(len);
}
if (len > max) {
fr_strerror_printf("Found trailing garbage parsing type \"%s\". "
"Expected length <= %zu bytes, got %zu bytes",
- fr_table_str_by_value(fr_value_box_type_table, type, "<INVALID>"),
+ fr_type_to_str(type),
max, len);
return -(max);
}
case FR_TYPE_SIZE:
case FR_TYPE_NON_LEAF:
fr_strerror_printf("Cannot decode type \"%s\" - Is not a value",
- fr_table_str_by_value(fr_value_box_type_table, type, "<INVALID>"));
+ fr_type_to_str(type));
break;
}
default:
fr_strerror_printf("Invalid data type '%s' for getting key",
- fr_table_str_by_value(fr_value_box_type_table, value->type, "<INVALID>"));
+ fr_type_to_str(value->type));
return -1;
}
if (src->vb_length < network_min_size(dst_type)) {
fr_strerror_printf("Invalid cast from %s to %s. Source is length %zd is smaller than "
"destination type size %zd",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
src->vb_length,
network_min_size(dst_type));
return -1;
if (src->vb_length > network_max_size(dst_type)) {
fr_strerror_printf("Invalid cast from %s to %s. Source length %zd is greater than "
"destination type size %zd",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
src->vb_length,
network_max_size(dst_type));
return -1;
if (memcmp(src->vb_ip.addr.v6.s6_addr, v4_v6_map, sizeof(v4_v6_map)) != 0) {
bad_v6_prefix_map:
fr_strerror_printf("Invalid cast from %s to %s. No IPv4-IPv6 mapping prefix",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
if (src->vb_ip.prefix != 32) {
fr_strerror_printf("Invalid cast from %s to %s. Only /32 (not %i/) prefixes may be "
"cast to IP address types",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
src->vb_ip.prefix);
return -1;
}
if (src->vb_ip.prefix != 128) {
fr_strerror_printf("Invalid cast from %s to %s. Only /128 (not /%i) prefixes may be "
"cast to IP address types",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
src->vb_ip.prefix);
return -1;
}
case FR_TYPE_OCTETS:
if (src->vb_length != sizeof(dst->vb_ip.addr.v4.s_addr)) {
fr_strerror_printf("Invalid cast from %s to %s. Needed octet string of length %zu, got %zu",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
sizeof(dst->vb_ip.addr.v4.s_addr), src->vb_length);
return -1;
}
default:
fr_strerror_printf("Invalid cast from %s to %s. Unsupported",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
if (memcmp(src->vb_ip.addr.v6.s6_addr, v4_v6_map, sizeof(v4_v6_map)) != 0) {
bad_v6_prefix_map:
fr_strerror_printf("Invalid cast from %s to %s. No IPv4-IPv6 mapping prefix",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
memcpy(&dst->vb_ip.addr.v4.s_addr, &src->vb_ip.addr.v6.s6_addr[sizeof(v4_v6_map)],
if (src->vb_ip.prefix < (sizeof(v4_v6_map) << 3)) {
fr_strerror_printf("Invalid cast from %s to %s. Expected prefix >= %u bits got %u bits",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
(unsigned int)(sizeof(v4_v6_map) << 3), src->vb_ip.prefix);
return -1;
}
case FR_TYPE_OCTETS:
if (src->vb_length != sizeof(dst->vb_ip.addr.v4.s_addr) + 1) {
fr_strerror_printf("Invalid cast from %s to %s. Needed octet string of length %zu, got %zu",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
sizeof(dst->vb_ip.addr.v4.s_addr) + 1, src->vb_length);
return -1;
}
default:
fr_strerror_printf("Invalid cast from %s to %s. Unsupported",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
if (src->vb_ip.prefix != 32) {
fr_strerror_printf("Invalid cast from %s to %s. Only /32 (not /%i) prefixes may be "
"cast to IP address types",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
src->vb_ip.prefix);
return -1;
}
if (src->vb_ip.prefix != 128) {
fr_strerror_printf("Invalid cast from %s to %s. Only /128 (not /%i) prefixes may be "
"cast to IP address types",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
src->vb_ip.prefix);
return -1;
}
case FR_TYPE_OCTETS:
if (src->vb_length != sizeof(dst->vb_ip.addr.v6.s6_addr)) {
fr_strerror_printf("Invalid cast from %s to %s. Needed octet string of length %zu, got %zu",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
sizeof(dst->vb_ip.addr.v6.s6_addr), src->vb_length);
return -1;
}
default:
fr_strerror_printf("Invalid cast from %s to %s. Unsupported",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
break;
}
case FR_TYPE_OCTETS:
if (src->vb_length != (sizeof(dst->vb_ip.addr.v6.s6_addr) + 2)) {
fr_strerror_printf("Invalid cast from %s to %s. Needed octet string of length %zu, got %zu",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
sizeof(dst->vb_ip.addr.v6.s6_addr) + 2, src->vb_length);
return -1;
}
default:
fr_strerror_printf("Invalid cast from %s to %s. Unsupported",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
return 0;
default:
fr_strerror_printf("Invalid cast from %s to %s. Unsupported",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
default:
fr_strerror_printf("Invalid cast from %s to %s. Unsupported",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
*/
if (!fr_cond_assert_msg(len > 0, "Invalid cast from %s to %s. "
"invalid source type len, expected > 0, got %zu",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
len)) return -1;
if (!fr_cond_assert_msg(len <= sizeof(uint64_t),
"Invalid cast from %s to %s. "
"invalid source type len, expected <= %zu, got %zu",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
sizeof(uint64_t), len)) return -1;
#endif
if ((int64_t)tmp < min) {
fr_strerror_printf("Invalid cast from %s to %s. %"PRId64" "
"outside value range %"PRId64"-%"PRIu64,
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
(int64_t)tmp,
min, fr_value_box_integer_max[dst_type]);
return -1;
} else if (tmp > fr_value_box_integer_max[dst_type]) {
fr_strerror_printf("Invalid cast from %s to %s. %"PRIu64" "
"outside value range 0-%"PRIu64,
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
tmp, fr_value_box_integer_max[dst_type]);
return -1;
}
bad_cast:
fr_strerror_printf("Invalid cast from %s to %s. Unsupported",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
bad_cast:
fr_strerror_printf("Invalid cast from %s to %s. Unsupported",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
if (fr_type_is_non_leaf(dst_type)) {
fr_strerror_printf("Invalid cast from %s to %s. Can only cast simple data types",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
case FR_TYPE_VOID:
case FR_TYPE_MAX:
fr_strerror_printf("Invalid cast from %s to %s. Invalid destination type",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type));
return -1;
}
if (src->vb_length < network_min_size(dst_type)) {
fr_strerror_printf("Invalid cast from %s to %s. Source is length %zd is smaller than "
"destination type size %zd",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
src->vb_length,
network_min_size(dst_type));
return -1;
if (src->vb_length > network_max_size(dst_type)) {
fr_strerror_printf("Invalid cast from %s to %s. Source length %zd is greater than "
"destination type size %zd",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"),
+ fr_type_to_str(src->type),
+ fr_type_to_str(dst_type),
src->vb_length,
network_max_size(dst_type));
return -1;
{
if (!fr_type_is_ip(src->type)) {
fr_strerror_printf("Unboxing failed. Needed IPv4/6 addr/prefix, had type %s",
- fr_table_str_by_value(fr_value_box_type_table, src->type, "?Unknown?"));
+ fr_type_to_str(src->type));
return -1;
}
if (dst->type != FR_TYPE_STRING) {
fr_strerror_printf("%s: Expected boxed value of type %s, got type %s", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_STRING, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst->type, "<INVALID>"));
+ fr_type_to_str(FR_TYPE_STRING),
+ fr_type_to_str(dst->type));
return -1;
}
if (dst->type != FR_TYPE_OCTETS) {
fr_strerror_printf("%s: Expected boxed value of type %s, got type %s", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_OCTETS, "<INVALID>"),
- fr_table_str_by_value(fr_value_box_type_table, dst->type, "<INVALID>"));
+ fr_type_to_str(FR_TYPE_OCTETS),
+ fr_type_to_str(dst->type));
return -1;
}
if (err == FR_SBUFF_PARSE_ERROR_NOT_FOUND) {
fr_strerror_printf("Failed parsing string as type '%s'",
- fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_type_to_str(dst_type));
} else {
fr_sbuff_parse_error_to_strerror(err);
}
break;
default:
- fr_strerror_printf("Cannot parse input as data type %s", fr_table_str_by_value(fr_value_box_type_table, dst_type, "<INVALID>"));
+ fr_strerror_printf("Cannot parse input as data type %s", fr_type_to_str(dst_type));
return -1;
}
default:
fr_strerror_printf("Invalid argument. Can't concatenate boxes to type %s",
- fr_table_str_by_value(fr_value_box_type_table, type, "<INVALID>"));
+ fr_type_to_str(type));
return -1;
}
# define _CONST
#endif
-extern fr_table_num_ordered_t const fr_value_box_type_table[];
-extern size_t fr_value_box_type_table_len;
-
extern size_t const fr_value_box_field_sizes[];
extern size_t const fr_value_box_offsets[];
{
if (unlikely(src->type != FR_TYPE_ETHERNET)) { \
fr_strerror_printf("Unboxing failed. Needed type %s, had type %s",
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_ETHERNET, "?Unknown?"),
- fr_table_str_by_value(fr_value_box_type_table, src->type, "?Unknown?"));
+ fr_type_to_str(FR_TYPE_ETHERNET),
+ fr_type_to_str(src->type));
return -1; \
}
memcpy(dst, src->vb_ether, sizeof(src->vb_ether)); /* Must be src, dst is a pointer */
static inline int fr_value_unbox_##_field(_ctype *var, fr_value_box_t const *src) { \
if (unlikely(src->type != _type)) { \
fr_strerror_printf("Unboxing failed. Needed type %s, had type %s", \
- fr_table_str_by_value(fr_value_box_type_table, _type, "?Unknown?"), \
- fr_table_str_by_value(fr_value_box_type_table, src->type, "?Unknown?")); \
+ fr_type_to_str(_type), \
+ fr_type_to_str(src->type)); \
return -1; \
} \
*var = src->vb_##_field; \
if (in_head->type != FR_TYPE_OCTETS) {
REDEBUG("Signature argument wrong type, expected %s, got %s. "
"Use %%{base64_decode:<text>} or %%{hex_decode:<text>} if signature is armoured",
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_OCTETS, "?Unknown?"),
- fr_table_str_by_value(fr_value_box_type_table, in_head->type, "?Unknown?"));
+ fr_type_to_str(FR_TYPE_OCTETS),
+ fr_type_to_str(in_head->type));
return XLAT_ACTION_FAIL;
}
sig = in_head->vb_octets;
default:
cf_log_err(conf, "Invalid key data type '%s'",
- fr_table_str_by_value(fr_value_box_type_table, inst->key_data_type, "<INVALID>"));
+ fr_type_to_str(inst->key_data_type));
return -1;
}
} else {
htype = fr_htrie_hint(inst->key_data_type);
if (htype == FR_HTRIE_INVALID) {
cf_log_err(conf, "Invalid data type '%s' used for CSV file.",
- fr_table_str_by_value(fr_value_box_type_table, inst->key_data_type, "???"));
+ fr_type_to_str(inst->key_data_type));
return -1;
}
return date_convert_string(ctx, out, request, arg->vb_strvalue, inst);
default:
- REDEBUG("Can't convert type %s into date", fr_table_str_by_value(fr_value_box_type_table, arg->type, "<INVALID>"));
+ REDEBUG("Can't convert type %s into date", fr_type_to_str(arg->type));
}
return XLAT_ACTION_FAIL;
case FR_TYPE_STRUCTURAL:
REDEBUG("Cannot convert %s of type '%s' to integer",
- vp->da->name, fr_table_str_by_value(fr_value_box_type_table, vp->vp_type, "?Unknown?"));
+ vp->da->name, fr_type_to_str(vp->vp_type));
goto error;
default:
inst->key_data_type = tmpl_expanded_type(inst->key);
if (fr_htrie_hint(inst->key_data_type) == FR_HTRIE_INVALID) {
cf_log_err(mctx->inst->conf, "Invalid data type '%s' for 'files' module.",
- fr_table_str_by_value(fr_value_box_type_table, inst->key_data_type, "???"));
+ fr_type_to_str(inst->key_data_type));
return -1;
}
semicolon = MAYBE_SEMICOLON;
}
- type = fr_table_value_by_str(fr_value_box_type_table, type_name, FR_TYPE_NULL);
+ type = fr_type_from_str(type_name);
if (type == FR_TYPE_NULL) {
fr_strerror_printf("unknown data type '%.*s'",
(int) (next - cmd), cmd);
slen = fr_pair_print_value_quoted(&FR_SBUFF_OUT(buff, sizeof(buff)), vp, T_BARE_WORD);
if (slen < 0) {
REDEBUG("Cannot convert %s to Lua type, insufficient buffer space",
- fr_table_str_by_value(fr_value_box_type_table, vp->vp_type, "<INVALID>"));
+ fr_type_to_str(vp->vp_type));
return -1;
}
break;
case FR_TYPE_NON_LEAF:
- REDEBUG("Cannot convert %s to Lua type", fr_table_str_by_value(fr_value_box_type_table, vp->vp_type, "<INVALID>"));
+ REDEBUG("Cannot convert %s to Lua type", fr_type_to_str(vp->vp_type));
return -1;
}
return 0;
fr_assert(vps);
RINDENT();
- RDEBUG3("Type : %s", fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"));
+ RDEBUG3("Type : %s", fr_type_to_str(da->type));
q = strchr(p, '&');
len = (!q) ? (rawlen - (p - raw)) : (unsigned)(q - p);
return XLAT_ACTION_FAIL;
}
- type = fr_table_value_by_str(fr_value_box_type_table, type_vb->vb_strvalue, FR_TYPE_NULL);
+ type = fr_type_from_str(type_vb->vb_strvalue);
if (fr_type_is_null(type)) {
REDEBUG("Invalid data type '%s'", type_vb->vb_strvalue);
return XLAT_ACTION_FAIL;
child = unknown; /* const issues */
FR_PROTO_TRACE("decode context changed %s:%s -> %s:%s",
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "<invalid>"), parent->name,
- fr_table_str_by_value(fr_value_box_type_table, child->type, "<invalid>"), child->name);
+ fr_type_to_str(parent->type), parent->name,
+ fr_type_to_str(child->type), child->name);
slen = decode_value(ctx, out, child, data, data_len);
if (slen < 0) fr_dict_unknown_free(&child);
child = unknown;
}
FR_PROTO_TRACE("decode context changed %s:%s -> %s:%s",
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "<invalid>"), parent->name,
- fr_table_str_by_value(fr_value_box_type_table, child->type, "<invalid>"), child->name);
+ fr_type_to_str(parent->type), parent->name,
+ fr_type_to_str(child->type), child->name);
tlv_len = decode_value(ctx, out, child, p + 2, p[1]);
if (tlv_len < 0) {
if (!da) return -1;
}
FR_PROTO_TRACE("decode context changed %s:%s -> %s:%s",
- fr_table_str_by_value(fr_value_box_type_table, parent->type, "<invalid>"), parent->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "<invalid>"), da->name);
+ fr_type_to_str(parent->type), parent->name,
+ fr_type_to_str(da->type), da->name);
if (da->type == FR_TYPE_VSA) return decode_vsa(ctx, out, da, data + 2, data[1]);
*/
if (da->type != FR_TYPE_VSA) {
fr_strerror_printf("%s: Expected type \"vsa\" got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
return PAIR_ENCODE_FATAL_ERROR;
}
if (dv->type != FR_TYPE_VENDOR) {
fr_strerror_printf("%s: Expected type \"vsa\" got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, dv->type, "?Unknown?"));
+ fr_type_to_str(dv->type));
return PAIR_ENCODE_FATAL_ERROR;
}
case FR_TYPE_VENDOR:
case FR_TYPE_VSA:
fr_strerror_printf("%s: Called with structural type %s", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
return PAIR_ENCODE_FATAL_ERROR;
default:
if (da_stack->da[depth]->type != FR_TYPE_TLV) {
fr_strerror_printf("%s: Expected type \"tlv\" got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da_stack->da[depth]->type, "?Unknown?"));
+ fr_type_to_str(da_stack->da[depth]->type));
return PAIR_ENCODE_FATAL_ERROR;
}
*/
if (da->type != FR_TYPE_VSA) {
fr_strerror_printf("%s: Expected type \"vsa\" got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
return PAIR_ENCODE_FATAL_ERROR;
}
if (dv->type != FR_TYPE_VENDOR) {
fr_strerror_printf("%s: Expected type \"vsa\" got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, dv->type, "?Unknown?"));
+ fr_type_to_str(dv->type));
return PAIR_ENCODE_FATAL_ERROR;
}
case FR_TYPE_VSA:
case FR_TYPE_GROUP:
fr_strerror_printf("%s: Called with structural type %s", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
return PAIR_ENCODE_FATAL_ERROR;
default:
if (da_stack->da[depth]->type != FR_TYPE_TLV) {
fr_strerror_printf("%s: Expected type \"tlv\" got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da_stack->da[depth]->type, "?Unknown?"));
+ fr_type_to_str(da_stack->da[depth]->type));
return PAIR_ENCODE_FATAL_ERROR;
}
case PROTO_OPT_L2_PAYLOAD_LEN:
if (in->type != FR_TYPE_SIZE) {
fr_strerror_printf("Unboxing failed. Needed type %s, had type %s",
- fr_table_str_by_value(fr_value_box_type_table, FR_TYPE_SIZE, "?Unknown?"),
- fr_table_str_by_value(fr_value_box_type_table, in->type, "?Unknown?"));
+ fr_type_to_str(FR_TYPE_SIZE),
+ fr_type_to_str(in->type));
return -1;
}
ether_ctx->payload_len = in->vb_size;
case FR_TYPE_VSA: /* An attribute holding vendor definitions */
if (unlikely(unknown)) {
fr_strerror_printf("%s: %s can't be marked as unknown", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
fr_dbuff_set(&work_dbuff, &ext_field);
goto error;
}
if (unlikely(tainted)) {
bad_tainted:
fr_strerror_printf("%s: %s can't be marked as tainted", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
fr_dbuff_set(&work_dbuff, &enc_field);
error:
if (unknown) fr_dict_unknown_free(&da);
}
FR_PROTO_TRACE("Decoding %s - %s", da->name,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
slen = internal_decode_pair(ctx, out, parent_da, &work_dbuff, decode_ctx);
if (slen <= 0) goto error;
default:
fr_strerror_printf("%s: Unexpected attribute type \"%s\"",
- __FUNCTION__, fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ __FUNCTION__, fr_type_to_str(da->type));
return PAIR_ENCODE_FATAL_ERROR;
}
FR_PROTO_HEX_DUMP(fr_dbuff_start(&work_dbuff), fr_dbuff_used(&work_dbuff) - vlen, "header");
FR_PROTO_HEX_DUMP(fr_dbuff_start(&value_dbuff), vlen, "value %s",
- fr_table_str_by_value(fr_value_box_type_table, vp->vp_type, "<UNKNOWN>"));
+ fr_type_to_str(vp->vp_type));
return fr_dbuff_set(dbuff, &work_dbuff);
}
default:
fr_strerror_printf("The 'encrypt' flag cannot be used with attributes of type '%s'",
- fr_table_str_by_value(fr_value_box_type_table, type, "<UNKNOWN>"));
+ fr_type_to_str(type));
return false;
}
* Double-check the length after decrypting the
* attribute.
*/
- FR_PROTO_TRACE("Type \"%s\" (%u)", fr_table_str_by_value(fr_value_box_type_table, parent->type, "?Unknown?"), parent->type);
+ FR_PROTO_TRACE("Type \"%s\" (%u)", fr_type_to_str(parent->type), parent->type);
switch (parent->type) {
case FR_TYPE_LEAF:
if (fr_type_is_structural(da->type)) {
fr_strerror_printf("%s: Called with structural type %s", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da_stack->da[depth]->type, "?Unknown?"));
+ fr_type_to_str(da_stack->da[depth]->type));
return PAIR_ENCODE_FATAL_ERROR;
}
}
FR_PROTO_HEX_DUMP(fr_dbuff_start(&work_dbuff), fr_dbuff_used(&work_dbuff), "value %s",
- fr_table_str_by_value(fr_value_box_type_table, vp->vp_type, "<UNKNOWN>"));
+ fr_type_to_str(vp->vp_type));
/*
* Rebuilds the TLV stack for encoding the next attribute
if (da->type != FR_TYPE_VENDOR) {
fr_strerror_printf("%s: Expected type \"vendor\" got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
return PAIR_ENCODE_FATAL_ERROR;
}
if (da->type != FR_TYPE_VSA) {
fr_strerror_printf("%s: Expected type \"vsa\" got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da->type, "?Unknown?"));
+ fr_type_to_str(da->type));
return PAIR_ENCODE_FATAL_ERROR;
}
case FR_TYPE_VENDOR:
/* FR_TYPE_STRUCT is actually allowed... */
fr_strerror_printf("%s: Expected leaf type got \"%s\"", __FUNCTION__,
- fr_table_str_by_value(fr_value_box_type_table, da_stack->da[depth]->type, "?Unknown?"));
+ fr_type_to_str(da_stack->da[depth]->type));
return PAIR_ENCODE_FATAL_ERROR;
default: