Hi All,
        I am using openser 1.2.1 and am having problem when using lookup() functions after failure_route is called.  

I'm assigning a new value to ruri in failure route and then calling route(x).
rotue(x) performs a lookup(location) and calls t_relay() if lookup is successful.  At this point, instead of using the contact uri returned by lookup(), t_relay still uses the original ruri.

Debug info:

Aug 31 10:54:56 mousse openser[6815]: a410a3c1-e4befc20-961fd447@10.1.12.174: route[17] - M=INVITE RURI=sip:10511@sipdev.oursiphost.com F=sip:10510@sipdev.oursiphost.com T=sip:10512@sipdev.oursiphost.com;user=phone IP=10.1.12.174
Aug 31 10:54:56 mousse openser[6815]: rewrite_uri: Rewriting Request-URI with 'sip:10511@10.1.12.172:8891'
Aug 31 10:54:56 mousse openser[6815]: a410a3c1-e4befc20-961fd447@10.1.12.174: route[17] - M=INVITE RURI=sip:10511@10.1.12.172:8891 F=sip:10510@sipdev.oursiphost.com T=sip:10512@sipdev.oursiphost.com;user=phone IP=10.1.12.174 -- inside location lookup
Aug 31 10:54:56 mousse openser[6815]: DEBUG: mk_proxy: doing DNS lookup...
Aug 31 10:54:56 mousse openser[6815]: DEBUG:sip_resolvehost2: no port, no proto -> do NAPTR lookup!
Aug 31 10:54:56 mousse openser[6815]: DEBUG:filter_and_sort_naptr: found valid SIP+D2U -> _sip._udp.sipdev.oursiphost.com
Aug 31 10:54:56 mousse openser[6815]: DEBUG:do_srv_lookup: SRV(_sip._udp.sipdev.oursiphost.com) = mousse.cc.oursiphost.com:5060
Aug 31 10:54:56 mousse openser[6815]: DEBUG:sip_resolvehost2: found!

Thanks in advance.

-- 
Zahid


Begin forwarded message:
From: Zahid Mehmood <zm23@columbia.edu>
Date: August 31, 2007 11:32:28 AM EDT
To: users@openser.org
Subject: [OpenSER-Users] t_relay after failure_route --  problem

Hi All,
     I am trying to implement serial forking and am using the example on voice-systems website as a guide.  The problem I am experiencing is as follows.


Failure route rewrite ruri with the next uri to try and calls route[17]
route 17 performs a lookup("location"), finds the usrloc information and rewrites ruri, however, when t_relay is called it uses the original ruri (one before the lookup) to do t_relay.


route[11] {
    # load all numbers asscociated with the pilot number in $avp(serial_fork) array
    xlog("L_INFO","$ci: route[11] - M=$rm RURI=$ru F=$fu T=$tu IP=$si\n");
      $avp(serial_fork) = "sip:*6" + $rU + "@sipdev.oursiphost.com";
       if (avp_db_query("select username from fork where pilot = $rU order by pri" , "$avp(serial_fork)")) {
              xlog("L_INFO", "route[11] $ci: method $rm r-uri <$ru>\n");
              xlog("L_INFO", "route[11] serial_fork = $avp(serial_fork) remote-user = $rU \n");
              t_on_failure("5");
              route(17);
              exit;
      } else {
              xlog("L_ERR", "route[11] failed to load serial_fork info.\n");
      }
      avp_print();   # debugging only
      setflag(8);
} # end of route[11]


