Hello,
i'm still fighting with the very annoying lump model that OpenSER uses. I need to send out INVITE's with different From headers in a failover situation. More specifically I need to send out each step -original request and failure_routes- with a different From header. If any request forks (parallel or serial due to DNS SRV or registered contacts), it needs to keep current (same) the replacement From on all branches.
I tried the following:
try 1:
REQUEST_ROUTE: uac_replace_from(a) t_relay();
FAILURE_ROUTE: append_branch() uac_replace_from(b) t_relay()
the second uac_replace_from always produces garbage in the From
try 2: REQUEST_ROUTE: t_newtran() uac_replace_from(a) t_relay();
FAILURE_ROUTE: append_branch() uac_replace_from(b) t_relay()
Now the second uac_replace_from is correct, but when the first t_relay() does dns based failover, the original from is used for the second branch instead of the replacement. If the response code is locally generated 408, the second uac_replace_from produces garabage too.
Is someone aware of a working solution for this (very common) situation?
El Tuesday 12 August 2008 14:17:39 Alex Hermann escribió:
REQUEST_ROUTE: uac_replace_from(a) t_relay();
FAILURE_ROUTE: append_branch() uac_replace_from(b) t_relay()
the second uac_replace_from always produces garbage in the From
Yes, it occurred the same to me. uac_replace_from has a very buggy behaviour.
Is not valid for you using P-Asserted-Identity or RPID?
On Tuesday 12 August 2008, Iñaki Baz Castillo wrote:
El Tuesday 12 August 2008 14:17:39 Alex Hermann escribió:
REQUEST_ROUTE: uac_replace_from(a) t_relay();
FAILURE_ROUTE: append_branch() uac_replace_from(b) t_relay()
the second uac_replace_from always produces garbage in the From
Yes, it occurred the same to me. uac_replace_from has a very buggy behaviour.
Is not valid for you using P-Asserted-Identity or RPID?
No. I really need to modify the From.
I tried Carstens patch to use uac_replace_from in branch route. This hack does the 'right thing' for requests, but still puts multiple From headers in replies.
Try textops subst() in branch_route.
Regards, Ovidiu Sas
On Tue, Aug 12, 2008 at 9:39 AM, Alex Hermann alex@speakup.nl wrote:
On Tuesday 12 August 2008, Iñaki Baz Castillo wrote:
El Tuesday 12 August 2008 14:17:39 Alex Hermann escribió:
REQUEST_ROUTE: uac_replace_from(a) t_relay();
FAILURE_ROUTE: append_branch() uac_replace_from(b) t_relay()
the second uac_replace_from always produces garbage in the From
Yes, it occurred the same to me. uac_replace_from has a very buggy behaviour.
Is not valid for you using P-Asserted-Identity or RPID?
No. I really need to modify the From.
I tried Carstens patch to use uac_replace_from in branch route. This hack does the 'right thing' for requests, but still puts multiple From headers in replies.
-- Greetings,
Alex Hermann
Users mailing list Users@lists.kamailio.org http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
Hi Alex,
Let me double check this. In our setup, this works properly (or at least no problem known); and the from headers in the reply is right as well. One difference may be, that we use uac_replace_from purely in branch_route() and not in the request route itself. I can double check your problem tomorrow (i'm not at the office today) and, if i find something, update the patch.
Carsten
Alex Hermann wrote:
On Tuesday 12 August 2008, Iñaki Baz Castillo wrote:
El Tuesday 12 August 2008 14:17:39 Alex Hermann escribió:
REQUEST_ROUTE: uac_replace_from(a) t_relay();
FAILURE_ROUTE: append_branch() uac_replace_from(b) t_relay()
the second uac_replace_from always produces garbage in the From
Yes, it occurred the same to me. uac_replace_from has a very buggy behaviour.
Is not valid for you using P-Asserted-Identity or RPID?
No. I really need to modify the From.
I tried Carstens patch to use uac_replace_from in branch route. This hack does the 'right thing' for requests, but still puts multiple From headers in replies.
On Tuesday 12 August 2008, Carsten Bock wrote:
Let me double check this. In our setup, this works properly (or at least no problem known); and the from headers in the reply is right as well. One difference may be, that we use uac_replace_from purely in branch_route() and not in the request route itself.
It's what I do now.
I can double check your problem tomorrow (i'm not at the office today) and, if i find something, update the patch.
It needed an additional patch to make it set the msg_id to the current reply_id. I also changed the DBG messages. Patch is against 1.2+svn4682.
See below for the complete working patch.
diff -u openser-1.2-orig/modules/uac/uac.c openser-1.2/modules/uac/uac.c --- openser-1.2-orig/modules/uac/uac.c 2008-08-12 15:55:12.000000000 +0200 +++ openser-1.2/modules/uac/uac.c 2008-08-12 13:26:27.000000000 +0200 @@ -81,9 +81,9 @@ /* Exported functions */ static cmd_export_t cmds[]={ {"uac_replace_from", w_replace_from2, 2, fixup_replace_from2, - REQUEST_ROUTE }, + REQUEST_ROUTE | BRANCH_ROUTE }, {"uac_replace_from", w_replace_from1, 1, fixup_replace_from1, - REQUEST_ROUTE }, + REQUEST_ROUTE | BRANCH_ROUTE }, {"uac_restore_from", w_restore_from, 0, 0, REQUEST_ROUTE }, {"uac_auth", w_uac_auth, 0, 0, diff -u openser-1.2-orig/modules/uac/from.c openser-1.2/modules/uac/from.c --- openser-1.2-orig/modules/uac/from.c 2007-10-22 11:48:48.000000000 +0200 +++ openser-1.2/modules/uac/from.c 2008-08-12 15:56:42.000000000 +0200 @@ -61,6 +61,8 @@
#define text3B64_len(_l) ( ( ((_l)+2)/3 ) << 2 )
+/* The reply, were the From-Line was replaced. */ +static unsigned int msg_id = 0;
void init_from_replacer() { @@ -564,6 +566,12 @@ "FROM hdr\n"); return; } + + DBG("DBG:uac::restore_from_reply: current id = %d, code %d (last id %d)\n", rpl->id, p->code, msg_id); + if (msg_id == rpl->id) { + DBG("DBG:uac::restore_from_reply: No change, already done!\n"); + return; + }
/* duplicate the new from value */ new_val.s = pkg_malloc( req->from->len ); @@ -589,6 +597,9 @@ LOG(L_ERR,"ERROR:uac:restore_from_reply: insert new lump failed\n"); return; } + + /* Mark this id as replied to prevent multiple From headers in replies */ + msg_id = rpl->id; }