<html><body>
<p>Hi Brett,<br>
<br>
For what it is worth, I do it the other way around: I check the source IP, and if from a PSTN provider process the telephone number as appropriate for them; otherwise I do user auth.<br>
<br>
A question: if you're allowing &quot;outside&quot; users to call in, why authenticate any INVITE traffic? (Ok, you have to authenticate traffic going to PSTN from your subscribers, but other than that...)?<br>
<br>
Regards,<br>
Kennard<br>
<br>
<img width="16" height="16" src="cid:1__=07BBFD0DDFC6356C8f9e8a93df9@logitech.com" border="0" alt="Inactive hide details for Brett Woollum ---09/14/2010 02:26:33 AM---David,  The &quot;is_from_local&quot; function is just what I needed."><font color="#424282">Brett Woollum ---09/14/2010 02:26:33 AM---David,  The &quot;is_from_local&quot; function is just what I needed. It will allow me to decipher whether or</font><br>
<br>
<font size="2" color="#5F5F5F">From:        </font><font size="2">Brett Woollum &lt;brett@woollum.com&gt;</font><br>
<font size="2" color="#5F5F5F">To:        </font><font size="2">OpenSIPS users mailling list &lt;users@lists.opensips.org&gt;</font><br>
<font size="2" color="#5F5F5F">Date:        </font><font size="2">09/14/2010 02:26 AM</font><br>
<font size="2" color="#5F5F5F">Subject:        </font><font size="2">Re: [OpenSIPS-Users] Help with Inbound PSTN, and Inbound SIP URI Authentication Sub-Routine</font><br>
<font size="2" color="#5F5F5F">Sent by:        </font><font size="2">users-bounces@lists.opensips.org</font><br>
<hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br>
<br>
<br>
<font size="4" face="Arial">David,<br>
<br>
The &quot;is_from_local&quot; function is just what I needed. It will allow me to decipher whether or not the user appears local or not, and authenticate them if so (ie: a subscriber), or check their IP if not (ie: from my gw).<br>
<br>
Thanks!<br>
</font><br>
<font size="4" face="Arial">Brett Woollum<br>
Brett@Woollum.com</font><br>
<font size="4" face="Arial"><br>
<br>
----- Original Message -----<br>
From: &quot;David J.&quot; &lt;david@styleflare.com&gt;<br>
To: &quot;OpenSIPS users mailling list&quot; &lt;users@lists.opensips.org&gt;<br>
Sent: Tuesday, September 14, 2010 1:08:38 AM GMT -08:00 US/Canada Pacific<br>
Subject: Re: [OpenSIPS-Users] Help with Inbound PSTN, and Inbound SIP URI Authentication Sub-Routine<br>
<br>
It depends on your configuration.<br>
<br>
You can place it before or after.<br>
<br>
Because you dont want to authenticate inbound calls, you can have a simple if statement that checks if the user is not local and alias exists, then relay to that alias.<br>
<br>
Not real code:<br>
<br>
if(not_from_local){<br>
    if(alias()){<br>
        relay;<br>
    }<br>
}<br>
<br>
On 9/14/10 3:32 AM, Brett Woollum wrote: </font>
<ul>
<ul><font size="4" face="Arial"> </font><br>
<font size="4" face="Arial"> </font><br>
<font size="4" face="Arial">Hi David,<br>
<br>
As far as I can tell, the alias module is independent of how the call is authenticated. My understanding is that it will look for a replacement URI based on the current one, and replace if a new one is found. It appears as though this &quot;function&quot; would go into the config file somewhere after the section I'm working on now. <br>
<br>
Is my understanding correct? <br>
<br>
I'll need some way to determine if this is an inbound call (i.e.; not originating from a subscriber's phone) prior to mapping it to the alias module. Also, I'd like to determine if the incoming call is from my PSTN gateway and give different aliases than if the call was a SIP URI call.<br>
<br>
Brett Woollum</font><br>
<a href="mailto:Brett@Woollum.com" target="_blank"><u><font size="4" color="#0000FF" face="Arial">Brett@Woollum.com</font></u></a><br>
<font size="4" face="Arial"><br>
<br>
----- Original Message -----<br>
From: &quot;David J.&quot; </font><a href="mailto:david@styleflare.com" target="_blank"><u><font size="4" color="#0000FF" face="Arial">&lt;david@styleflare.com&gt;</font></u></a><font size="4" face="Arial"><br>
To: &quot;OpenSIPS users mailling list&quot; </font><a href="mailto:users@lists.opensips.org" target="_blank"><u><font size="4" color="#0000FF" face="Arial">&lt;users@lists.opensips.org&gt;</font></u></a><font size="4" face="Arial"><br>
Sent: Tuesday, September 14, 2010 12:20:23 AM GMT -08:00 US/Canada Pacific<br>
Subject: Re: [OpenSIPS-Users] Help with Inbound PSTN, and Inbound SIP URI Authentication Sub-Routine<br>
<br>
Hi Brett,<br>
<br>
The common practice is to use the alias module for inbound routing.<br>
<br>
You can look at the docs for its usage, but essentially you can map DID's to local users.<br>
<br>
<br>
<br>
On 9/14/10 3:18 AM, Brett Woollum wrote: </font>
<ul>
<ul><font size="4" face="Arial"> </font><br>
<font size="4" face="Arial">Hello!<br>
<br>
I have an OpenSIPS 1.6.3 installation that is working well. I have subscribers registering to OpenSIPS, and they can dial between each other and outside of my domain (to my media servers and to the PSTN). All is well.<br>
<br>
I am now beginning to write the configuration that will process inbound calls - meaning calls from non-subscribers. This will include calls from the PSTN gateway, as well as direct SIP URI calls to the OpenSIPS subscribers. For example, a person can call 515-555-1212 from a regular phone, and the call will come to OpenSIPS as an un-authenticated call from my PSTN gateway. Also, I'd like to accept SIP URI's for incoming calls. For example, calling </font><a href="mailto:mycompany@mysipdomain.com" target="_blank"><u><font size="4" color="#0000FF" face="Arial">mycompany@mysipdomain.com</font></u></a><font size="4" face="Arial"> from a soft phone might route the call to subscriber A's phone. <br>
<br>
The code I have that applies to this is: (This is currently configured to authenticate all outbound calls from subscribers only.)<br>
    # authenticate if from local subscriber<br>
    if (!(method==&quot;REGISTER&quot;)) {                        <br>
            if (!proxy_authorize(&quot;&quot;, &quot;subscriber&quot;)) {                <br>
                proxy_challenge(&quot;&quot;, &quot;0&quot;);<br>
                exit;<br>
            }<br>
            if (!db_check_from()) {<br>
                send_reply(&quot;403&quot;,&quot;Forbidden auth ID&quot;);<br>
                exit;<br>
            }<br>
        <br>
            consume_credentials();<br>
            # caller authenticated<br>
    }<br>
