mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-16 18:38:32 +03:00
ts_51_011: Add sst_service_[de]{activate,allocate} shell commands
Just like the existing commands for UST/IST: Allow the user to activate/deactivate individual services. As EF.SST also contains information about "allocation" of a service, let's have commands for allocation and activation. Change-Id: If959d06248cb1a9d2c0a21cdd40d438726cbc5f0
This commit is contained in:
@@ -555,6 +555,22 @@ EF.ARR: read_arr_records
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Read + decode all EF.ARR records in flattened, human-friendly form.
|
||||
|
||||
DF.GSM/EF.SST: sst_service_allocate
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Mark a given single service as allocated in EF.SST. Requires service number as argument.
|
||||
|
||||
DF.GSM/EF.SST: sst_service_activate
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Mark a given single service as activated in EF.SST. Requires service number as argument.
|
||||
|
||||
DF.GSM/EF.SST: sst_service_deallocate
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Mark a given single service as deallocated in EF.SST. Requires service number as argument.
|
||||
|
||||
DF.GSM/EF.SST: sst_service_deactivate
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Mark a given single service as deactivated in EF.SST. Requires service number as argument.
|
||||
|
||||
ADF.USIM/EF.EST: est_service_enable
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Enables a single service in EF.EST. Requires service number as argument.
|
||||
|
||||
@@ -643,6 +643,7 @@ class EF_ServiceTable(TransparentEF):
|
||||
def __init__(self, fid, sfid, name, desc, size, table):
|
||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
||||
self.table = table
|
||||
self.shell_commands += [self.AddlShellCommands()]
|
||||
|
||||
@staticmethod
|
||||
def _bit_byte_offset_for_service(service: int) -> Tuple[int, int]:
|
||||
@@ -686,6 +687,42 @@ class EF_ServiceTable(TransparentEF):
|
||||
out[byte_offset] |= ((bits & 3) << bit_offset)
|
||||
return out
|
||||
|
||||
@with_default_category('File-Specific Commands')
|
||||
class AddlShellCommands(CommandSet):
|
||||
def _adjust_service(self, service_nr: int, allocate: Optional[bool] = None, activate : Optional[bool] = None):
|
||||
(byte_offset, bit_offset) = EF_ServiceTable._bit_byte_offset_for_service(service_nr)
|
||||
hex_data, sw = self._cmd.lchan.read_binary(length=1, offset=byte_offset)
|
||||
data = h2b(hex_data)
|
||||
if allocate is not None:
|
||||
if allocate:
|
||||
data[0] |= (1 << bit_offset)
|
||||
else:
|
||||
data[0] &= ~(1 << bit_offset)
|
||||
if activate is not None:
|
||||
if activate:
|
||||
data[0] |= (2 << bit_offset)
|
||||
else:
|
||||
data[0] &= ~(2 << bit_offset)
|
||||
total_data, sw = self._cmd.lchan.update_binary(b2h(data), offset=byte_offset)
|
||||
return sw
|
||||
|
||||
def do_sst_service_allocate(self, arg):
|
||||
"""Allocate a service within EF.SST"""
|
||||
self._adjust_service(int(arg), allocate = True)
|
||||
|
||||
def do_sst_service_deallocate(self, arg):
|
||||
"""Deallocate a service within EF.SST"""
|
||||
self._adjust_service(int(arg), allocate = False)
|
||||
|
||||
def do_sst_service_activate(self, arg):
|
||||
"""Activate a service within EF.SST"""
|
||||
self._adjust_service(int(arg), activate = True)
|
||||
|
||||
def do_sst_service_deactivate(self, arg):
|
||||
"""Deactivate a service within EF.SST"""
|
||||
self._adjust_service(int(arg), activate = False)
|
||||
|
||||
|
||||
# TS 51.011 Section 10.3.11
|
||||
class EF_SPN(TransparentEF):
|
||||
_test_de_encode = [
|
||||
|
||||
Reference in New Issue
Block a user