*/
if (!vpt->rules.attr.dict_def) tmpl_set_dict_def(vpt, dict);
- /*
- * Convert virtual &Attr-Foo to "%{Attr-Foo}"
- */
- if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) {
- if (tmpl_attr_to_xlat(ctx, vpt_p) < 0) {
- return false;
- }
-
- /*
- * The VPT has been rewritten, so use the new one.
- */
- vpt = *vpt_p;
- } /* it's now xlat, so we need to resolve it. */
-
/*
* Fixup any other tmpl types
*/
MEM(dst = fr_value_box_alloc(ctx, FR_TYPE_BOOL, attr_expr_bool_enum));
vp = tmpl_dcursor_init(NULL, NULL, &cc, &cursor, request, vpt);
- if (!vp) {
- dst->vb_bool = tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual;
- } else {
- dst->vb_bool = true;
- }
+ dst->vb_bool = (vp != NULL);
if (do_free) talloc_const_free(vpt);
tmpl_dcursor_clear(&cc);
FR_SBUFF_ERROR_RETURN(in);
}
- /*
- * Deal with virtual attributes.
- */
- if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) {
- if (tmpl_attr_num_elements(vpt) > 2) {
- fr_strerror_const("Virtual attributes cannot be nested.");
- goto error;
- }
-
- /*
- * This allows xlat functions to be
- * used to provide values for virtual
- * attributes. If we fail to resolve
- * a virtual attribute to a function
- * it's likely going to be handled as
- * a virtual attribute by
- * xlat_eval_pair_virtual
- *
- * We really need a virtual attribute
- * registry so we can check if the
- * attribute is valid.
- */
- if (xlat_resolve_virtual_attribute(node, vpt) < 0) goto do_attr;
/*
* Deal with unresolved attributes.
*/
- } else if (tmpl_is_attr_unresolved(vpt)) {
+ if (tmpl_is_attr_unresolved(vpt)) {
/*
* Could it be a virtual attribute?
*/
* see if it's actually a virtual attribute.
*/
if ((tmpl_attr_num_elements(vpt) == 1) ||
- (((tmpl_attr_list_head(tmpl_attr(vpt))->da) == request_attr_request) && tmpl_attr_num_elements(vpt) == 2)){
- if (tmpl_is_attr(vpt) && tmpl_attr_tail_da(vpt)->flags.virtual) {
- func = xlat_func_find(tmpl_attr_tail_da(vpt)->name, -1);
+ (((tmpl_attr_list_head(tmpl_attr(vpt))->da) == request_attr_request) && tmpl_attr_num_elements(vpt) == 2)) {
+ if (tmpl_is_attr_unresolved(vpt)) {
+ func = xlat_func_find(tmpl_attr_tail_unresolved(vpt), -1);
if (!func) {
- unresolved:
node = xlat_exp_alloc(head, XLAT_VIRTUAL_UNRESOLVED, vpt->name, vpt->len);
/*
goto done;
}
- virtual:
node = xlat_exp_alloc(head, XLAT_VIRTUAL, vpt->name, vpt->len);
node->vpt = talloc_move(node, vpt_p);
node->call.func = func;
node->flags = func->flags;
goto done;
-
- } else if (tmpl_is_attr_unresolved(vpt)) {
- func = xlat_func_find(tmpl_attr_tail_unresolved(vpt), -1);
- if (!func) goto unresolved;
- goto virtual;
}
}
uint32_t all_flags;
uint32_t shift_is_root, shift_internal;
uint32_t shift_array, shift_has_value;
- uint32_t shift_virtual, shift_subtype, shift_extra;
+ uint32_t shift_subtype, shift_extra;
uint32_t shift_counter;
fr_dict_attr_t const *v;
SET_FLAG(internal);
SET_FLAG(array);
SET_FLAG(has_value);
- SET_FLAG(virtual);
SET_FLAG(extra);
SET_FLAG(counter);
SET_FLAG(subtype);
// internal
// array
// has_value
- // virtual
// extra
// encrypt
// length
FORBID_OTHER_FLAGS(has_value);
}
- /*
- * virtual attributes are special.
- */
- if (flags->virtual) {
- if (!parent->flags.is_root) {
- fr_strerror_const("The 'virtual' flag can only be used for normal attributes");
- return false;
- }
-
- if (attr && !flags->internal && (*attr <= (1 << (8 * parent->flags.type_size)))) {
- fr_strerror_const("The 'virtual' flag can only be used for non-protocol attributes");
- return false;
- }
-
- ALLOW_FLAG(internal);
- FORBID_OTHER_FLAGS(virtual);
- }
-
/*
* The "extra" flag is a grab-bag of stuff, depending on
* the data type.