[Freeswitch-users] Using different contexts in gateways than the profile context

Gustavo Mársico gustavomarsico at gmail.com
Sun Oct 23 00:07:43 MSD 2011


Hi all

I'm trying to build a useful way to handle the remote gateways in wholesale scenarios. I'm checking the xml_curl due the very complex (and dynamic) rules of wholesale.
As far as I see, besides the IP address of the remote gw, the context could be a good differentiator of different remote entities.

I tried to change the Context of the gateways in the external profile (conf/sip_profiles/external/ws31.xml) to something like:

<include>
    <gateway name="10.8.0.10">
      <param name="register" value="false"/>
      <param name="ping" value="25"/>
      <param name="context" value="tgrp31"/>
    </gateway>
</include>

But for some reason Caller-Context and Hunt-Context are shown as 'public' context, which is the context configured in the external profile (conf/sip_profiles/external.xml).

Also, I tried to remove the context on the external.xml and keep the context in the external/ws31.xml file, to know if profile context configuration has precedence over the gateway context configuration. But this time, Caller-Context and Hunt-Context show 'default' as context (seems like mod_sofia is not using the context defined in the gateway).

Looking the src:

In the file src/endpoints/mod_sofia/sofia.c (parse_gateways function)

            if (!context) {
                context = "default";
            }

Which is perfectly fine and it's according to the behavior I've seen.

Below that, I found where the context is loaded:

                } else if (!strcmp(var, "context")) {
                    context = val;

A few lines after that:

gateway->register_context = switch_core_strdup(gateway->pool, context);

I did some debugs in that function and the context is well recorded.


In the sofia_handle_sip_i_invite function the register_context variable is used again:

if (gateway) {
            context = switch_core_session_strdup(session, gateway->register_context);

But the following comparison:

if (gw_name || gw_param_name) {

always return false, because a "gw+" is expected as part of the destination number.

if (strstr(destination_number, "gw+")) {


Just asking, shouldn't be a gateway treated as a gateway no matter if the destination contains certain characters or not?

I'm using FreeSWITCH Version 1.0.head (git-918d97b 2011-10-13 10-51-34 -0500)


Is this the expected behavior, am I looking this in the wrong way or am I missing something?

Best regards

Gustavo






Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list