[sr-dev] git:master:da0a6d48: core: new option BUILD_NEW_LOCAL_VIA to recreate the local via
Daniel-Constantin Mierla
miconda at gmail.com
Wed Feb 17 08:24:30 CET 2021
Module: kamailio
Branch: master
Commit: da0a6d48debb9c69c5a06a9e702a4378c61eaac7
URL: https://github.com/kamailio/kamailio/commit/da0a6d48debb9c69c5a06a9e702a4378c61eaac7
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-02-17T08:21:36+01:00
core: new option BUILD_NEW_LOCAL_VIA to recreate the local via
- to be used from tm uac when a local-generated request has to update
the via header following the event route execution
---
Modified: src/core/msg_translator.c
Modified: src/core/msg_translator.h
---
Diff: https://github.com/kamailio/kamailio/commit/da0a6d48debb9c69c5a06a9e702a4378c61eaac7.diff
Patch: https://github.com/kamailio/kamailio/commit/da0a6d48debb9c69c5a06a9e702a4378c61eaac7.patch
---
diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
index f895df9683..c3587d2e88 100644
--- a/src/core/msg_translator.c
+++ b/src/core/msg_translator.c
@@ -1971,7 +1971,7 @@ int check_boundaries(struct sip_msg *msg, struct dest_info *send_info)
* depending on the presence of the BUILD_IN_SHM flag, needs freeing when
* done) and sets returned_len or 0 on error.
*/
-char * build_req_buf_from_sip_req( struct sip_msg* msg,
+char * build_req_buf_from_sip_req(struct sip_msg* msg,
unsigned int *returned_len,
struct dest_info* send_info,
unsigned int mode)
@@ -1987,6 +1987,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
unsigned int offset, s_offset, size;
struct lump* via_anchor;
struct lump* via_lump;
+ struct lump* via_rm;
struct lump* via_insert_param;
struct lump* path_anchor;
struct lump* path_lump;
@@ -2032,11 +2033,22 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
via_anchor=anchor_lump(msg, msg->via1->hdr.s-buf, 0, HDR_VIA_T);
if (unlikely(via_anchor==0)) goto error00;
- line_buf = create_via_hf( &via_len, msg, send_info, &branch);
+ line_buf = create_via_hf(&via_len, msg, send_info, &branch);
if (unlikely(!line_buf)){
LM_ERR("could not create Via header\n");
goto error00;
}
+ if(unlikely(mode&BUILD_NEW_LOCAL_VIA)) {
+ /* delete exiting top Via header */
+ via_rm = del_lump(msg, msg->h_via1->name.s - msg->buf,
+ msg->h_via1->len, 0);
+ if (via_rm==0) {
+ LM_ERR("failed to remove exiting Via header\n");
+ goto error00;
+ }
+ /* do not update old Via header anymore */
+ mode |= BUILD_NO_VIA1_UPDATE;
+ }
after_local_via:
if(unlikely(mode&BUILD_NO_VIA1_UPDATE))
goto after_update_via1;
diff --git a/src/core/msg_translator.h b/src/core/msg_translator.h
index 4d14ce0fb2..9b9802ad1e 100644
--- a/src/core/msg_translator.h
+++ b/src/core/msg_translator.h
@@ -49,6 +49,7 @@
#define BUILD_NO_LOCAL_VIA (1<<0)
#define BUILD_NO_VIA1_UPDATE (1<<1)
#define BUILD_NO_PATH (1<<2)
+#define BUILD_NEW_LOCAL_VIA (1<<3)
#define BUILD_IN_SHM (1<<7)
#include "parser/msg_parser.h"
More information about the sr-dev
mailing list