Module: kamailio
Branch: master
Commit: 439eae7aa2154a25a0d9143345e526e22162b24f
URL:
https://github.com/kamailio/kamailio/commit/439eae7aa2154a25a0d9143345e526e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-09-06T21:08:20+02:00
core: ability to add paramters to top via of generated sip replies
- parameters and values are taken from xavp specified by xavp_via_reply_params
---
Modified: src/core/globals.h
Modified: src/core/msg_translator.c
---
Diff:
https://github.com/kamailio/kamailio/commit/439eae7aa2154a25a0d9143345e526e…
Patch:
https://github.com/kamailio/kamailio/commit/439eae7aa2154a25a0d9143345e526e…
---
diff --git a/src/core/globals.h b/src/core/globals.h
index da693a06bae..a11f8521a3b 100644
--- a/src/core/globals.h
+++ b/src/core/globals.h
@@ -218,6 +218,7 @@ extern int ksr_all_errors;
extern int ksr_route_locks_size;
extern str _ksr_xavp_via_params;
extern str _ksr_xavp_via_fields;
+extern str _ksr_xavp_via_reply_params;
extern int ksr_sip_parser_mode;
extern int ksr_cfg_print_mode;
extern int ksr_return_mode;
diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
index fcc6f133439..c5c4172c045 100644
--- a/src/core/msg_translator.c
+++ b/src/core/msg_translator.c
@@ -114,6 +114,7 @@ extern int version_len;
str _ksr_xavp_via_params = STR_NULL;
str _ksr_xavp_via_fields = STR_NULL;
+str _ksr_xavp_via_reply_params = STR_NULL;
int ksr_local_rport = 0;
/** per process fixup function for global_req_flags.
@@ -2415,6 +2416,7 @@ char *build_res_buf_from_sip_req(unsigned int code, str *text, str
*new_tag,
char *totags;
int httpreq;
char *pvia;
+ str xparams = STR_NULL;
body = 0;
buf = 0;
@@ -2456,6 +2458,17 @@ char *build_res_buf_from_sip_req(unsigned int code, str *text, str
*new_tag,
len -= msg->via1->rport->size + 1; /* include ';' */
}
+ /* test and add xavpvia params */
+ if(msg && (msg->msg_flags & FL_ADD_XAVP_VIA_REPLY_PARAMS)
+ && _ksr_xavp_via_reply_params.len > 0) {
+ xparams.s = pv_get_buffer();
+ xparams.len = xavp_serialize_fields(
+ &_ksr_xavp_via_reply_params, xparams.s, pv_get_buffer_size());
+ if(xparams.len > 0) {
+ len += xparams.len; /* ending ';' included */
+ }
+ }
+
/* first line */
len += msg->first_line.u.request.version.len
+ 1 /*space*/ + 3 /*code*/ + 1 /*space*/ + text->len
@@ -2588,6 +2601,10 @@ char *build_res_buf_from_sip_req(unsigned int code, str *text, str
*new_tag,
append_str_trans(p, hdr->name.s,
(hdr->body.s + hdr->body.len) - hdr->name.s, msg);
}
+ if(xparams.len > 0) {
+ append_str(p, ";", 1);
+ append_str(p, xparams.s, xparams.len - 1);
+ }
append_str(p, CRLF, CRLF_LEN);
/* if is HTTP, replace Via with Sia
* - HTTP Via format is different than SIP Via