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 765
 
766 766
 
767 767
 
768
-/* removes first via & sends msg to the second */
769
-int forward_reply(struct sip_msg* msg)
768
+/* removes first via & sends msg to the second
769
+ * - mode param controls if modules sip response callbacks are executed */
770
+static int do_forward_reply(struct sip_msg* msg, int mode)
770 771
 {
771 772
 	char* new_buf;
772 773
 	struct dest_info dst;
... ...
@@ -792,8 +794,10 @@ int forward_reply(struct sip_msg* msg)
792 792
 	}
793 793
 	
794 794
 	/* 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;
795
+	if(likely(mode==0)) {
796
+		for (r=0; r<mod_response_cbk_no; r++)
797
+			if (mod_response_cbks[r](msg)==0) goto skip;
798
+	}
797 799
 	/* we have to forward the reply stateless, so we need second via -bogdan*/
798 800
 	if (parse_headers( msg, HDR_VIA2_F, 0 )==-1 
799 801
 		|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))
... ...
@@ -872,6 +876,18 @@ error:
872 872
 	return -1;
873 873
 }
874 874
 
875
+/* removes first via & sends msg to the second */
876
+int forward_reply(struct sip_msg* msg)
877
+{
878
+	return do_forward_reply(msg, 0);
879
+}
880
+
881
+/* removes first via & sends msg to the second - no module callbacks */
882
+int forward_reply_nocb(struct sip_msg* msg)
883
+{
884
+	return do_forward_reply(msg, 1);
885
+}
886
+
875 887
 static void apply_force_send_socket(struct dest_info* dst, struct sip_msg* msg)
876 888
 {
877 889
 	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