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 ret =
CMP(
vp->vp_length, check->vp_length);
163 if (ret != 0)
return ret;
165 return CMP(memcmp(
vp->vp_strvalue, check->vp_strvalue,
vp->vp_length), 0);
168 return CMP(strcmp(
vp->vp_strvalue, check->vp_strvalue), 0);
171 return CMP(
vp->vp_uint8, check->vp_uint8);
174 return CMP(
vp->vp_uint16, check->vp_uint16);
177 return CMP(
vp->vp_uint32, check->vp_uint32);
180 return CMP(
vp->vp_uint64, check->vp_uint64);
183 return CMP(
vp->vp_int32, check->vp_int32);
189 return CMP(ntohl(
vp->vp_ipv4addr), ntohl(check->vp_ipv4addr));
192 return CMP(memcmp(
vp->vp_ip.addr.v6.s6_addr, check->vp_ip.addr.v6.s6_addr,
193 sizeof(
vp->vp_ip.addr.v6.s6_addr)), 0);
198 if (ret == -1)
return -2;
200 ret = (ret == 1) ? -1 : 1;
202 ret = (ret == 1) ? 1 : -1;
204 ret = (ret == 1) ? 0 : -1;
208 return CMP(memcmp(
vp->vp_ifid, check->vp_ifid,
sizeof(
vp->vp_ifid)), 0);
215 if (ret > 0)
return 1;
216 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