Module: kamailio Branch: master Commit: a070f5c132a68111fade7212db6a2bc738e03193 URL: https://github.com/kamailio/kamailio/commit/a070f5c132a68111fade7212db6a2bc7...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2022-08-30T13:19:33+02:00
dialog: updated to get the int value for cseq update operations
---
Modified: src/modules/dialog/dlg_cseq.c Modified: src/modules/dialog/dlg_var.c Modified: src/modules/dialog/dlg_var.h
---
Diff: https://github.com/kamailio/kamailio/commit/a070f5c132a68111fade7212db6a2bc7... Patch: https://github.com/kamailio/kamailio/commit/a070f5c132a68111fade7212db6a2bc7...
---
diff --git a/src/modules/dialog/dlg_cseq.c b/src/modules/dialog/dlg_cseq.c index 70b2b43c2b..c81cf904d4 100644 --- a/src/modules/dialog/dlg_cseq.c +++ b/src/modules/dialog/dlg_cseq.c @@ -211,7 +211,6 @@ int dlg_cseq_refresh(sip_msg_t *msg, dlg_cell_t *dlg, unsigned int ninc = 0; unsigned int vinc = 0; str nval; - str *pval; sr_cfgenv_t *cenv = NULL;
if(dlg_cseq_prepare_msg(msg)!=0) { @@ -236,18 +235,12 @@ int dlg_cseq_refresh(sip_msg_t *msg, dlg_cell_t *dlg, goto done; }
- /* get dialog variable holding cseq diff */ - pval = get_dlg_variable(dlg, &_dlg_cseq_diff_var_name); - if(pval==NULL || pval->s==NULL || pval->len<=0) { + /* get the value of the dialog variable holding cseq diff */ + if(get_dlg_variable_uintval(dlg, &_dlg_cseq_diff_var_name, &vinc) < 0) { LM_DBG("dialog marked with cseq diff but no variable set yet\n"); goto done; }
- if(str2int(pval, &vinc)<0) { - LM_ERR("invalid dlg cseq diff var value: %.*s\n", - pval->len, pval->s); - goto done; - } if(vinc==0) { LM_DBG("nothing to increment\n"); goto done; diff --git a/src/modules/dialog/dlg_var.c b/src/modules/dialog/dlg_var.c index b2a373a501..cd151fd115 100644 --- a/src/modules/dialog/dlg_var.c +++ b/src/modules/dialog/dlg_var.c @@ -297,6 +297,34 @@ str * get_dlg_variable(struct dlg_cell *dlg, str *key) return var; }
+int get_dlg_variable_uintval(struct dlg_cell *dlg, str *key, unsigned int *uval) +{ + str* var = NULL; + + if( !dlg || !key || key->len <=0 || !uval) { + LM_ERR("BUG - bad parameters\n"); + return -1; + } + + dlg_lock(d_table, &(d_table->entries[dlg->h_entry])); + var = get_dlg_variable_unsafe(dlg, key); + if(var==NULL || var->s==NULL || var->len<=0) { + LM_DBG("no variable set yet\n"); + goto error; + } + if(str2int(var, uval)<0) { + LM_ERR("invalid unsingned int value: %.*s\n", + var->len, var->s); + goto error; + } + dlg_unlock(d_table, &(d_table->entries[dlg->h_entry])); + return 0; + +error: + dlg_unlock(d_table, &(d_table->entries[dlg->h_entry])); + return -1; +} + int set_dlg_variable(struct dlg_cell *dlg, str *key, str *val) { int ret = -1; diff --git a/src/modules/dialog/dlg_var.h b/src/modules/dialog/dlg_var.h index f13fa458d3..70579810bf 100644 --- a/src/modules/dialog/dlg_var.h +++ b/src/modules/dialog/dlg_var.h @@ -62,6 +62,8 @@ typedef struct dlg_var { str* get_dlg_variable(dlg_cell_t *dlg, str *key); int set_dlg_variable(dlg_cell_t *dlg, str *key, str *val);
+int get_dlg_variable_uintval(struct dlg_cell *dlg, str *key, unsigned int *uval); + int pv_parse_dialog_var_name(pv_spec_p sp, str *in);
int pv_get_dlg_variable(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);