Quellcode durchsuchen

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
Daniel-Constantin Mierla vor 16 Jahren
Ursprung
Commit
313f526558
3 geänderte Dateien mit 205 neuen und 3 gelöschten Zeilen
  1. 144 0
      modules_k/kex/flags.c
  2. 35 0
      modules_k/kex/flags.h
  3. 26 3
      modules_k/kex/kex_mod.c

+ 144 - 0
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);
+}
+

+ 35 - 0
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

+ 26 - 3
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;
 }
 
+