[Asterisk-Dev] Need to reinivite based on context

John Paul Morrison jmorrison at bogomips.com
Sat Sep 11 23:36:29 MST 2004


I have a setup where Asterisk is deployed at a central location, and SIP
phones
have to pass through NAT in order to reach a PSTN gateway.
 
This works with nat=yes and canreinivite=no in the sip.conf. 
 
But if two phones need to talk to each other, they must go out to Asterisk
to be bridged
and then back. On a local LAN this is no big deal, but across WAN links this
is awful.
 
I've done some tests and this seems to do the trick. 
 
If the administrator puts phones in a different context, then asterisk will
not reinvite, 
otherwise if they are in the same context, canreinivite is honored. 
 
This is just a hack, perhaps I'm abusing the context. Any opinions as to how
this should be implemented for real?
I can implement a config setting in sip.conf, but should I just add it to
the sip_pvt structure? 
(but this would seem messy if you are looking at it in rtp.c)
 
 
--- rtp.c.orig  Sat Aug  7 07:22:09 2004
+++ rtp.c       Sat Sep 11 20:03:00 2004
@@ -1371,6 +1371,14 @@
                        return -2;
                }
        }
+/* hack for testing */
+        if (strncasecmp(c0->context,c1->context,AST_MAX_EXTENSION)) {
+                ast_log(LOG_WARNING, "context0 = %s does not match context1
= %s.\n",c0->context,c1->context);
+               ast_mutex_unlock(&c0->lock);
+               ast_mutex_unlock(&c1->lock);
+               return -2;
+        }
+/* hack for testing */
        if (pr0->set_rtp_peer(c0, p1, vp1, codec1)) 
                ast_log(LOG_WARNING, "Channel '%s' failed to talk to
'%s'\n", c0->name, c1->name);
        else {

 
 
 
 
John Paul Morrison
1-866-286-0342       604-787-7098
 
John Paul Morrison CCIE #8191, CCNP/Security, CCDP
johnpaulmorrison at bogomips.com http://www.bogomips.com/
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20040912/1bb50039/attachment.htm


More information about the asterisk-dev mailing list