From c5546e2bd7e49c9f51840bdbe454535f1d74be45 Mon Sep 17 00:00:00 2001
From: Damien Wedhorn <voip@facts.com.au>
Date: Mon, 10 Oct 2011 00:36:02 +0000
Subject: [PATCH] Increase SKINNY_MAX_PACKET and add some logging.

Increase SKINNY_MAX_PACKET to 2000 bytes to handle some messages
in v17 that are greater than the old 1000 bytes. Also add some
useful logging regarding packet and session handling.

A device (with protocol v17) was sending a packet with length
greater than 1000 which resulted in the TCP session being
destroyed and registration being retryed.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@340070 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_skinny.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index ec4d7b0f3f..7c5ca907bc 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -166,7 +166,7 @@ enum skinny_codecs {
 
 #define DEFAULT_SKINNY_PORT 2000
 #define DEFAULT_SKINNY_BACKLOG 2
-#define SKINNY_MAX_PACKET 1000
+#define SKINNY_MAX_PACKET 2000
 #define DEFAULT_AUTH_TIMEOUT 30
 #define DEFAULT_AUTH_LIMIT 50
 
@@ -6862,6 +6862,7 @@ static int get_input(struct skinnysession *s)
 			return -1;
 		}
 		if (dlen+8 > sizeof(s->inbuf)) {
+			ast_log(LOG_WARNING, "Skinny packet too large (%d bytes), max length(%d bytes)\n", dlen+8, SKINNY_MAX_PACKET);
 			dlen = sizeof(s->inbuf) - 8;
 		}
 		*bufaddr = htolel(dlen);
@@ -6915,6 +6916,7 @@ static void *skinny_session(void *data)
 	for (;;) {
 		res = get_input(s);
 		if (res < 0) {
+			ast_verb(3, "Ending Skinny session from %s (bad input)\n", ast_inet_ntoa(s->sin.sin_addr));
 			break;
 		}
 
@@ -6922,6 +6924,7 @@ static void *skinny_session(void *data)
 		{
 			if (!(req = skinny_req_parse(s))) {
 				destroy_session(s);
+				ast_verb(3, "Ending Skinny session from %s (failed parse)\n", ast_inet_ntoa(s->sin.sin_addr));
 				return NULL;
 			}
 
-- 
GitLab