[M] Change in libosmocore[master]: core: osmo_tdef_fsm_inst_state_chg(): allow millisecond precision

2023-12-29 Thread fixeria
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35466?usp=email )

Change subject: core: osmo_tdef_fsm_inst_state_chg(): allow millisecond 
precision
..


Patch Set 2:

(1 comment)

File tests/tdef/tdef_test.ok:

https://gerrit.osmocom.org/c/libosmocore/+/35466/comment/f9b7deee_7aa14da5
PS2, Line 172: 0.001000 s remaining
Hmm, I would expect it to be `0.10 s` given that we round-up to ms.



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35466?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4c4ee89e7e32e86f74cd215f5cbfa44ace5426c1
Gerrit-Change-Number: 35466
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Fri, 29 Dec 2023 22:12:49 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[M] Change in libosmocore[master]: core: osmo_tdef_fsm_inst_state_chg(): allow millisecond precision

2023-12-29 Thread fixeria
Attention is currently required from: fixeria.

Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/35466?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder


Change subject: core: osmo_tdef_fsm_inst_state_chg(): allow millisecond 
precision
..

core: osmo_tdef_fsm_inst_state_chg(): allow millisecond precision

This API predates commit 7b74551b9, which added support for millisecond
granularity to osmo_fsm.  Let's do the same for the tdef FSM wrapper
API, allowing the millisecond precision without rounding-up to seconds.

Of course, this patch changes behavior of the existing API, but having
more precise state timeouts is not going to make the API user
experience worse.

The old behavior of using seconds is for kept for:

* OSMO_TDEF_CUSTOM -- still treated as if it was OSMO_TDEF_S.
* \param[in] default_timeout -- still expected to be in seconds.

Change-Id: I4c4ee89e7e32e86f74cd215f5cbfa44ace5426c1
Related: 7b74551b9 "fsm: Allow millisecond granularity in osmo_fsm built-in 
timer"
---
M include/osmocom/core/tdef.h
M src/core/tdef.c
M tests/tdef/tdef_test.ok
3 files changed, 53 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/66/35466/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35466?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4c4ee89e7e32e86f74cd215f5cbfa44ace5426c1
Gerrit-Change-Number: 35466
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: fixeria 
Gerrit-MessageType: newpatchset


[M] Change in libosmocore[master]: core: osmo_tdef_fsm_inst_state_chg(): allow millisecond precision

2023-12-29 Thread Jenkins Builder
Jenkins Builder has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35466?usp=email )

Change subject: core: osmo_tdef_fsm_inst_state_chg(): allow millisecond 
precision
..


Patch Set 1:

(1 comment)

File src/core/tdef.c:

Robot Comment from checkpatch (run ID jenkins-gerrit-lint-13374):
https://gerrit.osmocom.org/c/libosmocore/+/35466/comment/00af44ad_e87856ed
PS1, Line 347:  const struct osmo_tdef *tdef = 
osmo_tdef_get_entry((struct osmo_tdef*)tdefs, t->T);
"(foo*)" should be "(foo *)"



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35466?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4c4ee89e7e32e86f74cd215f5cbfa44ace5426c1
Gerrit-Change-Number: 35466
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Fri, 29 Dec 2023 21:39:50 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[M] Change in libosmocore[master]: core: osmo_tdef_fsm_inst_state_chg(): allow millisecond precision

2023-12-29 Thread fixeria
fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35466?usp=email )


Change subject: core: osmo_tdef_fsm_inst_state_chg(): allow millisecond 
precision
..

core: osmo_tdef_fsm_inst_state_chg(): allow millisecond precision

This API predates commit 7b74551b9, which added support for millisecond
granularity to osmo_fsm.  Let's do the same for the tdef FSM wrapper
API, allowing the millisecond precision without rounding-up to seconds.

Of course, this patch changes behavior of the existing API, but having
more precise state timeouts is not going to make the API user
experience worse.

The old behavior of using seconds is for kept for:

* OSMO_TDEF_CUSTOM -- still treated as if it was OSMO_TDEF_S.
* \param[in] default_timeout -- still expected to be in seconds.

Change-Id: I4c4ee89e7e32e86f74cd215f5cbfa44ace5426c1
Related: 7b74551b9 "fsm: Allow millisecond granularity in osmo_fsm built-in 
timer"
---
M include/osmocom/core/tdef.h
M src/core/tdef.c
M tests/tdef/tdef_test.ok
3 files changed, 53 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/66/35466/1

diff --git a/include/osmocom/core/tdef.h b/include/osmocom/core/tdef.h
index d9d2675..402d010 100644
--- a/include/osmocom/core/tdef.h
+++ b/include/osmocom/core/tdef.h
@@ -121,11 +121,13 @@
 const struct osmo_tdef_state_timeout *osmo_tdef_get_state_timeout(uint32_t 
state,
  const struct 
osmo_tdef_state_timeout *timeouts_array);

-/*! Call osmo_fsm_inst_state_chg() or osmo_fsm_inst_state_chg_keep_timer(), 
depending on the timeouts_array, tdefs and
- * default_timeout.
+/*! Call osmo_fsm_inst_state_chg[_ms]() or 
osmo_fsm_inst_state_chg_keep_timer[_ms](),
+ * depending on the timeouts_array, tdefs and default_timeout.
  *
- * A T timer configured in sub-second precision is rounded up to the next full 
second. A timer in unit =
- * OSMO_TDEF_CUSTOM is applied as if the unit is in seconds (i.e. this macro 
does not make sense for custom units!).
+ * A timer defined with sub-millisecond precision (e.g OSMO_TDEF_US) is 
rounded up to the next full millisecond.
+ * A timer value defined in units higher than millisecond (e.g. OSMO_TDEF_S, 
OSMO_TDEF_M) is converted to milliseconds.
+ * A timer in unit = OSMO_TDEF_CUSTOM is applied as if the unit is in seconds 
(i.e. this macro does not make sense
+ * for custom units!).
  *
  * See osmo_tdef_get_state_timeout() and osmo_tdef_get().
  *
@@ -153,9 +155,10 @@
  * \param[in] state  State number to transition to.
  * \param[in] timeouts_array  Array of struct osmo_tdef_state_timeout[32] to 
look up state in.
  * \param[in] tdefs  Array of struct osmo_tdef (last entry zero initialized) 
to look up T in.
- * \param[in] default_timeout  If a T is set in timeouts_array, but no timeout 
value is configured for T, then use this
- * default timeout value as fallback, or pass -1 
to abort the program.
- * \return Return value from osmo_fsm_inst_state_chg() or 
osmo_fsm_inst_state_chg_keep_timer().
+ * \param[in] default_timeout  If a T is set in timeouts_array, but no timeout 
value is configured for T,
+ * then use this default timeout value (in 
seconds) as fallback,
+ * or pass a negative number to abort the program.
+ * \return Return value from osmo_fsm_inst_state_chg[_ms]() or 
osmo_fsm_inst_state_chg_keep_timer[_ms]().
  */
 #define osmo_tdef_fsm_inst_state_chg(fi, state, timeouts_array, tdefs, 
