[asterisk-dev] Setting nat=force_rport in [general] sip.conf

Alexandre Vézina avezina at ubikvoip.com
Thu Mar 7 17:48:46 CST 2013


Hi,

I noticed that it was impossible to set nat=force_rport in the general
section. It actually has no effect when issuing cli command "sip show
settings" (result is Force rport: Auto (No).

So I digged into the code and found this:

channels/sip/config_parser.c:818

} else if (!strcasecmp(this, "force_rport") && !ast_test_flag(&flags[2],
SIP_PAGE3_NAT_AUTO_RPORT)) {
    ast_set_flag(&flags[0], SIP_NAT_FORCE_RPORT);


Set I guess this will set the force_rport only if auto_force_rport is not
already set.

Digging a little deeper, I found this:

channels/chan_sip.c:31144

ast_set_flag(&global_flags[2], SIP_PAGE3_NAT_AUTO_RPORT); /*!< Default to
nat=auto_force_rport */

...

/* Read the [general] config section of sip.conf (or from realtime config)
*/
        for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
                if (handle_common_options(&global_flags[0], &dummy[0], v)) {

and then handle_common_options calls sip_parse_nat_option (which near line
818 of config_parser.c) if it finds the "nat" variable.

So, considering that config_parser is doing it's job in the [general]
context, it gets impossible for a user (e.g. me) to raise the flag
SIP_NAT_FORCE_RPORT since the global flag SIP_PAGE3_NAT_AUTO_RPORT was set
at the beginning of the reload am I right? And if I am, is it the behavior
you guys wanted?

I'm on Asterisk 11.2.1. I also checked out the trunk and the
SIP_PAGE3_NAT_AUTO_RPORT flag is still set in global_flags.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130307/beab4699/attachment-0001.htm>


More information about the asterisk-dev mailing list