[sr-dev] git:master:6fe9d152: htable: exported config functions to set value and item at once

Daniel-Constantin Mierla miconda at gmail.com
Tue Feb 1 17:25:55 CET 2022


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-02-01T11:20:39+01:00

htable: exported config functions to set value and item at once

- they were already available in kemi

---

Modified: src/modules/htable/htable.c

---

Diff:  https://github.com/kamailio/kamailio/commit/6fe9d1527d247d8d5ad926d2290dae3860a1d78a.diff
Patch: https://github.com/kamailio/kamailio/commit/6fe9d1527d247d8d5ad926d2290dae3860a1d78a.patch

---

diff --git a/src/modules/htable/htable.c b/src/modules/htable/htable.c
index 5599ffe0e6..6de38d57e9 100644
--- a/src/modules/htable/htable.c
+++ b/src/modules/htable/htable.c
@@ -84,6 +84,10 @@ static int w_ht_iterator_rm(struct sip_msg* msg, char* iname, char* foo);
 static int w_ht_iterator_sets(struct sip_msg* msg, char* iname, char* val);
 static int w_ht_iterator_seti(struct sip_msg* msg, char* iname, char* val);
 static int w_ht_iterator_setex(struct sip_msg* msg, char* iname, char* val);
+static int w_ht_setxs(sip_msg_t *msg, char *htname, char *itname,
+		char *itval, char *exval);
+static int w_ht_setxi(sip_msg_t *msg, char *htname, char *itname,
+		char *itval, char *exval);
 
 int ht_param(modparam_t type, void* val);
 
@@ -152,6 +156,10 @@ static cmd_export_t cmds[]={
 		fixup_free_spve_igp, ANY_ROUTE},
 	{"sht_iterator_setex",	(cmd_function)w_ht_iterator_setex,	2, fixup_spve_igp,
 		fixup_free_spve_igp, ANY_ROUTE},
+	{"sht_setxs",	(cmd_function)w_ht_setxs,	4, fixup_sssi,
+		fixup_free_sssi, ANY_ROUTE},
+	{"sht_setxi",	(cmd_function)w_ht_setxi,	4, fixup_ssii,
+		fixup_free_ssii, ANY_ROUTE},
 
 	{"bind_htable",     (cmd_function)bind_htable,     0, 0, 0,
 		ANY_ROUTE},
@@ -1302,6 +1310,37 @@ static int ki_ht_setxs(sip_msg_t *msg, str *htname, str *itname, str *itval,
 	return 1;
 }
 
+/**
+ *
+ */
+static int w_ht_setxs(sip_msg_t *msg, char *htname, char *itname,
+		char *itval, char *exval)
+{
+	str shtname;
+	str sitname;
+	str sitval;
+	int iexval;
+
+	if(fixup_get_svalue(msg, (gparam_t*)htname, &shtname)<0 || shtname.len<=0) {
+		LM_ERR("cannot get htable name\n");
+		return -1;
+	}
+	if(fixup_get_svalue(msg, (gparam_t*)itname, &sitname)<0 || sitname.len<=0) {
+		LM_ERR("cannot get item name\n");
+		return -1;
+	}
+	if(fixup_get_svalue(msg, (gparam_t*)itval, &sitval)<0) {
+		LM_ERR("cannot get item value\n");
+		return -1;
+	}
+	if(fixup_get_ivalue(msg, (gparam_t*)exval, &iexval)<0) {
+		LM_ERR("cannot get expire value\n");
+		return -1;
+	}
+
+	return ki_ht_setxs(msg, &shtname, &sitname, &sitval, iexval);
+}
+
 /**
  *
  */
@@ -1345,6 +1384,37 @@ static int ki_ht_setxi(sip_msg_t *msg, str *htname, str *itname, int itval,
 	return 0;
 }
 
+/**
+ *
+ */
+static int w_ht_setxi(sip_msg_t *msg, char *htname, char *itname,
+		char *itval, char *exval)
+{
+	str shtname;
+	str sitname;
+	int nitval;
+	int iexval;
+
+	if(fixup_get_svalue(msg, (gparam_t*)htname, &shtname)<0 || shtname.len<=0) {
+		LM_ERR("cannot get htable name\n");
+		return -1;
+	}
+	if(fixup_get_svalue(msg, (gparam_t*)itname, &sitname)<0 || sitname.len<=0) {
+		LM_ERR("cannot get item name\n");
+		return -1;
+	}
+	if(fixup_get_ivalue(msg, (gparam_t*)itval, &nitval)<0) {
+		LM_ERR("cannot get item value\n");
+		return -1;
+	}
+	if(fixup_get_ivalue(msg, (gparam_t*)exval, &iexval)<0) {
+		LM_ERR("cannot get expire value\n");
+		return -1;
+	}
+
+	return ki_ht_setxi(msg, &shtname, &sitname, nitval, iexval);
+}
+
 #define KSR_HT_KEMI_NOINTVAL -255
 static ht_cell_t *_htc_ki_local=NULL;
 




More information about the sr-dev mailing list