default_timeout) \
_osmo_tdef_fsm_inst_state_chg(fi, state, timeouts_array, tdefs, 
default_timeout, \
diff --git a/src/core/tdef.c b/src/core/tdef.c
index abbe581..4d83ee1 100644
--- a/src/core/tdef.c
+++ b/src/core/tdef.c
@@ -337,26 +337,37 @@
  const char *file, int line)
 {
const struct osmo_tdef_state_timeout *t = 
osmo_tdef_get_state_timeout(state, timeouts_array);
-   unsigned long val = 0;
+   unsigned long val_ms = 0;

/* No timeout defined for this state? */
if (!t)
return _osmo_fsm_inst_state_chg(fi, state, 0, 0, file, line);

-   if (t->T)
-   val = osmo_tdef_get(tdefs, t->T, OSMO_TDEF_S, default_timeout);
+   if (t->T) {
+   const struct osmo_tdef *tdef = osmo_tdef_get_entry((struct 
osmo_tdef*)tdefs, t->T);
+   if (tdef == NULL) {
+   /* emulate the old behavior: treat default_timeout as 
OSMO_TDEF_S */
+   OSMO_ASSERT(default_timeout >= 0);
+   val_ms = default_timeout * 1000;
+   } else {
+   val_ms = osmo_tdef_round(tdef->val, tdef->unit, 
OSMO_TDEF_MS);
+   /* emulate the old behavior: treat OSMO_TDEF_CUSTOM as 
OSMO_TDEF_S */
+   if (tdef->unit == 

[M] Change in libosmocore[master]: tests/tdef: also test OSMO_TDEF_US and negative T values

2023-12-29 Thread fixeria
fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35465?usp=email )


Change subject: tests/tdef: also test OSMO_TDEF_US and negative T values
..

tests/tdef: also test OSMO_TDEF_US and negative T values

Basically improving testing coverage...

Change-Id: I09945d277a5ec94985900a3f39f1cbb54c8ed6ff
---
M tests/tdef/tdef_test.c
M tests/tdef/tdef_test.ok
2 files changed, 39 insertions(+), 20 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/65/35465/1

diff --git a/tests/tdef/tdef_test.c b/tests/tdef/tdef_test.c
index a0fcc9a..13dcd01 100644
--- a/tests/tdef/tdef_test.c
+++ b/tests/tdef/tdef_test.c
@@ -37,6 +37,9 @@
{ .T=3, .default_val=50, .unit=OSMO_TDEF_M, .desc="50m" },
{ .T=4, .default_val=100, .unit=OSMO_TDEF_CUSTOM, .desc="100 potatoes" 
},

+   { .T=-5, .default_val=100, .unit=OSMO_TDEF_MS, .desc="X-100ms" },
+   { .T=-6, .default_val=100, .unit=OSMO_TDEF_US, .desc="X-100us" },
+
{ .T=7, .default_val=50, .desc="Water Boiling Timeout", .min_val=20, 
.max_val=800 },  // default is .unit=OSMO_TDEF_S == 0
{ .T=8, .default_val=300, .desc="Tea brewing" },
{ .T=9, .default_val=5, .unit=OSMO_TDEF_M, .desc="Let tea cool down 
before drinking" },
@@ -196,6 +199,8 @@
S_B,
S_C,
S_D,
+   S_E,
+   S_F,
S_G,
S_H,
S_I,
@@ -205,6 +210,7 @@
S_M,
S_N,
S_O,
+   /* ... gap ... */
S_X,
S_Y,
S_Z,
@@ -216,6 +222,9 @@
[S_C] = { .T = 3 },
[S_D] = { .T = 4 },

+   [S_E] = { .T = -5 },
+   [S_F] = { .T = -6 },
+
[S_G] = { .T = 7 },
[S_H] = { .T = 8 },
[S_I] = { .T = 9 },
@@ -246,31 +255,15 @@
 #define DEF_STATE(NAME) \
[S_##NAME] = { \
.name = #NAME, \
-   .out_state_mask = 0 \
-   | S(S_A) \
-   | S(S_B) \
-   | S(S_C) \
-   | S(S_D) \
-   | S(S_G) \
-   | S(S_H) \
-   | S(S_I) \
-   | S(S_J) \
-   | S(S_K) \
-   | S(S_L) \
-   | S(S_M) \
-   | S(S_N) \
-   | S(S_O) \
-   | S(S_X) \
-   | S(S_Y) \
-   | S(S_Z) \
-   , \
+   .out_state_mask = 0x, \
}

DEF_STATE(A),
DEF_STATE(B),
DEF_STATE(C),
DEF_STATE(D),
-
+   DEF_STATE(E),
+   DEF_STATE(F),
DEF_STATE(G),
DEF_STATE(H),
DEF_STATE(I),
@@ -383,7 +376,8 @@
test_tdef_fsm_state_chg(tdefs, S_B);
test_tdef_fsm_state_chg(tdefs, S_C);
test_tdef_fsm_state_chg(tdefs, S_D);
-
+   test_tdef_fsm_state_chg(tdefs, S_E);
+   test_tdef_fsm_state_chg(tdefs, S_F);
test_tdef_fsm_state_chg(tdefs, S_G);
test_tdef_fsm_state_chg(tdefs, S_H);
test_tdef_fsm_state_chg(tdefs, S_I);
diff --git a/tests/tdef/tdef_test.ok b/tests/tdef/tdef_test.ok
index 4c97dab..d934292 100644
--- a/tests/tdef/tdef_test.ok
+++ b/tests/tdef/tdef_test.ok
@@ -24,6 +24,18 @@
 osmo_tdef_get(4, m)= 100
 osmo_tdef_get(4, custom-unit)  = 100
 osmo_tdef_get(4, us)   = 100
+T-5=100ms
+osmo_tdef_get(-5, s)   = 1
+osmo_tdef_get(-5, ms)  = 100
+osmo_tdef_get(-5, m)   = 1
+osmo_tdef_get(-5, custom-unit) = 100
+osmo_tdef_get(-5, us)  = 10
+T-6=100us
+osmo_tdef_get(-6, s)   = 1
+osmo_tdef_get(-6, ms)  = 1
+osmo_tdef_get(-6, m)   = 1
+osmo_tdef_get(-6, custom-unit) = 100
+osmo_tdef_get(-6, us)  = 100
 T7=50s
 osmo_tdef_get(7, s)= 50
 osmo_tdef_get(7, ms)   = 5
@@ -156,6 +168,8 @@
  --> B (configured as T2 100 ms) rc=0; state=B T=2, 1.00 s remaining
  --> C (configured as T3 50 m) rc=0;   state=C T=3, 3000.00 s remaining
  --> D (configured as T4 100 custom-unit) rc=0;state=D T=4, 100.00 
s remaining
+ --> E (configured as T-5 100 ms) rc=0;state=E T=-5, 1.00 s 
remaining
+ --> F (configured as T-6 100 us) rc=0;state=F T=-6, 1.00 s 
remaining
  --> G (configured as T7 50 s) rc=0;   state=G T=7, 50.00 s remaining
  --> H (configured as T8 300 s) rc=0;  state=H T=8, 300.00 s remaining
  --> I (configured as T9 5 m) rc=0;state=I T=9, 300.00 s remaining

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35465?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I09945d277a5ec94985900a3f39f1cbb54c8ed6ff
Gerrit-Change-Number: 35465
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-MessageType: newchange


[M] Change in pysim[master]: test_files: Test decoder also with ff-padded input

2023-12-29 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35457?usp=email )

 (

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: test_files: Test decoder also with ff-padded input
..

test_files: Test decoder also with ff-padded input

It's customary in the SIM card universe to right-pad data with ff bytes.
So far we only test decoders without such padding, which is unrealistic.
Let's also tests the decoders with extra 'ff' padding present.

For some files this doesn't make sense, so we add a _test_no_pad class
attribute that can be spcified to prevent this new "test with ff-padding"
from being executed for the test data of the class.

Change-Id: I7f5cbb4a6f91040fe9adef9da0a1f30f9f156dae
---
M pySim/cdma_ruim.py
M pySim/ts_102_221.py
M pySim/ts_31_102.py
M pySim/ts_51_011.py
M tests/test_files.py
5 files changed, 70 insertions(+), 7 deletions(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/pySim/cdma_ruim.py b/pySim/cdma_ruim.py
index b254403..ad50e60 100644
--- a/pySim/cdma_ruim.py
+++ b/pySim/cdma_ruim.py
@@ -117,6 +117,7 @@
 _test_de_encode = [
 ( "00", { 'ms_operation_mode' : 'normal', 'additional_info' : 
'', 'rfu' : '' } ),
 ]
+_test_no_pad = True

 class OP_MODE(enum.IntEnum):
 normal = 0x00
diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py
index cb02bd3..308fc4a 100644
--- a/pySim/ts_102_221.py
+++ b/pySim/ts_102_221.py
@@ -639,6 +639,7 @@
 ( '656e', "en" ),
 ( '', None ),
 ]
+
 def __init__(self, fid='2f05', sfid=0x05, name='EF.PL', desc='Preferred 
Languages'):
 super().__init__(fid, sfid=sfid, name=name,
  desc=desc, rec_len=2, size=(2, None))
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index cce6f35..1976ae0 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -526,6 +526,7 @@
   "marine_guard": False, 
"mountain_rescue": False,
   "manual_ecall": False, 
"automatic_ecall": False } } ),
 ]
+_test_no_pad = True
 cc_construct = BcdAdapter(Rpad(Bytes(3)))
 category_construct = FlagsEnum(Byte, police=1, ambulance=2, 
fire_brigade=3, marine_guard=4,
mountain_rescue=5, manual_ecall=6, 
automatic_ecall=7)
@@ -588,6 +589,8 @@
  "prose_services": False, 
"extended_drx": False },
 "rfu": 0, "mnc_len": 2, "extensions": b'' } ),
 ]
