25RCSID(
"$Id: 93b6c3137b7fdc90c2c9eb49ea32b3b569c31cd6 $")
27#include <freeradius-devel/util/md5.h>
28#include <freeradius-devel/util/struct.h>
29#include <freeradius-devel/io/test_point.h>
30#include <freeradius-devel/protocol/radius/freeradius.internal.h>
37#include <freeradius-devel/protocol/radius/rfc2869.h>
38#include <freeradius-devel/protocol/radius/rfc5904.h>
39#include <freeradius-devel/protocol/radius/rfc6929.h>
40#include <freeradius-devel/protocol/radius/rfc7268.h>
42static bool memcpy_bounded(
void * restrict dst,
const void * restrict src,
size_t n,
const void * restrict end)
54 if (
n == 0)
return true;
57 if (
n >
len)
return false;
74 size_t i,
n, encrypted_len, embedded_len;
76 encrypted_len = *pwlen;
81 if (encrypted_len < 2) {
96 if (encrypted_len <= 3) {
127 block_len = *pwlen -
n - 2;
144 embedded_len = passwd[2] ^ digest[0];
145 if (embedded_len > (encrypted_len - 1)) {
147 "(shared secret is probably incorrect!)");
164 for (i = base; i < block_len; i++) {
165 passwd[
n + i - 1] = passwd[
n + i + 2] ^ digest[i];
175 if (
packet_ctx->tunnel_password_zeros)
for (i = embedded_len; i < (encrypted_len - 1); i++) {
176 if (passwd[i] != 0) {
178 "(shared secret is probably incorrect!)");
184 *pwlen = embedded_len;
186 passwd[embedded_len] =
'\0';
205 if (pwlen == 0)
goto done;
217 size_t left = (pwlen -
n);
238 for (i = 0; i < left; i++) passwd[i +
n] ^= digest[i];
245 passwd[pwlen] =
'\0';
246 return strlen((
char *) passwd);
256 FR_PROTO_TRACE(
"Checking TLV %u/%u", (
unsigned int) dv_type, (
unsigned int) dv_length);
260 if ((dv_length > 2) || (dv_type == 0) || (dv_type > 4)) {
268 if ((
data + dv_type + dv_length) > end) {
275 if ((
data[0] == 0) && (
data[1] == 0) &&
309 if (
data[dv_type] != 0) {
315 attrlen =
data[dv_type + dv_length - 1];
324 if (attrlen < (dv_type + dv_length)) {
329 if (attrlen > length) {
363 if ((ptr + 2) == end)
break;
364 if ((ptr + 2) > end)
return -1;
370 if (ptr[1] < 2)
return -1;
371 if ((ptr + ptr[1]) > end)
return -1;
377 if (ptr == end)
break;
382 if (ptr[0] != attr)
break;
394 if (!total)
return 2;
419#define decode_value fr_radius_decode_pair_value
426 uint8_t const *
data,
size_t const data_len,
void *decode_ctx)
434#ifdef STATIC_ANALYZER
443 if ((data_len < 2) || (
data[1] < 2)) {
451 if (
data[1] == 2)
return 2;
455 if (
len > data_len) {
457 "Length must be less than %zu bytes, got %zu bytes",
458 __FUNCTION__, data_len - 2,
len - 2);
467 if (slen < 0)
return slen;
470 FR_PROTO_TRACE(
"decode context changed %s -> %s",da->parent->name, da->name);
472 if (da->flags.array) {
482 if (slen > 0)
return len;
488 if (slen < 0)
return slen;
518 if ((ptr + 2) == end)
break;
519 if ((ptr + 2) > end)
return -1;
520 if ((ptr[0] != FR_NAS_FILTER_RULE))
break;
525 if (ptr[1] < 2)
return -1;
526 if ((ptr + ptr[1]) > end)
return -1;
534 FR_PROTO_TRACE(
"Coalesced NAS-Filter-Rule has %lu octets", total);
540 if ((attrs > 1) && total) {
560 memcpy(p, ptr + 2, ptr[1] - 2);
567 decode_end =
buffer + total;
581 while (
decode < decode_end) {
587 while (p < decode_end) {
588 if (*p == 0x00)
break;
652 if (((
size_t) (end - p) < 2) || (p[1] < 2) || (p[1] > (
size_t) (end - p))) {
661 if (slen < 0)
return slen;
669 if (p[1] == 2)
goto next;
683 if (p < end)
goto redo;
705 if (data_len < 3)
return -1;
707#ifdef STATIC_ANALYZER
759 if (!child)
goto error;
769 child, p + 2, p[1] - 2,
772 if (tlv_len < 0)
goto error;
791 unsigned int attribute;
795#ifdef STATIC_ANALYZER
817 attribute =
data[1] << 16;
818 attribute |=
data[2] << 8;
819 attribute |=
data[3];
823 attribute =
data[0] << 8;
824 attribute |=
data[1];
861 FR_PROTO_TRACE(
"decode context changed %s -> %s", da->parent->name, da->name);
867 if (my_len < 0)
return my_len;
923 if (attr_len < 3)
return -1;
928 if ((
data[1] & 0x80) == 0) {
931 if (ret < 0)
return -1;
941 fraglen = attr_len - 2;
942 frag =
data + attr_len;
948 if (last_frag || ((end - frag) < 4) ||
949 (frag[0] != attr[0]) ||
951 (frag[2] != attr[2]) ||
952 ((frag + frag[1]) > end)) {
957 last_frag = ((frag[3] & 0x80) == 0);
959 fraglen += frag[1] - 4;
965 if (!
head)
return -1;
967 FR_PROTO_TRACE(
"Fragments %d, total length %d", fragments, (
int) fraglen);
977 while (fragments > 0) {
978 if ((frag[1] > 4) && !
memcpy_bounded(tail, frag + 4, frag[1] - 4, end)) {
1004 if (ret < 0)
return ret;
1029 if (slen <= 0)
return slen;
1041 if (!unknown)
return -1;
1054 if (slen < 0 )
return slen;
1069 if (slen < 0)
return slen;
1078 if ((
data[3] & 0x80) == 0) {
1081 if (slen < 0 )
return slen;
1090 if (slen < 0)
return slen;
1107 uint8_t const *attr, *end, *tmp;
1111#ifdef STATIC_ANALYZER
1130 FR_PROTO_TRACE(
"attribute is too small to be WiMAX-Attr-WiMAX-Len Continuation");
1137 if (((
size_t) (
data[5] + 4)) != attr_len) {
1145 FR_PROTO_TRACE(
"decode context changed %s -> %s", da->parent->name, da->name);
1150 if ((
data[6] & 0x80) == 0) {
1154 wimax_len =
data[5] - 3;
1155 end =
data + attr_len;
1171 while (attr < end) {
1176 if ((end - attr) < 3) {
1193 if ((attr + attr[1]) > end) {
1201 more = ((attr[2] & 0x80) != 0);
1207 if (!more) end = attr + attr[1];
1213 if (more && ((attr + attr[1]) == end)) {
1222 wimax_len += attr[1] - 3;
1242 if ((end - attr) < 9) {
1247 if (attr[0] != FR_VENDOR_SPECIFIC) {
1257 if ((attr + attr[1]) > end) {
1262 if (memcmp(
data, attr + 2, 4) != 0) {
1267 if (attr[1] != (attr[7] + 6)) {
1272 if (
data[4] != attr[6]) {
1293 if (!
head)
return -1;
1300 while (attr < end) {
1305 tail += attr[4 + 1] - 3;
1306 attr += 4 + attr[4 + 1];
1340 if (slen < 0)
return slen;
1369#ifdef STATIC_ANALYZER
1379 if (attr_len < 5)
return -1;
1380 if (
data[0] != 0)
return -1;
1384 memcpy(&vendor_pen,
data, 4);
1385 vendor_pen = ntohl(vendor_pen);
1410 fr_assert(vendor_da->flags.type_size == 1);
1415 memset(&my_dv, 0,
sizeof(my_dv));
1417 my_dv.
pen = vendor_pen;
1463 while (attr_len > 0) {
1479 attr_len -= vsa_len;
1512 uint8_t const *
data,
size_t data_len,
void *decode_ctx)
1521 uint8_t const *
data,
size_t data_len,
void *decode_ctx)
1578 if (attr_len > 128 * 1024) {
1592 data_len = attr_len;
1597 if (attr_len == 0)
return 0;
1607 if ((attr_len != 4) || (p[0] >= 0x20)) {
1622 if (data_len >=
sizeof(
buffer))
goto raw;
1625 memcpy(
buffer, p + 1, data_len - 1);
1630 memcpy(
buffer, p, attr_len);
1666 if (new_tag_ctx) TALLOC_FREE(
packet_ctx->tags);
1678 if (
unlikely(!group))
goto tag_alloc_error;
1688#ifdef TALLOC_GET_TYPE_ABORT_NOOP
1715 if (data_len > 253)
goto raw;
1725 if (!
packet_ctx->request_authenticator)
goto raw;
1734 if (
parent->flags.length) {
1735 if (data_len >
parent->flags.length) {
1736 data_len =
parent->flags.length;
1749 while ((data_len > 0) && (
buffer[data_len - 1] ==
'\0')) data_len--;
1759 if (!
packet_ctx->request_authenticator)
goto raw;
1771 if (!
packet_ctx->request_authenticator)
goto raw;
1777 data_len = strlen((
char *)
buffer);
1785 (
parent->flags.length && (data_len >
parent->flags.length))) {
1786 data_len =
parent->flags.length;
1813 if (ret < 0)
goto raw;
1822 if (data_len < 6)
goto raw;
1824 memcpy(&vendor_pen, p, 4);
1825 vendor_pen = ntohl(vendor_pen);
1866 child, p + 5, attr_len - 5,
1868 if (ret < 0)
goto raw;
1879 if (ret < 0)
goto raw;
1890 if (ret < 0)
goto raw;
1906 if (!proto->
decode)
goto raw;
1912 ret = proto->
decode(
vp, &
vp->vp_group, p, attr_len);
1913 if (ret < 0)
goto raw;
1915 vp->vp_tainted =
true;
1974 if (data_len != 6)
goto raw;
1975 if (p[0] != 0)
goto raw;
1978 p[1], p + 2, 4,
true,
true) < 0) {
2004 if (data_len > 18)
goto raw;
2005 if (data_len < 2)
goto raw;
2006 if (p[0] != 0)
goto raw;
2009 p[1], p + 2, data_len - 2,
false,
true) < 0) {
2027 if (
parent->flags.length && (data_len !=
parent->flags.length))
goto raw;
2038 if (
vp->
da->flags.is_unknown) {
2047 vp->vp_tainted =
true;
2074 [FR_NAS_FILTER_RULE] =
true,
2077 [FR_EAP_MESSAGE] =
true,
2078 [FR_PKM_SS_CERT] =
true,
2079 [FR_PKM_CA_CERT] =
true,
2080 [FR_EAPOL_ANNOUNCEMENT] =
true,
2082 [FR_EXTENDED_ATTRIBUTE_1] =
true,
2083 [FR_EXTENDED_ATTRIBUTE_2] =
true,
2084 [FR_EXTENDED_ATTRIBUTE_3] =
true,
2085 [FR_EXTENDED_ATTRIBUTE_4] =
true,
2086 [FR_EXTENDED_ATTRIBUTE_5] =
true,
2087 [FR_EXTENDED_ATTRIBUTE_6] =
true,
2099 if ((data_len < 2) || (
data[1] < 2) || (
data[1] > data_len)) {
2125 FR_PROTO_TRACE(
"decode context changed %s -> %s",da->parent->name, da->name);
2133 if (
data[0] != FR_CHARGEABLE_USER_IDENTITY) {
2167 if (
data[0] == FR_NAS_FILTER_RULE) {
2206 if (ret < 0)
return ret;
2222 .tmp_ctx = talloc(ctx,
uint8_t),
2223 .end =
data + data_len,
2229 end = decode_ctx.
end;
2231 while (attr < end) {
2240 talloc_free_children(decode_ctx.
tmp_ctx);
2250 TALLOC_FREE(ctx->
tags);
2259 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2260 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2271 test_ctx->request_authenticator = vector;
2281 uint8_t const *
data,
size_t data_len,
void *proto_ctx)
2286 size_t packet_len = data_len;
2351 uint8_t const *
data,
size_t data_len,
void *decode_ctx)
ssize_t fr_radius_decode_abinary(fr_pair_t *vp, uint8_t const *data, size_t data_len)
Print an Ascend binary filter attribute to a string,.
static int const char char buffer[256]
static int packet_ctx
the tests pass only the address of packet_ctx
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
fr_dict_attr_t const * root_da
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
#define FR_DIGEST_ATTRIBUTES
static fr_dict_attr_t const * attr_packet_type
bool continuation
we only have one flag for now, for WiMAX
size_t type
Length of type data.
fr_dict_attr_decode_func_t decode
for decoding attributes.
static fr_dict_attr_t * fr_dict_attr_unknown_vendor_afrom_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int vendor)
fr_dict_protocol_t const * fr_dict_protocol(fr_dict_t const *dict)
Return the protocol descriptor for the dictionary.
static fr_dict_attr_t * fr_dict_attr_unknown_raw_afrom_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int attr)
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
uint32_t pen
Private enterprise number.
void fr_dict_attr_unknown_free(fr_dict_attr_t const **da)
Free dynamically allocated (unknown attributes)
size_t length
Length of length data.
static fr_dict_attr_t * fr_dict_attr_unknown_typed_afrom_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int num, fr_type_t type)
fr_dict_vendor_t const * fr_dict_vendor_by_num(fr_dict_t const *dict, uint32_t vendor_pen)
Look up a vendor by its PEN.
fr_dict_attr_t const * fr_dict_attr_child_by_num(fr_dict_attr_t const *parent, unsigned int attr)
Check if a child attribute exists in a parent using an attribute number.
Protocol-specific callbacks in libfreeradius-PROTOCOL.
static fr_dict_attr_t const * fr_dict_attr_ref(fr_dict_attr_t const *da)
Return the reference associated with a group type attribute.
#define PAIR_DECODE_OOM
Fatal error - Out of memory.
#define PAIR_DECODE_FATAL_ERROR
Fatal error - Failed decoding the packet.
static int _test_ctx_free(UNUSED fr_aka_sim_ctx_t *ctx)
ssize_t fr_pair_tlvs_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx, fr_pair_decode_value_t decode_tlv, fr_pair_tlvs_verify_t verify_tlvs, bool nested)
Decode a list of pairs from the network.
ssize_t fr_pair_raw_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *da, uint8_t const *data, size_t data_len)
Create a "raw" pair from malformed network data.
ssize_t fr_pair_array_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx, fr_pair_decode_value_t decode_value)
Decode an array of values from the network.
static const uint8_t * zero
void fr_md5_ctx_free_from_list(fr_md5_ctx_t **ctx)
Free function for MD5 digest ctx.
fr_md5_ctx_t * fr_md5_ctx_alloc_from_list(void)
Allocation function for MD5 digest context.
#define fr_md5_final(_out, _ctx)
Finalise the ctx, producing the digest.
#define fr_md5_ctx_copy(_dst, _src)
Copy the contents of a ctx.
#define fr_md5_update(_ctx, _in, _inlen)
Ingest plaintext into the digest.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_VENDOR
Attribute that represents a vendor in the attribute tree.
@ FR_TYPE_IPV4_PREFIX
IPv4 Prefix.
@ FR_TYPE_VSA
Vendor-Specific, for RADIUS attribute 26.
@ FR_TYPE_OCTETS
Raw octets.
@ FR_TYPE_GROUP
A grouping of other attributes.
bool fr_radius_ok(uint8_t const *packet, size_t *packet_len_p, uint32_t max_attributes, bool require_message_authenticator, bool radius_1_1, decode_fail_t *reason)
static fr_radius_decode_fail_t decode(TALLOC_CTX *ctx, fr_pair_list_t *reply, uint8_t *response_code, bio_handle_t *h, request_t *request, bio_request_t *u, uint8_t const request_authenticator[static RADIUS_AUTH_VECTOR_LENGTH], uint8_t *data, size_t data_len)
Decode response packet data, extracting relevant information and validating the packet.
static uint32_t fr_nbo_to_uint32(uint8_t const data[static sizeof(uint32_t)])
Read an unsigned 32bit integer from wire format (big endian)
#define RADIUS_HEADER_LENGTH
#define RADIUS_AUTH_VECTOR_LENGTH
int fr_pair_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Copy data into an "octets" data type.
fr_pair_list_t * fr_pair_parent_list(fr_pair_t const *vp)
Return a pointer to the parent pair list.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
int fr_pair_value_bstrndup(fr_pair_t *vp, char const *src, size_t len, bool tainted)
Copy data into a "string" type value pair.
int fr_pair_delete(fr_pair_list_t *list, fr_pair_t *vp)
Remove fr_pair_t from a list and free.
int fr_pair_value_mem_alloc(fr_pair_t *vp, uint8_t **out, size_t size, bool tainted)
Pre-allocate a memory buffer for a "octets" type value pair.
fr_pair_t * fr_pair_afrom_da_nested(TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *da)
Create a pair (and all intermediate parents), and append it to the list.
void fr_pair_list_steal(TALLOC_CTX *ctx, fr_pair_list_t *list)
Steal a list of pairs to a new context.
static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict, UNUSED fr_dict_attr_t const *root_da)
static ssize_t decode_value_trampoline(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
Handle arrays of DNS labels for fr_struct_from_network()
static ssize_t decode_vsa(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
RFC 4243 Vendor Specific Suboptions.
static ssize_t decode_tlv_trampoline(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
static ssize_t decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, NDEBUG_UNUSED fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx)
HIDDEN fr_dict_attr_t const * attr_packet_authentication_vector
HIDDEN fr_dict_attr_t const * attr_packet_reserved
HIDDEN fr_dict_attr_t const * attr_packet_token
ssize_t fr_radius_ascend_secret(fr_dbuff_t *dbuff, uint8_t const *in, size_t inlen, char const *secret, size_t secret_len, uint8_t const *vector)
Do Ascend-Send / Recv-Secret calculation.
ssize_t fr_radius_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t *packet, size_t packet_len, fr_radius_decode_ctx_t *decode_ctx)
char const * fr_radius_decode_fail_reason[FR_RADIUS_FAIL_MAX+1]
fr_test_point_proto_decode_t radius_tp_decode_proto
ssize_t fr_radius_decode_foreign(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len)
static ssize_t decode_concat(TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *parent, uint8_t const *data, uint8_t const *end)
Convert a "concatenated" attribute to one long VP.
static ssize_t decode_extended(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *da, uint8_t const *data, UNUSED size_t data_len, fr_radius_decode_ctx_t *packet_ctx)
Fast path for most extended attributes.
static ssize_t fr_radius_decode_password(uint8_t passwd[static 256], size_t pwlen, fr_radius_decode_ctx_t *packet_ctx)
Decode password.
static ssize_t decode_digest_attributes(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, fr_radius_decode_ctx_t *packet_ctx)
Decode Digest-Attributes.
static ssize_t decode_wimax(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t attr_len, fr_radius_decode_ctx_t *packet_ctx)
Convert a Vendor-Specific WIMAX to vps.
ssize_t fr_radius_decode_tlv(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, fr_radius_decode_ctx_t *packet_ctx)
Convert TLVs to one or more VPs.
fr_test_point_pair_decode_t radius_tp_decode_pair
ssize_t fr_radius_decode_pair_value(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const attr_len, void *decode_ctx)
Create any kind of VP from the attribute contents.
static ssize_t decode_extended_fragments(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t attr_len, fr_radius_decode_ctx_t *packet_ctx)
Convert a fragmented extended attr to a VP.
static ssize_t fr_radius_decode_tunnel_password(uint8_t passwd[static 256], size_t *pwlen, fr_radius_decode_ctx_t *packet_ctx)
Decode Tunnel-Password encrypted attributes.
static const bool special[UINT8_MAX+1]
int fr_radius_decode_tlv_ok(uint8_t const *data, size_t length, size_t dv_type, size_t dv_length)
Check if a set of RADIUS formatted TLVs are OK.
ssize_t fr_radius_decode_pair(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, fr_radius_decode_ctx_t *packet_ctx)
Create a "normal" fr_pair_t from the given data.
static void tag_group_cleanup(fr_radius_decode_ctx_t *packet_ctx, int8_t tag)
Free an empty Tag-N group.
static ssize_t decode_vsa_internal(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, fr_radius_decode_ctx_t *packet_ctx, fr_dict_vendor_t const *dv)
Convert a top-level VSA to a VP.
static ssize_t decode_rfc(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, void *decode_ctx)
decode an RFC-format TLV
static bool memcpy_bounded(void *restrict dst, const void *restrict src, size_t n, const void *restrict end)
static ssize_t decode_nas_filter_rule(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t const data_len, fr_radius_decode_ctx_t *packet_ctx)
Decode NAS-Filter-Rule.
static ssize_t fr_radius_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *proto_ctx)
fr_radius_tag_ctx_t ** tags
for decoding tagged attributes
fr_radius_attr_flags_encrypt_t
@ RADIUS_FLAG_ENCRYPT_NONE
No encryption.
@ RADIUS_FLAG_ENCRYPT_USER_PASSWORD
Encrypt attribute RFC 2865 style.
@ RADIUS_FLAG_ENCRYPT_ASCEND_SECRET
Encrypt attribute ascend style.
@ RADIUS_FLAG_ENCRYPT_TUNNEL_PASSWORD
Encrypt attribute RFC 2868 style.
static bool fr_radius_flag_long_extended(fr_dict_attr_t const *da)
uint8_t const * end
end of the packet
fr_radius_decode_fail_t
Failure reasons.
#define RADIUS_MAX_STRING_LENGTH
static bool fr_radius_flag_extended(fr_dict_attr_t const *da)
static fr_radius_attr_flags_encrypt_t fr_radius_flag_encrypted(fr_dict_attr_t const *da)
static bool fr_radius_flag_has_tag(fr_dict_attr_t const *da)
fr_radius_ctx_t const * common
static bool fr_radius_flag_abinary(fr_dict_attr_t const *da)
static bool fr_radius_flag_concat(fr_dict_attr_t const *da)
TALLOC_CTX * tmp_ctx
for temporary things cleaned up during decoding
static fr_radius_bio_verify_t test_ctx(void)
Make a verify context which allows Access-Request and Access-Accept.
static const uint8_t zeros[RADIUS_AUTH_VECTOR_LENGTH]
static fr_dict_t const * dict_radius
static fr_dict_attr_t const * attr_vendor_specific
ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, uint8_t const *data, size_t data_len, void *decode_ctx, fr_pair_decode_value_t decode_value, fr_pair_decode_value_t decode_tlv)
Convert a STRUCT to one or more VPs.
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
#define talloc_strdup(_ctx, _str)
static size_t talloc_strlen(char const *s)
Returns the length of a talloc array containing a string.
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Entry point for pair decoders.
Entry point for protocol decoders.
bool fr_pair_list_empty(fr_pair_list_t const *list)
Is a valuepair list empty.
static int fr_pair_find_or_append_by_da(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *da)
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
#define FR_PROTO_HEX_DUMP(_data, _data_len, _fmt,...)
#define FR_PROTO_TRACE(_fmt,...)
char const * fr_strerror(void)
Get the last library error.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_printf_push(_fmt,...)
Add a message to an existing stack of messages at the tail.
#define fr_strerror_const(_msg)
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
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, fr_dbuff_t *dbuff, size_t len, bool tainted)
Decode a fr_value_box_t from serialized binary data.
ssize_t fr_value_box_ipaddr_from_network(fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, int prefix_len, uint8_t const *data, size_t data_len, bool fixed, bool tainted)
Decode a fr_value_box_t of type IP address / prefix.
static fr_sbuff_err_t char ** out
static fr_sbuff_err_t char size_t * len