SIP-router core :: rvalue expressionsModule: SIP-router core. More...
#include "str.h"#include "ut.h"#include "usr_avp.h"#include "select.h"#include "pvar.h"#include "route.h"#include "parser/msg_parser.h"#include "action.h"

Go to the source code of this file.
Definition in file rvalue.h.
| enum rval_expr_op |
| int fix_rval_expr | ( | void * | p | ) |
fixes action, bexprs, resolves selects, pvars and optimizes simple sub expressions (e.g. 1+2).
| p | - pointer to a rval_expr |
Definition at line 3778 of file rvalue.c.
Referenced by fix_match_rve().

| struct rval_expr* mk_rval_expr1 | ( | enum rval_expr_op | op, | |
| struct rval_expr * | rve1, | |||
| struct cfg_pos * | pos | |||
| ) | [read] |
rval_expr ret= op rve1
| op | - rval expr. unary operator | |
| rve1 | - rval expr. on which the operator will act. | |
| pos | configuration position |
Definition at line 2591 of file rvalue.c.
References RVE_BNOT_OP, RVE_BOOL_OP, RVE_DEFINED_OP, RVE_INT_OP, RVE_LNOT_OP, RVE_STR_OP, RVE_STREMPTY_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.
| struct rval_expr* mk_rval_expr2 | ( | enum rval_expr_op | op, | |
| struct rval_expr * | rve1, | |||
| struct rval_expr * | rve2, | |||
| struct cfg_pos * | pos | |||
| ) | [read] |
from 2 other rval exprs, using op ret = rve1 op rve2
| op | - rval expr. operator | |
| rve1 | - rval expr. on which the operator will act. | |
| rve2 | - rval expr. on which the operator will act. | |
| pos | configuration position |
Definition at line 2632 of file rvalue.c.
References RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, RVE_CONCAT_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, RVE_IDIFF_OP, RVE_IEQ_OP, RVE_IPLUS_OP, RVE_LAND_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_PLUS_OP, RVE_STRDIFF_OP, and RVE_STREQ_OP.
| struct rval_expr* mk_rval_expr_v | ( | enum rval_type | rv_type, | |
| void * | val, | |||
| struct cfg_pos * | pos | |||
| ) | [read] |
create a RVE_RVAL_OP rval_expr, containing a single rval of the given type
| rv_type | - rval type | |
| val | - rval value | |
| pos | - config position |
Definition at line 2526 of file rvalue.c.
References rval_init().

| struct rvalue* rval_convert | ( | struct run_act_ctx * | h, | |
| struct sip_msg * | msg, | |||
| enum rval_type | type, | |||
| struct rvalue * | v, | |||
| struct rval_cache * | c | |||
| ) | [read] |
Convert a rvalue to another rvalue, of a specific type. The result is read-only in most cases (can be a reference to another rvalue, can be checked by using rv_chg_in_place()) and _must_ be rval_destroy()'ed.
| h | run action context | |
| msg | SIP mesasge | |
| type | - type to convert to | |
| v | - rvalue to convert | |
| c | - rval_cache (cached v value if known/filled by another function), can be 0 (unknown/not needed) |
Definition at line 1294 of file rvalue.c.
References rval_cache_clean(), rval_cache_init, rval_get_int(), rval_get_tmp_str(), rval_new(), and rval_new_str().
Referenced by rval_expr_eval(), rval_int_strop1(), rval_intop1(), rval_intop2(), rval_str_add2(), and rval_str_lop2().


| void rval_destroy | ( | struct rvalue * | rv | ) |
frees a rval_new(), rval_convert() or rval_expr_eval() returned rval.
Note: it will be freed only when refcnt reaches 0
Definition at line 130 of file rvalue.c.
References RV_RE_F, RV_RV_ALLOCED_F, and rv_unref.
Referenced by exp_optimize_left(), exp_optimize_right(), fix_match(), fix_match_rve(), lval_assign(), rval_expr_eval(), rval_expr_eval_int(), rval_expr_eval_new(), rval_expr_eval_rvint(), rval_int_strop1(), rval_intop1(), rval_intop2(), rval_str_add2(), rval_str_lop2(), rve_destroy(), rve_opt_01(), and rve_replace_with_val().

