[sr-dev] git:master: sl: lookup event route for local response at startup

Daniel-Constantin Mierla miconda at gmail.com
Fri Sep 20 13:40:11 CEST 2013


Module: sip-router
Branch: master
Commit: 16f87ae1b1f78938ed56a7c9a336a2853022b86c
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=16f87ae1b1f78938ed56a7c9a336a2853022b86c

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri Sep 20 13:39:15 2013 +0200

sl: lookup event route for local response at startup

- group lookup of sl event routes in one function

---

 modules/sl/sl.c       |    6 +-----
 modules/sl/sl_funcs.c |   22 +++++++++++++++++++---
 modules/sl/sl_funcs.h |    2 ++
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/modules/sl/sl.c b/modules/sl/sl.c
index 87449fd..ab5e737 100644
--- a/modules/sl/sl.c
+++ b/modules/sl/sl.c
@@ -78,8 +78,6 @@ MODULE_VERSION
 static int default_code = 500;
 static str default_reason = STR_STATIC_INIT("Internal Server Error");
 
-int _sl_filtered_ack_route = -1; /* default disabled */
-
 static int sl_bind_tm = 1;
 static struct tm_binds tmb;
 
@@ -176,9 +174,7 @@ static int mod_init(void)
 		}
 	}
 
-	_sl_filtered_ack_route=route_lookup(&event_rt, "sl:filtered-ack");
-	if (_sl_filtered_ack_route>=0 && event_rt.rlist[_sl_filtered_ack_route]==0)
-		_sl_filtered_ack_route=-1; /* disable */
+	sl_lookup_event_routes();
 
 	return 0;
 }
diff --git a/modules/sl/sl_funcs.c b/modules/sl/sl_funcs.c
index 388f79c..c9c870c 100644
--- a/modules/sl/sl_funcs.c
+++ b/modules/sl/sl_funcs.c
@@ -75,7 +75,24 @@ static char           *tag_suffix;
    we do not filter */
 static unsigned int  *sl_timeout;
 
-extern int _sl_filtered_ack_route;
+static int _sl_filtered_ack_route = -1; /* default disabled */
+
+static int _sl_evrt_local_response = -1; /* default disabled */
+
+/*!
+ * lookup sl event routes
+ */
+void sl_lookup_event_routes(void)
+{
+	_sl_filtered_ack_route=route_lookup(&event_rt, "sl:filtered-ack");
+	if (_sl_filtered_ack_route>=0 && event_rt.rlist[_sl_filtered_ack_route]==0)
+		_sl_filtered_ack_route=-1; /* disable */
+
+	 _sl_evrt_local_response = route_lookup(&event_rt, "sl:local-response");
+	if (_sl_evrt_local_response>=0
+			&& event_rt.rlist[_sl_evrt_local_response]!=NULL)
+		_sl_evrt_local_response = -1;
+}
 
 /*!
  * init sl internal structures
@@ -207,8 +224,7 @@ int sl_reply_helper(struct sip_msg *msg, int code, char *reason, str *tag)
 	ret = msg_send(&dst, buf.s, buf.len);
 	mhomed=backup_mhomed;
 
-	rt = route_lookup(&event_rt, "sl:local-response");
-	if (unlikely(rt >= 0 && event_rt.rlist[rt] != NULL))
+	if (unlikely(_sl_evrt_local_response >= 0))
 	{
 		if (likely(build_sip_msg_from_buf(&pmsg, buf.s, buf.len,
 				inc_msg_no()) == 0))
diff --git a/modules/sl/sl_funcs.h b/modules/sl/sl_funcs.h
index 772f106..4654d80 100644
--- a/modules/sl/sl_funcs.h
+++ b/modules/sl/sl_funcs.h
@@ -48,4 +48,6 @@ int sl_reply_error(struct sip_msg *msg);
 
 int sl_get_reply_totag(struct sip_msg *msg, str *totag);
 
+void sl_lookup_event_routes(void);
+
 #endif




More information about the sr-dev mailing list