route[17] {
    xlog("L_INFO","$ci: route[17] - M=$rm RURI=$ru F=$fu T=$tu IP=$si\n");
     $avp(s:inv_timeout) = "10";
    if (lookup("location")) {               # currently online registered UA.
        xlog("L_INFO","$ci: route[17] - M=$rm RURI=$ru F=$fu T=$tu IP=$si -- inside location lookup \n");
        if (!t_relay()) {
            sl_reply_error();
        };
        return;
    } else {                                # not online
        if (does_uri_exist()) {         # but exists
            xlog("L_INFO", "$ci: Subscriber is offline [$ru]\n");
            sl_send_reply("480", "Temporarily Unavailable.");
            return;
        }
        xlog("L_INFO","$ci: route[17] - M=$rm RURI=$ru F=$fu T=$tu IP=$si -- outside location lookup \n");
    };
    if (uri=~"^sip:(([0-9()+-])|(%20))+@") {
        subst_user('/[()+-]//g');   # strip out the punctuation.
        subst_user('/%20//g');  # strip out the white space.
        route(18);           # all numerics just go to route(18) -- off system calls
        return;
    };
} # end route[17]

failure_route[5] {
        xlog("L_INFO","$ci: failure_route[5] - M=$rm RURI=$ru F=$fu T=$tu IP=$si\n");
    avp_print();
        if (avp_pushto("$ruri", "$avp(serial_fork)")) {
                append_branch();
                xlog("L_INFO","$ci: failure_route[5] $rm r-uri <$ru> from <$fu> to <$tu>\n");
                avp_delete("$avp(serial_fork)");
                t_on_failure("5");
                route(17);
       } else {
                xlog("L_INFO","$ci: failure_route[5] $rm r-uri <$ru> from <$fu> to <$tu>\n");
        }
}



Debug info


