[SR-Dev] git:master: kex: script and branch flags operations

Daniel-Constantin Mierla miconda at gmail.com
Tue Apr 28 16:37:24 CEST 2009


Module: sip-router
Branch: master
Commit: 313f52655841f1abf4c0db585699cd31e9494a3f
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=313f52655841f1abf4c0db585699cd31e9494a3f

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Tue Apr 28 16:35:28 2009 +0200

kex: script and branch flags operations

- K script and branch flags operations included in kex module
- the parameters must be now enclosed in quotes
- the parameters can be now integer value or Pseudo-Variable with
  integer value
- the optional 'branch' parameter for branch flags parameters is now the
  second, for a more logical parameter mapping with the version without
  this parameter

---

 modules_k/kex/flags.c   |  144 +++++++++++++++++++++++++++++++++++++++++++++++
 modules_k/kex/flags.h   |   35 +++++++++++
 modules_k/kex/kex_mod.c |   29 +++++++++-
 3 files changed, 205 insertions(+), 3 deletions(-)

diff --git a/modules_k/kex/flags.c b/modules_k/kex/flags.c
new file mode 100644
index 0000000..ae539d1
--- /dev/null
+++ b/modules_k/kex/flags.c
@@ -0,0 +1,144 @@
+/**
+ * $Id$
+ *
+ * Copyright (C) 2009
+ *
+ * This file is part of SIP-Router.org, a free SIP server.
+ *
+ * SIP-Router is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "../../dprint.h"
+#include "../../flags.h"
+#include "../../dset.h"
+#include "../../mod_fix.h"
+#include "flags.h"
+
+int w_issflagset(struct sip_msg *msg, char *flag, str *s2)
+{
+	int fval=0;
+	if(fixup_get_ivalue(msg, (gparam_p)flag, &fval)!=0)
+	{
+		LM_ERR("no flag value\n");
+		return -1;
+	}
+	if(fval<0 || fval>31)
+		return -1;
+	return issflagset((flag_t)fval);
+}
+
+int w_resetsflag(struct sip_msg *msg, char *flag, str *s2)
+{
+	int fval=0;
+	if(fixup_get_ivalue(msg, (gparam_p)flag, &fval)!=0)
+	{
+		LM_ERR("no flag value\n");
+		return -1;
+	}
+	if(fval<0 || fval>31)
+		return -1;
+	return resetsflag((flag_t)fval);
+}
+
+int w_setsflag(struct sip_msg *msg, char *flag, char *s2)
+{
+	int fval=0;
+	if(fixup_get_ivalue(msg, (gparam_p)flag, &fval)!=0)
+	{
+		LM_ERR("no flag value\n");
+		return -1;
+	}
+	if(fval<0 || fval>31)
+		return -1;
+	return setsflag((flag_t)fval);
+}
+
+int w_isbflagset(struct sip_msg *msg, char *flag, str *idx)
+{
+	int fval=0;
+	int ival=0;
+	if(fixup_get_ivalue(msg, (gparam_p)flag, &fval)!=0)
+	{
+		LM_ERR("no flag value\n");
+		return -1;
+	}
+	if(fval<0 || fval>31)
+		return -1;
+	if(idx!=0)
+	{
+		if(fixup_get_ivalue(msg, (gparam_p)idx, &ival)!=0)
+		{
+			LM_ERR("no idx value\n");
+			return -1;
+		}
+		if(ival<0)
+			return -1;
+	}
+	return isbflagset(ival, (flag_t)fval);
+}
+
+int w_resetbflag(struct sip_msg *msg, char *flag, str *idx)
+{
+		int fval=0;
+	int ival=0;
+	if(fixup_get_ivalue(msg, (gparam_p)flag, &fval)!=0)
+	{
+		LM_ERR("no flag value\n");
+		return -1;
+	}
+	if(fval<0 || fval>31)
+		return -1;
+	if(idx!=0)
+	{
+		if(fixup_get_ivalue(msg, (gparam_p)idx, &ival)!=0)
+		{
+			LM_ERR("no idx value\n");
+			return -1;
+		}
+		if(ival<0)
+			return -1;
+	}
+	return resetbflag(ival, (flag_t)fval);
+
+}
+
+int w_setbflag(struct sip_msg *msg, char *flag, char *idx)
+{
+	int fval=0;
+	int ival=0;
+	if(fixup_get_ivalue(msg, (gparam_p)flag, &fval)!=0)
+	{
+		LM_ERR("no flag value\n");
+		return -1;
+	}
+	if(fval<0 || fval>31)
+		return -1;
+	if(idx!=0)
+	{
+		if(fixup_get_ivalue(msg, (gparam_p)idx, &ival)!=0)
+		{
+			LM_ERR("no idx value\n");
+			return -1;
+		}
+		if(ival<0)
+			return -1;
+	}
+	return setbflag(ival, (flag_t)fval);
+}
+
diff --git a/modules_k/kex/flags.h b/modules_k/kex/flags.h
new file mode 100644
index 0000000..d0dbad4
--- /dev/null
+++ b/modules_k/kex/flags.h
@@ -0,0 +1,35 @@
+/**
+ * $Id$
+ *
+ * Copyright (C) 2009
+ *
+ * This file is part of SIP-Router.org, a free SIP server.
+ *
+ * SIP-Router is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _KEX_FLAGS_H_
+#define _KEX_FLAGS_H_
+
+#include "../../sr_module.h"
+
+int w_issflagset(struct sip_msg *msg, char *flag, str *s2);
+int w_resetsflag(struct sip_msg *msg, char *flag, str *s2);
+int w_setsflag(struct sip_msg *msg, char *flag, char *s2);
+int w_isbflagset(struct sip_msg *msg, char *flag, str *idx);
+int w_resetbflag(struct sip_msg *msg, char *flag, str *idx);
+int w_setbflag(struct sip_msg *msg, char *flag, char *idx);
+
+#endif
diff --git a/modules_k/kex/kex_mod.c b/modules_k/kex/kex_mod.c
index c9c3ae3..e4960c0 100644
--- a/modules_k/kex/kex_mod.c
+++ b/modules_k/kex/kex_mod.c
@@ -3,9 +3,9 @@
  *
  * Copyright (C) 2009
  *
- * This file is part of Kamailio, a free SIP server.
+ * This file is part of SIP-Router.org, a free SIP server.
  *
- * Kamailio is free software; you can redistribute it and/or modify
+ * SIP-Router is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
@@ -26,7 +26,11 @@
 
 #include "../../sr_module.h"
 #include "../../dprint.h"
+#include "../../flags.h"
+#include "../../dset.h"
+#include "../../mod_fix.h"
 
+#include "flags.h"
 #include "mi_core.h"
 #include "core_stats.h"
 
@@ -38,10 +42,28 @@ MODULE_VERSION
 
 /** module functions */
 static int mod_init(void);
