Module: sip-router
Branch: master
Commit: 63b50d3b0e3a2250effd9a1aa92b7776854364a6
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=63b50d3…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Sat Mar 30 11:36:41 2013 +0000
modules/websocket: added some sub-protocol related statistics
---
modules/websocket/ws_handshake.c | 11 ++++++++++-
modules/websocket/ws_handshake.h | 2 ++
modules/websocket/ws_mod.c | 2 ++
3 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/modules/websocket/ws_handshake.c b/modules/websocket/ws_handshake.c
index 55dfc34..eb167e4 100644
--- a/modules/websocket/ws_handshake.c
+++ b/modules/websocket/ws_handshake.c
@@ -46,6 +46,8 @@ int ws_sub_protocols = DEFAULT_SUB_PROTOCOLS;
stat_var *ws_failed_handshakes;
stat_var *ws_successful_handshakes;
+stat_var *ws_sip_handshakes;
+stat_var *ws_msrp_handshakes;
static str str_sip = str_init("sip");
static str str_msrp = str_init("msrp");
@@ -306,7 +308,14 @@ int ws_handle_handshake(struct sip_msg *msg)
str_hdr_sec_websocket_version.len,
str_hdr_sec_websocket_version.s,
WS_VERSION);
- ws_send_reply(msg, 400, &str_status_bad_request, &headers);
+ if (ws_send_reply(msg, 400, &str_status_bad_request, &headers)
+ == 0)
+ {
+ if (ws_sub_protocols & SUB_PROTOCOL_SIP)
+ update_stat(ws_sip_handshakes, 1);
+ else if (ws_sub_protocols & SUB_PROTOCOL_MSRP)
+ update_stat(ws_msrp_handshakes, 1);
+ }
return 0;
}
diff --git a/modules/websocket/ws_handshake.h b/modules/websocket/ws_handshake.h
index fa51eb0..94c47ab 100644
--- a/modules/websocket/ws_handshake.h
+++ b/modules/websocket/ws_handshake.h
@@ -38,6 +38,8 @@ extern int ws_sub_protocols;
extern stat_var *ws_failed_handshakes;
extern stat_var *ws_successful_handshakes;
+extern stat_var *ws_sip_handshakes;
+extern stat_var *ws_msrp_handshakes;
int ws_handle_handshake(struct sip_msg *msg);
struct mi_root *ws_mi_disable(struct mi_root *cmd, void *param);
diff --git a/modules/websocket/ws_mod.c b/modules/websocket/ws_mod.c
index 7049bfd..df05c0f 100644
--- a/modules/websocket/ws_mod.c
+++ b/modules/websocket/ws_mod.c
@@ -98,6 +98,8 @@ static stat_export_t stats[] =
/* ws_handshake.c */
{ "ws_failed_handshakes", 0, &ws_failed_handshakes },
{ "ws_successful_handshakes", 0, &ws_successful_handshakes },
+ { "ws_sip_handshakes", 0, &ws_sip_handshakes },
+ { "ws_msrp_handshakes", 0, &ws_msrp_handshakes },
{ 0, 0, 0 }
};