tomh / rpms / asterisk

Forked from rpms/asterisk 6 years ago
Clone
c028602
From 27281c691ee1b1c632fcfd8c99f7b4a2d9fa8921 Mon Sep 17 00:00:00 2001
79d1ed7
From: David Woodhouse <dwmw2@infradead.org>
79d1ed7
Date: Tue, 20 Sep 2011 09:21:47 -0500
c028602
Subject: [PATCH 8/9] Fix two problems with app_sms.
79d1ed7
79d1ed7
Firstly, the 'flags' field on the stack in sms_exec() is
79d1ed7
uninitialised, causing it to use the wrong protocol in some cases.
79d1ed7
79d1ed7
Secondly, when disconnect supervision is not working or
79d1ed7
inbanddisconnect=yes is set in chan_dahdi.conf, app_sms was failing to
79d1ed7
terminate the call after it sent the REL(ease) message and the peer
79d1ed7
stopped talking to it. This patch fixes the code to handle the 'bad
79d1ed7
stop bit' message more gracefully in that case, and hang up the call.
79d1ed7
---
3ec7f26
 apps/app_sms.c | 12 +++++++++---
3ec7f26
 1 file changed, 9 insertions(+), 3 deletions(-)
79d1ed7
79d1ed7
diff --git a/apps/app_sms.c b/apps/app_sms.c
c028602
index 08b90d1..b6c4ade 100644
79d1ed7
--- a/apps/app_sms.c
79d1ed7
+++ b/apps/app_sms.c
79d1ed7
@@ -216,6 +216,7 @@ static const unsigned short escapes[] = {
79d1ed7
 typedef struct sms_s {
79d1ed7
 	unsigned char hangup;        /*!< we are done... */
79d1ed7
 	unsigned char err;           /*!< set for any errors */
79d1ed7
+	unsigned char sent_rel:1;     /*!< have sent REL message... */
79d1ed7
 	unsigned char smsc:1;        /*!< we are SMSC */
79d1ed7
 	unsigned char rx:1;          /*!< this is a received message */
79d1ed7
 	char queue[30];              /*!< queue name */
79d1ed7
@@ -1464,6 +1465,7 @@ static void sms_nextoutgoing (sms_t * h)
79d1ed7
 		} else {
79d1ed7
 			h->omsg[0] = 0x94;              /* SMS_REL */
79d1ed7
 			h->omsg[1] = 0;
79d1ed7
+			h->sent_rel = 1;
79d1ed7
 		}
79d1ed7
 	}
79d1ed7
 	sms_messagetx(h);
79d1ed7
@@ -1801,8 +1803,12 @@ static void sms_process(sms_t * h, int samples, signed short *data)
79d1ed7
 				h->iphasep -= 80;
79d1ed7
 				if (h->ibitn++ == 9) {      /* end of byte */
79d1ed7
 					if (!bit) {             /* bad stop bit */
3ec7f26
-						ast_log(LOG_NOTICE, "bad stop bit\n");
79d1ed7
-						h->ierr = 0xFF;     /* unknown error */
79d1ed7
+						if (h->sent_rel) {
79d1ed7
+							h->hangup = 1;
79d1ed7
+						} else {
79d1ed7
+							ast_log(LOG_NOTICE, "bad stop bit\n");
79d1ed7
+							h->ierr = 0xFF;     /* unknown error */
79d1ed7
+						}
79d1ed7
 					} else {
79d1ed7
 						if (h->ibytep < sizeof(h->imsg)) {
79d1ed7
 							h->imsg[h->ibytep] = h->ibytev;
79d1ed7
@@ -1864,7 +1870,7 @@ static int sms_exec(struct ast_channel *chan, const char *data)
79d1ed7
 	int res = -1;
79d1ed7
 	sms_t h = { 0 };
79d1ed7
 	/* argument parsing support */
79d1ed7
-	struct ast_flags flags;
79d1ed7
+	struct ast_flags flags = { 0 };
79d1ed7
 	char *parse, *sms_opts[OPTION_ARG_ARRAY_SIZE] = { 0, };
79d1ed7
 	char *p;
79d1ed7
 	AST_DECLARE_APP_ARGS(sms_args,
79d1ed7
-- 
c028602
1.7.12.1
79d1ed7