Browse code

topos: shortcut to handle forwarded MESSAGE replies

- no dialog created there

Daniel-Constantin Mierla authored on 18/03/2016 15:52:24
Showing 1 changed files
... ...
@@ -548,11 +548,8 @@ int tps_request_sent(sip_msg_t *msg, int dialog, int direction, int local)
548 548
 		return -1;
549 549
 	}
550 550
 
551
-	if(direction==TPS_DIR_DOWNSTREAM) {
552
-		lkey = get_from(msg)->tag_value;
553
-	} else {
554
-		lkey = get_to(msg)->tag_value;
555
-	}
551
+	lkey = msg->callid->body;
552
+
556 553
 	tps_storage_lock_get(&lkey);
557 554
 	if(dialog==0) {
558 555
 		if(tps_storage_record(msg, ptsd)<0) {
... ...
@@ -599,5 +596,42 @@ error:
599 596
  */
600 597
 int tps_response_sent(sip_msg_t *msg)
601 598
 {
599
+	tps_data_t mtsd;
600
+	tps_data_t stsd;
601
+	tps_data_t btsd;
602
+	str lkey;
603
+
604
+	memset(&mtsd, 0, sizeof(tps_data_t));
605
+	memset(&stsd, 0, sizeof(tps_data_t));
606
+	memset(&btsd, 0, sizeof(tps_data_t));
607
+
608
+	if(tps_pack_request(msg, &mtsd)<0) {
609
+		LM_ERR("failed to extract and pack the headers\n");
610
+		return -1;
611
+	}
612
+
613
+	if(get_cseq(msg)->method_id==METHOD_MESSAGE) {
614
+		tps_remove_headers(msg, HDR_RECORDROUTE_T);
615
+		tps_remove_headers(msg, HDR_CONTACT_T);
616
+		return 0;
617
+	}
618
+
619
+	lkey = msg->callid->body;
620
+
621
+	tps_storage_lock_get(&lkey);
622
+	if(tps_storage_load_branch(msg, &mtsd, &btsd)<0) {
623
+		goto error;
624
+	}
625
+	LM_DBG("loaded dialog a_uuid [%.*s]\n",
626
+			btsd.a_uuid.len, ZSW(btsd.a_uuid.s));
627
+	if(tps_storage_load_dialog(msg, &btsd, &stsd)<0) {
628
+		goto error;
629
+	}
630
+	tps_storage_lock_release(&lkey);
631
+
602 632
 	return 0;
633
+
634
+error:
635
+	tps_storage_lock_release(&lkey);
636
+	return -1;
603 637
 }