23 RCSID(
"$Id: 981bd93372c412207126323dfcc1727b51919575 $")
25 #include <freeradius-devel/util/misc.h>
26 #include <freeradius-devel/util/pair.h>
27 #include <freeradius-devel/util/proto.h>
28 #include <freeradius-devel/util/regex.h>
30 #include <freeradius-devel/protocol/radius/rfc2865.h>
31 #include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
38 if (!token || !op || !oplen)
return 0;
46 if (oplen < 2)
goto invalid_operator;
53 }
else if (p[1] ==
'~') {
58 }
else if (p[1] ==
'*') {
84 }
else if (p[1] ==
'~') {
89 }
else if (p[1] ==
'*') {
103 if ((oplen > 1) && (p[1] ==
'=')) {
114 if ((oplen > 1) && (p[1] ==
'=')) {
146 char const *
value,
size_t value_len,
151 if (!da || !
value || (value_len == 0))
return NULL;
154 if (!
vp)
return NULL;
190 if (slen <= 0)
return slen - (
in - start);
192 if (da->parent != pair_ctx->
parent) {
194 da->name, pair_ctx->
parent->name);
195 return -(
in - start);
201 return -(
in - start);
204 while ((isspace((
uint8_t) *p)) && (p < end)) p++;
217 return slen - -(p - start);
221 while ((isspace((
uint8_t) *p)) && (p < end)) p++;
233 if ((*p ==
'"') || (*p ==
'\'')) {
238 if (slen <= 0)
return slen - (p - start);
240 value_len = slen - 2;
249 while (!isspace((
uint8_t) *p) && (*p !=
',') && (p < end)) p++;
251 value_len = p -
value;
260 if (!
vp)
return -(
in - start);
304 if (slen <= 0)
return slen - (p -
in);
306 if (da->parent !=
parent) {
312 if ((p + slen) > end) {
323 if ((p >= end) || (*p ==
',')) {
382 while (isspace((
uint8_t) *p) && (p < end)) p++;
383 if (p >= end)
return end -
in;
427 if (p == end)
return p -
in;
439 if (slen <= 0)
return slen - (p -
in);
453 if ((p >= end) || (*p ==
','))
return p -
in;
469 pair_ctx->
parent = da->parent;
478 if (slen <= 0)
return slen - (p -
in);
fr_slen_t fr_dict_attr_by_name_substr(fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *name, fr_sbuff_term_t const *tt))
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_GROUP
A grouping of other attributes.
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.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
int fr_pair_value_from_str(fr_pair_t *vp, char const *value, size_t inlen, fr_sbuff_unescape_rules_t const *uerules, bool tainted)
Convert string value to native attribute value.
static ssize_t fr_pair_afrom_str(fr_pair_ctx_t *pair_ctx, char const *start, char const *in, size_t inlen)
Allocate one fr_pair_t from a string, and add it to the pair_ctx cursor.
static ssize_t op_to_token(fr_token_t *token, char const *op, size_t oplen)
static ssize_t fr_pair_ctx_set(fr_pair_ctx_t *pair_ctx, char const *in, size_t inlen)
Set a new DA context based on the input string.
static fr_pair_t * fr_pair_afrom_fields(TALLOC_CTX *ctx, fr_dict_attr_t const *da, fr_token_t op, char const *value, size_t value_len, fr_sbuff_unescape_rules_t const *uerules)
Allocate a fr_pair_t based on pre-parsed fields.
void fr_pair_ctx_reset(fr_pair_ctx_t *pair_ctx, fr_dict_t const *dict)
Reset a pair_ctx to the dictionary root.
ssize_t fr_pair_ctx_afrom_str(fr_pair_ctx_t *pair_ctx, char const *in, size_t inlen)
Parse a pair context from a string.
#define FR_SBUFF_IN(_start, _len_or_end)
Set of parsing rules for *unescape_until functions.
Stores an attribute, a value and various bits of other data.
ssize_t fr_skip_string(char const *start, char const *end)
Skip a quoted string.
TALLOC_CTX * ctx
to allocate VPs in
fr_pair_list_t * list
of VPs to add
fr_dict_attr_t const * parent
current attribute to allocate VPs in
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_const(_msg)
fr_sbuff_unescape_rules_t * fr_value_unescape_by_char[UINT8_MAX+1]
static size_t char fr_sbuff_t size_t inlen