+_test_no_pad = True
+
 class OP_MODE(enum.IntEnum):
 normal = 0x00
 type_approval = 0x80
diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py
index 6523769..0a6f774 100644
--- a/pySim/ts_51_011.py
+++ b/pySim/ts_51_011.py
@@ -141,6 +141,7 @@

"numbering_plan_id": "isdn_e164"},
"dialing_nr": "491721217212", "cap_conf_id": 255, 
"ext1_record_id": 255} )
 ]
+_test_no_pad = True

 def __init__(self, fid='6f3a', sfid=None, name='EF.ADN', desc='Abbreviated 
Dialing Numbers', ext=1, **kwargs):
 super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=(14, 
30), **kwargs)
@@ -215,6 +216,7 @@
 "call_number": "" },
 "tp_pid": "00", "tp_dcs": "00", "tp_vp_minutes": 1440 } ),
 ]
+_test_no_pad = True
 class ValidityPeriodAdapter(Adapter):
 def _decode(self, obj, context, path):
 if obj <= 143:
@@ -565,6 +567,8 @@
 ( "00",
   { "ms_operation_mode": "normal", "rfu1": 255, "rfu2": 127, 
"ofm": True, "extensions": None } ),
 ]
+_test_no_pad = True
+
 class OP_MODE(enum.IntEnum):
 normal = 0x00
 type_approval = 0x80
@@ -871,6 +875,8 @@
   False}, "num_waiting_voicemail": 0, 
"num_waiting_fax": 0, "num_waiting_email": 0,
"num_waiting_other": 0, "num_waiting_videomail": None} ),
 ]
+_test_no_pad = True
+
 def __init__(self, fid='6fca', sfid=None, name='EF.MWIS', rec_len=(5, 6),
  desc='Message Waiting Indication Status', **kwargs):
 super().__init__(fid, sfid=sfid, name=name, desc=desc, 
rec_len=rec_len, **kwargs)
diff --git a/tests/test_files.py b/tests/test_files.py
index 2eaaad1..9fdb022 100755
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -64,12 +64,20 @@
 name = get_qualified_name(c)
 if hasattr(c, '_test_decode'):
 for t in c._test_decode:
+encoded, rec_num, decoded = self._parse_t(t)
 with self.subTest(name, test_decode=t):
 inst 

[M] Change in pysim[master]: sysmocom_sja2: Implement EF_CHV files using construct

