[OpenSIPS-Users] Users Digest, Vol 20, Issue 85

Bogdan-Andrei Iancu bogdan at voice-system.ro
Tue Mar 23 10:39:42 CET 2010


Hi Ahmed,

you can simply write it like:

xlog("incoming from $si : $sp \n");
if (check_source_address("0")) {
    if(is_method("INVITE")) {
        log("#################### CHECK SOURCE ADDRESS 
######################");
        route(1);
        setflag(1);
    }
}

First check if the IPs you added in address table are in the "0" group. 
Also check the port part.

If still ot working, post here :
    1) the db content of "Address" table
    2) the logs of opensips in debug=6

Regards,
Bogdan

Ahmed Munir wrote:
>
>
> Hi Bogdan,
>
> Thanks for your reply. As you suggested about check_source_address() 
> function, I get its return value using $avp(i:checksrc) as listed down 
> below;
>
>         $avp(s:checksrc) = check_source_address("0");
>        
>  log("#################################################################################\n");
>         xlog("Check Source Address from Address TABLE Where Value 1 is 
> Equal to True: $(avp(s:checksrc))\n");
>        
>  log("#################################################################################\n");
>
>         if($avp(s:checksrc)!=1)
>         {
>                if(is_method("INVITE"))
>                {
>                        log("#################### CHECK SOURCE ADDRESS 
> ######################");
>                        route(1);
>                        setflag(1);
>                }
>         }
>         else
>         {
>                t_reply("403","Forbidden");
>                exit;
>         }
>
> But the problem I'm facing is when I enlist IP in address table i.e. 
> 11.22.33.44, call is rejected when else condition is used, when else 
> condition is commented call is made. But on other hand when I remove 
> the IP as mentioned from address table, it should reject the call 
> (commenting else condition), unfortunately the call is made.
>
> Kindly assist me how can I permit or deny calls on IP bases, when user 
> is not registered from OpenSIPS but sending calls from GW to OpenSIPs?
>
>
>     Date: Mon, 22 Mar 2010 00:09:43 +0200
>     From: Bogdan-Andrei Iancu <bogdan at voice-system.ro
>     <mailto:bogdan at voice-system.ro>>
>     Subject: Re: [OpenSIPS-Users] Check Live Peers on OpenSIPS
>     To: OpenSIPS users mailling list <users at lists.opensips.org
>     <mailto:users at lists.opensips.org>>
>     Message-ID: <4BA69927.2050102 at voice-system.ro
>     <mailto:4BA69927.2050102 at voice-system.ro>>
>     Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>     Hi Ahmed
>
>     Ahmed Munir wrote:
>     > Hi Bogdan,
>     >
>     > Thanks for your suggestion, few things I want to ask from you;
>     >
>     > 1- Can I use rewritehostport(); function instead of
>     $rd='11.22.33.44'
>     > and append it to t_relay()? Like;
>     >
>     > setflag(2);
>     > rewritehostport("11.22.33.55:5060 <http://203.215.179.34:5060>");
>     > t_relay();
>     > route(1);
>     > exit;
>
>     Yes, that is correct.
>     >
>     > 2- When using check_source_address() function of permissions module,
>     > I'm facing weird problem. On machine A I've installed OpenSIPS ver
>     > 1.6.1 svn one, I used this function to permitted certain source
>     IPs as
>     > I listed in address table. On machine B (currently working on it
>     using
>     > Radius) I've installed same version of OpenSIPS as on machine A,
>     when
>     > I call its check_source_address() function in INVITE section, it is
>     > working as it worked on machine A. Machine A settings are listed
>     below;
>     >
>     >
>     > if(is_method("INVITE") && check_source_address("0"))
>     > {
>     >        log("#################### CHECK SOURCE ADDRESS
>     > ######################");
>     >        route(1);
>     >        setflag(1);
>     > }
>     >
>     >
>     > Machine B description I'm mentioning below;
>     >
>     > 2-1- If user registered him/her self on SIP phone their source
>     IP not
>     > going to be checked, and make calls to each other.
>     > 2-2- If user A is on GW calls user B who is located and
>     Registered on
>     >  OpenSIPS, user A GW's source IP must be checked by OpenSIPs, if the
>     > IP exists on address table, call is permitted if not deny the call.
>     >
>     > Problems;
>     >
>     > When I user A and user B registered on OpenSIPs (using Radius) they
>     > can call each other, but if a user A calling from GW to user B
>     who is
>     > registered on OpenSIPs, calls is made even the address is not listed
>     > on address table. And also in logs I see that that permissions
>     module
>     > shows that it doesn't find any IP enlisted in its hash table, but
>     > still permitting it.
>     The function just checks if the source IP is in the table, but
>     does not
>     take any action - you need to so this manually from the script,
>     based on
>     the return code (true or false) of the function.
>
>     Regards,
>     Bogdan
>     > The configuration of machine B is listed below;
>     >
>     > [........]
>     >
>     > Kindly assist me, how can I permit or deny user from source IP ?
>     > Because on machine A, check_source_address() function is working
>     > perfectly but I haven't integrated FreeRadius with OpenSIPs. Please
>     > sort out my problem as your earliest.
>     >
>     >
>     >
>     >
>     >     Date: Thu, 18 Mar 2010 18:38:29 +0200
>     >     From: Bogdan-Andrei Iancu <bogdan at voice-system.ro
>     <mailto:bogdan at voice-system.ro>
>     >     <mailto:bogdan at voice-system.ro <mailto:bogdan at voice-system.ro>>>
>     >     Subject: Re: [OpenSIPS-Users] Check Live Peers on OpenSIPS
>     >     To: OpenSIPS users mailling list <users at lists.opensips.org
>     <mailto:users at lists.opensips.org>
>     >     <mailto:users at lists.opensips.org
>     <mailto:users at lists.opensips.org>>>
>     >     Message-ID: <4BA25705.10506 at voice-system.ro
>     <mailto:4BA25705.10506 at voice-system.ro>
>     >     <mailto:4BA25705.10506 at voice-system.ro
>     <mailto:4BA25705.10506 at voice-system.ro>>>
>     >     Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>     >
>     >     Hi Ahmed,
>     >
>     >     Ahmed Munir wrote:
>     >     > Hi Bogdan,
>     >     >
>     >     > Thanks for reply. I forgot to mention earlier that for I'm
>     using
>     >     > OpenSIPS + FreeRadius, where radius is doing accounting and
>     >     > authentication. I used aaa_does_uri_exist() function as
>     well, but
>     >     > seems not working or making mistake while implementing it.
>     On other
>     >     > hand using lookup("location",m) function, on retcode = -1, I
>     >     > redirected the INVITE to GW, using Dispatcher.  But though
>     >     thanks for
>     >     > your suggestion and I'll consider it.
>     >     >
>     >     > Few things I want to ask you, as I listed below;
>     >     > 1-How can I forward SIP INVITE request to other SIP
>     machine in state
>     >     > full manner ?
>     >     simply do:
>     >        # set new destination in RURI
>     >        $rd= "11.22.33.44";
>     >        # send it out in stateful mode
>     >        t_relay();
>     >        exit;
>     >
>     >     > 2- While accounting using radius, when user A (registered on
>     >     OpenSIPS)
>     >     > calls the user B who is located at GW side, accounting
>     doesn't take
>     >     > place.  On the other hand when user B (from GW) calls user
>     A (to
>     >     > OpenSIPS), accounting take place. I want to know its cause?
>     >     Because I
>     >     > want its accounting on both sides.
>     >     take care and check where you set in script the acc flag - maybe
>     >     you are
>     >     setting it only if lookup is successful.
>     >
>     >     Regards,
>     >     Bogdan
>     >     >
>     >     > Kindly advise me at your earliest.
>     >     >
>     >     >
>     >     >     ------------------------------
>     >     >
>     >     >     Message: 6
>     >     >     Date: Thu, 18 Mar 2010 10:23:27 +0200
>     >     >     From: Bogdan-Andrei Iancu <bogdan at voice-system.ro
>     <mailto:bogdan at voice-system.ro>
>     >     <mailto:bogdan at voice-system.ro <mailto:bogdan at voice-system.ro>>
>     >     >     <mailto:bogdan at voice-system.ro
>     <mailto:bogdan at voice-system.ro> <mailto:bogdan at voice-system.ro
>     <mailto:bogdan at voice-system.ro>>>>
>     >     >     Subject: Re: [OpenSIPS-Users] Check Live Peers on OpenSIPS
>     >     >     To: OpenSIPS users mailling list
>     <users at lists.opensips.org <mailto:users at lists.opensips.org>
>     >     <mailto:users at lists.opensips.org
>     <mailto:users at lists.opensips.org>>
>     >     >     <mailto:users at lists.opensips.org
>     <mailto:users at lists.opensips.org>
>     >     <mailto:users at lists.opensips.org
>     <mailto:users at lists.opensips.org>>>>
>     >     >     Message-ID: <4BA1E2FF.3060702 at voice-system.ro
>     <mailto:4BA1E2FF.3060702 at voice-system.ro>
>     >     <mailto:4BA1E2FF.3060702 at voice-system.ro
>     <mailto:4BA1E2FF.3060702 at voice-system.ro>>
>     >     >     <mailto:4BA1E2FF.3060702 at voice-system.ro
>     <mailto:4BA1E2FF.3060702 at voice-system.ro>
>     >     <mailto:4BA1E2FF.3060702 at voice-system.ro
>     <mailto:4BA1E2FF.3060702 at voice-system.ro>>>>
>     >     >     Content-Type: text/plain; charset=ISO-8859-1;
>     format=flowed
>     >     >
>     >     >     Hi Ahmed,
>     >     >
>     >     >     if the destination number (called number) is not a local
>     >     subscriber (a
>     >     >     SIP user), you simply route the call to a PSTN GW (you
>     do this
>     >     >     re-route
>     >     >     from the script)
>     >     >
>     >     >     To check if a user is a local subscriber, you can
>     either check a
>     >     >     pattern
>     >     >     (like all my local users are alphanumeric, or all starts
>     >     with 3345*,
>     >     >     etc), either simply check if the user does exists in the
>     >     subscriber
>     >     >     table (see the URI module, the db_does_uri_exists()
>     function:
>     >     >
>     >    
>      http://www.opensips.org/html/docs/modules/1.6.x/uri.html#id271131
>     >     >
>     >     >     Regards,
>     >     >     Bogdan
>     >     >
>     >     >     Ahmed Munir wrote:
>     >     >     > Hi,
>     >     >     >
>     >     >     > I want to know how can I check the peers of source and
>     >     destination
>     >     >     > phones? Like if both phones are located (registered)
>     on one
>     >     >     > UAS(OpenSIPS) can call SIP-SIP, if any one phone is
>     registered
>     >     >     on UAS
>     >     >     > and other is on PSTN, call will be re-routed to
>     SIP-PSTN.
>     >     In case of
>     >     >     > SIP-SIP, lookup("location") function works and I
>     need to know
>     >     >     how can
>     >     >     > I forward call to SIP-PSTN ?
>     >     >     >
>     >     >     > Kindly advise me the method/ function can used for it.
>     >     >     >
>     >     >     > --
>     >     >     > Regards,
>     >     >     >
>     >     >     > Ahmed Munir
>     >     >     >
>     >     >     >
>     >     >     >
>     >     >
>     >    
>     ------------------------------------------------------------------------
>     >     >     >
>     >     >     > _______________________________________________
>     >     >     > Users mailing list
>     >     >     > Users at lists.opensips.org
>     <mailto:Users at lists.opensips.org> <mailto:Users at lists.opensips.org
>     <mailto:Users at lists.opensips.org>>
>     >     <mailto:Users at lists.opensips.org
>     <mailto:Users at lists.opensips.org> <mailto:Users at lists.opensips.org
>     <mailto:Users at lists.opensips.org>>>
>     >     >     > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>     >     >     >
>     >     >
>     >     >
>     >     >     --
>     >     >     Bogdan-Andrei Iancu
>     >     >     www.voice-system.ro <http://www.voice-system.ro>
>     <http://www.voice-system.ro>
>     >     <http://www.voice-system.ro>
>     >     >
>     >     >
>     >     >
>     >     >
>     >     > --
>     >     > Regards,
>     >     >
>     >     > Ahmed Munir
>     >     >
>     >     >
>     >     >
>     >    
>     ------------------------------------------------------------------------
>     >     >
>     >     > _______________________________________________
>     >     > Users mailing list
>     >     > Users at lists.opensips.org <mailto:Users at lists.opensips.org>
>     <mailto:Users at lists.opensips.org <mailto:Users at lists.opensips.org>>
>     >     > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>     >     >
>     >
>     >
>     >     --
>     >     Bogdan-Andrei Iancu
>     >     www.voice-system.ro <http://www.voice-system.ro>
>     <http://www.voice-system.ro>
>     >
>     >
>     >
>     >
>     >
>     > --
>     > Regards,
>     >
>     > Ahmed Munir
>     >
>     >
>     >
>     ------------------------------------------------------------------------
>     >
>     > _______________________________________________
>     > Users mailing list
>     > Users at lists.opensips.org <mailto:Users at lists.opensips.org>
>     > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>     >
>
>
>     --
>     Bogdan-Andrei Iancu
>     www.voice-system.ro <http://www.voice-system.ro>
>
>
>
>
> -- 
> Regards,
>
> Ahmed Munir
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>   


-- 
Bogdan-Andrei Iancu
www.voice-system.ro




More information about the Users mailing list