[sr-dev] git:master: pike Add counter for blocked IP addresses
Olle E. Johansson
oej at edvina.net
Wed Apr 3 21:57:01 CEST 2013
Module: sip-router
Branch: master
Commit: 7fffcebb7ec85bfdffd3712b8f7d8ee91575fe22
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7fffcebb7ec85bfdffd3712b8f7d8ee91575fe22
Author: Olle E. Johansson <oej at edvina.net>
Committer: Olle E. Johansson <oej at edvina.net>
Date: Wed Apr 3 21:55:47 2013 +0200
pike Add counter for blocked IP addresses
---
modules/pike/pike.c | 3 +++
modules/pike/pike_funcs.c | 9 +++++++++
modules/pike/pike_funcs.h | 1 +
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/modules/pike/pike.c b/modules/pike/pike.c
index 3b23a94..5d34659 100644
--- a/modules/pike/pike.c
+++ b/modules/pike/pike.c
@@ -154,6 +154,9 @@ static int pike_init(void)
register_timer( clean_routine , 0, 1 );
register_timer( swap_routine , 0, time_unit );
+ /* Register counter */
+ pike_counter_init();
+
return 0;
error3:
destroy_ip_tree();
diff --git a/modules/pike/pike_funcs.c b/modules/pike/pike_funcs.c
index ba69756..009bb68 100644
--- a/modules/pike/pike_funcs.c
+++ b/modules/pike/pike_funcs.c
@@ -43,6 +43,7 @@
#include "../../timer.h"
#include "../../ip_addr.h"
#include "../../resolve.h"
+#include "../../counters.h"
#include "ip_tree.h"
#include "pike_funcs.h"
#include "timer.h"
@@ -55,6 +56,13 @@ extern struct list_link* timer;
extern int timeout;
extern int pike_log_level;
+counter_handle_t blocked;
+
+void pike_counter_init()
+{
+ counter_register(&blocked, "pike", "blocked_ips", 0, 0, 0, "Counter of blocked IP addresses", 0);
+}
+
int pike_check_req(struct sip_msg *msg, char *foo, char *bar)
@@ -154,6 +162,7 @@ int pike_check_req(struct sip_msg *msg, char *foo, char *bar)
if (flags&NEWRED_NODE) {
LM_GEN1( pike_log_level,
"PIKE - BLOCKing ip %s, node=%p\n",ip_addr2a(ip),node);
+ counter_inc(blocked);
return -2;
}
return -1;
diff --git a/modules/pike/pike_funcs.h b/modules/pike/pike_funcs.h
index e0f6e5a..1c8beb3 100644
--- a/modules/pike/pike_funcs.h
+++ b/modules/pike/pike_funcs.h
@@ -28,6 +28,7 @@
#include "../../locking.h"
+void pike_counter_init(void);
int pike_check_req(struct sip_msg *msg, char *foo, char *bar);
void clean_routine(unsigned int, void*);
void swap_routine(unsigned int, void*);
More information about the sr-dev
mailing list