Cache EF-PNN, EF-OPL sim files on disk.
PATCH 1/1 Cache EF-PNN, EF-OPL sim files on disk.
This uses plain files in /var/cache/ofono for storing contents of the operator lists to avoid possibly numerous queries to the SIM on every startup. Files are indexed with IMSI. I'm not 100% sure about the autoconf magic.
Users need to rerun bootstrap-configure after applying this.
--- bootstrap-configure | 3 +- configure.ac | 5 + src/sim.c | 233 +++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 233 insertions(+), 8 deletions(-)
bootstrap-configure +2 -1
@@ -10,4 +10,5 @@ fi --prefix=/usr \ --mandir=/usr/share/man \ --sysconfdir=/etc \ - --disable-datafiles + --disable-datafiles \ + --localstatedir=/var
configure.ac +5 -0
@@ -87,6 +87,11 @@ AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles], AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no") +eval "eval LOCALSTATE_DIR=$localstatedir" +AC_SUBST(LOCALSTATE_DIR) +AC_DEFINE_UNQUOTED(CONFIG_LOCALSTATEDIR, "$LOCALSTATE_DIR", + [Define to the location where state is stored.]) + COMPILER_FLAGS AC_OUTPUT(Makefile gdbus/Makefile gatchat/Makefile gisi/Makefile
src/sim.c +226 -7
288 lines not on this page · raw message
Signature · 1 line
1.6.0
Quoted 6 lines
This uses plain files in
/var/cache/ofonofor storing contents of the operator lists to avoid possibly numerous queries to the SIM on every startup. Files are indexed with IMSI. I'm not 100% sure about the autoconf magic.Users need to rerun bootstrap-configure after applying this.
Can you rebase and resubmit this patch? The changes to sim.c and network.c were a bit extensive.
Thanks,
-Denis
PATCH 1/1 Cache EF-PNN, EF-OPL sim files on disk.
This uses plain files in /var/cache/ofono for storing contents of the operator lists to avoid possibly numerous queries to the SIM on every startup. Files are indexed with IMSI. I'm not 100% sure about the autoconf magic.
Users need to rerun bootstrap-configure after applying this.
File format slightly changed in this second version (make it as simple as possible).
--- bootstrap-configure | 3 +- configure.ac | 5 ++ src/sim.c | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+), 1 deletions(-)
bootstrap-configure +2 -1
@@ -12,4 +12,5 @@ fi --prefix=/usr \ --mandir=/usr/share/man \ --sysconfdir=/etc \ - --disable-datafiles + --disable-datafiles \ + --localstatedir=/var
configure.ac +5 -0
@@ -96,6 +96,11 @@ AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles], AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no") +eval "eval LOCALSTATE_DIR=$localstatedir" +AC_SUBST(LOCALSTATE_DIR) +AC_DEFINE_UNQUOTED(CONFIG_LOCALSTATEDIR, "$LOCALSTATE_DIR", + [Define to the location where state is stored.]) + COMPILER_FLAGS AC_OUTPUT(Makefile gdbus/Makefile gatchat/Makefile gisi/Makefile
src/sim.c +193 -0
241 lines not on this page · raw message
Signature · 1 line
1.6.0
Hi,
Quoted 10 lines
This uses plain files in
/var/cache/ofonofor storing contents of the operator lists to avoid possibly numerous queries to the SIM on every startup. Files are indexed with IMSI. I'm not 100% sure about the autoconf magic.Users need to rerun bootstrap-configure after applying this.
File format slightly changed in this second version (make it as simple as possible).
return -1;
I somewhat like the idea of transparently caching the SIM file system, unfortunately we can't do it for all files. Suppose a user shuts off oFono device, takes out the SIM and puts it in another device. Then modifies some settings (e.g. like MBDN or MSISDN.) Then the SIM is returned to oFono based device.
However, not all files can be updated by the user. Namely files with the 'ADM' for UPDATE access condition. The only way they can be changed is at a service center.
What do you think of transparently caching only such files? This would include the ones we're really interested in caching anyway, namely EFspn, EFpnn, EFopl, EFust, etc.
If we decide to do this, we should store them in /var/lib/ instead of /var/cache, since these files will be stored semi-permanently. If really necessary, the carrier service center could probably remove the cache somehow during the SIM upgrade.
Regards,
-Denis
2009/7/18 Denis Kenzior <[email protected]>:
Quoted 7 lines
However, not all files can be updated by the user. Namely files with the 'ADM' for UPDATE access condition. The only way they can be changed is at a service center.
What do you think of transparently caching only such files? This would include the ones we're really interested in caching anyway, namely EFspn, EFpnn, EFopl, EFust, etc.
True, I was going to add code or a TODO in ofono_sim_write() to invalidate cache but it's a good point about updating outside ofono control. I now added a parameter to ofono_sim_read() to indicate that a file can be cached on disk, making it a little less transparent. In previous version I had separate entry points for cached read.
Quoted 3 lines
If we decide to do this, we should store them in
/var/lib/instead of/var/cache, since these files will be stored semi-permanently.
Ok, changed. There's also a standard path /var/state, I don't know if it's better or worse.
I should note that the cached reads can change the callback order because they will skip simop_q queue in sim.c.
Regards
From 9852f953a647d3e32a0637153d00096d4ac6942a Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Sat, 18 Jul 2009 15:19:51 +0200
Subject: [PATCH] Cache EF-PNN, EF-OPL sim files on disk.
This uses plain files in /var/cache/ofono for storing contents of the operator lists to avoid possibly numerous queries to the SIM on every startup. Files are indexed with IMSI. I'm not 100% sure about the autoconf magic.
Users need to rerun bootstrap-configure after applying this.
File format slightly changed in this second version (make it as simple as possible).
--- bootstrap-configure | 3 +- configure.ac | 5 ++ src/network.c | 9 ++- src/sim.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++- src/sim.h | 5 +- 5 files changed, 214 insertions(+), 8 deletions(-)
bootstrap-configure +2 -1
@@ -12,4 +12,5 @@ fi --prefix=/usr \ --mandir=/usr/share/man \ --sysconfdir=/etc \ - --disable-datafiles + --disable-datafiles \ + --localstatedir=/var
configure.ac +5 -0
@@ -96,6 +96,11 @@ AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles], AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no") +eval "eval LOCALSTATE_DIR=$localstatedir" +AC_SUBST(LOCALSTATE_DIR) +AC_DEFINE_UNQUOTED(CONFIG_LOCALSTATEDIR, "$LOCALSTATE_DIR", + [Define to the location where state is stored.]) + COMPILER_FLAGS AC_OUTPUT(Makefile gdbus/Makefile gatchat/Makefile gisi/Makefile
src/network.c +5 -4
@@ -1265,7 +1265,8 @@ static void sim_pnn_read_cb(struct ofono_modem *modem, int ok,* still be used for the HPLMN and/or EHPLMN, if PNN * is present. */ if (record == total && !sim_eons_pnn_is_empty (netreg->eons)) -ofono_sim_read (modem,SIM_EFOPL_FILEID , sim_opl_read_cb,NULL ); +ofono_sim_read (modem,SIM_EFOPL_FILEID , + sim_opl_read_cb,NULL ,1 ); } static void sim_spdi_read_cb(struct ofono_modem *modem, int ok,
@@ -1351,7 +1352,7 @@ static void sim_spn_read_cb(struct ofono_modem *modem, int ok, } netreg->spname = spn; -ofono_sim_read (modem,SIM_EFSPDI_FILEID , sim_spdi_read_cb,NULL ); +ofono_sim_read (modem,SIM_EFSPDI_FILEID , sim_spdi_read_cb,NULL ,1 );if (dcbyte &SIM_EFSPN_DC_HOME_PLMN_BIT ) netreg->flags |=NETWORK_REGISTRATION_FLAG_HOME_SHOW_PLMN ;
@@ -1374,8 +1375,8 @@ static void sim_spn_read_cb(struct ofono_modem *modem, int ok,static void network_sim_ready (struct ofono_modem *modem) { -ofono_sim_read (modem,SIM_EFPNN_FILEID , sim_pnn_read_cb,NULL ); -ofono_sim_read (modem,SIM_EFSPN_FILEID , sim_spn_read_cb,NULL ); +ofono_sim_read (modem,SIM_EFPNN_FILEID , sim_pnn_read_cb,NULL ,1 ); +ofono_sim_read (modem,SIM_EFSPN_FILEID , sim_spn_read_cb,NULL ,1 ); } int ofono_network_registration_register(struct ofono_modem *modem,
src/sim.c +198 -2
269 lines not on this page · raw message
src/sim.h +4 -1
@@ -45,10 +45,13 @@ void ofono_sim_set_ready(struct ofono_modem *modem);* if an error has occurred. For transparent files, the callback will only * be called once. * +* can_cache should only be set for files with update condition 'ADM'. +* * Returns 0 if the request could be queued, -1 otherwise. */ int ofono_sim_read (struct ofono_modem *modem,int id, -ofono_sim_file_read_cb_t cb,void *data); +ofono_sim_file_read_cb_t cb,void *data, +int can_cache); int ofono_sim_write(struct ofono_modem *modem, int id, enum ofono_sim_file_structure structure, int record,
Signature · 1 line
1.6.0
Hi Andrzej,
Quoted 15 lines
Quoted 7 lines
However, not all files can be updated by the user. Namely files with the 'ADM' for UPDATE access condition. The only way they can be changed is at a service center.
What do you think of transparently caching only such files? This would include the ones we're really interested in caching anyway, namely EFspn, EFpnn, EFopl, EFust, etc.
True, I was going to add code or a TODO in
ofono_sim_write()to invalidate cache but it's a good point about updating outside ofono control. I now added a parameter toofono_sim_read()to indicate that a file can be cached on disk, making it a little less transparent. In previous version I had separate entry points for cached read.Quoted 1 line
Quoted 5 lines
Quoted 2 lines
If we decide to do this, we should store them in
/var/lib/instead of/var/cache, since these files will be stored semi-permanently.Ok, changed. There's also a standard path
/var/state, I don't know if it's better or worse.
go with /var/lib since that is most common for persistent information. You can use /var/cache for information that can be easily retrieved again without having an impact on the functionality.
The /var/state should not be bothered with. If you have information that are only stored for one session then /var/run should be used. However that will be wiped during reboot.
Regards
Marcel
2009/7/18 andrzej zaborowski <[email protected]>:
Quoted 5 lines
2009/7/18 Denis Kenzior <[email protected]>:
Quoted 4 lines
However, not all files can be updated by the user. Namely files with the 'ADM' for UPDATE access condition. The only way they can be changed is at a service center.
Quoted 8 lines
Quoted 3 lines
What do you think of transparently caching only such files? This would include the ones we're really interested in caching anyway, namely EFspn, EFpnn, EFopl, EFust, etc.
True, I was going to add code or a TODO in
ofono_sim_write()to invalidate cache but it's a good point about updating outside ofono control. I now added a parameter toofono_sim_read()to indicate that a file can be cached on disk, making it a little less transparent.
Actually, ignore this, the response to SELECT gives access conditions so we can use that. I'll fix it and resend later.
Regards
Hi Andrzej,
Quoted 4 lines
This uses plain files in
/var/cache/ofonofor storing contents of the operator lists to avoid possibly numerous queries to the SIM on every startup. Files are indexed with IMSI. I'm not 100% sure about the autoconf magic.
please have a look into BlueZ or ConnMan and use STORAGEDIR for the base path of /var/lib/ofono.
Can we just use GKeyFile to store these files? It would make reading and adding them a lot easier.
Regards
Marcel
2009/7/20 Marcel Holtmann <[email protected]>:
Quoted 7 lines
Quoted 4 lines
This uses plain files in
/var/cache/ofonofor storing contents of the operator lists to avoid possibly numerous queries to the SIM on every startup. Files are indexed with IMSI. I'm not 100% sure about the autoconf magic.please have a look into BlueZ or ConnMan and use STORAGEDIR for the base path of
/var/lib/ofono.
Okay.
Quoted 3 lines
Can we just use GKeyFile to store these files? It would make reading and adding them a lot easier.
I didn't know about GKeyFile but I considered BlueZ textfile after Denis suggested them. The values in GKeyFile are UTF-8 encoded with some characters reserved so we would need either very heavy escaping or storing the SIM file contents hex encoded. Keys would be only perhaps "FileInfo" and "Record1"..."RecordN" because SIM files are nothing like key-value pairs. If you think the reading convenience is worth the parsing overhead, then I can change the patch to use GKeyFile or json or xml.
Supposedly this is only a form caching so there shouldn't be need for reading or adding these files, they can get overwritten at any time.
Regards
PATCH 1/1 Cache EF-PNN, EF-OPL sim files on disk.
In reply to andrzej zaborowskiThis uses plain files in /var/cache/ofono for storing contents of the operator lists to avoid possibly numerous queries to the SIM on every startup. Files are indexed with IMSI. I'm not 100% sure about the autoconf magic.
Users need to rerun bootstrap-configure after applying this.
Depends on [PATCH] Return SIM file access conditions from read_file_info.
--- bootstrap-configure | 3 +- configure.ac | 5 ++ src/sim.c | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 1 deletions(-)
bootstrap-configure +2 -1
@@ -12,4 +12,5 @@ fi --prefix=/usr \ --mandir=/usr/share/man \ --sysconfdir=/etc \ - --disable-datafiles + --disable-datafiles \ + --localstatedir=/var
configure.ac +5 -0
@@ -96,6 +96,11 @@ AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles], AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no") +eval "eval LOCALSTATE_DIR=$localstatedir" +AC_SUBST(LOCALSTATE_DIR) +AC_DEFINE_UNQUOTED(CONFIG_LOCALSTATEDIR, "$LOCALSTATE_DIR", + [Define to the location where state is stored.]) + COMPILER_FLAGS AC_OUTPUT(Makefile gdbus/Makefile gatchat/Makefile gisi/Makefile
src/sim.c +197 -0
263 lines not on this page · raw message
Signature · 1 line
1.6.0
Quoted 8 lines
This uses plain files in
/var/cache/ofonofor storing contents of the operator lists to avoid possibly numerous queries to the SIM on every startup. Files are indexed with IMSI. I'm not 100% sure about the autoconf magic.Users need to rerun bootstrap-configure after applying this.
Depends on [PATCH] Return SIM file access conditions from
read_file_info.
This patch has been pushed. Thanks.
Regards,
-Denis
2009/7/28 Denis Kenzior <[email protected]>:
Quoted 8 lines
Quoted 6 lines
This uses plain files in
/var/cache/ofonofor storing contents of the operator lists to avoid possibly numerous queries to the SIM on every startup. Files are indexed with IMSI. I'm not 100% sure about the autoconf magic.Users need to rerun bootstrap-configure after applying this.
This patch has been pushed.
Thanks. Attaching rebased patch to use Bluez autoconf snippet for setting STORAGEDIR.
Regards
From 857ab2447ce0f8dd3e69ab05f78ab6cb4dd3e7e7 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Mon, 27 Jul 2009 18:36:11 +0200
Subject: [PATCH] Use STORAGEDIR autoconf voodoo from Bluez.
--- configure.ac | 25 +++++++++++++++++++------ src/sim.c | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-)
configure.ac +19 -6
@@ -8,8 +8,6 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AM_MAINTAINER_MODE -AC_PREFIX_DEFAULT(/usr/local) - AC_LANG_C AC_PROG_CC
@@ -96,10 +94,25 @@ AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles], AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no") -eval "eval LOCALSTATE_DIR=$localstatedir" -AC_SUBST(LOCALSTATE_DIR) -AC_DEFINE_UNQUOTED(CONFIG_LOCALSTATEDIR, "$LOCALSTATE_DIR", - [Define to the location where state is stored.]) +AC_PREFIX_DEFAULT(/usr/local) + +if (test "${prefix}" = "NONE"); then + dnl no prefix and no localstatedir, so default to /var + if (test "$localstatedir" = '${prefix}/var'); then + AC_SUBST([localstatedir], ['/var']) + fi + + prefix="${ac_default_prefix}" +fi + +if (test "$localstatedir" = '${prefix}/var'); then + storagedir="${prefix}/var/lib/ofono" +else + storagedir="${localstatedir}/lib/ofono" +fi + +AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}", + [Directory for the storage files]) COMPILER_FLAGS
src/sim.c +1 -1
@@ -315,7 +315,7 @@ static void sim_op_error(struct ofono_modem *modem) }#define SIM_CACHE_MODE 0600 -#define SIM_CACHE_PATH CONFIG_LOCALSTATEDIR "/lib/ofono/%s/%04x" +#define SIM_CACHE_PATH STORAGEDIR "/%s/%04x"#define SIM_CACHE_PATH_LEN (imsilen) (strlen(SIM_CACHE_PATH) - 2 + imsilen)#define SIM_CACHE_HEADER_SIZE 6
Signature · 1 line
1.6.1
Quoted 2 lines
Thanks. Attaching rebased patch to use Bluez autoconf snippet for setting STORAGEDIR.
Path has been pushed. Thanks.
Regards,
-Denis