- default onreply_router {} added (this will be executed for any reply, it adds
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Tue, 12 Jul 2005 15:22:19 +0000 (15:22 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Tue, 12 Jul 2005 15:22:19 +0000 (15:22 +0000)
 the possibility of executing scripts on replies without using tm)

Makefile.defs
NEWS
cfg.y
receive.c

index c545b1a..215b9c7 100644 (file)
@@ -58,7 +58,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 10
 SUBLEVEL =   99
-EXTRAVERSION = -dev13-tcp
+EXTRAVERSION = -dev14-tcp
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
diff --git a/NEWS b/NEWS
index e6815a2..ad0ac28 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,9 @@ core:
                 dns_retr_time=1
                 dns_retr_no=1
                 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:
    dns_try_ipv6 = yes/no - if yes and a dns lookup fails, it will retry it
       for ipv6 (AAAA record). Default: yes
diff --git a/cfg.y b/cfg.y
index 3ec6dd6..8e12a8d 100644 (file)
--- a/cfg.y
+++ b/cfg.y
@@ -62,6 +62,8 @@
  *              (andrei)
  * 2005-07-11 added DNS_RETR_TIME, DNS_RETR_NO, DNS_SERVERS_NO, DNS_USE_SEARCH,
  *             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"); }
        ;
 
-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)){
                                                                                        push($6, &onreply_rlist[$3]);
                                                                                } else {
index c325038..08c18d0 100644 (file)
--- a/receive.c
+++ b/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) 
 {
        struct sip_msg* msg;
+       int ret;
 #ifdef STATS
        int skipped = 1;
        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 */
 
                /* 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: "
                                        "error while trying script\n");
                        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 )
                        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 */
                forward_reply(msg);
 
@@ -227,6 +236,11 @@ end:
        if (skipped) STATS_RX_DROPS;
 #endif
        return 0;
+error_rpl:
+       /* execute post reply-script callbacks */
+       exec_post_rpl_cb(msg);
+       reset_avps();
+       goto error02;
 error_req:
        DBG("receive_msg: error:...\n");
        /* execute post request-script callbacks */