[OpenSIPS-Users] DIferent call Status when base on user Preference

pjgonzalez pgonzalez at dgtec.net.do
Wed Jan 14 15:21:37 CET 2009


Thanks is working but when i try to send the forward I'm doing the
following:

 

$rU =  $avp(s:callForward)

rewritehostport("XXX:XXX:XXX:5070");

 append_branch();

t_on_failure("1");

        t_on_reply("1");

        if (!t_relay()) {

          sl_reply_error();

          

        };

 

And I get the following response on replay 1:

 

opensips[2049]:  Reply 1 - M=INVITE RURI=<null> S=100 D=Trying
F=sip:CallingNumber at SenderGW:5060 T=sip:calledNumber at receiverGW:5060
IP=NAT_IP ID=<CALLID>

opensips[2039]:  Reply 1 - M=INVITE RURI=<null> S=100 D=Trying
F=sip:CallingNumber at SenderGW:5060 T=sip:calledNumber at receiverGW:5060
IP=NAT_IP ID=<CALLID>

opensips[2054]:  Reply 1 - M=INVITE RURI=<null> S=180 D=Ringing
F=sip:CallingNumber at SenderGW:5060 T=sip:calledNumber at receiverGW:5060
IP=NAT_IP ID=<CALLID>

opensips[2041]:  Reply 1 - M=INVITE RURI=<null> S=403 D=Forbidden
F=sip:CallingNumber at SenderGW:5060 T=sip:calledNumber at receiverGW:5060
IP=NAT_IP ID=<CALLID>

 

 

thanks.

 

From: Gustavo Mistrinelli (via Nabble)
[mailto:ml-user+125057-519850071 at n2.nabble.com] 
Sent: Tuesday, January 13, 2009 9:52 PM
To: pjgonzalez
Subject: Re: [OpenSIPS-Users] DIferent call Status when base on user
Preference

 

Hi, 

You can use one line to load all user preferences to avps

  avp_db_load("$ru/username","*")

Assuming that usr_preferences table have records like that:

username | attribute   | value 
------------------------------
abcd     | callForward | 123456
dcba     | voicemail   | true

Then you can check user settings asking:

if (is_avp_set($avp(s:callForward)) {
   $rU =  $avp(s:callForward)
}
if (is_avp_set($avp(s:voicemail)) {
  if ($avp(s:voicemail)=="true" {
      # Redirect to voicemail server
      rewritehostport("XXX.XXX.XXX.XXX:5070");
  }
}

I hope you get the idea, if not please review documentation  usr_preferences
and avpops module:
 http://www.opensips.org/html/docs/db/db-schema-1.4.x.html#AEN581
 http://www.opensips.org/html/docs/modules/1.4.x/avpops.html

Cheers,

Gustavo

On Tue, Jan 13, 2009 at 11:19 PM, pjgonzalez <pgonzalez at ...
<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2154691&i=0> >
wrote:


Hi every body, i want to be able route calls from my sip, depending on his
status, For example when the user is online he can change his status to
ringOndevice to ring on his sip-phone, voice-mail to route to asterisk
voicemail, and callforward to forward the call to a given number, the two
first escerany are ok bu, i need to know how can i make a call forward base
on users prefenrece.

i alredy load the user preference from the usr_preference table.

here my script part:

if(nat_uac_test("19"))
          {
           setbflag(6);
           fix_nated_contact();
           xlog("L_INFO", "Fixing NAT AGAIN- M=$rm RURI=$ru F=$fu USR=$tU
T=$tu IP=$si ID=$ci\n");
          };

       if(!lookup("location")){
               avp_db_query("SELECT count(*) FROM usr_preferences WHERE
uuid='$tU'","$avp(s:hasPreference)");
               xlog("L_INFO", "User Preference:
atributo:'$avp(s:hasPreference)'\n");

CHECH IF USR is on preference DB to forward to voice Mail server.
              if($avp(s:hasPreference)){
                       route(9);
                       exit;
               }
#OUTBOUNT CALLS/
                       if (uri=~"^sip:[0-9]*@") {
                               route(3);
                               route(6);
                               exit;
                       };
        }
         else
        {
               route(13);
        }

route[11]
{
 xlog("L_INFO","Here on route 11");
 avp_pushto("$ru", "$avp(s:callForward)");

 rewritehostport("XXX.XXX.XXX.XXX:5070");
 append_branch();

xlog("L_INFO", "The call was forwarded to: $avp(s:callForward) - M=$rm
RURI=$ru F=$fu USR=$tU T=$tu IP=$si ID=$ci\n");
#t_on_failure("1");
#t_on_reply("1");
#t_relay();
#xlog("L_INFO", "The call was relay to: $avp(s:callForward) - M=$rm RURI=$ru
F=$fu USR=$tU T=$tu IP=$si ID=$ci\n");
#route(6);
#t_on_branch("1");
 route(12);
}

route[12]{
        xlog("L_INFO","Here on route 12");
       t_on_failure("3");
       t_on_reply("1");
       if (!t_relay()) {
         sl_reply_error();
         xlog("L_INFO", "The error:  - M=$rm RURI=$ru F=$fu USR=$tU T=$tu
IP=$si ID=$ci\n");

       };
       exit;
}

My script is base on sipwise sample.

thanks a lot.

route[13]
{

               xlog("L_INFO", "User is Online - M=$rm RURI=$ru F=$fu
USR=$tU T=$tu IP=$si ID=$ci\n");

                if(avp_db_load("$ru/username","$avp(s:callForward)"))
                  {
                       #xlog("L_INFO", "The call was forwarded to:
$avp(s:callForward) - M=$rm RURI=$ru F=$fu USR=$tU T=$tu IP=$si ID=$ci\n");
                       #avp_pushto("$tu", "$avp(s:callForward)");
                       route(11);
                       exit;
                  }
                else if(avp_db_load("$ru/username","$avp(s:ringOnDevice)"))
                  {
                       xlog("L_INFO"," The call is ringing on: $ruri");
                               route(3);
                               route(8);
                               exit;
                  }
                else if(avp_db_load("$ru/username","$avp(s:voiceMail)"))
                  {
                    xlog("L_INFO", "Voice Mail HERE!! - M=$rm RURI=$ru
F=$fu T=$tu IP=$si ID=$ci\n");
                               route(9);
                               exit;
                  };

exit;
}



--
View this message in context:
http://n2.nabble.com/DIferent-call-Status-when-base-on-user-Preference-tp215
4604p2154604.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.


_______________________________________________
Users mailing list
Users at ...
<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2154691&i=1> 
http://lists.opensips.org/cgi-bin/mailman/listinfo/users




-- 
Gustavo Mistrinelli

_______________________________________________ 
Users mailing list 
Users at ...
<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2154691&i=2>  
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



  _____  

This email is a reply to your post @
http://n2.nabble.com/DIferent-call-Status-when-base-on-user-Preference-tp215
4604p2154691.html
You can reply by email or by visting the link above.

 


-- 
View this message in context: http://n2.nabble.com/DIferent-call-Status-when-base-on-user-Preference-tp2154604p2157067.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.opensips.org/pipermail/users/attachments/20090114/d6c84fb8/attachment-0001.htm 


More information about the Users mailing list