<br>
I am looking for direction on how to expand this to determine if the call is A) from a subscriber calling outbound, B) inbound from the PSTN, or C) inbound from any other user calling my SIP URI's. Once I am able to determine this information, I'll be able to route the call appropriately within the rest of my scripts.<br>
<br>
My problem is that my SIP phones usually attempt to place calls without including authorization in the header (because they are registered already), then OpenSIPS replies requiring proxy authentication. The SIP phones will then try the call again including the credentials in the header, which works. How can I re-write this section of code to allow inbound SIP URI calls and calls from my PSTN gateway, while still asking my subscribers to authenticate? Or, is there a method that might work better?<br>
<br>
Notes:<br>
- Each of my PSTN gateway's has a static IP. <br>
- It's safe to assume a single-domain setup (mysipdomain.com).<br>
<br>
Thanks in advance!<br>
</font><br>
<font size="4" face="Arial">Brett Woollum</font><u><font size="4" color="#0000FF" face="Arial"><br>
</font></u><a href="mailto:Brett@Woollum.com" target="_blank"><u><font size="4" color="#0000FF" face="Arial">Brett@Woollum.com</font></u></a><br>
<br>
<font size="4" face="Arial"><br>
_______________________________________________<br>
Users mailing list<br>
</font><a href="mailto:Users@lists.opensips.org" target="_blank"><u><font size="4" color="#0000FF" face="Arial">Users@lists.opensips.org</font></u></a><font size="4" face="Arial"><br>
</font><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank"><u><font size="4" color="#0000FF" face="Arial">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</font></u></a><font size="4" face="Arial"><br>
</font></ul>
</ul>
<font size="4" face="Arial"><br>
<br>
_______________________________________________ Users mailing list </font><a href="mailto:Users@lists.opensips.org" target="_blank"><u><font size="4" color="#0000FF" face="Arial">Users@lists.opensips.org</font></u></a><font size="4" face="Arial"> </font><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank"><u><font size="4" color="#0000FF" face="Arial">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</font></u></a><font size="4" face="Arial"> </font><br>
<font size="4" face="Arial"><br>
_______________________________________________<br>
Users mailing list<br>
</font><a href="mailto:Users@lists.opensips.org" target="_blank"><u><font size="4" color="#0000FF" face="Arial">Users@lists.opensips.org</font></u></a><font size="4" face="Arial"><br>
</font><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank"><u><font size="4" color="#0000FF" face="Arial">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</font></u></a><font size="4" face="Arial"><br>
</font></ul>
</ul>
<font size="4" face="Arial"><br>
<br>
_______________________________________________ Users mailing list Users@lists.opensips.org </font><font size="4" face="Arial"><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a></font><font size="4" face="Arial"> </font><tt>_______________________________________________<br>
Users mailing list<br>
Users@lists.opensips.org<br>
</tt><tt><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a></tt><tt><br>
</tt><br>
</body></html>