Browse Source

modules/websocket: added some sub-protocol related statistics

Peter Dunkley 12 years ago
parent
commit
63b50d3b0e
3 changed files with 14 additions and 1 deletions
  1. 10 1
      modules/websocket/ws_handshake.c
  2. 2 0
      modules/websocket/ws_handshake.h
  3. 2 0
      modules/websocket/ws_mod.c

+ 10 - 1
modules/websocket/ws_handshake.c

@@ -46,6 +46,8 @@ int ws_sub_protocols = DEFAULT_SUB_PROTOCOLS;
 
 
 stat_var *ws_failed_handshakes;
 stat_var *ws_failed_handshakes;
 stat_var *ws_successful_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_sip = str_init("sip");
 static str str_msrp = str_init("msrp");
 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.len,
 					str_hdr_sec_websocket_version.s,
 					str_hdr_sec_websocket_version.s,
 					WS_VERSION);
 					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;
 		return 0;
 	}
 	}
 
 

+ 2 - 0
modules/websocket/ws_handshake.h

@@ -38,6 +38,8 @@ extern int ws_sub_protocols;
 
 
 extern stat_var *ws_failed_handshakes;
 extern stat_var *ws_failed_handshakes;
 extern stat_var *ws_successful_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);
 int ws_handle_handshake(struct sip_msg *msg);
 struct mi_root *ws_mi_disable(struct mi_root *cmd, void *param);
 struct mi_root *ws_mi_disable(struct mi_root *cmd, void *param);

+ 2 - 0
modules/websocket/ws_mod.c

@@ -98,6 +98,8 @@ static stat_export_t stats[] =
 	/* ws_handshake.c */
 	/* ws_handshake.c */
 	{ "ws_failed_handshakes",         0, &ws_failed_handshakes },
 	{ "ws_failed_handshakes",         0, &ws_failed_handshakes },
 	{ "ws_successful_handshakes",     0, &ws_successful_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 }
 	{ 0, 0, 0 }
 };
 };