65 REDEBUG(
"Non-Unary operations require two operands");
74 fr_regmatch_t *regmatch;
76 char *expr = NULL, *
value = NULL;
77 char const *expr_p, *value_p;
80 expr_p = check->vp_strvalue;
87 value_p =
vp->vp_strvalue;
93 if (!expr_p || !value_p) {
94 REDEBUG(
"Error stringifying operand for regular expression");
106 slen = regex_compile(request, &preg, expr_p, talloc_array_length(expr_p) - 1,
114 subcaptures = regex_subcapture_count(preg);
115 if (!subcaptures) subcaptures = REQUEST_MAX_REGEX + 1;
116 MEM(regmatch = regex_match_data_alloc(NULL, subcaptures));
121 slen = regex_exec(preg, value_p, talloc_array_length(value_p) - 1, regmatch);
132 regex_sub_to_request(request, &preg, ®match, &
vp->data);
133 ret = (slen == 1) ? 0 : -1;
135 ret = (slen != 1) ? 0 : -1;
155 if (
vp->vp_type != check->vp_type)
return -1;
160 switch (check->vp_type) {
162 if (
vp->vp_length != check->vp_length) {
166 ret = memcmp(
vp->vp_strvalue, check->vp_strvalue,
vp->vp_length);
170 ret = strcmp(
vp->vp_strvalue, check->vp_strvalue);
174 ret =
vp->vp_uint8 - check->vp_uint8;
178 ret =
vp->vp_uint16 - check->vp_uint16;
182 ret =
vp->vp_uint32 - check->vp_uint32;
189 if (
vp->vp_uint64 < check->vp_uint64) {
191 }
else if (
vp->vp_uint64 > check->vp_uint64) {
199 ret =
CMP(
vp->vp_int32, check->vp_int32);
207 ret = ntohl(
vp->vp_ipv4addr) - ntohl(check->vp_ipv4addr);
211 ret = memcmp(
vp->vp_ip.addr.v6.s6_addr, check->vp_ip.addr.v6.s6_addr,
212 sizeof(
vp->vp_ip.addr.v6.s6_addr));
218 if (ret == -1)
return -2;
220 ret = (ret == 1) ? -1 : 1;
222 ret = (ret == 1) ? 1 : -1;
224 ret = (ret == 1) ? 0 : -1;
228 ret = memcmp(
vp->vp_ifid, check->vp_ifid,
sizeof(
vp->vp_ifid));
236 if (ret > 0)
return 1;
237 if (ret < 0)
return -1;
#define REMARKER(_str, _marker_idx, _marker,...)
Output string with error marker, showing where format error occurred.
int paircmp_pairs(UNUSED request_t *request, fr_pair_t const *check, fr_pair_t *vp)
Compares check and vp by value.
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