Hello everyone,
While going through the WebRTC example configuration (cfg) to better understand and implement it in my setup, I came across a potential issue in the code block. The code in question can be found at this link: https://github.com/kamailio/kamailio/blob/465994de2859c7863b4cef8457be0a207f...
In the code, there is an "if else" block, "if(loose_route())" that seems to be incorrect. It appears that the "if" block will always evaluate to true, given that "loose_route" never returns 0. According to the documentation, the return values of "loose_route" are specified as 1, 2, -1, -2, -3.
Therefore, it seems the "if" block is unnecessary, and the "else" block will never be executed. Could someone please confirm this observation and, if accurate, suggest a correction for the code?
Thank you for your attention to this matter.
Best regards, Pavan Kumar
1,2 would be a true response. -1,-2,-3 would be a false response.
https://www.kamailio.org/docs/modules/stable/modules/rr.html#rr.f.loose_rout...
" If there is no Route: header, the function returns FALSE and routing should be done with normal lookup functions. If a Route: header is found, the function returns 1 and behaves as described in section 16.12 of RFC 3261. There is only one exception: If the request is out-of-dialog (no to-tag) and there is only one Route: header indicating the local proxy, then the Route: header is removed and the function returns FALSE."
Regards,
Fred Posner p: +1 (352) 664-3733 https://qxork.com
Thanks Fred. If I understand correctly, when a document says "function returns FALSE", it means it will return one of the negative numbers. I assume the expresion "if(negative_number)" will be evaluated to be true in kamailio cnf.
In that case, the code
if (loose_route()) {
will never go to "else" block. So basically the code is wrong, right?
Best regards, Pavan Kumar
On Sat, Apr 27, 2024 at 3:29 AM Fred Posner via sr-users < sr-users@lists.kamailio.org> wrote:
On Apr 26, 2024, at 9:30 PM, Pavan Kumar pavanputhra@gmail.com wrote:
No.
If there is no Route header, it returns false. If there is, it returns true. If there is no Route header the else section will be utilized.
Regards,
Fred Posner p: +1 (352) 664-3733 https://qxork.com
Hello,
your main assumption regarding the evaluation of return values is wrong. Refer e.g. to this documentation for details on how is evaluated.
https://www.kamailio.org/wikidocs/cookbooks/5.8.x/core/#return
Cheers,
Henning
From: Pavan Kumar via sr-users sr-users@lists.kamailio.org Sent: Freitag, 26. April 2024 23:18 To: sr-users@lists.kamailio.org Cc: Pavan Kumar pavanputhra@gmail.com Subject: [SR-Users] Wrong code in the websocket examples cfg
Hello everyone,
While going through the WebRTC example configuration (cfg) to better understand and implement it in my setup, I came across a potential issue in the code block. The code in question can be found at this link: https://github.com/kamailio/kamailio/blob/465994de2859c7863b4cef8457be0a207f...
In the code, there is an "if else" block, "if(loose_route())" that seems to be incorrect. It appears that the "if" block will always evaluate to true, given that "loose_route" never returns 0. According to the documentation, the return values of "loose_route" are specified as 1, 2, -1, -2, -3.
Therefore, it seems the "if" block is unnecessary, and the "else" block will never be executed. Could someone please confirm this observation and, if accurate, suggest a correction for the code?
Thank you for your attention to this matter.
Best regards, Pavan Kumar
Thanks Henning for clarification, I got confused, maybe because I was writing cfg in Python.
On Sat, Apr 27, 2024 at 12:02 PM Henning Westerholt hw@gilawa.com wrote: