Browse Source

core: add rport to generated replies after first via branch when no incoming rport

Daniel-Constantin Mierla 7 months ago
parent
commit
09d1ba87f4
1 changed files with 16 additions and 0 deletions
  1. 16 0
      src/core/msg_translator.c

+ 16 - 0
src/core/msg_translator.c

@@ -2683,6 +2683,22 @@ char *build_res_buf_from_sip_req(unsigned int code, str *text, str *new_tag,
 											- msg->via1->rport->start
 											- msg->via1->rport->size,
 									msg);
+						} else if(msg->via1->branch) { /* add after branch */
+							/* copy until after branch */
+							append_str_trans(p, hdr->name.s,
+									msg->via1->branch->start - hdr->name.s
+											+ msg->via1->branch->size,
+									msg);
+							/* copy new rport */
+							append_str(p, rport_buf, rport_len);
+							/* copy the rest of the via */
+							append_str_trans(p,
+									msg->via1->branch->start
+											+ msg->via1->branch->size,
+									hdr->body.s + hdr->body.len
+											- msg->via1->branch->start
+											- msg->via1->branch->size,
+									msg);
 						} else { /* just append the new one */
 							/* normal whole via copy */
 							append_str_trans(p, hdr->name.s,