version: kamailio 3.1.4 (i386/linux)
FAILURE_ROUTE:
xlogl("L_NOTICE","failure to PSTN gateway: Call to $ru\n");
$rd = "81.209.128.132:5060";
xlogl("L_NOTICE","next gateway. Call to $ru\n");
route(RELAY);
results in:
NOTICE: <script>: 1089:failure to PSTN gateway: Call to
sip:00431505641636@1.2.3.4:5060
ERROR: pv [pv_core.c:186]: failed to parse the R-URI
NOTICE: <script>: 1097:next gateway. Call to <null>
...
ERROR: uri2dst: bad_uri: sip:00431505641636@81.209.128.132:5060:5060
Looks like the assignment to $rd is buggy (double port)
regards
klaus
Module: sip-router
Branch: master
Commit: 1db5459e967bbe34133718a6184266c45c4e868b
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1db5459…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Mon Jul 4 00:40:21 2011 +0200
tm: add doxygen documentation for sip_msg.[c,h] files
---
modules/tm/sip_msg.c | 54 +++++++++++++++++++++++++++++------------
modules/tm/sip_msg.h | 65 +++++++++++++++++++++++++++++++++++++++----------
2 files changed, 89 insertions(+), 30 deletions(-)
diff --git a/modules/tm/sip_msg.c b/modules/tm/sip_msg.c
index f968acd..0eac3a4 100644
--- a/modules/tm/sip_msg.c
+++ b/modules/tm/sip_msg.c
@@ -1,17 +1,4 @@
/*
- * $Id$
- *
- * cloning a message into shared memory (TM keeps a snapshot
- * of messages in memory); note that many operations, which
- * allocate pkg memory (such as parsing) cannot be used with
- * a cloned message -- it would result in linking pkg structures
- * to shmem msg and eventually in a memory error
- *
- * the cloned message is stored in a single memory fragment to
- * save too many shm_mallocs -- these are expensive as they
- * not only take lookup in fragment table but also a shmem lock
- * operation (the same for shm_free)
- *
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of ser, a free SIP server.
@@ -54,6 +41,28 @@
* later than the SIP msg. (Miklos)
* 2009-07-22 moved most of the functions to core sip_msg_clone.c (andrei)*/
+/**
+ * @file
+ * @brief TM :: Message cloning functionality
+ *
+ * Cloning a message into shared memory (TM keeps a snapshot
+ * of messages in memory); note that many operations, which
+ * allocate pkg memory (such as parsing) cannot be used with
+ * a cloned message -- it would result in linking pkg structures
+ * to shmem msg and eventually in a memory error.
+ *
+ * The cloned message is stored in a single memory fragment to
+ * save too many shm_mallocs -- these are expensive as they
+ * not only take lookup in fragment table but also a shmem lock
+ * operation (the same for shm_free)
+ *
+ * Allow postponing the cloning of SIP msg:
+ * t_newtran() copies the requests to shm mem without the lumps,
+ * and t_forward_nonack() clones the lumps later when it is called
+ * the first time.
+ * @ingroup tm
+ */
+
#include "defs.h"
@@ -66,8 +75,14 @@
#include "../../sip_msg_clone.h"
#include "../../fix_lumps.h"
-/* Warning: Cloner does not clone all hdr_field headers (From, To, etc.). Pointers will reference pkg memory. Dereferencing will crash ser!!! */
+/**
+ * @brief Clone a SIP message
+ * @warning Cloner does not clone all hdr_field headers (From, To, etc.). Pointers will reference pkg memory. Dereferencing will crash ser!
+ * @param org_msg Original SIP message
+ * @param sip_msg_len Length of the SIP message
+ * @return Cloned SIP message, or NULL on error
+ */
struct sip_msg* sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
{
/* take care of the lumps only for replies if the msg cloning is
@@ -79,12 +94,19 @@ struct sip_msg* sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
return sip_msg_shm_clone(org_msg, sip_msg_len, 0);
}
-/* indicates wheter we have already cloned the msg lumps or not */
+/**
+ * @brief Indicates wheter we have already cloned the msg lumps or not
+ */
unsigned char lumps_are_cloned = 0;
-/* wrapper function for msg_lump_cloner() with some additional sanity checks */
+/**
+ * @brief Wrapper function for msg_lump_cloner() with some additional sanity checks
+ * @param shm_msg SIP message in shared memory
+ * @param pgk_msg SIP message in private memory
+ * @return 0 on success, -1 on error
+ */
int save_msg_lumps( struct sip_msg *shm_msg, struct sip_msg *pkg_msg)
{
int ret;
diff --git a/modules/tm/sip_msg.h b/modules/tm/sip_msg.h
index f006cde..1742207 100644
--- a/modules/tm/sip_msg.h
+++ b/modules/tm/sip_msg.h
@@ -1,6 +1,4 @@
/*
- * $Id$
- *
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of ser, a free SIP server.
@@ -25,7 +23,27 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+/**
+ * @file
+ * @brief TM :: Message cloning functionality
+ *
+ * Cloning a message into shared memory (TM keeps a snapshot
+ * of messages in memory); note that many operations, which
+ * allocate pkg memory (such as parsing) cannot be used with
+ * a cloned message -- it would result in linking pkg structures
+ * to shmem msg and eventually in a memory error.
+ *
+ * The cloned message is stored in a single memory fragment to
+ * save too many shm_mallocs -- these are expensive as they
+ * not only take lookup in fragment table but also a shmem lock
+ * operation (the same for shm_free)
+ *
+ * Allow postponing the cloning of SIP msg:
+ * t_newtran() copies the requests to shm mem without the lumps,
+ * and t_forward_nonack() clones the lumps later when it is called
+ * the first time.
+ * @ingroup tm
+ */
#ifndef _SIP_MSG_H
#define _SIP_MSG_H
@@ -36,20 +54,18 @@
#include "../../parser/msg_parser.h"
#include "../../mem/shm_mem.h"
-/* Allow postponing the cloning of SIP msg:
- * t_newtran() copies the requests to shm mem without the lumps,
- * and t_forward_nonack() clones the lumps later when it is called
- * the first time.
- * Replies use only one memory block.
- */
#include "../../atomic_ops.h" /* membar_depends() */
-/* msg is a reply: one memory block was allocated
+/**
+ * @brief Helper function to free a SIP message
+ *
+ * msg is a reply: one memory block was allocated
+ *
* msg is a request: two memory blocks were allocated:
- * - one for the sip_msg struct
- * - another one for the lumps which is linked to
- * add_rm, body_lumps, or reply_lump.
+ * - one for the sip_msg struct
+ * - another one for the lumps which is linked to add_rm, body_lumps,
+ * or reply_lump
*/
#define _sip_msg_free(_free_func, _p_msg) \
do{ \
@@ -69,14 +85,35 @@
}while(0)
+/**
+ * @brief Free a SIP message safely, with locking
+ */
#define sip_msg_free(_p_msg) _sip_msg_free(shm_free, _p_msg)
+/**
+ * @brief Free a SIP message unsafely, without locking
+ */
#define sip_msg_free_unsafe(_p_msg) _sip_msg_free(shm_free_unsafe, _p_msg)
-
+/**
+ * @brief Clone a SIP message
+ * @warning Cloner does not clone all hdr_field headers (From, To, etc.). Pointers will reference pkg memory. Dereferencing will crash ser!
+ * @param org_msg Original SIP message
+ * @param sip_msg_len Length of the SIP message
+ * @return Cloned SIP message, or NULL on error
+ */
struct sip_msg* sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len );
+/**
+ * @brief Indicates wheter we have already cloned the msg lumps or not
+ */
extern unsigned char lumps_are_cloned;
+/**
+ * @brief Wrapper function for msg_lump_cloner() with some additional sanity checks
+ * @param shm_msg SIP message in shared memory
+ * @param pgk_msg SIP message in private memory
+ * @return 0 on success, -1 on error
+ */
int save_msg_lumps( struct sip_msg *shm_msg, struct sip_msg *pkg_msg);
Module: sip-router
Branch: master
Commit: 56f2823ca3cba947e968a398b96395232ee21f62
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=56f2823…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Mon Jul 4 00:07:45 2011 +0200
tm: remove #ifdef POSTPONE_MSG_CLONING, its default for three years now
- remove POSTPONE_MSG_CLONING define from tm module
- its now the default for more than three years
- control flow in the module without it is better understandable
- the current way is the expected behavior, also recently discussed on the list
---
modules/tm/h_table.c | 7 -------
modules/tm/sip_msg.c | 9 ---------
modules/tm/sip_msg.h | 25 ++++++-------------------
modules/tm/t_fwd.c | 10 ++--------
modules/tm/t_suspend.c | 2 --
modules/tm/tm.c | 9 ---------
6 files changed, 8 insertions(+), 54 deletions(-)
diff --git a/modules/tm/h_table.c b/modules/tm/h_table.c
index 991435f..743fa94 100644
--- a/modules/tm/h_table.c
+++ b/modules/tm/h_table.c
@@ -369,13 +369,6 @@ struct cell* build_cell( struct sip_msg* p_msg )
}
if (p_msg) {
-#ifndef POSTPONE_MSG_CLONING
- /* it makes no sense to clean the lumps when they are not cloned (Miklos) */
-
- /* clean possible previous added vias/clen header or else they would
- * get propagated in the failure routes */
- free_via_clen_lump(&p_msg->add_rm);
-#endif
new_cell->uas.request = sip_msg_cloner(p_msg,&sip_msg_len);
if (!new_cell->uas.request)
goto error;
diff --git a/modules/tm/sip_msg.c b/modules/tm/sip_msg.c
index ab093f8..f968acd 100644
--- a/modules/tm/sip_msg.c
+++ b/modules/tm/sip_msg.c
@@ -64,29 +64,21 @@
#include "../../data_lump_rpl.h"
#include "../../ut.h"
#include "../../sip_msg_clone.h"
-
-#ifdef POSTPONE_MSG_CLONING
#include "../../fix_lumps.h"
-#endif
/* Warning: Cloner does not clone all hdr_field headers (From, To, etc.). Pointers will reference pkg memory. Dereferencing will crash ser!!! */
struct sip_msg* sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
{
-#ifdef POSTPONE_MSG_CLONING
/* take care of the lumps only for replies if the msg cloning is
postponed */
if (org_msg->first_line.type==SIP_REPLY)
-#endif /* POSTPONE_MSG_CLONING */
/*cloning all the lumps*/
return sip_msg_shm_clone(org_msg, sip_msg_len, 1);
-#ifdef POSTPONE_MSG_CLONING
/* don't clone the lumps */
return sip_msg_shm_clone(org_msg, sip_msg_len, 0);
-#endif /* POSTPONE_MSG_CLONING */
}
-#ifdef POSTPONE_MSG_CLONING
/* indicates wheter we have already cloned the msg lumps or not */
unsigned char lumps_are_cloned = 0;
@@ -144,4 +136,3 @@ int save_msg_lumps( struct sip_msg *shm_msg, struct sip_msg *pkg_msg)
}
return ret<0?-1:0;
}
-#endif /* POSTPONE_MSG_CLONING */
diff --git a/modules/tm/sip_msg.h b/modules/tm/sip_msg.h
index 0c6a6a3..f006cde 100644
--- a/modules/tm/sip_msg.h
+++ b/modules/tm/sip_msg.h
@@ -42,19 +42,15 @@
* the first time.
* Replies use only one memory block.
*/
-#define POSTPONE_MSG_CLONING
-#ifdef POSTPONE_MSG_CLONING
#include "../../atomic_ops.h" /* membar_depends() */
-#endif
-#ifdef POSTPONE_MSG_CLONING
- /* msg is a reply: one memory block was allocated
- * msg is a request: two memory blocks were allocated:
- * - one for the sip_msg struct
- * - another one for the lumps which is linked to
- * add_rm, body_lumps, or reply_lump.
- */
+/* msg is a reply: one memory block was allocated
+ * msg is a request: two memory blocks were allocated:
+ * - one for the sip_msg struct
+ * - another one for the lumps which is linked to
+ * add_rm, body_lumps, or reply_lump.
+ */
#define _sip_msg_free(_free_func, _p_msg) \
do{ \
if (_p_msg->first_line.type==SIP_REPLY) { \
@@ -72,13 +68,6 @@
} \
}while(0)
-#else /* POSTPONE_MSG_CLONING */
-
- /* only one memory block was allocated */
-#define _sip_msg_free(_free_func, _p_msg) \
- _free_func( (_p_msg) )
-
-#endif /* POSTPONE_MSG_CLONING */
#define sip_msg_free(_p_msg) _sip_msg_free(shm_free, _p_msg)
#define sip_msg_free_unsafe(_p_msg) _sip_msg_free(shm_free_unsafe, _p_msg)
@@ -86,11 +75,9 @@
struct sip_msg* sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len );
-#ifdef POSTPONE_MSG_CLONING
extern unsigned char lumps_are_cloned;
int save_msg_lumps( struct sip_msg *shm_msg, struct sip_msg *pkg_msg);
-#endif
#endif
diff --git a/modules/tm/t_fwd.c b/modules/tm/t_fwd.c
index d0e8fb9..6385812 100644
--- a/modules/tm/t_fwd.c
+++ b/modules/tm/t_fwd.c
@@ -123,9 +123,8 @@
#ifdef USE_DST_BLACKLIST
#include "../../dst_blacklist.h"
#endif
-#ifdef POSTPONE_MSG_CLONING
#include "../../atomic_ops.h" /* membar_depends() */
-#endif
+
static int goto_on_branch = 0, branch_route = 0;
@@ -231,11 +230,9 @@ static int prepare_new_uac( struct cell *t, struct sip_msg *i_req,
/* dup lumps
* TODO: clone lumps only if needed */
-#ifdef POSTPONE_MSG_CLONING
/* lumps can be set outside of the lock, make sure that we read
* the up-to-date values */
membar_depends();
-#endif
add_rm_backup = i_req->add_rm;
body_lumps_backup = i_req->body_lumps;
if (unlikely(i_req->add_rm)){
@@ -919,11 +916,9 @@ int e2e_cancel_branch( struct sip_msg *cancel_msg, struct cell *t_cancel,
/* print */
if (cfg_get(tm, tm_cfg, reparse_invite)) {
/* buffer is built localy from the INVITE which was sent out */
-#ifdef POSTPONE_MSG_CLONING
/* lumps can be set outside of the lock, make sure that we read
* the up-to-date values */
membar_depends();
-#endif
if (cancel_msg->add_rm || cancel_msg->body_lumps) {
LOG(L_WARN, "WARNING: e2e_cancel_branch: CANCEL is built locally, "
"thus lumps are not applied to the message!\n");
@@ -1461,7 +1456,6 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
branch_route = 0;
}
-#ifdef POSTPONE_MSG_CLONING
/* on first-time forwarding, update the lumps */
if (first_branch==0) {
/* update the shmem-ized msg with the lumps */
@@ -1472,7 +1466,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
return -1;
}
}
-#endif
+
/* if ruri is not already consumed (by another invocation), use current
uri too. Else add only additional branches (which may be continuously
refilled).
diff --git a/modules/tm/t_suspend.c b/modules/tm/t_suspend.c
index 19c7f32..578d6b0 100644
--- a/modules/tm/t_suspend.c
+++ b/modules/tm/t_suspend.c
@@ -82,7 +82,6 @@ int t_suspend(struct sip_msg *msg,
DBG("SER: ERROR: t_suspend (100)\n");
}
-#ifdef POSTPONE_MSG_CLONING
if ((t->nr_of_outgoings==0) && /* if there had already been
an UAC created, then the lumps were
saved as well */
@@ -92,7 +91,6 @@ int t_suspend(struct sip_msg *msg,
"failed to save the message lumps\n");
return -1;
}
-#endif
/* save the message flags */
t->uas.request->flags = msg->flags;
diff --git a/modules/tm/tm.c b/modules/tm/tm.c
index 734f093..096e30c 100644
--- a/modules/tm/tm.c
+++ b/modules/tm/tm.c
@@ -726,10 +726,7 @@ static int script_init( struct sip_msg *foo, unsigned int flags, void *bar)
/* set request mode so that multiple-mode actions know
* how to behave */
set_route_type(REQUEST_ROUTE);
-
-#ifdef POSTPONE_MSG_CLONING
lumps_are_cloned = 0;
-#endif
return 1;
}
@@ -1888,7 +1885,6 @@ static int w_t_drop_replies(struct sip_msg* msg, char* foo, char* bar)
/* save the message lumps after t_newtran() but before t_relay() */
static int w_t_save_lumps(struct sip_msg* msg, char* foo, char* bar)
{
-#ifdef POSTPONE_MSG_CLONING
struct cell *t;
if (is_route_type(REQUEST_ROUTE)) {
@@ -1905,11 +1901,6 @@ static int w_t_save_lumps(struct sip_msg* msg, char* foo, char* bar)
}
} /* else nothing to do, the lumps have already been saved */
return 1;
-#else
- LOG(L_ERR, "ERROR: w_t_save_lumps: POSTPONE_MSG_CLONING is not defined,"
- " thus, the functionality is not supported\n");
- return -1;
-#endif
}
Module: sip-router
Branch: 3.1
Commit: 57092200dbc11a61510988b7bb6939284618f5ff
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5709220…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Jun 22 11:42:30 2011 +0200
uac: more verbose debug message
- give hint of how to get rid of append_fromtag requirement on rr module
(cherry picked from commit 70ae31556b09d300f6d708b0e4edf287927748d2)
---
modules_k/uac/uac.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/modules_k/uac/uac.c b/modules_k/uac/uac.c
index 81dfe35..3152ce7 100644
--- a/modules_k/uac/uac.c
+++ b/modules_k/uac/uac.c
@@ -221,8 +221,9 @@ static int mod_init(void)
if (from_restore_mode==FROM_AUTO_RESTORE) {
/* we need the append_fromtag on in RR */
if (!uac_rrb.append_fromtag) {
- LM_ERR("'append_fromtag' RR param is not enabled!"
- " - required by AUTO restore mode\n");
+ LM_ERR("'append_fromtag' RR param is not enabled"
+ " - required by AUTO restore mode!"
+ " Or you should set from_restore_mode param to 'none'\n");
goto error;
}
/* get all requests doing loose route */