[sr-dev] git:pd/websocket: modules/websockets: Added some extra debug/diagnostics

Peter Dunkley peter.dunkley at crocodile-rcs.com
Sun Jul 1 23:22:11 CEST 2012


Module: sip-router
Branch: pd/websocket
Commit: b66cd6508d9bff106a88fbbd1c649e492b6d742c
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b66cd6508d9bff106a88fbbd1c649e492b6d742c

Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date:   Sun Jul  1 22:21:38 2012 +0100

modules/websockets: Added some extra debug/diagnostics

---

 modules/websocket/ws_frame.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/modules/websocket/ws_frame.c b/modules/websocket/ws_frame.c
index ca66582..31754a5 100644
--- a/modules/websocket/ws_frame.c
+++ b/modules/websocket/ws_frame.c
@@ -556,7 +556,7 @@ static int handle_pong(ws_frame_t *frame)
 
 int ws_frame_receive(void *data)
 {
-	ws_frame_t ws_frame;
+	ws_frame_t frame;
 	tcp_event_info_t *tcpinfo = (tcp_event_info_t *) data;
 
 	update_stat(ws_received_frames, 1);
@@ -567,21 +567,23 @@ int ws_frame_receive(void *data)
 		return -1;
 	}
 
-	switch(decode_and_validate_ws_frame(&ws_frame, tcpinfo))
+	switch(decode_and_validate_ws_frame(&frame, tcpinfo))
 	{
 	case OPCODE_TEXT_FRAME:
 	case OPCODE_BINARY_FRAME:
-		return receive_msg(ws_frame.payload_data, ws_frame.payload_len,
+		LM_DBG("Rx SIP message:\n%.*s\n", frame.payload_len,
+				frame.payload_data);
+		return receive_msg(frame.payload_data, frame.payload_len,
 				tcpinfo->rcv);
 
 	case OPCODE_CLOSE:
-		return handle_close(&ws_frame);
+		return handle_close(&frame);
 
 	case OPCODE_PING:
-		return handle_ping(&ws_frame);
+		return handle_ping(&frame);
 
 	case OPCODE_PONG:
-		return handle_pong(&ws_frame);
+		return handle_pong(&frame);
 
 	default:
 		LM_WARN("received bad frame\n");
@@ -606,6 +608,9 @@ int ws_frame_transmit(void *data)
 	frame.payload_data = wsev->buf;
 	frame.wsc = wsconn_get(wsev->id);
 
+	LM_DBG("Tx SIP message:\n%.*s\n", frame.payload_len,
+			frame.payload_data);
+
 	if (encode_and_send_ws_frame(&frame, CONN_CLOSE_DONT) < 0)
 	{	
 		LM_ERR("sending SIP message\n");




More information about the sr-dev mailing list