Hi, using the lates 1.5 revision I've realized that when calling a NAT
registered user, the RURI domain is set to the real domain used in the
user REGISTER (this is, a private address).
I remember some threads asking this feature long time ago since then
Kamailio sets the "received" address in the RURI after "loockup".
When has been it fixes/improved? :)
--
Iñaki Baz Castillo
<ibc(a)aliax.net>
Bugs item #2791122, was opened at 2009-05-13 13:07
Message generated for change (Comment added) made by effeks
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2791122&group_…
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: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Tobias Lindgren (effeks)
Assigned to: Nobody/Anonymous (nobody)
Summary: fr_inv_timer_avp on amd64
Initial Comment:
Hi!
When we compile kamailio 1.5.1 trunk on Debian Linux amd64 the fr_inv_time_avp timer cannot altered (the value of the AVP-variable has no effect on the timer) and seem stuck on something like 15 seconds. Compiling the same code in a 32bit chroot works fine, aswell as on any other standard 32bit system, where the timer is set to the value of the AVP as expected.
/effeks
----------------------------------------------------------------------
>Comment By: Tobias Lindgren (effeks)
Date: 2009-09-16 00:42
Message:
Hi, did you have a chance to look at the debugs?
----------------------------------------------------------------------
Comment By: Tobias Lindgren (effeks)
Date: 2009-06-17 16:04
Message:
Sent debugs to your email.
----------------------------------------------------------------------
Comment By: Daniel-Constantin Mierla (miconda)
Date: 2009-06-10 13:23
Message:
I did several tests and the timeout was ok. Here are my parameters:
modparam("tm", "fr_timer", 15)
modparam("tm", "fr_inv_timer", 60)
modparam("tm", "wt_timer", 5)
modparam("tm", "fr_inv_timer_avp", "$avp(i:120)")
$avp(i:120) = 30;
Can you get a ngrep trace and send it to me at: <miconda [at] gmail.com>?
Thanks.
----------------------------------------------------------------------
Comment By: Tobias Lindgren (effeks)
Date: 2009-06-05 13:23
Message:
Any news?
----------------------------------------------------------------------
Comment By: Tobias Lindgren (effeks)
Date: 2009-05-25 13:50
Message:
The avp-value was a string, but changing it into an integer makes no
difference. On 32bit it works regardless of int or str.
----------------------------------------------------------------------
Comment By: Daniel-Constantin Mierla (miconda)
Date: 2009-05-25 11:49
Message:
Did you check my last message? Is the timer avp integer or string value?
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2009-05-25 11:47
Message:
Any progress on this?
----------------------------------------------------------------------
Comment By: Daniel-Constantin Mierla (miconda)
Date: 2009-05-22 19:12
Message:
Just saw in your last comment that you assign a string to the avp:
$avp(i:10) = "25";
Should be:
$avp(i:10) = 25;
Can you doublecheck?
----------------------------------------------------------------------
Comment By: Daniel-Constantin Mierla (miconda)
Date: 2009-05-19 09:25
Message:
OK, i am going to check the log. thanks.
----------------------------------------------------------------------
Comment By: Tobias Lindgren (effeks)
Date: 2009-05-15 13:23
Message:
Done, the config snippet looks something like this:
modparam("tm", "fr_inv_timer_avp", "$avp(i:10)")
$avp(i:10) = "25";
t_relay();
----------------------------------------------------------------------
Comment By: Daniel-Constantin Mierla (miconda)
Date: 2009-05-15 12:07
Message:
Can you run with debug=5 and attach the syslog output here?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2791122&group_…
Module: sip-router
Branch: andrei/path
Commit: 3c7744da21a2c2cb82dfdfc28f43f65e139b91cf
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3c7744d…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Sep 14 13:32:08 2009 +0200
core: add path route headers after local via
- minor header order fix: route header generated from recorded
path are added after the local via if no other route headers are
present in the message (they were added in front of the local
via until now).
---
msg_translator.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/msg_translator.c b/msg_translator.c
index 42c1cf1..2958fc5 100644
--- a/msg_translator.c
+++ b/msg_translator.c
@@ -1563,6 +1563,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
new_buf=0;
received_buf=0;
rport_buf=0;
+ via_anchor=0;
line_buf=0;
via_len=0;
path_buf.s=0;
@@ -1584,8 +1585,10 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
branch.s=msg->add_to_branch_s;
branch.len=msg->add_to_branch_len;
+ via_anchor=anchor_lump(msg, msg->via1->hdr.s-buf, 0, HDR_VIA_T);
+ if (unlikely(via_anchor==0)) goto error00;
line_buf = create_via_hf( &via_len, msg, send_info, &branch);
- if (!line_buf){
+ if (unlikely(!line_buf)){
LOG(L_ERR,"ERROR: build_req_buf_from_sip_req: "
"memory allocation failure\n");
goto error00;
@@ -1684,10 +1687,13 @@ after_update_via1:
memcpy(path_buf.s+ROUTE_PREFIX_LEN+msg->path_vec.len, CRLF, CRLF_LEN);
path_buf.s[path_buf.len]=0;
/* insert Route header either before the other routes
- (if present & parsed) or after the local via */
+ (if present & parsed), after the local via or after in front of
+ the first via if we don't add a local via*/
if (msg->route){
path_anchor=anchor_lump(msg, msg->route->name.s-buf, 0,
HDR_ROUTE_T);
+ }else if (likely(via_anchor)){
+ path_anchor=via_anchor;
}else if (likely(msg->via1)){
path_anchor=anchor_lump(msg, msg->via1->hdr.s-buf, 0,
HDR_ROUTE_T);
@@ -1755,8 +1761,6 @@ after_update_via1:
/* try to add it before msg. 1st via */
/* add first via, as an anchor for second via*/
if(likely(line_buf)) {
- via_anchor=anchor_lump(msg, msg->via1->hdr.s-buf, 0, HDR_VIA_T);
- if (via_anchor==0) goto error04;
if ((via_lump=insert_new_lump_before(via_anchor, line_buf, via_len,
HDR_VIA_T))==0)
goto error04;
Module: sip-router
Branch: andrei/send_flags
Commit: 67c9277aaa07fb6b8c91fc38e761d30426ded8b5
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=67c9277…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Sep 15 17:38:06 2009 +0200
core: send flags support
Added support for send flags and per message send flags.
Right now there are 2 flags defined:
- SND_F_FORCE_CON_REUSE (forces connection reuse, send will fail if
a connection does not already exist to the destination)
- SND_F_CON_CLOSE (hint that after the send completes the
connection should be closed).
The send flags can be passed directly to msg_send() via
dest_info.send_flags or they can be set for each sip_msg, in which
case forward_request() and forward_reply() will obey them.
The sip_msg flags can be set for replies or for forwarding.
---
forward.c | 15 ++++++++++-----
ip_addr.h | 9 +++++++++
parser/msg_parser.h | 2 ++
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/forward.c b/forward.c
index dea7584..d7fb827 100644
--- a/forward.c
+++ b/forward.c
@@ -384,9 +384,12 @@ int check_self_port(unsigned short port, unsigned short proto)
* default port or non srv. lookup is desired, the port must
* be !=0
* port - used only if dst!=0 (else the port in send_info->to is used)
- * send_info - filled dest_info structure:
- * if the send_socket member is null, a send_socket will be
- * chosen automatically
+ * send_info - value/result partially filled dest_info structure:
+ * - send_info->proto and comp are used
+ * - send_info->to will be filled (dns)
+ * - send_info->send_flags is filled from the message
+ * - if the send_socket member is null, a send_socket will be
+ * chosen automatically
* WARNING: don't forget to zero-fill all the unused members (a non-zero
* random id along with proto==PROTO_TCP can have bad consequences, same for
* a bogus send_socket value)
@@ -438,13 +441,14 @@ int forward_request(struct sip_msg* msg, str* dst, unsigned short port,
goto error;
}
}/* dst */
+ send_info->send_flags=msg->fwd_send_flags;
/* calculate branch for outbound request; if syn_branch is turned off,
calculate is from transaction key, i.e., as an md5 of From/To/CallID/
CSeq exactly the same way as TM does; good for reboot -- than messages
belonging to transaction lost due to reboot will still be forwarded
with the same branch parameter and will be match-able downstream
-
- if it is turned on, we don't care about reboot; we simply put a simple
+
+ if it is turned on, we don't care about reboot; we simply put a simple
value in there; better for performance
*/
if (syn_branch ) {
@@ -694,6 +698,7 @@ int forward_reply(struct sip_msg* msg)
}
dst.proto=msg->via2->proto;
+ dst.send_flags=msg->fwd_send_flags | msg->rpl_send_flags;
if (update_sock_struct_from_via( &dst.to, msg, msg->via2 )==-1) goto error;
#ifdef USE_COMP
dst.comp=msg->via2->comp_no;
diff --git a/ip_addr.h b/ip_addr.h
index 50bcbe4..355fc77 100644
--- a/ip_addr.h
+++ b/ip_addr.h
@@ -34,6 +34,7 @@
* 2006-04-21 added init_dst_from_rcv (andrei)
* 2007-06-26 added ip_addr_mk_any() (andrei)
* 2008-05-21 added su2a(), ip_addr2sbuf(), ip4tosbuf(), ip62sbuf() (andrei)
+ * 2009-09-14 added send flags support to dest_info (andrei)
*/
#ifndef ip_addr_h
@@ -136,11 +137,18 @@ struct receive_info{
};
+/* send flags */
+#define SND_F_FORCE_CON_REUSE 1 /* reuse an existing connection or fail */
+#define SND_F_CON_CLOSE 2 /* close the connection after sending */
+
+typedef unsigned char snd_flags_t;
+
struct dest_info{
struct socket_info* send_sock;
union sockaddr_union to;
int id; /* tcp stores the connection id here */
char proto;
+ snd_flags_t send_flags;
#ifdef USE_COMP
short comp;
#endif
@@ -748,6 +756,7 @@ inline static void init_dst_from_rcv(struct dest_info* dst,
dst->to=rcv->src_su;
dst->id=rcv->proto_reserved1;
dst->proto=rcv->proto;
+ dst->send_flags=0;
#ifdef USE_COMP
dst->comp=rcv->comp;
#endif
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index 1ce00bb..22b3167 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -246,6 +246,8 @@ typedef struct msg_body {
typedef struct sip_msg {
unsigned int id; /* message id, unique/process*/
+ snd_flags_t fwd_send_flags; /* send flags for forwarding */
+ snd_flags_t rpl_send_flags; /* send flags for replies */
struct msg_start first_line; /* Message first line */
struct via_body* via1; /* The first via */
struct via_body* via2; /* The second via */
Module: sip-router
Branch: andrei/send_flags
Commit: 340ce466abb2938ba9db1d3cb1d8b10819c1e2aa
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=340ce46…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Sep 15 17:45:41 2009 +0200
tcp: send_flags support
Support for SND_F_FORCE_CON_REUSE and SND_F_CON_CLOSE added to the
tcp code.
---
tcp_conn.h | 7 ++++-
tcp_main.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++------------
2 files changed, 74 insertions(+), 18 deletions(-)
diff --git a/tcp_conn.h b/tcp_conn.h
index 9db6308..5338734 100644
--- a/tcp_conn.h
+++ b/tcp_conn.h
@@ -170,7 +170,8 @@ struct tcp_connection{
struct tcp_req req; /* request data */
atomic_t refcnt;
enum sip_protos type; /* PROTO_TCP or a protocol over it, e.g. TLS */
- int flags; /* connection related flags */
+ unsigned short flags; /* connection related flags */
+ unsigned short send_flags; /* special send flags */
enum tcp_conn_states state; /* connection state */
void* extra_data; /* extra data associated to the connection, 0 for tcp*/
struct timer_ln timer;
@@ -190,6 +191,10 @@ struct tcp_connection{
/* helper macros */
+#define tcpconn_set_send_flags(c, snd_flags) ((c)->send_flags|=(snd_flags))
+
+#define tcpconn_close_after_send(c) ((c)->send_flags & SND_F_CON_CLOSE)
+
#define TCP_RCV_INFO(c) (&(c)->rcv)
#define TCP_RCV_LADDR(r) (&((r).dst_ip))
diff --git a/tcp_main.c b/tcp_main.c
index c238b2e..a72e3cc 100644
--- a/tcp_main.c
+++ b/tcp_main.c
@@ -100,7 +100,9 @@
* 2009-02-26 direct blacklist support (andrei)
* 2009-03-20 s/wq_timeout/send_timeout ; send_timeout is now in ticks
* (andrei)
- * 2009-04-09 tcp ev and tcp stats macros added (andrei)
+ * 2009-04-09 tcp ev and tcp stats macros added (andrei)
+ * 2009-09-15 support for force connection reuse and close after send
+ * send flags (andrei)
*/
@@ -1762,18 +1764,24 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
if (likely(port)){
/* try again w/o id */
c=tcpconn_get(0, &ip, port, from, con_lifetime);
- goto no_id;
}else{
LOG(L_ERR, "ERROR: tcp_send: id %d not found, dropping\n",
dst->id);
return -1;
}
- }else goto get_fd;
+ }
}
-no_id:
- if (unlikely(c==0)){
+/* no_id: */
+ if (unlikely((c==0) || tcpconn_close_after_send(c))){
+ if (unlikely(c)){
+ /* can't use c if it's marked as close-after-send =>
+ release it and try opening new one */
+ tcpconn_chld_put(c); /* release c (dec refcnt & free on 0) */
+ c=0;
+ }
/* check if connect() is disabled */
- if (cfg_get(tcp, tcp_cfg, no_connect))
+ if (unlikely((dst->send_flags & SND_F_FORCE_CON_REUSE) ||
+ cfg_get(tcp, tcp_cfg, no_connect)))
return -1;
DBG("tcp_send: no open tcp connection found, opening new one\n");
/* create tcp connection */
@@ -1814,6 +1822,7 @@ no_id:
return -1;
}
c->flags|=F_CONN_PENDING|F_CONN_FD_CLOSED;
+ tcpconn_set_send_flags(c, dst->send_flags);
atomic_set(&c->refcnt, 2); /* ref from here and from main hash
table */
/* add it to id hash and aliases */
@@ -1918,6 +1927,14 @@ no_id:
}
LOG(L_INFO, "tcp_send: quick connect for %p\n", c);
TCP_STATS_ESTABLISHED(S_CONN_CONNECT);
+ if (unlikely(dst->send_flags & SND_F_CON_CLOSE)){
+ /* if close-after-send requested, don't bother
+ sending the fd back to tcp_main, try closing it
+ immediately (no other tcp_send should use it,
+ because it is marked as close-after-send before
+ being added to the hash */
+ goto conn_wait_close;
+ }
c->state=S_CONN_OK;
/* send to tcp_main */
response[0]=(long)c;
@@ -1938,6 +1955,7 @@ no_id:
su2a(&dst->to, sizeof(dst->to)));
return -1;
}
+ tcpconn_set_send_flags(c, dst->send_flags);
if (likely(c->state==S_CONN_OK))
TCP_STATS_ESTABLISHED(S_CONN_CONNECT);
atomic_set(&c->refcnt, 2); /* ref. from here and it will also
@@ -1962,7 +1980,7 @@ no_id:
}
goto send_it;
}
-get_fd:
+/* get_fd: */
#ifdef TCP_ASYNC
/* if data is already queued, we don't need the fd any more */
if (unlikely(cfg_get(tcp, tcp_cfg, async) &&
@@ -2048,6 +2066,8 @@ get_fd:
send_it:
DBG("tcp_send: sending...\n");
lock_get(&c->write_lock);
+ /* update connection send flags with the current ones */
+ tcpconn_set_send_flags(c, dst->send_flags);
#ifdef TCP_ASYNC
if (likely(cfg_get(tcp, tcp_cfg, async))){
if (_wbufq_non_empty(c)
@@ -2203,6 +2223,31 @@ error:
TCP_STATS_ESTABLISHED(c->state);
c->state=S_CONN_OK;
}
+ if (unlikely(dst->send_flags & SND_F_CON_CLOSE)){
+ /* close after write => send EOF request to tcp_main */
+ c->state=S_CONN_BAD;
+ c->timeout=get_ticks_raw();
+ /* tell "main" it should drop this*/
+ response[0]=(long)c;
+ response[1]=CONN_EOF;
+ if (send_all(unix_tcp_sock, response, sizeof(response))<=0){
+ LOG(L_CRIT, "BUG: tcp_send: error return failed (write):%s (%d)\n",
+ strerror(errno), errno);
+ tcpconn_chld_put(c); /* deref. it manually */
+ n=-1;
+ }
+ /* CONN_EOF will auto-dec refcnt => we must not call tcpconn_put
+ * if it succeeds */
+#ifdef TCP_FD_CACHE
+ if (unlikely(fd_cache_e)){
+ tcp_fd_cache_rm(fd_cache_e);
+ fd_cache_e=0;
+ close(fd);
+ }else
+#endif /* TCP_FD_CACHE */
+ if (do_close_fd) close(fd);
+ goto end_no_conn;
+ }
end:
#ifdef TCP_FD_CACHE
if (unlikely((fd_cache_e==0) && use_fd_cache)){
@@ -2216,11 +2261,14 @@ end_no_conn:
return n;
#ifdef TCP_CONNECT_WAIT
conn_wait_error:
- /* connect or send failed on newly created connection which was not
- * yet sent to tcp_main (but was already hashed) => don't send to main,
- * unhash and destroy directly (if refcnt>2 it will be destroyed when the
- * last sender releases the connection (tcpconn_chld_put(c))) or when
- * tcp_main receives a CONN_ERROR it*/
+ n=-1;
+conn_wait_close:
+ /* connect or send failed or immediate close-after-send was requested on
+ * newly created connection which was not yet sent to tcp_main (but was
+ * already hashed) => don't send to main, unhash and destroy directly
+ * (if refcnt>2 it will be destroyed when the last sender releases the
+ * connection (tcpconn_chld_put(c))) or when tcp_main receives a
+ * CONN_ERROR it*/
c->state=S_CONN_BAD;
TCPCONN_LOCK;
if (c->flags & F_CONN_HASHED){
@@ -2234,7 +2282,7 @@ conn_wait_error:
TCPCONN_UNLOCK;
/* dec refcnt -> mark it for destruction */
tcpconn_chld_put(c);
- return -1;
+ return n;
#endif /* TCP_CONNET_WAIT */
}
@@ -3025,11 +3073,12 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
LOG(L_ERR, "handle_ser_child: ERROR: received CON_ERROR for %p"
" (id %d), refcnt %d\n",
tcpconn, tcpconn->id, atomic_get(&tcpconn->refcnt));
+ case CONN_EOF: /* forced EOF after full send, due to send flags */
#ifdef TCP_CONNECT_WAIT
/* if the connection is pending => it might be on the way of
* reaching tcp_main (e.g. CONN_NEW_COMPLETE or
* CONN_NEW_PENDING_WRITE) => it cannot be destroyed here */
- if ( !(tcpconn->flags & F_CONN_PENDING) &&
+ if ( !(tcpconn->flags & F_CONN_PENDING) &&
tcpconn_try_unhash(tcpconn) )
tcpconn_put(tcpconn);
#else /* ! TCP_CONNECT_WAIT */
@@ -3155,7 +3204,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i)
}
}
}else{
- LOG(L_WARN, "tcp_main: hanlder_ser_child: connection %p"
+ LOG(L_WARN, "tcp_main: handler_ser_child: connection %p"
" already watched for write\n", tcpconn);
}
break;
@@ -3466,8 +3515,10 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
empty_q=0; /* warning fix */
if (unlikely((ev & (POLLOUT|POLLERR|POLLHUP)) &&
(tcpconn->flags & F_CONN_WRITE_W))){
- if (unlikely((ev & (POLLERR|POLLHUP)) ||
- (wbufq_run(tcpconn->s, tcpconn, &empty_q)<0))){
+ if (unlikely((ev & (POLLERR|POLLHUP)) ||
+ (wbufq_run(tcpconn->s, tcpconn, &empty_q)<0) ||
+ (empty_q && tcpconn_close_after_send(tcpconn))
+ )){
if (unlikely(io_watch_del(&io_h, tcpconn->s, fd_i, 0)<0)){
LOG(L_ERR, "ERROR: handle_tcpconn_ev: io_watch_del(1) failed:"
" for %p, fd %d\n", tcpconn, tcpconn->s);
Module: sip-router
Branch: andrei/send_flags
Commit: 51205ff5d47a04a8a4f89ac18b45b3c05f02ec1f
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=51205ff…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Sep 15 17:51:40 2009 +0200
NEWS: update
---
NEWS | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/NEWS b/NEWS
index 9eb07b6..3cec56d 100644
--- a/NEWS
+++ b/NEWS
@@ -62,13 +62,30 @@ config script changes:
- support for kamailio style pvars
- C-like switch()/case (integer only)
- while()
+ - include file support: include_file "somefile"
+ - event route support: event_route[module_name:eventid]
+
build system:
- multiple modules directories are now supported (defined in Makefile.dirs)
new config variables:
- max_while_loops - maximum iterations allowed for a while (can be changed
at runtime). Default 100.
+ - log_name - set the application name used when printing to syslog.
+new script commands:
+ add_local_rport() - adds the rport parameter to the added via header
+ (rfc3581).
+ set_forward_no_connect() - the message will be forwarded only if there is
+ already an existing connection to the destination (it applies only to
+ connection oriented protocols like tcp, tls and in the future sctp).
+ set_reply_no_connect() - like set_forward_no_connect(), but works for
+ replies to the current message.
+ set_forward_close() - try to close the connection after forwarding the
+ current message (it applies only when the underlying protocol is
+ connection oriented).
+ set_reply_close() - like set_forward_close(), but it works for replies to
+ the current message.
Module: sip-router
Branch: andrei/send_flags
Commit: bf0a0d42e810f6f8c3999b7f3f2b668ae0bad1d6
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bf0a0d4…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Sep 15 17:43:24 2009 +0200
tm: support for send_flags
The send_flags are taken from the current message and added to the
retr_bufs (for branch uacs and replies).
---
modules/tm/t_fwd.c | 9 ++++++---
modules/tm/t_lookup.c | 1 +
modules/tm/uac.c | 6 +++---
modules/tm/ut.h | 17 ++++++++++++-----
4 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/modules/tm/t_fwd.c b/modules/tm/t_fwd.c
index bb0cf61..5f5cb42 100644
--- a/modules/tm/t_fwd.c
+++ b/modules/tm/t_fwd.c
@@ -413,6 +413,8 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri, str* next_hop,
t->uac[branch].request.dst.send_sock =
get_send_socket( request, &t->uac[branch].request.dst.to,
t->uac[branch].request.dst.proto);
+ t->uac[branch].request.dst.send_flags=request?
+ request->fwd_send_flags:0;
}else {
#ifdef USE_DNS_FAILOVER
if (uri2dst(&t->uac[branch].dns_h, &t->uac[branch].request.dst,
@@ -1083,15 +1085,16 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
} else try_new=0;
init_branch_iterator();
- while((current_uri.s=next_branch( ¤t_uri.len, &q, &dst_uri.s, &dst_uri.len, &si))) {
+ while((current_uri.s=next_branch( ¤t_uri.len, &q, &dst_uri.s,
+ &dst_uri.len, &si))) {
try_new++;
p_msg->force_send_socket = si;
getbflagsval(get_branch_iterator(), &bflags);
setbflagsval(0, bflags);
branch_ret=add_uac( t, p_msg, ¤t_uri,
- (dst_uri.len) ? (&dst_uri) : ¤t_uri,
- proxy, proto);
+ (dst_uri.len) ? (&dst_uri) : ¤t_uri,
+ proxy, proto);
/* pick some of the errors in case things go wrong;
note that picking lowest error is just as good as
any other algorithm which picks any other negative
diff --git a/modules/tm/t_lookup.c b/modules/tm/t_lookup.c
index 72c14c7..1fe5755 100644
--- a/modules/tm/t_lookup.c
+++ b/modules/tm/t_lookup.c
@@ -1218,6 +1218,7 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
#ifdef USE_COMP
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
*/
diff --git a/modules/tm/uac.c b/modules/tm/uac.c
index e070cd5..cd3e1e9 100644
--- a/modules/tm/uac.c
+++ b/modules/tm/uac.c
@@ -238,7 +238,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
#ifdef USE_DNS_FAILOVER
if (cfg_get(core, core_cfg, use_dns_failover)){
dns_srv_handle_init(&dns_h);
- if ((uri2dst2(&dns_h, &dst, uac_r->dialog->send_sock,
+ if ((uri2dst2(&dns_h, &dst, uac_r->dialog->send_sock, 0,
uac_r->dialog->hooks.next_hop, PROTO_NONE)==0)
|| (dst.send_sock==0)){
dns_srv_handle_put(&dns_h);
@@ -249,7 +249,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
}
dns_srv_handle_put(&dns_h); /* not needed anymore */
}else{
- if ((uri2dst2(0, &dst, uac_r->dialog->send_sock,
+ if ((uri2dst2(0, &dst, uac_r->dialog->send_sock, 0,
uac_r->dialog->hooks.next_hop, PROTO_NONE)==0) ||
(dst.send_sock==0)){
ser_error = E_NO_SOCKET;
@@ -259,7 +259,7 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
}
}
#else /* USE_DNS_FAILOVER */
- if ((uri2dst2(&dst, uac_r->dialog->send_sock,
+ if ((uri2dst2(&dst, uac_r->dialog->send_sock, 0,
uac_r->dialog->hooks.next_hop, PROTO_NONE)==0) ||
(dst.send_sock==0)){
ser_error = E_NO_SOCKET;
diff --git a/modules/tm/ut.h b/modules/tm/ut.h
index 0c7afaf..e0cabcf 100644
--- a/modules/tm/ut.h
+++ b/modules/tm/ut.h
@@ -221,6 +221,7 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
* dst - will be filled
* force_send_sock - if 0 dst->send_sock will be set to the default
* (see get_send_socket2())
+ * sflags - send flags
* uri - uri in str form
* proto - if != PROTO_NONE, this protocol will be forced over the
* uri_proto, otherwise the uri proto will be used if set or
@@ -231,10 +232,12 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
inline static struct dest_info *uri2dst2(struct dns_srv_handle* dns_h,
struct dest_info* dst,
struct socket_info *force_send_socket,
+ snd_flags_t sflags,
str *uri, int proto )
#else
inline static struct dest_info *uri2dst2(struct dest_info* dst,
struct socket_info *force_send_socket,
+ snd_flags_t sflags,
str *uri, int proto )
#endif
{
@@ -268,6 +271,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
#ifdef USE_COMP
dst->comp=parsed_uri.comp;
#endif
+ dst->send_flags=sflags;
#ifdef HONOR_MADDR
if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
host=&parsed_uri.maddr_val;
@@ -336,9 +340,10 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
* null. If null or use_dns_failover==0 normal dns lookup will
* be performed (no failover).
* dst - will be filled
- * msg - sip message used to set dst->send_sock, if 0 dst->send_sock
- * will be set to the default w/o using msg->force_send_socket
- * (see get_send_socket())
+ * msg - sip message used to set dst->send_sock and dst->send_flags,
+ * if 0 dst->send_sock will be set to the default w/o using
+ * msg->force_send_socket (see get_send_socket()) and the
+ * send_flags will be set to 0.
* uri - uri in str form
* proto - if != PROTO_NONE, this protocol will be forced over the
* uri_proto, otherwise the uri proto will be used if set or
@@ -351,14 +356,16 @@ inline static struct dest_info *uri2dst(struct dns_srv_handle* dns_h,
struct sip_msg *msg, str *uri,
int proto )
{
- return uri2dst2(dns_h, dst, msg?msg->force_send_socket:0, uri, proto);
+ return uri2dst2(dns_h, dst, msg?msg->force_send_socket:0,
+ msg?msg->fwd_send_flags:0, uri, proto);
}
#else
inline static struct dest_info *uri2dst(struct dest_info* dst,
struct sip_msg *msg, str *uri,
int proto )
{
- return uri2dst2(dst, msg?msg->force_send_socket:0, uri, proto);
+ return uri2dst2(dst, msg?msg->force_send_socket:0,
+ msg?msg->fwd_send_flags:0, uri, proto);
}
#endif /* USE_DNS_FAILOVER */
Sipwise is currently hiring a VoIP System Administrator for an
interesting position based in Vienna/Austria.
You have strong skills in Linux system administration (Monitoring and
Alerting using SNMP/Nagios/Cacti/MRTG, Scripting in Perl/M4/sh), a deep
understanding of highly available system deployments and good knowledge
regarding SIP (preferably Kamailio, Sems, Asterisk)?
We offer you a challenging position to help our team further improving
our Kamailio-based Class5 Softswitches, deploying them at customer sites
and supporting our customers (large DSL and Cable Providers throughout
Europe) and sales teams with technical details.
If you are interested, please send me an email for further information.
Best regards,
Andreas
Module: sip-router
Branch: master
Commit: 54ec52858d97a416d3927b1ea2f58e7ebe46af46
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=54ec528…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Mon Sep 14 17:57:40 2009 +0200
tm: callback param free functions can use shm_free()
The release function of the callback parameters is
called outside of the shared memory lock to make the
implementation of such functions easier.
---
modules/tm/h_table.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/modules/tm/h_table.c b/modules/tm/h_table.c
index 06a643c..3acee65 100644
--- a/modules/tm/h_table.c
+++ b/modules/tm/h_table.c
@@ -142,7 +142,13 @@ void free_cell( struct cell* dead_cell )
cbs_tmp = cbs;
cbs = cbs->next;
if (cbs_tmp->release) {
+ /* It is safer to release the shm memory lock
+ * otherwise the release function must to be aware of
+ * the lock state (Miklos)
+ */
+ shm_unlock();
cbs_tmp->release(cbs_tmp->param);
+ shm_lock();
}
shm_free_unsafe( cbs_tmp );
}