[sr-dev] git:master:85ac764b: core: allow event_route blocks to run ONEVENT_ROUTE|REQUEST_ROUTE functions

Daniel-Constantin Mierla miconda at gmail.com
Tue Jul 18 16:46:23 CEST 2017


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-18T16:46:10+02:00

core: allow event_route blocks to run ONEVENT_ROUTE|REQUEST_ROUTE functions

- preserve compatibility with old behaviour that allowed REQUEST_ROUTE
  functions to be used inside event_route

---

Modified: src/core/sr_module.c

---

Diff:  https://github.com/kamailio/kamailio/commit/85ac764bf89009dac758aa178317f15acb42f44d.diff
Patch: https://github.com/kamailio/kamailio/commit/85ac764bf89009dac758aa178317f15acb42f44d.patch

---

diff --git a/src/core/sr_module.c b/src/core/sr_module.c
index 2bf336caf2..fe545378eb 100644
--- a/src/core/sr_module.c
+++ b/src/core/sr_module.c
@@ -665,7 +665,21 @@ int load_module(char* mod_path)
 	return -1;
 }
 
-
+/**
+ * test if command flags are compatible with route block flags (type)
+ * - decide if the command is allowed to run within a specific route block
+ * - return: 1 if allowed; 0 if not allowed
+ */
+static inline int sr_cmd_flags_match(int cflags, int rflags)
+{
+	if((cflags & rflags) == rflags) {
+		return 1;
+	}
+	if((rflags==EVENT_ROUTE) && (cflags & EVENT_ROUTE)) {
+		return 1;
+	}
+	return 0;
+}
 
 /* searches the module list for function name in module mod and returns
  *  a pointer to the "name" function record union or 0 if not found
@@ -688,16 +702,16 @@ sr31_cmd_export_t* find_mod_export_record(char* mod, char* name,
 				if((strcmp(name, cmd->name) == 0) &&
 					((cmd->param_no == param_no) ||
 					(cmd->param_no==VAR_PARAM_NO)) &&
-					((cmd->flags & flags) == flags)
+					(sr_cmd_flags_match(cmd->flags, flags)==1)
 				){
-					LM_DBG("find_export_record: found <%s> in module %s [%s]\n",
+					LM_DBG("found export of <%s> in module %s [%s]\n",
 						name, t->exports.name, t->path);
 					*mod_if_ver=t->orig_mod_interface_ver;
 					return cmd;
 				}
 			}
 	}
-	LM_DBG("find_export_record: <%s> not found \n", name);
+	LM_DBG("export of <%s> not found (flags %d)\n", name, flags);
 	return 0;
 }
 




More information about the sr-dev mailing list