return data_len;
}
+ /*
+ * These are always raw.
+ */
+ if (da->flags.is_unknown) {
+ return fr_pair_raw_from_network(ctx, out, da, data, data_len);
+ }
+
vp = fr_pair_afrom_da(ctx, da);
if (!vp) return -1;
/*
* string / octets / bool can be empty. Other data types are
- * incorrect if they're empty.
+ * raw if they're empty.
*/
if (data_len == 0) {
if (da->type == FR_TYPE_BOOL) {
goto finish;
}
- if (!((da->type == FR_TYPE_OCTETS) || (da->type == FR_TYPE_STRING))) goto raw;
- goto finish;
- }
+ if ((da->type == FR_TYPE_OCTETS) || (da->type == FR_TYPE_STRING)) {
+ goto finish;
+ }
- /*
- * Unknown attributes always get converted to
- * octet types, so there's no way there could
- * be multiple attributes, so its safe to
- * steal the unknown attribute into the context
- * of the pair.
- *
- * Note that we *cannot* do talloc_steal here, because
- * this function is called in a loop from decode_array().
- * And we cannot steal the same da into multiple parent
- * VPs. As a result, we have to copy it, and rely in the
- * caller to clean up the unknown da.
- */
- if (da->flags.is_unknown) {
- fr_pair_reinit_from_da(NULL, vp, fr_dict_unknown_attr_afrom_da(vp, da));
- da = vp->da;
+ talloc_free(vp);
+ return fr_pair_raw_from_network(ctx, out, da, data, 0);
}
switch (vp->da->type) {
da = fr_dict_attr_child_by_num(parent, option);
if (!da) {
da = fr_dict_unknown_attr_afrom_num(packet_ctx->tmp_ctx, parent, option);
- if (!da) return PAIR_DECODE_FATAL_ERROR;
+ if (!da) return PAIR_DECODE_OOM;
}
FR_PROTO_TRACE("decode context changed %s -> %s",da->parent->name, da->name);
if ((da->type == FR_TYPE_STRING) && da_is_dns_label(da)) {
slen = fr_pair_dns_labels_from_network(ctx, out, da, data + 2, data + 2, len, NULL, true);
- if (slen < 0) return slen;
} else if (da->flags.array) {
slen = fr_pair_array_from_network(ctx, out, da, data + 2, len, decode_ctx, decode_value);
if (!packet_ctx->buffer) {
packet_ctx->buffer = talloc_array(packet_ctx, uint8_t, data_len);
- if (!packet_ctx->buffer) return -1;
+ if (!packet_ctx->buffer) return PAIR_DECODE_OOM;
} else if (talloc_array_length(packet_ctx->buffer) < data_len) {
/*
# These next two tests will be broken until we start printing qualified attribute names
decode-pair 52 07 01 03 ab cd ef 03 00
-match Relay-Agent-Information.Circuit-Id = 0xabcdef, Relay-Agent-Information.3 = 0x
+match Relay-Agent-Information.Circuit-Id = 0xabcdef, raw.Relay-Agent-Information.3 = 0x
decode-pair 52 08 01 03 ab cd ef 03 01 ad
-match Relay-Agent-Information.Circuit-Id = 0xabcdef, Relay-Agent-Information.3 = 0xad
+match Relay-Agent-Information.Circuit-Id = 0xabcdef, raw.Relay-Agent-Information.3 = 0xad
#
# And option 82 with full suboptions