| struct rvalue* rval_expr_eval | ( | struct run_act_ctx * | h, | |
| struct sip_msg * | msg, | |||
| struct rval_expr * | rve | |||
| ) | [read] |
| h | run action context | |
| msg | SIP message | |
| rve | rvalue expression |
Definition at line 2314 of file rvalue.c.
References int_intop2(), rval_cache_clean(), rval_cache_init, rval_convert(), rval_destroy(), rval_expr_eval(), rval_expr_eval_int(), rval_get_btype(), rval_get_int(), rval_get_int_handle_ret, rval_new(), rval_str_add2(), RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BNOT_OP, RVE_BOOL_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, RVE_CONCAT_OP, RVE_DEFINED_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, RVE_IDIFF_OP, RVE_IEQ_OP, RVE_INT_OP, RVE_IPLUS_OP, RVE_LAND_OP, RVE_LNOT_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_NONE_OP, RVE_PLUS_OP, RVE_RVAL_OP, RVE_STR_OP, RVE_STRDIFF_OP, RVE_STREMPTY_OP, RVE_STREQ_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.
Referenced by fix_match(), fix_match_rve(), lval_assign(), rval_expr_eval(), rval_expr_eval_int(), rval_expr_eval_new(), and rval_expr_eval_rvint().


| int rval_expr_eval_int | ( | struct run_act_ctx * | h, | |
| struct sip_msg * | msg, | |||
| int * | res, | |||
| struct rval_expr * | rve | |||
| ) |
*res=(int)eval(rve)
Definition at line 1903 of file rvalue.c.
References int_intop1(), int_intop2(), int_rve_defined(), rval_cache_clean(), rval_cache_init, rval_destroy(), rval_expr_eval(), rval_expr_eval_int(), rval_expr_eval_rvint(), rval_get_int(), rval_get_int_handle_ret, rval_int_strop1(), rval_str_lop2(), RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BNOT_OP, RVE_BOOL_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, RVE_CONCAT_OP, RVE_DEFINED_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, RVE_IDIFF_OP, RVE_IEQ_OP, RVE_INT_OP, RVE_IPLUS_OP, RVE_LAND_OP, RVE_LNOT_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_NONE_OP, RVE_PLUS_OP, RVE_RVAL_OP, RVE_STR_OP, RVE_STRDIFF_OP, RVE_STREMPTY_OP, RVE_STREQ_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.
Referenced by fix_switch(), rval_expr_eval(), rval_expr_eval_int(), and rval_expr_eval_rvint().


| int rval_expr_eval_rvint | ( | struct run_act_ctx * | h, | |
| struct sip_msg * | msg, | |||
| struct rvalue ** | res_rv, | |||
| int * | res_i, | |||
| struct rval_expr * | rve, | |||
| struct rval_cache * | cache | |||
| ) |
| h | run action context | |
| msg | SIP message | |
| res_rv | pointer to rvalue result, if non-null it means the expression evaluated to a non-int (str), which will be stored here. | |
| res_i | pointer to int result, if res_rv==0 and the function returns success => the result is an int which will be stored here. | |
| rve | expression that will be evaluated. | |
| cache | write-only value cache, it might be filled if non-null and empty (rval_cache_init()). If non-null, it _must_ be rval_cache_clean()'ed when done. |
Definition at line 2169 of file rvalue.c.
References int_intop2(), rval_cache_clean(), rval_cache_init, rval_destroy(), rval_expr_eval(), rval_expr_eval_int(), rval_expr_eval_rvint(), rval_get_btype(), rval_get_int(), rval_get_int_handle_ret, rval_str_add2(), RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BNOT_OP, RVE_BOOL_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, RVE_CONCAT_OP, RVE_DEFINED_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, RVE_IDIFF_OP, RVE_IEQ_OP, RVE_INT_OP, RVE_IPLUS_OP, RVE_LAND_OP, RVE_LNOT_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_NONE_OP, RVE_PLUS_OP, RVE_RVAL_OP, RVE_STR_OP, RVE_STRDIFF_OP, RVE_STREMPTY_OP, RVE_STREQ_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.
Referenced by rval_expr_eval_int(), and rval_expr_eval_rvint().


