Basically what you do is to load the number to forward to by using
avp_db_load and then add code in failure_route to test on the return codes,
write the loaded number into ruri and use append_branch() to fork a new
request. Paul posted an example on serusers
He uses a more complex authorization structure for giving users access to
various types of calls (local, long distance, international), so you will
have to sort out the code necessary for the forwarding you want to do.
Here is what you need on failure_route[1] (remember to set t_on_failure[1]
before calling t_relay() ):
# flag 26 means that a "forward busy" number is set
# This flag is set if avp_db_load("$ruri","s:fwdbusy") resulted
in a
an avpair being loaded (before t_relay())
# Code example using only username portion of ruri to look up avpair:
if (avp_db_load("$ruri/username", "s:fwdbusy")) { setflag(26) }
if (isflagset(26) && t_check_status("486")) {
# forward busy is flag 26
if (avp_pushto("$ruri", "s:fwdbusy")) {
avp_delete("s:fwdbusy");
append_branch();
resetflag(26);
# route the call to IP or PSTN
route(2);
break;
};
};
g-)
Charles Wang wrote:
Thank you for your kind to answer me these question.
And because I can't find a lot of discussions at serusers's maillist.
So I post it to serdev. I am very sorry to do that.
I have no voicemail solution in my scenario. But I wanna implement the
call busy forward and noanswer forward to another UA or PSTN.
For example: if A call B and B is busy or noanswer, then forward this
call to C or PSTN(defined by B). Is it possible?
Why does almost discussions about avpops are about voicemail?
Is it mean that system will send a voicemail to
"1011(a)domainA.com"(setting above at usr_preferences) if a UA is busy
or noanswer?
How can I implement it if I want to forward the busy call or noanswer
call to PSTN or another UA(registed on the same machine)?
On Sat, 19 Feb 2005 12:02:18 +0100, Greger V. Teigre
<greger(a)teigre.com> wrote:
> I don't think your message is appropriate for serdev, so I removed
> it from the recipient list.
> See inline comments.
>
> Charles Wang wrote:
>> Dear ALL:
>>
>> I have defined these lines at my ser.cfg.
>>
>> modparam("avpops", "avp_url",
"mysql://ser:heslo@localhost/ser")
>> modparam("avpops", "avp_table", "usr_preferences")
>> modparam("avpops", "uuid_column", "uuid")
>> modparam("avpops", "username_column", "username")
>> modparam("avpops", "domain_column", "domain")
>> modparam("avpops", "attribute_column",
"attribute")
>> modparam("avpops", "value_column", "value")
>> modparam("avpops", "type_column", "type")
>> modparam("avpops", "avp_aliases",
>>
"voicemail=i:500;calltype=i:700;fwd_no_answer_type=i:701;fwd_busy_type=i:702")
>>
>> Q1: If I use usr_preferences as default table, should I insert some
>> initial data to it?
>> Can you give me some example?
>
> Yes, you should. Let's say you want user a(a)b.com to have voicemail
> as an option. Add:
>
> username=a
>
domain=b.com
> attribute=voicemail
> value=y
> type=0 (default string)
>
>>
>> And I have refered to
http://www.voice-system.ro/docs/avpops
>>
>> And find many examples in it.
>>
>> But I still can't understand what it mean about avp_db_load().
>
> avp_db_load() will load a certain value from your usr_preferences
> table.
>
> avp_db_load("$ruri","s:voicemail");
> will use to request uri (i.e. somebody is calling a(a)b.com) to lookup
> the attribute voicemail. Instead of "$ruri", you can use
> "$ruri/username" or "$ruri/domain" and only the username or
domain
> part of $ruri, respectively, will be used to look up the attribute
> voicemail in the table. avp_check("s:voicemail", "eq/y/i") can
then
> be used to check if value from the usr_preferences table is "y".
>
>> my avp table is named as "usr_preferences" and it is empty before I
>> use avpops modules.
>>
>> For this web page said:
>> avp_db_load("$ruri/domain","i:/domain_preferences");
>> - loads all AVPs with ID from 'domain_preferences'
>> table for domain from RURI
>> Q2: Is "$ruri" the caller user's URI? and the "domain" is
the same?
>
> Yes.
>
>> Is "domain_preferences" table name?
> Yes, you can opt to select a different table. It is not necessary
> though.
>
>> Is it equal to my
>> "usr_preferences"? Or it is just a virtual table in memory?
> No and no.
>
> avpops is a very powerful module with various ways of using tables,
> loading av pairs and doing tests. Remember that avpairs are no more
> than pairs of attribute names (either string names as above or
> integer values i:34) and values (either string values or integer
> values). These avpairs must be loaded from somewhere, using
> avp_db_load avp_radius_load, etc using $from or $ruri for looking up
> the correct pair.
>
> g-)