GH #
#### Pre-Submission Checklist - [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 - [x] Small bug fix (non-breaking change which fixes an issue) - [ ] 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 --> - [ ] PR should be backported to stable branches - [ ] Tested changes locally - [ ] Related to issue #3210
#### Description
Added 'always_log_missed_content_length' mode for sanity module. If 'always_log_missed_content_length' is 1 then the SIP message with no 'Content-Length' header will cause warning message in the logs. Otherwise warning message is not generated for cases when SIP message with no 'Content-Length' header is sent over UDP.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3359
-- Commit Summary --
* No warning generated when UDP and no Content-Length header
-- File Changes --
M src/modules/sanity/doc/sanity_admin.xml (21) M src/modules/sanity/sanity.c (4) M src/modules/sanity/sanity_mod.c (12) M src/modules/sanity/sanity_mod.h (3)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3359.patch https://github.com/kamailio/kamailio/pull/3359.diff
@sergey-safarov pushed 1 commit.
1f4e21130751ca90292ef5c1b112f40d879661fa No warning generated when UDP and no Content-Length header
Content-Length is not mandatory for UDP, the sip message is required to be in a single datagram.
Even that one can check with `is_present_hf("Content-Length")` and write a log message from config, I am fine to add an option to log from the module, but I would prefer to be a more generic approach, in order to reuse the same mechanism for similar needs. I would go with a new parameter like `log_filter` and then use flags (bits) to control what is logged or not (e.g., bit 1 set, the log missing content length).
As an common recommendation, parameter names should be kept short, ideally one-two words, not to have a very long snake-case name. The name should be suggestive (related to its purpose), but `not_the_full_description_of_the_parameter`.
And do not forget the commit message format, check the CONTRIBUTING guide for it.
This should apply not only to UDP and SCTP, but also to WebSockets: https://www.rfc-editor.org/rfc/rfc7118.html#section-5
Because the WebSocket transport preserves message boundaries, the use of the Content-Length header in SIP messages is not necessary when they are transported using the WebSocket subprotocol.
This simplifies the parsing of SIP messages for both clients and servers. There is no need to establish message boundaries using Content-Length headers between messages. Other SIP transports, such as UDP and the Stream Control Transmission Protocol (SCTP) [[RFC4168](https://www.rfc-editor.org/rfc/rfc4168)], also provide this benefit.
Thanks for the PR. Any plans to integrate the remarks made from Daniel some weeks ago?
yes, @henningw we will make these changes.
Closing this one for aging, just reopen or make a new PR when ready.
Closed #3359.
Implementing this is a really good idea and I am looking forward to see progress on this improvement.