<!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">
At one point upgrading would be easier than patch the old...<br>
g-)<br>
<br>
Atle Samuelsen wrote:
<blockquote cite="mid:20070815080435.GC35751@mystic.cyberhouse.no"
 type="cite">
  <pre wrap="">If your useing 0.8.11, I think you can just do a few google searches and
you will find a function that does this.

On the other hand.. you should maybe concider upgradeing at somepoint
soon :)
-A


* Fernando Schmitt <a class="moz-txt-link-rfc2396E" href="mailto:fernandoschmitt@ig.com.br">&lt;fernandoschmitt@ig.com.br&gt;</a> [070815 08:52]:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hehe. I'm using ser 0.8.11-r1. I know. I know. shame on me.

 

Fernando Schmitt

  _____  

From: Greger V. Teigre [<a class="moz-txt-link-freetext" href="mailto:greger@teigre.com">mailto:greger@teigre.com</a>] 
Sent: Wednesday, August 15, 2007 3:35 AM
To: Fernando Schmitt
Cc: <a class="moz-txt-link-abbreviated" href="mailto:serusers@lists.iptel.org">serusers@lists.iptel.org</a>
Subject: Re: [Serusers] SER Proxy with Redirect

 

I believe you can do this a lot easier in ser.cfg 2.x using selects to pick
the Contact.
g-)

Fernando Schmitt wrote: 

Juha,

 

I'm new into C programming. Could you kindly let me know where this code
should be inserted?

 

yes, i implemented a function called move that turned 302 to invite, but
that code relied on a patch to tm module that gave me access to contact
header of reply in reply route.
 
i found the function and it is below.  someone who needs this
functionality has to check if same kind of access to the contact header
of the reply is still possible or if the access method is now different
and modify the code accordingly.
 
also, all contacts would need to be taken from 302, not just the first.
 
contact_re was compiled during module initialization:
 
        regcomp(&amp;contact_re, "^Contact:(.*)$", REG_EXTENDED|REG_NEWLINE);
 
needless to say, i'm not proud of this code, but it gives an idea on how
it can be done.
 
-- juha
 
/*
 * Appends a new branch to request using the first Contact URI of the (302)
 * reply (if any) as the Request URI.  Returns 1 if appending succeeded and
-1
 * if it failed.
 */
int move(struct sip_msg* _m, char* _s1, char* _s2)
{
        struct sip_msg* reply;
        regmatch_t pmatch[2];
        struct hdr_field hf;
        contact_t* first;
 
        reply = _m-&gt;final_reply;
 
        if (!reply) {
               LOG(L_ERR, "move(): No reply found\n");
               return -1;
        }
 
        LOG(L_ERR, "move(): unparsed part of reply: %s\n", reply-&gt;unparsed);
 
        if ((regexec(&amp;contact_re, reply-&gt;unparsed, 2, &amp;(pmatch[0]), 0) != 0)
||
            (pmatch[1].rm_so == -1)) {
               LOG(L_ERR, "move(): No Contact header found\n");
               return -1;
        }
 
        hf.type = HDR_CONTACT;
        hf.name.len = 0;
        hf.body.len = pmatch[1].rm_eo - pmatch[1].rm_so - 1;
        hf.body.s = &amp;(reply-&gt;unparsed[pmatch[1].rm_so]);
        hf.len = hf.body.len + 2;
        hf.parsed = NULL;
        hf.next = NULL;
        
        LOG(L_ERR, "hf.body: '%.*s'\n", hf.body.len, hf.body.s);
 
        if (parse_contact(&amp;hf) &lt; 0) {
               LOG(L_ERR, "move(): Error while parsing Contact\n");
               goto failure;
        }
        
        if (((contact_body_t*)hf.parsed)-&gt;star == 1) {
               LOG(L_ERR, "move(): Contact is *\n");
               goto failure;
        }
 
        first = ((contact_body_t*)hf.parsed)-&gt;contacts;
        if (first) {
               if (append_branch(_m, first-&gt;uri.s, first-&gt;uri.len) == 1) {
                       goto success;
               } else {
                       LOG(L_ERR, "move(): Appending branch failed\n");
               }
        } else {
               LOG(L_ERR, "move(): No contacts in Contact header\n");
        }
 
failure:
        if (hf.parsed) {
               free_contact((contact_body_t**)(&amp;(hf.parsed)));
        }
        return -1;
 
success:
        free_contact((contact_body_t**)(&amp;(hf.parsed)));
        return 1;
}

 

Fernando Schmitt

 
 
 





  _____  



 
 
 
_______________________________________________
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>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">_______________________________________________
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>
  <pre wrap=""><!---->
_______________________________________________
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>