All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix: simplify isimodem call-barring driver.
@ 2010-03-23 17:46 ppessi
  2010-03-23 21:53 ` Denis Kenzior
  0 siblings, 1 reply; 7+ messages in thread
From: ppessi @ 2010-03-23 17:46 UTC (permalink / raw)
  To: ofono

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

From: Pekka Pessi <Pekka.Pessi@nokia.com>

Add support for lock codes AG and AC (MMI codes 333 and 353. respectively).
---
 drivers/isimodem/call-barring.c |  153 ++++++++++++---------------------------
 drivers/isimodem/ss.h           |   28 ++++----
 2 files changed, 63 insertions(+), 118 deletions(-)

diff --git a/drivers/isimodem/call-barring.c b/drivers/isimodem/call-barring.c
index 6487ae8..b0246fa 100644
--- a/drivers/isimodem/call-barring.c
+++ b/drivers/isimodem/call-barring.c
@@ -48,6 +48,28 @@ struct barr_data {
 	GIsiClient *client;
 };
 
+static int lock_code_to_mmi(char const *lock)
+{
+	if (strcmp(lock, "AO") == 0)
+		return SS_GSM_BARR_ALL_OUT;
+	else if (strcmp(lock, "OI") == 0)
+		return SS_GSM_BARR_OUT_INTER;
+	else if (strcmp(lock, "OX") == 0)
+		return SS_GSM_BARR_OUT_INTER_EXC_HOME;
+	else if (strcmp(lock, "AI") == 0)
+		return SS_GSM_BARR_ALL_IN;
+	else if (strcmp(lock, "IR") == 0)
+		return SS_GSM_BARR_ALL_IN_ROAM;
+	else if (strcmp(lock, "AB") == 0)
+		return SS_GSM_ALL_BARRINGS;
+	else if (strcmp(lock, "AG") == 0)
+		return SS_GSM_OUTGOING_BARR_SERV;
+	else if (strcmp(lock, "AC") == 0)
+		return SS_GSM_INCOMING_BARR_SERV;
+	else
+		return 0;
+}
+
 static bool set_resp_cb(GIsiClient *client, const void *restrict data,
 				size_t len, uint16_t object, void *opaque)
 {
@@ -84,19 +106,19 @@ static void isi_set(struct ofono_call_barring *barr, const char *lock,
 {
 	struct barr_data *bd = ofono_call_barring_get_data(barr);
 	struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
-	int ss_code;
-	char *ucs2 = NULL;
+	int ss_code = lock_code_to_mmi(lock);
 
 	unsigned char msg[] = {
 		SS_SERVICE_REQ,
 		enable ? SS_ACTIVATION : SS_DEACTIVATION,
 		SS_ALL_TELE_AND_BEARER,
-		0, 0,				/* Supplementary services code */
-		SS_SEND_ADDITIONAL_INFO,
+		ss_code >> 8, ss_code & 0xFF,	/* Supplementary services code */
+		SS_SEND_ADDITIONAL_INFO,	/* ? */
 		1,				/* Subblock count */
 		SS_GSM_PASSWORD,
 		28,				/* Subblock length */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* Password */
+		0, passwd[0], 0, passwd[1],	/* Password */
+		0, passwd[2], 0, passwd[3],
 		0, 0, 0, 0, 0, 0, 0, 0,		/* Filler */
 		0, 0, 0, 0, 0, 0, 0, 0,		/* Filler */
 		0, 0				/* Filler */
@@ -105,43 +127,10 @@ static void isi_set(struct ofono_call_barring *barr, const char *lock,
 	DBG("lock code %s enable %d class %d password %s\n",
 		lock, enable, cls, passwd);
 
-	if (!cbd || !passwd || strlen(passwd) > 4 || cls != 7)
-		goto error;
-
-	if (strcmp(lock, "AO") == 0)
-		ss_code = SS_GSM_BARR_ALL_OUT;
-	else if (strcmp(lock, "OI") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER;
-	else if (strcmp(lock, "OX") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER_EXC_HOME;
-	else if (strcmp(lock, "AI") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN;
-	else if (strcmp(lock, "IR") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN_ROAM;
-	else if (strcmp(lock, "AB") == 0)
-		ss_code = SS_GSM_ALL_BARRINGS;
-	else if (strcmp(lock, "AG") == 0)
-		ss_code = SS_GSM_BARR_ALL_OUT;
-	else if (strcmp(lock, "AC") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN;
-	else
-		goto error;
-
-	msg[3] = ss_code >> 8;
-	msg[4] = ss_code & 0xFF;
-
-	ucs2 = g_convert(passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
-				NULL, NULL, NULL);
-	if (ucs2 == NULL)
-		goto error;
-
-	memcpy((char *)msg + 9, ucs2, 8);
-	g_free(ucs2);
-
-	if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
-				set_resp_cb, cbd))
+	if (cbd && g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
+				      set_resp_cb, cbd))
 		return;
-error:
+
 	CALLBACK_WITH_FAILURE(cb, data);
 	g_free(cbd);
 }
@@ -267,43 +256,23 @@ static void isi_query(struct ofono_call_barring *barr, const char *lock, int cls
 {
 	struct barr_data *bd = ofono_call_barring_get_data(barr);
 	struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
-	int ss_code;
+	int ss_code = lock_code_to_mmi(lock);
 
 	unsigned char msg[] = {
 		SS_SERVICE_REQ,
 		SS_INTERROGATION,
 		SS_ALL_TELE_AND_BEARER,
-		0, 0,				/* Supplementary services code */
-		SS_SEND_ADDITIONAL_INFO,
+		ss_code >> 8, ss_code & 0xFF,	/* Supplementary services code */
+		SS_SEND_ADDITIONAL_INFO,	/* Get BER-encoded result, too */
 		0				/* Subblock count */
 	};
 
-	DBG("barring query lock code %s class %d\n", lock, cls);
-
-	if (!cbd || cls != 7)
-		goto error;
-
-	if (strcmp(lock, "AO") == 0)
-		ss_code = SS_GSM_BARR_ALL_OUT;
-	else if (strcmp(lock, "OI") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER;
-	else if (strcmp(lock, "OX") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER_EXC_HOME;
-	else if (strcmp(lock, "AI") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN;
-	else if (strcmp(lock, "IR") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN_ROAM;
-	else
-		goto error;
-
-	msg[3] = ss_code >> 8;
-	msg[4] = ss_code & 0xFF;
+	DBG("barring query lock code %s\n", lock);
 
-	if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
-				query_resp_cb, cbd))
+	if (cbd && g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
+				      query_resp_cb, cbd))
 		return;
 
-error:
 	CALLBACK_WITH_FAILURE(cb, 0, data);
 	g_free(cbd);
 }
@@ -343,60 +312,34 @@ static void isi_set_passwd(struct ofono_call_barring *barr, const char *lock,
 {
 	struct barr_data *bd = ofono_call_barring_get_data(barr);
 	struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
-	int ss_code;
-	char *ucs2 = NULL;
+	int ss_code = lock_code_to_mmi(lock);
 
 	unsigned char msg[] = {
 		SS_SERVICE_REQ,
 		SS_GSM_PASSWORD_REGISTRATION,
 		SS_ALL_TELE_AND_BEARER,
-		0, 0,				/* Supplementary services code */
+		ss_code >> 8, ss_code & 0xFF,	/* Supplementary services code */
 		SS_SEND_ADDITIONAL_INFO,
 		1,				/* Subblock count */
 		SS_GSM_PASSWORD,
 		28,				/* Subblock length */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* Old password */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* New password */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* New password */
+		0, old_passwd[0], 0, old_passwd[1],
+		0, old_passwd[2], 0, old_passwd[3],
+		0, new_passwd[0], 0, new_passwd[1],
+		0, new_passwd[2], 0, new_passwd[3],
+		0, new_passwd[0], 0, new_passwd[1],
+		0, new_passwd[2], 0, new_passwd[3],
 		0, 0				/* Filler */
 	};
 
-	if (!cbd || strlen(old_passwd) > 4 || strlen(new_passwd) > 4)
-		goto error;
-
-	DBG("lock code %s old password %s new password %s\n",
-		lock, old_passwd, new_passwd);
-
-	if (strcmp(lock, "AB") == 0)
-		ss_code = SS_GSM_ALL_BARRINGS;
-	else
-		goto error;
-
-	msg[3] = ss_code >> 8;
-	msg[4] = ss_code & 0xFF;
+	DBG("lock code %s (%u) old password %s new password %s\n",
+	    lock, ss_code, old_passwd, new_passwd);
 
-	ucs2 = g_convert(old_passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
-				NULL, NULL, NULL);
-	if (ucs2 == NULL)
-		goto error;
-
-	memcpy((char *)msg + 9, ucs2, 8);
-	g_free(ucs2);
-
-	ucs2 = g_convert(new_passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
-				NULL, NULL, NULL);
-	if (ucs2 == NULL)
-		goto error;
-
-	memcpy((char *)msg + 17, ucs2, 8);
-	memcpy((char *)msg + 25, ucs2, 8);
-	g_free(ucs2);
-
-	if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
+	if (cbd &&
+	    g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
 				set_passwd_resp_cb, cbd))
 		return;
 
-error:
 	CALLBACK_WITH_FAILURE(cb, data);
 	g_free(cbd);
 }
diff --git a/drivers/isimodem/ss.h b/drivers/isimodem/ss.h
index 7c20bcc..2313ae6 100644
--- a/drivers/isimodem/ss.h
+++ b/drivers/isimodem/ss.h
@@ -81,19 +81,21 @@ enum ss_basic_service_codes {
 };
 
 enum ss_codes {
-	SS_GSM_ALL_FORWARDINGS = 0x02,
-	SS_GSM_ALL_COND_FORWARDINGS = 0x04,
-	SS_GSM_FORW_UNCONDITIONAL = 0x15,
-	SS_GSM_BARR_ALL_OUT = 0x21,
-	SS_GSM_BARR_ALL_IN = 0x23,
-	SS_GSM_CALL_WAITING = 0x2B,
-	SS_GSM_FORW_NO_REPLY = 0x3D,
-	SS_GSM_FORW_NO_REACH = 0x3E,
-	SS_GSM_FORW_BUSY = 0x43,
-	SS_GSM_ALL_BARRINGS = 0x014A,
-	SS_GSM_BARR_OUT_INTER = 0x014B,
-	SS_GSM_BARR_OUT_INTER_EXC_HOME = 0x014C,
-	SS_GSM_BARR_ALL_IN_ROAM = 0x015F
+	SS_GSM_ALL_FORWARDINGS = 002,
+	SS_GSM_ALL_COND_FORWARDINGS = 004,
+	SS_GSM_FORW_UNCONDITIONAL = 21,
+	SS_GSM_BARR_ALL_OUT = 33,
+	SS_GSM_OUTGOING_BARR_SERV = 333,
+	SS_GSM_INCOMING_BARR_SERV = 353,
+	SS_GSM_BARR_ALL_IN = 35,
+	SS_GSM_CALL_WAITING = 43,
+	SS_GSM_FORW_NO_REPLY = 61,
+	SS_GSM_FORW_NO_REACH = 62,
+	SS_GSM_FORW_BUSY = 67,
+	SS_GSM_ALL_BARRINGS = 330,
+	SS_GSM_BARR_OUT_INTER = 331,
+	SS_GSM_BARR_OUT_INTER_EXC_HOME = 332,
+	SS_GSM_BARR_ALL_IN_ROAM = 351,
 };
 
 enum ss_response_data {
-- 
1.6.3.3


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

* Re: [PATCH] Fix: simplify isimodem call-barring driver.
  2010-03-23 17:46 [PATCH] Fix: simplify isimodem call-barring driver ppessi
@ 2010-03-23 21:53 ` Denis Kenzior
  2010-03-24  8:05   ` Aki Niemi
  2010-03-29 18:20   ` Pekka Pessi
  0 siblings, 2 replies; 7+ messages in thread
From: Denis Kenzior @ 2010-03-23 21:53 UTC (permalink / raw)
  To: ofono

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

Hi Pekka,

> From: Pekka Pessi <Pekka.Pessi@nokia.com>
> 
> Add support for lock codes AG and AC (MMI codes 333 and 353. respectively).

First of all, please keep your commit messages less than 72 characters long 
and headings less than 50 characters long.

Secondly, please keep your patches whitespace clean, there are several cases 
of spaces being used instead of tabs for indentation.

> ---
>  drivers/isimodem/call-barring.c |  153
>  ++++++++++++--------------------------- drivers/isimodem/ss.h           | 
>   28 ++++----
>  2 files changed, 63 insertions(+), 118 deletions(-)
> 
> diff --git a/drivers/isimodem/call-barring.c
>  b/drivers/isimodem/call-barring.c index 6487ae8..b0246fa 100644
> --- a/drivers/isimodem/call-barring.c
> +++ b/drivers/isimodem/call-barring.c
> @@ -48,6 +48,28 @@ struct barr_data {
>  	GIsiClient *client;
>  };

> 
> +	DBG("lock code %s (%u) old password %s new password %s\n",
> +	    lock, ss_code, old_passwd, new_passwd);

Here is an instance of whitespace error.

> -	if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
> +	if (cbd &&
> +	    g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
>  				set_passwd_resp_cb, cbd))
>  		return;

Here's another one..

>  enum ss_codes {
> -	SS_GSM_ALL_FORWARDINGS = 0x02,
> -	SS_GSM_ALL_COND_FORWARDINGS = 0x04,
> -	SS_GSM_FORW_UNCONDITIONAL = 0x15,
> -	SS_GSM_BARR_ALL_OUT = 0x21,
> -	SS_GSM_BARR_ALL_IN = 0x23,
> -	SS_GSM_CALL_WAITING = 0x2B,
> -	SS_GSM_FORW_NO_REPLY = 0x3D,
> -	SS_GSM_FORW_NO_REACH = 0x3E,
> -	SS_GSM_FORW_BUSY = 0x43,
> -	SS_GSM_ALL_BARRINGS = 0x014A,
> -	SS_GSM_BARR_OUT_INTER = 0x014B,
> -	SS_GSM_BARR_OUT_INTER_EXC_HOME = 0x014C,
> -	SS_GSM_BARR_ALL_IN_ROAM = 0x015F
> +	SS_GSM_ALL_FORWARDINGS = 002,
> +	SS_GSM_ALL_COND_FORWARDINGS = 004,

Are you sure this isn't octal syntax?  It still works, but you might simply 
use 2 and 4  here.

> +	SS_GSM_FORW_UNCONDITIONAL = 21,
> +	SS_GSM_BARR_ALL_OUT = 33,
> +	SS_GSM_OUTGOING_BARR_SERV = 333,
> +	SS_GSM_INCOMING_BARR_SERV = 353,
> +	SS_GSM_BARR_ALL_IN = 35,
> +	SS_GSM_CALL_WAITING = 43,
> +	SS_GSM_FORW_NO_REPLY = 61,
> +	SS_GSM_FORW_NO_REACH = 62,
> +	SS_GSM_FORW_BUSY = 67,
> +	SS_GSM_ALL_BARRINGS = 330,
> +	SS_GSM_BARR_OUT_INTER = 331,
> +	SS_GSM_BARR_OUT_INTER_EXC_HOME = 332,
> +	SS_GSM_BARR_ALL_IN_ROAM = 351,
>  };

From now on we'll require all enum values to be tab aligned so they're a bit 
easier to read.  See src/stkutil.h for reference.

Regards,
-Denis

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

* Re: [PATCH] Fix: simplify isimodem call-barring driver.
  2010-03-23 21:53 ` Denis Kenzior
@ 2010-03-24  8:05   ` Aki Niemi
  2010-03-29 18:20   ` Pekka Pessi
  1 sibling, 0 replies; 7+ messages in thread
From: Aki Niemi @ 2010-03-24  8:05 UTC (permalink / raw)
  To: ofono

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

ti, 2010-03-23 kello 22:53 +0100, ext Denis Kenzior kirjoitti:
> Secondly, please keep your patches whitespace clean, there are several cases 
> of spaces being used instead of tabs for indentation.

Pekka is an emacs guy, and emacs likes syntactic indentation a lot. I'm
using this custom mode with fairly good results:

(defun linux-c-mode ()
  "C mode with adjusted defaults for use with the Linux kernel."
  (interactive)
  (c-mode)
  (c-set-style "K&R")
  (setq c-syntactic-indentation nil)
  (setq c-basic-offset 8))

Cheers,
Aki


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

* Re: [PATCH] Fix: simplify isimodem call-barring driver.
  2010-03-23 21:53 ` Denis Kenzior
  2010-03-24  8:05   ` Aki Niemi
@ 2010-03-29 18:20   ` Pekka Pessi
  1 sibling, 0 replies; 7+ messages in thread
From: Pekka Pessi @ 2010-03-29 18:20 UTC (permalink / raw)
  To: ofono

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

2010/3/23 Denis Kenzior <denkenz@gmail.com>:
>> Add support for lock codes AG and AC (MMI codes 333 and 353. respectively).
>
> First of all, please keep your commit messages less than 72 characters long
> and headings less than 50 characters long.

Is there any git setting or nice filter which could complain
automatically if the limits are reached?

>> +     SS_GSM_ALL_FORWARDINGS = 002,
>> +     SS_GSM_ALL_COND_FORWARDINGS = 004,
>
> Are you sure this isn't octal syntax?  It still works, but you might simply
> use 2 and 4  here.

Those values equal to MMI codes (002 and 004); I just think it is a
good idea to show it.

> From now on we'll require all enum values to be tab aligned so they're a bit
> easier to read.  See src/stkutil.h for reference.

I've reformatted <ss.h>.

-- 
Pekka.Pessi mail at nokia.com

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

* Re: [PATCH] Fix: simplify isimodem call-barring driver.
  2010-03-29 18:17 ppessi
@ 2010-03-29 20:40 ` Denis Kenzior
  0 siblings, 0 replies; 7+ messages in thread
From: Denis Kenzior @ 2010-03-29 20:40 UTC (permalink / raw)
  To: ofono

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

Hi Pekka,

> From: Pekka Pessi <Pekka.Pessi@nokia.com>
> 
> Add support for lock codes AG and AC (MMI codes 333 and 353,
> respectively). Use decimal MMI codes in <ss.h>.
> ---
>  drivers/isimodem/call-barring.c |  153
>  ++++++++++++--------------------------- drivers/isimodem/ss.h           | 
>  142 ++++++++++++++++++------------------ 2 files changed, 120
>  insertions(+), 175 deletions(-)

Patch has now been applied, thanks.

Regards,
-Denis

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

* [PATCH] Fix: simplify isimodem call-barring driver.
@ 2010-03-29 18:17 ppessi
  2010-03-29 20:40 ` Denis Kenzior
  0 siblings, 1 reply; 7+ messages in thread
From: ppessi @ 2010-03-29 18:17 UTC (permalink / raw)
  To: ofono

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

From: Pekka Pessi <Pekka.Pessi@nokia.com>

Add support for lock codes AG and AC (MMI codes 333 and 353,
respectively). Use decimal MMI codes in <ss.h>.
---
 drivers/isimodem/call-barring.c |  153 ++++++++++++---------------------------
 drivers/isimodem/ss.h           |  142 ++++++++++++++++++------------------
 2 files changed, 120 insertions(+), 175 deletions(-)

diff --git a/drivers/isimodem/call-barring.c b/drivers/isimodem/call-barring.c
index 6487ae8..b8b175d 100644
--- a/drivers/isimodem/call-barring.c
+++ b/drivers/isimodem/call-barring.c
@@ -48,6 +48,28 @@ struct barr_data {
 	GIsiClient *client;
 };
 
