Quellcode durchsuchen

sl_filter_ACK no more exported and called on beginning of every
script instead

Jiri Kuthan vor 23 Jahren
Ursprung
Commit
a50f3f897c
4 geänderte Dateien mit 22 neuen und 4 gelöschten Zeilen
  1. 5 1
      receive.c
  2. 7 2
      script_cb.c
  3. 1 1
      script_cb.h
  4. 9 0
      sr_module.c

+ 5 - 1
receive.c

@@ -96,7 +96,11 @@ int receive_msg(char* buf, unsigned int len, union sockaddr_union* src_su)
 	DBG("After parse_msg...\n");
 
 	/* execute pre-script callbacks, if any; -jiri */
-	exec_pre_cb(msg);
+	/* if some of the callbacks said not to continue with
+	   script processing, don't do so
+	*/
+	if (exec_pre_cb(msg)==0) goto error;
+
 	/* ... and clear branches from previous message */
 	clear_branches();
 

+ 7 - 2
script_cb.c

@@ -67,10 +67,15 @@ int register_script_cb( cb_function f, callback_t t, void *param )
 	return 1;
 }
 
-void exec_pre_cb( struct sip_msg *msg)
+int exec_pre_cb( struct sip_msg *msg)
 {
 	struct script_cb *i;
-	for (i=pre_cb; i; i=i->next) i->cbf(msg, i->param);
+	for (i=pre_cb; i; i=i->next) {
+		/* stop on error */
+		if (i->cbf(msg, i->param)==0)
+			return 0;
+	}
+	return 1;
 }
 
 void exec_post_cb( struct sip_msg *msg)

+ 1 - 1
script_cb.h

@@ -44,7 +44,7 @@ struct script_cb{
 };
 
 int register_script_cb( cb_function f, callback_t t, void *param );
-void exec_pre_cb( struct sip_msg *msg);
+int exec_pre_cb( struct sip_msg *msg);
 void exec_post_cb( struct sip_msg *msg);
 
 

+ 9 - 0
sr_module.c

@@ -60,6 +60,10 @@ struct sr_module* modules=0;
         extern struct module_exports* usrloc_exports();
 #endif
 
+#ifdef STATIC_SL
+        extern struct module_exports* sl_exports();
+#endif
+
 
 /* initializes statically built (compiled in) modules*/
 int register_builtin_modules()
@@ -96,6 +100,11 @@ int register_builtin_modules()
 	ret=register_module(usrloc_exports, "built-in", 0);
 	if (ret<0) return ret;
 #endif
+
+#ifdef STATIC_SL
+	ret=register_module(sl_exports, "built-in", 0);
+	if (ret<0) return ret;
+#endif
 	
 	return ret;
 }