<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I believe you can do this a lot easier in ser.cfg 2.x using selects to
pick the Contact.<br>
g-)<br>
<br>
Fernando Schmitt wrote:
<blockquote cite="mid:20070815062507.2830EB01C1@larry.ufrgs.br"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <meta name="Generator" content="Microsoft Word 11 (filtered medium)">
  <style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
pre
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle18
        {mso-style-type:personal-compose;
        font-family:Verdana;
        color:windowtext;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
  </style>
  <div class="Section1">
  <p class="MsoNormal"><font face="Verdana" size="2"><span
 style="font-size: 10pt; font-family: Verdana;">Juha,<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font face="Verdana" size="2"><span
 style="font-size: 10pt; font-family: Verdana;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font face="Verdana" size="2"><span
 style="font-size: 10pt; font-family: Verdana;">I&#8217;m new into C
programming&#8230; Could you kindly
let me know where this code should be inserted?<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font face="Verdana" size="2"><span
 style="font-size: 10pt; font-family: Verdana;"><o:p>&nbsp;</o:p></span></font></p>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">yes, i implemented a function called move that turned 302 to invite, but<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">that code relied on a patch to tm module that gave me access to contact<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">header of reply in reply route.<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">i found the function and it is below.&nbsp; someone who needs this<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">functionality has to check if same kind of access to the contact header<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">of the reply is still possible or if the access method is now different<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">and modify the code accordingly.<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">also, all contacts would need to be taken from 302, not just the first.<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">contact_re was compiled during module initialization:<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; regcomp(&amp;contact_re, "^Contact:(.*)$", REG_EXTENDED|REG_NEWLINE);<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">needless to say, i'm not proud of this code, but it gives an idea on how<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">it can be done.<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">-- juha<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">/*<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"> * Appends a new branch to request using the first Contact URI of the (302)<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"> * reply (if any) as the Request URI.&nbsp; Returns 1 if appending succeeded and -1<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"> * if it failed.<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"> */<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">int move(struct sip_msg* _m, char* _s1, char* _s2)<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">{<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct sip_msg* reply;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; regmatch_t pmatch[2];<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct hdr_field hf;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contact_t* first;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reply = _m-&gt;final_reply;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!reply) {<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOG(L_ERR, "move(): No reply found\n");<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOG(L_ERR, "move(): unparsed part of reply: %s\n", reply-&gt;unparsed);<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((regexec(&amp;contact_re, reply-&gt;unparsed, 2, &amp;(pmatch[0]), 0) != 0) ||<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (pmatch[1].rm_so == -1)) {<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOG(L_ERR, "move(): No Contact header found\n");<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hf.type = HDR_CONTACT;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hf.name.len = 0;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hf.body.len = pmatch[1].rm_eo - pmatch[1].rm_so - 1;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hf.body.s = &amp;(reply-&gt;unparsed[pmatch[1].rm_so]);<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hf.len = hf.body.len + 2;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hf.parsed = NULL;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hf.next = NULL;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOG(L_ERR, "hf.body: '%.*s'\n", hf.body.len, hf.body.s);<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"> <o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (parse_contact(&amp;hf) &lt; 0) {<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOG(L_ERR, "move(): Error while parsing Contact\n");<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto failure;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (((contact_body_t*)hf.parsed)-&gt;star == 1) {<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOG(L_ERR, "move(): Contact is *\n");<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto failure;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; first = ((contact_body_t*)hf.parsed)-&gt;contacts;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (first) {<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (append_branch(_m, first-&gt;uri.s, first-&gt;uri.len) == 1) {<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto success;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOG(L_ERR, "move(): Appending branch failed\n");<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOG(L_ERR, "move(): No contacts in Contact header\n");<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">failure:<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (hf.parsed) {<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; free_contact((contact_body_t**)(&amp;(hf.parsed)));<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">success:<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; free_contact((contact_body_t**)(&amp;(hf.parsed)));<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1;<o:p></o:p></span></font></pre>
  <pre><font face="Courier New" size="2"><span style="font-size: 10pt;">}<o:p></o:p></span></font></pre>
  <p class="MsoNormal"><font face="Verdana" size="2"><span
 style="font-size: 10pt; font-family: Verdana;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font face="Verdana" size="2"><span
 style="font-size: 10pt; font-family: Verdana;">Fernando Schmitt</span></font><o:p></o:p></p>
  </div>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Serusers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Serusers@lists.iptel.org">Serusers@lists.iptel.org</a>
<a class="moz-txt-link-freetext" href="http://lists.iptel.org/mailman/listinfo/serusers">http://lists.iptel.org/mailman/listinfo/serusers</a>
  </pre>
</blockquote>
</body>
</html>