Hello everyone,
My company operates a FreePBX system running ~500 endpoints, and have been having issues with calls forwarded externally of the system being anonymized.
Our SIP trunk provider sends privacy headers for calls not requesting anonymity in this format:
Privacy: off
I understand that this is not a token value recognized under RFC 3323, and assume off
is a being used as a synonym for none
, but the industry has adopted this value widely enough that it now needs to be accounted for.
I found that in the res_pjsip.c file, at line 2728 in Asterisk 22.4, this logic statement is provided:
It appears that this only provides the ability to parse single-token values in the privacy, and sets calls to prohibited (Anonymous) if the value does not match “none”.
To test my theory, I included “off” as a value to match:
if (!privacy || !pj_stricmp2(&privacy->hvalue, "none") || !pj_stricmp2(&privacy->hvalue, "off")) {
I compiled with this modification on a test system, and the issue seems to be fixed.
I am not well-versed in C or the Asterisk codebase, so I would like input on whether this is the appropriate way to fix this behavior.
If this is in fact the section that handles the privacy header, it would be great if it could also handle multiple values, as described in RFC 3323. Being able to parse values separated by semicolons and spaces, as well as leading and/or trailing spaces. Being able to handle commas is a requirement for some other systems not fully compliant with RFC 3323.
The code should follow this logic statement:
“Privacy header values that include tokens other than “off” and “none” should be anonymized.”
This logical statement is given due to the non-granular privacy of the original code. Further RFC compliance may be a bit more challenging. In my opinion, an “on and off” approach to privacy is still acceptable until further provisions are made. Being able to parse the values is my main goal in bringing this up.
To further clarify, here’s some examples of multiple-value Privacy headers and how I interpret they should be handled:
• Privacy: off;none
(Behavior should be to present user details normally, log RFC violation)
• Privacy: off , none
(Behavior should be to present user details normally, log RFC violation)
• Privacy: none; none,off
(Behavior should be to present user details normally, log RFC violation)
• Privacy: id ;off
(Reject with 400 Bad Request
, log RFC violation)
• Privacy: session;header
(Anonymize the call accordingly)
• Privacy: header;session;id;user
(Anonymize the call accordingly)
Even if some of these input values are sent in a strange way due to the configuration of other provider’s systems, Asterisk should be capable of fully interpreting header contents. I can tell you from experience, people don’t like when all their incoming calls are being anonymized!
Thanks in advance.