[sr-dev] git:master:b7dc2ac6: dialog: wrapper function to set a dlg var with unsigned integer parameter

Daniel-Constantin Mierla miconda at gmail.com
Thu Sep 1 10:51:31 CEST 2022


Module: kamailio
Branch: master
Commit: b7dc2ac6d66839b38ba8d6f36e9f28bc0a2d1425
URL: https://github.com/kamailio/kamailio/commit/b7dc2ac6d66839b38ba8d6f36e9f28bc0a2d1425

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-09-01T10:50:30+02:00

dialog: wrapper function to set a dlg var with unsigned integer parameter

- use it to set cseq diff value

---

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/b7dc2ac6d66839b38ba8d6f36e9f28bc0a2d1425.diff
Patch: https://github.com/kamailio/kamailio/commit/b7dc2ac6d66839b38ba8d6f36e9f28bc0a2d1425.patch

---

diff --git a/src/modules/dialog/dlg_cseq.c b/src/modules/dialog/dlg_cseq.c
index e5555441fe..d5ffe20c85 100644
--- a/src/modules/dialog/dlg_cseq.c
+++ b/src/modules/dialog/dlg_cseq.c
@@ -173,8 +173,7 @@ int dlg_cseq_update(sip_msg_t *msg)
 		LM_DBG("nothing to increment\n");
 		goto done;
 	}
-	nval.s = int2str(vinc, &nval.len);
-	if(set_dlg_variable(dlg, &_dlg_cseq_diff_var_name, &nval) <0) {
+	if(set_dlg_variable_uintval(dlg, &_dlg_cseq_diff_var_name, vinc) <0) {
 		LM_ERR("failed to set the dlg cseq diff var\n");
 		goto done;
 	}
diff --git a/src/modules/dialog/dlg_var.c b/src/modules/dialog/dlg_var.c
index 04e48fa636..6c4da06742 100644
--- a/src/modules/dialog/dlg_var.c
+++ b/src/modules/dialog/dlg_var.c
@@ -378,6 +378,18 @@ int set_dlg_variable(struct dlg_cell *dlg, str *key, str *val)
     return ret;
 }
 
+int set_dlg_variable_uintval(struct dlg_cell *dlg, str *key, unsigned int uval)
+{
+	str sval = STR_NULL;
+
+	sval.s = int2str(uval, &sval.len);
+	if(sval.s==NULL) {
+		return -1;
+	}
+
+	return set_dlg_variable(dlg, key, &sval);
+}
+
 int pv_get_dlg_variable(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
 {
 	dlg_cell_t *dlg;
diff --git a/src/modules/dialog/dlg_var.h b/src/modules/dialog/dlg_var.h
index 70579810bf..a4b497dbd7 100644
--- a/src/modules/dialog/dlg_var.h
+++ b/src/modules/dialog/dlg_var.h
@@ -63,6 +63,7 @@ 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 set_dlg_variable_uintval(struct dlg_cell *dlg, str *key, unsigned int uval);
 
 int pv_parse_dialog_var_name(pv_spec_p sp, str *in);
 




More information about the sr-dev mailing list