25RCSID(
"$Id: cad6d9c8bdc58c06e644b93fef195be8c634d526 $")
27#include <freeradius-devel/server/base.h>
28#include <freeradius-devel/server/module_rlm.h>
29#include <freeradius-devel/unlang/xlat_func.h>
30#include <freeradius-devel/util/base16.h>
54 fr_value_box_list_t *
in)
56 size_t len, input_len, offset;
69 REDEBUG(
"unpack requires the input attribute to be 'string' or 'octets'");
73 if ((data_vb->type ==
FR_TYPE_STRING) && (data_vb->vb_length > 1) &&
74 (data_vb->vb_strvalue[0] ==
'0') && (data_vb->vb_strvalue[1] ==
'x')) {
78 len = strlen(data_vb->vb_strvalue + 2);
86 REDEBUG(
"Invalid hex string in '%s'", data_vb->vb_strvalue);
90 REDEBUG(
"Zero length hex string in '%s'", data_vb->vb_strvalue);
94 input = (
uint8_t const *)data_vb->vb_strvalue;
95 input_len = data_vb->vb_length;
97 input = data_vb->vb_octets;
98 input_len = data_vb->vb_length;
101 offset = offset_vb->vb_uint32;
103 if (offset >= input_len) {
104 REDEBUG(
"unpack offset %zu is larger than input data length %zu", offset, input_len);
111 REDEBUG(
"Invalid data type '%s'", type_vb->vb_strvalue);
116 if ((repeat_vb->type ==
FR_TYPE_STRING) && (strcmp(repeat_vb->vb_strvalue,
"*") == 0)) {
120 REDEBUG(
"Invalid value for limit");
123 repeat = repeat_vb->vb_uint32;
136 input_len - offset, data_vb->tainted);
138 RPEDEBUG(
"Failed decoding %s", type_vb->vb_strvalue);
144 if (
count == repeat)
break;
147 if (offset +
used > input_len)
break;
#define fr_base16_decode(_err, _out, _in, _no_trailing)
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
static xlat_action_t unpack_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
Unpack data.
#define RPEDEBUG(fmt,...)
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_OCTETS
Raw octets.
module_t common
Common fields presented by all modules.
static int mod_load(void)
static xlat_arg_parser_t const unpack_xlat_args[]
static void mod_unload(void)
#define FR_SBUFF_IN(_start, _len_or_end)
fr_aka_sim_id_type_t type
bool required
Argument must be present, and non-empty.
#define XLAT_ARG_PARSER_TERMINATOR
@ XLAT_ACTION_FAIL
An xlat function failed.
@ XLAT_ACTION_DONE
We're done evaluating this level of nesting.
Definition for a single argument consumend by an xlat function.
#define fr_type_is_null(_x)
static fr_type_t fr_type_from_str(char const *type)
Return the constant value representing a type.
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.
int fr_value_box_cast_in_place(TALLOC_CTX *ctx, fr_value_box_t *vb, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv)
Convert one type of fr_value_box_t to another in place.
#define fr_value_box_alloc_null(_ctx)
Allocate a value box for later use with a value assignment function.
static size_t char ** out
void xlat_func_flags_set(xlat_t *x, xlat_func_flags_t flags)
Specify flags that alter the xlat's behaviour.
int xlat_func_args_set(xlat_t *x, xlat_arg_parser_t const args[])
Register the arguments of an xlat.
xlat_t * xlat_func_register(TALLOC_CTX *ctx, char const *name, xlat_func_t func, fr_type_t return_type)
Register an xlat function.
void xlat_func_unregister(char const *name)
Unregister an xlat function.