2023-12-29 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35458?usp=email )

 (

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: sysmocom_sja2: Implement EF_CHV files using construct
..

sysmocom_sja2: Implement EF_CHV files using construct

this has the advantage of getting the encoder for free (so far we only
had the decoder).  While at it, also add some tests data for the unit
tests.

Change-Id: Ifb8caf5cd96706d7fb6b452d6552b115c0828797
---
M pySim/sysmocom_sja2.py
1 file changed, 37 insertions(+), 20 deletions(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




diff --git a/pySim/sysmocom_sja2.py b/pySim/sysmocom_sja2.py
index a25bece..5bec446 100644
--- a/pySim/sysmocom_sja2.py
+++ b/pySim/sysmocom_sja2.py
@@ -46,27 +46,31 @@


 class EF_PIN(TransparentEF):
-def __init__(self, fid, name):
+_test_de_encode = [
+( 'f10303313233340a0a3132333435363738',
+  { 'state': { 'valid': True, 'change_able': True, 'unblock_able': 
True, 'disable_able': True,
+   'not_initialized': False, 'disabled': True },
+   'attempts_remaining': 3, 'maximum_attempts': 3, 'pin': '31323334',
+   'puk': { 'attempts_remaining': 10, 'maximum_attempts': 10, 'puk': 
'3132333435363738' }
+  } ),
+( 'f00303',
+  { 'state': { 'valid': True, 'change_able': True, 'unblock_able': 
True, 'disable_able': True,
+   'not_initialized': False, 'disabled': False },
+   'attempts_remaining': 3, 'maximum_attempts': 3, 'pin': 
'',
+   'puk': None } ),
+]
+def __init__(self, fid='6f01', name='EF.CHV1'):
 super().__init__(fid, name=name, desc='%s PIN file' % name)
-
-def _decode_bin(self, raw_bin_data):
-u = unpack('!BBB8s', raw_bin_data[:11])
-res = {'enabled': (True, False)[u[0] & 0x01],
-   'initialized': (True, False)[u[0] & 0x02],
-   'disable_able': (False, True)[u[0] & 0x10],
-   'unblock_able': (False, True)[u[0] & 0x20],
-   'change_able': (False, True)[u[0] & 0x40],
-   'valid': (False, True)[u[0] & 0x80],
-   'attempts_remaining': u[1],
-   'maximum_attempts': u[2],
-   'pin': u[3].hex(),
-   }
-if len(raw_bin_data) == 21:
-u2 = unpack('!BB8s', raw_bin_data[11:10])
-res['attempts_remaining_puk'] = u2[0]
-res['maximum_attempts_puk'] = u2[1]
-res['puk'] = u2[2].hex()
-return res
+StateByte = FlagsEnum(Byte, disabled=1, not_initialized=2, 
disable_able=0x10, unblock_able=0x20,
+change_able=0x40, valid=0x80)
+PukStruct = Struct('attempts_remaining'/Int8ub,
+   'maximum_attempts'/Int8ub,
+   'puk'/HexAdapter(Rpad(Bytes(8
+self._construct = Struct('state'/StateByte,
+ 'attempts_remaining'/Int8ub,
+ 'maximum_attempts'/Int8ub,
+ 'pin'/HexAdapter(Rpad(Bytes(8))),
+ 'puk'/Optional(PukStruct))


 class EF_MILENAGE_CFG(TransparentEF):

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35458?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ifb8caf5cd96706d7fb6b452d6552b115c0828797
Gerrit-Change-Number: 35458
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


[S] Change in pysim[master]: Fix TLV_IE_Collection.from_tlv in certain situations

2023-12-29 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35455?usp=email )

 (

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: Fix TLV_IE_Collection.from_tlv in certain situations
..

Fix TLV_IE_Collection.from_tlv in certain situations

The existing code used to produce an empty output in situations where a
TLV_IE_Collection would be parsed from a single TLV only with some
additional trailing padding:

>>> from pySim.utils import h2b
>>> from pySim.ts_31_102 import EF_CSGT
>>> t = EF_CSGT.Csgt_TLV_Collection()
>>> t.from_tlv(h2b('8906810300666f6fff'))
[TextCsgType(foo)]
>>> t.to_dict()
[]

This was caused by an early return (actually returning the decoded
result) but *without updating self.children*.

Change-Id: I1c84ccf698c6ff7e7f14242f9aaf7d15ac2239f4
---
M pySim/tlv.py
1 file changed, 25 insertions(+), 1 deletion(-)

Approvals:
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/pySim/tlv.py b/pySim/tlv.py
index 4ac5ebf..ccf049e 100644
--- a/pySim/tlv.py
+++ b/pySim/tlv.py
@@ -361,7 +361,7 @@
 # obtain the tag at the start of the remainder
 tag, r = first._parse_tag_raw(remainder)
 if tag == None:
-return res
+break
 if tag in self.members_by_tag:
 cls = self.members_by_tag[tag]
 # create an instance and parse accordingly

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35455?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I1c84ccf698c6ff7e7f14242f9aaf7d15ac2239f4
Gerrit-Change-Number: 35455
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


[M] Change in pysim[master]: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A

2023-12-29 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35452?usp=email )

Change subject: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A
..

Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A

TS 102 221 Annex A defines three variants of encoding UCS-2 characters
into byte streams in files on UICC cards: One rather simplistic one, and
two variants for optimizing memory utilization on the card.

Let's impelement a construct "Ucs2Adapter" class for this.

Change-Id: Ic8bc8f71079faec1bf0e538dc0dfa21403869c6d
---
M pySim/construct.py
M tests/test_construct.py
2 files changed, 217 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve




diff --git a/pySim/construct.py b/pySim/construct.py
index f78adfe..778a878 100644
--- a/pySim/construct.py
+++ b/pySim/construct.py
@@ -48,6 +48,164 @@
 def _encode(self, obj, context, path):
 return codecs.encode(obj, "utf-8")

+class Ucs2Adapter(Adapter):
+"""convert a bytes() type that contains UCS2 encoded characters encoded as 
defined in TS 102 221
+Annex A to normal python string representation (and back)."""
+def _decode(self, obj, context, path):
+# In case the string contains only 0xff bytes we interpret it as an 
empty string
+if obj == b'\xff' * len(obj):
+return ""
+if obj[0] == 0x80:
+# TS 102 221 Annex A Variant 1
+return codecs.decode(obj[1:], 'utf_16_be')
+elif obj[0] == 0x81:
+# TS 102 221 Annex A Variant 2
+out = ""
+# second byte contains a value indicating the number of characters
+num_of_chars = obj[1]
+# the third byte contains an 8 bit number which defines bits 15 to 
8 of a 16 bit base
+# pointer, where bit 16 is set to zero, and bits 7 to 1 are also 
set to zero. These
+# sixteen bits constitute a base pointer to a "half-page" in the 
UCS2 code space
+base_ptr = obj[2] << 7
+for ch in obj[3:3+num_of_chars]:
+# if bit 8 of the byte is set to zero, the remaining 7 bits of 
the byte contain a
+# GSM Default Alphabet character, whereas if bit 8 of the byte 
is set to one, then
+# the remaining seven bits are an offset value added to the 16 
bit base pointer
+# defined earlier, and the resultant 16 bit value is a UCS2 
code point
+if ch & 0x80:
+codepoint = (ch & 0x7f) + base_ptr
+out += codecs.decode(codepoint.to_bytes(2, 
byteorder='big'), 'utf_16_be')
+else:
+out += codecs.decode(bytes([ch]), 'gsm03.38')
+return out
+elif obj[0] == 0x82:
+# TS 102 221 Annex A Variant 3
+out = ""
+# second byte contains a value indicating the number of characters
+num_of_chars = obj[1]
+# third and fourth bytes contain a 16 bit number which defines the 
complete 16 bit base
+# pointer to a half-page in the UCS2 code space, for use with some 
or all of the
+# remaining bytes in the string
+base_ptr = obj[2] << 8 | obj[3]
+for ch in obj[4:4+num_of_chars]:
+# if bit 8 of the byte is set to zero, the remaining 7 bits of 
the byte contain a
+# GSM Default Alphabet character, whereas if bit 8 of the byte 
is set to one, the
+# remaining seven bits are an offset value added to the base 
pointer defined in
+# bytes three and four, and the resultant 16 bit value is a 
UCS2 code point, else: #
+# GSM default alphabet
+if ch & 0x80:
+codepoint = (ch & 0x7f) + base_ptr
+out += codecs.decode(codepoint.to_bytes(2, 
byteorder='big'), 'utf_16_be')
+else:
+out += codecs.decode(bytes([ch]), 'gsm03.38')
+return out
+else:
+raise ValueError('First byte of TS 102 221 UCS-2 must be 0x80, 
0x81 or 0x82')
+
+def _encode(self, obj, context, path):
+def encodable_in_gsm338(instr: str) -> bool:
+"""Determine if given input string is encode-ale in gsm03.38."""
+try:
+# TODO: figure out if/how we can constrain to default 
alphabet.  The gsm0338
+# library seems to include the spanish lock/shift table
+codecs.encode(instr, 'gsm03.38')
+except ValueError:
+return False
+return True
+
+def codepoints_not_in_gsm338(instr: str) -> typing.List[int]:
+"""Return an integer list of UCS2 codepoints for all characters of 
'inster'
+which are not 

[M] Change in pysim[master]: support UCS-2 characters in EF.MMSUP, EF.ADN, EF.SPN, EF.PNN, EF.ECC

2023-12-29 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35453?usp=email )

Change subject: support UCS-2 characters in EF.MMSUP, EF.ADN, EF.SPN, EF.PNN, 
EF.ECC
..

support UCS-2 characters in EF.MMSUP, EF.ADN, EF.SPN, EF.PNN, EF.ECC

Now that we have support for the UCS-2 encoding as per TS 102 221 Annex A,
we can start to make use of it from various file constructs.

As some specs say "Either 7-bit GSM or UCS-2" we also introduce
a related automatic GsmOrUcs2Adapter and GsmOrUcs2String class.

Change-Id: I4eb8aea0a13260a143e2c60fca73c3c4312fd3b2
---
M pySim/construct.py
M pySim/ts_31_102.py
M pySim/ts_51_011.py
3 files changed, 56 insertions(+), 4 deletions(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




diff --git a/pySim/construct.py b/pySim/construct.py
index 778a878..1ed3576 100644
--- a/pySim/construct.py
+++ b/pySim/construct.py
@@ -48,6 +48,29 @@
 def _encode(self, obj, context, path):
 return codecs.encode(obj, "utf-8")

+class GsmOrUcs2Adapter(Adapter):
+"""Try to encode into a GSM 03.38 string; if that fails, fall back to 
UCS-2 as described
+in TS 102 221 Annex A."""
+def _decode(self, obj, context, path):
+# In case the string contains only 0xff bytes we interpret it as an 
empty string
+if obj == b'\xff' * len(obj):
+return ""
+# one of the magic bytes of TS 102 221 Annex A
+if obj[0] in [0x80, 0x81, 0x82]:
+ad = Ucs2Adapter(GreedyBytes)
+else:
+ad = GsmString(GreedyBytes)
+return ad._decode(obj, context, path)
+
+def _encode(self, obj, context, path):
+# first try GSM 03.38; then fall back to TS 102 221 Annex A UCS-2
+try:
+ad = GsmString(GreedyBytes)
+return ad._encode(obj, context, path)
+except:
+ad = Ucs2Adapter(GreedyBytes)
+return ad._encode(obj, context, path)
+
 class Ucs2Adapter(Adapter):
 """convert a bytes() type that contains UCS2 encoded characters encoded as 
defined in TS 102 221
 Annex A to normal python string representation (and back)."""
@@ -447,6 +470,20 @@
 '''
 return GsmStringAdapter(Rpad(Bytes(n), pattern=b'\xff'), codec='gsm03.38')

+def GsmOrUcs2String(n):
+'''
+GSM 03.38 or UCS-2 (TS 102 221 Annex A) encoded byte string of fixed 
length n.
+Encoder appends padding bytes (b'\\xff') to maintain
+length. Decoder removes those trailing bytes.
+
+Exceptions are raised for invalid characters
+and length excess.
+
+Parameters:
+n (Integer): Fixed length of the encoded byte string
+'''
+return GsmOrUcs2Adapter(Rpad(Bytes(n), pattern=b'\xff'))
+
 class GreedyInteger(Construct):
 """A variable-length integer implementation, think of combining 
GrredyBytes with BytesInteger."""
 def __init__(self, signed=False, swapped=False, minlen=0):
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index 16526c2..1a35cb7 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -529,7 +529,7 @@
 cc_construct = BcdAdapter(Rpad(Bytes(3)))
 category_construct = FlagsEnum(Byte, police=1, ambulance=2, 
fire_brigade=3, marine_guard=4,
mountain_rescue=5, manual_ecall=6, 
automatic_ecall=7)
-alpha_construct = GsmStringAdapter(Rpad(GreedyBytes))
+alpha_construct = GsmOrUcs2Adapter(Rpad(GreedyBytes))

 def __init__(self, fid='6fb7', sfid=0x01, name='EF.ECC',
  desc='Emergency Call Codes'):
diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py
index 422b35e..6523769 100644
--- a/pySim/ts_51_011.py
+++ b/pySim/ts_51_011.py
@@ -145,7 +145,7 @@
 def __init__(self, fid='6f3a', sfid=None, name='EF.ADN', desc='Abbreviated 
Dialing Numbers', ext=1, **kwargs):
 super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=(14, 
30), **kwargs)
 ext_name = 'ext%u_record_id' % ext
-self._construct = 
Struct('alpha_id'/COptional(GsmStringAdapter(Rpad(Bytes(this._.total_len-14)), 
codec='ascii')),
+self._construct = 
Struct('alpha_id'/COptional(GsmOrUcs2Adapter(Rpad(Bytes(this._.total_len-14,
  'len_of_bcd'/Int8ub,
  'ton_npi'/TonNpi,
  
'dialing_nr'/ExtendedBcdAdapter(BcdAdapter(Rpad(Bytes(10,
@@ -514,7 +514,7 @@
 'hide_in_oplmn'/Flag,
 'show_in_hplmn'/Flag,
 # Bytes 2..17
-'spn'/Bytewise(GsmString(16))
+'spn'/Bytewise(GsmOrUcs2String(16))
 )

 # TS 51.011 Section 10.3.13
@@ -929,7 +929,7 @@
 # TS 51.011 Section 10.3.54
 class EF_MMSUP(LinFixedEF):
 class MMS_UserPref_ProfileName(BER_TLV_IE, tag=0x81):
-pass
+_construct = GsmOrUcs2Adapter(GreedyBytes)

 class 

[M] Change in pysim[master]: ts_31_102: Implement decoders/encoders for EFs below DF.HNB

2023-12-29 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35454?usp=email )

Change subject: ts_31_102: Implement decoders/encoders for EFs below DF.HNB
..

ts_31_102: Implement decoders/encoders for EFs below DF.HNB

These files are mostly related to CSG (Closed Subscriber Group)
in the context of HomeNodeB (HNB), aka femtocells.

Change-Id: Ie57963381e928e2c1da408ad46549a780056242a
---
M pySim/ts_31_102.py
1 file changed, 95 insertions(+), 6 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve




diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index 1a35cb7..cce6f35 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -949,6 +949,83 @@


 ##
+# DF.NHB
+##
+
+# 3GPP TS 31.102 Section 4.4.6.2
+class EF_ACSGL(LinFixedEF):
+_test_de_encode = [
+( 'a00d800362f210810602e0',
+  {'csg_list': [{'plmn': '262-01'},
+{'csg_information': { 'csg_type': 'from_other_sources',
+  'hnb_name_indication': 
'from_other_sources',
+  'csg_id': { 'id': 23 } } } ] } ),
+]
+class Plmn(BER_TLV_IE, tag=0x80):
+_construct = PlmnAdapter(Bytes(3))
+class CsgInformation(BER_TLV_IE, tag=0x81):
+_construct = Struct('csg_type'/Enum(Int8ub, from_other_sources=0),
+'hnb_name_indication'/Enum(Int8ub, 
from_other_sources=0),
+'csg_id'/BitStruct('id'/BitsInteger(27), 
Padding(5)))
+class CsgList(BER_TLV_IE, tag=0xa0, nested=[Plmn, CsgInformation]):
+pass
+def __init__(self, fid='4f81', sfid=0x01, name='EF.ACSGL', desc='Allowed 
CSG Lists', service=86, **kwargs):
+super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, 
service=service, rec_len=(1, None), **kwargs)
+self._tlv = EF_ACSGL.CsgList
+
+# 3GPP TS 31.102 Section 4.4.6.3
+class EF_CSGT(LinFixedEF):
+_test_de_encode = [
+( '8906810300666f6f', [{ 'text_csg_type': 'foo' }] ),
+( '8906810300666f6f801068747470733a2f2f666f6f2e6261722f',
+  [{ 'text_csg_type': 'foo' }, { "graphics_csg_type_uri": 
"https://foo.bar/; }] ),
+]
+class TextCsgType(BER_TLV_IE, tag=0x89):
+_construct = Ucs2Adapter(GreedyBytes)
+class GraphicsCsgTypeURI(BER_TLV_IE, tag=0x80):
+_construct = Utf8Adapter(GreedyBytes)
+class GraphicsCsgTypeEfImg(BER_TLV_IE, tag=0x81):
+_construct = Int8ub
+class Csgt_TLV_Collection(TLV_IE_Collection,
+  nested=[TextCsgType, GraphicsCsgTypeURI, 
GraphicsCsgTypeEfImg]):
+pass
+def __init__(self, fid='4f82', sfid=0x02, name='EF.CSGT', desc='CSG 
Types', service=86, **kwargs):
+super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, 
service=service, rec_len=(1, None), **kwargs)
+self._tlv = EF_CSGT.Csgt_TLV_Collection
+
+
+# 3GPP TS 31.102 Section 4.4.6.4
+class EF_HNBN(LinFixedEF):
+_test_de_encode = [
+( '800b8108006d61686c7a656974', { 'hnb_name': 'mahlzeit' }),
+]
+class HnbName(BER_TLV_IE, tag=0x80):
+_construct = Ucs2Adapter(GreedyBytes)
+def __init__(self, fid='4f83', sfid=0x03, name='EF.HNBN', desc='Home NodeB 
Name', service=86, **kwargs):
+super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, 
service=service, rec_len=(1, None), **kwargs)
+self._tlv = EF_HNBN.HnbName
+
+# 3GPP TS 31.102 Section 4.4.6.5
+class EF_OCSGL(LinFixedEF):
+_test_de_encode = [
+( 'a010800362f210810602e0820100',
+  {'operator_csg_list': [{'plmn': '262-01'},
+ {'csg_information': { 'csg_type': 
'from_other_sources',
+  'hnb_name_indication': 
'from_other_sources',
+  'csg_id': { 'id': 23 } } },
+ {'csg_display_indicator': 
'all_available_csg_ids' } ] } ),
+
+]
+class CsgDisplayIndicator(BER_TLV_IE, tag=0x82):
+_construct = Enum(Int8ub, all_available_csg_ids=0, 
only_ocsgl_csg_ids=1)
+class OperatorCsgList(BER_TLV_IE, tag=0xa0, nested=[EF_ACSGL.Plmn, 
EF_ACSGL.CsgInformation, CsgDisplayIndicator]):
+pass
+def __init__(self, fid='4f84', sfid=0x04, name='EF.OCSGL', desc='Operator 
CSG Lists', service=90, **kwargs):
+super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, 
service=service, rec_len=(1, None), **kwargs)
+self._tlv = EF_OCSGL.OperatorCsgList
+
+
+##
 # DF.5GS
 ##

@@ -1315,12 

[M] Change in pysim[master]: tests_files.py: Reduce code duplication

2023-12-29 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35456?usp=email )

 (

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: tests_files.py: Reduce code duplication
..

tests_files.py: Reduce code duplication

Change-Id: Ib84a0ae35262a19fce3e688afe8e1678a4c59eba
---
M tests/test_files.py
1 file changed, 26 insertions(+), 24 deletions(-)

Approvals:
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/tests/test_files.py b/tests/test_files.py
index 24a80a1..2eaaad1 100755
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -39,6 +39,20 @@
 classes = all_subclasses(LinFixedEF)
 maxDiff = None

+@staticmethod
+def _parse_t(t):
+"""Parse a test description which can either be a 2-tuple of (enc, 
dec) or
+a 3-tuple of (enc, rec_nr, dec)."""
+if len(t) == 2:
+encoded = t[0]
+rec_num = 1
+decoded = t[1]
+else:
+encoded = t[0]
+rec_num = t[1]
+decoded = t[2]
+return encoded, rec_num, decoded
+
 def test_decode_record(self):
 """Test the decoder for a linear-fixed EF.  Requires the given 
LinFixedEF subclass
 to have an '_test_decode' attribute, containing a list of tuples. Each 
tuple can
@@ -52,14 +66,7 @@
 for t in c._test_decode:
 with self.subTest(name, test_decode=t):
 inst = c()
-if len(t) == 2:
-encoded = t[0]
-rec_num = 1
-decoded = t[1]
-else:
-encoded = t[0]
-rec_num = t[1]
-decoded = t[2]
+encoded, rec_num, decoded = self._parse_t(t)
 logging.debug("Testing decode of %s", name)
 re_dec = inst.decode_record_hex(encoded, rec_num)
 self.assertEqual(decoded, re_dec)
@@ -77,14 +84,7 @@
 for t in c._test_encode:
 with self.subTest(name, test_encode=t):
 inst = c()
-if len(t) == 2:
-encoded = t[0]
-rec_num = 1
-decoded = t[1]
-else:
-encoded = t[0]
-rec_num = t[1]
-decoded = t[2]
+encoded, rec_num, decoded = self._parse_t(t)
 logging.debug("Testing encode of %s", name)
 re_enc = inst.encode_record_hex(decoded, rec_num)
 self.assertEqual(encoded.upper(), re_enc.upper())
@@ -106,14 +106,7 @@
 for t in c._test_de_encode:
 with self.subTest(name, test_de_encode=t):
 inst = c()
-if len(t) == 2:
-encoded = t[0]
-rec_num = 1
-decoded = t[1]
-else:
-encoded = t[0]
-rec_num = t[1]
-decoded = t[2]
+encoded, rec_num, decoded = self._parse_t(t)
 logging.debug("Testing decode of %s", name)
 re_dec = inst.decode_record_hex(encoded, rec_num)
 self.assertEqual(decoded, re_dec)

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35456?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib84a0ae35262a19fce3e688afe8e1678a4c59eba
Gerrit-Change-Number: 35456
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


[M] Change in pysim[master]: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A

2023-12-29 Thread laforge
Attention is currently required from: dexter.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35452?usp=email )

Change subject: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A
..


Patch Set 6: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35452?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic8bc8f71079faec1bf0e538dc0dfa21403869c6d
Gerrit-Change-Number: 35452
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 19:02:39 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: support UCS-2 characters in EF.MMSUP, EF.ADN, EF.SPN, EF.PNN, EF.ECC

2023-12-29 Thread laforge
Attention is currently required from: dexter.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35453?usp=email )

Change subject: support UCS-2 characters in EF.MMSUP, EF.ADN, EF.SPN, EF.PNN, 
EF.ECC
..


Patch Set 6: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35453?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4eb8aea0a13260a143e2c60fca73c3c4312fd3b2
Gerrit-Change-Number: 35453
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 19:02:36 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: ts_31_102: Implement decoders/encoders for EFs below DF.HNB

2023-12-29 Thread laforge
Attention is currently required from: dexter.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35454?usp=email )

Change subject: ts_31_102: Implement decoders/encoders for EFs below DF.HNB
..


Patch Set 7: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35454?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie57963381e928e2c1da408ad46549a780056242a
Gerrit-Change-Number: 35454
Gerrit-PatchSet: 7
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 19:02:31 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: ts_31_102: Implement decoders/encoders for EFs below DF.HNB

2023-12-29 Thread fixeria
Attention is currently required from: dexter, laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35454?usp=email )

Change subject: ts_31_102: Implement decoders/encoders for EFs below DF.HNB
..


Patch Set 7: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35454?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie57963381e928e2c1da408ad46549a780056242a
Gerrit-Change-Number: 35454
Gerrit-PatchSet: 7
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 17:53:20 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in libosmocore[master]: tests: fix update-exp: soft_uart_test overwrites rlp_test.ok

2023-12-29 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35463?usp=email )

Change subject: tests: fix update-exp: soft_uart_test overwrites rlp_test.ok
..

tests: fix update-exp: soft_uart_test overwrites rlp_test.ok

Change-Id: I41ea2c3d5b1e2e0349740acd63c39413472e0dad
Fixes: 9ef304dd2 "soft_uart: add unit tests for the receiver and transmitter"
---
M tests/Makefile.am
1 file changed, 11 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4eac635..72ecc1e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -709,7 +709,7 @@
>$(srcdir)/osmo_io/osmo_io_test.ok \
2>$(srcdir)/osmo_io/osmo_io_test.err
soft_uart/soft_uart_test \
-   >$(srcdir)/soft_uart/soft_uart.ok \
+   >$(srcdir)/soft_uart/soft_uart.ok
rlp/rlp_test \
>$(srcdir)/rlp/rlp_test.ok \
$(NULL)

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35463?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I41ea2c3d5b1e2e0349740acd63c39413472e0dad
Gerrit-Change-Number: 35463
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


[M] Change in pysim[master]: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A

2023-12-29 Thread fixeria
Attention is currently required from: dexter, laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35452?usp=email )

