laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35260?usp=email )
Change subject: euicc: Fix encoding of Lc value in STORE DATA
......................................................................
euicc: Fix encoding of Lc value in STORE DATA
The length value "of course" is a hex value, don't use %02u but %02x
This fixes any eUICC command with a Lc > 10 bytes.
Change-Id: I1e1efbfb9916fc43699602cc889cf4b3d42736f2
---
M pySim/euicc.py
1 file changed, 14 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/60/35260/1
diff --git a/pySim/euicc.py b/pySim/euicc.py
index 58d19f1..c070525 100644
--- a/pySim/euicc.py
+++ b/pySim/euicc.py
@@ -297,7 +297,7 @@
def store_data(scc: SimCardCommands, tx_do: Hexstr) -> Tuple[Hexstr, SwHexstr]:
"""Perform STORE DATA according to Table 47+48 in Section 5.7.2 of SGP.22.
Only single-block store supported for now."""
- capdu = '%sE29100%02u%s' % (scc.cla4lchan('80'), len(tx_do)//2, tx_do)
+ capdu = '%sE29100%02x%s' % (scc.cla4lchan('80'), len(tx_do)//2, tx_do)
return scc._tp.send_apdu_checksw(capdu)
@staticmethod
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35260?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: I1e1efbfb9916fc43699602cc889cf4b3d42736f2
Gerrit-Change-Number: 35260
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35259?usp=email )
Change subject: tests/coding: fix -Wmaybe-uninitialized in test_pdtch()
......................................................................
tests/coding: fix -Wmaybe-uninitialized in test_pdtch()
I am seeing this when building with gcc v13.2.1:
tests/coding/coding_test.c: In function ‘test_pdtch’:
tests/coding/coding_test.c:444:23: warning: ‘*result[<unknown>]’
may be used uninitialized
444 | result[len - 1] &= 0x7f;
| ~~~~~~^~~~~~~~~
tests/coding/coding_test.c:448:23: warning: ‘*result[39]’
may be used uninitialized
448 | result[len - 1] &= 0x07;
| ~~~~~~^~~~~~~~~
The idea here is to pre-clear some bits in the resulting buffer,
because they're not going to be set during decoding of the burst
bits. The problem is that result[] holds uninitialized data, so
we're basically taking a 'garbage' octet and clear some of its
bits. The remaining 'garbage' bits of that octet are overwritten
by the decoder, so in the end we still get deterministic results.
Let's make GCC happy by clearing all bits in the last octet.
Change-Id: I24d79de8b3a5f4184b71414504657e5857498e0e
---
M tests/coding/coding_test.c
1 file changed, 32 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/35259/1
diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c
index c9508f7..d536e44 100644
--- a/tests/coding/coding_test.c
+++ b/tests/coding/coding_test.c
@@ -441,11 +441,11 @@
case 34:
case 54:
l2[len - 1] &= 0x7f;
- result[len - 1] &= 0x7f;
+ result[len - 1] = 0x00;
break;
case 40:
l2[len - 1] &= 0x07;
- result[len - 1] &= 0x07;
+ result[len - 1] = 0x00;
break;
}
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35259?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: I24d79de8b3a5f4184b71414504657e5857498e0e
Gerrit-Change-Number: 35259
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35257?usp=email )
Change subject: coding: clarify the USF decoding for PDCH blocks
......................................................................
coding: clarify the USF decoding for PDCH blocks
The USF (Uplink State Flag) field is present in the MAC header of all
Downlink PDCH blocks. It is used by the network to indicate which MS
can transmit on subsequent Uplink PDCH block(s). This field is of a
high importance for the MS, thus the decoder API allows the caller
to obtain USF value separately from the actual data bits.
In the case of gsm0503_pdtch_decode(), if the 'usf_p' pointer is not
NULL, the USF value would be assigned for CS2/CS3/CS4 (but not CS1)
even if the CRC check fails (negative return value). A subsequent
patch is to bring the CS1 in consistency with CS2/CS3/CS4.
In the case of gsm0503_pdtch_egprs_decode(), decoding of the USF
field separately from data bits is not implemented, and moreover
the function itself cannot be used for decoding Downlink blocks.
Change-Id: I43e8bfb4003f34766ace7c5c6080ca583ce5efbb
---
M src/coding/gsm0503_coding.c
1 file changed, 29 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/57/35257/1
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index 612e0ad..5b78502 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -921,7 +921,7 @@
* \param[out] l2_data caller-allocated buffer for L2 Frame
* \param[in] bursts burst input data as soft unpacked bits
* \param[in] nbits number of bits in \a bursts
- * \param usf_p unused argument ?!?
+ * \param usf_p Uplink State Flag, FIXME: not implemented
* \param[out] n_errors number of detected bit-errors
* \param[out] n_bits_total total number of decoded bits
* \returns number of bytes decoded; negative on error */
@@ -1010,7 +1010,7 @@
/*! Decode GPRS PDTCH
* \param[out] l2_data caller-allocated buffer for L2 Frame
* \param[in] bursts burst input data as soft unpacked bits
- * \param[out] usf_p uplink stealing flag
+ * \param[out] usf_p Uplink State Flag, only relevant for DL blocks
* \param[out] n_errors number of detected bit-errors
* \param[out] n_bits_total total number of dcoded bits
* \returns number of bytes decoded; negative on error */
@@ -1061,6 +1061,7 @@
osmo_conv_decode_ber(&gsm0503_cs2_np, cB,
conv, n_errors, n_bits_total);
+ /* 5.1.2.2 a) the three USF bits d(0),d(1),d(2) are precoded into six bits */
for (i = 0; i < 8; i++) {
for (j = 0, k = 0; j < 6; j++)
k += abs(((int)gsm0503_usf2six[i][j]) - ((int)conv[j]));
@@ -1096,6 +1097,7 @@
osmo_conv_decode_ber(&gsm0503_cs3_np, cB,
conv, n_errors, n_bits_total);
+ /* 5.1.3.2 a) the three USF bits d(0),d(1),d(2) are precoded into six bits */
for (i = 0; i < 8; i++) {
for (j = 0, k = 0; j < 6; j++)
k += abs(((int)gsm0503_usf2six[i][j]) - ((int)conv[j]));
@@ -1124,6 +1126,7 @@
for (i = 12; i < 456; i++)
conv[i] = (cB[i] < 0) ? 1 : 0;
+ /* 5.1.4.2 a) the three USF bits d(0),d(1),d(2) are precoded into twelve bits */
for (i = 0; i < 8; i++) {
for (j = 0, k = 0; j < 12; j++)
k += abs(((int)gsm0503_usf2twelve_sbit[i][j]) - ((int)cB[j]));
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35257?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: I43e8bfb4003f34766ace7c5c6080ca583ce5efbb
Gerrit-Change-Number: 35257
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange