switch (tmpl_value_type(map->rhs)) {
case FR_TYPE_STRING:
case FR_TYPE_OCTETS:
- out[2] = tmpl_value(map->rhs).datum.ptr;
+ out[2] = tmpl_value(map->rhs)->datum.ptr;
out_len[2] = tmpl_value_length(map->rhs);
break;
* For everything else we get the string representation
*/
default:
- new = fr_value_box_asprint(pool, &tmpl_value(map->rhs), '\0');
+ new = fr_value_box_asprint(pool, tmpl_value(map->rhs), '\0');
if (!new) {
talloc_free(key);
return -1;
break;
case TMPL_TYPE_DATA:
- rhs = &tmpl_value(map->rhs);
+ rhs = tmpl_value(map->rhs);
CHECK_INT_CAST(lhs, rhs);
CAST(lhs);
break;
case TMPL_TYPE_DATA:
- rcode = cond_normalise_and_cmp(request, c, &tmpl_value(map->lhs));
+ rcode = cond_normalise_and_cmp(request, c, tmpl_value(map->lhs));
break;
case TMPL_TYPE_UNPARSED:
break;
}
- fr_value_box_copy(map->rhs, &tmpl_value(map->rhs), &vp->data);
+ fr_value_box_copy(map->rhs, tmpl_value(map->rhs), &vp->data);
*out = map;
MEM(n = fr_pair_afrom_da(ctx, tmpl_da(map->lhs)));
if (tmpl_da(map->lhs)->type == tmpl_value_type(map->rhs)) {
- if (fr_value_box_copy(n, &n->data, &tmpl_value(map->rhs)) < 0) {
+ if (fr_value_box_copy(n, &n->data, tmpl_value(map->rhs)) < 0) {
rcode = -1;
talloc_free(n);
goto error;
}
} else {
- if (fr_value_box_cast(n, &n->data, n->vp_type, n->da,
- &tmpl_value(map->rhs)) < 0) {
+ if (fr_value_box_cast(n, &n->data, n->vp_type, n->da, tmpl_value(map->rhs)) < 0) {
RPEDEBUG("Implicit cast failed");
rcode = -1;
talloc_free(n);
* zero length string to the specified type and
* see what happens...
*/
- if (fr_value_box_cast(n->mod->rhs, &tmpl_value(n->mod->rhs),
+ if (fr_value_box_cast(n->mod->rhs, tmpl_value(n->mod->rhs),
mutated->cast ? mutated->cast : tmpl_da(mutated->lhs)->type,
tmpl_da(mutated->lhs), &empty_string) < 0) {
talloc_free(n);
* getting the buffer value from may be freed
* before this map is applied.
*/
- if (fr_value_box_copy(n_mod->rhs, &tmpl_value(n_mod->rhs), &vp->data) < 0) goto error;
+ if (fr_value_box_copy(n_mod->rhs, tmpl_value(n_mod->rhs), &vp->data) < 0) goto error;
fr_cursor_append(&to, n_mod);
} while ((vp = fr_cursor_next(&from)));
fr_cursor_init(&values, &head);
- if (fr_value_box_from_str(n->mod, &tmpl_value(n->mod->rhs), &type,
+ if (fr_value_box_from_str(n->mod, tmpl_value(n->mod->rhs), &type,
tmpl_da(mutated->lhs),
mutated->rhs->name, mutated->rhs->len, mutated->rhs->quote, false)) {
RPEDEBUG("Assigning value to \"%s\" failed", tmpl_da(mutated->lhs)->name);
n = list_mod_generic_afrom_map(ctx, original, mutated);
if (!n) goto error;
- vb_head = &tmpl_value(mutated->rhs);
+ vb_head = tmpl_value(mutated->rhs);
for (vb = fr_cursor_init(&from, &vb_head);
vb;
* If tmpl_value were a pointer we could
* assign values directly.
*/
- fr_value_box_copy(n->mod->rhs, &tmpl_value(n->mod->rhs), head);
- tmpl_value(n->mod->rhs).next = head->next;
+ fr_value_box_copy(n->mod->rhs, tmpl_value(n->mod->rhs), head);
+ tmpl_value(n->mod->rhs)->next = head->next;
talloc_free(head);
finish:
/*
* Fast path...
*/
- if (!vlm->mod->next && !tmpl_value(vlm->mod->rhs).next) {
- return map_list_mod_to_vp(ctx, vlm->mod->lhs, &tmpl_value(vlm->mod->rhs));
+ if (!vlm->mod->next && !tmpl_value(vlm->mod->rhs)->next) {
+ return map_list_mod_to_vp(ctx, vlm->mod->lhs, tmpl_value(vlm->mod->rhs));
}
/*
fr_value_box_t *vb;
VALUE_PAIR *vp;
- for (vb = &tmpl_value(mod->rhs);
+ for (vb = tmpl_value(mod->rhs);
vb;
vb = vb->next) {
vp = map_list_mod_to_vp(ctx, mod->lhs, vb);
* map_list_mod_debug()
*/
if (RDEBUG_ENABLED2) {
- for (vb = &tmpl_value(mod->rhs);
+ for (vb = tmpl_value(mod->rhs);
vb;
vb = vb->next) {
map_list_mod_debug(request, map, mod, vb->type != FR_TYPE_INVALID ? vb : NULL);
* any of these values.
*/
if (tmpl_num(map->lhs) != NUM_ALL) {
- fr_value_box_t *vb = &tmpl_value(vlm->mod->rhs);
+ fr_value_box_t *vb = tmpl_value(vlm->mod->rhs);
do {
if (fr_value_box_cmp(vb, &found->data) == 0) {
* matches any of these values.
*/
do {
- fr_value_box_t *vb = &tmpl_value(vlm->mod->rhs);
+ fr_value_box_t *vb = tmpl_value(vlm->mod->rhs);
do {
if (fr_value_box_cmp(vb, &found->data) == 0) {
* Instance specific[n] filter
*/
if (tmpl_num(map->lhs) != NUM_ALL) {
- fr_value_box_t *vb = &tmpl_value(mod->rhs);
+ fr_value_box_t *vb = tmpl_value(mod->rhs);
bool remove = true;
do {
* All instances[*] filter
*/
do {
- fr_value_box_t *vb = &tmpl_value(mod->rhs);
+ fr_value_box_t *vb = tmpl_value(mod->rhs);
bool remove = true;
do {
(data->type == FR_TYPE_STRING) ? T_SINGLE_QUOTED_STRING : T_BARE_WORD);
if (steal) {
- if (fr_value_box_steal(vpt, &tmpl_value(vpt), data) < 0) {
+ if (fr_value_box_steal(vpt, tmpl_value(vpt), data) < 0) {
talloc_free(vpt);
return -1;
}
} else {
- if (fr_value_box_copy(vpt, &tmpl_value(vpt), data) < 0) {
+ if (fr_value_box_copy(vpt, tmpl_value(vpt), data) < 0) {
talloc_free(vpt);
return -1;
}
binlen = (inlen - 2) / 2;
vpt = tmpl_alloc(ctx, TMPL_TYPE_DATA, in, inlen, type);
- tmpl_value(vpt).datum.ptr = talloc_array(vpt, uint8_t, binlen);
+ tmpl_value(vpt)->datum.ptr = talloc_array(vpt, uint8_t, binlen);
tmpl_value_length_set(vpt, binlen);
tmpl_value_type_set(vpt, FR_TYPE_OCTETS);
- len = fr_hex2bin(tmpl_value(vpt).datum.ptr, binlen, in + 2, inlen - 2);
+ len = fr_hex2bin(tmpl_value(vpt)->datum.ptr, binlen, in + 2, inlen - 2);
if (len != binlen) {
fr_strerror_printf("Hex string contains non-hex char");
talloc_free(vpt);
/*
* Why do we pass a pointer to the tmpl type? Goddamn WiMAX.
*/
- if (fr_value_box_from_str(vpt, &tmpl_value(vpt), &tmpl_value_type(vpt),
+ if (fr_value_box_from_str(vpt, tmpl_value(vpt), &tmpl_value_type(vpt),
enumv, vpt->name, vpt->len, '\0', false) < 0) return -1;
vpt->type = TMPL_TYPE_DATA;
break;
if (type == tmpl_value_type(vpt)) return 0; /* noop */
- if (fr_value_box_cast(vpt, &new, type, enumv, &tmpl_value(vpt)) < 0) return -1;
+ if (fr_value_box_cast(vpt, &new, type, enumv, tmpl_value(vpt)) < 0) return -1;
/*
* Free old value buffers
switch (tmpl_value_type(vpt)) {
case FR_TYPE_STRING:
case FR_TYPE_OCTETS:
- talloc_free(tmpl_value(vpt).datum.ptr);
+ talloc_free(tmpl_value(vpt)->datum.ptr);
break;
default:
break;
}
- fr_value_box_copy(vpt, &tmpl_value(vpt), &new);
+ fr_value_box_copy(vpt, tmpl_value(vpt), &new);
}
break;
fr_assert(vpt != NULL);
fr_assert(tmpl_is_unparsed(vpt));
- tmpl_value(vpt).vb_strvalue = talloc_typed_strdup(vpt, vpt->name);
- fr_assert(tmpl_value(vpt).vb_strvalue != NULL);
+ tmpl_value(vpt)->vb_strvalue = talloc_typed_strdup(vpt, vpt->name);
+ fr_assert(tmpl_value(vpt)->vb_strvalue != NULL);
vpt->type = TMPL_TYPE_DATA;
tmpl_value_type_set(vpt, FR_TYPE_STRING);
- tmpl_value_length_set(vpt, talloc_array_length(tmpl_value(vpt).vb_strvalue) - 1);
+ tmpl_value_length_set(vpt, talloc_array_length(tmpl_value(vpt)->vb_strvalue) - 1);
}
/** Expand a #vp_tmpl_t to a string, parse it as an attribute of type cast, create a #VALUE_PAIR from the result
VP_VERIFY(vp);
fr_assert(vp->vp_type == tmpl_value_type(vpt));
- fr_value_box_copy(vp, &vp->data, &tmpl_value(vpt));
+ fr_value_box_copy(vp, &vp->data, tmpl_value(vpt));
*out = vp;
return 0;
}
ret = tmpl_find_vp(&vp, request, vpt);
if (ret < 0) return -2;
- to_cast = &tmpl_value(vpt);
+ to_cast = tmpl_value(vpt);
src_type = tmpl_value_type(vpt);
}
break;
{
RDEBUG4("EXPAND TMPL DATA");
- to_cast = &tmpl_value(vpt);
+ to_cast = tmpl_value(vpt);
switch (to_cast->type) {
case FR_TYPE_STRING:
case FR_TYPE_OCTETS:
break;
case TMPL_TYPE_DATA:
- return fr_value_box_snprint(out, end - out_p, &tmpl_value(vpt), fr_token_quote[vpt->quote]);
+ return fr_value_box_snprint(out, end - out_p, tmpl_value(vpt), fr_token_quote[vpt->quote]);
default:
goto empty;
*/
switch (tmpl_value_type(vpt)) {
case FR_TYPE_STRING:
- if (tmpl_value(vpt).vb_strvalue[tmpl_value_length(vpt)] != '\0') {
+ if (tmpl_value(vpt)->vb_strvalue[tmpl_value_length(vpt)] != '\0') {
fr_fatal_assert_fail("CONSISTENCY CHECK FAILED %s[%u]: TMPL_TYPE_DATA char buffer not \\0 "
"terminated", file, line);
}
*
* @{
*/
-#define tmpl_value(_tmpl) (_tmpl)->data.literal
+#define tmpl_value(_tmpl) (&(_tmpl)->data.literal)
#define tmpl_value_length(_tmpl) (_tmpl)->data.literal.datum.length
#define tmpl_value_type(_tmpl) (_tmpl)->data.literal.type
if (tmpl_da(head->lhs) == attr_cache_created) {
vp_map_t *map;
- c->created = tmpl_value(head->rhs).vb_date;
+ c->created = tmpl_value(head->rhs)->vb_date;
map = head;
head = head->next;
if (tmpl_da(head->lhs) == attr_cache_expires) {
vp_map_t *map;
- c->expires = tmpl_value(head->rhs).vb_date;
+ c->expires = tmpl_value(head->rhs)->vb_date;
map = head;
head = head->next;
*/
tmpl_init(&created_value, TMPL_TYPE_DATA, "<TEMP>", 6, T_BARE_WORD);
tmpl_value_type(&created_value) = FR_TYPE_DATE;
- tmpl_value(&created_value).vb_date = c->created;
+ tmpl_value(&created_value)->vb_date = c->created;
/*
* Encode the entry expiry time
*/
tmpl_init(&expires_value, TMPL_TYPE_DATA, "<TEMP>", 6, T_BARE_WORD);
tmpl_value_type(&expires_value) = FR_TYPE_DATE;
- tmpl_value(&expires_value).vb_date = c->expires;
+ tmpl_value(&expires_value)->vb_date = c->expires;
expires.next = c->maps; /* Head of the list */
for (cnt = 0, map = &created; map; cnt++, map = map->next);
do_rhs:
MEM(c_map->rhs = tmpl_init(talloc(c_map, vp_tmpl_t),
TMPL_TYPE_DATA, map->rhs->name, map->rhs->len, T_BARE_WORD));
- if (fr_value_box_copy(c_map->rhs, &tmpl_value(c_map->rhs), &vp->data) < 0) {
+ if (fr_value_box_copy(c_map->rhs, tmpl_value(c_map->rhs), &vp->data) < 0) {
REDEBUG("Failed copying attribute value");
error:
talloc_free(pool);
(tmpl_tag(map->lhs) != tmpl_tag(target)) ||
(tmpl_list(map->lhs) != tmpl_list(target))) continue;
- *out = fr_value_box_asprint(request, &tmpl_value(map->rhs), '\0');
+ *out = fr_value_box_asprint(request, tmpl_value(map->rhs), '\0');
ret = talloc_array_length(*out) - 1;
break;
}
goto error;
}
- value = fr_value_box_asprint(value_pool, &tmpl_value(map->rhs), '\'');
+ value = fr_value_box_asprint(value_pool, tmpl_value(map->rhs), '\'');
if (!value) goto error;
to_store = talloc_asprintf_append_buffer(to_store, "%s %s %s\n", attr,
*/
if (fr_dict_attr_is_top_level(tmpl_da(map->lhs))) switch (tmpl_da(map->lhs)->attr) {
case FR_CACHE_CREATED:
- c->created = tmpl_value(map->rhs).vb_date;
+ c->created = tmpl_value(map->rhs)->vb_date;
talloc_free(map);
goto next;
case FR_CACHE_EXPIRES:
- c->expires = tmpl_value(map->rhs).vb_date;
+ c->expires = tmpl_value(map->rhs)->vb_date;
talloc_free(map);
goto next;
cf_log_err(cp, "Right side of map must be a string");
return -1;
}
- p = tmpl_value(map->rhs).vb_strvalue;
+ p = tmpl_value(map->rhs)->vb_strvalue;
slen = fr_jpath_parse(cache, &cache->jpath, p, tmpl_value_length(map->rhs));
if (slen <= 0) goto error;
break;
tmp.vb_uint32 = ntohl((uint32_t)reply->element[1]->integer);
tmp.type = FR_TYPE_UINT32;
- if (fr_value_box_cast(NULL, &tmpl_value(ip_map.rhs), FR_TYPE_IPV4_ADDR,
+ if (fr_value_box_cast(NULL, tmpl_value(ip_map.rhs), FR_TYPE_IPV4_ADDR,
NULL, &tmp)) {
RPEDEBUG("Failed converting integer to IPv4 address");
ret = IPPOOL_RCODE_FAIL;
goto finish;
}
} else {
- tmpl_value(ip_map.rhs).vb_uint32 = ntohl((uint32_t)reply->element[1]->integer);
+ tmpl_value(ip_map.rhs)->vb_uint32 = ntohl((uint32_t)reply->element[1]->integer);
tmpl_value_type(ip_map.rhs) = FR_TYPE_UINT32;
}
}
goto do_ip_map;
case REDIS_REPLY_STRING:
- tmpl_value(ip_map.rhs).vb_strvalue = reply->element[1]->str;
+ tmpl_value(ip_map.rhs)->vb_strvalue = reply->element[1]->str;
tmpl_value_length(ip_map.rhs) = reply->element[1]->len;
tmpl_value_type(ip_map.rhs) = FR_TYPE_STRING;
tmpl_init(&range_rhs, TMPL_TYPE_DATA, "", 0, T_DOUBLE_QUOTED_STRING);
tmpl_value_type_set(&range_rhs, FR_TYPE_STRING);
- tmpl_value(range_map.rhs).vb_strvalue = reply->element[2]->str;
+ tmpl_value(range_map.rhs)->vb_strvalue = reply->element[2]->str;
tmpl_value_length(range_map.rhs) = reply->element[2]->len;
tmpl_value_type(range_map.rhs) = FR_TYPE_STRING;
if (map_to_request(request, &range_map, map_to_vp, NULL) < 0) {
goto finish;
}
- tmpl_value(expiry_map.rhs).vb_uint32 = reply->element[3]->integer;
+ tmpl_value(expiry_map.rhs)->vb_uint32 = reply->element[3]->integer;
tmpl_value_type(expiry_map.rhs) = FR_TYPE_UINT32;
if (map_to_request(request, &expiry_map, map_to_vp, NULL) < 0) {
ret = IPPOOL_RCODE_FAIL;
* Add range ID to request
*/
case REDIS_REPLY_STRING:
- tmpl_value(range_map.rhs).vb_strvalue = reply->element[1]->str;
+ tmpl_value(range_map.rhs)->vb_strvalue = reply->element[1]->str;
tmpl_value_length(range_map.rhs) = reply->element[1]->len;
tmpl_value_type(range_map.rhs) = FR_TYPE_STRING;
if (map_to_request(request, &range_map, map_to_vp, NULL) < 0) {
tmpl_init(&expiry_rhs, TMPL_TYPE_DATA, "", 0, T_DOUBLE_QUOTED_STRING);
tmpl_value_type_set(&expiry_rhs, FR_TYPE_STRING);
- tmpl_value(expiry_map.rhs).vb_uint32 = expires;
+ tmpl_value(expiry_map.rhs)->vb_uint32 = expires;
tmpl_value_type(expiry_map.rhs) = FR_TYPE_UINT32;
if (map_to_request(request, &expiry_map, map_to_vp, NULL) < 0) {
ret = IPPOOL_RCODE_FAIL;
};
tmpl_value_length(&ip_rhs) = strlen(ip_str);
- tmpl_value(&ip_rhs).vb_strvalue = ip_str;
+ tmpl_value(&ip_rhs)->vb_strvalue = ip_str;
tmpl_value_type(&ip_rhs) = FR_TYPE_STRING;
if (map_to_request(request, &ip_map, map_to_vp, NULL) < 0) return RLM_MODULE_FAIL;