falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33060 )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: codec: new function osmo_hr_sid_reset()
......................................................................
codec: new function osmo_hr_sid_reset()
If a network element that receives call leg A UL and is responsible
for preparing leg B DL receives a GSM-HR SID frame whose SID field
is not all 1s but which is marked as valid SID by out-of-band means
(TRAU-UL frame control bits or the FT field in RFC 5993 ToC octet),
this SID frame should be rejuvenated (SID field reset to all 1s)
prior to retransmission on call leg B DL. Provide a function
that performs this operation.
Related: OS#6036
Change-Id: Iebc0863ffcc3f8f25aeb54d4b14fac0487bc2bbb
---
M include/osmocom/codec/codec.h
M src/codec/gsm620.c
2 files changed, 48 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/include/osmocom/codec/codec.h b/include/osmocom/codec/codec.h
index 4dbe129..c5981f8 100644
--- a/include/osmocom/codec/codec.h
+++ b/include/osmocom/codec/codec.h
@@ -131,6 +131,7 @@
bool osmo_efr_sid_preen(uint8_t *rtp_payload);
void osmo_fr_sid_reset(uint8_t *rtp_payload);
+void osmo_hr_sid_reset(uint8_t *rtp_payload);
void osmo_efr_sid_reset(uint8_t *rtp_payload);
int osmo_amr_rtp_enc(uint8_t *payload, uint8_t cmr, enum osmo_amr_type ft,
diff --git a/src/codec/gsm620.c b/src/codec/gsm620.c
index 4eae514..ef1d3b9 100644
--- a/src/codec/gsm620.c
+++ b/src/codec/gsm620.c
@@ -21,6 +21,7 @@
#include <stdint.h>
#include <stdbool.h>
+#include <string.h>
#include <osmocom/core/bitvec.h>
#include <osmocom/core/utils.h>
@@ -285,3 +286,31 @@
return true;
}
+
+/*! Reset the SID field of a potentially corrupted, but still valid GSM-HR
+ * SID frame in TS 101 318 format to its pristine state (full SID codeword).
+ * \param[in] rtp_payload Buffer with RTP payload - must be writable!
+ *
+ * Per GSM 06.22 section 5.3, a freshly minted SID frame consists of 33 bits
+ * of comfort noise parameters and 79 bits of SID codeword (all 1s). Network
+ * elements that receive SID frames from call leg A uplink and need to
+ * retransmit them on leg B downlink should "rejuvenate" received SID frames
+ * prior to retransmission by resetting the SID field to its pristine state
+ * of all 1s; this function does the job.
+ *
+ * Important note: because of HR-specific quirks (lack of exact bit counting
+ * rules in GSM 06.41 spec compared to 06.31 & 06.81, plus the fact that such
+ * bit counting can only be done efficiently in the GSM 05.03 channel decoder
+ * prior to bit reordering based on voiced or unvoiced mode), a generic
+ * (usable from any network element) SID classification function similar to
+ * osmo_{fr,efr}_sid_classify() unfortunately cannot exist for HR. Therefore,
+ * the triggering condition for invoking this SID rejuvenation/reset function
+ * can only be an out-of-band SID indication, as in GSM 08.61 TRAU frames
+ * or RFC 5993 ToC octet.
+ */
+void osmo_hr_sid_reset(uint8_t *rtp_payload)
+{
+ /* set all 79 SID codeword bits to 1 */
+ rtp_payload[4] |= 0x7F;
+ memset(rtp_payload + 5, 0xFF, 9);
+}
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33060
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iebc0863ffcc3f8f25aeb54d4b14fac0487bc2bbb
Gerrit-Change-Number: 33060
Gerrit-PatchSet: 2
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/32688 )
Change subject: docs: add SUPI/SUCI usage example
......................................................................
docs: add SUPI/SUCI usage example
Change-Id: I2908ea9df7e78c596554731085902e2ab7278328
---
M docs/conf.py
M docs/shell.rst
A docs/suci-tutorial.rst
3 files changed, 215 insertions(+), 2 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/docs/conf.py b/docs/conf.py
index 6fea583..8455007 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -18,8 +18,8 @@
# -- Project information -----------------------------------------------------
project = 'osmopysim-usermanual'
-copyright = '2009-2022 by Sylvain Munaut, Harald Welte, Philipp Maier, Supreeth Herle'
-author = 'Sylvain Munaut, Harald Welte, Philipp Maier, Supreeth Herle'
+copyright = '2009-2023 by Sylvain Munaut, Harald Welte, Philipp Maier, Supreeth Herle, Merlin Chlosta'
+author = 'Sylvain Munaut, Harald Welte, Philipp Maier, Supreeth Herle, Merlin Chlosta'
# -- General configuration ---------------------------------------------------
diff --git a/docs/shell.rst b/docs/shell.rst
index 8f440c2..510f4c6 100644
--- a/docs/shell.rst
+++ b/docs/shell.rst
@@ -36,6 +36,13 @@
:module: pySim-shell
:func: option_parser
+Usage Examples
+--------------
+.. toctree::
+ :maxdepth: 1
+ :caption: Tutorials for pySIM-shell:
+
+ suci-tutorial
cmd2 basics
diff --git a/docs/suci-tutorial.rst b/docs/suci-tutorial.rst
new file mode 100644
index 0000000..00c060f
--- /dev/null
+++ b/docs/suci-tutorial.rst
@@ -0,0 +1,197 @@
+
+Guide: Enabling 5G SUCI
+========================
+
+SUPI/SUCI Concealment is a feature of 5G-Standalone (SA) to encrypt the
+IMSI/SUPI with a network operator public key. 3GPP Specifies two different
+variants for this:
+
+* SUCI calculation *in the UE*, using data from the SIM
+* SUCI calculation *on the card itself*
+
+pySIM supports writing the 5G-specific files for *SUCI calculation in the UE* on USIM cards, assuming that
+your cards contain the required files, and you have the privileges/credentials to write to them. This is
+the case using sysmocom sysmoISIM-SJA2 cards (or successor products).
+
+In short, you can enable SUCI with these steps:
+
+* activate USIM **Service 124**
+* make sure USIM **Service 125** is disabled
+* store the public keys in **SUCI_Calc_Info**
+* set the **Routing Indicator** (required)
+
+If you want to disable the feature, you can just disable USIM Service 124 (and 125).
+
+Technical References
+~~~~~~~~~~~~~~~~~~~~
+
+This guide covers the basic workflow of provisioning SIM cards with the 5G SUCI feature. For detailed information on the SUCI feature and file contents, the following documents are helpful:
+
+* USIM files and structure: `TS 31.102 <https://www.etsi.org/deliver/etsi_ts/131100_131199/131102/16.06.00_60/ts_13…>`__
+* USIM tests (incl. file content examples) `TS 31.121 <https://www.etsi.org/deliver/etsi_ts/131100_131199/131121/16.01.00_60/ts_13…>`__
+
+For specific information on sysmocom SIM cards, refer to Section 9.1 of the `sysmoUSIM User
+Manual <https://www.sysmocom.de/manuals/sysmousim-manual.pdf>`__.
+
+--------------
+
+Admin PIN
+---------
+
+The usual way to authenticate yourself to the card as the cellular
+operator is to validate the so-called ADM1 (admin) PIN. This may differ
+from card model/vendor to card model/vendor.
+
+Start pySIM-shell and enter the admin PIN for your card. If you bought
+the SIM card from your network operator and don’t have the admin PIN,
+you cannot change SIM contents!
+
+Launch pySIM:
+
+::
+
+ $ ./pySim-shell.py -p 0
+
+ Using PC/SC reader interface
+ Autodetected card type: sysmoISIM-SJA2
+ Welcome to pySim-shell!
+ pySIM-shell (MF)>
+
+Enter the ADM PIN:
+
+::
+
+ pySIM-shell (MF)> verify_adm XXXXXXXX
+
+Otherwise, write commands will fail with ``SW Mismatch: Expected 9000 and got 6982.``
+
+Key Provisioning
+----------------
+
+::
+
+ pySIM-shell (MF)> select MF
+ pySIM-shell (MF)> select ADF.USIM
+ pySIM-shell (MF/ADF.USIM)> select DF.5GS
+ pySIM-shell (MF/ADF.USIM/DF.5GS)> select EF.SUCI_Calc_Info
+
+By default, the file is present but empty:
+
+::
+
+ pySIM-shell (MF/ADF.USIM/DF.5GS/EF.SUCI_Calc_Info)> read_binary_decoded
+ missing Protection Scheme Identifier List data object tag
+ 9000: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> {}
+
+The following JSON config defines the testfile from `TS 31.121 <https://www.etsi.org/deliver/etsi_ts/131100_131199/131121/16.01.00_60/ts_13…>`__ Section 4.9.4 with
+test keys from `TS 33.501 <hhttps://www.etsi.org/deliver/etsi_ts/133500_133599/133501/16.05.00_60/ts_1…>`__ Annex C.4. Highest priority (``0``) has a
+Profile-B (``identifier: 2``) key in key slot ``1``, which means the key
+with ``hnet_pubkey_identifier: 27``.
+
+.. code:: json
+
+ {
+ "prot_scheme_id_list": [
+ {"priority": 0, "identifier": 2, "key_index": 1},
+ {"priority": 1, "identifier": 1, "key_index": 2},
+ {"priority": 2, "identifier": 0, "key_index": 0}],
+ "hnet_pubkey_list": [
+ {"hnet_pubkey_identifier": 27,
+ "hnet_pubkey": "0272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD1"},
+ {"hnet_pubkey_identifier": 30,
+ "hnet_pubkey": "5A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650"}]
+ }
+
+Write the config to file (must be single-line input as for now):
+
+::
+
+ pySIM-shell (MF/ADF.USIM/DF.5GS/EF.SUCI_Calc_Info)> update_binary_decoded '{ "prot_scheme_id_list": [ {"priority": 0, "identifier": 2, "key_index": 1}, {"priority": 1, "identifier": 1, "key_index": 2}, {"priority": 2, "identifier": 0, "key_index": 0}], "hnet_pubkey_list": [ {"hnet_pubkey_identifier": 27, "hnet_pubkey": "0272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD1"}, {"hnet_pubkey_identifier": 30, "hnet_pubkey": "5A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650"}]}'
+
+WARNING: These are TEST KEYS with publicly known/specified private keys, and hence unsafe for live/secure
+deployments! For use in production networks, you need to generate your own set[s] of keys.
+
+Routing Indicator
+-----------------
+
+The Routing Indicator must be present for the SUCI feature. By default,
+the contents of the file is **invalid** (ffffffff):
+
+::
+
+ pySIM-shell (MF)> select MF
+ pySIM-shell (MF)> select ADF.USIM
+ pySIM-shell (MF/ADF.USIM)> select DF.5GS
+ pySIM-shell (MF/ADF.USIM/DF.5GS)> select EF.Routing_Indicator
+ pySIM-shell (MF/ADF.USIM/DF.5GS/EF.Routing_Indicator)> read_binary_decoded
+ 9000: ffffffff -> {'raw': 'ffffffff'}
+
+The Routing Indicator is a four-byte file but the actual Routing
+Indicator goes into bytes 0 and 1 (the other bytes are reserved). To set
+the Routing Indicator to 0x71:
+
+::
+
+ pySIM-shell (MF/ADF.USIM/DF.5GS/EF.Routing_Indicator)> update_binary 0071ffff
+
+(the encoding might be different, see `this
+comment <https://gist.github.com/mrlnc/01d6300f1904f154d969ff205136b753?permalink_co…>`__)
+You can also set the routing indicator to **0x0**, which is *valid* and
+means “routing indicator not specified”, leaving it to the modem.
+
+USIM Service Table
+------------------
+
+First, check out the USIM Service Table (UST):
+
+::
+
+ pySIM-shell (MF)> select MF
+ pySIM-shell (MF)> select ADF.USIM
+ pySIM-shell (MF/ADF.USIM)> select EF.UST
+ pySIM-shell (MF/ADF.USIM/EF.UST)> read_binary_decoded
+ 9000: beff9f9de73e0408400170730000002e00000000 -> [2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 25, 27, 28, 29, 33, 34, 35, 38, 39, 42, 43, 44, 45, 46, 51, 60, 71, 73, 85, 86, 87, 89, 90, 93, 94, 95, 122, 123, 124, 126]
+
+.. list-table:: From TS31.102
+ :widths: 15 40
+ :header-rows: 1
+
+ * - Service No.
+ - Description
+ * - 122
+ - 5GS Mobility Management Information
+ * - 123
+ - 5G Security Parameters
+ * - 124
+ - Subscription identifier privacy support
+ * - 125
+ - SUCI calculation by the USIM
+ * - 126
+ - UAC Access Identities support
+ * - 129
+ - 5GS Operator PLMN List
+
+If you’d like to enable/disable any UST service:
+
+::
+
+ pySIM-shell (MF/ADF.USIM/EF.UST)> ust_service_deactivate 124
+ pySIM-shell (MF/ADF.USIM/EF.UST)> ust_service_activate 124
+ pySIM-shell (MF/ADF.USIM/EF.UST)> ust_service_deactivate 125
+
+In this case, UST Service 124 is already enabled and you’re good to go. The
+sysmoISIM-SJA2 does not support on-SIM calculation, so service 125 must
+be disabled.
+
+USIM Error with 5G and sysmoISIM
+--------------------------------
+
+sysmoISIMs come 5GS-enabled. By default however, the configuration stored
+in the card file-system is **not valid** for 5G networks: Service 124 is enabled,
+but EF.SUCI_Calc_Info and EF.Routing_Indicator are empty files (hence
+do not contain valid data).
+
+At least for Qualcomm’s X55 modem, this results in an USIM error and the
+whole modem shutting 5G down. If you don’t need SUCI concealment but the
+smartphone refuses to connect to any 5G network, try to disable the UST
+service 124.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/32688
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I2908ea9df7e78c596554731085902e2ab7278328
Gerrit-Change-Number: 32688
Gerrit-PatchSet: 4
Gerrit-Owner: merlinchlosta <merlin.chlosta(a)rub.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/pysim/+/33064 )
Change subject: ts_31_102: Add decoder/encoder for DF.5GS/EF.Routing_Indicator
......................................................................
ts_31_102: Add decoder/encoder for DF.5GS/EF.Routing_Indicator
This file is rather important for 5G SA operation, so we should have
a proper encoder/decoder in place.
Change-Id: I1b37fdfc2807976880b2cafb61951f08eebeb344
---
M docs/suci-tutorial.rst
M pySim/ts_31_102.py
2 files changed, 24 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/64/33064/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33064
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I1b37fdfc2807976880b2cafb61951f08eebeb344
Gerrit-Change-Number: 33064
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newpatchset
Attention is currently required from: matanp.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/32686 )
Change subject: cards: Add support for Gialer SIM cards
......................................................................
Patch Set 6: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/32686
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Icd2021aec630ac018f66ab565e03112047389e17
Gerrit-Change-Number: 32686
Gerrit-PatchSet: 6
Gerrit-Owner: matanp <matan1008(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: matanp <matan1008(a)gmail.com>
Gerrit-Comment-Date: Sat, 27 May 2023 10:55:36 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33059 )
Change subject: codec: new functions osmo_{fr,efr}_sid_reset()
......................................................................
codec: new functions osmo_{fr,efr}_sid_reset()
In Iec5c1f2619a82499f61cb3e5a7cd03ff0f020ad8 we added
osmo_{fr,efr}_sid_preen() functions that apply SID classification
of GSM 06.31/06.81 section 6.1.1 (osmo_{fr,efr}_sid_classify()),
reject invalid SID, and "rejuvenate" deemed-valid SID frames by
resetting their SID code word, correcting the one bit error that
may be present in a deemed-valid SID frame. However, the last
operation (rejuvenation of a SID frame by resetting its SID field)
should also be made available as its own function, as it may be
more efficient in some applications: for example, an application
may need to call osmo_{fr,efr}_sid_classify(), apply the rejuvenation
to valid SID, but also use the classification result to drive other
logic. Factor out these functions.
Change-Id: I1d6dd867a358bdda8850cd8c959d0f361c0a5b6d
---
M include/osmocom/codec/codec.h
M src/codec/gsm610.c
M src/codec/gsm660.c
3 files changed, 94 insertions(+), 32 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/include/osmocom/codec/codec.h b/include/osmocom/codec/codec.h
index 731f169..4dbe129 100644
--- a/include/osmocom/codec/codec.h
+++ b/include/osmocom/codec/codec.h
@@ -130,6 +130,9 @@
bool osmo_fr_sid_preen(uint8_t *rtp_payload);
bool osmo_efr_sid_preen(uint8_t *rtp_payload);
+void osmo_fr_sid_reset(uint8_t *rtp_payload);
+void osmo_efr_sid_reset(uint8_t *rtp_payload);
+
int osmo_amr_rtp_enc(uint8_t *payload, uint8_t cmr, enum osmo_amr_type ft,
enum osmo_amr_quality bfi);
int osmo_amr_rtp_dec(const uint8_t *payload, int payload_len, uint8_t *cmr,
diff --git a/src/codec/gsm610.c b/src/codec/gsm610.c
index 19c7aa4..5cc4f14 100644
--- a/src/codec/gsm610.c
+++ b/src/codec/gsm610.c
@@ -404,6 +404,35 @@
return OSMO_GSM631_SID_CLASS_VALID;
}
+/*! Reset the SID field and the unused bits of a potentially corrupted,
+ * but still valid GSM-FR SID frame in RTP encoding to their pristine state.
+ * \param[in] rtp_payload Buffer with RTP payload - must be writable!
+ *
+ * Per GSM 06.12 section 5.2, a freshly minted SID frame carries 60 bits
+ * of comfort noise parameters (LARc and 4 times Xmaxc), while the remaining
+ * 200 bits are all zeros; the latter 200 all-0 bits further break down into
+ * 95 bits of SID field (checked by receivers to detect SID) and 105 unused
+ * bits which receivers are told to ignore. Network elements that receive
+ * SID frames from call leg A uplink and need to retransmit them on leg B
+ * downlink should "rejuvenate" received SID frames prior to retransmission;
+ * this function does the job.
+ */
+void osmo_fr_sid_reset(uint8_t *rtp_payload)
+{
+ uint8_t *p, sub;
+
+ p = rtp_payload + 5; /* skip magic+LARc */
+ for (sub = 0; sub < 4; sub++) {
+ *p++ = 0;
+ *p++ &= 0x1F; /* upper 5 bits of Xmaxc field */
+ *p++ &= 0x80; /* and the lsb spilling into the next byte */
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+ *p++ = 0;
+ }
+}
+
/*! Preen potentially-SID FR codec frame in RTP format, ensuring that it is
* either a speech frame or a valid SID, and if the latter, making it a
* perfect, error-free SID frame.
@@ -413,7 +442,6 @@
bool osmo_fr_sid_preen(uint8_t *rtp_payload)
{
enum osmo_gsm631_sid_class sidc;
- uint8_t *p, sub;
sidc = osmo_fr_sid_classify(rtp_payload);
switch (sidc) {
@@ -422,20 +450,8 @@
case OSMO_GSM631_SID_CLASS_INVALID:
return false;
case OSMO_GSM631_SID_CLASS_VALID:
- /* "Rejuvenate" this SID frame, correcting any errors:
- * zero out all bits that aren't LARc or Xmaxc, thereby
- * clearing all SID code word bits and all unused/reserved
- * bits. */
- p = rtp_payload + 5; /* skip magic+LARc */
- for (sub = 0; sub < 4; sub++) {
- *p++ = 0;
- *p++ &= 0x1F;
- *p++ &= 0x80;
- *p++ = 0;
- *p++ = 0;
- *p++ = 0;
- *p++ = 0;
- }
+ /* "Rejuvenate" this SID frame, correcting any errors */
+ osmo_fr_sid_reset(rtp_payload);
return true;
default:
/* There are only 3 possible SID classifications per GSM 06.31
diff --git a/src/codec/gsm660.c b/src/codec/gsm660.c
index 9b5c55a..b15bdf3 100644
--- a/src/codec/gsm660.c
+++ b/src/codec/gsm660.c
@@ -352,6 +352,42 @@
return OSMO_GSM631_SID_CLASS_VALID;
}
+/*! Reset the SID field of a potentially corrupted, but still valid GSM-EFR
+ * SID frame in RTP encoding to its pristine state (full SID code word).
+ * \param[in] rtp_payload Buffer with RTP payload - must be writable!
+ *
+ * Per GSM 06.62 section 5.3, a freshly minted SID frame consists of 58 bits
+ * of comfort noise parameters (LSF and 4 times fixed codebook gain), 95 bits
+ * of SID code word (all 1s) and 91 unused bits (all 0s). Network elements
+ * that receive SID frames from call leg A uplink and need to retransmit them
+ * on leg B downlink should "rejuvenate" received SID frames prior to
+ * retransmission by resetting the SID field to its pristine state of all 1s;
+ * this function does the job.
+ *
+ * Potential TODO: it would be nice to also zero out the remaining 91 bits
+ * which the spec leaves as reserved, clearing out leg A radio bit errors -
+ * but do we really need to?
+ */
+void osmo_efr_sid_reset(uint8_t *rtp_payload)
+{
+ /* set all 95 SID code word bits to 1 */
+ rtp_payload[6] |= 0x6F;
+ rtp_payload[7] = 0xFF;
+ rtp_payload[8] = 0xFF;
+ rtp_payload[9] |= 0x80;
+ rtp_payload[12] |= 0x3B;
+ rtp_payload[13] = 0xFF;
+ rtp_payload[14] = 0xFF;
+ rtp_payload[15] |= 0xE0;
+ rtp_payload[19] = 0xFF;
+ rtp_payload[20] = 0xFF;
+ rtp_payload[21] = 0xFF;
+ rtp_payload[25] = 0xFF;
+ rtp_payload[26] |= 0xFC;
+ rtp_payload[27] = 0xFF;
+ rtp_payload[28] |= 0xC0;
+}
+
/*! Preen potentially-SID EFR codec frame in RTP format, ensuring that it is
* either a speech frame or a valid SID, and if the latter, making it a
* perfect, error-free SID frame.
@@ -369,23 +405,8 @@
case OSMO_GSM631_SID_CLASS_INVALID:
return false;
case OSMO_GSM631_SID_CLASS_VALID:
- /* "Rejuvenate" this SID frame, correcting any errors:
- * set all 95 SID code word bits to 1. */
- rtp_payload[6] |= 0x6F;
- rtp_payload[7] = 0xFF;
- rtp_payload[8] = 0xFF;
- rtp_payload[9] |= 0x80;
- rtp_payload[12] |= 0x3B;
- rtp_payload[13] = 0xFF;
- rtp_payload[14] = 0xFF;
- rtp_payload[15] |= 0xE0;
- rtp_payload[19] = 0xFF;
- rtp_payload[20] = 0xFF;
- rtp_payload[21] = 0xFF;
- rtp_payload[25] = 0xFF;
- rtp_payload[26] |= 0xFC;
- rtp_payload[27] = 0xFF;
- rtp_payload[28] |= 0xC0;
+ /* "Rejuvenate" this SID frame, correcting any errors */
+ osmo_efr_sid_reset(rtp_payload);
return true;
default:
/* There are only 3 possible SID classifications per GSM 06.81
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33059
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I1d6dd867a358bdda8850cd8c959d0f361c0a5b6d
Gerrit-Change-Number: 33059
Gerrit-PatchSet: 2
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
Attention is currently required from: laforge, fixeria.
falconia has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33063 )
Change subject: coding: gsm0503_tch_{fr,hr}_encode(): add ability to emit BFI
......................................................................
Patch Set 1:
(2 comments)
File src/coding/gsm0503_coding.c:
https://gerrit.osmocom.org/c/libosmocore/+/33063/comment/775d3030_55069b50
PS1, Line 1953: 185
> `sizeof(conv)` - this way it's clear that you're zero-initializing the whole buffer.
Will do.
https://gerrit.osmocom.org/c/libosmocore/+/33063/comment/7ff61124_85f3249c
PS1, Line 1955: osmo_con
> but how would this work for EFR? As we can see, this function is used to treat EFR and FR cases, dep […]
The BFI-inducing frame of all zeros at the u(k) level is the same for FR and EFR. Strictly speaking it is neither valid FR nor valid EFR, but that's the whole point: the intended effect is that the receiving MS will flag it as a BFI, and that result will happen in both TCH/FS and TCH/EFS channel models. I have also observed experimentally that what I implemented here is exactly what sysmoBTS PHY does, and I run with EFR most of the time.
If you are wondering how I did the experimental observation of what sysmoBTS puts out, I used the TCH DL sniffing feature of FreeCalypso, tapping the DL path in the MS at the point between channel decoder output and Rx DTX handler input - that's the a_dd_0[] array in the DSP's accessible NDB page. I see a frame of 260 zero bits (including EFR) with the channel decoder bit error count reading zero, but the BFI flag is set, telling me that the CRC3 is inverted. Normal encoding of all-zeros would put 111 in CRC3, hence it is obvious to me that the proprietary PHY is generating that bad-CRC3 frame simply by emitting all zeros at the u(k) level.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33063
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iade3310e16b906efb6892d28f474a0d15204e861
Gerrit-Change-Number: 33063
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Sat, 27 May 2023 10:46:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: falconia.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/33060 )
Change subject: codec: new function osmo_hr_sid_reset()
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33060
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iebc0863ffcc3f8f25aeb54d4b14fac0487bc2bbb
Gerrit-Change-Number: 33060
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: falconia <falcon(a)freecalypso.org>
Gerrit-Comment-Date: Sat, 27 May 2023 10:44:47 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment