[OpenSIPS-Users] using avpops module

Richard Revels rrevels at bandwidth.com
Wed May 30 02:25:58 CEST 2012


Here is another example or two.

Set module parameter to grab an extra column (tag) in a dbaliases table:
modparam("avpops", "db_scheme",
"alias_scheme:table=dbaliases;username_col=username;domain_col=domain;value_col=tag;value_type=string")

In the config use the alias scheme (send in the uri of the RURI and store
in avp 120):
avp_db_load( "$ru/uri", "$avp(120)/$alias_scheme" );

Assuming the tag column contains the customer class, use it to load values
from the (default) usr_preferences table:
avp_db_load("$avp(120)", "a");

You can also load avp values based on various headers.  Use request user
from RURI:
avp_db_load("$ru", "a");

The first form will look for rows in usr_preferences where the uuid column
match what is contained in avp 120.  The second form will look for rows in
which the username and domain columns match the username and domain of the
RURI.  If the domain is looked at is a module parameter.  The avp's that
get set are the  attribute column and the value the avp is set to is the
value column.

Here are a couple rows from the usr_preferences table:

| id | uuid | username     | domain               | attribute          |
type | value                       | last_modified       |

| 37 | 2000 |              |                      | no-nat-support     |
 0 | Y                           | 0000-00-00 00:00:00 |

| 28 |      | 9194397461   | trunking.bsltech.net | userdebug          |
 0 | Y                           | 2010-08-25 00:00:00 |

And finally, use those values:

        if( is_avp_set("$avp(userdebug)/s") )
        {
                xlog("L_INFO", "Turning on debug in inbound call due to
user prefs flag for call $ci from $fU \n");
                setflag(1);
        }

        if( !is_avp_set("$avp(no-nat-support)/s") )
        {
                bm_start_timer("media_proxy_benchmark"); #keep track of how
long it's taking to talk to relays
                engage_media_proxy();
                more interesting stuff....
        }


Richard


On Mon, May 28, 2012 at 2:23 PM, Ali Pey <alipey at gmail.com> wrote:

> avp_db_query("insert into SIP_REG(TIMESTAMP, SIP_USERNAME, DOMAIN, AGENT,
> CONTACT, EXPIRES, SOURCE, NET_TYPE, SERVER) values ('CURRENT_TIMESTAMP',
> '$fU', '$fd', '$ua', '$ct', '$hdr(Expires)', '$avp(i:42)', 'NATED',
> 'Primary OpenSIPS' )");
>
> Regards,
> Ali
>
> On Sun, May 27, 2012 at 3:07 AM, prasad kelkar <durga144 at gmail.com> wrote:
>
>> hello,
>> I tried using AVPpops module to connect to table in mysql.
>> I cant acces value
>> Please give me example code.
>> Thank You
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20120529/4bd22430/attachment.htm>


More information about the Users mailing list