<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1515" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hello, </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>this topic was last discussed here: </FONT></DIV>
<DIV><FONT face=Arial size=2><A
href="http://lists.iptel.org/pipermail/serusers/2005-May/019551.html">http://mail.iptel.org/pipermail/serusers/2005-May/019551.html</A></FONT></DIV>
<DIV> </DIV>
<DIV>last few days i was trying to apply juha's move() function with almost no
success to 0.9.3 stable branch. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>i added such code to my ser.cfg:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>onreply_route[1]
{<BR> xlog("L_NOTICE", "Reply status
%rs: Reason %rr\n");<BR> if
(t_check_status("30[12]"))
{<BR>
xlog("L_NOTICE", "We got a
30[12]!!!!!\n");<BR>
t_move(); # custom function by
juha<BR>
#t_reply();<BR>
};<BR>}<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>and modified move() code like this: </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>inline static int move(struct sip_msg* _m, char
*_foo, char *_bar)<BR>{<BR> //struct
sip_msg* reply;<BR> regmatch_t
pmatch[2];<BR> struct hdr_field
hf;<BR> contact_t*
first;<BR> regex_t
contact_re;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> // What
is it? didn't find anywere.</FONT></DIV>
<DIV><FONT face=Arial size=2> //reply
= _m->final_reply;</FONT></DIV>
<DIV><FONT face=Arial size=2> // MOD
HERE</FONT></DIV>
<DIV><FONT face=Arial size=2> if (!_m)
{<BR>
LOG(L_ERR, "move(): No reply
found\n");<BR>
return -1;<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><FONT face=Arial size=2>
<DIV><BR> LOG(L_ERR, "move(): unparsed
part of reply: %s\n",
_m->unparsed);<BR> // FIXME: where
to put this? initialisation?<BR> //
MOD HERE</DIV>
<DIV> regcomp(&contact_re,
"^Contact:(.*)$",
REG_EXTENDED|REG_NEWLINE);<BR> if ( (
regexec(&contact_re, _m->unparsed, 2, &(pmatch[0]), 0) != 0) ||
(pmatch[1].rm_so == -1))
{<BR>
LOG(L_ERR, "move(): No Contact header
found\n");<BR>
return -1;<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> hf.type
= HDR_CONTACT;<BR> hf.name.len =
0;<BR> hf.body.len = pmatch[1].rm_eo -
pmatch[1].rm_so - 1;<BR> hf.body.s =
&(_m->unparsed[pmatch[1].rm_so]);<BR>
hf.len = hf.body.len + 2;<BR>
hf.parsed = NULL;<BR> hf.next =
NULL;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> // this
prints out redirected contact</FONT></DIV>
<DIV><FONT face=Arial size=2>
LOG(L_ERR, "hf.body: '%.*s'\n", hf.body.len, hf.body.s);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> if
(parse_contact(&hf) < 0)
{<BR>
LOG(L_ERR, "move(): Error while parsing
Contact\n");<BR>
goto failure;<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> if
(((contact_body_t*)hf.parsed)->star == 1)
{<BR>
LOG(L_ERR, "move(): Contact is
*\n");<BR>
goto failure;<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2> first =
((contact_body_t*)hf.parsed)->contacts;<BR>
if (first) {<BR>
// MOD HERE</FONT></DIV>
<DIV><FONT face=Arial
size=2>
if (append_branch(_m, first->uri.s, first->uri.len, 0, 0, Q_UNSPECIFIED)
== 1)
{<BR>
goto
success;<BR>
} else
{<BR>
LOG(L_ERR, "move(): Appending branch
failed\n");<BR>
}<BR> } else
{<BR>
LOG(L_ERR, "move(): No contacts in Contact
header\n");<BR> }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2>failure:<BR> if (hf.parsed)
{<BR>
free_contact((contact_body_t**)(&(hf.parsed)));<BR>
}<BR> return -1;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2>success:<BR>
free_contact((contact_body_t**)(&(hf.parsed)));<BR>
return 1;<BR>}<BR></FONT></DIV>
<DIV><FONT face=Arial size=2> </DIV></FONT>
<DIV><FONT face=Arial size=2>it seems that t_move succeeds(), contact gets
parsed and append_branch() gets execuded. But then, nothing happens. 302 is
replied back to call originator. It is function build_res_buf_from_sip_res is
called() which builds 302 message back to call originator..</FONT></DIV>
<DIV><FONT face=Arial size=2>It seems that after getting contact from 302
message, INVITE sould be generatated somehow. I suspect that i am passing wrong
message to append_branch, but i didn't found how to access INVITE from tm module
while in onreply_route[]. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Can anybody with deeper ser knowledge
help? </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Antanas </FONT></DIV>
<DIV><FONT face=Arial size=2> </DIV></FONT></BODY></HTML>