[asterisk-dev] [Code Review] Explicit context set in SIP peer overridden by default domain context
Philip A. Prindeville
philipp_subx at redfish-solutions.com
Tue Mar 16 17:14:08 CDT 2010
Summary
--------
Having inbound SIP 'guest' calls associated to a default context is
handy, especially when multi-tenancy or hosting multiple domains is
being done.
However, the code as written will clobber an explicitly configured
context associated with a peer if a domain-list is configured.
This is counter-intuitive, since (a) explicit configuration should
always trump default or implicit config, and (b) puts all internal
domain-bound SIP handsets in the same context as guest callers, making
it hard to apply a restricted dialplan to guest callers.
The Fix
-------
Only override the context if (1) it hasn't been explicitly set and (2)
we're not associated with a specific peer.
Testing
--------
Running patched 1.6.2.6 on our production network. Seems to work fine.
Diffs
-----
--- asterisk-1.6.2.6/channels/chan_sip.c.orig 2010-03-02 17:19:57.000000000 -0700
+++ asterisk-1.6.2.6/channels/chan_sip.c 2010-03-16 13:08:41.000000000 -0600
@@ -13353,8 +13353,10 @@ static int get_destination(struct sip_pv
return -2;
}
}
- /* If we have a context defined, overwrite the original context */
- if (!ast_strlen_zero(domain_context))
+ /* If we don't have a context defined (i.e. we're a guest call),
+ * overwrite the original context */
+ if (!p->owner && ast_strlen_zero(p->context) &&
+ !ast_strlen_zero(domain_context))
ast_string_field_set(p, context, domain_context);
}
More information about the asterisk-dev
mailing list