Skip to contentSkip to conversation

ussd fixes

PATCH In review Nicolas Bertrand 3 participants 6 messages Apr 10, 2012

lore
Share & tools
lore
#0 lore raw

cover ussd fixes

Fix some issues with ussd:
- Crash with speedup dongles
- Crash with ZTE dongles

Nicolas Bertrand (2):
ussd: rise up buffer lenght for ussd strings
ussd: Fix speedup ussd encoding

 drivers/atmodem/ussd.c |   15 +++++++++++----
 plugins/speedup.c      |    2 +-
 2 files changed, 12 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/2 ussd: rise up buffer lenght for ussd strings

Some ZTE modems used to convert any ussd strings in UCS2, and so the buffer length is double. Considering the limit of 182 characters, 364 will avoid crash.

---
 drivers/atmodem/ussd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/atmodem/ussd.c +1 -1
index 443251a..f5b38e2 100644
@@ -106,7 +106,7 @@ static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd)
 	const char *content;
 	int dcs;
 	enum sms_charset charset;
-	unsigned char msg[160];
+	unsigned char msg[364];
 	const unsigned char *msg_ptr = NULL;
 	long msg_len;
 
Signature · 1 line
1.7.5.4
#2 lore raw

Re: [PATCH 1/2] ussd: rise up buffer lenght for ussd strings

Hi Nicolas,

Quoted 12 lines · Nicolas Bertrand

Some ZTE modems used to convert any ussd strings in UCS2, and so the buffer length is double. Considering the limit of 182 characters, 364 will avoid crash.

---
 drivers/atmodem/ussd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/atmodem/ussd.c +0 -0
index 443251a..f5b38e2 100644

drivers/atmodem/ussd.c static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd) · line 109

Quoted 5 lines
drivers/atmodem/ussd.c +1 -1
@@ -106,7 +106,7 @@ static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd)
 	const char *content;
 	int dcs;
 	enum sms_charset charset;
-	unsigned char msg[160];
+	unsigned char msg[364];

Actually I'm not happy with this since the core is still expecting raw 160 byte PDUs. If ZTE reports all USSDs as unpacked UCS2 data, then we need to pack that back up into packed GSM 7 bit. This probably requires a custom driver for ZTE modems.

Alternatively you can see whether ZTE provides some way to modify the USSD reporting behavior, similar to what Huawei did with ^USSDMODE.

Regards,
-Denis

#3 lore raw

PATCH 2/2 ussd: Fix speedup ussd encoding

In reply to Nicolas Bertrand

Speedup dongles encode USSD strings in GSM7
packed, so we don't have to pack it ourselves.

---
 drivers/atmodem/ussd.c |   13 ++++++++++---
 plugins/speedup.c      |    2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/atmodem/ussd.c +10 -3
index f5b38e2..e90db11 100644
@@ -136,9 +136,15 @@ static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd)
 	case SMS_CHARSET_7BIT:
 		switch (data->charset) {
 		case AT_UTIL_CHARSET_GSM:
-			msg_ptr = pack_7bit_own_buf((const guint8 *) content,
-							-1, 0, TRUE, &msg_len,
-							0, msg);
+			if (data->vendor == OFONO_VENDOR_SPEEDUP)
+				msg_ptr = decode_hex_own_buf(content, -1,
+								&msg_len,
+								0, msg);
+			else
+				msg_ptr = pack_7bit_own_buf((const guint8 *)
+								content, -1, 0,
+								TRUE, &msg_len,
+								0, msg);
 			break;
 
 		case AT_UTIL_CHARSET_UTF8:
@@ -242,6 +248,7 @@ static void cusd_cancel_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	switch (data->vendor) {
 	case OFONO_VENDOR_GOBI:
 	case OFONO_VENDOR_QUALCOMM_MSM:
+	case OFONO_VENDOR_SPEEDUP:
 		/* All errors and notifications arrive unexpected and
 		 * thus just reset the state here. This is safer than
 		 * getting stuck in a dead-lock. */
plugins/speedup.c +1 -1
index ca6ed13..5cc380f 100644
@@ -282,7 +282,7 @@ static void speedup_post_online(struct ofono_modem *modem)
 
 	ofono_cbs_create(modem, OFONO_VENDOR_QUALCOMM_MSM,
 						"atmodem", data->aux);
-	ofono_ussd_create(modem, OFONO_VENDOR_QUALCOMM_MSM,
+	ofono_ussd_create(modem, OFONO_VENDOR_SPEEDUP,
 						"atmodem", data->aux);
 }
 
Signature · 1 line
1.7.5.4
#4 lore raw

Re: [PATCH 2/2] ussd: Fix speedup ussd encoding

Hi Nicolas,

Quoted 7 lines · Nicolas Bertrand

Speedup dongles encode USSD strings in GSM7
packed, so we don't have to pack it ourselves.

---
 drivers/atmodem/ussd.c |   13 ++++++++++---
 plugins/speedup.c      |    2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

Patch looks good, but please split it into two in accordance with our patch submission guidelines. See HACKING document, 'Submitting patches' section.

Regards,
-Denis

#5 lore raw

Re: [PATCH 2/2] ussd: Fix speedup ussd encoding

Hi Denis,

Quoted 11 lines
Quoted 7 lines

Speedup dongles encode USSD strings in GSM7
packed, so we don't have to pack it ourselves.

---
 drivers/atmodem/ussd.c |   13 ++++++++++---
 plugins/speedup.c      |    2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

Patch looks good, but please split it into two in accordance with our patch submission guidelines. See HACKING document, 'Submitting patches' section.

if the modem uses a fixed encoding all the time, would it not be simpler to just add a specific modem driver for it? Like we did for Huawei and its binary mode.

Regards

Marcel