All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] simutil: Fix EF_PNN access
@ 2014-03-14 16:23 Alfonso Sanchez-Beato
  2014-03-14 16:23 ` [PATCH 2/2] unit: Fix test to use valid EF_PNN Alfonso Sanchez-Beato
  2014-03-14 18:30 ` [PATCH 1/2] simutil: Fix EF_PNN access Denis Kenzior
  0 siblings, 2 replies; 3+ messages in thread
From: Alfonso Sanchez-Beato @ 2014-03-14 16:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1543 bytes --]

EF_PNN was not being read properly (see TS 24.008, section 10.5.3.5a,
for network names format), which affected the displayed PLMN name for
some MVNOs. Some modems already read the file and return the right
string: these do not show the problem.
---
 src/simutil.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/simutil.c b/src/simutil.c
index 90d7f8d..a7745ae 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -767,12 +767,14 @@ static char *sim_network_name_parse(const unsigned char *buffer, int length,
 					gboolean *add_ci)
 {
 	char *ret = NULL;
-	unsigned char *endp;
 	unsigned char dcs;
 	int i;
 	gboolean ci = FALSE;
+	unsigned char *unpacked_buf;
+	long num_char, written;
+	int spare_bits;
 
-	if (length < 1)
+	if (length < 2)
 		return NULL;
 
 	dcs = *buffer++;
@@ -787,11 +789,18 @@ static char *sim_network_name_parse(const unsigned char *buffer, int length,
 
 	switch (dcs & (7 << 4)) {
 	case 0x00:
-		endp = memchr(buffer, 0xff, length);
-		if (endp)
-			length = endp - buffer;
-		ret = convert_gsm_to_utf8(buffer, length,
-				NULL, NULL, 0xff);
+		spare_bits = dcs & 0x07;
+		num_char = (length * 8 - spare_bits) / 7;
+
+		unpacked_buf = unpack_7bit(buffer, length, 0, FALSE,
+						num_char, &written, 0);
+		if (unpacked_buf == NULL)
+			break;
+
+		ret = convert_gsm_to_utf8(unpacked_buf, written, NULL, NULL, 0);
+
+		g_free(unpacked_buf);
+
 		break;
 	case 0x10:
 		if ((length % 2) == 1) {
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] unit: Fix test to use valid EF_PNN
  2014-03-14 16:23 [PATCH 1/2] simutil: Fix EF_PNN access Alfonso Sanchez-Beato
@ 2014-03-14 16:23 ` Alfonso Sanchez-Beato
  2014-03-14 18:30 ` [PATCH 1/2] simutil: Fix EF_PNN access Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: Alfonso Sanchez-Beato @ 2014-03-14 16:23 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1328 bytes --]

test-simutil was not using EF_PNN files with a valid format.
---
 unit/test-simutil.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/unit/test-simutil.c b/unit/test-simutil.c
index cf76a37..69dd81e 100644
--- a/unit/test-simutil.c
+++ b/unit/test-simutil.c
@@ -345,10 +345,12 @@ const unsigned char valid_efopl[] = {
 };
 
 const unsigned char valid_efpnn[][28] = {
-	{ 0x43, 0x0a, 0x00, 0x54, 0x75, 0x78, 0x20, 0x43, 0x6f, 0x6d,
-	  0x6d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, },
-	{ 0x43, 0x05, 0x00, 0x4C, 0x6F, 0x6E, 0x67, 0x45, 0x06, 0x00,
-	  0x53, 0x68, 0x6F, 0x72, 0x74, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }
+	/* Solavei */
+	{ 0x43, 0x08, 0x87, 0xD3, 0x37, 0x3B, 0x6C, 0x2F, 0xA7, 0x01 },
+	/* T-Mobile / T-Mobile */
+	{ 0x43, 0x08, 0x80, 0xD4, 0x56, 0xF3, 0x2D, 0x4E, 0xB3, 0xCB,
+	  0x45, 0x08, 0x80, 0xD4, 0x56, 0xF3, 0x2D, 0x4E, 0xB3, 0xCB,
+	  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
 };
 
 static void test_eons(void)
@@ -376,7 +378,7 @@ static void test_eons(void)
 	op_info = sim_eons_lookup(eons_info, "246", "81");
 	g_assert(op_info);
 
-	g_assert(!strcmp(op_info->longname, "Tux Comm"));
+	g_assert(!strcmp(op_info->longname, "Solavei"));
 	g_assert(!op_info->shortname);
 	g_assert(!op_info->info);
 
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] simutil: Fix EF_PNN access
  2014-03-14 16:23 [PATCH 1/2] simutil: Fix EF_PNN access Alfonso Sanchez-Beato
  2014-03-14 16:23 ` [PATCH 2/2] unit: Fix test to use valid EF_PNN Alfonso Sanchez-Beato
@ 2014-03-14 18:30 ` Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2014-03-14 18:30 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

Hi Alfonso,

On 03/14/2014 11:23 AM, Alfonso Sanchez-Beato wrote:
> EF_PNN was not being read properly (see TS 24.008, section 10.5.3.5a,
> for network names format), which affected the displayed PLMN name for
> some MVNOs. Some modems already read the file and return the right
> string: these do not show the problem.
> ---
>   src/simutil.c | 23 ++++++++++++++++-------
>   1 file changed, 16 insertions(+), 7 deletions(-)

That was indeed a bug, nice catch.

Both patches have been applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-14 18:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-14 16:23 [PATCH 1/2] simutil: Fix EF_PNN access Alfonso Sanchez-Beato
2014-03-14 16:23 ` [PATCH 2/2] unit: Fix test to use valid EF_PNN Alfonso Sanchez-Beato
2014-03-14 18:30 ` [PATCH 1/2] simutil: Fix EF_PNN access Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.