[PATCH] sim: fix crash in case of invalid sim password type
by Christophe Ronco
Hi,
I have an old Swedish SIM card here that I tried to put in my MC7304 modem.
My ofono version is 1.20 (with some additional patches).
It sometimes return an invalid SIM password type.
After that, ofono crashes. Here is an extract of debug traces when this happens.
Ofono is just starting, modem was here before ofono starts.
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_attributes() file id 0x6fb7 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/devinfo.c:string_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/devinfo.c:qmi_query_serial()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:get_file_attributes_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.err ofonod[1120]: Requested file structure differs from SIM: 6fb7
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/src/voicecall.c:ecc_g2_read_cb() 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_attributes() file id 0x6fb7 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/devinfo.c:get_ids_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:get_file_attributes_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_record() file id 0x6fb7 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:read_generic_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/src/voicecall.c:ecc_g3_read_cb() 1
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_record() file id 0x6fb7 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:read_generic_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/src/voicecall.c:ecc_g3_read_cb() 1
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_record() file id 0x6fb7 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:read_generic_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/src/voicecall.c:ecc_g3_read_cb() 1
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_record() file id 0x6fb7 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:read_generic_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/src/voicecall.c:ecc_g3_read_cb() 1
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_record() file id 0x6fb7 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:read_generic_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/src/voicecall.c:ecc_g3_read_cb() 1
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_attributes() file id 0x2fe2 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:get_file_attributes_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_transparent() file id 0x2fe2 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:read_generic_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/src/simfs.c:sim_fs_op_read_block_cb() bufoff: 0, dataoff: 0, tocopy: 10
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_attributes() file id 0x6f05 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:get_file_attributes_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_transparent() file id 0x6f05 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:read_generic_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/src/simfs.c:sim_fs_op_read_block_cb() bufoff: 0, dataoff: 0, tocopy: 6
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_attributes() file id 0x2f05 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:get_file_attributes_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_read_transparent() file id 0x2f05 path len 0
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:read_generic_cb()
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/src/simfs.c:sim_fs_op_read_block_cb() bufoff: 0, dataoff: 0, tocopy: 6
Jun 27 15:28:41 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:qmi_query_passwd_state()
Jun 27 15:28:42 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:get_card_status() info1->app_state:0x6: OFONO_SIM_PASSWORD_INVALID
Jun 27 15:28:42 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/drivers/qmimodem/sim.c:query_passwd_state_cb() passwd state 16
Jun 27 15:28:42 klk-lpbs-0504B4 daemon.debug ofonod[1120]: ../git/src/sim.c:sim_pin_query_cb() sim->pin_type: 0, pin_type: 16
Jun 27 15:28:42 klk-lpbs-0504B4 daemon.err ofonod[1120]: Aborting (signal 11) [/usr/sbin/ofonod]
Problem is just that we don't have a string corresponding to this password type.
Christophe Ronco (1):
sim: fix crash in case of invalid sim password type
src/sim.c | 1 +
1 file changed, 1 insertion(+)
--
2.7.4
2 years, 9 months
ofono with sim5320 module
by David Ashley
Hello, I'm at my wits' end trying to get ofono working with the
sim5320 module. I'm using the plugins/sim900.c module as a starting
point. I think the issue has something to do with the difference
between the MUX functionality between the 900 and the 5320. The sim900
supports the elaborate parameters sent on the
AT+CMUX=0,x,x,x,x, etc.
but the SIM5320 only supports
AT+CMUX=0
There's that... but also the way the sim900 plugin creates a
SETUP_DLC, initiates muxing, then deletes the setup DLC and creates 4
new DLC's... it didn't work for the sim5320 until I remapped the DLC's
somewhat like this:
#define NUM_DLC 4
#define VOICE_DLC 2
#define NETREG_DLC 1
//#define SMS_DLC 2
#define GPRS_DLC 3
#define SETUP_DLC 0
static char *dlc_prefixes[NUM_DLC] = {
[VOICE_DLC]="Voice: ",
[NETREG_DLC]="Net: ",
// [SMS_DLC]= "SMS: ",
[GPRS_DLC]= "GPRS: " ,
[SETUP_DLC]= "Setup: ",
};
Note I have to eliminate the SMS_DLC usage later in sim5320_post_sim:
// ofono_sms_create(modem, OFONO_VENDOR_SIMCOM, "atmodem",
// data->dlcs[SMS_DLC]);
OK everything is *ALMOST* working. ofonod interacts fine with
connmand, connmand tells ofonod to activate the sim5320, which
actually establishes a ppp connection and sets up a ppp device:
ppp0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-0
inet addr:30.97.132.47 P-t-P:30.97.132.47 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:124 (124.0 B)
Here's the rub: No matter what I do, I never get any RX packets from
that ppp device, and even when it appears to TX packets (I'm trying to
ping out) the machine on the internet isn't actually receiving them.
I'm running on a beaglebone with a custom board with a sim5320 module on it.
I have no idea what to try... Any advice would be appreciated...
Thanks very much!!!!
-Dave
3 years, 1 month
[PATCH] qmi: remove request when it timeouts
by Christophe Ronco
Patch proposed to solve problem seen by Eswaran Vinothkumar in thread: Ofono 1.21 crashes with Sierra MC7455.
Tested by Jonas Bonn on his setup.
On my side, I did that to solve an Ofono crash seen with this setup:
- huawei E3372 USB key plugged
- MC7304
I stop Ofono, power off and on both modems and restart Ofono immediately. Sometimes I see an Ofono crash.
Here is the result of the debug I made:
When sierra modem reappears, Ofono will ask Modem which service it supports. Usually modem answers quickly.
>From traces, here is what happened:
- Sep 26 14:11:56: modem asks the list of supported services
- Sep 26 14:12:01: no answer after 5s, modem asks the list of supported services again
- Sep 26 14:12:03: modem replies to request sent at Sep 26 14:11:56. Ofono crashes during message treatment
Problem is that when a timeout occurs for this type of request, part of the data is released. When answer arrives, this data is used.
I still have the corresponding trace but I don't think it will be very useful.
Christophe
Christophe Ronco (1):
qmi: remove request when it timeouts
drivers/qmimodem/qmi.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
--
2.7.4
3 years, 2 months
[PATCH] sim: Move atom registration to the end of ofono_sim_register
by Slava Monich
The state needs to be checked prior to calling __ofono_atom_register
because atom registration calls OFONO_ATOM_WATCH_CONDITION_REGISTERED
callbacks each of which may call ofono_sim_inserted_notify. Should
that happen, by the time __ofono_atom_register returns, ofono_sim
will be in OFONO_SIM_STATE_INSERTED state and sim_initialize will
be called twice if the initial state was OFONO_SIM_STATE_NOT_PRESENT.
If nothing else, that results in memory leaks like this one (because
IMSI will be queried twice, among other things):
==3017== 16 bytes in 1 blocks are definitely lost in loss record 187 of 475
==3017== at 0x483F380: malloc (vg_replace_malloc.c:296)
==3017== by 0x4AFB0DF: g_malloc (gmem.c:94)
==3017== by 0x4B12185: g_strdup (gstrfuncs.c:363)
==3017== by 0xF79D3: sim_imsi_obtained (sim.c:1535)
==3017== by 0xF7BB3: sim_imsi_cb (sim.c:1594)
==3017== by 0x66C23: at_cimi_cb (sim.c:441)
==3017== by 0xA6B53: at_chat_finish_command (gatchat.c:459)
==3017== by 0xA6D9F: at_chat_handle_command_response (gatchat.c:521)
==3017== by 0xA70AF: have_line (gatchat.c:600)
==3017== by 0xA76DF: new_bytes (gatchat.c:759)
==3017== by 0xABACF: received_data (gatio.c:122)
==3017== by 0xAD093: watch_dispatch (gatmux.c:461)
==3017== by 0xAC5D3: dispatch_sources (gatmux.c:180)
==3017== by 0xAC98F: received_data (gatmux.c:265)
==3017== by 0x4AF606F: g_main_dispatch (gmain.c:3154)
==3017== by 0x4AF606F: g_main_context_dispatch (gmain.c:3769)
==3017== by 0x4AF631D: g_main_context_iterate.isra.4 (gmain.c:3840)
==3017== by 0x4AF658F: g_main_loop_run (gmain.c:4034)
==3017== by 0xBE8AF: main (main.c:261)
---
src/sim.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/sim.c b/src/sim.c
index 88c0421..155f421 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -3108,8 +3108,6 @@ void ofono_sim_register(struct ofono_sim *sim)
sim->spn_watches = __ofono_watchlist_new(g_free);
sim->simfs = sim_fs_new(sim, sim->driver);
- __ofono_atom_register(sim->atom, sim_unregister);
-
ofono_sim_add_state_watch(sim, sim_ready, sim, NULL);
if (sim->state > OFONO_SIM_STATE_NOT_PRESENT)
@@ -3118,6 +3116,8 @@ void ofono_sim_register(struct ofono_sim *sim)
sim->hfp_watch = __ofono_modem_add_atom_watch(modem,
OFONO_ATOM_TYPE_EMULATOR_HFP,
emulator_hfp_watch, sim, NULL);
+
+ __ofono_atom_register(sim->atom, sim_unregister);
}
void ofono_sim_remove(struct ofono_sim *sim)
--
1.9.1
3 years, 2 months
[PATCH] gatchat: Removed unused GAtPPP field
by Slava Monich
---
gatchat/gatppp.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 5144084..4a80b4b 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -40,7 +40,6 @@
#include "crc-ccitt.h"
#include "ppp.h"
-#define DEFAULT_MRU 1500
#define DEFAULT_MTU 1500
#define PPP_ADDR_FIELD 0xff
@@ -66,7 +65,6 @@ struct _GAtPPP {
struct ppp_chap *chap;
struct ppp_pap *pap;
GAtHDLC *hdlc;
- gint mru;
gint mtu;
char username[256];
char password[256];
@@ -830,7 +828,6 @@ static GAtPPP *ppp_init_common(gboolean is_server, guint32 ip)
ppp->fd = -1;
/* set options to defaults */
- ppp->mru = DEFAULT_MRU;
ppp->mtu = DEFAULT_MTU;
/* initialize the lcp state */
--
1.9.1
3 years, 2 months
RFC: Add support for last call dialing
by Philippe De Swert
Hello all,
This is my first ofono patch and I have tried to follow the coding guidelines etc.
I did not find support to actually dial the last dialled call that I could use for
HFP with bluetooth. I did find some references but no method to do so. Thus I added
one myself. I took existing code as a guideline to implement this.
This has been tested with several phone models and with the Bluetooth SIG testing tool.
Comments and corrections welcome.
Regards,
Philippe
3 years, 2 months
Ofono 1.21 crashes with Sierra MC7455
by Eswaran Vinothkumar (BEG/PJ-IOT-EL)
I make a quick review, use checkpatch and post it.
Thanks for testing and sorry to not always take the time needed to propose a patch to mainline.
Christophe
On 10/26/2017 12:54 PM, Jonas Bonn wrote:
On 10/26/2017 12:43 PM, Christophe Ronco wrote:
Seems to be this:
i) When the modem is first powered on, service discovery takes some time (more than 5 seconds)
ii) The service discovery timeout fires before the QMI request returns so discover_reply gets called before discover_callback and things get cleaned up
iii) Then the QMI request returns and discover_callback gets called even though the request has timed out in ii)
...and this is where things go wrong because the userdata pointer to discover_callback is probably no longer valid.
How do we handle the QMI request returning a _late_ response, i.e. after it technically has timed out? I'll dig a bit more...
/Jonas
Hi Jonas,
When I look at my personal patches, it seems I've already seen that. Please find attached the patch I currently have in my setup on this subject.
Yes, that's exactly what I was just in the process of implementing. Glad you beat me to it. :)
I tested your patch and it solves the problem. Can you submit it to the list? If not, I will... :)
I think service_create_reply() has the same issue but I don't hit it in my setup..
Eswaran: try the patch from Christophe... I'm 99% certain it solves your issue.
/Jonas
Hi,
Sorry, I couldn't able to run GDB on my test bench. Hence, not able to provide the necessary core dumps. I applied the patch you had provided. This fixes the issue during enabling the modem.
The ofono is running fine when I run enable-modem.
But I am seeing some other issues. After starting the system, I am running the scripts when I identify the modem device and ofono service is in active state.
/enable-modem
/online-modem
/list-modems --> here I am checking the ofono sim interface for SIM card status. The ofono is reporting that SIM is not present even though the SIM card is attached to the system
/offline-modem -> the oFono process gets exited.
I have attached the ofono debug messages. I will send the gdb backtrace logs as soon as possible.
Regards,
vinoth
3 years, 2 months
Ofono 1.21 crashes with Sierra MC7455
by Eswaran Vinothkumar (BEG/PJ-IOT-EL)
Hello,
For our next connectivity project we are planning to use Connman along with oFono
The version being used are Connman :1.35 and oFono:1.21
After system start up, I am seeing that the oFono process gets exited, whenever I try to enable the modem by calling the python script enable-modem in the test directory. However, if I restart the ofono systemd service, everything works fine.
I have attached the logs for your reference. Please let me know, if any further log messages are required.
Modem chip. MC7455 from sierra
Linux kernel: 4.9.44-fslc+g8f876e1 (freescale)
Mit freundlichen Grüßen / Best regards
Vinothkumar Eswaran
3 years, 2 months
[PATCH] atmodem: Query the list of supported <fac>s from the modem
by Slava Monich
Not all modems support all <fac>s (particularly, "PS"), let's be polite
and not ask them for the ones they don't support.
---
drivers/atmodem/sim.c | 69 ++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 57 insertions(+), 12 deletions(-)
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 6395a04..effce6e 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -52,6 +52,7 @@ struct sim_data {
unsigned int vendor;
guint ready_id;
struct at_util_sim_state_query *sim_state_query;
+ const char *passwd_fac[OFONO_SIM_PASSWORD_INVALID];
};
static const char *crsm_prefix[] = { "+CRSM:", NULL };
@@ -1439,7 +1440,7 @@ static void at_lock_unlock_cb(gboolean ok, GAtResult *result,
cb(&error, cbd->data);
}
-static const char *const at_clck_cpwd_fac[] = {
+static const char *const at_clck_cpwd_fac[OFONO_SIM_PASSWORD_INVALID] = {
[OFONO_SIM_PASSWORD_SIM_PIN] = "SC",
[OFONO_SIM_PASSWORD_SIM_PIN2] = "P2",
[OFONO_SIM_PASSWORD_PHSIM_PIN] = "PS",
@@ -1459,13 +1460,13 @@ static void at_pin_enable(struct ofono_sim *sim,
struct cb_data *cbd = cb_data_new(cb, data);
char buf[64];
int ret;
- unsigned int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac);
- if (passwd_type >= len || at_clck_cpwd_fac[passwd_type] == NULL)
+ if (passwd_type >= ARRAY_SIZE(sd->passwd_fac) ||
+ sd->passwd_fac[passwd_type] == NULL)
goto error;
snprintf(buf, sizeof(buf), "AT+CLCK=\"%s\",%i,\"%s\"",
- at_clck_cpwd_fac[passwd_type], enable ? 1 : 0, passwd);
+ sd->passwd_fac[passwd_type], enable ? 1 : 0, passwd);
ret = g_at_chat_send(sd->chat, buf, none_prefix,
at_lock_unlock_cb, cbd, g_free);
@@ -1490,14 +1491,13 @@ static void at_change_passwd(struct ofono_sim *sim,
struct cb_data *cbd = cb_data_new(cb, data);
char buf[64];
int ret;
- unsigned int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac);
- if (passwd_type >= len ||
- at_clck_cpwd_fac[passwd_type] == NULL)
+ if (passwd_type >= ARRAY_SIZE(sd->passwd_fac) ||
+ sd->passwd_fac[passwd_type] == NULL)
goto error;
snprintf(buf, sizeof(buf), "AT+CPWD=\"%s\",\"%s\",\"%s\"",
- at_clck_cpwd_fac[passwd_type], old_passwd, new_passwd);
+ sd->passwd_fac[passwd_type], old_passwd, new_passwd);
ret = g_at_chat_send(sd->chat, buf, none_prefix,
at_lock_unlock_cb, cbd, g_free);
@@ -1550,13 +1550,13 @@ static void at_query_clck(struct ofono_sim *sim,
struct sim_data *sd = ofono_sim_get_data(sim);
struct cb_data *cbd = cb_data_new(cb, data);
char buf[64];
- unsigned int len = sizeof(at_clck_cpwd_fac) / sizeof(*at_clck_cpwd_fac);
- if (passwd_type >= len || at_clck_cpwd_fac[passwd_type] == NULL)
+ if (passwd_type >= ARRAY_SIZE(sd->passwd_fac) ||
+ sd->passwd_fac[passwd_type] == NULL)
goto error;
snprintf(buf, sizeof(buf), "AT+CLCK=\"%s\",2",
- at_clck_cpwd_fac[passwd_type]);
+ sd->passwd_fac[passwd_type]);
if (g_at_chat_send(sd->chat, buf, clck_prefix,
at_lock_status_cb, cbd, g_free) > 0)
@@ -1568,6 +1568,43 @@ error:
CALLBACK_WITH_FAILURE(cb, -1, data);
}
+static void at_clck_query_cb(gboolean ok, GAtResult *result, gpointer user)
+{
+ struct ofono_sim *sim = user;
+ struct sim_data *sd = ofono_sim_get_data(sim);
+ GAtResultIter iter;
+ const char *fac;
+
+ if (!ok)
+ goto done;
+
+ g_at_result_iter_init(&iter, result);
+
+ /* e.g. +CLCK: ("SC","FD","PN","PU","PP","PC","PF") */
+ if (!g_at_result_iter_next(&iter, "+CLCK:") ||
+ !g_at_result_iter_open_list(&iter))
+ goto done;
+
+ memset(sd->passwd_fac, 0, sizeof(sd->passwd_fac));
+
+ while (g_at_result_iter_next_string(&iter, &fac)) {
+ int i;
+
+ /* Find it in the list of known <fac>s */
+ for (i = 0; i < ARRAY_SIZE(at_clck_cpwd_fac); i++) {
+ if (!g_strcmp0(at_clck_cpwd_fac[i], fac)) {
+ DBG("found %s", fac);
+ /* at_clck_cpwd_fac[i] is a static string */
+ sd->passwd_fac[i] = at_clck_cpwd_fac[i];
+ break;
+ }
+ }
+ }
+
+done:
+ ofono_sim_register(sim);
+}
+
static gboolean at_sim_register(gpointer user)
{
struct ofono_sim *sim = user;
@@ -1591,7 +1628,15 @@ static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,
g_at_chat_send(sd->chat, "AT*EPEE=1", NULL, NULL, NULL, NULL);
ofono_sim_set_data(sim, sd);
- g_idle_add(at_sim_register, sim);
+
+ /* The default password -> <fac> map */
+ memcpy(sd->passwd_fac, at_clck_cpwd_fac, sizeof(sd->passwd_fac));
+
+ /* Query supported <fac>s */
+ if (!g_at_chat_send(sd->chat, "AT+CLCK=?", clck_prefix,
+ at_clck_query_cb, sim, NULL)) {
+ g_idle_add(at_sim_register, sim);
+ }
return 0;
}
--
1.9.1
3 years, 3 months