Browse code

tm: proper fill of From/To URI/tag values using parsed structure in t_uac_send()

Daniel-Constantin Mierla authored on 19/11/2020 16:06:06
Showing 1 changed files
... ...
@@ -593,7 +593,7 @@ void rpc_t_uac_wait(rpc_t* rpc, void* c)
593 593
 
594 594
 static int t_uac_check_msg(struct sip_msg* msg,
595 595
 		str* method, str* body,
596
-		int* fromtag, int *cseq_is, int* cseq,
596
+		str *fromtag, int *cseq_is, int* cseq,
597 597
 		str* callid)
598 598
 {
599 599
 	struct to_body* parsed_from;
... ...
@@ -628,7 +628,13 @@ static int t_uac_check_msg(struct sip_msg* msg,
628 628
 	}
629 629
 
630 630
 	parsed_from = (struct to_body*)msg->from->parsed;
631
-	*fromtag = parsed_from->tag_value.s && parsed_from->tag_value.len;
631
+	if(parsed_from->tag_value.s && parsed_from->tag_value.len) {
632
+		fromtag->s = parsed_from->tag_value.s;
633
+		fromtag->len = parsed_from->tag_value.len;
634
+	} else {
635
+		fromtag->s = NULL;
636
+		fromtag->len = 0;
637
+	}
632 638
 
633 639
 	*cseq = 0;
634 640
 	if (msg->cseq && (parsed_cseq = get_cseq(msg))) {
... ...
@@ -676,7 +682,8 @@ int t_uac_send(str *method, str *ruri, str *nexthop, str *send_socket,
676 682
 	struct socket_info* ssock;
677 683
 	str saddr;
678 684
 	int sport, sproto;
679
-	int ret, fromtag, cseq_is, cseq;
685
+	int ret, cseq_is, cseq;
686
+	str fromtag;
680 687
 	dlg_t dlg;
681 688
 	uac_req_t uac_req;
682 689
 
... ...
@@ -749,7 +756,9 @@ int t_uac_send(str *method, str *ruri, str *nexthop, str *send_socket,
749 756
 	 */
750 757
 
751 758
 	/* Generate fromtag if not present */
752
-	if (!fromtag) {
759
+	if (fromtag.s && fromtag.len) {
760
+		dlg.id.loc_tag = fromtag;
761
+	} else {
753 762
 		generate_fromtag(&dlg.id.loc_tag, &dlg.id.call_id, ruri);
754 763
 	}
755 764
 
... ...
@@ -758,8 +767,11 @@ int t_uac_send(str *method, str *ruri, str *nexthop, str *send_socket,
758 767
 	else dlg.loc_seq.value = DEFAULT_CSEQ;
759 768
 	dlg.loc_seq.is_set = 1;
760 769
 
761
-	dlg.loc_uri = faked_msg.from->body;
762
-	dlg.rem_uri = faked_msg.to->body;
770
+	dlg.loc_uri = get_from(&faked_msg)->uri;
771
+	dlg.rem_uri = get_to(&faked_msg)->uri;
772
+	if(get_to(&faked_msg)->tag_value.len > 0) {
773
+		dlg.id.rem_tag = get_to(&faked_msg)->tag_value;
774
+	}
763 775
 	dlg.rem_target = *ruri;
764 776
 	dlg.dst_uri = *nexthop;
765 777
 	dlg.send_sock=ssock;