Change subject: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A
..


Patch Set 6: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35452?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic8bc8f71079faec1bf0e538dc0dfa21403869c6d
Gerrit-Change-Number: 35452
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 17:52:48 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A

2023-12-29 Thread laforge
Attention is currently required from: dexter, fixeria.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35452?usp=email )

Change subject: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A
..


Patch Set 6:

(2 comments)

File pySim/construct.py:

https://gerrit.osmocom.org/c/pysim/+/35452/comment/88c1b685_619fccae
PS5, Line 79: ch.to_bytes(1, byteorder='big'),
> Not critical, but for just one byte I would rather do `bytes([ch])`. Same 
> below.
Done


https://gerrit.osmocom.org/c/pysim/+/35452/comment/31d5f9f4_6722184e
PS5, Line 81: elif obj[0] == 0x82:
> We may want to raise an exception if `obj[0]` is neither `0x81` nor `0x82`, 
> rather than returning `N […]
Done



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35452?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic8bc8f71079faec1bf0e538dc0dfa21403869c6d
Gerrit-Change-Number: 35452
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: fixeria 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 17:52:23 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: fixeria 
Gerrit-MessageType: comment


[M] Change in pysim[master]: add PlmnAdapter for decoding PLMN bcd-strings like 262f01 to 262-01

2023-12-29 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35451?usp=email )

Change subject: add PlmnAdapter for decoding PLMN bcd-strings like 262f01 to 
262-01
..

add PlmnAdapter for decoding PLMN bcd-strings like 262f01 to 262-01

The human representation of a PLMN is usually MCC-MNC like 262-01
or 262-001.  Let's add a PlmnAdapter for use within construct, so we
can properly decode that.

Change-Id: I96f276e6dcdb54a5a3d2bcde5ee6dbaf981ed789
---
M pySim/cat.py
M pySim/construct.py
M pySim/gsm_r.py
M pySim/ts_31_102.py
M pySim/ts_51_011.py
M pysim-testdata/pySim-trace_test_gsmtap.pcapng.ok
6 files changed, 47 insertions(+), 17 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve




diff --git a/pySim/cat.py b/pySim/cat.py
index e98ce4a..5925bf3 100644
--- a/pySim/cat.py
+++ b/pySim/cat.py
@@ -22,7 +22,7 @@
 from typing import List
 from pySim.utils import b2h, h2b, dec_xplmn_w_act
 from pySim.tlv import TLV_IE, COMPR_TLV_IE, BER_TLV_IE, TLV_IE_Collection
-from pySim.construct import BcdAdapter, HexAdapter, GsmStringAdapter, TonNpi
+from pySim.construct import PlmnAdapter, BcdAdapter, HexAdapter, 
GsmStringAdapter, TonNpi
 from construct import Int8ub, Int16ub, Byte, Bytes, Bit, Flag, BitsInteger
 from construct import Struct, Enum, Tell, BitStruct, this, Padding, RepeatUntil
 from construct import GreedyBytes, Switch, GreedyRange, FlagsEnum
@@ -597,7 +597,7 @@

 # TS 31.111 Section 8.91
 class RoutingAreaIdentification(COMPR_TLV_IE, tag=0xF3):
-_construct = Struct('mcc_mnc'/BcdAdapter(Bytes(3)),
+_construct = Struct('mcc_mnc'/PlmnAdapter(Bytes(3)),
 'lac'/HexAdapter(Bytes(2)),
 'rac'/Int8ub)

@@ -645,7 +645,7 @@

 # TS 31.111 Section 8.97
 class PlmnList(COMPR_TLV_IE, tag=0xF9):
-_construct = GreedyRange('mcc_mnc'/HexAdapter(Bytes(3)))
+_construct = GreedyRange('mcc_mnc'/PlmnAdapter(Bytes(3)))

 # TS 102 223 Section 8.98
 class EcatSequenceNumber(COMPR_TLV_IE, tag=0xA1):
diff --git a/pySim/construct.py b/pySim/construct.py
index cef9557..f78adfe 100644
--- a/pySim/construct.py
+++ b/pySim/construct.py
@@ -58,6 +58,23 @@
 def _encode(self, obj, context, path):
 return h2b(swap_nibbles(obj))

+class PlmnAdapter(BcdAdapter):
+"""convert a bytes(3) type to BCD string like 262-02 or 262-002."""
+def _decode(self, obj, context, path):
+bcd = super()._decode(obj, context, path)
+if bcd[3] == 'f':
+return '-'.join([bcd[:3], bcd[4:]])
+else:
+return '-'.join([bcd[:3], bcd[3:]])
+
+def _encode(self, obj, context, path):
+l = obj.split('-')
+if len(l[1]) == 2:
+bcd = l[0] + 'f' + l[1]
+else:
+bcd = l[0] + l[1]
+return super()._encode(bcd, context, path)
+
 class InvertAdapter(Adapter):
 """inverse logic (false->true, true->false)."""
 @staticmethod
diff --git a/pySim/gsm_r.py b/pySim/gsm_r.py
index cd111d6..db7819c 100644
--- a/pySim/gsm_r.py
+++ b/pySim/gsm_r.py
@@ -202,12 +202,12 @@
 class EF_GsmrPLMN(LinFixedEF):
 """Section 7.7"""
 _test_de_encode = [
-( "22f860f86f8d6f8e01", { "plmn": "228f06", "class_of_network": {
+( "22f860f86f8d6f8e01", { "plmn": "228-06", "class_of_network": {
 "supported": { "vbs": True, "vgcs": True, 
"emlpp": True,
 "fn": True, "eirene": True }, 
"preference": 0 },
   "ic_incoming_ref_tbl": "6f8d", 
"outgoing_ref_tbl": "6f8e",
   "ic_table_ref": "01" } ),
-( "22f810416f8d6f8e02", { "plmn": "228f01", "class_of_network": {
+( "22f810416f8d6f8e02", { "plmn": "228-01", "class_of_network": {
 "supported": { "vbs": False, "vgcs": 
False, "emlpp": False,
 "fn": True, "eirene": False }, 
"preference": 1 },
   "ic_incoming_ref_tbl": "6f8d", 
"outgoing_ref_tbl": "6f8e",
@@ -216,7 +216,7 @@
 def __init__(self):
 super().__init__(fid='6ff5', sfid=None, name='EF.GsmrPLMN',
  desc='GSM-R network selection', rec_len=(9, 9))
-self._construct = Struct('plmn'/BcdAdapter(Bytes(3)),
+self._construct = Struct('plmn'/PlmnAdapter(Bytes(3)),
  
'class_of_network'/BitStruct('supported'/FlagsEnum(BitsInteger(5), vbs=1, 
vgcs=2, emlpp=4, fn=8, eirene=16),
   
'preference'/BitsInteger(3)),
  'ic_incoming_ref_tbl'/HexAdapter(Bytes(2)),
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py
index b5faf08..16526c2 100644
--- a/pySim/ts_31_102.py
+++ b/pySim/ts_31_102.py
@@ -566,14 +566,14 @@
 

[M] Change in pysim[master]: ts_31_102: Implement decoders/encoders for EFs below DF.HNB

2023-12-29 Thread laforge
Attention is currently required from: dexter, fixeria.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35454?usp=email )

Change subject: ts_31_102: Implement decoders/encoders for EFs below DF.HNB
..


Patch Set 7:

(1 comment)

File pySim/ts_31_102.py:

https://gerrit.osmocom.org/c/pysim/+/35454/comment/d3fc410b_6c5de1ae
PS6, Line 1023: service=86
> It was `service=90` before your patch, are you sure this is correct?
thanks, that was indeed an error



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35454?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie57963381e928e2c1da408ad46549a780056242a
Gerrit-Change-Number: 35454
Gerrit-PatchSet: 7
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: fixeria 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 17:52:07 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: fixeria 
Gerrit-MessageType: comment


[M] Change in pysim[master]: sysmocom_sja2: Implement EF_CHV files using construct

2023-12-29 Thread laforge
Attention is currently required from: dexter.

Hello Jenkins Builder, dexter, fixeria,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/pysim/+/35458?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder

The change is no longer submittable: Verified is unsatisfied now.


Change subject: sysmocom_sja2: Implement EF_CHV files using construct
..

sysmocom_sja2: Implement EF_CHV files using construct

this has the advantage of getting the encoder for free (so far we only
had the decoder).  While at it, also add some tests data for the unit
tests.

Change-Id: Ifb8caf5cd96706d7fb6b452d6552b115c0828797
---
M pySim/sysmocom_sja2.py
1 file changed, 37 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/58/35458/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35458?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ifb8caf5cd96706d7fb6b452d6552b115c0828797
Gerrit-Change-Number: 35458
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Attention: dexter 
Gerrit-MessageType: newpatchset


[M] Change in pysim[master]: test_files: Test decoder also with ff-padded input

2023-12-29 Thread laforge
Attention is currently required from: dexter.

Hello Jenkins Builder, dexter, fixeria,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/pysim/+/35457?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder

The change is no longer submittable: Verified is unsatisfied now.


Change subject: test_files: Test decoder also with ff-padded input
..

test_files: Test decoder also with ff-padded input

It's customary in the SIM card universe to right-pad data with ff bytes.
So far we only test decoders without such padding, which is unrealistic.
Let's also tests the decoders with extra 'ff' padding present.

For some files this doesn't make sense, so we add a _test_no_pad class
attribute that can be spcified to prevent this new "test with ff-padding"
from being executed for the test data of the class.

Change-Id: I7f5cbb4a6f91040fe9adef9da0a1f30f9f156dae
---
M pySim/cdma_ruim.py
M pySim/ts_102_221.py
M pySim/ts_31_102.py
M pySim/ts_51_011.py
M tests/test_files.py
5 files changed, 70 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/57/35457/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35457?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I7f5cbb4a6f91040fe9adef9da0a1f30f9f156dae
Gerrit-Change-Number: 35457
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Attention: dexter 
Gerrit-MessageType: newpatchset


[M] Change in pysim[master]: ts_31_102: Implement decoders/encoders for EFs below DF.HNB

2023-12-29 Thread laforge
Attention is currently required from: dexter, fixeria, laforge.

Hello Jenkins Builder, dexter, fixeria,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/pysim/+/35454?usp=email

to look at the new patch set (#7).

The following approvals got outdated and were removed:
Code-Review+1 by fixeria, Verified+1 by Jenkins Builder


Change subject: ts_31_102: Implement decoders/encoders for EFs below DF.HNB
..

ts_31_102: Implement decoders/encoders for EFs below DF.HNB

These files are mostly related to CSG (Closed Subscriber Group)
in the context of HomeNodeB (HNB), aka femtocells.

Change-Id: Ie57963381e928e2c1da408ad46549a780056242a
---
M pySim/ts_31_102.py
1 file changed, 95 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/54/35454/7
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35454?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie57963381e928e2c1da408ad46549a780056242a
Gerrit-Change-Number: 35454
Gerrit-PatchSet: 7
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: fixeria 
Gerrit-Attention: dexter 
Gerrit-MessageType: newpatchset


[S] Change in pysim[master]: Fix TLV_IE_Collection.from_tlv in certain situations

2023-12-29 Thread laforge
Attention is currently required from: laforge.

Hello Jenkins Builder, fixeria,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/pysim/+/35455?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder

The change is no longer submittable: Verified is unsatisfied now.


Change subject: Fix TLV_IE_Collection.from_tlv in certain situations
..

Fix TLV_IE_Collection.from_tlv in certain situations

The existing code used to produce an empty output in situations where a
TLV_IE_Collection would be parsed from a single TLV only with some
additional trailing padding:

>>> from pySim.utils import h2b
>>> from pySim.ts_31_102 import EF_CSGT
>>> t = EF_CSGT.Csgt_TLV_Collection()
>>> t.from_tlv(h2b('8906810300666f6fff'))
[TextCsgType(foo)]
>>> t.to_dict()
[]

This was caused by an early return (actually returning the decoded
result) but *without updating self.children*.

Change-Id: I1c84ccf698c6ff7e7f14242f9aaf7d15ac2239f4
---
M pySim/tlv.py
1 file changed, 25 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/55/35455/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35455?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I1c84ccf698c6ff7e7f14242f9aaf7d15ac2239f4
Gerrit-Change-Number: 35455
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-MessageType: newpatchset


[M] Change in pysim[master]: tests_files.py: Reduce code duplication

2023-12-29 Thread laforge
Attention is currently required from: laforge.

Hello Jenkins Builder, fixeria,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/pysim/+/35456?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder

The change is no longer submittable: Verified is unsatisfied now.


Change subject: tests_files.py: Reduce code duplication
..

tests_files.py: Reduce code duplication

Change-Id: Ib84a0ae35262a19fce3e688afe8e1678a4c59eba
---
M tests/test_files.py
1 file changed, 26 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/56/35456/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35456?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib84a0ae35262a19fce3e688afe8e1678a4c59eba
Gerrit-Change-Number: 35456
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-MessageType: newpatchset


[M] Change in pysim[master]: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A

2023-12-29 Thread laforge
Attention is currently required from: dexter, fixeria, laforge.

Hello Jenkins Builder, dexter, fixeria,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/pysim/+/35452?usp=email

to look at the new patch set (#6).

The following approvals got outdated and were removed:
Code-Review+1 by fixeria, Verified+1 by Jenkins Builder


Change subject: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A
..

Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A

TS 102 221 Annex A defines three variants of encoding UCS-2 characters
into byte streams in files on UICC cards: One rather simplistic one, and
two variants for optimizing memory utilization on the card.

Let's impelement a construct "Ucs2Adapter" class for this.

Change-Id: Ic8bc8f71079faec1bf0e538dc0dfa21403869c6d
---
M pySim/construct.py
M tests/test_construct.py
2 files changed, 217 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/52/35452/6
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35452?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic8bc8f71079faec1bf0e538dc0dfa21403869c6d
Gerrit-Change-Number: 35452
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: fixeria 
Gerrit-Attention: dexter 
Gerrit-MessageType: newpatchset


[M] Change in pysim[master]: add PlmnAdapter for decoding PLMN bcd-strings like 262f01 to 262-01

2023-12-29 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35451?usp=email )

Change subject: add PlmnAdapter for decoding PLMN bcd-strings like 262f01 to 
262-01
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35451?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I96f276e6dcdb54a5a3d2bcde5ee6dbaf981ed789
Gerrit-Change-Number: 35451
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Fri, 29 Dec 2023 17:47:36 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: sysmocom_sja2: Implement EF_CHV files using construct

2023-12-29 Thread laforge
Attention is currently required from: dexter.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35458?usp=email )

Change subject: sysmocom_sja2: Implement EF_CHV files using construct
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35458?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ifb8caf5cd96706d7fb6b452d6552b115c0828797
Gerrit-Change-Number: 35458
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 17:45:47 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: test_files: Test decoder also with ff-padded input

2023-12-29 Thread laforge
Attention is currently required from: dexter.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35457?usp=email )

Change subject: test_files: Test decoder also with ff-padded input
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35457?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I7f5cbb4a6f91040fe9adef9da0a1f30f9f156dae
Gerrit-Change-Number: 35457
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 17:45:41 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: sysmocom_sja2: Implement EF_CHV files using construct

2023-12-29 Thread fixeria
Attention is currently required from: dexter, laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35458?usp=email )

Change subject: sysmocom_sja2: Implement EF_CHV files using construct
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35458?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ifb8caf5cd96706d7fb6b452d6552b115c0828797
Gerrit-Change-Number: 35458
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 12:44:23 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: test_files: Test decoder also with ff-padded input

2023-12-29 Thread fixeria
Attention is currently required from: dexter, laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35457?usp=email )

Change subject: test_files: Test decoder also with ff-padded input
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35457?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I7f5cbb4a6f91040fe9adef9da0a1f30f9f156dae
Gerrit-Change-Number: 35457
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 12:42:29 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: tests_files.py: Reduce code duplication

2023-12-29 Thread fixeria
Attention is currently required from: laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35456?usp=email )

Change subject: tests_files.py: Reduce code duplication
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35456?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ib84a0ae35262a19fce3e688afe8e1678a4c59eba
Gerrit-Change-Number: 35456
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Comment-Date: Fri, 29 Dec 2023 12:40:45 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[S] Change in pysim[master]: Fix TLV_IE_Collection.from_tlv in certain situations

2023-12-29 Thread fixeria
Attention is currently required from: laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35455?usp=email )

Change subject: Fix TLV_IE_Collection.from_tlv in certain situations
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35455?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I1c84ccf698c6ff7e7f14242f9aaf7d15ac2239f4
Gerrit-Change-Number: 35455
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Comment-Date: Fri, 29 Dec 2023 12:39:55 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: ts_31_102: Implement decoders/encoders for EFs below DF.HNB

2023-12-29 Thread fixeria
Attention is currently required from: dexter, laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35454?usp=email )

Change subject: ts_31_102: Implement decoders/encoders for EFs below DF.HNB
..


Patch Set 6: Code-Review+1

(1 comment)

File pySim/ts_31_102.py:

https://gerrit.osmocom.org/c/pysim/+/35454/comment/dea8ff98_733ceb71
PS6, Line 1023: service=86
It was `service=90` before your patch, are you sure this is correct?



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35454?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie57963381e928e2c1da408ad46549a780056242a
Gerrit-Change-Number: 35454
Gerrit-PatchSet: 6
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 12:39:16 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: support UCS-2 characters in EF.MMSUP, EF.ADN, EF.SPN, EF.PNN, EF.ECC

2023-12-29 Thread fixeria
Attention is currently required from: dexter, laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35453?usp=email )

Change subject: support UCS-2 characters in EF.MMSUP, EF.ADN, EF.SPN, EF.PNN, 
EF.ECC
..


Patch Set 5: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35453?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4eb8aea0a13260a143e2c60fca73c3c4312fd3b2
Gerrit-Change-Number: 35453
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 12:35:43 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A

2023-12-29 Thread fixeria
Attention is currently required from: dexter, laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35452?usp=email )

Change subject: Implement convoluted encoding of UCS-2 as per TS 102 221 Annex A
..


Patch Set 5: Code-Review+1

(2 comments)

File pySim/construct.py:

https://gerrit.osmocom.org/c/pysim/+/35452/comment/7ce5eab6_82f821af
PS5, Line 79: ch.to_bytes(1, byteorder='big'),
Not critical, but for just one byte I would rather do `bytes([ch])`. Same below.


https://gerrit.osmocom.org/c/pysim/+/35452/comment/2af102cf_a5d24ce2
PS5, Line 81: elif obj[0] == 0x82:
We may want to raise an exception if `obj[0]` is neither `0x81` nor `0x82`, 
rather than returning `None`?



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35452?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic8bc8f71079faec1bf0e538dc0dfa21403869c6d
Gerrit-Change-Number: 35452
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Attention: dexter 
Gerrit-Comment-Date: Fri, 29 Dec 2023 12:34:16 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


[M] Change in pysim[master]: add PlmnAdapter for decoding PLMN bcd-strings like 262f01 to 262-01

2023-12-29 Thread fixeria
Attention is currently required from: laforge.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35451?usp=email )

Change subject: add PlmnAdapter for decoding PLMN bcd-strings like 262f01 to 
262-01
..


Patch Set 3: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35451?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I96f276e6dcdb54a5a3d2bcde5ee6dbaf981ed789
Gerrit-Change-Number: 35451
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Attention: laforge 
Gerrit-Comment-Date: Fri, 29 Dec 2023 11:22:39 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment