Browse code

Merge 674330d33ca0c0ab6fa9e989300cec92734e9e1d into 554d03a55f62b06802d4880f005806a0517da5fb

Mvondo Eric authored on 17/08/2022 10:06:05 • GitHub committed on 17/08/2022 10:06:05
Showing 2 changed files
... ...
@@ -81,6 +81,7 @@ static str _tps_db_url = str_init(DEFAULT_DB_URL);
81 81
 int _tps_param_mask_callid = 0;
82 82
 int _tps_sanity_checks = 0;
83 83
 int _tps_rr_update = 0;
84
+int _tps_separate_via = 0;
84 85
 str _tps_storage = str_init("db");
85 86
 
86 87
 extern int _tps_branch_expire;
... ...
@@ -156,6 +157,7 @@ static param_export_t params[]={
156 157
 	{"db_url",		PARAM_STR, &_tps_db_url},
157 158
 	{"mask_callid",		PARAM_INT, &_tps_param_mask_callid},
158 159
 	{"sanity_checks",	PARAM_INT, &_tps_sanity_checks},
160
+	{"separate_via",    PARAM_INT, &_tps_separate_via},
159 161
 	{"branch_expire",	PARAM_INT, &_tps_branch_expire},
160 162
 	{"dialog_expire",	PARAM_INT, &_tps_dialog_expire},
161 163
 	{"clean_interval",	PARAM_INT, &_tps_clean_interval},
... ...
@@ -50,6 +50,7 @@ extern int _tps_param_mask_callid;
50 50
 extern int _tps_contact_mode;
51 51
 extern str _tps_cparam_name;
52 52
 extern int _tps_rr_update;
53
+extern int _tps_separate_via;
53 54
 
54 55
 extern str _tps_context_param;
55 56
 extern str _tps_context_value;
... ...
@@ -631,10 +632,53 @@ int tps_remove_name_headers(sip_msg_t *msg, str *hname)
631 632
 /**
632 633
  *
633 634
  */
635
+int tps_reappend_via_separate_header(sip_msg_t *msg, tps_data_t *ptsd, str *hbody)
636
+{
637
+        str hname = str_init("Via");
638
+        int i;
639
+        str sb;
640
+        char *p = NULL;
641
+
642
+        if(hbody==NULL || hbody->s==NULL || hbody->len<=0 || hbody->s[0]=='\0')
643
+            return 0;
644
+
645
+        sb.len = 1;
646
+        p = hbody->s;
647
+        for(i=0; i<hbody->len-1; i++) {
648
+            if(hbody->s[i]==',') {
649
+                if(sb.len>0) {
650
+                    sb.s = p;
651
+                    if(sb.s[sb.len-1]==',') sb.len--;
652
+                    if(tps_add_headers(msg, &hname, &sb, 0)<0) {
653
+                        return -1;
654
+                    }
655
+                }
656
+                sb.len = 0;
657
+                p = hbody->s + i + 1;
658
+            }
659
+            sb.len++;
660
+        }
661
+
662
+
663
+        if(sb.len>0) {
664
+                sb.s = p;
665
+                if(sb.s[sb.len-1]==',') sb.len--;
666
+                if(tps_add_headers(msg, &hname, &sb, 0)<0) {
667
+                    return -1;
668
+                }
669
+        }
670
+
671
+
672
+        return 0;
673
+}
674
+
634 675
 int tps_reappend_via(sip_msg_t *msg, tps_data_t *ptsd, str *hbody)
635 676
 {
636 677
 	str hname = str_init("Via");
637 678
 
679
+    if (_tps_separate_via!= 0)
680
+        return tps_reappend_via_separate_header(msg, ptsd, hbody);
681
+
638 682
 	if(tps_add_headers(msg, &hname, hbody, 0)<0) {
639 683
 		return -1;
640 684
 	}