| int rval_get_int | ( | struct run_act_ctx * | h, | |
| struct sip_msg * | msg, | |||
| int * | i, | |||
| struct rvalue * | rv, | |||
| struct rval_cache * | cache | |||
| ) |
*i=(int)rv if rv == undefined select, avp or pvar, return 0. if an error occurs while evaluating a select, avp or pvar, behave as for the undefined case (and return success).
| h | - script context handle | |
| msg | - sip msg | |
| i | - pointer to int, where the conversion result will be stored | |
| rv | - rvalue to be converted | |
| cache | - cached rv value (read-only), can be 0 |
Definition at line 889 of file rvalue.c.
References rval_cache::avp_val, _str::len, rval_cache::pval, run_actions_safe(), and _str::s.
Referenced by rval_convert(), rval_expr_eval(), rval_expr_eval_int(), rval_expr_eval_rvint(), and rve_replace_with_ct_rv().


| int rval_get_str | ( | struct run_act_ctx * | h, | |
| struct sip_msg * | msg, | |||
| str * | s, | |||
| struct rvalue * | rv, | |||
| struct rval_cache * | cache | |||
| ) |
*s=(str)rv The result is pkg malloc'ed (so it should be pkg_free()'ed when finished.
Definition at line 1250 of file rvalue.c.
References _str::len, rval_cache_clean(), rval_cache_init, rval_get_tmp_str(), and _str::s.
Referenced by fix_match(), fix_match_rve(), and rve_replace_with_ct_rv().


| int rval_get_tmp_str | ( | struct run_act_ctx * | h, | |
| struct sip_msg * | msg, | |||
| str * | tmpv, | |||
| struct rvalue * | rv, | |||
| struct rval_cache * | cache, | |||
| struct rval_cache * | tmp_cache | |||
| ) |
get the string value of an rv in a tmp variable
if an error occurs while evaluating a select, avp or pvar, behave as for the undefined case (and return success). The result points either inside the passed rv, inside new_cache or inside an avp. new_cache must be non zero, initialized previously and it _must_ be rval_cache_clean(...)'ed when done. WARNING: it's not intended for general use. It might return a pointer inside rv so the result _must_ be treated as read-only. rv and new_cache must not be released/freed until the result is no longer needed. For general use see rval_get_str().
| h | - script context handle | |
| msg | - sip msg | |
| tmpv | - str return value (pointer to a str struct that will be be filled with the conversion result) | |
| rv | - rvalue to be converted | |
| cache | - cached rv value (read-only), can be 0 | |
| tmp_cache | - used for temporary storage (so that tmpv will not point to possible freed data), it must be non-null, initialized and cleaned afterwards. |
Definition at line 1102 of file rvalue.c.
References rval_cache::avp_val, rval_cache::i2s, _str::len, rval_cache::pval, run_actions_safe(), _str::s, and sint2strbuf().
Referenced by rval_convert(), and rval_get_str().


| void rval_init | ( | struct rvalue * | rv, | |
| enum rval_type | t, | |||
| union rval_val * | v, | |||
| int | flags | |||
| ) |
inits a rvalue structure-
Note: not needed if the structure is allocate with one of the rval_new* functions
Definition at line 208 of file rvalue.c.
Referenced by mk_rval_expr_v(), and rve_replace_with_val().

| struct rvalue* rval_new | ( | enum rval_type | t, | |
| union rval_val * | v, | |||
| int | extra_size | |||
| ) | [read] |
| t | rvalue type | |
| v | rvalue value | |
| extra_size | extra space to allocate (so that future string operation can reuse the space) |
Definition at line 351 of file rvalue.c.
References rval_new_empty(), and rval_new_str().
Referenced by rval_convert(), rval_expr_eval(), rval_expr_eval_new(), rval_intop1(), rval_intop2(), and rval_str_add2().


| struct rvalue* rval_new_empty | ( | int | extra_size | ) | [read] |
allocates a new rval (should be freed by rval_destroy()).
| extra_size | - extra space to allocate (e.g.: so that future string operation can reuse the space) |
Definition at line 230 of file rvalue.c.
Referenced by rval_new(), rval_new_re(), and rval_new_str().

