core: build_req_buf_from_sip_req() has a new parameter
[sip-router] / receive.c
index 9941df7..9f59933 100644 (file)
--- a/receive.c
+++ b/receive.c
@@ -76,6 +76,13 @@ str default_global_port={0,0};
 str default_via_address={0,0};
 str default_via_port={0,0};
 
+/**
+ * increment msg_no and return the new value
+ */
+unsigned int inc_msg_no(void)
+{
+       return ++msg_no;
+}
 
 
 /* WARNING: buf must be 0 terminated (buf[len]=0) or some things might 
@@ -125,8 +132,11 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 
        if (msg->first_line.type==SIP_REQUEST){
                if (!IS_SIP(msg)){
-                       if (nonsip_msg_run_hooks(msg)!=NONSIP_MSG_ACCEPT)
+                       if ((ret=nonsip_msg_run_hooks(msg))!=NONSIP_MSG_ACCEPT){
+                               if (unlikely(ret==NONSIP_MSG_ERROR))
+                                       goto error03;
                                goto end; /* drop the message */
+                       }
                }
                /* sanity checks */
                if ((msg->via1==0) || (msg->via1->error!=PARSE_OK)){
@@ -164,7 +174,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
                   (like presence of at least one via), so you can count
                   on via1 being parsed in a pre-script callback --andrei
                */
-               if (exec_pre_req_cb(msg)==0 )
+               if (exec_pre_script_cb(msg, REQUEST_CB_TYPE)==0 )
                        goto end; /* drop the request */
 
                set_route_type(REQUEST_ROUTE);
@@ -185,7 +195,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 #endif
 
                /* execute post request-script callbacks */
-               exec_post_req_cb(msg);
+               exec_post_script_cb(msg, REQUEST_CB_TYPE);
        }else if (msg->first_line.type==SIP_REPLY){
                /* sanity checks */
                if ((msg->via1==0) || (msg->via1->error!=PARSE_OK)){
@@ -206,7 +216,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
                   (like presence of at least one via), so you can count
                   on via1 being parsed in a pre-script callback --andrei
                */
-               if (exec_pre_rpl_cb(msg)==0 )
+               if (exec_pre_script_cb(msg, ONREPLY_CB_TYPE)==0 )
                        goto end; /* drop the request */
 
                /* exec the onreply routing script */
@@ -232,7 +242,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 #endif
 
                /* execute post reply-script callbacks */
-               exec_post_rpl_cb(msg);
+               exec_post_script_cb(msg, ONREPLY_CB_TYPE);
        }
 
 end:
@@ -250,13 +260,14 @@ end:
        return 0;
 error_rpl:
        /* execute post reply-script callbacks */
-       exec_post_rpl_cb(msg);
+       exec_post_script_cb(msg, ONREPLY_CB_TYPE);
        reset_avps();
        goto error02;
 error_req:
        DBG("receive_msg: error:...\n");
        /* execute post request-script callbacks */
-       exec_post_req_cb(msg);
+       exec_post_script_cb(msg, REQUEST_CB_TYPE);
+error03:
        /* free possible loaded avps -bogdan */
        reset_avps();
 error02: