fr_dict_unknown_free(&child);
if (!vp) return NULL;
- if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da, data, data_len, true) < 0) {
+ if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
+ &FR_DBUFF_TMP(data, data_len), data_len, true) < 0) {
talloc_free(vp);
return NULL;
}
* If we can't decode this field, then the entire
* structure is treated as a raw blob.
*/
- if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da, p, child_length, true) < 0) {
+ if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
+ &FR_DBUFF_TMP(p, child_length), child_length, true) < 0) {
FR_PROTO_TRACE("fr_struct_from_network - failed decoding child VP");
talloc_free(vp);
unknown:
fr_dict_attr_t **u;
memcpy(&u, &c, sizeof(c)); /* const issues */
- memcpy(u, &vp->da, sizeof(vp->da));
+ memcpy(u, &vp->da, sizeof(vp->da));
}
/*
* @param[out] dst value_box to write the result to.
* @param[in] type to decode data to.
* @param[in] enumv Aliases for values.
- * @param[in] src Binary data to decode.
+ * @param[in] dbuff Binary data to decode.
* @param[in] len Length of data to decode. For fixed length types we only
* decode complete values.
* @param[in] tainted Whether the value came from a trusted source.
*/
ssize_t fr_value_box_from_network(TALLOC_CTX *ctx,
fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv,
- uint8_t const *src, size_t len,
+ fr_dbuff_t *dbuff, size_t len,
bool tainted)
-{
- return fr_value_box_from_network_dbuff(ctx, dst, type, enumv, &FR_DBUFF_TMP(src, len), len, tainted);
-}
-
-ssize_t fr_value_box_from_network_dbuff(TALLOC_CTX *ctx,
- fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv,
- fr_dbuff_t *dbuff, size_t len,
- bool tainted)
{
size_t min, max;
fr_dbuff_t work_dbuff = FR_DBUFF(dbuff);
/** Special value to ensure other encoding/decoding errors don't overlap
*/
#define FR_VALUE_BOX_NET_MAX (FR_VALUE_BOX_NET_OOM + 1)
+
ssize_t fr_value_box_from_network(TALLOC_CTX *ctx,
fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv,
- uint8_t const *src, size_t len, bool tainted);
-ssize_t fr_value_box_from_network_dbuff(TALLOC_CTX *ctx,
- fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv,
- fr_dbuff_t *dbuff, size_t len, bool tainted);
+ fr_dbuff_t *dbuff, size_t len, bool tainted);
int fr_value_box_cast(TALLOC_CTX *ctx, fr_value_box_t *dst,
fr_type_t dst_type, fr_dict_attr_t const *dst_enumv,
size_t max_size);
char *fr_value_box_list_aprint(TALLOC_CTX *ctx, fr_value_box_list_t const *list, char const *delim,
- fr_sbuff_escape_rules_t const *e_rules);
+ fr_sbuff_escape_rules_t const *e_rules);
int fr_value_box_list_acopy(TALLOC_CTX *ctx, fr_value_box_list_t *out, fr_value_box_list_t const *in);
MEM(vp = fr_pair_afrom_da(ctx, da));
}
- ret = fr_value_box_from_network(vp, &vp->data, vp->vp_type, vp->da, p, len, true);
+ ret = fr_value_box_from_network(vp, &vp->data, vp->vp_type, vp->da,
+ &FR_DBUFF_TMP(p, (size_t)len), len, true);
if (ret != len) {
fr_pair_to_unknown(vp);
fr_pair_value_memdup(vp, p, len, true);
}
do_value:
- ret = fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da, p, value_len, true);
+ ret = fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
+ &FR_DBUFF_TMP(p, (size_t)value_len), value_len, true);
if (ret < 0) {
/*
* Mandatory bit is set, and the attribute
case FR_TYPE_IPV6_ADDR:
case FR_TYPE_OCTETS:
if (fr_value_box_from_network(ur->out_ctx, vb, ur->return_type, NULL,
- (uint8_t *)fr_dbuff_current(&dbuff), rdlength, true) < 0) {
+ &dbuff, rdlength, true) < 0) {
error:
talloc_free(vb);
fr_dlist_talloc_free(&ur->list);
}
priority_vb = fr_value_box_alloc_null(ur->out_ctx);
if (fr_value_box_from_network(ur->out_ctx, priority_vb, FR_TYPE_UINT16, NULL,
- (uint8_t *)fr_dbuff_current(&dbuff), 2, true) < 0) {
+ &dbuff, 2, true) < 0) {
talloc_free(priority_vb);
goto error;
}
* Call the generic routines to get data from the
* "network" buffer.
*/
- if (fr_value_box_from_network(ctx, vb, type, NULL, input + offset, input_len - offset, data_vb->tainted) < 0) {
+ if (fr_value_box_from_network(ctx, vb, type, NULL,
+ &FR_DBUFF_TMP(input + offset, input_len - offset),
+ input_len - offset, data_vb->tainted) < 0) {
RPEDEBUG("Failed decoding %s", type_vb->vb_strvalue);
talloc_free(vb);
return XLAT_ACTION_FAIL;
{
ssize_t ret;
- ret = fr_value_box_from_network(vp, &vp->data, vp->da->type, da, p, end - p, true);
+ ret = fr_value_box_from_network(vp, &vp->data, vp->da->type, da,
+ &FR_DBUFF_TMP(p, end - p), end - p, true);
if (ret < 0) {
raw:
FR_PROTO_TRACE("decoding as unknown type");
default:
if (fr_value_box_from_network(vp, &vp->data, vp->vp_type, vp->da,
- p, dhcp_header_sizes[i], true) < 0) goto error;
+ &FR_DBUFF_TMP(p, (size_t)dhcp_header_sizes[i]),
+ dhcp_header_sizes[i], true) < 0) goto error;
break;
}
p += dhcp_header_sizes[i];
/*
* Gateway address is set - use that one
*/
- fr_value_box_from_network(vp, &box, FR_TYPE_IPV4_ADDR, NULL, data + 24, 4, true);
+ fr_value_box_from_network(vp, &box, FR_TYPE_IPV4_ADDR, NULL,
+ &FR_DBUFF_TMP(data + 24, 4), 4, true);
fr_value_box_cast(vp, &vp->data, vp->da->type, vp->da, &box);
} else {
/*
* else, store client address whatever it is
*/
- fr_value_box_from_network(vp, &box, FR_TYPE_IPV4_ADDR, NULL, data + 12, 4, true);
+ fr_value_box_from_network(vp, &box, FR_TYPE_IPV4_ADDR, NULL,
+ &FR_DBUFF_TMP(data + 12, 4), 4, true);
fr_value_box_cast(vp, &vp->data, vp->da->type, vp->da, &box);
}
*/
vp = fr_pair_afrom_da(ctx, attr_hop_count);
if (!vp) goto fail;
- if (fr_value_box_from_network(vp, &vp->data, vp->da->type, NULL, packet + 1, 1, true) < 0) {
+ if (fr_value_box_from_network(vp, &vp->data, vp->da->type, NULL,
+ &FR_DBUFF_TMP(packet + 1, 1), 1, true) < 0) {
goto fail;
}
fr_dcursor_append(cursor, vp);
vp = fr_pair_afrom_da(ctx, attr_relay_link_address);
if (!vp) goto fail;
- if (fr_value_box_from_network(vp, &vp->data, vp->da->type, NULL, packet + 2, 16, true) < 0) {
+ if (fr_value_box_from_network(vp, &vp->data, vp->da->type, NULL,
+ &FR_DBUFF_TMP(packet + 2, 16), 16, true) < 0) {
goto fail;
}
fr_dcursor_append(cursor, vp);
vp = fr_pair_afrom_da(ctx, attr_relay_peer_address);
if (!vp) goto fail;
- if (fr_value_box_from_network(vp, &vp->data, vp->da->type, NULL, packet + 2 + 16, 16, true) < 0) {
+ if (fr_value_box_from_network(vp, &vp->data, vp->da->type, NULL,
+ &FR_DBUFF_TMP(packet + 2 + 16, 16), 16, true) < 0) {
goto fail;
}
vp = fr_pair_afrom_da(ctx, unknown);
if (!vp) return PAIR_DECODE_OOM;
- slen = fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da, data, data_len, true);
+ slen = fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
+ &FR_DBUFF_TMP(data, data_len), data_len, true);
if (slen < 0) {
talloc_free(vp);
da = unknown;
vp = fr_pair_afrom_da(ctx, parent);
if (!vp) return PAIR_DECODE_OOM;
- if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da, data, data_len, true) < 0) {
+ if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
+ &FR_DBUFF_TMP(data, data_len), data_len, true) < 0) {
talloc_free(vp);
goto raw;
}
vp = fr_pair_afrom_da(ctx, parent);
if (!vp) return PAIR_DECODE_OOM;
- if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da, data, data_len, true) < 0) {
+ if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
+ &FR_DBUFF_TMP(data, data_len), data_len, true) < 0) {
talloc_free(vp);
goto raw;
}
/*
* Zero length is fine here
*/
- slen = fr_value_box_from_network_dbuff(vp, &vp->data, vp->da->type, vp->da,
- &work_dbuff, fr_dbuff_len(&work_dbuff), tainted);
+ slen = fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
+ &work_dbuff, fr_dbuff_len(&work_dbuff), tainted);
if (slen < 0) {
talloc_free(vp);
return slen;
default:
decode:
- if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da, p, data_len, true) < 0) {
+ if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
+ &FR_DBUFF_TMP(p, data_len), data_len, true) < 0) {
/*
* Paranoid loop prevention
*/
*
* @todo - if the attribute is malformed, create a "raw" one.
*/
- if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da, ptr, attr_len, true) < 0) {
+ if (fr_value_box_from_network(vp, &vp->data, vp->da->type, vp->da,
+ &FR_DBUFF_TMP(ptr, attr_len), attr_len, true) < 0) {
talloc_free(vp);
return -1;
}