Merge remote branch 'origin/sr_3.0'
[sip-router] / receive.c
index 562c033..2a26b62 100644 (file)
--- a/receive.c
+++ b/receive.c
@@ -71,6 +71,7 @@
 #include "tcp_server.h" /* for tcpconn_add_alias */
 #include "tcp_options.h" /* for access to tcp_accept_aliases*/
 #include "cfg/cfg.h"
+#include "core_stats.h"
 
 #ifdef DEBUG_DMALLOC
 #include <mem/dmalloc.h>
@@ -156,6 +157,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
                if ((msg->via1==0) || (msg->via1->error!=PARSE_OK)){
                        /* no via, send back error ? */
                        LOG(L_ERR, "ERROR: receive_msg: no via found in request\n");
+                       STATS_BAD_MSG();
                        goto error02;
                }
                /* check if necessary to add receive?->moved to forward_req */
@@ -189,7 +191,10 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
                   on via1 being parsed in a pre-script callback --andrei
                */
                if (exec_pre_script_cb(msg, REQUEST_CB_TYPE)==0 )
+               {
+                       STATS_REQ_FWD_DROP();
                        goto end; /* drop the request */
+               }
 
                set_route_type(REQUEST_ROUTE);
                /* exec the routing script */
@@ -215,6 +220,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
                if ((msg->via1==0) || (msg->via1->error!=PARSE_OK)){
                        /* no via, send back error ? */
                        LOG(L_ERR, "ERROR: receive_msg: no via found in reply\n");
+                       STATS_BAD_RPL();
                        goto error02;
                }
 
@@ -231,7 +237,10 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
                   on via1 being parsed in a pre-script callback --andrei
                */
                if (exec_pre_script_cb(msg, ONREPLY_CB_TYPE)==0 )
-                       goto end; /* drop the request */
+               {
+                       STATS_RPL_FWD_DROP();
+                       goto end; /* drop the reply */
+               }
 
                /* exec the onreply routing script */
                if (onreply_rt.rlist[DEFAULT_RT]){
@@ -245,6 +254,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
                        }else
 #endif /* NO_ONREPLY_ROUTE_ERROR */
                        if (unlikely(ret==0 || (ctx.run_flags&DROP_R_F))){
+                               STATS_RPL_FWD_DROP();
                                goto skip_send_reply; /* drop the message, no error */
                        }
                }