From da15e031272012909e6f9af07cda0805298f892d Mon Sep 17 00:00:00 2001 From: emvondo Date: Tue, 16 Aug 2022 19:24:59 +0100 Subject: [PATCH 1/6] topos: enable multiple Via values in separate via header --- src/modules/topos/topos_mod.c | 2 ++ src/modules/topos/tps_msg.c | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/modules/topos/topos_mod.c b/src/modules/topos/topos_mod.c index 90c60e39e42..a5f641b599d 100644 --- a/src/modules/topos/topos_mod.c +++ b/src/modules/topos/topos_mod.c @@ -81,6 +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; str _tps_storage = str_init("db"); extern int _tps_branch_expire; @@ -156,6 +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}, {"branch_expire", PARAM_INT, &_tps_branch_expire}, {"dialog_expire", PARAM_INT, &_tps_dialog_expire}, {"clean_interval", PARAM_INT, &_tps_clean_interval}, diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c index 5e1b1be0324..4a5b07b6fd6 100644 --- a/src/modules/topos/tps_msg.c +++ b/src/modules/topos/tps_msg.c @@ -50,6 +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 str _tps_context_param; extern str _tps_context_value; @@ -631,10 +632,57 @@ 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) +{ + str hname = str_init("Via"); + int i; + int c; + str sb; + char *p = NULL; + + if(hbody==NULL || hbody->s==NULL || hbody->len<=0 || hbody->s[0]=='\0') + return 0; + + + c = 0; + sb.len = 1; + p = hbody->s; + for(i=0; ilen-1; i++) { + if(hbody->s[i]==',') { + c = 1; + if(sb.len>0) { + sb.s = p; + if(sb.s[sb.len-1]==',') sb.len--; + if(tps_add_headers(msg, &hname, &sb, 0)<0) { + return -1; + } + } + sb.len = 0; + p = hbody->s + i + 1; + } + sb.len++; + } + + if(c==0 || c== 1) { + if(sb.len>0) { + sb.s = p; + if(sb.s[sb.len-1]==',') sb.len--; + if(tps_add_headers(msg, &hname, &sb, 0)<0) { + return -1; + } + } + } + + return 0; +} + 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_add_headers(msg, &hname, hbody, 0)<0) { return -1; } From 674330d33ca0c0ab6fa9e989300cec92734e9e1d Mon Sep 17 00:00:00 2001 From: emvondo Date: Wed, 17 Aug 2022 11:05:54 +0100 Subject: [PATCH 2/6] topos: enable multiple Via values in separate via header --- src/modules/topos/tps_msg.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c index 4a5b07b6fd6..ab64e16e4c2 100644 --- a/src/modules/topos/tps_msg.c +++ b/src/modules/topos/tps_msg.c @@ -636,20 +636,16 @@ int tps_reappend_via_separate_header(sip_msg_t *msg, tps_data_t *ptsd, str *hbod { str hname = str_init("Via"); int i; - int c; str sb; char *p = NULL; if(hbody==NULL || hbody->s==NULL || hbody->len<=0 || hbody->s[0]=='\0') return 0; - - c = 0; sb.len = 1; p = hbody->s; for(i=0; ilen-1; i++) { if(hbody->s[i]==',') { - c = 1; if(sb.len>0) { sb.s = p; if(sb.s[sb.len-1]==',') sb.len--; @@ -663,16 +659,16 @@ int tps_reappend_via_separate_header(sip_msg_t *msg, tps_data_t *ptsd, str *hbod sb.len++; } - if(c==0 || c== 1) { - if(sb.len>0) { + + if(sb.len>0) { sb.s = p; if(sb.s[sb.len-1]==',') sb.len--; if(tps_add_headers(msg, &hname, &sb, 0)<0) { return -1; } - } } + return 0; } From f06ecefeb7f1533370cd5ad726128c64c3006084 Mon Sep 17 00:00:00 2001 From: emvondo Date: Thu, 18 Aug 2022 18:29:57 +0100 Subject: [PATCH 3/6] topos: disable multiple comma separated values in One Single Via, Record-Route or Route header --- src/modules/topos/topos_mod.c | 4 ++-- src/modules/topos/tps_msg.c | 19 ++++++++++++------- src/modules/topos/tps_msg.h | 4 ++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/modules/topos/topos_mod.c b/src/modules/topos/topos_mod.c index a5f641b599d..55197b66853 100644 --- a/src/modules/topos/topos_mod.c +++ b/src/modules/topos/topos_mod.c @@ -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; @@ -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}, diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c index ab64e16e4c2..b90e8248ee5 100644 --- a/src/modules/topos/tps_msg.c +++ b/src/modules/topos/tps_msg.c @@ -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; @@ -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; @@ -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; } } @@ -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; } } @@ -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; @@ -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; } @@ -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; } diff --git a/src/modules/topos/tps_msg.h b/src/modules/topos/tps_msg.h index b8efbc401b1..ce9d8b70078 100644 --- a/src/modules/topos/tps_msg.h +++ b/src/modules/topos/tps_msg.h @@ -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); From 82822f3dfd7df124e3d7cfe4ae7928fb6646ab8a Mon Sep 17 00:00:00 2001 From: emvondo Date: Thu, 18 Aug 2022 18:50:08 +0100 Subject: [PATCH 4/6] topos: disable multiple comma separated values in One Single Via, Record-Route or Route header --- src/modules/topos/doc/topos_admin.xml | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/modules/topos/doc/topos_admin.xml b/src/modules/topos/doc/topos_admin.xml index 6ddf9f2783a..75cec316b0d 100644 --- a/src/modules/topos/doc/topos_admin.xml +++ b/src/modules/topos/doc/topos_admin.xml @@ -543,6 +543,34 @@ modparam("topos", "context", "srvone") ... modparam("topos", "methods_nocontact", "CANCEL,PRACK") ... + + + +
+ <varname>separate_header_values</varname> (int) + + List of headers to disable multiple comma separated values inserted in compact form. + Altough compact form is RFC compliant this paramter gives possibilty to disable + compact form header values for UA that dont support/handle it. + + The following options are available: + + (1) - disable multiple comma separated values for Via header + (2) - disable multiple comma separated values for Record-Route header + (4) - disable multiple comma separated values for Route header + + + + + Default value is 0. + + + + Set <varname>separate_header_values</varname> parameter + +... +modparam("topos", "separate_header_values", 1) +...
From 4816a86bf6fe82d8bf20c31909f5db6205added4 Mon Sep 17 00:00:00 2001 From: emvondo Date: Thu, 18 Aug 2022 18:55:03 +0100 Subject: [PATCH 5/6] topos: disable multiple comma separated values in One Single Via, Record-Route or Route header --- src/modules/topos/tps_msg.c | 6 +++--- src/modules/topos/tps_msg.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c index b90e8248ee5..dd27462a5ec 100644 --- a/src/modules/topos/tps_msg.c +++ b/src/modules/topos/tps_msg.c @@ -676,7 +676,7 @@ int tps_reappend_via(sip_msg_t *msg, tps_data_t *ptsd, str *hbody) { str hname = str_init("Via"); - if (TPS_SEPERATE_VIA & _tps_separate_hv) + if (TPS_SPLIT_VIA & _tps_separate_hv) return tps_reappend_separate_header_values(msg, ptsd, hbody,&hname); if(tps_add_headers(msg, &hname, hbody, 0)<0) { @@ -788,7 +788,7 @@ 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) + if (TPS_SPLIT_RECORD_ROUTE & _tps_separate_hv) return tps_reappend_separate_header_values(msg, ptsd, hbody,&hname); if(tps_add_headers(msg, &hname, hbody, 0)<0) { @@ -845,7 +845,7 @@ 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) + if (TPS_SPLIT_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; diff --git a/src/modules/topos/tps_msg.h b/src/modules/topos/tps_msg.h index ce9d8b70078..93f768462fe 100644 --- a/src/modules/topos/tps_msg.h +++ b/src/modules/topos/tps_msg.h @@ -31,9 +31,9 @@ #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) +#define TPS_SPLIT_VIA (1<<0) +#define TPS_SPLIT_RECORD_ROUTE (1<<1) +#define TPS_SPLIT_ROUTE (1<<2) int tps_update_hdr_replaces(sip_msg_t *msg); char* tps_msg_update(sip_msg_t *msg, unsigned int *olen); From 8dc1e856c590430ec591e8f53ef1df608abfcaef Mon Sep 17 00:00:00 2001 From: emvondo Date: Sat, 20 Aug 2022 10:17:25 +0100 Subject: [PATCH 6/6] change parameter name for disabling compact form values --- src/modules/topos/doc/topos_admin.xml | 8 ++++---- src/modules/topos/topos_mod.c | 4 ++-- src/modules/topos/tps_msg.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/modules/topos/doc/topos_admin.xml b/src/modules/topos/doc/topos_admin.xml index 75cec316b0d..c15fcf245e9 100644 --- a/src/modules/topos/doc/topos_admin.xml +++ b/src/modules/topos/doc/topos_admin.xml @@ -546,8 +546,8 @@ modparam("topos", "methods_nocontact", "CANCEL,PRACK") -
- <varname>separate_header_values</varname> (int) +
+ <varname>header_mode</varname> (int) List of headers to disable multiple comma separated values inserted in compact form. Altough compact form is RFC compliant this paramter gives possibilty to disable @@ -566,10 +566,10 @@ modparam("topos", "methods_nocontact", "CANCEL,PRACK") - Set <varname>separate_header_values</varname> parameter + Set <varname>header_mode</varname> parameter ... -modparam("topos", "separate_header_values", 1) +modparam("topos", "header_mode", 1) ... diff --git a/src/modules/topos/topos_mod.c b/src/modules/topos/topos_mod.c index 55197b66853..0d36058188c 100644 --- a/src/modules/topos/topos_mod.c +++ b/src/modules/topos/topos_mod.c @@ -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_hv = 0; +int _tps_header_mode = 0; str _tps_storage = str_init("db"); extern int _tps_branch_expire; @@ -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_header_values", PARAM_INT, &_tps_separate_hv}, + {"header_mode", PARAM_INT, &_tps_header_mode}, {"branch_expire", PARAM_INT, &_tps_branch_expire}, {"dialog_expire", PARAM_INT, &_tps_dialog_expire}, {"clean_interval", PARAM_INT, &_tps_clean_interval}, diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c index dd27462a5ec..a19b30dcfc4 100644 --- a/src/modules/topos/tps_msg.c +++ b/src/modules/topos/tps_msg.c @@ -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_hv; +extern int _tps_header_mode; extern str _tps_context_param; extern str _tps_context_value; @@ -676,7 +676,7 @@ int tps_reappend_via(sip_msg_t *msg, tps_data_t *ptsd, str *hbody) { str hname = str_init("Via"); - if (TPS_SPLIT_VIA & _tps_separate_hv) + if (TPS_SPLIT_VIA & _tps_header_mode) return tps_reappend_separate_header_values(msg, ptsd, hbody,&hname); if(tps_add_headers(msg, &hname, hbody, 0)<0) { @@ -788,7 +788,7 @@ int tps_reappend_rr(sip_msg_t *msg, tps_data_t *ptsd, str *hbody) { str hname = str_init("Record-Route"); - if (TPS_SPLIT_RECORD_ROUTE & _tps_separate_hv) + if (TPS_SPLIT_RECORD_ROUTE & _tps_header_mode) return tps_reappend_separate_header_values(msg, ptsd, hbody,&hname); if(tps_add_headers(msg, &hname, hbody, 0)<0) { @@ -845,7 +845,7 @@ 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_SPLIT_ROUTE & _tps_separate_hv) + if (TPS_SPLIT_ROUTE & _tps_header_mode) return tps_reappend_separate_header_values(msg, ptsd, &sb,&hname); if(tps_add_headers(msg, &hname, &sb, 0)<0) { return -1;