mirror of https://github.com/sipwise/kamailio.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.6 KiB
97 lines
3.6 KiB
From ad3ae0133f321e357cf09f65f2067ed10d9c64a2 Mon Sep 17 00:00:00 2001
|
|
From: Richard Fuchs <rfuchs@sipwise.com>
|
|
Date: Tue, 28 Jan 2020 09:13:11 -0500
|
|
Subject: [PATCH] rtpengine: update/fix via-branch=next ID generation
|
|
|
|
- via-branch=next should not use a hard-coded branch index of zero, but
|
|
instead use the actual branch index from the tm module
|
|
- also adds via-branch=auto-next and via-branch=auto-extra for easier
|
|
processing in scripts
|
|
---
|
|
diff --git a/src/modules/rtpengine/rtpengine.c b/src/modules/rtpengine/rtpengine.c
|
|
index 9399f94e00..4db1461f0d 100644
|
|
--- a/src/modules/rtpengine/rtpengine.c
|
|
+++ b/src/modules/rtpengine/rtpengine.c
|
|
@@ -2268,6 +2268,10 @@ static int parse_flags(struct ng_flags_parse *ng_flags, struct sip_msg *msg, enu
|
|
ng_flags->via = -1;
|
|
else if (str_eq(&val, "next"))
|
|
ng_flags->via = -2;
|
|
+ else if (str_eq(&val, "auto-next") || str_eq(&val, "next-auto"))
|
|
+ ng_flags->via = -3;
|
|
+ else if (str_eq(&val, "auto-extra") || str_eq(&val, "extra-auto"))
|
|
+ ng_flags->via = -4;
|
|
else
|
|
goto error;
|
|
goto next;
|
|
@@ -2363,6 +2367,8 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
|
|
char md5[MD5_LEN];
|
|
char branch_buf[MAX_BRANCH_PARAM_LEN];
|
|
bencode_item_t *result;
|
|
+ tm_cell_t *t;
|
|
+ unsigned int branch_idx;
|
|
|
|
/*** get & init basic stuff needed ***/
|
|
|
|
@@ -2453,11 +2459,21 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
|
|
bencode_dictionary_add_str(ng_flags.dict, "call-id", &ng_flags.call_id);
|
|
|
|
if (ng_flags.via) {
|
|
- ret = -1;
|
|
+ /* pre-process */
|
|
switch (ng_flags.via) {
|
|
case 3:
|
|
ng_flags.via = (msg->first_line.type == SIP_REPLY) ? 2 : 1;
|
|
- /* fall thru */
|
|
+ break;
|
|
+ case -3:
|
|
+ ng_flags.via = (msg->first_line.type == SIP_REPLY) ? 1 : -2;
|
|
+ break;
|
|
+ case -4:
|
|
+ ng_flags.via = (msg->first_line.type == SIP_REPLY) ? 1 : -1;
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ ret = -1;
|
|
+ switch (ng_flags.via) {
|
|
case 1:
|
|
case 2:
|
|
ret = get_via_branch(msg, ng_flags.via, &viabranch);
|
|
@@ -2469,10 +2485,16 @@ static bencode_item_t *rtpp_function_call(bencode_buffer_t *bencbuf, struct sip_
|
|
case -2:
|
|
if (!char_msg_val(msg, md5))
|
|
break;
|
|
+ branch_idx = 0;
|
|
+ if (tmb.t_gett) {
|
|
+ t = tmb.t_gett();
|
|
+ if (t && t != T_UNDEFINED)
|
|
+ branch_idx = t->nr_of_outgoings;
|
|
+ }
|
|
msg->hash_index = hash(msg->callid->body, get_cseq(msg)->number);
|
|
|
|
viabranch.s = branch_buf;
|
|
- if (branch_builder(msg->hash_index, 0, md5, 0, branch_buf, &viabranch.len))
|
|
+ if (branch_builder(msg->hash_index, 0, md5, branch_idx, branch_buf, &viabranch.len))
|
|
ret = 0;
|
|
break;
|
|
}
|
|
--- a/src/modules/rtpengine/doc/rtpengine_admin.xml
|
|
+++ b/src/modules/rtpengine/doc/rtpengine_admin.xml
|
|
@@ -2063,7 +2063,13 @@
|
|
<quote>auto</quote> - use the first <quote>Via</quote> header if this is
|
|
a request, or the second one if this is a reply;
|
|
<quote>extra</quote> - don't take the value from a header, but instead use
|
|
- the value of the <quote>extra_id_pv</quote> variable.
|
|
+ the value of the <quote>extra_id_pv</quote> variable;
|
|
+ <quote>next</quote> - use the branch ID generated by &kamailio; for the
|
|
+ next outgoing branch;
|
|
+ <quote>auto-next</quote> - use <quote>next</quote> in requests and
|
|
+ <quote>1</quote> in replies;
|
|
+ <quote>auto-extra</quote> - use <quote>extra</quote> in requests and
|
|
+ <quote>1</quote> in replies.
|
|
This can be used to create one media session per branch
|
|
on the &rtp; proxy. When sending a subsequent <quote>delete</quote> command to
|
|
the &rtp; proxy, you can then stop just the session for a specific branch when
|
|
--
|
|
2.20.1
|
|
|