Browse Source

sl: option to run event_route[sl:filtered-ack]

- event route executed when a ACK is filtered by SL module
- separate statistic var for SL module failures from err replies
Daniel-Constantin Mierla 15 years ago
parent
commit
59793be255
4 changed files with 27 additions and 0 deletions
  1. 6 0
      modules/sl/sl.c
  2. 5 0
      modules/sl/sl_funcs.c
  3. 14 0
      modules/sl/sl_stats.c
  4. 2 0
      modules/sl/sl_stats.h

+ 6 - 0
modules/sl/sl.c

@@ -76,6 +76,8 @@ 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;
 
@@ -163,6 +165,10 @@ 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 */
+
 	return 0;
 }
 

+ 5 - 0
modules/sl/sl_funcs.c

@@ -72,6 +72,7 @@ static char           *tag_suffix;
    we do not filter */
 static unsigned int  *sl_timeout;
 
+extern int _sl_filtered_ack_route;
 
 /*!
  * init sl internal structures
@@ -321,6 +322,10 @@ int sl_filter_ACK(struct sip_msg *msg, unsigned int flags, void *bar )
 				LM_DBG("SL local ACK found -> dropping it!\n" );
 				update_sl_filtered_acks();
 				sl_run_callbacks(SLCB_ACK_FILTERED, msg, 0, 0, 0, 0);
+				if(unlikely(_sl_filtered_ack_route>=0)) {
+					run_top_route(event_rt.rlist[_sl_filtered_ack_route],
+							msg, 0);
+				}
 				return 0;
 			}
 		}

+ 14 - 0
modules/sl/sl_stats.c

@@ -146,6 +146,11 @@ void update_sl_failures( void )
 	(*sl_stats)[process_no].failures++;
 }
 
+void update_sl_err_replies( void )
+{
+	(*sl_stats)[process_no].err_replies++;
+}
+
 void update_sl_filtered_acks( void )
 {
 	(*sl_stats)[process_no].filtered_acks++;
@@ -244,6 +249,7 @@ unsigned long sl_stats_RT_xxx(void);
 
 unsigned long sl_stats_sent_rpls(void);
 unsigned long sl_stats_sent_err_rpls(void);
+unsigned long sl_stats_failures(void);
 unsigned long sl_stats_rcv_acks(void);
 
 static stat_export_t mod_stats[] = {
@@ -292,6 +298,8 @@ static stat_export_t mod_stats[] = {
 		(stat_var**)sl_stats_sent_rpls      },
 	{"sent_err_replies" ,  STAT_IS_FUNC,
 		(stat_var**)sl_stats_sent_err_rpls  },
+	{"failures" ,          STAT_IS_FUNC,
+		(stat_var**)sl_stats_failures       },
 	{"received_ACKs" ,     STAT_IS_FUNC,
 		(stat_var**)sl_stats_rcv_acks       },
 	{0,0,0}
@@ -456,6 +464,12 @@ unsigned long sl_stats_sent_rpls(void)
 }
 
 unsigned long sl_stats_sent_err_rpls(void)
+{
+	sl_stats_update();
+	return _sl_stats_total.err_replies;
+}
+
+unsigned long sl_stats_failures(void)
 {
 	sl_stats_update();
 	return _sl_stats_total.failures;

+ 2 - 0
modules/sl/sl_stats.h

@@ -46,6 +46,7 @@ enum reply_type { RT_1xx = 0,  RT_200, RT_202, RT_2xx,
 struct sl_stats {
 	unsigned long err[RT_END];
 	unsigned long all_replies;
+	unsigned long err_replies;
 	unsigned long failures;
 	unsigned long filtered_acks;
 };
@@ -54,6 +55,7 @@ int init_sl_stats(void);
 int init_sl_stats_child(void);
 void update_sl_stats( int code );
 void update_sl_failures( void );
+void update_sl_err_replies( void );
 void update_sl_filtered_acks( void );
 void sl_stats_destroy();