### Description
I think something wrong with integer comparison when tested this config file ``` listen=udp:[::1]:5060 listen=udp:127.0.0.1:5060 loadmodule "xlog.so" loadmodule "sdpops.so"
request_route { if (sdp_get_address_family() ieq 6 ) { xlog("L_WARN", "sdp_get_address_family == 6\n"); } else if (sdp_get_address_family() ieq 4) { xlog("L_WARN", "sdp_get_address_family == 4\n"); } else if (sdp_get_address_family() ieq 1) { xlog("L_WARN", "cannot detect sdp family\n"); } } ```
The expected output of IP address type used in SDP. But really I always get "cannot detect sdp family" message.
Closed #2701.
That sdp function returns 4, 6 or -1.
The true for comparing with 1 happens because of how return code for functions is evaluated: negative values are evaluated to false and positive values are evaluated to true -- that is something specific for kamailio config interpreter, existing pretty much from the day 0 of the ser project.
It is documented in core cookbook in the section for return and in the FAQ:
* https://www.kamailio.org/wiki/tutorials/faq/main#how_is_the_function_return_...
Where I just added an explicit example for this case. Try the variant with getting the return value via $rc and if does not work reopen. Also the default config file has a similar approach for lookup location evaluation.
Tanks you Daniel for your clarification I have tested this config ``` listen=udp:[::1]:5060 listen=udp:127.0.0.1:5060 loadmodule "xlog.so" loadmodule "sdpops.so"
request_route { if (sdp_get_address_family() && $rc ieq 6 ) { xlog("L_WARN", "sdp_get_address_family == 6\n"); } else if (sdp_get_address_family() && $rc ieq 4) { xlog("L_WARN", "sdp_get_address_family == 4 \n"); } else { xlog("L_WARN", "cannot detect sdp family\n"); } } ```
Should I update Wiki with another usage example? ``` if (function_returns_four() && $rc ieq 6 ) { # it doesn't go here } else if (function_returns_four() && $rc ieq 4) { # it goes here } ```
Adding valid examples to documentation is always welcome.