[Kamailio-Devel] [ openser-Patches-1809467 ] Tiny patch to allow the usage of uac_replace_from in branch

SourceForge.net noreply at sourceforge.net
Tue Aug 12 16:07:26 CEST 2008


Patches item #1809467, was opened at 2007-10-08 09:36
Message generated for change (Comment added) made by osas
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=743022&aid=1809467&group_id=139143

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: ver devel
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Carsten Bock (carstenbock)
Assigned to: Nobody/Anonymous (nobody)
Summary: Tiny patch to allow the usage of uac_replace_from in branch

Initial Comment:
Hi,

attached a tiny patch, that allows the use of uac_replace_from in a branch route in Auto-Mode.
We've been using the patch for quite some time on production systems.
The Patch is simple: It just checks, if the From-Line was already restored in the Reply. If Yes, it will not make an second attempt.

Carsten

----------------------------------------------------------------------

>Comment By: Ovidiu Sas (osas)
Date: 2008-08-12 10:07

Message:
Logged In: YES 
user_id=1395524
Originator: NO

> As I can't find a way to attach files
See "Upload and Attach a File:" at the bottom of the web page.

Regards,
Ovidiu Sas

----------------------------------------------------------------------

Comment By: Alex Hermann (axlh)
Date: 2008-08-12 10:03

Message:
Logged In: YES 
user_id=1212856
Originator: NO

Forget the previous comment.

I had to change the patch to actually make it modify the static variable
msg_id. First tests seem promising. As I can't find a way to attach files
via sourceforge, complete patch is inline:

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;
 }




----------------------------------------------------------------------

Comment By: Alex Hermann (axlh)
Date: 2008-08-12 07:55

Message:
Logged In: YES 
user_id=1212856
Originator: NO

Does this actually work (under load)? You use a static global variable to
keep state. What happens if in the meantime another transaction is handled
by the process?

Alex.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=743022&aid=1809467&group_id=139143



More information about the Devel mailing list