Module: kamailio
Branch: master
Commit: ded5a70ed6bec3513c18044bd8852989a1d3f680
URL:
https://github.com/kamailio/kamailio/commit/ded5a70ed6bec3513c18044bd885298…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-04-12T09:51:10+02:00
core: new internal msg flag to add srvid param to local via
---
Modified: src/core/msg_translator.c
Modified: src/core/parser/msg_parser.h
---
Diff:
https://github.com/kamailio/kamailio/commit/ded5a70ed6bec3513c18044bd885298…
Patch:
https://github.com/kamailio/kamailio/commit/ded5a70ed6bec3513c18044bd885298…
---
diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
index ca0f9fa521..e7a6deeeb2 100644
--- a/src/core/msg_translator.c
+++ b/src/core/msg_translator.c
@@ -2847,6 +2847,8 @@ char* create_via_hf( unsigned int *len,
char* via;
str extra_params;
struct hostport hp;
+ char sbuf[24];
+ int slen;
#if defined USE_TCP || defined USE_SCTP
char* id_buf;
unsigned int id_len;
@@ -2906,6 +2908,29 @@ char* create_via_hf( unsigned int *len,
extra_params.s[extra_params.len]='\0';
}
+ /* test and add srvid parameter to local via */
+ if(msg && msg->msg_flags&FL_ADD_SRVID && server_id!=0) {
+ slen = snprintf(sbuf, 24, ";srvid=%u", (unsigned int)server_id);
+ if(slen<=0 || slen>=24) {
+ LM_WARN("failed to buld srvid parameter");
+ } else {
+ via = (char*)pkg_malloc(extra_params.len+slen+1);
+ if(via==0) {
+ LM_ERR("building srvid param 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, sbuf, slen);
+ extra_params.s = via;
+ extra_params.len += slen;
+ 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);
diff --git a/src/core/parser/msg_parser.h b/src/core/parser/msg_parser.h
index 3d69e8d462..b06ff0d8d2 100644
--- a/src/core/parser/msg_parser.h
+++ b/src/core/parser/msg_parser.h
@@ -100,6 +100,7 @@ typedef enum request_method {
#define FL_BODY_MULTIPART (1<<17) /* body modified is multipart */
#define FL_RR_ADDED (1<<18) /* Record-Route header was added */
#define FL_UAC_AUTH (1<<19) /* Proxy UAC-like authentication */
+#define FL_ADD_SRVID (1<<20) /*!< add 'srvid' to local via hdr
*/
/* WARNING: Value (1 << 28) is temporarily reserved for use in kamailio
call_control
* module (flag FL_USE_CALL_CONTROL )! */