23RCSID(
"$Id: 08b15f75098ddcd4de97f865174a80d643ad41e6 $")
25#include <freeradius-devel/util/skip.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;
191 if (slen <= 0)
return slen - (
in - start);
193 if (da->parent != pair_ctx->
parent) {
195 da->name, pair_ctx->
parent->name);
196 return -(
in - start);
202 return -(
in - start);
205 while ((isspace((
uint8_t) *p)) && (p < end)) p++;
218 return slen - -(p - start);
222 while ((isspace((
uint8_t) *p)) && (p < end)) p++;
234 if ((*p ==
'"') || (*p ==
'\'')) {
239 if (slen <= 0)
return slen - (p - start);
241 value_len = slen - 2;
250 while (!isspace((
uint8_t) *p) && (*p !=
',') && (p < end)) p++;
252 value_len = p -
value;
261 if (!
vp)
return -(
in - start);
306 if (slen <= 0)
return slen - (p -
in);
308 if (da->parent !=
parent) {
314 if ((p + slen) > end) {
325 if ((p >= end) || (*p ==
',')) {
384 while (isspace((
uint8_t) *p) && (p < end)) p++;
385 if (p >= end)
return end -
in;
429 if (p == end)
return p -
in;
441 if (slen <= 0)
return slen - (p -
in);
455 if ((p >= end) || (*p ==
','))
return p -
in;
471 pair_ctx->
parent = da->parent;
480 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.
int fr_pair_value_from_str(fr_pair_t *vp, char const *value, size_t inlen, fr_sbuff_unescape_rules_t const *uerules, UNUSED bool tainted)
Convert string value to native attribute value.
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.
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.
ssize_t fr_skip_string(char const *start, char const *end)
Skip a quoted string.
Stores an attribute, a value and various bits of other data.
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