aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2022-02-12 14:37:48 +0100
committerHarald Welte <laforge@osmocom.org>2022-02-15 15:35:35 +0100
commit4c5e2310fad815e60b721f5fc3df680ac3f07651 (patch)
tree54cf399300e87cd4918a989006a2bcbff360f074
parentd16d904c572905c40906df713e2f538854d31b21 (diff)
ts_31_102: Add "ust_service_check" command.
This command performs a consistency check between the services activated in EF.UST/EF.IST and the files that should (or should not) be active/selectable for the given service. Produces output like: Checking service No 48 (inactive) ERROR: File EF(EF.MWIS) is selectable but should not! Checking service No 49 (active) ERROR: File EF(EF.CFIS) is not selectable (SW=6a82) but should! Change-Id: Iea7166959e2015eb8fa34d86036560c9e42ce4d3
-rw-r--r--pySim/ts_31_102.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index 17d865d..9105418 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -600,6 +600,42 @@ class EF_UServiceTable(TransparentEF):
"""Deactivate a service within EF.UST"""
self._cmd.card.update_ust(int(arg), 0)
+ def do_ust_service_check(self, arg):
+ """Check consistency between services of this file and files present/activated"""
+ # obtain list of currently active services
+ (service_data, sw) = self._cmd.rs.read_binary_dec()
+ for s in service_data.keys():
+ if service_data[s]['activated']:
+ active_services.append(s)
+ # iterate over all the service-constraints we know of
+ selected_file = self._cmd.rs.selected_file
+ files_by_service = selected_file.parent.files_by_service
+ try:
+ for s in sorted(files_by_service.keys()):
+ active_str = 'active' if s in active_services else 'inactive'
+ self._cmd.poutput("Checking service No %u (%s)" % (s, active_str))
+ for f in files_by_service[s]:
+ should_exist = f.should_exist_for_services(active_services)
+ try:
+ (data, sw) = self._cmd.card._scc.select_file(f.fid)
+ exists = True
+ fcp = f.decode_select_response(data)
+ # if we just selected a directory, go back
+ if fcp['file_descriptor']['file_type'] == 'df':
+ self._cmd.card._scc.select_parent_df()
+ except SwMatchError as e:
+ sw = e.sw_actual
+ exists = False
+ if exists != should_exist:
+ if exists:
+ self._cmd.poutput(" ERROR: File %s is selectable but should not!" % f)
+ else:
+ self._cmd.poutput(" ERROR: File %s is not selectable (SW=%s) but should!" % (f, sw))
+ finally:
+ # re-select the EF.UST
+ self._cmd.card._scc.select_file(selected_file.fid)
+
+
# TS 31.103 Section 4.2.7 - *not* the same as DF.GSM/EF.ECC!
class EF_ECC(LinFixedEF):
cc_construct = Rpad(BcdAdapter(Rpad(Bytes(3))), pattern='f')