Browse code

- default onreply_router {} added (this will be executed for any reply, it adds the possibility of executing scripts on replies without using tm)

Andrei Pelinescu-Onciul authored on 12/07/2005 15:22:19
Showing 4 changed files
... ...
@@ -58,7 +58,7 @@ MAIN_NAME=ser
58 58
 VERSION = 0
59 59
 PATCHLEVEL = 10
60 60
 SUBLEVEL =   99
61
-EXTRAVERSION = -dev13-tcp
61
+EXTRAVERSION = -dev14-tcp
62 62
 
63 63
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
64 64
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -31,6 +31,9 @@ core:
31 31
                 dns_retr_time=1
32 32
                 dns_retr_no=1
33 33
                 dns_use_search_list=no
34
+- default on reply route added: onreply_route {.. } will add a default 
35
+    onreply route that will be executed for any reply (usefull to catch
36
+    replies without using tm)
34 37
 new config variables:
35 38
    dns_try_ipv6 = yes/no - if yes and a dns lookup fails, it will retry it
36 39
       for ipv6 (AAAA record). Default: yes
... ...
@@ -62,6 +62,8 @@
62 62
  *              (andrei)
63 63
  * 2005-07-11 added DNS_RETR_TIME, DNS_RETR_NO, DNS_SERVERS_NO, DNS_USE_SEARCH,
64 64
  *             DNS_TRY_IPV6 (andrei)
65
+ * 2005-07-12  default onreply route added (andrei)
66
+ *
65 67
  */
66 68
 
67 69
 
... ...
@@ -855,7 +857,10 @@ failure_route_stm: ROUTE_FAILURE LBRACK NUMBER RBRACK LBRACE actions RBRACE {
855 857
 		| ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
856 858
 	;
857 859
 
858
-onreply_route_stm: ROUTE_ONREPLY LBRACK NUMBER RBRACK LBRACE actions RBRACE {
860
+onreply_route_stm: ROUTE LBRACE actions RBRACE {
861
+										push($3, &onreply_rlist[DEFAULT_RT]);
862
+											  }
863
+				| ROUTE_ONREPLY LBRACK NUMBER RBRACK LBRACE actions RBRACE {
859 864
 										if (($3<ONREPLY_RT_NO)&&($3>=1)){
860 865
 											push($6, &onreply_rlist[$3]);
861 866
 										} else {
... ...
@@ -81,6 +81,7 @@ str default_via_port={0,0};
81 81
 int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info) 
82 82
 {
83 83
 	struct sip_msg* msg;
84
+	int ret;
84 85
 #ifdef STATS
85 86
 	int skipped = 1;
86 87
 	struct timeval tvb, tve;	
... ...
@@ -159,7 +160,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
159 160
 			goto end; /* drop the request */
160 161
 
161 162
 		/* exec the routing script */
162
-		if (run_actions(rlist[0], msg)<0) {
163
+		if (run_actions(rlist[DEFAULT_RT], msg)<0){
163 164
 			LOG(L_WARN, "WARNING: receive_msg: "
164 165
 					"error while trying script\n");
165 166
 			goto error_req;
... ...
@@ -198,7 +199,15 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
198 199
 		*/
199 200
 		if (exec_pre_rpl_cb(msg)==0 )
200 201
 			goto end; /* drop the request */
201
-
202
+		/* exec the onreply routing script */
203
+		if (onreply_rlist[DEFAULT_RT]){
204
+			ret=run_actions(onreply_rlist[DEFAULT_RT], msg);
205
+			if (ret<0){
206
+				LOG(L_WARN, "WARNING: receive_msg: "
207
+						"error while trying onreply script\n");
208
+				goto error_rpl;
209
+			}else if (ret==0) goto end; /* drop the message, no error */
210
+		}
202 211
 		/* send the msg */
203 212
 		forward_reply(msg);
204 213
 
... ...
@@ -227,6 +236,11 @@ end:
227 236
 	if (skipped) STATS_RX_DROPS;
228 237
 #endif
229 238
 	return 0;
239
+error_rpl:
240
+	/* execute post reply-script callbacks */
241
+	exec_post_rpl_cb(msg);
242
+	reset_avps();
243
+	goto error02;
230 244
 error_req:
231 245
 	DBG("receive_msg: error:...\n");
232 246
 	/* execute post request-script callbacks */