Hi Stagg, This is a common issue when you have an Asterisk with multiple extensions and a single registration to OpenSER. A trick you can do is to save the username part of the RURI (the extension) and restore if the location lookup (for registrations) was successful:
...... $avp(s:tmp) = $rU; if ( !lookup("location")) { # no location found sl_send_reply("404","Not Found"); exit; } # registration found -> restore the username part $rU = $avp(s:tmp) t_relay(); ...... Note that is is better to use an AVP (or a variable) to store the username before the lookup, instead of using the $oU (original username). Original username is the username that openser received from the net, but you may consider that your script does other RURI processing (like aliases) before the lookup("location") - so you need the username value from before the lookup and not the received one. Regards, Bogdan Stagg Shelton wrote: > I will re-read the lookup function documentation. > > The reason why I am having to do this is because in my particular case > I have many asterisk PBX's registering to OpenSER. When asterisk > registers to OpenSER it has a contact id in the REGISTER message of [EMAIL > PROTECTED] > . After using alias_db_lookup OpenSER is using the contact id in the > To: field. When the message gets to asterisk, I cannot route it to > the correct extension, IVR, Queue because the message is being sent to [EMAIL > PROTECTED] > instead of [EMAIL PROTECTED] > > Thanks > Stagg > > On Jun 29, 2008, at 6:08 PM, Iñaki Baz Castillo wrote: > > >> El Domingo, 29 de Junio de 2008, Stagg Shelton escribió: >> >>> Thank you Iñaki. Not only did I find that my syntax made no sense, I >>> also found that openser would not start because of it. >>> >>> I believe that I have found my solution with your help. The below >>> syntax appears to be working with the results I intended. >>> >>> alias_db_lookup("dbaliases"); >>> >>> if (!lookup("location")) { >>> >>> ... >>> >>> } >>> } >>> else >>> { >>> avp_pushto("$ru/username", "$oU"); >>> } >>> >>> What the above does for me is that OpenSER can receive an invite from >>> one of my SIP providers. I can determine if the call is intended for >>> one of the PBX's that are registered to OpenSER and appropriately >>> route the call to the PBX that serves the number. >>> >> Hi, first this complex syntax is not needed anymore: >> avp_pushto("$ru/username", "$oU"); >> because you can just do: >> $rU = $oU; >> >> >> But anyway I can't understand why you do it. In your case, please re- >> read the >> doc of "lookup" function. When you do: >> if (!lookup("location")) { >> that will change the RURI ****just**** in the case the original RURI >> is an AoR >> existing in the "location" table, this is: that user is registered in >> OpenSer. >> But in the case it's not registered then the RURI ***won't*** be >> changed so >> you don't need, at all, to restore the RURI. >> >> Well, imagine an example with your code: >> >> - There is an alias: >> [EMAIL PROTECTED] => [EMAIL PROTECTED] >> >> - [EMAIL PROTECTED] is not registered in OpenSer. >> >> - Your code: >> >> => RURI = [EMAIL PROTECTED] >> >> alias_db_lookup("dbaliases"); >> => RURI = [EMAIL PROTECTED] >> >> if (!lookup("location")) { >> => User not registered so RURI still is [EMAIL PROTECTED] and this >> block >> is not executed >> .... >> } >> else { >> avp_pushto("$ru/username", "$oU"); >> => Now RURI = [EMAIL PROTECTED] >> } >> >> >> The question is: why do you need RURI being the original? it makes >> no sense >> (IMHO). >> >> >> Regards. >> >> >> -- >> Iñaki Baz Castillo >> >> _______________________________________________ >> Users mailing list >> Users@lists.openser.org >> http://lists.openser.org/cgi-bin/mailman/listinfo/users >> > > > _______________________________________________ > Users mailing list > Users@lists.openser.org > http://lists.openser.org/cgi-bin/mailman/listinfo/users > > _______________________________________________ Users mailing list Users@lists.openser.org http://lists.openser.org/cgi-bin/mailman/listinfo/users