mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-06-19 01:17:54 +03:00
Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d18f16e26 | |||
| 00af942dbc | |||
| 13530c6fe9 | |||
| 27def57be2 | |||
| 2c3820c39f | |||
| b8871ed04e | |||
| d9e0adbe1a | |||
| e04db4b7fb | |||
| ac2fe707e4 | |||
| ec6f079a94 | |||
| a9fe3e2fde | |||
| 68dd9e6140 | |||
| 947a0ab723 | |||
| e9c68df3c6 | |||
| a2ffe30542 | |||
| 050b08157d | |||
| 035c49100b | |||
| 2e310ee825 | |||
| 41ae4db9bb | |||
| 6a6dacef51 | |||
| 270c148343 | |||
| a07e4de853 | |||
| 6e2498eac0 | |||
| 1173b11ca6 | |||
| 1d79baca35 | |||
| abe4a8f9b1 | |||
| 429656dcc6 | |||
| 74f66fecdb | |||
| bfdcdbfc23 | |||
| 87beb049a4 | |||
| cf6c47dba2 | |||
| 10d42458a4 | |||
| 0cab988f47 | |||
| a259c45e7a | |||
| ff02cd8c78 | |||
| 54c202a7ca | |||
| 257f8c2598 | |||
| 45c88d52b3 | |||
| ee09e15e5d | |||
| 4e12d17238 | |||
| f18cf6d2c7 | |||
| d8768aa7bf | |||
| 72556426f8 | |||
| 8b07326265 | |||
| 4d23824a81 | |||
| 0a559d2c6e | |||
| cbfbe4ac40 | |||
| 8017025137 | |||
| 0e9583f4f7 | |||
| 30fa174feb | |||
| ef03270a93 | |||
| 994fd13194 | |||
| 62f85218e8 | |||
| 1222ebe6ae | |||
| 9012d669b1 | |||
| b45c44e998 | |||
| 04a47010d1 | |||
| 691b0d3c92 | |||
| 03b58985a5 | |||
| cc71dbf899 | |||
| aafc8d51c3 |
+19
-13
@@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
export PYTHONUNBUFFERED=1
|
export PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
setup_venv() {
|
||||||
|
virtualenv -p python3 venv --system-site-packages
|
||||||
|
. venv/bin/activate
|
||||||
|
}
|
||||||
|
|
||||||
if [ ! -d "./tests/" ] ; then
|
if [ ! -d "./tests/" ] ; then
|
||||||
echo "###############################################"
|
echo "###############################################"
|
||||||
echo "Please call from pySim-prog top directory"
|
echo "Please call from pySim-prog top directory"
|
||||||
@@ -23,8 +28,7 @@ fi
|
|||||||
|
|
||||||
case "$JOB_TYPE" in
|
case "$JOB_TYPE" in
|
||||||
"test")
|
"test")
|
||||||
virtualenv -p python3 venv --system-site-packages
|
setup_venv
|
||||||
. venv/bin/activate
|
|
||||||
|
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install pyshark
|
pip install pyshark
|
||||||
@@ -32,23 +36,27 @@ case "$JOB_TYPE" in
|
|||||||
# Execute automatically discovered unit tests first
|
# Execute automatically discovered unit tests first
|
||||||
python -m unittest discover -v -s tests/unittests
|
python -m unittest discover -v -s tests/unittests
|
||||||
|
|
||||||
# Run pySim-prog integration tests (requires physical cards)
|
# Run pySim-trace test
|
||||||
|
tests/pySim-trace_test/pySim-trace_test.sh
|
||||||
|
;;
|
||||||
|
"card-test") # tests requiring physical cards
|
||||||
|
setup_venv
|
||||||
|
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
# Run pySim-prog integration tests
|
||||||
cd tests/pySim-prog_test/
|
cd tests/pySim-prog_test/
|
||||||
./pySim-prog_test.sh
|
./pySim-prog_test.sh
|
||||||
cd ../../
|
cd ../../
|
||||||
|
|
||||||
# Run pySim-trace test
|
# Run pySim-shell integration tests
|
||||||
tests/pySim-trace_test/pySim-trace_test.sh
|
|
||||||
|
|
||||||
# Run pySim-shell integration tests (requires physical cards)
|
|
||||||
python3 -m unittest discover -v -s ./tests/pySim-shell_test/
|
python3 -m unittest discover -v -s ./tests/pySim-shell_test/
|
||||||
|
|
||||||
# Run pySim-smpp2sim test
|
# Run pySim-smpp2sim test
|
||||||
tests/pySim-smpp2sim_test/pySim-smpp2sim_test.sh
|
tests/pySim-smpp2sim_test/pySim-smpp2sim_test.sh
|
||||||
;;
|
;;
|
||||||
"distcheck")
|
"distcheck")
|
||||||
virtualenv -p python3 venv --system-site-packages
|
setup_venv
|
||||||
. venv/bin/activate
|
|
||||||
|
|
||||||
pip install .
|
pip install .
|
||||||
pip install pyshark
|
pip install pyshark
|
||||||
@@ -61,8 +69,7 @@ case "$JOB_TYPE" in
|
|||||||
# Print pylint version
|
# Print pylint version
|
||||||
pip3 freeze | grep pylint
|
pip3 freeze | grep pylint
|
||||||
|
|
||||||
virtualenv -p python3 venv --system-site-packages
|
setup_venv
|
||||||
. venv/bin/activate
|
|
||||||
|
|
||||||
pip install .
|
pip install .
|
||||||
|
|
||||||
@@ -80,8 +87,7 @@ case "$JOB_TYPE" in
|
|||||||
contrib/*.py
|
contrib/*.py
|
||||||
;;
|
;;
|
||||||
"docs")
|
"docs")
|
||||||
virtualenv -p python3 venv --system-site-packages
|
setup_venv
|
||||||
. venv/bin/activate
|
|
||||||
|
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
|||||||
@@ -1344,7 +1344,15 @@ class SuciCalcInfoParameter(ConfigurableParameter):
|
|||||||
if not f_sucici:
|
if not f_sucici:
|
||||||
continue
|
continue
|
||||||
ef_sucici = EF_SUCI_Calc_Info()
|
ef_sucici = EF_SUCI_Calc_Info()
|
||||||
f_sucici.body = ef_sucici.encode_bin(val)
|
body = ef_sucici.encode_bin(val)
|
||||||
|
|
||||||
|
# 0xff pad up to the existing file size, so that the underlying template doesn't come through
|
||||||
|
is_size = f_sucici.file_size
|
||||||
|
pad_n = is_size - len(body)
|
||||||
|
if pad_n > 0:
|
||||||
|
body = body + b'\xff' * pad_n
|
||||||
|
|
||||||
|
f_sucici.body = body
|
||||||
pe.file2pe(f_sucici)
|
pe.file2pe(f_sucici)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
+31
-1
@@ -251,6 +251,16 @@ class EF_SMSP(LinFixedEF):
|
|||||||
"numbering_plan_id": "isdn_e164" },
|
"numbering_plan_id": "isdn_e164" },
|
||||||
"call_number": "4915790109999" },
|
"call_number": "4915790109999" },
|
||||||
"tp_pid": b"\x00", "tp_dcs": b"\x00", "tp_vp_minutes": 4320 } ),
|
"tp_pid": b"\x00", "tp_dcs": b"\x00", "tp_vp_minutes": 4320 } ),
|
||||||
|
( 'e1ffffffffffffffffffffffff0891945197109099f9ffffff0000a9',
|
||||||
|
{ "alpha_id": "", "parameter_indicators": { "tp_dest_addr": False, "tp_sc_addr": True,
|
||||||
|
"tp_pid": True, "tp_dcs": True, "tp_vp": True },
|
||||||
|
"tp_dest_addr": { "length": 255, "ton_npi": { "ext": True, "type_of_number": "reserved_for_extension",
|
||||||
|
"numbering_plan_id": "reserved_for_extension" },
|
||||||
|
"call_number": "" },
|
||||||
|
"tp_sc_addr": { "length": 8, "ton_npi": { "ext": True, "type_of_number": "international",
|
||||||
|
"numbering_plan_id": "isdn_e164" },
|
||||||
|
"call_number": "4915790109999" },
|
||||||
|
"tp_pid": b"\x00", "tp_dcs": b"\x00", "tp_vp_minutes": 4320 } ),
|
||||||
( '454e6574776f726b73fffffffffffffff1ffffffffffffffffffffffffffffffffffffffffffffffff0000a7',
|
( '454e6574776f726b73fffffffffffffff1ffffffffffffffffffffffffffffffffffffffffffffffff0000a7',
|
||||||
{ "alpha_id": "ENetworks", "parameter_indicators": { "tp_dest_addr": False, "tp_sc_addr": True,
|
{ "alpha_id": "ENetworks", "parameter_indicators": { "tp_dest_addr": False, "tp_sc_addr": True,
|
||||||
"tp_pid": True, "tp_dcs": True, "tp_vp": False },
|
"tp_pid": True, "tp_dcs": True, "tp_vp": False },
|
||||||
@@ -331,7 +341,8 @@ class EF_SMSP(LinFixedEF):
|
|||||||
'ton_npi'/TonNpi, 'call_number'/PaddedBcdAdapter(Rpad(Bytes(10))))
|
'ton_npi'/TonNpi, 'call_number'/PaddedBcdAdapter(Rpad(Bytes(10))))
|
||||||
DestAddr = Struct('length'/Rebuild(Int8ub, lambda ctx: EF_SMSP.dest_addr_len(ctx)),
|
DestAddr = Struct('length'/Rebuild(Int8ub, lambda ctx: EF_SMSP.dest_addr_len(ctx)),
|
||||||
'ton_npi'/TonNpi, 'call_number'/PaddedBcdAdapter(Rpad(Bytes(10))))
|
'ton_npi'/TonNpi, 'call_number'/PaddedBcdAdapter(Rpad(Bytes(10))))
|
||||||
self._construct = Struct('alpha_id'/COptional(GsmOrUcs2Adapter(Rpad(Bytes(this._.total_len-28)))),
|
# (see comment below)
|
||||||
|
self._construct = Struct('alpha_id'/GsmOrUcs2Adapter(Rpad(Bytes(this._.total_len-28))),
|
||||||
'parameter_indicators'/InvertAdapter(BitStruct(
|
'parameter_indicators'/InvertAdapter(BitStruct(
|
||||||
Const(7, BitsInteger(3)),
|
Const(7, BitsInteger(3)),
|
||||||
'tp_vp'/Flag,
|
'tp_vp'/Flag,
|
||||||
@@ -345,6 +356,25 @@ class EF_SMSP(LinFixedEF):
|
|||||||
'tp_dcs'/Bytes(1),
|
'tp_dcs'/Bytes(1),
|
||||||
'tp_vp_minutes'/EF_SMSP.ValidityPeriodAdapter(Byte))
|
'tp_vp_minutes'/EF_SMSP.ValidityPeriodAdapter(Byte))
|
||||||
|
|
||||||
|
# Ensure 'alpha_id' is always present
|
||||||
|
def encode_record_hex(self, abstract_data: dict, record_nr: int, total_len: int = None) -> str:
|
||||||
|
# Problem: TS 51.011 Section 10.5.6 describes the 'alpha_id' field as optional. However, this is only true
|
||||||
|
# at the time when the record length of the file is set up in the file system. A card manufacturer may decide
|
||||||
|
# to remove the field by setting the record length to 28. Likewise, the card manaufacturer may also decide to
|
||||||
|
# set the field to a distinct length by setting the record length to a value greater than 28 (e.g. 14 bytes
|
||||||
|
# 'alpha_id' + 28 bytes). Due to the fixed nature of the record length, this eventually means that in practice
|
||||||
|
# 'alpha_id' is a mandatory field with a fixed length.
|
||||||
|
#
|
||||||
|
# Due to the problematic specification of 'alpha_id' as a pseudo-optional field at the beginning of a
|
||||||
|
# fixed-size memory, the construct definition in self._construct has been incorrectly implemented and the field
|
||||||
|
# has been marked as COptional. We may correct the problem by removing COptional. But to maintain compatibility,
|
||||||
|
# we then have to ensure that in case the field is not provided (None), it is set to an empty string ('').
|
||||||
|
#
|
||||||
|
# See also ts_31_102.py, class EF_OCI for a correct example.
|
||||||
|
if abstract_data['alpha_id'] is None:
|
||||||
|
abstract_data['alpha_id'] = ''
|
||||||
|
return super().encode_record_hex(abstract_data, record_nr, total_len)
|
||||||
|
|
||||||
# TS 51.011 Section 10.5.7
|
# TS 51.011 Section 10.5.7
|
||||||
class EF_SMSS(TransparentEF):
|
class EF_SMSS(TransparentEF):
|
||||||
class MemCapAdapter(Adapter):
|
class MemCapAdapter(Adapter):
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Utility to verify the functionality of pySim-trace.py
|
# Utility to verify the functionality of pySim-smpp2sim.py
|
||||||
#
|
#
|
||||||
# (C) 2026 by sysmocom - s.f.m.c. GmbH
|
# (C) 2026 by sysmocom - s.f.m.c. GmbH
|
||||||
# All Rights Reserved
|
# All Rights Reserved
|
||||||
|
|||||||
Reference in New Issue
Block a user