Explorar el Código

- 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 hace 20 años
padre
commit
6b6642f470
Se han modificado 4 ficheros con 26 adiciones y 4 borrados
  1. 1 1
      Makefile.defs
  2. 3 0
      NEWS
  3. 6 1
      cfg.y
  4. 16 2
      receive.c

+ 1 - 1
Makefile.defs

@@ -58,7 +58,7 @@ MAIN_NAME=ser
 VERSION = 0
 VERSION = 0
 PATCHLEVEL = 10
 PATCHLEVEL = 10
 SUBLEVEL =   99
 SUBLEVEL =   99
-EXTRAVERSION = -dev13-tcp
+EXTRAVERSION = -dev14-tcp
 
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 3 - 0
NEWS

@@ -31,6 +31,9 @@ core:
                 dns_retr_time=1
                 dns_retr_time=1
                 dns_retr_no=1
                 dns_retr_no=1
                 dns_use_search_list=no
                 dns_use_search_list=no
+- default on reply route added: onreply_route {.. } will add a default 
+    onreply route that will be executed for any reply (usefull to catch
+    replies without using tm)
 new config variables:
 new config variables:
    dns_try_ipv6 = yes/no - if yes and a dns lookup fails, it will retry it
    dns_try_ipv6 = yes/no - if yes and a dns lookup fails, it will retry it
       for ipv6 (AAAA record). Default: yes
       for ipv6 (AAAA record). Default: yes

+ 6 - 1
cfg.y

@@ -62,6 +62,8 @@
  *              (andrei)
  *              (andrei)
  * 2005-07-11 added DNS_RETR_TIME, DNS_RETR_NO, DNS_SERVERS_NO, DNS_USE_SEARCH,
  * 2005-07-11 added DNS_RETR_TIME, DNS_RETR_NO, DNS_SERVERS_NO, DNS_USE_SEARCH,
  *             DNS_TRY_IPV6 (andrei)
  *             DNS_TRY_IPV6 (andrei)
+ * 2005-07-12  default onreply route added (andrei)
+ *
  */
  */
 
 
 
 
@@ -855,7 +857,10 @@ failure_route_stm: ROUTE_FAILURE LBRACK NUMBER RBRACK LBRACE actions RBRACE {
 		| ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
 		| ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
 	;
 	;
 
 
-onreply_route_stm: ROUTE_ONREPLY LBRACK NUMBER RBRACK LBRACE actions RBRACE {
+onreply_route_stm: ROUTE LBRACE actions RBRACE {
+										push($3, &onreply_rlist[DEFAULT_RT]);
+											  }
+				| ROUTE_ONREPLY LBRACK NUMBER RBRACK LBRACE actions RBRACE {
 										if (($3<ONREPLY_RT_NO)&&($3>=1)){
 										if (($3<ONREPLY_RT_NO)&&($3>=1)){
 											push($6, &onreply_rlist[$3]);
 											push($6, &onreply_rlist[$3]);
 										} else {
 										} else {

+ 16 - 2
receive.c

@@ -81,6 +81,7 @@ str default_via_port={0,0};
 int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info) 
 int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info) 
 {
 {
 	struct sip_msg* msg;
 	struct sip_msg* msg;
+	int ret;
 #ifdef STATS
 #ifdef STATS
 	int skipped = 1;
 	int skipped = 1;
 	struct timeval tvb, tve;	
 	struct timeval tvb, tve;	
@@ -159,7 +160,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 			goto end; /* drop the request */
 			goto end; /* drop the request */
 
 
 		/* exec the routing script */
 		/* exec the routing script */
-		if (run_actions(rlist[0], msg)<0) {
+		if (run_actions(rlist[DEFAULT_RT], msg)<0){
 			LOG(L_WARN, "WARNING: receive_msg: "
 			LOG(L_WARN, "WARNING: receive_msg: "
 					"error while trying script\n");
 					"error while trying script\n");
 			goto error_req;
 			goto error_req;
@@ -198,7 +199,15 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 		*/
 		*/
 		if (exec_pre_rpl_cb(msg)==0 )
 		if (exec_pre_rpl_cb(msg)==0 )
 			goto end; /* drop the request */
 			goto end; /* drop the request */
-
+		/* exec the onreply routing script */
+		if (onreply_rlist[DEFAULT_RT]){
+			ret=run_actions(onreply_rlist[DEFAULT_RT], msg);
+			if (ret<0){
+				LOG(L_WARN, "WARNING: receive_msg: "
+						"error while trying onreply script\n");
+				goto error_rpl;
+			}else if (ret==0) goto end; /* drop the message, no error */
+		}
 		/* send the msg */
 		/* send the msg */
 		forward_reply(msg);
 		forward_reply(msg);
 
 
@@ -227,6 +236,11 @@ end:
 	if (skipped) STATS_RX_DROPS;
 	if (skipped) STATS_RX_DROPS;
 #endif
 #endif
 	return 0;
 	return 0;
+error_rpl:
+	/* execute post reply-script callbacks */
+	exec_post_rpl_cb(msg);
+	reset_avps();
+	goto error02;
 error_req:
 error_req:
 	DBG("receive_msg: error:...\n");
 	DBG("receive_msg: error:...\n");
 	/* execute post request-script callbacks */
 	/* execute post request-script callbacks */