[sr-dev] git:master:5fb231b6: core: add extra via params from xavp

Daniel-Constantin Mierla miconda at gmail.com
Sun Apr 22 08:42:43 CEST 2018


Module: kamailio
Branch: master
Commit: 5fb231b69f150494a8d51e2581635e98520866ad
URL: https://github.com/kamailio/kamailio/commit/5fb231b69f150494a8d51e2581635e98520866ad

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-04-21T21:16:04+02:00

core: add extra via params from xavp

---

Modified: src/core/msg_translator.c

---

Diff:  https://github.com/kamailio/kamailio/commit/5fb231b69f150494a8d51e2581635e98520866ad.diff
Patch: https://github.com/kamailio/kamailio/commit/5fb231b69f150494a8d51e2581635e98520866ad.patch

---

diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
index 5d7c1866e5..22122768a1 100644
--- a/src/core/msg_translator.c
+++ b/src/core/msg_translator.c
@@ -103,6 +103,8 @@
 #include "parser/parse_param.h"
 #include "forward.h"
 #include "str_list.h"
+#include "pvapi.h"
+#include "xavp.h"
 #include "rand/kam_rand.h"
 
 #define append_str_trans(_dest,_src,_len,_msg) \
@@ -2849,6 +2851,7 @@ char* create_via_hf( unsigned int *len,
 	struct hostport hp;
 	char sbuf[24];
 	int slen;
+	str xparams;
 #if defined USE_TCP || defined USE_SCTP
 	char* id_buf;
 	unsigned int id_len;
@@ -2931,6 +2934,29 @@ char* create_via_hf( unsigned int *len,
 		}
 	}
 
+	/* test and add xavp params */
+	if(msg && (msg->msg_flags&FL_ADD_XAVP_VIA) && _ksr_xavp_via_params.len>0) {
+		xparams.s = pv_get_buffer();
+		xparams.len = xavp_serialize_fields(&_ksr_xavp_via_params,
+							xparams.s, pv_get_buffer_size());
+		if(xparams.len>0) {
+			via = (char*)pkg_malloc(extra_params.len+xparams.len+1);
+			if(via==0) {
+				LM_ERR("building xavps params failed\n");
+				if (extra_params.s) pkg_free(extra_params.s);
+				return 0;
+			}
+			if(extra_params.len != 0) {
+				memcpy(via, extra_params.s, extra_params.len);
+				pkg_free(extra_params.s);
+			}
+			memcpy(via + extra_params.len, xparams.s, xparams.len);
+			extra_params.s = via;
+			extra_params.len += xparams.len;
+			extra_params.s[extra_params.len] = '\0';
+		}
+	}
+
 	set_hostport(&hp, msg);
 	via = via_builder( len, send_info, branch,
 							extra_params.len?&extra_params:0, &hp);




More information about the sr-dev mailing list