Aug 31 10:54:56 mousse openser[6815]: a410a3c1-e4befc20-961fd447@10.1.12.174: failure_route[5] - M=INVITE RURI=sip:10512@10.1.12.172:8891 F=sip:10510@sipdev.oursiphost.com T=sip:10512@sipdev.oursiphost.com;user=phone IP=10.1.12.174
Aug 31 10:54:56 mousse openser[6815]: INFO:avpops:print_avp: p=0xb6039c28, flags=0x0003
Aug 31 10:54:56 mousse openser[6815]: INFO:                     name=<inv_timeout>
Aug 31 10:54:56 mousse openser[6815]: INFO:                     val_str=<10 / 2>
Aug 31 10:54:56 mousse openser[6815]: INFO:avpops:print_avp: p=0xb6039bf0, flags=0x0002
Aug 31 10:54:56 mousse openser[6815]: INFO:                     id=<655>
Aug 31 10:54:56 mousse openser[6815]: INFO:                     val_str=<sip:10511@sipdev.oursiphost.com / 29>
Aug 31 10:54:56 mousse openser[6815]: INFO:avpops:print_avp: p=0xb6039bb8, flags=0x0002
Aug 31 10:54:56 mousse openser[6815]: INFO:                     id=<655>
Aug 31 10:54:56 mousse openser[6815]: INFO:                     val_str=<sip:10210@sipdev.oursiphost.com / 29>
Aug 31 10:54:56 mousse openser[6815]: INFO:avpops:print_avp: p=0xb6039b80, flags=0x0002
Aug 31 10:54:56 mousse openser[6815]: INFO:                     id=<655>
Aug 31 10:54:56 mousse openser[6815]: INFO:                     val_str=<sip:10510@sipdev.oursiphost.com / 29>
Aug 31 10:54:56 mousse openser[6815]: INFO:avpops:print_avp: p=0xb6039b48, flags=0x0002
Aug 31 10:54:56 mousse openser[6815]: INFO:                     id=<655>
Aug 31 10:54:56 mousse openser[6815]: INFO:                     val_str=<sip:*610512@sipdev.oursiphost.com / 31>
Aug 31 10:54:56 mousse openser[6815]: INFO:avpops:print_avp: p=0xb6039b18, flags=0x0083
Aug 31 10:54:56 mousse openser[6815]: INFO:                     name=<is_pilot>
Aug 31 10:54:56 mousse openser[6815]: INFO:                     val_str=<y / 1>
Aug 31 10:54:56 mousse openser[6815]: DEBUG:avpops:pushto_avps: 1 avps were processed
Aug 31 10:54:56 mousse openser[6815]: ******* setting for branch 0 flags 0
Aug 31 10:54:56 mousse openser[6815]: a410a3c1-e4befc20-961fd447@10.1.12.174: failure_route[5] INVITE r-uri <sip:10511@sipdev.oursiphost.com> from <sip:10510@sipdev.oursiphost.com> to <sip:10512@sipdev.oursiphost.com;user=phone>
Aug 31 10:54:56 mousse openser[6815]: DEBUG:avpops:delete_avps: 1 avps were removed
Aug 31 10:54:56 mousse openser[6815]: a410a3c1-e4befc20-961fd447@10.1.12.174: route[17] - M=INVITE RURI=sip:10511@sipdev.oursiphost.com F=sip:10510@sipdev.oursiphost.com T=sip:10512@sipdev.oursiphost.com;user=phone IP=10.1.12.174
Aug 31 10:54:56 mousse openser[6815]: rewrite_uri: Rewriting Request-URI with 'sip:10511@10.1.12.172:8891'
Aug 31 10:54:56 mousse openser[6815]: a410a3c1-e4befc20-961fd447@10.1.12.174: route[17] - M=INVITE RURI=sip:10511@10.1.12.172:8891 F=sip:10510@sipdev.oursiphost.com T=sip:10512@sipdev.oursiphost.com;user=phone IP=10.1.12.174 -- inside location lookup
Aug 31 10:54:56 mousse openser[6815]: DEBUG: mk_proxy: doing DNS lookup...
Aug 31 10:54:56 mousse openser[6815]: DEBUG:sip_resolvehost2: no port, no proto -> do NAPTR lookup!
Aug 31 10:54:56 mousse openser[6815]: DEBUG:filter_and_sort_naptr: found valid SIP+D2U -> _sip._udp.sipdev.oursiphost.com
Aug 31 10:54:56 mousse openser[6815]: DEBUG:do_srv_lookup: SRV(_sip._udp.sipdev.oursiphost.com) = mousse.cc.oursiphost.com:5060
Aug 31 10:54:56 mousse openser[6815]: DEBUG:sip_resolvehost2: found!
Aug 31 10:54:56 mousse openser[6815]: check_via_address(10.1.12.174, 10.1.12.174, 0)
Aug 31 10:54:56 mousse openser[6815]: DEBUG:tm:set_timer: relative timeout is 500000
Aug 31 10:54:56 mousse openser[6815]: DEBUG: add_to_tail_of_timer[4]: 0xb6039eb4 (61500000)
Aug 31 10:54:56 mousse openser[6815]: DEBUG:tm:set_timer: relative timeout is 30
Aug 31 10:54:56 mousse openser[6815]: DEBUG: add_to_tail_of_timer[0]: 0xb6039ed0 (91)
Aug 31 10:54:56 mousse openser[6815]: DEBUG:tm:relay_reply: branch=0, save=1, relay=-1
>, CSEQ_N=<CSeq: 1> 2@sipdev.oursiphost.com;user=phone>ocal: using FROM=<From: "Zahid 10510" <sip:10510@sipdev.oursiphost.com>;tag=BF787F6-F6DD44ED
Aug 31 10:54:56 mousse openser[6815]: DEBUG: cancel_branch: sending cancel...
Aug 31 10:54:56 mousse openser[6815]: DEBUG:tm:set_timer: relative timeout is 500000
Aug 31 10:54:56 mousse openser[6815]: DEBUG: add_to_tail_of_timer[4]: 0xb6039e20 (61500000)
Aug 31 10:54:56 mousse openser[6815]: DEBUG:tm:set_timer: relative timeout is 30
Aug 31 10:54:56 mousse openser[6815]: DEBUG: add_to_tail_of_timer[0]: 0xb6039e3c (91)