Skip to content

Commit

Permalink
core: new option BUILD_NEW_LOCAL_VIA to recreate the local via
Browse files Browse the repository at this point in the history
- to be used from tm uac when a local-generated request has to update
the via header following the event route execution
  • Loading branch information
miconda committed Feb 17, 2021
1 parent cc4644e commit da0a6d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/msg_translator.c
Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/core/msg_translator.h
Expand Up @@ -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"
Expand Down

0 comments on commit da0a6d4

Please sign in to comment.