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

2010-03-23 Thread Ahmed Munir
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 bog...@voice-system.ro
 Subject: Re: [OpenSIPS-Users] Check Live Peers on OpenSIPS
 To: OpenSIPS users mailling list users@lists.opensips.org
 Message-ID: 4ba69927.2050...@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 bog...@voice-system.ro
  mailto:bog...@voice-system.ro
  Subject: Re: [OpenSIPS-Users] Check Live Peers on OpenSIPS
  To: OpenSIPS users mailling list users@lists.opensips.org
  mailto:users@lists.opensips.org
  Message-ID: 4ba25705.10...@voice-system.ro
  mailto:4ba25705.10...@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
  

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

2010-03-23 Thread Bogdan-Andrei Iancu
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 bog...@voice-system.ro
 mailto:bog...@voice-system.ro
 Subject: Re: [OpenSIPS-Users] Check Live Peers on OpenSIPS
 To: OpenSIPS users mailling list users@lists.opensips.org
 mailto:users@lists.opensips.org
 Message-ID: 4ba69927.2050...@voice-system.ro
 mailto:4ba69927.2050...@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