-
 void destroy(void);
 
 static cmd_export_t cmds[]={
+	{"setsflag", (cmd_function)w_setsflag,          1,fixup_igp_null,
+			0, ANY_ROUTE },
+	{"resetsflag", (cmd_function)w_resetsflag,      1,fixup_igp_null,
+			0, ANY_ROUTE },
+	{"issflagset", (cmd_function)w_issflagset,      1,fixup_igp_null,
+			0, ANY_ROUTE },
+	{"setbflag", (cmd_function)w_setbflag,          1,fixup_igp_null,
+			0, ANY_ROUTE },
+	{"setbflag", (cmd_function)w_setbflag,          2,fixup_igp_igp,
+			0, ANY_ROUTE },
+	{"resetbflag", (cmd_function)w_resetbflag,      1,fixup_igp_null,
+			0, ANY_ROUTE },
+	{"resetbflag", (cmd_function)w_resetbflag,      2,fixup_igp_igp,
+			0, ANY_ROUTE },
+	{"isbflagset", (cmd_function)w_isbflagset,      1,fixup_igp_null,
+			0, ANY_ROUTE },
+	{"isbflagset", (cmd_function)w_isbflagset,      2,fixup_igp_igp,
+			0, ANY_ROUTE },
+
 	{0,0,0,0,0,0}
 };
 
@@ -93,3 +115,4 @@ void destroy(void)
 	return;
 }
 
+




More information about the sr-dev mailing list