From: ppessi@gmail.com
To: ofono@ofono.org
Subject: [PATCH 7/7] Fix: isimodem handling of call barring services.
Date: Thu, 18 Mar 2010 16:44:31 +0200 [thread overview]
Message-ID: <1268923471-29059-7-git-send-email-ppessi@gmail.com> (raw)
In-Reply-To: <1268923471-29059-6-git-send-email-ppessi@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6068 bytes --]
From: Pekka Pessi <Pekka.Pessi@nokia.com>
Signed-off-by: Pekka Pessi <Pekka.Pessi@nokia.com>
---
drivers/isimodem/call-barring.c | 64 ++++++++++++++++++++------------------
drivers/isimodem/ss.h | 28 +++++++++--------
2 files changed, 49 insertions(+), 43 deletions(-)
diff --git a/drivers/isimodem/call-barring.c b/drivers/isimodem/call-barring.c
index 6487ae8..6261b23 100644
--- a/drivers/isimodem/call-barring.c
+++ b/drivers/isimodem/call-barring.c
@@ -85,14 +85,13 @@ 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;
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_SEND_ADDITIONAL_INFO, /* ? */
1, /* Subblock count */
SS_GSM_PASSWORD,
28, /* Subblock length */
@@ -105,7 +104,9 @@ 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)
+ if (!cbd || !lock)
+ goto error;
+ if (!passwd || strlen(passwd) != 4 || strspn(passwd, "0123456789") != 4)
goto error;
if (strcmp(lock, "AO") == 0)
@@ -120,23 +121,23 @@ static void isi_set(struct ofono_call_barring *barr, const char *lock,
ss_code = SS_GSM_BARR_ALL_IN_ROAM;
else if (strcmp(lock, "AB") == 0)
ss_code = SS_GSM_ALL_BARRINGS;
+ else if (enable)
+ /* Only Deactivate supports AG (333) and AC (353) */
+ goto error;
else if (strcmp(lock, "AG") == 0)
- ss_code = SS_GSM_BARR_ALL_OUT;
+ ss_code = SS_GSM_OUTGOING_BARR_SERV;
else if (strcmp(lock, "AC") == 0)
- ss_code = SS_GSM_BARR_ALL_IN;
+ ss_code = SS_GSM_INCOMING_BARR_SERV;
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);
+ msg[10] = passwd[0];
+ msg[12] = passwd[1];
+ msg[14] = passwd[2];
+ msg[16] = passwd[4];
if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
set_resp_cb, cbd))
@@ -274,13 +275,13 @@ static void isi_query(struct ofono_call_barring *barr, const char *lock, int cls
SS_INTERROGATION,
SS_ALL_TELE_AND_BEARER,
0, 0, /* Supplementary services code */
- SS_SEND_ADDITIONAL_INFO,
+ 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)
+ if (!cbd)
goto error;
if (strcmp(lock, "AO") == 0)
@@ -344,7 +345,6 @@ 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;
unsigned char msg[] = {
SS_SERVICE_REQ,
@@ -361,7 +361,11 @@ static void isi_set_passwd(struct ofono_call_barring *barr, const char *lock,
0, 0 /* Filler */
};
- if (!cbd || strlen(old_passwd) > 4 || strlen(new_passwd) > 4)
+ if (!cbd)
+ goto error;
+ if (strlen(old_passwd) != 4 || strspn(old_passwd, "0123456789") != 4)
+ goto error;
+ if (strlen(new_passwd) != 4 || strspn(new_passwd, "0123456789") != 4)
goto error;
DBG("lock code %s old password %s new password %s\n",
@@ -369,28 +373,28 @@ static void isi_set_passwd(struct ofono_call_barring *barr, const char *lock,
if (strcmp(lock, "AB") == 0)
ss_code = SS_GSM_ALL_BARRINGS;
+ else if (strcmp(lock, "") == 0)
+ ss_code = 0;
else
goto error;
msg[3] = ss_code >> 8;
msg[4] = ss_code & 0xFF;
- 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);
+ msg[10] = old_passwd[0];
+ msg[12] = old_passwd[1];
+ msg[14] = old_passwd[2];
+ msg[16] = old_passwd[4];
- ucs2 = g_convert(new_passwd, 4, "UCS-2BE", "UTF-8//TRANSLIT",
- NULL, NULL, NULL);
- if (ucs2 == NULL)
- goto error;
+ msg[18] = new_passwd[0];
+ msg[20] = new_passwd[1];
+ msg[22] = new_passwd[2];
+ msg[24] = new_passwd[4];
- memcpy((char *)msg + 17, ucs2, 8);
- memcpy((char *)msg + 25, ucs2, 8);
- g_free(ucs2);
+ msg[26] = new_passwd[0];
+ msg[28] = new_passwd[1];
+ msg[30] = new_passwd[2];
+ msg[32] = new_passwd[4];
if (g_isi_request_make(bd->client, msg, sizeof(msg), SS_TIMEOUT,
set_passwd_resp_cb, 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
next prev parent reply other threads:[~2010-03-18 14:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-18 14:44 [PATCH 1/7] Barring services can only be activated/deactivated ppessi
2010-03-18 14:44 ` [PATCH 2/7] Return newly-queried barring status ppessi
2010-03-18 14:44 ` [PATCH 3/7] Number of barring services is constant ppessi
2010-03-18 14:44 ` [PATCH 4/7] Network password has exactly 4 digits ppessi
2010-03-18 14:44 ` [PATCH 5/7] Interrogation of a barring does not require password ppessi
2010-03-18 14:44 ` [PATCH 6/7] Added call-barring-api.txt ppessi
2010-03-18 14:44 ` ppessi [this message]
2010-03-18 16:51 ` [PATCH 7/7] Fix: isimodem handling of call barring services Denis Kenzior
2010-03-18 17:38 ` Pekka Pessi
2010-03-18 17:50 ` Denis Kenzior
2010-03-18 16:46 ` [PATCH 6/7] Added call-barring-api.txt Denis Kenzior
2010-03-18 16:44 ` [PATCH 5/7] Interrogation of a barring does not require password Denis Kenzior
2010-03-18 16:43 ` [PATCH 4/7] Network password has exactly 4 digits Denis Kenzior
2010-03-19 14:36 ` Pekka Pessi
2010-03-18 16:40 ` [PATCH 3/7] Number of barring services is constant Denis Kenzior
2010-03-18 16:39 ` [PATCH 2/7] Return newly-queried barring status Denis Kenzior
2010-03-18 16:11 ` [PATCH 1/7] Barring services can only be activated/deactivated Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1268923471-29059-7-git-send-email-ppessi@gmail.com \
--to=ppessi@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox