[Serusers] Database queries?

Daniel-Constantin Mierla daniel at voice-system.ro
Tue Sep 27 12:50:56 CEST 2005


Hello,

the content of $from is sip:motherinlaw at another.domain.com

$from is a sip uri, that's why does not match when do the check.

Daniel

On 09/26/05 22:09, sip wrote:

>I'm attempting to figure out how to use AVPops to grab data from the
>calls_forwarding database table so I can avoid having to write my own module
>to handle that sort of thing, and I can avoid doing what I'm CURRENTLY doing
>which is using a pretty hideous exec_msg SQL query hack. 
>
>I've run into a snag that I can't figure a way around.... 
>
>In the calls_forwarding table, I have these fields used in this fashion:
>username == username
>domain == domain
>uri_re == username at domain information (for use in a couple of ways)
>purpose == purpose for this entry (callblock, callfwd, screening, etc)
>action == action to take (for callblock, could be reply or relay, etc)
>param1 == option for the action above
>param2 == additional option
>
>So... if I have a call block entry, it would be like this:
>
>username = bob
>domain = mydomain.com
>uri_re = motherinlaw at another.domain.com
>purpose = callblock
>action = reply
>param1 = 486
>param2 = "Busy"
>
>The logic would be along the lines of, when a call comes in for
>bob at mydomain.com, I check to see if he has any callblock entries. If so, I
>check those to see if any match the From user. If there's a match, take the
>action in action (in this case reply with 486 - Busy... could be relay to
>voicemail, etc). 
>
>The problem I'm having is in the grabbing of all the data from the DB and
>comparing it to the right values. For instance, with this avpops query
>
>
>avp_db_load("$ruri/username", "$urire/$urire_scheme");
># Load the urire column for this and check to see if
># it matches the $from address
>if(avp_check("$urire", "eq/$from/I"))
>{
>  send reply... take action... etc.
>}
>
>I'm calling from the number motherinlaw at another.domain.com.  If I use the
>above, the avp_check test fails.  If I put  
>
>if(avp_check("$urire", "eq/motherinlaw at another.domain.com/I"))
>{
>  send reply... take action... etc.
>}
>
>
>Then the test succeeds and the appropriate action is taken. 
>
>Any guesses as to what I'm missing here... why the test is failing when I use
>the $from variable for AVPops, but not when I hard-code the $from address into
>the test (which implies to me that it's grabbing the right data from the
>database, but there's an issue in either the $from variable or the comparison
>statement)? 
>
>I'd love a little shove in the right direction. I thought about writing a
>module that returned what I need without the need for complex logical paths,
>but my C is pretty rusty, and I'm trying to save myself the hair-pulling. :)
>
>
>N.
>
>_______________________________________________
>Serusers mailing list
>serusers at lists.iptel.org
>http://lists.iptel.org/mailman/listinfo/serusers
>
>  
>




More information about the sr-users mailing list