+static int lock_code_to_mmi(char const *lock)
+{
+	if (strcmp(lock, "AO") == 0)
+		return SS_GSM_BARR_ALL_OUT;
+	else if (strcmp(lock, "OI") == 0)
+		return SS_GSM_BARR_OUT_INTER;
+	else if (strcmp(lock, "OX") == 0)
+		return SS_GSM_BARR_OUT_INTER_EXC_HOME;
+	else if (strcmp(lock, "AI") == 0)
+		return SS_GSM_BARR_ALL_IN;
+	else if (strcmp(lock, "IR") == 0)
+		return SS_GSM_BARR_ALL_IN_ROAM;
+	else if (strcmp(lock, "AB") == 0)
+		return SS_GSM_ALL_BARRINGS;
+	else if (strcmp(lock, "AG") == 0)
+		return SS_GSM_OUTGOING_BARR_SERV;
+	else if (strcmp(lock, "AC") == 0)
+		return SS_GSM_INCOMING_BARR_SERV;
+	else
+		return 0;
+}
+
 static bool set_resp_cb(GIsiClient *client, const void *restrict data,
 				size_t len, uint16_t object, void *opaque)
 {
@@ -84,19 +106,19 @@ static void isi_set(struct ofono_call_barring *barr, const char *lock,
 {
 	struct barr_data *bd = ofono_call_barring_get_data(barr);
 	struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
-	int ss_code;
-	char *ucs2 = NULL;
+	int ss_code = lock_code_to_mmi(lock);
 
 	unsigned char msg[] = {
 		SS_SERVICE_REQ,
 		enable ? SS_ACTIVATION : SS_DEACTIVATION,
 		SS_ALL_TELE_AND_BEARER,
-		0, 0,				/* Supplementary services code */
-		SS_SEND_ADDITIONAL_INFO,
+		ss_code >> 8, ss_code & 0xFF,	/* Supplementary services code */
+		SS_SEND_ADDITIONAL_INFO,	/* ? */
 		1,				/* Subblock count */
 		SS_GSM_PASSWORD,
 		28,				/* Subblock length */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* Password */
+		0, passwd[0], 0, passwd[1],	/* Password */
+		0, passwd[2], 0, passwd[3],
 		0, 0, 0, 0, 0, 0, 0, 0,		/* Filler */
 		0, 0, 0, 0, 0, 0, 0, 0,		/* Filler */
 		0, 0				/* Filler */
@@ -105,43 +127,10 @@ static void isi_set(struct ofono_call_barring *barr, const char *lock,
 	DBG("lock code %s enable %d class %d password %s\n",
 		lock, enable, cls, passwd);
 
-	if (!cbd || !passwd || strlen(passwd) > 4 || cls != 7)
-		goto error;
-
-	if (strcmp(lock, "AO") == 0)
-		ss_code = SS_GSM_BARR_ALL_OUT;
-	else if (strcmp(lock, "OI") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER;
-	else if (strcmp(lock, "OX") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER_EXC_HOME;
-	else if (strcmp(lock, "AI") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN;
-	else if (strcmp(lock, "IR") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN_ROAM;
-	else if (strcmp(lock, "AB") == 0)
-		ss_code = SS_GSM_ALL_BARRINGS;
-	else if (strcmp(lock, "AG") == 0)
-		ss_code = SS_GSM_BARR_ALL_OUT;
-	else if (strcmp(lock, "AC") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN;
-	else
-		goto error;
-
-	msg[3] = ss_code >> 8;
-	msg[4] = ss_code & 0xFF;
-
-	ucs2 = g_convert(passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
-				NULL, NULL, NULL);
-	if (ucs2 == NULL)
-		goto error;
-
-	memcpy((char *)msg + 9, ucs2, 8);
-	g_free(ucs2);
-
-	if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
-				set_resp_cb, cbd))
+	if (cbd && g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
+					set_resp_cb, cbd))
 		return;
-error:
+
 	CALLBACK_WITH_FAILURE(cb, data);
 	g_free(cbd);
 }
@@ -267,43 +256,23 @@ static void isi_query(struct ofono_call_barring *barr, const char *lock, int cls
 {
 	struct barr_data *bd = ofono_call_barring_get_data(barr);
 	struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
-	int ss_code;
+	int ss_code = lock_code_to_mmi(lock);
 
 	unsigned char msg[] = {
 		SS_SERVICE_REQ,
 		SS_INTERROGATION,
 		SS_ALL_TELE_AND_BEARER,
-		0, 0,				/* Supplementary services code */
-		SS_SEND_ADDITIONAL_INFO,
+		ss_code >> 8, ss_code & 0xFF,	/* Supplementary services code */
+		SS_SEND_ADDITIONAL_INFO,	/* Get BER-encoded result, too */
 		0				/* Subblock count */
 	};
 
-	DBG("barring query lock code %s class %d\n", lock, cls);
-
-	if (!cbd || cls != 7)
-		goto error;
-
-	if (strcmp(lock, "AO") == 0)
-		ss_code = SS_GSM_BARR_ALL_OUT;
-	else if (strcmp(lock, "OI") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER;
-	else if (strcmp(lock, "OX") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER_EXC_HOME;
-	else if (strcmp(lock, "AI") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN;
-	else if (strcmp(lock, "IR") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN_ROAM;
-	else
-		goto error;
-
-	msg[3] = ss_code >> 8;
-	msg[4] = ss_code & 0xFF;
+	DBG("barring query lock code %s\n", lock);
 
-	if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
-				query_resp_cb, cbd))
+	if (cbd && g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
+					query_resp_cb, cbd))
 		return;
 
-error:
 	CALLBACK_WITH_FAILURE(cb, 0, data);
 	g_free(cbd);
 }
@@ -343,60 +312,34 @@ static void isi_set_passwd(struct ofono_call_barring *barr, const char *lock,
 {
 	struct barr_data *bd = ofono_call_barring_get_data(barr);
 	struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
-	int ss_code;
-	char *ucs2 = NULL;
+	int ss_code = lock_code_to_mmi(lock);
 
 	unsigned char msg[] = {
 		SS_SERVICE_REQ,
 		SS_GSM_PASSWORD_REGISTRATION,
 		SS_ALL_TELE_AND_BEARER,
-		0, 0,				/* Supplementary services code */
+		ss_code >> 8, ss_code & 0xFF,	/* Supplementary services code */
 		SS_SEND_ADDITIONAL_INFO,
 		1,				/* Subblock count */
 		SS_GSM_PASSWORD,
 		28,				/* Subblock length */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* Old password */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* New password */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* New password */
+		0, old_passwd[0], 0, old_passwd[1],
+		0, old_passwd[2], 0, old_passwd[3],
+		0, new_passwd[0], 0, new_passwd[1],
+		0, new_passwd[2], 0, new_passwd[3],
+		0, new_passwd[0], 0, new_passwd[1],
+		0, new_passwd[2], 0, new_passwd[3],
 		0, 0				/* Filler */
 	};
 
-	if (!cbd || strlen(old_passwd) > 4 || strlen(new_passwd) > 4)
-		goto error;
-
-	DBG("lock code %s old password %s new password %s\n",
-		lock, old_passwd, new_passwd);
-
-	if (strcmp(lock, "AB") == 0)
-		ss_code = SS_GSM_ALL_BARRINGS;
-	else
-		goto error;
-
-	msg[3] = ss_code >> 8;
-	msg[4] = ss_code & 0xFF;
+	DBG("lock code %s (%u) old password %s new password %s\n",
+		lock, ss_code, old_passwd, new_passwd);
 
-	ucs2 = g_convert(old_passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
-				NULL, NULL, NULL);
-	if (ucs2 == NULL)
-		goto error;
-
-	memcpy((char *)msg + 9, ucs2, 8);
-	g_free(ucs2);
-
-	ucs2 = g_convert(new_passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
-				NULL, NULL, NULL);
-	if (ucs2 == NULL)
-		goto error;
-
-	memcpy((char *)msg + 17, ucs2, 8);
-	memcpy((char *)msg + 25, ucs2, 8);
-	g_free(ucs2);
-
-	if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
+	if (cbd &&
+		g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
 				set_passwd_resp_cb, cbd))
 		return;
 
-error:
 	CALLBACK_WITH_FAILURE(cb, data);
 	g_free(cbd);
 }
diff --git a/drivers/isimodem/ss.h b/drivers/isimodem/ss.h
index 7c20bcc..93554db 100644
--- a/drivers/isimodem/ss.h
+++ b/drivers/isimodem/ss.h
@@ -24,102 +24,104 @@
 #ifndef __ISIMODEM_SS_H
 #define __ISIMODEM_SS_H
 
-#define PN_SS			0x06
-#define SS_TIMEOUT		15
-#define SS_MAX_USSD_LENGTH	160
+#define PN_SS				0x06
+#define SS_TIMEOUT			15
+#define SS_MAX_USSD_LENGTH		160
 
 enum ss_message_id {
-	SS_SERVICE_REQ = 0x00,
-	SS_SERVICE_COMPLETED_RESP = 0x01,
-	SS_SERVICE_FAILED_RESP = 0x02,
-	SS_GSM_USSD_SEND_REQ = 0x04,
-	SS_GSM_USSD_SEND_RESP = 0x05,
-	SS_GSM_USSD_RECEIVE_IND = 0x06,
-	SS_STATUS_IND = 0x09,
-	SS_COMMON_MESSAGE = 0xF0
+	SS_SERVICE_REQ = 			0x00,
+	SS_SERVICE_COMPLETED_RESP =		0x01,
+	SS_SERVICE_FAILED_RESP =		0x02,
+	SS_GSM_USSD_SEND_REQ =			0x04,
+	SS_GSM_USSD_SEND_RESP =			0x05,
+	SS_GSM_USSD_RECEIVE_IND =		0x06,
+	SS_STATUS_IND =				0x09,
+	SS_COMMON_MESSAGE =			0xF0
 };
 
 enum ss_ussd_type {
-	SS_GSM_USSD_MT_REPLY = 0x01,
-	SS_GSM_USSD_COMMAND = 0x02,
-	SS_GSM_USSD_REQUEST = 0x03,
-	SS_GSM_USSD_NOTIFY = 0x04,
-	SS_GSM_USSD_END = 0x05
+	SS_GSM_USSD_MT_REPLY =			0x01,
+	SS_GSM_USSD_COMMAND =			0x02,
+	SS_GSM_USSD_REQUEST =			0x03,
+	SS_GSM_USSD_NOTIFY =			0x04,
+	SS_GSM_USSD_END =			0x05
 };
 
 enum ss_ussd_status {
-	SS_GSM_STATUS_REQUEST_USSD_START = 0x02,
-	SS_GSM_STATUS_REQUEST_USSD_STOP = 0x03,
-	SS_GSM_STATUS_REQUEST_USSD_FAILED = 0x04
+	SS_GSM_STATUS_REQUEST_USSD_START =	0x02,
+	SS_GSM_STATUS_REQUEST_USSD_STOP =	0x03,
+	SS_GSM_STATUS_REQUEST_USSD_FAILED =	0x04
 };
 
 enum ss_operations {
-	SS_ACTIVATION = 0x01,
-	SS_DEACTIVATION = 0x02,
-	SS_REGISTRATION = 0x03,
-	SS_ERASURE = 0x04,
-	SS_INTERROGATION = 0x05,
-	SS_GSM_PASSWORD_REGISTRATION = 0x06
+	SS_ACTIVATION =				0x01,
+	SS_DEACTIVATION =			0x02,
+	SS_REGISTRATION =			0x03,
+	SS_ERASURE =				0x04,
+	SS_INTERROGATION =			0x05,
+	SS_GSM_PASSWORD_REGISTRATION =		0x06
 };
 
 enum ss_basic_service_codes {
-	SS_ALL_TELE_AND_BEARER = 0x00,
-	SS_GSM_ALL_TELE = 0x0A,
-	SS_GSM_TELEPHONY = 0x0B,
-	SS_GSM_ALL_DATA_TELE = 0x0C,
-	SS_GSM_FACSIMILE = 0x0D,
-	SS_GSM_SMS = 0x10,
-	SS_GSM_VOICE_GROUP = 0x11,
-	SS_GSM_ALL_TELE_EXC_SMS = 0x13,
-	SS_GSM_ALL_BEARER = 0x14,
-	SS_GSM_ALL_ASYNC = 0x15,
-	SS_GSM_ALL_SYNC = 0x16,
-	SS_GSM_ALL_DATA_CIRCUIT_SYNC = 0x18,
-	SS_GSM_ALL_DATA_CIRCUIT_ASYNC = 0x19,
-	SS_GSM_ALL_DATA_PACKET_SYNC = 0x1A,
-	SS_GSM_ALL_PAD_ACCESS = 0x1B
+	SS_ALL_TELE_AND_BEARER =		0,
+	SS_GSM_ALL_TELE =			10,
+	SS_GSM_TELEPHONY =			11,
+	SS_GSM_ALL_DATA_TELE =			12,
+	SS_GSM_FACSIMILE =			13,
+	SS_GSM_SMS =				16,
+	SS_GSM_VOICE_GROUP =			17,
+	SS_GSM_ALL_TELE_EXC_SMS =		19,
+	SS_GSM_ALL_BEARER =			20,
+	SS_GSM_ALL_ASYNC =			21,
+	SS_GSM_ALL_SYNC =			22,
+	SS_GSM_ALL_DATA_CIRCUIT_SYNC =		24,
+	SS_GSM_ALL_DATA_CIRCUIT_ASYNC =		25,
+	SS_GSM_ALL_DATA_PACKET_SYNC =		26,
+	SS_GSM_ALL_PAD_ACCESS =			27
 };
 
 enum ss_codes {
-	SS_GSM_ALL_FORWARDINGS = 0x02,
-	SS_GSM_ALL_COND_FORWARDINGS = 0x04,
-	SS_GSM_FORW_UNCONDITIONAL = 0x15,
-	SS_GSM_BARR_ALL_OUT = 0x21,
-	SS_GSM_BARR_ALL_IN = 0x23,
-	SS_GSM_CALL_WAITING = 0x2B,
-	SS_GSM_FORW_NO_REPLY = 0x3D,
-	SS_GSM_FORW_NO_REACH = 0x3E,
-	SS_GSM_FORW_BUSY = 0x43,
-	SS_GSM_ALL_BARRINGS = 0x014A,
-	SS_GSM_BARR_OUT_INTER = 0x014B,
-	SS_GSM_BARR_OUT_INTER_EXC_HOME = 0x014C,
-	SS_GSM_BARR_ALL_IN_ROAM = 0x015F
+	SS_GSM_ALL_FORWARDINGS =		002,
+	SS_GSM_ALL_COND_FORWARDINGS =		004,
+	SS_GSM_FORW_UNCONDITIONAL =		21,
+	SS_GSM_BARR_ALL_OUT =			33,
+	SS_GSM_OUTGOING_BARR_SERV =		333,
+	SS_GSM_INCOMING_BARR_SERV =		353,
+	SS_GSM_BARR_ALL_IN =			35,
+	SS_GSM_CALL_WAITING =			43,
+	SS_GSM_FORW_NO_REPLY =			61,
+	SS_GSM_FORW_NO_REACH =			62,
+	SS_GSM_FORW_BUSY =			67,
+	SS_GSM_ALL_BARRINGS =			330,
+	SS_GSM_BARR_OUT_INTER =			331,
+	SS_GSM_BARR_OUT_INTER_EXC_HOME =	332,
+	SS_GSM_BARR_ALL_IN_ROAM =		351,
 };
 
 enum ss_response_data {
-	SS_SEND_ADDITIONAL_INFO = 0x01
+	SS_SEND_ADDITIONAL_INFO =		0x01
 };
 
 enum ss_subblock {
-	SS_FORWARDING = 0x00,
-	SS_STATUS_RESULT = 0x01,
-	SS_GSM_PASSWORD = 0x03,
-	SS_GSM_FORWARDING_INFO = 0x04,
-	SS_GSM_FORWARDING_FEATURE = 0x05,
-	SS_GSM_DATA = 0x08,
-	SS_GSM_BSC_INFO = 0x09,
-	SS_GSM_PASSWORD_INFO = 0x0B,
-	SS_GSM_INDICATE_PASSWORD_ERROR = 0x0D,
-	SS_GSM_INDICATE_ERROR = 0x0E,
-	SS_GSM_ADDITIONAL_INFO = 0x2F,
-	SS_GSM_USSD_STRING = 0x32
+	SS_FORWARDING =				0x00,
+	SS_STATUS_RESULT =			0x01,
+	SS_GSM_PASSWORD =			0x03,
+	SS_GSM_FORWARDING_INFO =		0x04,
+	SS_GSM_FORWARDING_FEATURE =		0x05,
+	SS_GSM_DATA =				0x08,
+	SS_GSM_BSC_INFO =			0x09,
+	SS_GSM_PASSWORD_INFO =			0x0B,
+	SS_GSM_INDICATE_PASSWORD_ERROR =	0x0D,
+	SS_GSM_INDICATE_ERROR =			0x0E,
+	SS_GSM_ADDITIONAL_INFO =		0x2F,
+	SS_GSM_USSD_STRING =			0x32
 };
 
 enum ss_isi_cause {
-	SS_GSM_ACTIVE = 0x01,
-	SS_GSM_REGISTERED = 0x02,
-	SS_GSM_PROVISIONED = 0x04,
-	SS_GSM_QUIESCENT = 0x08
+	SS_GSM_ACTIVE =				0x01,
+	SS_GSM_REGISTERED =			0x02,
+	SS_GSM_PROVISIONED =			0x04,
+	SS_GSM_QUIESCENT =			0x08
 };
 
 #endif /* __ISIMODEM_SS_H */
-- 
1.6.3.3


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

* [PATCH] Fix: simplify isimodem call-barring driver.
@ 2010-03-29 18:15 ppessi
  0 siblings, 0 replies; 7+ messages in thread
From: ppessi @ 2010-03-29 18:15 UTC (permalink / raw)
  To: ofono

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

From: Pekka Pessi <Pekka.Pessi@nokia.com>

Add support for lock codes AG and AC (MMI codes 333 and 353. respectively).
Use decimal MMI codes in <ss.h>.
---
 drivers/isimodem/call-barring.c |  153 ++++++++++++---------------------------
 drivers/isimodem/ss.h           |  142 ++++++++++++++++++------------------
 2 files changed, 120 insertions(+), 175 deletions(-)

diff --git a/drivers/isimodem/call-barring.c b/drivers/isimodem/call-barring.c
index 6487ae8..b8b175d 100644
--- a/drivers/isimodem/call-barring.c
+++ b/drivers/isimodem/call-barring.c
@@ -48,6 +48,28 @@ struct barr_data {
 	GIsiClient *client;
 };
 
+static int lock_code_to_mmi(char const *lock)
+{
+	if (strcmp(lock, "AO") == 0)
+		return SS_GSM_BARR_ALL_OUT;
+	else if (strcmp(lock, "OI") == 0)
+		return SS_GSM_BARR_OUT_INTER;
+	else if (strcmp(lock, "OX") == 0)
+		return SS_GSM_BARR_OUT_INTER_EXC_HOME;
+	else if (strcmp(lock, "AI") == 0)
+		return SS_GSM_BARR_ALL_IN;
+	else if (strcmp(lock, "IR") == 0)
+		return SS_GSM_BARR_ALL_IN_ROAM;
+	else if (strcmp(lock, "AB") == 0)
+		return SS_GSM_ALL_BARRINGS;
+	else if (strcmp(lock, "AG") == 0)
+		return SS_GSM_OUTGOING_BARR_SERV;
+	else if (strcmp(lock, "AC") == 0)
+		return SS_GSM_INCOMING_BARR_SERV;
+	else
+		return 0;
+}
+
 static bool set_resp_cb(GIsiClient *client, const void *restrict data,
 				size_t len, uint16_t object, void *opaque)
 {
@@ -84,19 +106,19 @@ static void isi_set(struct ofono_call_barring *barr, const char *lock,
 {
 	struct barr_data *bd = ofono_call_barring_get_data(barr);
 	struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
-	int ss_code;
-	char *ucs2 = NULL;
+	int ss_code = lock_code_to_mmi(lock);
 
 	unsigned char msg[] = {
 		SS_SERVICE_REQ,
 		enable ? SS_ACTIVATION : SS_DEACTIVATION,
 		SS_ALL_TELE_AND_BEARER,
-		0, 0,				/* Supplementary services code */
-		SS_SEND_ADDITIONAL_INFO,
+		ss_code >> 8, ss_code & 0xFF,	/* Supplementary services code */
+		SS_SEND_ADDITIONAL_INFO,	/* ? */
 		1,				/* Subblock count */
 		SS_GSM_PASSWORD,
 		28,				/* Subblock length */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* Password */
+		0, passwd[0], 0, passwd[1],	/* Password */
+		0, passwd[2], 0, passwd[3],
 		0, 0, 0, 0, 0, 0, 0, 0,		/* Filler */
 		0, 0, 0, 0, 0, 0, 0, 0,		/* Filler */
 		0, 0				/* Filler */
@@ -105,43 +127,10 @@ static void isi_set(struct ofono_call_barring *barr, const char *lock,
 	DBG("lock code %s enable %d class %d password %s\n",
 		lock, enable, cls, passwd);
 
-	if (!cbd || !passwd || strlen(passwd) > 4 || cls != 7)
-		goto error;
-
-	if (strcmp(lock, "AO") == 0)
-		ss_code = SS_GSM_BARR_ALL_OUT;
-	else if (strcmp(lock, "OI") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER;
-	else if (strcmp(lock, "OX") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER_EXC_HOME;
-	else if (strcmp(lock, "AI") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN;
-	else if (strcmp(lock, "IR") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN_ROAM;
-	else if (strcmp(lock, "AB") == 0)
-		ss_code = SS_GSM_ALL_BARRINGS;
-	else if (strcmp(lock, "AG") == 0)
-		ss_code = SS_GSM_BARR_ALL_OUT;
-	else if (strcmp(lock, "AC") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN;
-	else
-		goto error;
-
-	msg[3] = ss_code >> 8;
-	msg[4] = ss_code & 0xFF;
-
-	ucs2 = g_convert(passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
-				NULL, NULL, NULL);
-	if (ucs2 == NULL)
-		goto error;
-
-	memcpy((char *)msg + 9, ucs2, 8);
-	g_free(ucs2);
-
-	if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
-				set_resp_cb, cbd))
+	if (cbd && g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
+					set_resp_cb, cbd))
 		return;
-error:
+
 	CALLBACK_WITH_FAILURE(cb, data);
 	g_free(cbd);
 }
@@ -267,43 +256,23 @@ static void isi_query(struct ofono_call_barring *barr, const char *lock, int cls
 {
 	struct barr_data *bd = ofono_call_barring_get_data(barr);
 	struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
-	int ss_code;
+	int ss_code = lock_code_to_mmi(lock);
 
 	unsigned char msg[] = {
 		SS_SERVICE_REQ,
 		SS_INTERROGATION,
 		SS_ALL_TELE_AND_BEARER,
-		0, 0,				/* Supplementary services code */
-		SS_SEND_ADDITIONAL_INFO,
+		ss_code >> 8, ss_code & 0xFF,	/* Supplementary services code */
+		SS_SEND_ADDITIONAL_INFO,	/* Get BER-encoded result, too */
 		0				/* Subblock count */
 	};
 
-	DBG("barring query lock code %s class %d\n", lock, cls);
-
-	if (!cbd || cls != 7)
-		goto error;
-
-	if (strcmp(lock, "AO") == 0)
-		ss_code = SS_GSM_BARR_ALL_OUT;
-	else if (strcmp(lock, "OI") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER;
-	else if (strcmp(lock, "OX") == 0)
-		ss_code = SS_GSM_BARR_OUT_INTER_EXC_HOME;
-	else if (strcmp(lock, "AI") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN;
-	else if (strcmp(lock, "IR") == 0)
-		ss_code = SS_GSM_BARR_ALL_IN_ROAM;
-	else
-		goto error;
-
-	msg[3] = ss_code >> 8;
-	msg[4] = ss_code & 0xFF;
+	DBG("barring query lock code %s\n", lock);
 
-	if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
-				query_resp_cb, cbd))
+	if (cbd && g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
+					query_resp_cb, cbd))
 		return;
 
-error:
 	CALLBACK_WITH_FAILURE(cb, 0, data);
 	g_free(cbd);
 }
@@ -343,60 +312,34 @@ static void isi_set_passwd(struct ofono_call_barring *barr, const char *lock,
 {
 	struct barr_data *bd = ofono_call_barring_get_data(barr);
 	struct isi_cb_data *cbd = isi_cb_data_new(barr, cb, data);
-	int ss_code;
-	char *ucs2 = NULL;
+	int ss_code = lock_code_to_mmi(lock);
 
 	unsigned char msg[] = {
 		SS_SERVICE_REQ,
 		SS_GSM_PASSWORD_REGISTRATION,
 		SS_ALL_TELE_AND_BEARER,
-		0, 0,				/* Supplementary services code */
+		ss_code >> 8, ss_code & 0xFF,	/* Supplementary services code */
 		SS_SEND_ADDITIONAL_INFO,
 		1,				/* Subblock count */
 		SS_GSM_PASSWORD,
 		28,				/* Subblock length */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* Old password */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* New password */
-		0, 0, 0, 0, 0, 0, 0, 0,		/* New password */
+		0, old_passwd[0], 0, old_passwd[1],
+		0, old_passwd[2], 0, old_passwd[3],
+		0, new_passwd[0], 0, new_passwd[1],
+		0, new_passwd[2], 0, new_passwd[3],
+		0, new_passwd[0], 0, new_passwd[1],
+		0, new_passwd[2], 0, new_passwd[3],
 		0, 0				/* Filler */
 	};
 
-	if (!cbd || strlen(old_passwd) > 4 || strlen(new_passwd) > 4)
-		goto error;
-
-	DBG("lock code %s old password %s new password %s\n",
-		lock, old_passwd, new_passwd);
-
-	if (strcmp(lock, "AB") == 0)
-		ss_code = SS_GSM_ALL_BARRINGS;
-	else
-		goto error;
-
-	msg[3] = ss_code >> 8;
-	msg[4] = ss_code & 0xFF;
+	DBG("lock code %s (%u) old password %s new password %s\n",
+		lock, ss_code, old_passwd, new_passwd);
 
-	ucs2 = g_convert(old_passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
-				NULL, NULL, NULL);
-	if (ucs2 == NULL)
-		goto error;
-
-	memcpy((char *)msg + 9, ucs2, 8);
-	g_free(ucs2);
-
-	ucs2 = g_convert(new_passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
-				NULL, NULL, NULL);
-	if (ucs2 == NULL)
-		goto error;
-
-	memcpy((char *)msg + 17, ucs2, 8);
-	memcpy((char *)msg + 25, ucs2, 8);
-	g_free(ucs2);
-
-	if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
+	if (cbd &&
+		g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
 				set_passwd_resp_cb, cbd))
 		return;
 
-error:
 	CALLBACK_WITH_FAILURE(cb, data);
 	g_free(cbd);
 }
diff --git a/drivers/isimodem/ss.h b/drivers/isimodem/ss.h
index 7c20bcc..93554db 100644
--- a/drivers/isimodem/ss.h
+++ b/drivers/isimodem/ss.h
@@ -24,102 +24,104 @@
 #ifndef __ISIMODEM_SS_H
 #define __ISIMODEM_SS_H
 
-#define PN_SS			0x06
-#define SS_TIMEOUT		15
-#define SS_MAX_USSD_LENGTH	160
+#define PN_SS				0x06
+#define SS_TIMEOUT			15
+#define SS_MAX_USSD_LENGTH		160
 
 enum ss_message_id {
-	SS_SERVICE_REQ = 0x00,
-	SS_SERVICE_COMPLETED_RESP = 0x01,
-	SS_SERVICE_FAILED_RESP = 0x02,
-	SS_GSM_USSD_SEND_REQ = 0x04,
-	SS_GSM_USSD_SEND_RESP = 0x05,
-	SS_GSM_USSD_RECEIVE_IND = 0x06,
-	SS_STATUS_IND = 0x09,
-	SS_COMMON_MESSAGE = 0xF0
+	SS_SERVICE_REQ = 			0x00,
+	SS_SERVICE_COMPLETED_RESP =		0x01,
+	SS_SERVICE_FAILED_RESP =		0x02,
+	SS_GSM_USSD_SEND_REQ =			0x04,
+	SS_GSM_USSD_SEND_RESP =			0x05,
+	SS_GSM_USSD_RECEIVE_IND =		0x06,
+	SS_STATUS_IND =				0x09,
+	SS_COMMON_MESSAGE =			0xF0
 };
 
 enum ss_ussd_type {
-	SS_GSM_USSD_MT_REPLY = 0x01,
-	SS_GSM_USSD_COMMAND = 0x02,
-	SS_GSM_USSD_REQUEST = 0x03,
-	SS_GSM_USSD_NOTIFY = 0x04,
-	SS_GSM_USSD_END = 0x05
+	SS_GSM_USSD_MT_REPLY =			0x01,
+	SS_GSM_USSD_COMMAND =			0x02,
+	SS_GSM_USSD_REQUEST =			0x03,
+	SS_GSM_USSD_NOTIFY =			0x04,
+	SS_GSM_USSD_END =			0x05
 };
 
 enum ss_ussd_status {
-	SS_GSM_STATUS_REQUEST_USSD_START = 0x02,
-	SS_GSM_STATUS_REQUEST_USSD_STOP = 0x03,
-	SS_GSM_STATUS_REQUEST_USSD_FAILED = 0x04
+	SS_GSM_STATUS_REQUEST_USSD_START =	0x02,
+	SS_GSM_STATUS_REQUEST_USSD_STOP =	0x03,
+	SS_GSM_STATUS_REQUEST_USSD_FAILED =	0x04
 };
 
 enum ss_operations {
-	SS_ACTIVATION = 0x01,
-	SS_DEACTIVATION = 0x02,
-	SS_REGISTRATION = 0x03,
-	SS_ERASURE = 0x04,
-	SS_INTERROGATION = 0x05,
-	SS_GSM_PASSWORD_REGISTRATION = 0x06
+	SS_ACTIVATION =				0x01,
+	SS_DEACTIVATION =			0x02,
+	SS_REGISTRATION =			0x03,
+	SS_ERASURE =				0x04,
+	SS_INTERROGATION =			0x05,
+	SS_GSM_PASSWORD_REGISTRATION =		0x06
 };
 
 enum ss_basic_service_codes {
-	SS_ALL_TELE_AND_BEARER = 0x00,
-	SS_GSM_ALL_TELE = 0x0A,
-	SS_GSM_TELEPHONY = 0x0B,
-	SS_GSM_ALL_DATA_TELE = 0x0C,
-	SS_GSM_FACSIMILE = 0x0D,
-	SS_GSM_SMS = 0x10,
-	SS_GSM_VOICE_GROUP = 0x11,
-	SS_GSM_ALL_TELE_EXC_SMS = 0x13,
-	SS_GSM_ALL_BEARER = 0x14,
-	SS_GSM_ALL_ASYNC = 0x15,
-	SS_GSM_ALL_SYNC = 0x16,
-	SS_GSM_ALL_DATA_CIRCUIT_SYNC = 0x18,
-	SS_GSM_ALL_DATA_CIRCUIT_ASYNC = 0x19,
-	SS_GSM_ALL_DATA_PACKET_SYNC = 0x1A,
-	SS_GSM_ALL_PAD_ACCESS = 0x1B
+	SS_ALL_TELE_AND_BEARER =		0,
+	SS_GSM_ALL_TELE =			10,
+	SS_GSM_TELEPHONY =			11,
+	SS_GSM_ALL_DATA_TELE =			12,
+	SS_GSM_FACSIMILE =			13,
+	SS_GSM_SMS =				16,
+	SS_GSM_VOICE_GROUP =			17,
+	SS_GSM_ALL_TELE_EXC_SMS =		19,
+	SS_GSM_ALL_BEARER =			20,
+	SS_GSM_ALL_ASYNC =			21,
+	SS_GSM_ALL_SYNC =			22,
+	SS_GSM_ALL_DATA_CIRCUIT_SYNC =		24,
+	SS_GSM_ALL_DATA_CIRCUIT_ASYNC =		25,
+	SS_GSM_ALL_DATA_PACKET_SYNC =		26,
+	SS_GSM_ALL_PAD_ACCESS =			27
 };
 
 enum ss_codes {
-	SS_GSM_ALL_FORWARDINGS = 0x02,
-	SS_GSM_ALL_COND_FORWARDINGS = 0x04,
-	SS_GSM_FORW_UNCONDITIONAL = 0x15,
-	SS_GSM_BARR_ALL_OUT = 0x21,
-	SS_GSM_BARR_ALL_IN = 0x23,
-	SS_GSM_CALL_WAITING = 0x2B,
-	SS_GSM_FORW_NO_REPLY = 0x3D,
-	SS_GSM_FORW_NO_REACH = 0x3E,
-	SS_GSM_FORW_BUSY = 0x43,
-	SS_GSM_ALL_BARRINGS = 0x014A,
-	SS_GSM_BARR_OUT_INTER = 0x014B,
-	SS_GSM_BARR_OUT_INTER_EXC_HOME = 0x014C,
-	SS_GSM_BARR_ALL_IN_ROAM = 0x015F
+	SS_GSM_ALL_FORWARDINGS =		002,
+	SS_GSM_ALL_COND_FORWARDINGS =		004,
+	SS_GSM_FORW_UNCONDITIONAL =		21,
+	SS_GSM_BARR_ALL_OUT =			33,
+	SS_GSM_OUTGOING_BARR_SERV =		333,
+	SS_GSM_INCOMING_BARR_SERV =		353,
+	SS_GSM_BARR_ALL_IN =			35,
+	SS_GSM_CALL_WAITING =			43,
+	SS_GSM_FORW_NO_REPLY =			61,
+	SS_GSM_FORW_NO_REACH =			62,
+	SS_GSM_FORW_BUSY =			67,
+	SS_GSM_ALL_BARRINGS =			330,
+	SS_GSM_BARR_OUT_INTER =			331,
+	SS_GSM_BARR_OUT_INTER_EXC_HOME =	332,
+	SS_GSM_BARR_ALL_IN_ROAM =		351,
 };
 
 enum ss_response_data {
-	SS_SEND_ADDITIONAL_INFO = 0x01
+	SS_SEND_ADDITIONAL_INFO =		0x01
 };
 
 enum ss_subblock {
-	SS_FORWARDING = 0x00,
-	SS_STATUS_RESULT = 0x01,
-	SS_GSM_PASSWORD = 0x03,
-	SS_GSM_FORWARDING_INFO = 0x04,
-	SS_GSM_FORWARDING_FEATURE = 0x05,
-	SS_GSM_DATA = 0x08,
-	SS_GSM_BSC_INFO = 0x09,
-	SS_GSM_PASSWORD_INFO = 0x0B,
-	SS_GSM_INDICATE_PASSWORD_ERROR = 0x0D,
-	SS_GSM_INDICATE_ERROR = 0x0E,
-	SS_GSM_ADDITIONAL_INFO = 0x2F,
-	SS_GSM_USSD_STRING = 0x32
+	SS_FORWARDING =				0x00,
+	SS_STATUS_RESULT =			0x01,
+	SS_GSM_PASSWORD =			0x03,
+	SS_GSM_FORWARDING_INFO =		0x04,
+	SS_GSM_FORWARDING_FEATURE =		0x05,
+	SS_GSM_DATA =				0x08,
+	SS_GSM_BSC_INFO =			0x09,
+	SS_GSM_PASSWORD_INFO =			0x0B,
+	SS_GSM_INDICATE_PASSWORD_ERROR =	0x0D,
+	SS_GSM_INDICATE_ERROR =			0x0E,
+	SS_GSM_ADDITIONAL_INFO =		0x2F,
+	SS_GSM_USSD_STRING =			0x32
 };
 
 enum ss_isi_cause {
-	SS_GSM_ACTIVE = 0x01,
-	SS_GSM_REGISTERED = 0x02,
-	SS_GSM_PROVISIONED = 0x04,
-	SS_GSM_QUIESCENT = 0x08
+	SS_GSM_ACTIVE =				0x01,
+	SS_GSM_REGISTERED =			0x02,
+	SS_GSM_PROVISIONED =			0x04,
+	SS_GSM_QUIESCENT =			0x08
 };
 
 #endif /* __ISIMODEM_SS_H */
-- 
1.6.3.3


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

end of thread, other threads:[~2010-03-29 20:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-23 17:46 [PATCH] Fix: simplify isimodem call-barring driver ppessi
2010-03-23 21:53 ` Denis Kenzior
2010-03-24  8:05   ` Aki Niemi
2010-03-29 18:20   ` Pekka Pessi
2010-03-29 18:15 ppessi
2010-03-29 18:17 ppessi
2010-03-29 20:40 ` 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.