... | ... |
@@ -577,7 +577,7 @@ inline static int comp_num(int op, long left, int rtype, union exp_op* r) |
577 | 577 |
if (avp && !(avp->flags & AVP_VAL_STR)) right = val.n; |
578 | 578 |
else return 0; /* Always fail */ |
579 | 579 |
} else if (rtype == NUMBER_ST) { |
580 |
- right = r->intval; |
|
580 |
+ right = r->numval; |
|
581 | 581 |
} else { |
582 | 582 |
LOG(L_CRIT, "BUG: comp_num: Invalid right operand (%d)\n", rtype); |
583 | 583 |
return E_BUG; |
... | ... |
@@ -759,6 +759,7 @@ inline static int comp_avp(int op, avp_spec_t* spec, int rtype, union exp_op* r, |
759 | 759 |
int_str val; |
760 | 760 |
union exp_op num_val; |
761 | 761 |
str tmp; |
762 |
+ unsigned int uval; |
|
762 | 763 |
|
763 | 764 |
if (spec->type & AVP_INDEX_ALL) { |
764 | 765 |
avp = search_first_avp(spec->type & ~AVP_INDEX_ALL, spec->name, NULL, NULL); |
... | ... |
@@ -777,11 +778,11 @@ inline static int comp_avp(int op, avp_spec_t* spec, int rtype, union exp_op* r, |
777 | 778 |
break; |
778 | 779 |
|
779 | 780 |
case BINOR_OP: |
780 |
- return (val.n | r->intval)!=0; |
|
781 |
+ return (val.n | r->numval)!=0; |
|
781 | 782 |
break; |
782 | 783 |
|
783 | 784 |
case BINAND_OP: |
784 |
- return (val.n & r->intval)!=0; |
|
785 |
+ return (val.n & r->numval)!=0; |
|
785 | 786 |
break; |
786 | 787 |
} |
787 | 788 |
|
... | ... |
@@ -794,18 +795,20 @@ inline static int comp_avp(int op, avp_spec_t* spec, int rtype, union exp_op* r, |
794 | 795 |
case STRING_ST: |
795 | 796 |
tmp.s=r->string; |
796 | 797 |
tmp.len=strlen(r->string); |
797 |
- if (str2int(&tmp, (unsigned int*)&num_val.intval)<0){ |
|
798 |
+ if (str2int(&tmp, &uval)<0){ |
|
798 | 799 |
LOG(L_ERR, "ERROR: comp_avp: cannot convert string value" |
799 | 800 |
" to int (%s)\n", ZSW(r->string)); |
800 | 801 |
return -1; |
801 | 802 |
} |
803 |
+ num_val.numval=uval; |
|
802 | 804 |
return comp_num(op, val.n, NUMBER_ST, &num_val); |
803 | 805 |
case STR_ST: |
804 |
- if (str2int(&r->str, (unsigned int*)&num_val.intval)<0){ |
|
806 |
+ if (str2int(&r->str, &uval)<0){ |
|
805 | 807 |
LOG(L_ERR, "ERROR: comp_avp: cannot convert str value" |
806 | 808 |
" to int (%.*s)\n", r->str.len, ZSW(r->str.s)); |
807 | 809 |
return -1; |
808 | 810 |
} |
811 |
+ num_val.numval=uval; |
|
809 | 812 |
return comp_num(op, val.n, NUMBER_ST, &num_val); |
810 | 813 |
default: |
811 | 814 |
LOG(L_CRIT, "BUG: comp_avp: invalid type for numeric avp " |
... | ... |
@@ -1064,7 +1067,7 @@ inline static int eval_elem(struct run_act_ctx* h, struct expr* e, |
1064 | 1067 |
break; |
1065 | 1068 |
|
1066 | 1069 |
case NUMBER_O: |
1067 |
- ret=!(!e->r.intval); /* !! to transform it in {0,1} */ |
|
1070 |
+ ret=!(!e->r.numval); /* !! to transform it in {0,1} */ |
|
1068 | 1071 |
break; |
1069 | 1072 |
|
1070 | 1073 |
case ACTION_O: |
... | ... |
@@ -101,15 +101,15 @@ enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST, |
101 | 101 |
|
102 | 102 |
/* Expression operand */ |
103 | 103 |
union exp_op { |
104 |
+ void* param; |
|
105 |
+ long numval; /* must have the same size as a void*/ |
|
104 | 106 |
struct expr* expr; |
105 |
- struct _str str; |
|
106 | 107 |
char* string; |
107 |
- void* param; |
|
108 |
- int intval; |
|
109 | 108 |
avp_spec_t* attr; |
110 | 109 |
select_t* select; |
111 | 110 |
regex_t* re; |
112 | 111 |
struct net* net; |
112 |
+ struct _str str; |
|
113 | 113 |
}; |
114 | 114 |
|
115 | 115 |
struct expr{ |