Module: sip-router
Branch: master
Commit: 9cb173699b25bc420ff5938214b3df81ed18a4ba
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9cb1736…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Jan 25 17:30:42 2013 +0100
core: made a wrapper forward_reply_nocb()
- it forwards a reply without calling the callbacks from modules for sip
response handling
- fixes the issue of sl_forward_reply() looping when used in TM onreply
routes
---
forward.c | 26 +++++++++++++++++++++-----
forward.h | 1 +
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/forward.c b/forward.c
index b0540d2..380b204 100644
--- a/forward.c
+++ b/forward.c
@@ -754,7 +754,8 @@ int update_sock_struct_from_via( union sockaddr_union* to,
he=sip_resolvehost(name, &port, &proto);
if (he==0){
- LOG(L_NOTICE, "ERROR:forward_reply:resolve_host(%.*s) failure\n",
+ LOG(L_NOTICE,
+ "update_sock_struct_from_via:resolve_host(%.*s) failure\n",
name->len, name->s);
return -1;
}
@@ -765,8 +766,9 @@ int update_sock_struct_from_via( union sockaddr_union* to,
-/* removes first via & sends msg to the second */
-int forward_reply(struct sip_msg* msg)
+/* removes first via & sends msg to the second
+ * - mode param controls if modules sip response callbacks are executed */
+static int do_forward_reply(struct sip_msg* msg, int mode)
{
char* new_buf;
struct dest_info dst;
@@ -792,8 +794,10 @@ int forward_reply(struct sip_msg* msg)
}
/* check modules response_f functions */
- for (r=0; r<mod_response_cbk_no; r++)
- if (mod_response_cbks[r](msg)==0) goto skip;
+ if(likely(mode==0)) {
+ for (r=0; r<mod_response_cbk_no; r++)
+ if (mod_response_cbks[r](msg)==0) goto skip;
+ }
/* we have to forward the reply stateless, so we need second via -bogdan*/
if (parse_headers( msg, HDR_VIA2_F, 0 )==-1
|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))
@@ -872,6 +876,18 @@ error:
return -1;
}
+/* removes first via & sends msg to the second */
+int forward_reply(struct sip_msg* msg)
+{
+ return do_forward_reply(msg, 0);
+}
+
+/* removes first via & sends msg to the second - no module callbacks */
+int forward_reply_nocb(struct sip_msg* msg)
+{
+ return do_forward_reply(msg, 1);
+}
+
static void apply_force_send_socket(struct dest_info* dst, struct sip_msg* msg)
{
if (msg->force_send_socket != 0) {
diff --git a/forward.h b/forward.h
index 2b9ae78..17ac683 100644
--- a/forward.h
+++ b/forward.h
@@ -105,6 +105,7 @@ int update_sock_struct_from_via( union sockaddr_union* to,
((msg)->via1->port)?(msg)->via1->port: SIP_PORT )
int forward_reply( struct sip_msg* msg);
+int forward_reply_nocb( struct sip_msg* msg);
int is_check_self_func_list_set(void);