Hello List,
some months ago I reported a problem with pua_dialoginfo:
Avps declared in request route are not available anymore in branch
route, if pua_dialoginfo module is loaded.
I do not know whether there are some experiences with this problem or
not, so I looked for the reason.
pua_dialoginfo uses pua for sending PUBLISH request
pua uses tm t_request for sending PUBLISH request
t_request() is located in uac.c (tm):
- in line 411 avp list is reset
- in line 276 build_cell() is called:
build_cell() is located in h_table.c, where lines 305-323 delete avps
If I comment out the mentioned lines, which delete avps, then avps set
in request route are also available in branch route.
But I do not know, what is also affected by this change.
So would it be reasonable, to add a parameter to build_cell() for not
changing the AVP list?
Best Regards
Jasmin
Module: sip-router
Branch: master
Commit: 742ce3ae28a4d1294ce0b7f63f0bc0968bff8ea3
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=742ce3a…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 18 20:01:31 2010 +0200
kstats: cleanup - move type defs. to separate file
- moved kamailio statistics type defs to kstats_types.h (from
lib/kcore/kstats_wrapper.h). This removes core dependency on
lib/kcore include files (the statistics types are needed for the
kamailio module interface defs).
- removed statistics.h (it is obsolete, counters.h should be used
instead and if somebody really needs it, it should include
lib/kcore/kstats_wrapper.h or lib/kcore/statistics.h).
---
kstats_types.h | 69 ++++++++++++++++++++++++++++++++++++++++++++
lib/kcore/kstats_wrapper.h | 27 ++---------------
sr_module.h | 2 +-
statistics.h | 33 ---------------------
4 files changed, 73 insertions(+), 58 deletions(-)
diff --git a/kstats_types.h b/kstats_types.h
new file mode 100644
index 0000000..b8d1629
--- /dev/null
+++ b/kstats_types.h
@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 iptelorg GmbH
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/** kamailio statistics types.
+ * This file contains type declaration for kamailio statistics.
+ * They are needed when modules are loaded (sr_module.c).
+ * The rest of kamailio stats are in lib/kcore (include
+ * lib/kcore/kstats_wrapper.h or lib/kcore/statistics.h and link with
+ * libkcore).
+ * Note: kamailio statistics are obsolete. Use sr counters in new code
+ * (counters.h).
+ * @file kstats_types.h
+ * @ingroup: core
+ */
+/*
+ * History:
+ * --------
+ * 2010-08-18 initial version (andrei)
+*/
+
+#ifndef __kstats_types_h
+#define __kstats_types_h
+
+#include "counters.h"
+
+/* types */
+
+typedef counter_val_t stat_val;
+/* stat_var is always used as a pointer in k, we missuse
+ stat_var* for holding out counter id */
+typedef void stat_var;
+/* get val callback
+ * TODO: change it to counter_cbk_f compatible callback?
+ */
+typedef counter_val_t (*stat_function)(void);
+
+/* statistic module interface */
+struct stat_export_s {
+ char* name;
+ int flags;
+ stat_var** stat_pointer; /* pointer to the memory location
+ (where a counter handle will be stored)
+ Note: it's a double pointer because of
+ the original k version which needed it
+ allocated in shm. This version
+ will store the counter id at *stat_pointer.
+ */
+};
+
+typedef struct stat_export_s stat_export_t;
+
+
+#endif /*__kstats_types_h*/
+
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
diff --git a/lib/kcore/kstats_wrapper.h b/lib/kcore/kstats_wrapper.h
index 1d6ba47..1c9559b 100644
--- a/lib/kcore/kstats_wrapper.h
+++ b/lib/kcore/kstats_wrapper.h
@@ -35,12 +35,15 @@
* History:
* --------
* 2010-08-08 initial version (andrei)
+ * 2010-08-18 type declaration needed by sr_module.c moved to
+ * ../../kstats_types.h (andrei)
*/
#ifndef __kstats_wrapper_h
#define __kstats_wrapper_h
#include "../../counters.h"
+#include "../../kstats_types.h"
/* k stat flags */
#define STAT_NO_RESET 1 /* used in dialog(k), nat_traversal(k),
@@ -49,31 +52,7 @@
#define STAT_SHM_NAME 4 /* used only from usrloc(k) */
#define STAT_IS_FUNC 8
-/* types */
-typedef counter_val_t stat_val;
-/* stat_var is always used as a pointer in k, we missuse
- stat_var* for holding out counter id */
-typedef void stat_var;
-/* get val callback
- * TODO: change it to counter_cbk_f compatible callback?
- */
-typedef counter_val_t (*stat_function)(void);
-
-/* statistic module interface */
-struct stat_export_s {
- char* name;
- int flags;
- stat_var** stat_pointer; /* pointer to the memory location
- (where a counter handle will be stored)
- Note: it's a double pointer because of
- the original k version which needed it
- allocated in shm. This version
- will store the counter id at *stat_pointer.
- */
-};
-
-typedef struct stat_export_s stat_export_t;
#ifdef STATISTICS
diff --git a/sr_module.h b/sr_module.h
index baf1081..4d32514 100644
--- a/sr_module.h
+++ b/sr_module.h
@@ -68,7 +68,7 @@
#include "str.h"
/* kamailio compat */
-#include "statistics.h"
+#include "kstats_types.h"
#include "mi/mi_types.h"
#include "pvar.h"
diff --git a/statistics.h b/statistics.h
deleted file mode 100644
index e9e430a..0000000
--- a/statistics.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2008 iptelorg GmbH
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * statistics compatibility wrapper for kamailio
- * for now it doesn't do anything
- * (obsolete, do not use anymore)
- *
- * History:
- * --------
- * 2008-11-17 initial version compatible with kamailio statistics.h (andrei)
- */
-
-#ifndef _STATISTICS_H_
-#define _STATISTICS_H_
-
-#include "lib/kcore/statistics.h"
-
-#endif /* _STATISTICS_H_ */
Module: sip-router
Branch: master
Commit: 627a1969b49446360f227fe23c56b80683145e5f
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=627a196…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 18 19:54:09 2010 +0200
mi: cleanup - move type defs. to separate file
Moved MI types defs to mi/mi_types.h (from lib/kmi/mi.h).
This removes core dependency on lib/mi include files
(mi types are needed for kamailio module interface defs).
---
lib/kmi/mi.h | 16 +----------
lib/kmi/tree.h | 18 ++----------
mi/mi.h | 35 ------------------------
mi/mi_types.h | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sr_module.h | 2 +-
5 files changed, 86 insertions(+), 65 deletions(-)
diff --git a/lib/kmi/mi.h b/lib/kmi/mi.h
index 5c0ac19..988bcd1 100644
--- a/lib/kmi/mi.h
+++ b/lib/kmi/mi.h
@@ -23,6 +23,7 @@
* History:
* ---------
* 2006-09-08 first version (bogdan)
+ * 2010-08-18 use mi types from ../../mi/mi_types.h (andrei)
*/
/*!
@@ -36,6 +37,7 @@
#define _MI_MI_H_
#include "../../str.h"
+#include "../../mi/mi_types.h"
#include "tree.h"
#define MI_ASYNC_RPL_FLAG (1<<0)
@@ -43,11 +45,6 @@
#define MI_ROOT_ASYNC_RPL ((struct mi_root*)-1)
-struct mi_handler;
-
-typedef struct mi_root* (mi_cmd_f)(struct mi_root*, void *param);
-typedef int (mi_child_init_f)(void);
-typedef void (mi_handler_f)(struct mi_root *, struct mi_handler *, int);
struct mi_handler {
@@ -66,15 +63,6 @@ struct mi_cmd {
};
-typedef struct mi_export_ {
- char *name;
- mi_cmd_f *cmd;
- unsigned int flags;
- void *param;
- mi_child_init_f *init_f;
-}mi_export_t;
-
-
int register_mi_cmd( mi_cmd_f f, char *name, void *param,
mi_child_init_f in, unsigned int flags);
diff --git a/lib/kmi/tree.h b/lib/kmi/tree.h
index 4a42823..ef6e657 100644
--- a/lib/kmi/tree.h
+++ b/lib/kmi/tree.h
@@ -23,6 +23,7 @@
* History:
* ---------
* 2006-09-08 first version (bogdan)
+ * 2010-08-18 use mi types from ../../mi/mi_types.h (andrei)
*/
/*!
@@ -39,6 +40,7 @@
#include <stdarg.h>
#include "../../str.h"
+#include "../../mi/mi_types.h"
struct mi_node;
struct mi_handler;
@@ -63,21 +65,7 @@ struct mi_handler;
#define MI_MISSING_PARM MI_MISSING_PARM_S
#define MI_BAD_PARM MI_BAD_PARM_S
-struct mi_node {
- str value;
- str name;
- struct mi_node *kids;
- struct mi_node *next;
- struct mi_node *last;
- struct mi_attr *attributes;
-};
-
-struct mi_root {
- unsigned int code;
- str reason;
- struct mi_handler *async_hdl;
- struct mi_node node;
-};
+
struct mi_root *init_mi_tree(unsigned int code, char *reason, int reason_len);
diff --git a/mi/mi.h b/mi/mi.h
deleted file mode 100644
index b3c106f..0000000
--- a/mi/mi.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2008 iptelorg GmbH
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * mi compatibility wrapper for kamailio
- * for now it doesn't do anything, it just a compile helper
- * (obsolete, do not use anymore)
- *
- * History:
- * --------
- * 2008-11-17 initial version compatible with kamailio mi/mi.h (andrei)
- */
-
-#ifndef _mi_h_
-#define _mi_h_
-
-#include "../lib/kmi/mi.h"
-
-#endif /* _mi_h_ */
-
-
diff --git a/mi/mi_types.h b/mi/mi_types.h
new file mode 100644
index 0000000..4da303c
--- /dev/null
+++ b/mi/mi_types.h
@@ -0,0 +1,80 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2008 iptelorg GmbH
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * mi compatibility wrapper for kamailio
+ * It contains only the type definition, needed for loading kamilio modules
+ * (used by sr_module.c).
+ * Note that MI usage in new modules is opsolete. They should implement RPCs
+ * instead. To use MI include lib/kmi/mi.h and link with lib kmi.
+ *
+ * History:
+ * --------
+ * 2008-11-17 initial version compatible with kamailio mi/mi.h (andrei)
+ * 2010-08-18 remove everything but the data types definition (andrei)
+ */
+
+#ifndef _mi_h_
+#define _mi_h_
+
+#include "../str.h"
+
+struct mi_node {
+ str value;
+ str name;
+ struct mi_node *kids;
+ struct mi_node *next;
+ struct mi_node *last;
+ struct mi_attr *attributes;
+};
+
+
+struct mi_handler;
+
+struct mi_root {
+ unsigned int code;
+ str reason;
+ struct mi_handler *async_hdl;
+ struct mi_node node;
+};
+
+typedef struct mi_root* (mi_cmd_f)(struct mi_root*, void *param);
+typedef int (mi_child_init_f)(void);
+typedef void (mi_handler_f)(struct mi_root *, struct mi_handler *, int);
+
+/* FIXME
+struct mi_handler {
+ mi_handler_f *handler_f;
+ void * param;
+};
+*/
+
+
+struct mi_export_ {
+ char *name;
+ mi_cmd_f *cmd;
+ unsigned int flags;
+ void *param;
+ mi_child_init_f *init_f;
+};
+
+typedef struct mi_export_ mi_export_t;
+
+
+#endif /* _mi_h_ */
+
+
diff --git a/sr_module.h b/sr_module.h
index 1940a96..baf1081 100644
--- a/sr_module.h
+++ b/sr_module.h
@@ -69,7 +69,7 @@
/* kamailio compat */
#include "statistics.h"
-#include "mi/mi.h"
+#include "mi/mi_types.h"
#include "pvar.h"
Module: sip-router
Branch: master
Commit: 96e1bc629bc7ed78dd64b221bc54b266cd45e3ca
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=96e1bc6…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 18 18:39:43 2010 +0200
tm: don't reply if the reply dest. is not yet set
- relay_reply() doesn't attempt to send the reply if the reply
destination is not yet fully set. This can happen for example
if reply_to_via is set, Via contains a host name (and not an ip)
and before having a chance to resolve the name a reply must be
sent (reply for a message that hasn't been sent yet: very
unlikely, but possible).
- use a membar_write() in init_rb(), before setting the reply send
socket (the reply send socket is also used as a flag for a fully
initialized reply destination and the membar_write() makes sure
that everything else was written before the send socket and no
re-ordering will take place).
---
modules/tm/t_lookup.c | 17 ++---------------
modules/tm/t_reply.c | 8 +++++---
2 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/modules/tm/t_lookup.c b/modules/tm/t_lookup.c
index b0ddfa6..e69fdec 100644
--- a/modules/tm/t_lookup.c
+++ b/modules/tm/t_lookup.c
@@ -1196,7 +1196,6 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
/*struct socket_info* send_sock;*/
struct via_body* via;
int proto;
- int backup_mhomed;
/* rb. timers are init. init_t()/new_cell() */
via=msg->via1;
@@ -1220,20 +1219,8 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
rb->dst.comp=via->comp_no;
#endif
rb->dst.send_flags=msg->rpl_send_flags;
- /* turn off mhomed for generating replies -- they are ideally sent to where
- request came from to make life with NATs and other beasts easier
- */
- backup_mhomed=mhomed;
- mhomed=0;
- mhomed=backup_mhomed;
- /* use for sending replies the incoming interface of the request -bogdan */
- /*send_sock=get_send_socket(msg, &rb->dst.to, proto);
- if (send_sock==0) {
- LOG(L_ERR, "ERROR: init_rb: cannot fwd to af %d, proto %d "
- "no socket\n", rb->dst.to.s.sa_family, proto);
- ser_error=E_BAD_VIA;
- return 0;
- }*/
+
+ membar_write();
rb->dst.send_sock=msg->rcv.bind_address;
return 1;
}
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index df372e1..1a90844 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -637,7 +637,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
If reply_to_via is set and via contains a host name (and not an ip)
the chances for this increase a lot.
*/
- if (!trans->uas.response.dst.send_sock) {
+ if (unlikely(!trans->uas.response.dst.send_sock)) {
LOG(L_ERR, "ERROR: _reply_light: no resolved dst to send reply to\n");
} else {
if (likely(SEND_PR_BUFFER( rb, buf, len )>=0)){
@@ -1786,7 +1786,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
if (reply_status == RPS_COMPLETED) {
start_final_repl_retr(t);
}
- if (SEND_PR_BUFFER( uas_rb, buf, res_len )>=0){
+ if (likely(uas_rb->dst.send_sock &&
+ SEND_PR_BUFFER( uas_rb, buf, res_len ) >= 0)){
if (unlikely(!totag_retr && has_tran_tmcbs(t, TMCB_RESPONSE_OUT))){
run_trans_callbacks( TMCB_RESPONSE_OUT, t, t->uas.request,
relayed_msg, relayed_code);
@@ -1801,7 +1802,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
run_onsend_callbacks2(TMCB_RESPONSE_SENT, t, &onsend_params);
}
#endif
- }
+ } else if (unlikely(uas_rb->dst.send_sock == 0))
+ ERR("no resolved dst to send reply to\n");
/* Call put_on_wait() only if we really send out
* the reply. It can happen that the reply has been already sent from
* failure_route or from a callback and the timer has been already
Module: sip-router
Branch: master
Commit: 66cda7bc5f642ce892124cfb35f1e5effd78e9d6
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=66cda7b…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 18 18:36:14 2010 +0200
tcp: fix double increment for the established stats
The counter/stats for established TCP connections were incremented
twice in the case of accept()-ed connections: once immediately
after the accept() and another time after the first packet
received or sent on the connection.
Now they are incremented only after the first successful send or
receive.
---
tcp_main.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/tcp_main.c b/tcp_main.c
index a1761f6..31fc0fa 100644
--- a/tcp_main.c
+++ b/tcp_main.c
@@ -3973,7 +3973,15 @@ static inline int handle_new_connect(struct socket_info* si)
return 1; /* success, because the accept was succesfull */
}
(*tcp_connections_no)++;
- TCP_STATS_ESTABLISHED(S_CONN_ACCEPT);
+ /* stats for established connections are incremented after
+ the first received or sent packet.
+ Alternatively they could be incremented here for accepted
+ connections, but then the connection state must be changed to
+ S_CONN_OK:
+ TCP_STATS_ESTABLISHED(S_CONN_ACCEPT);
+ ...
+ tcpconn=tcpconn_new(new_sock, &su, dst_su, si, si->proto, S_CONN_OK);
+ */
dst_su=&si->su;
if (unlikely(si->flags & SI_IS_ANY)){