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 <fernandoschmitt(a)ig.com.br> [070815 08:52]:
Hehe. I'm using ser 0.8.11-r1. I know. I know.
shame on me.
Fernando Schmitt
_____
From: Greger V. Teigre [mailto:greger@teigre.com]
Sent: Wednesday, August 15, 2007 3:35 AM
To: Fernando Schmitt
Cc: serusers(a)lists.iptel.org
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(&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->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->unparsed);
if ((regexec(&contact_re, reply->unparsed, 2, &(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 = &(reply->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(&hf) < 0) {
LOG(L_ERR, "move(): Error while parsing Contact\n");
goto failure;
}
if (((contact_body_t*)hf.parsed)->star == 1) {
LOG(L_ERR, "move(): Contact is *\n");
goto failure;
}
first = ((contact_body_t*)hf.parsed)->contacts;
if (first) {
if (append_branch(_m, first->uri.s, first->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**)(&(hf.parsed)));
}
return -1;
success:
free_contact((contact_body_t**)(&(hf.parsed)));
return 1;
}
Fernando Schmitt
_____
_______________________________________________
Serusers mailing list
Serusers(a)lists.iptel.org
http://lists.iptel.org/mailman/listinfo/serusers
_______________________________________________
Serusers mailing list
Serusers(a)lists.iptel.org
http://lists.iptel.org/mailman/listinfo/serusers