Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

topos: disable multiple comma separated values in One Single Via, Record-Route or Route header if needed #3220

Merged
4 changes: 2 additions & 2 deletions src/modules/topos/topos_mod.c
Expand Up @@ -81,7 +81,7 @@ static str _tps_db_url = str_init(DEFAULT_DB_URL);
int _tps_param_mask_callid = 0;
int _tps_sanity_checks = 0;
int _tps_rr_update = 0;
int _tps_separate_via = 0;
int _tps_separate_hv = 0;
str _tps_storage = str_init("db");

extern int _tps_branch_expire;
Expand Down Expand Up @@ -157,7 +157,7 @@ static param_export_t params[]={
{"db_url", PARAM_STR, &_tps_db_url},
{"mask_callid", PARAM_INT, &_tps_param_mask_callid},
{"sanity_checks", PARAM_INT, &_tps_sanity_checks},
{"separate_via", PARAM_INT, &_tps_separate_via},
{"separate_header_values", PARAM_INT, &_tps_separate_hv},
{"branch_expire", PARAM_INT, &_tps_branch_expire},
{"dialog_expire", PARAM_INT, &_tps_dialog_expire},
{"clean_interval", PARAM_INT, &_tps_clean_interval},
Expand Down
19 changes: 12 additions & 7 deletions src/modules/topos/tps_msg.c
Expand Up @@ -50,7 +50,7 @@ extern int _tps_param_mask_callid;
extern int _tps_contact_mode;
extern str _tps_cparam_name;
extern int _tps_rr_update;
extern int _tps_separate_via;
extern int _tps_separate_hv;

extern str _tps_context_param;
extern str _tps_context_value;
Expand Down Expand Up @@ -632,9 +632,9 @@ int tps_remove_name_headers(sip_msg_t *msg, str *hname)
/**
*
*/
int tps_reappend_via_separate_header(sip_msg_t *msg, tps_data_t *ptsd, str *hbody)
int tps_reappend_separate_header_values(sip_msg_t *msg, tps_data_t *ptsd, str *hbody, str *hname)
{
str hname = str_init("Via");

int i;
str sb;
char *p = NULL;
Expand All @@ -649,7 +649,7 @@ int tps_reappend_via_separate_header(sip_msg_t *msg, tps_data_t *ptsd, str *hbod
if(sb.len>0) {
sb.s = p;
if(sb.s[sb.len-1]==',') sb.len--;
if(tps_add_headers(msg, &hname, &sb, 0)<0) {
if(tps_add_headers(msg, hname, &sb, 0)<0) {
return -1;
}
}
Expand All @@ -663,7 +663,7 @@ int tps_reappend_via_separate_header(sip_msg_t *msg, tps_data_t *ptsd, str *hbod
if(sb.len>0) {
sb.s = p;
if(sb.s[sb.len-1]==',') sb.len--;
if(tps_add_headers(msg, &hname, &sb, 0)<0) {
if(tps_add_headers(msg, hname, &sb, 0)<0) {
return -1;
}
}
Expand All @@ -676,8 +676,8 @@ int tps_reappend_via(sip_msg_t *msg, tps_data_t *ptsd, str *hbody)
{
str hname = str_init("Via");

if (_tps_separate_via!= 0)
return tps_reappend_via_separate_header(msg, ptsd, hbody);
if (TPS_SEPERATE_VIA & _tps_separate_hv)
return tps_reappend_separate_header_values(msg, ptsd, hbody,&hname);

if(tps_add_headers(msg, &hname, hbody, 0)<0) {
return -1;
Expand Down Expand Up @@ -788,6 +788,9 @@ int tps_reappend_rr(sip_msg_t *msg, tps_data_t *ptsd, str *hbody)
{
str hname = str_init("Record-Route");

if (TPS_SEPERATE_RECORD_ROUTE & _tps_separate_hv)
return tps_reappend_separate_header_values(msg, ptsd, hbody,&hname);

if(tps_add_headers(msg, &hname, hbody, 0)<0) {
return -1;
}
Expand Down Expand Up @@ -842,6 +845,8 @@ int tps_reappend_route(sip_msg_t *msg, tps_data_t *ptsd, str *hbody, int rev)
trim_zeros_lr(&sb);
trim(&sb);
if(sb.len>0 && sb.s[sb.len-1]==',') sb.len--;
if (TPS_SEPERATE_ROUTE & _tps_separate_hv)
return tps_reappend_separate_header_values(msg, ptsd, &sb,&hname);
if(tps_add_headers(msg, &hname, &sb, 0)<0) {
return -1;
}
Expand Down
4 changes: 4 additions & 0 deletions src/modules/topos/tps_msg.h
Expand Up @@ -31,6 +31,10 @@

#include "../../core/parser/msg_parser.h"

#define TPS_SEPERATE_VIA (1<<0)
#define TPS_SEPERATE_RECORD_ROUTE (1<<1)
#define TPS_SEPERATE_ROUTE (1<<2)

int tps_update_hdr_replaces(sip_msg_t *msg);
char* tps_msg_update(sip_msg_t *msg, unsigned int *olen);
int tps_skip_msg(sip_msg_t *msg);
Expand Down