30 RCSID(
"$Id: d133e58a1390dc449109aa2a2c2c13cdbb3f25b4 $")
32 #include <freeradius-devel/server/paircmp.h>
33 #include <freeradius-devel/server/regex.h>
34 #include <freeradius-devel/server/request.h>
35 #include <freeradius-devel/unlang/xlat.h>
36 #include <freeradius-devel/util/debug.h>
68 REDEBUG(
"Non-Unary operations require two operands");
77 fr_regmatch_t *regmatch;
79 char *expr = NULL, *
value = NULL;
80 char const *expr_p, *value_p;
83 expr_p =
check->vp_strvalue;
90 value_p =
vp->vp_strvalue;
96 if (!expr_p || !value_p) {
97 REDEBUG(
"Error stringifying operand for regular expression");
109 slen = regex_compile(request, &preg, expr_p, talloc_array_length(expr_p) - 1,
117 subcaptures = regex_subcapture_count(preg);
118 if (!subcaptures) subcaptures = REQUEST_MAX_REGEX + 1;
119 MEM(regmatch = regex_match_data_alloc(NULL, subcaptures));
124 slen = regex_exec(preg, value_p, talloc_array_length(value_p) - 1, regmatch);
135 regex_sub_to_request(request, &preg, ®match);
136 ret = (slen == 1) ? 0 : -1;
138 ret = (slen != 1) ? 0 : -1;
158 if (
vp->vp_type !=
check->vp_type)
return -1;
163 switch (
check->vp_type) {
165 if (
vp->vp_length !=
check->vp_length) {
169 ret = memcmp(
vp->vp_strvalue,
check->vp_strvalue,
vp->vp_length);
173 ret = strcmp(
vp->vp_strvalue,
check->vp_strvalue);
177 ret =
vp->vp_uint8 -
check->vp_uint8;
181 ret =
vp->vp_uint16 -
check->vp_uint16;
185 ret =
vp->vp_uint32 -
check->vp_uint32;
192 if (
vp->vp_uint64 <
check->vp_uint64) {
194 }
else if (
vp->vp_uint64 >
check->vp_uint64) {
210 ret = ntohl(
vp->vp_ipv4addr) - ntohl(
check->vp_ipv4addr);
214 ret = memcmp(
vp->vp_ip.addr.v6.s6_addr,
check->vp_ip.addr.v6.s6_addr,
215 sizeof(
vp->vp_ip.addr.v6.s6_addr));
221 if (ret == -1)
return -2;
223 ret = (ret == 1) ? -1 : 1;
225 ret = (ret == 1) ? 1 : -1;
227 ret = (ret == 1) ? 0 : -1;
231 ret = memcmp(
vp->vp_ifid,
check->vp_ifid,
sizeof(
vp->vp_ifid));
239 if (ret > 0)
return 1;
240 if (ret < 0)
return -1;
#define CMP(_a, _b)
Same as CMP_PREFER_SMALLER use when you don't really care about ordering, you just want an ordering.
#define REMARKER(_str, _marker_idx, _marker,...)
Output string with error marker, showing where format error occurred.
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_INT32
32 Bit signed integer.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_IPV4_PREFIX
IPv4 Prefix.
@ FR_TYPE_IFID
Interface ID.
@ FR_TYPE_OCTETS
Raw octets.
int paircmp_pairs(UNUSED request_t *request, fr_pair_t const *check, fr_pair_t *vp)
Compares check and vp by value.
#define check(_handle, _len_p)
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
Stores an attribute, a value and various bits of other data.
static int8_t fr_unix_time_cmp(fr_unix_time_t a, fr_unix_time_t b)
Compare two fr_unix_time_t values.
#define fr_pair_cmp_op(_op, _a, _b)
Compare two attributes using and operator.
char const * fr_strerror(void)
Get the last library error.
static fr_slen_t fr_value_box_aprint(TALLOC_CTX *ctx, char **out, fr_value_box_t const *data, fr_sbuff_escape_rules_t const *e_rules) 1(fr_value_box_print