<!-- Kamailio Pull Request Template --> Topos module always put a single Via header with multiple comma separated values. Even if this behaviour is RFC compliant there should a possibilty to disable that behaviour four uas that dont support/handle that.
this pull request adds a new parameter topos module to disable that behaviour if needed otherwise the default topos compact form is used.
``` modparam("topos", "separate_via", 1) ``` <!-- IMPORTANT: - for detailed contributing guidelines, read: https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md - pull requests must be done to master branch, unless they are backports of fixes from master branch to a stable branch - backports to stable branches must be done with 'git cherry-pick -x ...' - code is contributed under BSD for core and main components (tm, sl, auth, tls) - code is contributed GPLv2 or a compatible license for the other components - GPL code is contributed with OpenSSL licensing exception -->
#### Pre-Submission Checklist <!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply --> <!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above--> <!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list --> - [x] Commit message has the format required by CONTRIBUTING guide - [x] Commits are split per component (core, individual modules, libs, utils, ...) - [x] Each component has a single commit (if not, squash them into one commit) - [x] No commits to README files for modules (changes must be done to docbook files in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change - [ ] Small bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds new functionality) - [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist: <!-- Go over all points below, and after creating the PR, tick the checkboxes that apply --> - [x] PR should be backported to stable branches - [x] Tested changes locally - [ ] Related to issue #3216
#### Description <!-- Describe your changes in detail -->
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3220
-- Commit Summary --
* topos: enable multiple Via values in separate via header
-- File Changes --
M src/modules/topos/topos_mod.c (2) M src/modules/topos/tps_msg.c (48)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3220.patch https://github.com/kamailio/kamailio/pull/3220.diff
Hello can you please remove the uncessary condition if (c==0 || c== 1) {} and leave only the body of that condition please and remove also the unused c variable. we dont need it.
Thanks.
Hello can you please remove the uncessary condition if (c==0 || c== 1) {} and leave only the body of that condition please and remove also the unused c variable. we dont need it.
should be like this
``` int tps_reappend_via_separate_header(sip_msg_t *msg, tps_data_t *ptsd, str *hbody) { str hname = str_init("Via"); int i; str sb; char *p = NULL;
if(hbody==NULL || hbody->s==NULL || hbody->len<=0 || hbody->s[0]=='\0') return 0;
sb.len = 1; p = hbody->s; for(i=0; i<hbody->len-1; i++) { if(hbody->s[i]==',') { 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(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; }
```
Thanks.
@emvondo: if you want to change the commit of the PR, you can update on your local copy and force push to the same git branch.
@emvondo pushed 1 commit.
674330d33ca0c0ab6fa9e989300cec92734e9e1d topos: enable multiple Via values in separate via header
@emvondo: if you want to change the commit of the PR, you can update on your local copy and force push to the same git branch.
Thanks Daniel.
its done.
@emvondo thanks for the pull request. In the issue #3216 you are also discussing the Route and Record-Route headers. Are you planning to add also individual parameters for this headers in the PR? Maybe it make sense to have a one parameter for all three headers? Just trying to understand the direction of it.
@emvondo thanks for the pull request. The issue #3216 also discusses the Route and Record-Route headers. Are you planning to add also individual parameters for this headers in the PR? Maybe it make sense to have a one parameter for all three headers? Just trying to understand the direction of it.
@henningw yes you are right . its better to have one parameter flag with which we could choose the interested headers for disabling that behaviour.
OK let me update the same PR branch to have all that.
Ok, sounds good. As you probably know, the documentation (XML docbook) needs to be extended as well, to be ready for the merge. But its usually a good idea to do that at the end after all code changes were done.
@emvondo pushed 1 commit.
f06ecefeb7f1533370cd5ad726128c64c3006084 topos: disable multiple comma separated values in One Single Via, Record-Route or Route header
Ok, sounds good. As you probably know, the documentation (XML docbook) needs to be extended as well, to be ready for the merge. But its usually a good idea to do that at the end after all code changes were done.
Thanks for feedback.
i pushed updates for Via , Record-Route and Route header.
@emvondo pushed 1 commit.
82822f3dfd7df124e3d7cfe4ae7928fb6646ab8a topos: disable multiple comma separated values in One Single Via, Record-Route or Route header
@emvondo pushed 1 commit.
4816a86bf6fe82d8bf20c31909f5db6205added4 topos: disable multiple comma separated values in One Single Via, Record-Route or Route header
Thank you, lgtm. @miconda any comments from your side? Otherwise I think it could be merged, preferable squashed to one commit.
The name of the parameter `separate_header_values` should be changed to `header_mode` to be even more generic and reused if anything else related to header management needs to be added in the future (e.g., add Via before or after Route).
From implementation point of view, the current solution is "good enough" because it is doing a basic split on comma, working with the common format seen for these headers. Otherwise, at least the `Record/-Route` can have comma in its value, being defined as `name-addr` by grammar and in the eventuality of a display name, comma is allowed inside. Not sure if Via is allowed to have quoted value parameter, because I think inside it is also allowed to have comma.
Anyhow, given that this commit adds this behaviour for particular deployments when some UA doesn't support headers with multiple comma separated values, I am fine to merge the implementation as it is, after renaming the parameter.
@emvondo pushed 1 commit.
8dc1e856c590430ec591e8f53ef1df608abfcaef change parameter name for disabling compact form values
The name of the parameter `separate_header_values` should be changed to `header_mode` to be even more generic and reused if anything else related to header management needs to be added in the future (e.g., add Via before or after Route).
From implementation point of view, the current solution is "good enough" because it is doing a basic split on comma, working with the common format seen for these headers. Otherwise, at least the `Record/-Route` can have comma in its value, being defined as `name-addr` by grammar and in the eventuality of a display name, comma is allowed inside. Not sure if Via is allowed to have quoted value parameter, because I think inside it is also allowed to have comma.
Anyhow, given that this commit adds this behaviour for particular deployments when some UA doesn't support headers with multiple comma separated values, I am fine to merge the implementation as it is, after renaming the parameter.
Thanks for feedback @miconda changes done.
Merged #3220 into master.
Thank you all, merged.