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("203.215.179.34:5060"); t_relay(); route(1); exit; 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 configuration of machine B is listed below; # main request routing logic route{ if (!mf_process_maxfwd_header("10")) { sl_send_reply("483","Too Many Hops"); exit; } if (has_totag()) { if (loose_route()) { if (is_method("BYE")) { setflag(1); # do accounting ... setflag(3); # ... even if the transaction fails } else if (is_method("INVITE")) { record_route(); } route(1); } else { if ( is_method("ACK") ) { if ( t_check_trans() ) { # non loose-route, but stateful ACK; must be an ACK after # a 487 or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction -> # ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; } #initial requests # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); # preloaded route checking if (loose_route()) { xlog("L_ERR", "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]"); if (!is_method("ACK")) sl_send_reply("403","Preload Route denied"); exit; } # record routing if (!is_method("REGISTER|MESSAGE")) record_route(); # account only INVITEs if (is_method("INVITE") && check_source_address("0")){ log("#################### INVITE CASE 1 ####################"); setflag(1); # do accounting } if (!uri==myself) ## replace with following line if multi-domain support is used ##if (!is_uri_host_local()) { append_hf("P-hint: outbound\r\n"); # if you have some interdomain connections via TLS ##if($rd=="tls_domain1.net") { ## t_relay("tls:domain1.net"); ## exit; ##} else if($rd=="tls_domain2.net") { ## t_relay("tls:domain2.net"); ## exit; ##} route(1); } # requests for my domain ## uncomment this if you want to enable presence server ## and comment the next 'if' block ## NOTE: uncomment also the definition of route[2] from below ##if( is_method("PUBLISH|SUBSCRIBE")) ## route(2); if (is_method("PUBLISH")) { sl_send_reply("503", "Service Unavailable"); exit; } if (is_method("REGISTER")) { route(2); } if ($rU==NULL) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # apply DB based aliases (uncomment to enable) ##alias_db_lookup("dbaliases"); # do lookup with method filtering if (!lookup("location","m")) { switch ($retcode) { case -1: log("############# LOOKUP LOCATION FLAG -1 PASS ###############"); setflag(2); rewritehostport("11.22.33.44:5060"); log("############### CALL ROUTING TO ROUTE 1 ###################"); route(1); exit; case -3: log("############# LOOKUP LOCATION FLAG -3 PASS ###############"); t_newtran(); t_reply("404", "Not Found"); exit; case -2: log("############# LOOKUP LOCATION FLAG -2 PASS ###############"); sl_send_reply("405", "Method Not Allowed"); exit; } } # when routing via usrloc, log the missed calls also setflag(2); log("############ LOOKUP LOCATION FLAG 1 PASS ################"); route(1); } route[1] { # for INVITEs enable some additional helper routes #if (is_method("INVITE") && check_source_address("0")) { if (is_method("INVITE")) { log("####################INVITE ROUTE 1 Function####################"); t_on_branch("2"); t_on_reply("2"); t_on_failure("1"); #ds_select_dst("1","4"); #forward(); } if (!t_relay()) { sl_reply_error(); }; exit; } route[2] { log("############## AAA-REGISTRATION #################"); if (!aaa_www_authorize("rose.abc.com")) { www_challenge("rose.abc.com", "1"); return; } if (!save("location")) sl_reply_error(); exit; } branch_route[2] { xlog("new branch at $ru\n"); } onreply_route[2] { xlog("incoming reply\n"); } failure_route[1] { if (t_was_cancelled()) { exit; } } 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> > Subject: Re: [OpenSIPS-Users] Check Live Peers on OpenSIPS > To: OpenSIPS users mailling list <users@lists.opensips.org> > Message-ID: <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 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 <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: <4ba1e2ff.3060...@voice-system.ro > > <mailto:4ba1e2ff.3060...@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@lists.opensips.org <mailto:Users@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@lists.opensips.org > > http://lists.opensips.org/cgi-bin/mailman/listinfo/users > > > > > -- > Bogdan-Andrei Iancu > www.voice-system.ro > > > > > -- Regards, Ahmed Munir
_______________________________________________ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users