Browse code

core: made a wrapper forward_reply_nocb()

- it forwards a reply without calling the callbacks from modules for sip
response handling
- fixes the issue of sl_forward_reply() looping when used in TM onreply
routes

Daniel-Constantin Mierla authored on 25/01/2013 16:30:42
Showing 2 changed files
... ...
@@ -754,7 +754,8 @@ int update_sock_struct_from_via( union sockaddr_union* to,
754 754
 	he=sip_resolvehost(name, &port, &proto);
755 755
 	
756 756
 	if (he==0){
757
-		LOG(L_NOTICE, "ERROR:forward_reply:resolve_host(%.*s) failure\n",
757
+		LOG(L_NOTICE,
758
+				"update_sock_struct_from_via:resolve_host(%.*s) failure\n",
758 759
 				name->len, name->s);
759 760
 		return -1;
760 761
 	}
... ...
@@ -765,8 +766,9 @@ int update_sock_struct_from_via( union sockaddr_union* to,
765 766
 
766 767
 
767 768
 
768
-/* removes first via & sends msg to the second */
769
-int forward_reply(struct sip_msg* msg)
769
+/* removes first via & sends msg to the second
770
+ * - mode param controls if modules sip response callbacks are executed */
771
+static int do_forward_reply(struct sip_msg* msg, int mode)
770 772
 {
771 773
 	char* new_buf;
772 774
 	struct dest_info dst;
... ...
@@ -792,8 +794,10 @@ int forward_reply(struct sip_msg* msg)
792 794
 	}
793 795
 	
794 796
 	/* check modules response_f functions */
795
-	for (r=0; r<mod_response_cbk_no; r++)
796
-		if (mod_response_cbks[r](msg)==0) goto skip;
797
+	if(likely(mode==0)) {
798
+		for (r=0; r<mod_response_cbk_no; r++)
799
+			if (mod_response_cbks[r](msg)==0) goto skip;
800
+	}
797 801
 	/* we have to forward the reply stateless, so we need second via -bogdan*/
798 802
 	if (parse_headers( msg, HDR_VIA2_F, 0 )==-1 
799 803
 		|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))
... ...
@@ -872,6 +876,18 @@ error:
872 876
 	return -1;
873 877
 }
874 878
 
879
+/* removes first via & sends msg to the second */
880
+int forward_reply(struct sip_msg* msg)
881
+{
882
+	return do_forward_reply(msg, 0);
883
+}
884
+
885
+/* removes first via & sends msg to the second - no module callbacks */
886
+int forward_reply_nocb(struct sip_msg* msg)
887
+{
888
+	return do_forward_reply(msg, 1);
889
+}
890
+
875 891
 static void apply_force_send_socket(struct dest_info* dst, struct sip_msg* msg)
876 892
 {
877 893
 	if (msg->force_send_socket != 0) {
... ...
@@ -105,6 +105,7 @@ int update_sock_struct_from_via( union sockaddr_union* to,
105 105
 							((msg)->via1->port)?(msg)->via1->port: SIP_PORT )
106 106
 
107 107
 int forward_reply( struct sip_msg* msg);
108
+int forward_reply_nocb( struct sip_msg* msg);
108 109
 
109 110
 int is_check_self_func_list_set(void);
110 111