[sr-dev] appending a new branch in route block

Juha Heinanen jh at tutpro.com
Mon May 17 17:47:29 CEST 2010


Juha Heinanen writes:

> any pointer on how to do the same from lcr module?  i guess i need to
> load tm api and call some tm function?

i think i was able to figure this out.  the corresponding tm api
function is t_gett().

so i went and changed next_gw() implementation so that if no transaction
exists, it rewrites request uri and if it exists, it clears possible old
branches and appends a new one.

still next_gw() does not work as it should, i.e., second next_gw() call
after failing t_relay() results in destination set with two sip uris
(the first one and the second one).

then i went and added some more debug to script:

 	    # relay the request
	    if (t_relay()) {
		    xlog("Relaying succeeded with result $rc\n");
			exit;
		} else {	
		    xlog("Relaying failed with result $rc\n");
		    if (t_check_trans()) {
			    xlog("Transaction exists\n");
		    } else {
		       xlog("Transaction does not exist\n");
		    };
		};

what happens now is that execution of the script stops at
t_check_trans() test, i.e., nothing gets printed to syslog after this:

May 17 18:26:09 localhost /usr/sbin/sip-proxy[30400]: ERROR: Relaying failed with result -478

even if t_check_trans() would not be a proper function to call at this
point, i don't understand why it does not return.

anyway, then i then went and changed in above t_check_trans() to
t_lookup_request() and execution of the script went on and printed this:

May 17 18:36:35 localhost /usr/sbin/sip-proxy[30693]: INFO: Relaying
INVITE <sip:00358407058055 at sars.tutpro.com;transport=tcp> to gw
May 17 18:36:35 localhost /usr/sbin/sip-proxy[30693]: ERROR: tm [ut.h:295]: ERROR: uri2dst: failed to resolve "sars.tutpro.com" :unresolvable A or AAAA request (-7)
May 17 18:36:35 localhost /usr/sbin/sip-proxy[30693]: ERROR: tm [t_fwd.c:1391]: ERROR: t_forward_nonack: failure to add branches
May 17 18:36:35 localhost /usr/sbin/sip-proxy[30693]: ERROR: Relaying failed with result -478
May 17 18:36:35 localhost /usr/sbin/sip-proxy[30693]: ERROR: Transaction exists
May 17 18:36:36 localhost /usr/sbin/sip-proxy[30693]: ERROR: Calling next_gw()
May 17 18:36:36 localhost /usr/sbin/sip-proxy[30693]: ERROR: found next
gw <Contact: sip:00358407058055 at sars.tutpro.com;transport=tcp,
sip:00358407058055 at lohi.tutpro.com:5060>
May 17 18:36:36 localhost /usr/sbin/sip-proxy[30693]: INFO: Relaying
INVITE <sip:00358407058055 at sars.tutpro.com;transport=tcp> to gw
...

so even if t_relay() failed with result -478, transaction was created.
as result, next_gw() thought that it must now append a new branch
instead of rewriting request uri, which resulted in trying the first gw
the second time.

i don't understand, how it is possible that transaction was created, but
request uri was not marked as used.  also, i don't understand how i can
ever get this to work, because i don't have no way to know if i should
rewrite request uri or append a branch.

andrei, are you around?  perhaps you can shed some light on this or
better yet implement opensips behavior about which i posted a request
to the tracker, which would allow me always just to rewrite request uri
and be done with it.

-- juha



More information about the sr-dev mailing list