| struct rvalue* rval_new_str | ( | str * | s, | |
| int | extra_size | |||
| ) | [read] |
| s | - pointer to str, must be non-null | |
| extra_size | - extra space to allocate (so that future string operation can reuse the space) |
Definition at line 256 of file rvalue.c.
References _str::len, rval_new_empty(), and _str::s.
Referenced by rval_convert(), and rval_new().


| char* rval_type_name | ( | enum rval_type | type | ) |
| int rve_check_type | ( | enum rval_type * | type, | |
| struct rval_expr * | rve, | |||
| struct rval_expr ** | bad_rve, | |||
| enum rval_type * | bad_t, | |||
| enum rval_type * | exp_t | |||
| ) |
| type | filled with the type of the expression (RV_INT, RV_STR or RV_NONE if it's dynamic) | |
| rve | checked expression | |
| bad_rve | set on failure to the subexpression for which the type check failed | |
| bad_t | set on failure to the type of the bad subexpression | |
| exp_t | set on failure to the expected type for the bad subexpression |
Definition at line 690 of file rvalue.c.
References RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BNOT_OP, RVE_BOOL_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, rve_check_type(), RVE_CONCAT_OP, RVE_DEFINED_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, rve_guess_type(), RVE_IDIFF_OP, RVE_IEQ_OP, RVE_INT_OP, RVE_IPLUS_OP, RVE_LAND_OP, RVE_LNOT_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_NONE_OP, RVE_PLUS_OP, RVE_RVAL_OP, RVE_STR_OP, RVE_STRDIFF_OP, RVE_STREMPTY_OP, RVE_STREQ_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.
Referenced by rve_check_type().


| void rve_destroy | ( | struct rval_expr * | rve | ) |
Definition at line 156 of file rvalue.c.
References rval_destroy(), rve_destroy(), and RVE_RVAL_OP.
Referenced by fix_match(), fix_switch(), rve_destroy(), rve_opt_01(), and rve_replace_with_val().


| enum rval_type rve_guess_type | ( | struct rval_expr * | rve | ) |
Definition at line 482 of file rvalue.c.
References RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BNOT_OP, RVE_BOOL_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, RVE_CONCAT_OP, RVE_DEFINED_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, rve_guess_type(), RVE_IDIFF_OP, RVE_IEQ_OP, RVE_INT_OP, RVE_IPLUS_OP, RVE_LAND_OP, RVE_LNOT_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_NONE_OP, RVE_PLUS_OP, RVE_RVAL_OP, RVE_STR_OP, RVE_STRDIFF_OP, RVE_STREMPTY_OP, RVE_STREQ_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.
Referenced by fix_match_rve(), rve_check_type(), and rve_guess_type().


| int rve_has_side_effects | ( | struct rval_expr * | rve | ) |
returns true if the expression can have side-effect
Definition at line 617 of file rvalue.c.
References rve_is_constant().
Referenced by fix_match(), and fix_switch().


| int rve_is_constant | ( | struct rval_expr * | rve | ) |
Definition at line 550 of file rvalue.c.
References RVE_BAND_OP, RVE_BLSHIFT_OP, RVE_BNOT_OP, RVE_BOOL_OP, RVE_BOR_OP, RVE_BRSHIFT_OP, RVE_BXOR_OP, RVE_CONCAT_OP, RVE_DEFINED_OP, RVE_DIFF_OP, RVE_DIV_OP, RVE_EQ_OP, RVE_GT_OP, RVE_GTE_OP, RVE_IDIFF_OP, RVE_IEQ_OP, RVE_INT_OP, RVE_IPLUS_OP, rve_is_constant(), RVE_LAND_OP, RVE_LNOT_OP, RVE_LOR_OP, RVE_LT_OP, RVE_LTE_OP, RVE_MATCH_OP, RVE_MINUS_OP, RVE_MOD_OP, RVE_MUL_OP, RVE_NONE_OP, RVE_PLUS_OP, RVE_RVAL_OP, RVE_STR_OP, RVE_STRDIFF_OP, RVE_STREMPTY_OP, RVE_STREQ_OP, RVE_STRLEN_OP, and RVE_UMINUS_OP.
Referenced by fix_match(), fix_match_rve(), fix_switch(), rve_has_side_effects(), rve_is_constant(), and rve_opt_01().


1.7.1