Browse code

script callbacks: onsend route

- pre- and post-script callbacks are executed also
for onsend route

Miklos Tirpak authored on 01/06/2009 13:50:37
Showing 1 changed files
... ...
@@ -28,6 +28,7 @@
28 28
  * History:
29 29
  * -------
30 30
  *  2005-12-11 created by andrei
31
+ *  2009-06-01 Pre- and post-script callbacks of onsend route are executed (Miklos)
31 32
  */
32 33
 
33 34
 
... ...
@@ -38,6 +39,7 @@
38 38
 #include "ip_addr.h"
39 39
 #include "action.h"
40 40
 #include "route.h"
41
+#include "script_cb.h"
41 42
 
42 43
 struct onsend_info{
43 44
 	union sockaddr_union* to;
... ...
@@ -60,18 +62,23 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
60 60
 	struct onsend_info onsnd_info;
61 61
 	int ret;
62 62
 	struct run_act_ctx ra_ctx;
63
-	
64
-	ret=1;
65
-	if (onsend_rt.rlist[DEFAULT_RT]){
66
-		onsnd_info.to=&dst->to;
67
-		onsnd_info.send_sock=dst->send_sock;
68
-		onsnd_info.buf=buf;
69
-		onsnd_info.len=len;
70
-		p_onsend=&onsnd_info;
71
-		set_route_type(ONSEND_ROUTE);
72
-		init_run_actions_ctx(&ra_ctx);
73
-		ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
74
-		p_onsend=0; /* reset it */
63
+
64
+	if (exec_pre_script_cb(orig_msg, ONSEND_CB_TYPE)>0) {
65
+		ret=1;
66
+		if (onsend_rt.rlist[DEFAULT_RT]){
67
+			onsnd_info.to=&dst->to;
68
+			onsnd_info.send_sock=dst->send_sock;
69
+			onsnd_info.buf=buf;
70
+			onsnd_info.len=len;
71
+			p_onsend=&onsnd_info;
72
+			set_route_type(ONSEND_ROUTE);
73
+			init_run_actions_ctx(&ra_ctx);
74
+			ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
75
+			p_onsend=0; /* reset it */
76
+		}
77
+		exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
78
+	} else {
79
+		ret = 0;
75 80
 	}
76 81
 	return ret;
77 82
 }