[sr-dev] git:master:63fc16e7: corex: functions to manage extended flags

Daniel-Constantin Mierla miconda at gmail.com
Wed Mar 14 13:04:31 CET 2018


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-03-14T13:02:16+01:00

corex: functions to manage extended flags

- setxflag(idx), resetxflag(idx), isxflagset(idx)
- idx can be between 0 and 63
- requested via GH #1288

---

Modified: src/modules/corex/corex_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/63fc16e77ade9c682ec8489269517f4a5e77a999.diff
Patch: https://github.com/kamailio/kamailio/commit/63fc16e77ade9c682ec8489269517f4a5e77a999.patch

---

diff --git a/src/modules/corex/corex_mod.c b/src/modules/corex/corex_mod.c
index 58a87e0c48..d80004dd05 100644
--- a/src/modules/corex/corex_mod.c
+++ b/src/modules/corex/corex_mod.c
@@ -46,6 +46,9 @@ static int w_msg_iflag_reset(sip_msg_t *msg, char *pflag, char *p2);
 static int w_msg_iflag_is_set(sip_msg_t *msg, char *pflag, char *p2);
 static int w_file_read(sip_msg_t *msg, char *fn, char *vn);
 static int w_file_write(sip_msg_t *msg, char *fn, char *vn);
+static int w_isxflagset(struct sip_msg *msg, char *flag, str *s2);
+static int w_resetxflag(struct sip_msg *msg, char *flag, str *s2);
+static int w_setxflag(struct sip_msg *msg, char *flag, char *s2);
 
 static int fixup_file_op(void** param, int param_no);
 
@@ -91,6 +94,12 @@ static cmd_export_t cmds[]={
 		0, ANY_ROUTE },
 	{"file_write", (cmd_function)w_file_write, 2, fixup_spve_spve,
 		0, ANY_ROUTE },
+	{"setxflag", (cmd_function)w_setxflag,          1,fixup_igp_null,
+		0, ANY_ROUTE },
+	{"resetxflag", (cmd_function)w_resetxflag,      1,fixup_igp_null,
+		0, ANY_ROUTE },
+	{"isxflagset", (cmd_function)w_isxflagset,      1,fixup_igp_null,
+		0, ANY_ROUTE },
 
 	{0, 0, 0, 0, 0, 0}
 };
@@ -462,6 +471,75 @@ static int ki_append_branch_uri_q(sip_msg_t *msg, str *uri, str *q)
 	return 1;
 }
 
+/**
+ *
+ */
+static int ki_isxflagset(sip_msg_t *msg, int fval)
+{
+	if((flag_t)fval>KSR_MAX_XFLAG)
+		return -1;
+	return isxflagset(msg, (flag_t)fval);
+}
+
+/**
+ *
+ */
+static int w_isxflagset(sip_msg_t *msg, char *flag, str *s2)
+{
+	int fval=0;
+	if(fixup_get_ivalue(msg, (gparam_t*)flag, &fval)!=0) {
+		LM_ERR("no flag value\n");
+		return -1;
+	}
+	return ki_isxflagset(msg, fval);
+}
+
+/**
+ *
+ */
+static int ki_resetxflag(sip_msg_t *msg, int fval)
+{
+	if((flag_t)fval>KSR_MAX_XFLAG)
+		return -1;
+	return resetxflag(msg, (flag_t)fval);
+}
+
+/**
+ *
+ */
+static int w_resetxflag(sip_msg_t *msg, char *flag, str *s2)
+{
+	int fval=0;
+	if(fixup_get_ivalue(msg, (gparam_t*)flag, &fval)!=0) {
+		LM_ERR("no flag value\n");
+		return -1;
+	}
+	return ki_resetxflag(msg, fval);
+}
+
+/**
+ *
+ */
+static int ki_setxflag(sip_msg_t *msg, int fval)
+{
+	if((flag_t)fval>KSR_MAX_XFLAG)
+		return -1;
+	return setxflag(msg, (flag_t)fval);
+}
+
+/**
+ *
+ */
+static int w_setxflag(sip_msg_t *msg, char *flag, char *s2)
+{
+	int fval=0;
+	if(fixup_get_ivalue(msg, (gparam_t*)flag, &fval)!=0) {
+		LM_ERR("no flag value\n");
+		return -1;
+	}
+	return ki_setxflag(msg, fval);
+}
+
 /**
  *
  */
@@ -482,6 +560,21 @@ static sr_kemi_t sr_kemi_corex_exports[] = {
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init("corex"), str_init("setxflag"),
+		SR_KEMIP_INT, ki_setxflag,
+		{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init("corex"), str_init("resetxflag"),
+		SR_KEMIP_INT, ki_resetxflag,
+		{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init("corex"), str_init("isxflagset"),
+		SR_KEMIP_INT, ki_isxflagset,
+		{ SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
 
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
 };
@@ -494,4 +587,4 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2)
 {
 	sr_kemi_modules_add(sr_kemi_corex_exports);
 	return 0;
-}
\ No newline at end of file
+}




More information about the sr-dev mailing list