Attention is currently required from: daniel, laforge.
pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39611?usp=email )
Change subject: vty: Add cmd to look up route
......................................................................
Patch Set 3: Code-Review+2
(1 comment)
File src/osmo_ss7_vty.c:
https://gerrit.osmocom.org/c/libosmo-sigtran/+/39611/comment/5b63fd58_f2b80… :
PS3, Line 570: pc = osmo_ss7_pointcode_parse(inst, argv[2]);
> You don't really seem to do anything with the source PC except validate. […]
I'm not doing anything (yet) here because it is be implemented in a follow-up patch, when I add the new route-label struct to look up routes.
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39611?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I4dbe04862c018a1beea253de99404adb88bb7f4b
Gerrit-Change-Number: 39611
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 26 Feb 2025 12:01:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: daniel <dwillmann(a)sysmocom.de>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39622?usp=email )
Change subject: rtp2trau HR: add support for TRAU-8k-UL frame output
......................................................................
rtp2trau HR: add support for TRAU-8k-UL frame output
When osmo_rtp2trau() function is used to pass traffic to an E1 BTS,
it only needs to generate TRAU-DL frames, not TRAU-UL. OTOH,
ability to generate TRAU-UL frames is needed for TFO, i.e., for
software implementation of TFO-capable speech transcoders.
osmo_rtp2trau() already supports TRAU-UL frame output for FR and
EFR codecs, but not for HR codec in TRAU-8k framing - add the
missing support. (Out of the two possible TRAU frame formats for
GSM-HR codec, TFO always uses TRAU-8k format.)
Change-Id: I288cfa7d467125f7732ef1d0ef83b933e41da536
---
M src/trau/trau_rtp_conv.c
M tests/Makefile.am
M tests/testsuite.at
A tests/trau_conv/hr_speech_invsid_bits.hex
A tests/trau_conv/hr_speech_twts002.hex
A tests/trau_conv/rtp2trau_hr_ul1.ok
A tests/trau_conv/rtp2trau_hr_ul2.ok
A tests/trau_conv/rtp2trau_hr_ul3.ok
8 files changed, 241 insertions(+), 11 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/22/39622/1
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index 328221e..d5ac1fa 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -756,7 +756,7 @@
return 0;
}
-static int rtp2trau_hr8(struct osmo_trau_frame *tf, const uint8_t *data, size_t data_len)
+static int rtp2trau_hr8_dl(struct osmo_trau_frame *tf, const uint8_t *data, size_t data_len)
{
/* accept both TS 101 318 and RFC 5993 payloads */
switch (data_len) {
@@ -773,12 +773,6 @@
return -EINVAL;
}
- /* FIXME: implement TRAU-UL frame generation if and when
- * someone actually needs it in a program that uses
- * this library. */
- if (tf->dir != OSMO_TRAU_DIR_DL)
- return -ENOTSUP;
-
tf->type = OSMO_TRAU8_SPEECH;
/* C1..C5 */
@@ -819,6 +813,130 @@
return 0;
}
+/* compute the odd parity bit of the given input bit sequence */
+static ubit_t compute_odd_parity(const ubit_t *in, unsigned int num_bits)
+{
+ int i;
+ unsigned int sum = 0;
+
+ for (i = 0; i < num_bits; i++) {
+ if (in[i])
+ sum++;
+ }
+ return !(sum & 1);
+}
+
+static int rtp2trau_hr8_ul(struct osmo_trau_frame *tf, const uint8_t *data, size_t data_len)
+{
+ uint8_t ft, xc1_4;
+ bool data_bits_req, have_taf;
+
+ /* In TRAU-UL direction we require/expect TW-TS-002 RTP payload format;
+ * RFC 5993 is also accepted because it is a subset of TW-TS-002.
+ * TS 101 318 input is not supported for TRAU-UL output! */
+ if (data_len < 1)
+ return -EINVAL;
+ ft = data[0] >> 4;
+ switch (ft) {
+ case FT_GOOD_SPEECH:
+ xc1_4 = 0;
+ data_bits_req = true;
+ have_taf = false;
+ break;
+ case FT_INVALID_SID:
+ xc1_4 = 4;
+ data_bits_req = false;
+ have_taf = true;
+ break;
+ case FT_GOOD_SID:
+ xc1_4 = 1;
+ data_bits_req = true;
+ have_taf = false;
+ break;
+ case FT_BFI_WITH_DATA:
+ xc1_4 = 6;
+ data_bits_req = true;
+ have_taf = true;
+ break;
+ case FT_NO_DATA:
+ xc1_4 = 6;
+ data_bits_req = false;
+ have_taf = true;
+ break;
+ default:
+ return -EINVAL;
+ }
+ /* If the frame type is one that includes data bits, the payload length
+ * per RFC 5993 and TW-TS-002 is 15 bytes. If the frame type is one
+ * that does not include data bits, then the payload length per the
+ * same specs is only 1 byte - but we also accept 15-byte payloads
+ * in this case to make life easier for applications that pass the
+ * content of a buffer.
+ *
+ * When we make a TRAU-UL frame from FT=1 or FT=7, we fill all Dn bits
+ * with zeros if we got a short (1 byte) payload. However, if the
+ * application passed us a long (15 byte) payload despite FT being
+ * 1 or 7, we fill Dn bits with application-provided payload.
+ */
+ switch (data_len) {
+ case GSM_HR_BYTES_RTP_RFC5993:
+ break;
+ case 1:
+ if (data_bits_req)
+ return -EINVAL;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ tf->type = OSMO_TRAU8_SPEECH;
+
+ /* C1..C5 */
+ tf->c_bits[0] = 0;
+ tf->c_bits[1] = 0;
+ tf->c_bits[2] = 0;
+ tf->c_bits[3] = 1;
+ tf->c_bits[4] = 0;
+ /* C6..C8: spare bits */
+ memset(tf->c_bits + 5, 1, 3);
+ /* C9 is DTXd */
+ tf->c_bits[8] = (data[0] & 0x08) >> 3;
+
+ /* XC1..XC6 */
+ tf->xc_bits[0] = (xc1_4 >> 3) & 1;
+ tf->xc_bits[1] = (xc1_4 >> 2) & 1;
+ tf->xc_bits[2] = (xc1_4 >> 1) & 1;
+ if (have_taf)
+ tf->xc_bits[3] = (data[0] & 0x01) >> 0;
+ else
+ tf->xc_bits[3] = (xc1_4 >> 0) & 1;
+ tf->xc_bits[4] = (data[0] & 0x02) >> 1; /* UFI */
+ tf->xc_bits[5] = compute_odd_parity(tf->xc_bits, 5);
+
+ memset(&tf->t_bits[0], 1, 2);
+
+ if (data_len > 1)
+ osmo_pbit2ubit(tf->d_bits, data + 1, GSM_HR_BYTES * 8);
+ else
+ memset(tf->d_bits, 0, GSM_HR_BYTES * 8);
+ /* CRC is *not* computed by TRAU frame encoder - we have to do it */
+ osmo_crc8gen_set_bits(&gsm0860_efr_crc3, tf->d_bits, 44, tf->crc_bits);
+
+ return 0;
+}
+
+static int rtp2trau_hr8(struct osmo_trau_frame *tf, const uint8_t *data, size_t data_len)
+{
+ switch (tf->dir) {
+ case OSMO_TRAU_DIR_DL:
+ return rtp2trau_hr8_dl(tf, data, data_len);
+ case OSMO_TRAU_DIR_UL:
+ return rtp2trau_hr8_ul(tf, data, data_len);
+ default:
+ return -EINVAL;
+ }
+}
+
/* TS 48.060 Section 5.5.1.1.2 */
static int rtp2trau_efr(struct osmo_trau_frame *tf, const uint8_t *data, size_t data_len)
{
@@ -1571,9 +1689,9 @@
* TRAU-UL (TFO) is TW-TS-001 - the basic RTP format of TS 101 318 or
* RFC 3551 lacks the necessary metadata flags.
*
- * - TRAU-UL output for HR codec is not currently implemented; when we do
- * implement it in the future, TW-TS-002 will be required in this path
- * for the same reason as above.
+ * - For HRv1 codec, for the same reason as above, the only correct RTP
+ * format for conversion to TRAU-UL is TW-TS-002. RFC 5993 payloads are
+ * also accepted (because it is a subset of TW-TS-002), but not TS 101 318.
*
* - TRAU-UL output for CSD 14.4 kbit/s mode is not currently implemented
* (C-bits are always set according to the rules for TRAU-DL) - but the
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4645b7e..73341a2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -99,13 +99,15 @@
trau_conv/fr_speech_basic.hex trau_conv/fr_speech_twts001_good.hex \
trau_conv/fr_speech_twts001_mix.hex \
trau_conv/hr_speech_rfc5993.hex trau_conv/hr_speech_ts101318.hex \
+ trau_conv/hr_speech_twts002.hex trau_conv/hr_speech_invsid_bits.hex \
trau_conv/rtp2trau_efr_dl1.ok trau_conv/rtp2trau_efr_dl2.ok \
trau_conv/rtp2trau_efr_ul1.ok trau_conv/rtp2trau_efr_ul2.ok \
trau_conv/rtp2trau_efr_ul3.ok \
trau_conv/rtp2trau_fr_dl1.ok trau_conv/rtp2trau_fr_dl2.ok \
trau_conv/rtp2trau_fr_ul1.ok trau_conv/rtp2trau_fr_ul2.ok \
trau_conv/rtp2trau_fr_ul3.ok \
- trau_conv/rtp2trau_hr_dl.ok \
+ trau_conv/rtp2trau_hr_dl.ok trau_conv/rtp2trau_hr_ul1.ok \
+ trau_conv/rtp2trau_hr_ul2.ok trau_conv/rtp2trau_hr_ul3.ok \
trau_conv/trau16_efr.in trau_conv/trau16_efr_std.ok \
trau_conv/trau16_efr_twts001.ok \
trau_conv/trau16_fr.in trau_conv/trau16_fr_std.ok \
diff --git a/tests/testsuite.at b/tests/testsuite.at
index a5cf070..b3c2764 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -162,3 +162,21 @@
cat $abs_srcdir/trau_conv/rtp2trau_hr_dl.ok > expout
AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/hr_speech_rfc5993.hex hr dl], [0], [expout], [ignore])
AT_CLEANUP
+
+AT_SETUP([rtp2trau_hr_ul1])
+AT_KEYWORDS([rtp2trau_hr_ul1])
+cat $abs_srcdir/trau_conv/rtp2trau_hr_ul1.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/hr_speech_rfc5993.hex hr ul], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_hr_ul2])
+AT_KEYWORDS([rtp2trau_hr_ul2])
+cat $abs_srcdir/trau_conv/rtp2trau_hr_ul2.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/hr_speech_twts002.hex hr ul], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_hr_ul3])
+AT_KEYWORDS([rtp2trau_hr_ul3])
+cat $abs_srcdir/trau_conv/rtp2trau_hr_ul3.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/hr_speech_invsid_bits.hex hr ul], [0], [expout], [ignore])
+AT_CLEANUP
diff --git a/tests/trau_conv/hr_speech_invsid_bits.hex b/tests/trau_conv/hr_speech_invsid_bits.hex
new file mode 100644
index 0000000..3ac5172
--- /dev/null
+++ b/tests/trau_conv/hr_speech_invsid_bits.hex
@@ -0,0 +1,14 @@
+# This TW-TS-005 hex file contains an input to osmo_rtp2trau() for GSM-HR
+# codec that is *not* a valid RTP payload per TW-TS-002: an invalid SID
+# frame for conversion to TRAU-UL that begins as defined in TW-TS-002
+# (FT=1 to signify invalid SID), but then contrary to the spec, does
+# include the payload data bits. Such concoction is not valid in RTP
+# flight between network elements, but osmo_rtp2trau() supports such
+# extended usage in order to allow TFO applications to set the fill bit
+# pattern in the TRAU-UL frame to something other than all zeros.
+#
+# In the present example, this fill bit pattern consists of R0+LPC
+# parameters (33 bits) from a valid SID frame, followed by alternating
+# 1s and 0s in the 79-bit SID field.
+
+1000D9EA65D5555555555555555555
diff --git a/tests/trau_conv/hr_speech_twts002.hex b/tests/trau_conv/hr_speech_twts002.hex
new file mode 100644
index 0000000..e0e6321
--- /dev/null
+++ b/tests/trau_conv/hr_speech_twts002.hex
@@ -0,0 +1,43 @@
+# This hex file (TW-TS-005 Annex B format) contains some RTP payloads for
+# GSM-HR codec, using the super-5993 RTP payload format of TW-TS-002,
+# semantically corresponding to the uplink direction of a GSM call leg.
+#
+# The present example contains a mix of good and bad frames, the same kind
+# of mix that can be represented in a TRAU-UL frame stream. This example
+# has been constructed by hand: some frames were taken from GSM 06.07 test
+# sequences and then tweaked, other are outright concoctions. The setting
+# of DTXd bit is also exercised.
+
+# good speech frame (DHF)
+000371AF61C8F2802531C000000000
+
+# good speech frame (regular)
+00B77916FC7D902F9372B569F5D17F
+# same with TAF
+01B77916FC7D902F9372B569F5D17F
+# same with UFI
+02B77916FC7D902F9372B569F5D17F
+
+# valid SID frame (first SID from dtx06.cod)
+2000D9EA65FFFFFFFFFFFFFFFFFFFF
+# same with TAF
+2100D9EA65FFFFFFFFFFFFFFFFFFFF
+# same with UFI
+2200D9EA65FFFFFFFFFFFFFFFFFFFF
+
+# BFI with data
+608FE9B77000000000000000000000
+# same with TAF
+618FE9B77000000000000000000000
+
+# short TW-TS-002 payloads (ToC octet only)
+10 # invalid SID frame
+11 # same with TAF
+13 # TAF+UFI
+70 # BFI-no-data
+71 # same with TAF
+
+# some of these same frames with DTXd=1
+08B77916FC7D902F9372B569F5D17F
+2800D9EA65FFFFFFFFFFFFFFFFFFFF
+688FE9B77000000000000000000000
diff --git a/tests/trau_conv/rtp2trau_hr_ul1.ok b/tests/trau_conv/rtp2trau_hr_ul1.ok
new file mode 100644
index 0000000..1fd3f3b
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_hr_ul1.ok
@@ -0,0 +1,17 @@
+00884486f1d7d8b98ff2c089a69c8080808080bb
+00884486f1d7d8b98ff2c089a69c8080808080bb
+0088469fe9dbdc8080d0808080808080808080bb
+0088469fe3eedf90dd9c9dddc7f193a9e5c587bb
+008845fef4fd9ba986ddabfceac589d38ab3febb
+008846bfe3eedab7e4aed7eb88b4a4a4f997ccfb
+008846eef98bbf8fd9a097e4eeababa7ebd1bffb
+00884486f1d7d8b98ff2c089a69c8080808080bb
+00884486f1d7d8b98ff2c089a69c8080808080bb
+00884481d9f599b9c9cce0b8ccb6c099e9f1f6fb
+00884481d9f599b18c9df0b0cdb68099d9f5f6fb
+00884481d9f599b18c9df0b2cdb28099d9f5f6fb
+00884481d9f599b18c9df0b2cdb28099d9f5f6fb
+00884481d9f599b18c9df0b2cdb28099d9f5f6fb
+00884481d9f599b18c9df0b2cdb28099d9f5f6fb
+00884481d9f599b18c9df0b2cdb28099d9f5f6fb
+00885081d9f599bffffffffffffffffffffffffb
diff --git a/tests/trau_conv/rtp2trau_hr_ul2.ok b/tests/trau_conv/rtp2trau_hr_ul2.ok
new file mode 100644
index 0000000..01ba3e4
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_hr_ul2.ok
@@ -0,0 +1,17 @@
+00884486f1d7d8b98ff2c089a69c8080808080bb
+008846eef98bbf8fd9a097e4eeababa7ebd1bffb
+008846eef98bbf8fd9a097e4eeababa7ebd1bffb
+00884aeef98bbf8fd9a097e4eeababa7ebd1bffb
+00885081d9f599bffffffffffffffffffffffffb
+00885081d9f599bffffffffffffffffffffffffb
+00885c81d9f599bffffffffffffffffffffffffb
+0089669fe9dbdc8080d0808080808080808080bb
+0089729fe9dbdc8080d0808080808080808080bb
+008940808080808080f0808080808080808080bb
+008954808080808080f0808080808080808080bb
+008958808080808080f0808080808080808080bb
+008964808080808080f0808080808080808080bb
+008970808080808080f0808080808080808080bb
+008846eef98bbf8fd9a097e4eeababa7ebd1bfff
+00885081d9f599bfffffffffffffffffffffffff
+0089669fe9dbdc8080d0808080808080808080bf
diff --git a/tests/trau_conv/rtp2trau_hr_ul3.ok b/tests/trau_conv/rtp2trau_hr_ul3.ok
new file mode 100644
index 0000000..a6d657c
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_hr_ul3.ok
@@ -0,0 +1 @@
+00894081d9f599bad5a5aad5aad5aad5aad5aafb
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39622?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I288cfa7d467125f7732ef1d0ef83b933e41da536
Gerrit-Change-Number: 39622
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39620?usp=email )
Change subject: trau_rtp_conv: document API functions
......................................................................
trau_rtp_conv: document API functions
The two API functions that constitute TRAU<->RTP conversion layer
of libosmotrau, osmo_trau2rtp() and osmo_rtp2trau(), date back to
the reintroduction of E1 BTS support in Osmocom in 2020, and their
functionality has been greatly extended in previous Themyscira
patches. However, they have not been properly documented until
now - fix this defect.
Change-Id: Ib7ee2466aaab47e47f78ff94c5179b90cf393d0e
---
M src/trau/trau_rtp_conv.c
1 file changed, 99 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/20/39620/1
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index 9bee640..328221e 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -1456,6 +1456,38 @@
return false;
}
+/*! convert received TRAU-UL frame to RTP payload
+ * \param[out] out Buffer for the output RTP payload
+ * \param[in] out_len Size of buffer pointed to by \ref out
+ * \param[in] tf Osmo-decoded TRAU frame
+ * \param[in] st State/config structure
+ * \returns length of converted RTP payload if successful; negative on error
+ *
+ * This function is intended to operate on TRAU-UL or TFO frames, either
+ * received from an E1 BTS or extracted from lsbs of PCM samples in TFO.
+ * Supported TRAU frame types are FR & EFR speech, HRv1 speech in both
+ * 16k and 8k formats, and all defined CSD frame types up to 14.4 kbit/s
+ * extended data frames.
+ *
+ * In the case of FR/EFR speech, the output format is either RFC 3551 or
+ * TW-TS-001; in the case of HRv1 speech, the output format is either RFC 5993
+ * or TW-TS-002. st->rtp_extensions field selects the use or non-use of
+ * Themyscira RTP extensions; the structure passed in \ref st currently
+ * has no other uses in the TRAU->RTP direction.
+ *
+ * The following TRAU frame types are _not_ supported:
+ *
+ * - TRAU-DL frames: the direction field of the parsed frame structure is
+ * ignored and all frames are processed as if they were TRAU-UL. In the
+ * case of FR, EFR, HR-16k and extended data (E-TRAU) frames some control
+ * bits are different between TRAU-UL and TRAU-DL, such that this
+ * misinterpretation will produce invalid results.
+ *
+ * - D144 sync frames: these special frames are not convertible to RTP;
+ * their synchronization function needs to be handled by the application.
+ *
+ * - AMR speech frames: not currently implemented.
+ */
int osmo_trau2rtp(uint8_t *out, size_t out_len, const struct osmo_trau_frame *tf,
struct osmo_trau2rtp_state *st)
{
@@ -1481,6 +1513,73 @@
}
}
+/*! convert RTP payload to TRAU-UL or TRAU-DL frame
+ * \param[out] tf Osmocom-defined structure for TRAU frame bits
+ * \param[in] rtp Payload to be converted
+ * \param[in] rtp_len Length of payload in \ref rtp
+ * \param[in] st State/config structure
+ * \returns 0 in case of success; negative on error
+ *
+ * This function can be used to generate both TRAU-UL and TRAU-DL frames.
+ * TRAU-DL output is needed when feeding traffic to an E1 BTS; TRAU-UL output
+ * is needed in more specialized applications that emulate an E1 BTS or
+ * implement in-band TFO.
+ *
+ * The set of supported codecs and frame types is the same as osmo_trau2rtp();
+ * st->type selects the TRAU frame type to be emitted. Additionally, if the
+ * TRAU frame type to be generated is OSMO_TRAU16_FT_DATA, st->interm_rate_16k
+ * needs to be set to true for 16 kbit/s IR or false for 8 kbit/s IR.
+ *
+ * In the output structure pointed to by \ref tf, the caller MUST set dir
+ * member prior to calling the present function; additionally, dl_ta_usec
+ * member MUST be set (usually to 0) prior to calling osmo_trau_frame_encode().
+ * All other required bits are filled correctly by the present function.
+ *
+ * With FR/HR/EFR speech codecs, semantically appropriate RTP payloads are
+ * different between UL and DL output applications. Considerations for
+ * TRAU-DL output:
+ *
+ * - RTP payload formats of RFC 5993, TW-TS-001 and TW-TS-002 are accepted
+ * by the function - however, all metadata flags carried by the header octet
+ * of these extended formats are ignored/dropped in the DL direction.
+ *
+ * - The most native RTP input formats for conversion to TRAU-DL are those
+ * defined in ETSI TS 101 318 for FR, HR and EFR; the ones for FR and EFR
+ * are also duplicated in RFC 3551. In the case of HR codec, RFC 5993 input
+ * is also appropriate as specified in 3GPP TS 48.103 - as long as the user
+ * remembers that the extra header octet is ignored.
+ *
+ * - The only correct way to implement TrFO for GSM, accepting FR/HR/EFR from
+ * call leg A uplink in TW-TS-001 or TW-TS-002 format and generating TRAU-DL
+ * frames for call leg B, is to apply the TFO transform of TS 28.062 section
+ * C.3.2.1.1, then feed the output of that transform to the present function.
+ *
+ * - The provision whereby a zero-length RTP payload is not treated as an error
+ * like other invalid RTP inputs, but is converted to an idle speech frame
+ * in TRAU-DL output should be considered a bogon. This condition never
+ * occurs when the just-mentioned TFO transform is applied immediately prior
+ * to TRAU-DL output, nor does it ever occur in the original GSM architecture
+ * where the TRAU either free-runs a speech encoder or applies the same TFO
+ * transform - hence it is unlikely to be handled well by real E1 BTSes.
+ * Furthermore, this code path in libosmotrau is currently broken (the
+ * intended idle speech frame gets turned into a "regular" but invalid FR/EFR
+ * speech frame) and should be considered for removal.
+ *
+ * Considerations for TRAU-UL output:
+ *
+ * - For FR and EFR codecs, the only correct RTP format for conversion to
+ * TRAU-UL (TFO) is TW-TS-001 - the basic RTP format of TS 101 318 or
+ * RFC 3551 lacks the necessary metadata flags.
+ *
+ * - TRAU-UL output for HR codec is not currently implemented; when we do
+ * implement it in the future, TW-TS-002 will be required in this path
+ * for the same reason as above.
+ *
+ * - TRAU-UL output for CSD 14.4 kbit/s mode is not currently implemented
+ * (C-bits are always set according to the rules for TRAU-DL) - but the
+ * primary application for TRAU-UL frame output via libosmotrau is TFO,
+ * which does not include CSD.
+ */
int osmo_rtp2trau(struct osmo_trau_frame *tf, const uint8_t *rtp, size_t rtp_len,
struct osmo_trau2rtp_state *st)
{
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39620?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ib7ee2466aaab47e47f78ff94c5179b90cf393d0e
Gerrit-Change-Number: 39620
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39625?usp=email )
Change subject: rtp2trau FR & EFR: disallow BFI in DL
......................................................................
rtp2trau FR & EFR: disallow BFI in DL
osmo_rtp2trau() accepts TW-TS-001 extended RTP payload format for
FR and EFR, converting to either TRAU-DL or TRAU-UL. This extended
format is required for TRAU-UL/TFO frame output, but it is also
accepted for conversion to TRAU-DL in order to support the current
form of OsmoMGW-E1 that has no TFO transform between RTP input and
TDM-timed calls to osmo_rtp2trau().
TW-TS-001 can represent not only good frames, but also bad ones -
however, bad frames on Abis are valid only in UL, not in DL. Prior
to the present patch, if a BFI-marked frame were fed to osmo_rtp2trau()
for conversion to TRAU-DL, the Bad Frame Indicator was dropped and
the garbage payload bits were emitted as if they were a good frame -
bad choice. Reject BFI frames in TRAU-DL mode, return -EINVAL.
Change-Id: Ic63943d4bde9902b27e4d8fe9a5fb6ccecbf36c6
---
M src/trau/trau_rtp_conv.c
1 file changed, 9 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/25/39625/1
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index 8d2631b..1114aaf 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -586,6 +586,10 @@
if ((data[0] & 0xF0) != 0xD0)
return -EINVAL;
+ /* bad frames are only allowed in UL */
+ if (bfi && tf->dir != OSMO_TRAU_DIR_UL)
+ return -EINVAL;
+
tf->type = OSMO_TRAU16_FT_FR;
/* FR Data Bits according to TS 48.060 Section 5.5.1.1.2 */
@@ -894,6 +898,10 @@
if ((data[0] & 0xF0) != 0xC0)
return -EINVAL;
+ /* bad frames are only allowed in UL */
+ if (bfi && tf->dir != OSMO_TRAU_DIR_UL)
+ return -EINVAL;
+
tf->type = OSMO_TRAU16_FT_EFR;
/* FR Data Bits according to TS 48.060 Section 5.5.1.1.2 */
@@ -1566,6 +1574,7 @@
* - RTP payload formats of RFC 5993, TW-TS-001 and TW-TS-002 are accepted
* by the function - however, all metadata flags carried by the header octet
* of these extended formats are ignored/dropped in the DL direction.
+ * BFI frames are not allowed in DL.
*
* - The most native RTP input formats for conversion to TRAU-DL are those
* defined in ETSI TS 101 318 for FR, HR and EFR; the ones for FR and EFR
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39625?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ic63943d4bde9902b27e4d8fe9a5fb6ccecbf36c6
Gerrit-Change-Number: 39625
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39621?usp=email )
Change subject: tests: add unit tests for osmo_rtp2trau()
......................................................................
tests: add unit tests for osmo_rtp2trau()
The suite of unit tests added in this patch exercises osmo_rtp2trau()
followed by osmo_trau_frame_encode() for the following combinations
of speech codec and TRAU frame type:
* FR and EFR codecs, TRAU-16k frames, both DL and UL
* HRv1 codec, TRAU-8k format, DL only
(RTP->TRAU conversion for HRv1 does not currenty support TRAU-UL
output.)
All output TRAU frames contained in rtp2trau_*.ok files (expected
output for unit tests) have been manually checked with Themyscira
decoding utilities trau-parse-hex (16k) and trau-hr-dump-hex (8k);
these utilities in turn were developed to analyze TRAU frame streams
captured from historical BTS and TRAU equipment, hence the chain of
truth reference comparison is traceable to pre-existing historical
hardware implementations of GSM 08.60 and 08.61 specs.
Change-Id: Ia5ca8af6bd3a899253bbcc718b70e43f2265b495
---
M .gitignore
M tests/Makefile.am
M tests/testsuite.at
A tests/trau_conv/efr_speech_basic.hex
A tests/trau_conv/efr_speech_twts001_good.hex
A tests/trau_conv/efr_speech_twts001_mix.hex
A tests/trau_conv/fr_speech_basic.hex
A tests/trau_conv/fr_speech_twts001_good.hex
A tests/trau_conv/fr_speech_twts001_mix.hex
A tests/trau_conv/hr_speech_rfc5993.hex
A tests/trau_conv/hr_speech_ts101318.hex
A tests/trau_conv/rtp2trau_efr_dl1.ok
A tests/trau_conv/rtp2trau_efr_dl2.ok
A tests/trau_conv/rtp2trau_efr_ul1.ok
A tests/trau_conv/rtp2trau_efr_ul2.ok
A tests/trau_conv/rtp2trau_efr_ul3.ok
A tests/trau_conv/rtp2trau_fr_dl1.ok
A tests/trau_conv/rtp2trau_fr_dl2.ok
A tests/trau_conv/rtp2trau_fr_ul1.ok
A tests/trau_conv/rtp2trau_fr_ul2.ok
A tests/trau_conv/rtp2trau_fr_ul3.ok
A tests/trau_conv/rtp2trau_gen.c
A tests/trau_conv/rtp2trau_hr_dl.ok
A tests/trau_conv/tw5reader.c
A tests/trau_conv/tw5reader.h
25 files changed, 735 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/21/39621/1
diff --git a/.gitignore b/.gitignore
index dbe50db..80e6834 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,6 +43,7 @@
tests/raa_prime/test_dec
tests/raa_prime/test_enc
tests/trau_pcu_ericsson/trau_pcu_ericsson_test
+tests/trau_conv/rtp2trau_gen
tests/trau_conv/trau16_to_rtp
tests/trau_conv/trau2rtp_gen
tests/trau_sync/trau_sync_test
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4abfc4a..4645b7e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,6 +8,7 @@
ipa_recv/ipa_recv_test \
raa_prime/test_dec \
raa_prime/test_enc \
+ trau_conv/rtp2trau_gen \
trau_conv/trau16_to_rtp \
trau_conv/trau2rtp_gen \
trau_sync/trau_sync_test \
@@ -52,6 +53,9 @@
rtp_test_rtp_test_SOURCES = rtp_test/rtp_test.c
rtp_test_rtp_test_LDADD = $(TRAU_LA_LIBS)
+trau_conv_rtp2trau_gen_SOURCES = trau_conv/rtp2trau_gen.c trau_conv/tw5reader.c
+trau_conv_rtp2trau_gen_LDADD = $(TRAU_LA_LIBS)
+
trau_conv_trau16_to_rtp_SOURCES = trau_conv/trau16_to_rtp.c
trau_conv_trau16_to_rtp_LDADD = $(TRAU_LA_LIBS)
@@ -64,6 +68,8 @@
trau_pcu_ericsson_trau_pcu_ericsson_test_SOURCES = trau_pcu_ericsson/trau_pcu_ericsson_test.c
trau_pcu_ericsson_trau_pcu_ericsson_test_LDADD = $(TRAU_LA_LIBS)
+noinst_HEADERS = trau_conv/tw5reader.h
+
# boilerplate for the tests
# The `:;' works around a Bash 3.2 bug when the output is not writeable.
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
@@ -88,6 +94,18 @@
ipa_recv/ipa_recv_test.ok \
raa_prime/d144-ul-input.asc raa_prime/nokia-tcsm2-atrau.hex \
rtp_test/rtp_test.ok \
+ trau_conv/efr_speech_basic.hex trau_conv/efr_speech_twts001_good.hex \
+ trau_conv/efr_speech_twts001_mix.hex \
+ trau_conv/fr_speech_basic.hex trau_conv/fr_speech_twts001_good.hex \
+ trau_conv/fr_speech_twts001_mix.hex \
+ trau_conv/hr_speech_rfc5993.hex trau_conv/hr_speech_ts101318.hex \
+ trau_conv/rtp2trau_efr_dl1.ok trau_conv/rtp2trau_efr_dl2.ok \
+ trau_conv/rtp2trau_efr_ul1.ok trau_conv/rtp2trau_efr_ul2.ok \
+ trau_conv/rtp2trau_efr_ul3.ok \
+ trau_conv/rtp2trau_fr_dl1.ok trau_conv/rtp2trau_fr_dl2.ok \
+ trau_conv/rtp2trau_fr_ul1.ok trau_conv/rtp2trau_fr_ul2.ok \
+ trau_conv/rtp2trau_fr_ul3.ok \
+ trau_conv/rtp2trau_hr_dl.ok \
trau_conv/trau16_efr.in trau_conv/trau16_efr_std.ok \
trau_conv/trau16_efr_twts001.ok \
trau_conv/trau16_fr.in trau_conv/trau16_fr_std.ok \
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 291d47d..a5cf070 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -90,3 +90,75 @@
cat $abs_srcdir/trau_conv/trau2rtp_hr_twts002.ok > expout
AT_CHECK([$abs_top_builddir/tests/trau_conv/trau2rtp_gen -8 -x $abs_srcdir/trau_conv/trau2rtp_hr.in], [0], [expout], [ignore])
AT_CLEANUP
+
+AT_SETUP([rtp2trau_fr_dl1])
+AT_KEYWORDS([rtp2trau_fr_dl1])
+cat $abs_srcdir/trau_conv/rtp2trau_fr_dl1.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/fr_speech_basic.hex fr dl], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_fr_dl2])
+AT_KEYWORDS([rtp2trau_fr_dl2])
+cat $abs_srcdir/trau_conv/rtp2trau_fr_dl2.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/fr_speech_twts001_good.hex fr dl], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_fr_ul1])
+AT_KEYWORDS([rtp2trau_fr_ul1])
+cat $abs_srcdir/trau_conv/rtp2trau_fr_ul1.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/fr_speech_basic.hex fr ul], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_fr_ul2])
+AT_KEYWORDS([rtp2trau_fr_ul2])
+cat $abs_srcdir/trau_conv/rtp2trau_fr_ul2.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/fr_speech_twts001_good.hex fr ul], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_fr_ul3])
+AT_KEYWORDS([rtp2trau_fr_ul3])
+cat $abs_srcdir/trau_conv/rtp2trau_fr_ul3.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/fr_speech_twts001_mix.hex fr ul], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_efr_dl1])
+AT_KEYWORDS([rtp2trau_efr_dl1])
+cat $abs_srcdir/trau_conv/rtp2trau_efr_dl1.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/efr_speech_basic.hex efr dl], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_efr_dl2])
+AT_KEYWORDS([rtp2trau_efr_dl2])
+cat $abs_srcdir/trau_conv/rtp2trau_efr_dl2.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/efr_speech_twts001_good.hex efr dl], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_efr_ul1])
+AT_KEYWORDS([rtp2trau_efr_ul1])
+cat $abs_srcdir/trau_conv/rtp2trau_efr_ul1.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/efr_speech_basic.hex efr ul], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_efr_ul2])
+AT_KEYWORDS([rtp2trau_efr_ul2])
+cat $abs_srcdir/trau_conv/rtp2trau_efr_ul2.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/efr_speech_twts001_good.hex efr ul], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_efr_ul3])
+AT_KEYWORDS([rtp2trau_efr_ul3])
+cat $abs_srcdir/trau_conv/rtp2trau_efr_ul3.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/efr_speech_twts001_mix.hex efr ul], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_hr_dl1])
+AT_KEYWORDS([rtp2trau_hr_dl1])
+cat $abs_srcdir/trau_conv/rtp2trau_hr_dl.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/hr_speech_ts101318.hex hr dl], [0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([rtp2trau_hr_dl2])
+AT_KEYWORDS([rtp2trau_hr_dl2])
+cat $abs_srcdir/trau_conv/rtp2trau_hr_dl.ok > expout
+AT_CHECK([$abs_top_builddir/tests/trau_conv/rtp2trau_gen $abs_srcdir/trau_conv/hr_speech_rfc5993.hex hr dl], [0], [expout], [ignore])
+AT_CLEANUP
diff --git a/tests/trau_conv/efr_speech_basic.hex b/tests/trau_conv/efr_speech_basic.hex
new file mode 100644
index 0000000..b1dc98a
--- /dev/null
+++ b/tests/trau_conv/efr_speech_basic.hex
@@ -0,0 +1,15 @@
+# This hex file (TW-TS-005 Annex A format) contains some RTP payloads for
+# GSM-EFR codec, using the basic RTP payload format of RFC 3551. The only
+# semantics allowed by this basic RTP payload format are good speech and
+# valid SID frames; the present test sequence exercises both.
+
+# first 5 frames from GSM 06.54 test0.cod: good speech frames,
+# two DHFs followed by 3 regular speech frames
+C085EB490FAAD603E3A18607B0C42C080480558000000000036B0000000000
+C085EB490FAAD603E3A18607B0C42C080480558000000000036B0000000000
+C7D32592D041B69F4C5775FE5FFFB94A89B6823DF4BB5374AC6FD35A26A92D
+C46F83F969C09E106324A86026E8F1B2002A0136F4FF12FDC45A3561608D70
+C6CF4F49D64E98BEE99B42DF0ECF48E02C1801EC92322FE4C07CD56A97C0D0
+
+# frame #71 (0-based numbering) from GSM 06.54 dtx01.cod: valid SID frame
+C286DD29B5806FFFFF80001E3BFFFFE0000800FFFFFF000040FFFCFFC00010
diff --git a/tests/trau_conv/efr_speech_twts001_good.hex b/tests/trau_conv/efr_speech_twts001_good.hex
new file mode 100644
index 0000000..9146be3
--- /dev/null
+++ b/tests/trau_conv/efr_speech_twts001_good.hex
@@ -0,0 +1,34 @@
+# This hex file (TW-TS-005 Annex A format) contains some RTP payloads for
+# GSM-EFR codec, using the extended RTP payload format of TW-TS-001,
+# semantically corresponding to the uplink direction of a GSM call leg.
+#
+# The present example has been synthetically constructed from GSM 06.54
+# test sequence test0.cod (first 24 frames, enough to exercise TAF),
+# exhibiting the scenario of how GSM TCH/EFS UL would look with this
+# sequence in it under conditions of 100% error-free transmission,
+# i.e., no bad, corrupted or FACCH-stolen frames.
+
+E0C085EB490FAAD603E3A18607B0C42C080480558000000000036B0000000000
+E0C085EB490FAAD603E3A18607B0C42C080480558000000000036B0000000000
+E0C7D32592D041B69F4C5775FE5FFFB94A89B6823DF4BB5374AC6FD35A26A92D
+E0C46F83F969C09E106324A86026E8F1B2002A0136F4FF12FDC45A3561608D70
+E0C6CF4F49D64E98BEE99B42DF0ECF48E02C1801EC92322FE4C07CD56A97C0D0
+E0C46F43F93781183456EB245E4D074736045882A8A9FEC728C0ACB4090E3B6D
+E0C6AF4E83A50175B45688815E5D38E258B5F9206D64CEEDE4B62B9D0E6A6D8E
+E0C56ECF6364C1B564A43648227571484D0CE603ECDA8E996034FBB4E64B5CB3
+E0C6AECBB36382156125752CD88D59CDC26E97A32ECDAD5B243A1B75DD6AD88F
+E0C56F510999C278B23386B76AA713CFD60D070530DE0152A4C55CC93032854F
+E0C6AF4F63A502B7560FFB36A2B5D10BFE8C3785EC5026496FC17C1E4C8D248F
+E0C56F4F69375336549EF23661157859F7D6D806B28BDCCE43BDAA9697FCC04C
+E0C6AECF63550376301D108824DD2B1E1C9267072E6CA14017ADDB84A09202AC
+E0C56FC4F935D4963DA918A5250D0C0243B69887F2278593343A0B97F30BB094
+E0C6AF5069E8041AFE322B00E10E4C24538A1788720271A9E24A2C16F52ED90F
+E0C56F4F69464476DE1F957C5D1DB657F45118AC6D32464375422A8F71E2C28E
+E0C6AF4F697584B9316DF2EDA30659669A023809F360299E422E1B9FA699B6D0
+E0C48ECF63850517CA1634951F1DB71144A2672EECF09024ABC21BF3645EDF2F
+E0C6AF4E83850574103F7B4C9CFD1418E16A480B2CFC63CAE0361AA38E02916D
+E0C56F83F90685D665DBCDEDED15F9D9D601088BF302165EAFBA3C5939E5FB72
+E0C56F4F6A37D938405A8056E115FA97AAE0188CAE24EF5B1B420B091B56B90D
+E0C56F4F69458677D6764D8DA30D6F1EC260588D2D0A05C06B363C91F5C64110
+E0C56ECF63A65A7749EEDFAC990D0E91C1678A0DEAC6B0630931FB0C805B6D30
+E1C56FC4F404C7152210F2655D0D98C8C2E5F80E6F19BA804BBE2B1B5D7B7F93
diff --git a/tests/trau_conv/efr_speech_twts001_mix.hex b/tests/trau_conv/efr_speech_twts001_mix.hex
new file mode 100644
index 0000000..ff8bcec
--- /dev/null
+++ b/tests/trau_conv/efr_speech_twts001_mix.hex
@@ -0,0 +1,25 @@
+# This hex file (TW-TS-005 Annex A format) contains some RTP payloads for
+# GSM-EFR codec, using the extended RTP payload format of TW-TS-001,
+# semantically corresponding to the uplink direction of a GSM call leg.
+#
+# The present example contains a mix of good and bad frames, the same
+# kind of mix that can be represented in a TRAU-UL frame stream.
+# This example has been constructed by taking a few frames out of
+# efr_speech_twts001_good.hex and corrupting some of them, turning them
+# into BFIs. The setting of DTXd bit is also exercised.
+
+# DTXd=0
+E0C56F510999C278B23386B76AA713CFD60D070530DE0152A4C55CC93032854F
+E0C6AF4F63A502B7560FFB36A2B5D10BFE8C3785EC5026496FC17C1E4C8D248F
+E2C56F4F69375336549EF23661157859F7D6D806B28BDCCE43BDAA9697FFFFFF
+E0C6AECF63550376301D108824DD2B1E1C9267072E6CA14017ADDB84A09202AC
+E2C56FC4F935D4963DA918A5250D0C0243B69887F2278593343A0B97F3000000
+E2C6AF5069E8041AFE322B00E10E4C24538AAAAAA20271A9E24A2C16F52ED90F
+
+# DTXd=1
+E8C56F510999C278B23386B76AA713CFD60D070530DE0152A4C55CC93032854F
+E8C6AF4F63A502B7560FFB36A2B5D10BFE8C3785EC5026496FC17C1E4C8D248F
+EAC56F4F69375336549EF23661157859F7D6D806B28BDCCE43BDAA9697FFFFFF
+E8C6AECF63550376301D108824DD2B1E1C9267072E6CA14017ADDB84A09202AC
+EAC56FC4F935D4963DA918A5250D0C0243B69887F2278593343A0B97F3000000
+EAC6AF5069E8041AFE322B00E10E4C24538AAAAAA20271A9E24A2C16F52ED90F
diff --git a/tests/trau_conv/fr_speech_basic.hex b/tests/trau_conv/fr_speech_basic.hex
new file mode 100644
index 0000000..d6ee569
--- /dev/null
+++ b/tests/trau_conv/fr_speech_basic.hex
@@ -0,0 +1,19 @@
+# This hex file (TW-TS-005 Annex A format) contains some RTP payloads for
+# GSM-FR codec, using the basic RTP payload format of RFC 3551. The only
+# semantics allowed by this basic RTP payload format are good speech and
+# valid SID frames; the present test sequence exercises both.
+
+# first 4 frames from GSM 06.10 Seq01.cod: good speech frames
+D760A2E177503E681BD129615AB83E5C9CB52BB6B706F9CA56D4F037F7837A86BC
+D96292A5577FB8B75C10E8535D19FB4399B73299398CF96AE516D9D8D5258638C6
+D9E39269CF5FF3F318AF44285FF9469AB5C1DF7F78E35770BB30D91850EDA24E1C
+D8638B28E75F392A23B04AE29D365728A74C63BD36C694A9AE5D59FBD7D4315765
+
+# frame #41 (0-based numbering) from GSM 06.32 good_sp.cod: valid SID frame
+DAE6DB659B00010000000000000100000000000001000000000000010000000000
+
+# fixed silence frame of GSM 06.11
+DAA7AAA51A502038E46DB91B502038E46DB91B502038E46DB91B502038E46DB91B
+
+# decoder homing frame introduced in later versions of GSM 06.10
+D2577A1CDA50004924924924500049249249245000492492492450004923924924
diff --git a/tests/trau_conv/fr_speech_twts001_good.hex b/tests/trau_conv/fr_speech_twts001_good.hex
new file mode 100644
index 0000000..8aa5467
--- /dev/null
+++ b/tests/trau_conv/fr_speech_twts001_good.hex
@@ -0,0 +1,34 @@
+# This hex file (TW-TS-005 Annex A format) contains some RTP payloads for
+# GSM-FR codec, using the extended RTP payload format of TW-TS-001,
+# semantically corresponding to the uplink direction of a GSM call leg.
+#
+# The present example has been synthetically constructed from GSM 06.10
+# test sequence Seq01.cod (first 24 frames, enough to exercise TAF),
+# exhibiting the scenario of how GSM TCH/FS UL would look with this
+# sequence in it under conditions of 100% error-free transmission,
+# i.e., no bad, corrupted or FACCH-stolen frames.
+
+E0D760A2E177503E681BD129615AB83E5C9CB52BB6B706F9CA56D4F037F7837A86BC
+E0D96292A5577FB8B75C10E8535D19FB4399B73299398CF96AE516D9D8D5258638C6
+E0D9E39269CF5FF3F318AF44285FF9469AB5C1DF7F78E35770BB30D91850EDA24E1C
+E0D8638B28E75F392A23B04AE29D365728A74C63BD36C694A9AE5D59FBD7D4315765
+E0D7A0A2E16FB9950C6AF5D56661FA37244DC8D8DD5767D738B35E7D39C6E64E4904
+E0D81FA2E19F79D7F7149226757FD98AEB6DB8DB9FF44AD49148E761FD48E492355F
+E0D85F9AE5A7B9178F48EE199BB7F80CEA6DD45C5FB4F4B8A29CDB7F16AD206B4507
+E0DA208AA60F5BD836EAE64945E17B569DA8AEE057FAAB2A3374265F59B12589ACE1
+E0D8E48AE8D79D1943E44F14ECDD56C3DD0E4C29B938DA84B286BD5DFB41A56B38DF
+E0D89F9AE96760BB2A1BB1B5657F5734B1A2CA8FB93B4E9391C90C9956F98A5B18AF
+E0D81EA2E5E761957644764873DF59594C90E5D57DF946DB8DC3A779170C23A93AE9
+E0D99E92E657B9B6259996510F7FB6F30F6637149F78694B9455DDB8F894F6465A5F
+E0D8E292A91F97F828DDC9ACF85F37B7E42F4C267F58D11689BB215B589F3887C4E5
+E0D91E9AE1DFBBB81A8791C54ED7168E94EA063D7D3888EC6F3A207FD34CDD5EE5C6
+E0D8A38AE91FDDFB38DCCA0F32B919669F8D3D22D916AF6136E09F7DB70CDC4D3724
+E0D82292E8E7DB76EC50F1991DB91A0A73CAB8A499958AEB75BAA9D975F7447AA07C
+E0D8A09AE997BD39569775590CBDF66B10F231595B98F0CC7238E399B6495D155538
+E0DA1E8AE6CF619957DC6D58E25F382C9F715746BCF74F20F207F5D75762E451FA20
+E0D8628AE8DFD7F8B8DD7C45257FF93C9C7DC165BF18A65EAD2EA07B37B9589640E5
+E0D92092A997B759E11D4D69119DF6E760AFB32F7F98F31C71A7237FF9B532824A99
+E0D81FA2E5A7B939BAE0AAC8D4D9757495CD0DEA9DB62317516555DDB47C13E2AB54
+E0D8609AE92779191CF98DA9A4B991E9A1A7A6DD5FD5BE618ACAE39FFAB91B8E38FA
+E0D92192A9575D97236551CD045936CFD08B947F9B59976C2E5A18D9DA26DC7531A6
+E1D9DD8AE6979F1706B48CE55D9AB83517505754D6F93B619308BAD7DA48E38D57C5
diff --git a/tests/trau_conv/fr_speech_twts001_mix.hex b/tests/trau_conv/fr_speech_twts001_mix.hex
new file mode 100644
index 0000000..e6360ff
--- /dev/null
+++ b/tests/trau_conv/fr_speech_twts001_mix.hex
@@ -0,0 +1,25 @@
+# This hex file (TW-TS-005 Annex A format) contains some RTP payloads for
+# GSM-FR codec, using the extended RTP payload format of TW-TS-001,
+# semantically corresponding to the uplink direction of a GSM call leg.
+#
+# The present example contains a mix of good and bad frames, the same kind
+# of mix that can be represented in a TRAU-UL frame stream. This example
+# has been constructed by taking a few frames out of fr_speech_twts001_good.hex
+# and corrupting some of them, turning them into BFIs. The setting of DTXd bit
+# is also exercised.
+
+# DTXd=0
+E0D81FA2E19F79D7F7149226757FD98AEB6DB8DB9FF44AD49148E761FD48E492355F
+E0D85F9AE5A7B9178F48EE199BB7F80CEA6DD45C5FB4F4B8A29CDB7F16AD206B4507
+E2DA208AA60F5BD836EFFF0005E17B569DA8AEEAAAAAAB2A3374265F59B12589ACE1
+E0D8E48AE8D79D1943E44F14ECDD56C3DD0E4C29B938DA84B286BD5DFB41A56B38DF
+E2D89F9AE96760BB2A1BB1B5657F5734B1777777793B4E9391C90C9956F98A5B18AF
+E2D81EA2E5E7619576447641111119594C90E5D57DF946DB8DC3A779170C23A93AE9
+
+# DTXd=1
+E8D81FA2E19F79D7F7149226757FD98AEB6DB8DB9FF44AD49148E761FD48E492355F
+E8D85F9AE5A7B9178F48EE199BB7F80CEA6DD45C5FB4F4B8A29CDB7F16AD206B4507
+EADA208AA60F5BD836EFFF0005E17B569DA8AEEAAAAAAB2A3374265F59B12589ACE1
+E8D8E48AE8D79D1943E44F14ECDD56C3DD0E4C29B938DA84B286BD5DFB41A56B38DF
+EAD89F9AE96760BB2A1BB1B5657F5734B1777777793B4E9391C90C9956F98A5B18AF
+EAD81EA2E5E7619576447641111119594C90E5D57DF946DB8DC3A779170C23A93AE9
diff --git a/tests/trau_conv/hr_speech_rfc5993.hex b/tests/trau_conv/hr_speech_rfc5993.hex
new file mode 100644
index 0000000..1aa4549
--- /dev/null
+++ b/tests/trau_conv/hr_speech_rfc5993.hex
@@ -0,0 +1,28 @@
+# This hex file (TW-TS-005 Annex B format) contains some RTP payloads for
+# GSM-HR codec, using the slightly extended RTP payload format of
+# IETF RFC 5993.
+#
+# The only semantics allowed by TS 101 318 and RFC 5993 RTP payload formats
+# are good speech and valid SID frames; the present test sequence exercises
+# both, using fragments from the official test sequences of GSM 06.07.
+
+# first 7 frames of seq01.cod, converted to RFC 5993 format
+000371AF61C8F2802531C000000000
+000371AF61C8F2802531C000000000
+008FE9B77000000000000000000000
+008FE3DD7C85DC3B763F126A72C50E
+007F74FA6D486D57F3545134C533FC
+009FE3DD69BE4EAFAC4344893C9799
+00B77916FC7D902F9372B569F5D17F
+
+# first 10 frames of dtx06.cod, converted to RFC 5993 format
+000371AF61C8F2802531C000000000
+000371AF61C8F2802531C000000000
+0000D9EA65CC9CC0E263680674F1ED
+0000D9EA6588CDE0C26B60066CF5ED
+0000D9EA6588CDE0CA6B20066CF5ED
+0000D9EA6588CDE0CA6B20066CF5ED
+0000D9EA6588CDE0CA6B20066CF5ED
+0000D9EA6588CDE0CA6B20066CF5ED
+0000D9EA6588CDE0CA6B20066CF5ED
+2000D9EA65FFFFFFFFFFFFFFFFFFFF
diff --git a/tests/trau_conv/hr_speech_ts101318.hex b/tests/trau_conv/hr_speech_ts101318.hex
new file mode 100644
index 0000000..59c87da
--- /dev/null
+++ b/tests/trau_conv/hr_speech_ts101318.hex
@@ -0,0 +1,28 @@
+# This hex file (TW-TS-005 Annex B format) contains some RTP payloads for
+# GSM-HR codec, using the minimal (no metadata) RTP payload format of
+# ETSI TS 101 318.
+#
+# The only semantics allowed by TS 101 318 and RFC 5993 RTP payload formats
+# are good speech and valid SID frames; the present test sequence exercises
+# both, using fragments from the official test sequences of GSM 06.07.
+
+# first 7 frames of seq01.cod, converted to TS 101 318 format
+0371AF61C8F2802531C000000000
+0371AF61C8F2802531C000000000
+8FE9B77000000000000000000000
+8FE3DD7C85DC3B763F126A72C50E
+7F74FA6D486D57F3545134C533FC
+9FE3DD69BE4EAFAC4344893C9799
+B77916FC7D902F9372B569F5D17F
+
+# first 10 frames of dtx06.cod, converted to TS 101 318 format
+0371AF61C8F2802531C000000000
+0371AF61C8F2802531C000000000
+00D9EA65CC9CC0E263680674F1ED
+00D9EA6588CDE0C26B60066CF5ED
+00D9EA6588CDE0CA6B20066CF5ED
+00D9EA6588CDE0CA6B20066CF5ED
+00D9EA6588CDE0CA6B20066CF5ED
+00D9EA6588CDE0CA6B20066CF5ED
+00D9EA6588CDE0CA6B20066CF5ED
+00D9EA65FFFFFFFFFFFFFFFFFFFF
diff --git a/tests/trau_conv/rtp2trau_efr_dl1.ok b/tests/trau_conv/rtp2trau_efr_dl1.ok
new file mode 100644
index 0000000..4cbf398
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_efr_dl1.ok
@@ -0,0 +1,6 @@
+0000e80fc217d6928f95ad609f1d86188f6c9885c080a402aac080008000800eeb00800080008fff
+0000e80fc217d6928f95ad609f1d86188f6c9885c080a402aac080008000800eeb00800080008fff
+0000e80fdf4ccb25d0409b69fa62ddd7ff17fff794a8cdb6811efd2eea6ecaf8efd3ad13aa4bbfff
+0000e80fd1be87f2e9c089e1831992a1c209dd1e9b208153c09bbd3fe25fdc60da35b0b0a35c9fff
+0000e80fdb3d9e93d649e98bf74ced0bbdc3d9e98e02e0c2c0f6a48cc5fccc00fcd5b54bf0348bff
+0000e80fca1bba53b5b086fffffc8000bc0efffffe008042c07fffffe0008411fffcffe0800481ff
diff --git a/tests/trau_conv/rtp2trau_efr_dl2.ok b/tests/trau_conv/rtp2trau_efr_dl2.ok
new file mode 100644
index 0000000..8a77ee1
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_efr_dl2.ok
@@ -0,0 +1,24 @@
+0000e80fc217d6928f95ad609f1d86188f6c9885c080a402aac080008000800eeb00800080008fff
+0000e80fc217d6928f95ad609f1d86188f6c9885c080a402aac080008000800eeb00800080008fff
+0000e80fdf4ccb25d0409b69fa62ddd7ff17fff794a8cdb6811efd2eea6ecaf8efd3ad13aa4bbfff
+0000e80fd1be87f2e9c089e1831992a1c209dd1e9b208153c09bbd3fe25fdc60da35b0b0a35c9fff
+0000e80fdb3d9e93d649e98bf74ced0bbdc3d9e98e02e0c2c0f6a48cc5fccc00fcd5b54bf0348bff
+0000e80fd1bd87f2b7989183a2b7ac91bf93a0e8f360a2c68154aa7fd8e58c19acb484878edbb3ff
+0000e80fdabd9d07a530975ba2b4a205bd97a71ca58bafc8d036d933ddbccb5cab9d87359b63d7ff
+0000e80fd5bb9ec6e4c09b56a521d920c69dae2984d0e732c1f6b6a3d32c8349fbb4f325d72ce3ff
+0000e80fdabb9766e3a0a156892bd4b3b023ab39dc26f4bfd197b36bab64c3849b75eeb5b623e3ff
+0000e80fd5bda21399f8a78b919c9addd4a9e279fd60e83b8298b780aa54cc7adcc99819a153fbff
+0000e80fdabd9ec7a528ab75b07fecdac52dba21bfe8e1bdc2f69409c92dfc1afc1ea646c923efff
+0000e80fd5bd9ed2b74ab365a4f7c8d9c0c5af0b9f7db6c08359a2f799c8bbebaa96cbfeb01383ff
+0000e80fdabb9ec6d518b76380e8c220cab7a563e1c9933883979b28a802faf3db84d04980ab93ff
+0000e80fd5bf89f2b5fac963ed48e294cbc3a180a43bb4c6c3f989e1b266c3948b97f985ec2597ff
+0000e80fdabda0d3e830c1aff191ac03c043c984c538d0bc8439809cb53ca4acac16fa97b643f7ff
+0000e80fd5bd9ed2c648c76df0fcd5f1b8c7b6caff4588c49636cc91c86ed41caa8fb8f1b0a3d7ff
+0000e80fdabd9ed2f590cb938b6fcbb6c7c1cb2ce9a091c2c4f9d80ab3c8a2dc9b9fd34cedb497ff
+0000e80fd23b9ec78520d17cd0b1d254bcc7b6e2944a933ad776bc248495bc349bf3b22fb7cbe3ff
+0000e80fdabd9d078530d74181fbed32babfa2838e16d2428596bf18f95c835c9aa3c701a45ba3ff
+0000e80fd5be87f28698dd66aedeb7b7dbc5bf3b9d60884485f9c085cbd5fbbcbc599cf2fedcc3ff
+0000e80fd5bd9ed4b7d3938482d4815bc2c5bf52faae80c48657893beb63b4148b098dabae43a3ff
+0000e80fd5bd9ed2c588e77db3b2b636c7c3ade3ec2682c6c696c281b80db364bc91fae3904483ff
+0000e80fd5bb9ec7a643a774cf76feb2b343a1d29c16bc52c6f5b1ac8c619303fb0cc02ddb4c93ff
+0000e80fd5bf89e884e8f1529087c995b943b3198c2eafc2c737c66ed009bbfcab1baebddfe4e3ff
diff --git a/tests/trau_conv/rtp2trau_efr_ul1.ok b/tests/trau_conv/rtp2trau_efr_ul1.ok
new file mode 100644
index 0000000..f456ddb
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_efr_ul1.ok
@@ -0,0 +1,6 @@
+0000e800c217d6928f95ad609f1d86188f6c9885c080a402aac080008000800eeb00800080008eff
+0000e800c217d6928f95ad609f1d86188f6c9885c080a402aac080008000800eeb00800080008eff
+0000e800df4ccb25d0409b69fa62ddd7ff17fff794a8cdb6811efd2eea6ecaf8efd3ad13aa4bbeff
+0000e800d1be87f2e9c089e1831992a1c209dd1e9b208153c09bbd3fe25fdc60da35b0b0a35c9eff
+0000e800db3d9e93d649e98bf74ced0bbdc3d9e98e02e0c2c0f6a48cc5fccc00fcd5b54bf0348aff
+0000e804ca1bba53b5b086fffffc8000bc0efffffe008042c07fffffe0008411fffcffe0800482ff
diff --git a/tests/trau_conv/rtp2trau_efr_ul2.ok b/tests/trau_conv/rtp2trau_efr_ul2.ok
new file mode 100644
index 0000000..6430b9c
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_efr_ul2.ok
@@ -0,0 +1,24 @@
+0000e800c217d6928f95ad609f1d86188f6c9885c080a402aac080008000800eeb00800080008eff
+0000e800c217d6928f95ad609f1d86188f6c9885c080a402aac080008000800eeb00800080008eff
+0000e800df4ccb25d0409b69fa62ddd7ff17fff794a8cdb6811efd2eea6ecaf8efd3ad13aa4bbeff
+0000e800d1be87f2e9c089e1831992a1c209dd1e9b208153c09bbd3fe25fdc60da35b0b0a35c9eff
+0000e800db3d9e93d649e98bf74ced0bbdc3d9e98e02e0c2c0f6a48cc5fccc00fcd5b54bf0348aff
+0000e800d1bd87f2b7989183a2b7ac91bf93a0e8f360a2c68154aa7fd8e58c19acb484878edbb2ff
+0000e800dabd9d07a530975ba2b4a205bd97a71ca58bafc8d036d933ddbccb5cab9d87359b63d6ff
+0000e800d5bb9ec6e4c09b56a521d920c69dae2984d0e732c1f6b6a3d32c8349fbb4f325d72ce2ff
+0000e800dabb9766e3a0a156892bd4b3b023ab39dc26f4bfd197b36bab64c3849b75eeb5b623e2ff
+0000e800d5bda21399f8a78b919c9addd4a9e279fd60e83b8298b780aa54cc7adcc99819a153faff
+0000e800dabd9ec7a528ab75b07fecdac52dba21bfe8e1bdc2f69409c92dfc1afc1ea646c923eeff
+0000e800d5bd9ed2b74ab365a4f7c8d9c0c5af0b9f7db6c08359a2f799c8bbebaa96cbfeb01382ff
+0000e800dabb9ec6d518b76380e8c220cab7a563e1c9933883979b28a802faf3db84d04980ab92ff
+0000e800d5bf89f2b5fac963ed48e294cbc3a180a43bb4c6c3f989e1b266c3948b97f985ec2596ff
+0000e800dabda0d3e830c1aff191ac03c043c984c538d0bc8439809cb53ca4acac16fa97b643f6ff
+0000e800d5bd9ed2c648c76df0fcd5f1b8c7b6caff4588c49636cc91c86ed41caa8fb8f1b0a3d6ff
+0000e800dabd9ed2f590cb938b6fcbb6c7c1cb2ce9a091c2c4f9d80ab3c8a2dc9b9fd34cedb496ff
+0000e800d23b9ec78520d17cd0b1d254bcc7b6e2944a933ad776bc248495bc349bf3b22fb7cbe2ff
+0000e800dabd9d078530d74181fbed32babfa2838e16d2428596bf18f95c835c9aa3c701a45ba2ff
+0000e800d5be87f28698dd66aedeb7b7dbc5bf3b9d60884485f9c085cbd5fbbcbc599cf2fedcc2ff
+0000e800d5bd9ed4b7d3938482d4815bc2c5bf52faae80c48657893beb63b4148b098dabae43a2ff
+0000e800d5bd9ed2c588e77db3b2b636c7c3ade3ec2682c6c696c281b80db364bc91fae3904482ff
+0000e800d5bb9ec7a643a774cf76feb2b343a1d29c16bc52c6f5b1ac8c619303fb0cc02ddb4c92ff
+0000e801d5bf89e884e8f1529087c995b943b3198c2eafc2c737c66ed009bbfcab1baebddfe4e2ff
diff --git a/tests/trau_conv/rtp2trau_efr_ul3.ok b/tests/trau_conv/rtp2trau_efr_ul3.ok
new file mode 100644
index 0000000..4495e4a
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_efr_ul3.ok
@@ -0,0 +1,12 @@
+0000e800d5bda21399f8a78b919c9addd4a9e279fd60e83b8298b780aa54cc7adcc99819a153faff
+0000e800dabd9ec7a528ab75b07fecdac52dba21bfe8e1bdc2f69409c92dfc1afc1ea646c923eeff
+0000e808d5bd9ed2b74ab365a4f7c8d9c0c5af0b9f7db6c08359a2f799c8bbebaa96cbfffffffaff
+0000e800dabb9ec6d518b76380e8c220cab7a563e1c9933883979b28a802faf3db84d04980ab92ff
+0000e808d5bf89f2b5fac963ed48e294cbc3a180a43bb4c6c3f989e1b266c3948b97f98080008eff
+0000e808dabda0d3e830c1aff191ac03c043c984c538d556d551809cb53ca484ac16fa97b643f6ff
+0000e800d5bda21399f8a78b919c9addd4a9e279fd60e83b8298b780aa54cc7adcc99819a153fbff
+0000e800dabd9ec7a528ab75b07fecdac52dba21bfe8e1bdc2f69409c92dfc1afc1ea646c923efff
+0000e808d5bd9ed2b74ab365a4f7c8d9c0c5af0b9f7db6c08359a2f799c8bbebaa96cbfffffffbff
+0000e800dabb9ec6d518b76380e8c220cab7a563e1c9933883979b28a802faf3db84d04980ab93ff
+0000e808d5bf89f2b5fac963ed48e294cbc3a180a43bb4c6c3f989e1b266c3948b97f98080008fff
+0000e808dabda0d3e830c1aff191ac03c043c984c538d556d551809cb53ca484ac16fa97b643f7ff
diff --git a/tests/trau_conv/rtp2trau_fr_dl1.ok b/tests/trau_conv/rtp2trau_fr_dl1.ok
new file mode 100644
index 0000000..af8308c
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_fr_dl1.ok
@@ -0,0 +1,7 @@
+0000f00fdc09ba1abe28c7b29b32c8d396a89ef389f391bbb69d8dbcb46ee447cbdfcc6cf465e7ff
+0000f00fd28aaa9aaffbd1edb8838cc5ce939fb4b17bb168e5b387bce55a94cdf63ac4d3871c8fff
+0000f00ff38ab25ecfebfcf8b85ce50a9ebd99cb95b8c7dff9e3b957e335960dd03a9ada84f1c7ff
+0000f00fc38ca65c9fe9c9aa875286e2ce58edc6c58cdc39f5ad9c91d597cd4dbfbbdd18aaeab7ff
+0000f00feacef696ec008800800080008001800080008000801080008000800081008000800081ff
+0000f00fabcdaa92e428c063c4edd89dc2888638cedb89d8a880e389edb19d85880cb89ddb13dbff
+0000f00fc9d7c2ece4288012a492a492a2808124c924c924a8009249924992458002a4e2a492a7ff
diff --git a/tests/trau_conv/rtp2trau_fr_dl2.ok b/tests/trau_conv/rtp2trau_fr_dl2.ok
new file mode 100644
index 0000000..149c1e7
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_fr_dl2.ok
@@ -0,0 +1,24 @@
+0000f00fdc09ba1abe28c7b29b32c8d396a89ef389f391bbb69d8dbcb46ee447cbdfcc6cf465e7ff
+0000f00fd28aaa9aaffbd1edb8838cc5ce939fb4b17bb168e5b387bce55a94cdf63ac4d3871c8fff
+0000f00ff38ab25ecfebfcf8b85ce50a9ebd99cb95b8c7dff9e3b957e335960dd03a9ada84f1c7ff
+0000f00fc38ca65c9fe9c9aa875286e2ce58edc6c58cdc39f5ad9c91d597cd4dbfbbdd18aaeab7ff
+0000f00fbc09ba1ade778a87957bd552e1bcdec4cad8cec1ed5dbdd7c734dcdf9b33d8b5c49287ff
+0000f00f83f1ba16ee7bbefca892ab47bfb798baf6db8edbe7c59b919289e3c3bd72b892a72bdfff
+0000f00fc3f6ba969e759e8fb07cb0bddb7c987ad6dad4c7eba5f4b8d163edbf92d4e48ccca29fff
+0000f00f8a0caa91cf6ba1edd578a4d1a1ddddcbad51be23abebaa6ac2fa82fd973c84d2d93cb3ff
+0000f00fe24cba5caee58999e4acf16aaed6e99fa8c4d8b0f5a3da81d346af5dbdb28cdccf1ddfff
+0000f00fa3f6ba5a9e1acdaa9b53d953bf95ee49e514ea9cf59b9e969389984cd6deae24ee15bfff
+0000f00f82f1ba9e9e1b8afd80eaa4c7ded59d368931d755fbd39db69d8cb3cf91d0e0eacb5db3ff
+0000f00fb2f2ba99ae77c6a4fa1ab419ffbaef86be87b147e5c3b3669a2afd4eee38d9b586d9dfff
+0000f00fe28aaa52efa7e1a3dab5c9ee9e9beedcccccd82ff963d05395b5932d9639e7839cacb7ff
+0000f00f92f6ba1eef77c1cac393c558fad2e8e98f44b0f5f9a383a9ecf5823fb592fb55f5ae8fff
+0000f00fa38cba52eeefede3d8b4a396c7519bcbb9cb9928ed2daf4ccb58addfb9d0fb15cb62a7ff
+0000f00f828aba5c9f6df6b78873d09da750d8b1f3578a24e7358baeebb5ab0ddf5fd41cf509e7ff
+0000f00fa20eba56aef5c9dccbead498af7ceba5872785d2eb23f1a1e271e38cf8d2b751aaa3e3ff
+0000f00f8af4ba9dce1b89ddf8ecd4e2de989a6bbe2af50df6dd9e48f246f775d5d79894bbd0a3ff
+0000f00fc28cba5cefaff1e3daee8513bfbd9e6b8ef8c537f523ad33dc97a22f9bdcb703a48cb7ff
+0000f00f920aaa56afb5b9b0baaccc958e7eebd4c5dfa1bffb23f871e39693bfbf3cc5a284d5d3ff
+0000f00f83f1ba969e75d9ebc455a4e4a6ddaf49abc89fa9e78da857a29ad55df85ee16e955ac7ff
+0000f00fc20eba529e7989c7de1dc8b2a7738b2ce59db6d7eb75ef0c954de3bcfebca763c71debff
+0000f00f930aaa5aaeeb8ea9a6a3c590a69ae9fd815e94fee573cd69cc6d8c0df4b5db1dab06afff
+0000f00ff374ba95afe58e8ccc9d8d5db6689e45ba22f547aed3eb4c92c1aeb5f4b2b8e3caee97ff
diff --git a/tests/trau_conv/rtp2trau_fr_ul1.ok b/tests/trau_conv/rtp2trau_fr_ul1.ok
new file mode 100644
index 0000000..96ef731
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_fr_ul1.ok
@@ -0,0 +1,7 @@
+00008800dc09ba1abe28c7b29b32c8d396a89ef389f391bbb69d8dbcb46ee447cbdfcc6cf465e6ff
+00008800d28aaa9aaffbd1edb8838cc5ce939fb4b17bb168e5b387bce55a94cdf63ac4d3871c8eff
+00008800f38ab25ecfebfcf8b85ce50a9ebd99cb95b8c7dff9e3b957e335960dd03a9ada84f1c6ff
+00008800c38ca65c9fe9c9aa875286e2ce58edc6c58cdc39f5ad9c91d597cd4dbfbbdd18aaeab6ff
+00008804eacef696ec008800800080008001800080008000801080008000800081008000800082ff
+00008800abcdaa92e428c063c4edd89dc2888638cedb89d8a880e389edb19d85880cb89ddb13daff
+00008800c9d7c2ece4288012a492a492a2808124c924c924a8009249924992458002a4e2a492a6ff
diff --git a/tests/trau_conv/rtp2trau_fr_ul2.ok b/tests/trau_conv/rtp2trau_fr_ul2.ok
new file mode 100644
index 0000000..7abb1db
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_fr_ul2.ok
@@ -0,0 +1,24 @@
+00008800dc09ba1abe28c7b29b32c8d396a89ef389f391bbb69d8dbcb46ee447cbdfcc6cf465e6ff
+00008800d28aaa9aaffbd1edb8838cc5ce939fb4b17bb168e5b387bce55a94cdf63ac4d3871c8eff
+00008800f38ab25ecfebfcf8b85ce50a9ebd99cb95b8c7dff9e3b957e335960dd03a9ada84f1c6ff
+00008800c38ca65c9fe9c9aa875286e2ce58edc6c58cdc39f5ad9c91d597cd4dbfbbdd18aaeab6ff
+00008800bc09ba1ade778a87957bd552e1bcdec4cad8cec1ed5dbdd7c734dcdf9b33d8b5c49286ff
+0000880083f1ba16ee7bbefca892ab47bfb798baf6db8edbe7c59b919289e3c3bd72b892a72bdeff
+00008800c3f6ba969e759e8fb07cb0bddb7c987ad6dad4c7eba5f4b8d163edbf92d4e48ccca29eff
+000088008a0caa91cf6ba1edd578a4d1a1ddddcbad51be23abebaa6ac2fa82fd973c84d2d93cb2ff
+00008800e24cba5caee58999e4acf16aaed6e99fa8c4d8b0f5a3da81d346af5dbdb28cdccf1ddeff
+00008800a3f6ba5a9e1acdaa9b53d953bf95ee49e514ea9cf59b9e969389984cd6deae24ee15beff
+0000880082f1ba9e9e1b8afd80eaa4c7ded59d368931d755fbd39db69d8cb3cf91d0e0eacb5db2ff
+00008800b2f2ba99ae77c6a4fa1ab419ffbaef86be87b147e5c3b3669a2afd4eee38d9b586d9deff
+00008800e28aaa52efa7e1a3dab5c9ee9e9beedcccccd82ff963d05395b5932d9639e7839cacb6ff
+0000880092f6ba1eef77c1cac393c558fad2e8e98f44b0f5f9a383a9ecf5823fb592fb55f5ae8eff
+00008800a38cba52eeefede3d8b4a396c7519bcbb9cb9928ed2daf4ccb58addfb9d0fb15cb62a6ff
+00008800828aba5c9f6df6b78873d09da750d8b1f3578a24e7358baeebb5ab0ddf5fd41cf509e6ff
+00008800a20eba56aef5c9dccbead498af7ceba5872785d2eb23f1a1e271e38cf8d2b751aaa3e2ff
+000088008af4ba9dce1b89ddf8ecd4e2de989a6bbe2af50df6dd9e48f246f775d5d79894bbd0a2ff
+00008800c28cba5cefaff1e3daee8513bfbd9e6b8ef8c537f523ad33dc97a22f9bdcb703a48cb6ff
+00008800920aaa56afb5b9b0baaccc958e7eebd4c5dfa1bffb23f871e39693bfbf3cc5a284d5d2ff
+0000880083f1ba969e75d9ebc455a4e4a6ddaf49abc89fa9e78da857a29ad55df85ee16e955ac6ff
+00008800c20eba529e7989c7de1dc8b2a7738b2ce59db6d7eb75ef0c954de3bcfebca763c71deaff
+00008800930aaa5aaeeb8ea9a6a3c590a69ae9fd815e94fee573cd69cc6d8c0df4b5db1dab06aeff
+00008801f374ba95afe58e8ccc9d8d5db6689e45ba22f547aed3eb4c92c1aeb5f4b2b8e3caee96ff
diff --git a/tests/trau_conv/rtp2trau_fr_ul3.ok b/tests/trau_conv/rtp2trau_fr_ul3.ok
new file mode 100644
index 0000000..925c455
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_fr_ul3.ok
@@ -0,0 +1,12 @@
+0000880083f1ba16ee7bbefca892ab47bfb798baf6db8edbe7c59b919289e3c3bd72b892a72bdeff
+00008800c3f6ba969e759e8fb07cb0bddb7c987ad6dad4c7eba5f4b8d163edbf92d4e48ccca29eff
+000088088a0caa91cf6ba1edd7fee001a1ddddcbad51beaad6aaaa6ac2fa82fd973c84d2d93cb2ff
+00008800e24cba5caee58999e4acf16aaed6e99fa8c4d8b0f5a3da81d346af5dbdb28cdccf1ddeff
+00008808a3f6ba5a9e1acdaa9b53d953bf95ee49e6aff57cf99b9e969389984cd6deae24ee15beff
+0000880882f1ba9e9e1b8afd80eaa41582119d368931d755fbd39db69d8cb3cf91d0e0eacb5db2ff
+0000880083f1ba16ee7bbefca892ab47bfb798baf6db8edbe7c59b919289e3c3bd72b892a72bdfff
+00008800c3f6ba969e759e8fb07cb0bddb7c987ad6dad4c7eba5f4b8d163edbf92d4e48ccca29fff
+000088088a0caa91cf6ba1edd7fee001a1ddddcbad51beaad6aaaa6ac2fa82fd973c84d2d93cb3ff
+00008800e24cba5caee58999e4acf16aaed6e99fa8c4d8b0f5a3da81d346af5dbdb28cdccf1ddfff
+00008808a3f6ba5a9e1acdaa9b53d953bf95ee49e6aff57cf99b9e969389984cd6deae24ee15bfff
+0000880882f1ba9e9e1b8afd80eaa41582119d368931d755fbd39db69d8cb3cf91d0e0eacb5db3ff
diff --git a/tests/trau_conv/rtp2trau_gen.c b/tests/trau_conv/rtp2trau_gen.c
new file mode 100644
index 0000000..3a5eb8d
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_gen.c
@@ -0,0 +1,170 @@
+/*
+ * This program reads RTP payloads for FR/HR/EFR speech from a TW-TS-005
+ * hex file and converts them to either TRAU-DL or TRAU-UL frames
+ * as specified on the command line, exercising osmo_rtp2trau() and
+ * osmo_trau_frame_encode() functions in the process.
+ *
+ * Author: Mychaela N. Falconia <falcon(a)freecalypso.org>, 2025 - however,
+ * Mother Mychaela's contributions are NOT subject to copyright.
+ * No rights reserved, all rights relinquished.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <osmocom/core/bits.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/trau/trau_frame.h>
+#include <osmocom/trau/trau_rtp.h>
+
+#include "tw5reader.h"
+
+static enum osmo_trau_frame_direction direction;
+static struct osmo_trau2rtp_state trau2rtp_st;
+static FILE *out_file;
+
+static void emit_hex_frame(const uint8_t *frame, unsigned nbytes)
+{
+ unsigned n;
+
+ for (n = 0; n < nbytes; n++)
+ fprintf(out_file, "%02x", frame[n]);
+ putc('\n', out_file);
+}
+
+static void emit_hex_trau_frame_16k(const ubit_t *tf_bits)
+{
+ uint8_t tf_bytes[40];
+
+ osmo_ubit2pbit(tf_bytes, tf_bits, sizeof(tf_bytes) * 8);
+ emit_hex_frame(tf_bytes, sizeof(tf_bytes));
+}
+
+static void emit_hex_trau_frame_8k(const ubit_t *tf_bits)
+{
+ uint8_t tf_bytes[20];
+
+ osmo_ubit2pbit(tf_bytes, tf_bits, sizeof(tf_bytes) * 8);
+ emit_hex_frame(tf_bytes, sizeof(tf_bytes));
+}
+
+static void process_record(const uint8_t *rtp_pl, unsigned rtp_pl_len,
+ const char *filename, unsigned lineno)
+{
+ struct osmo_trau_frame tf;
+ ubit_t tf_bits[640]; /* 2x space required by osmo_trau_frame_encode() */
+ int rc;
+
+ tf.dir = direction;
+ rc = osmo_rtp2trau(&tf, rtp_pl, rtp_pl_len, &trau2rtp_st);
+ if (rc < 0) {
+ fprintf(stderr, "%s line %u: not valid for osmo_rtp2trau()\n",
+ filename, lineno);
+ exit(1);
+ }
+ tf.dl_ta_usec = 0;
+ rc = osmo_trau_frame_encode(tf_bits, sizeof(tf_bits), &tf);
+ switch (rc) {
+ case 320:
+ emit_hex_trau_frame_16k(tf_bits);
+ break;
+ case 160:
+ emit_hex_trau_frame_8k(tf_bits);
+ break;
+ default:
+ fprintf(stderr,
+ "%s line %u: osmo_trau_frame_encode() returned %d\n",
+ filename, lineno, rc);
+ exit(1);
+ }
+}
+
+static void process_file(const char *infname, const char *outfname)
+{
+ FILE *inf;
+ unsigned lineno;
+ uint8_t frame[TWTS005_MAX_FRAME];
+ unsigned frame_len;
+ int rc;
+
+ inf = fopen(infname, "r");
+ if (!inf) {
+ perror(infname);
+ exit(1);
+ }
+ if (outfname) {
+ out_file = fopen(outfname, "w");
+ if (!out_file) {
+ perror(outfname);
+ exit(1);
+ }
+ } else {
+ out_file = stdout;
+ }
+
+ lineno = 0;
+ for (;;) {
+ rc = twts005_read_frame(inf, &lineno, frame, &frame_len);
+ if (rc < 0) {
+ fprintf(stderr, "%s line %u: not valid TW-TS-005\n",
+ infname, lineno);
+ exit(1);
+ }
+ if (!rc)
+ break;
+ process_record(frame, frame_len, infname, lineno);
+ }
+
+ fclose(inf);
+ if (outfname) {
+ fclose(out_file);
+ out_file = NULL;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ char *infname, *outfname;
+
+ if (argc < 4 || argc > 5)
+ goto usage;
+ infname = argv[1];
+ if (!strcmp(argv[2], "fr"))
+ trau2rtp_st.type = OSMO_TRAU16_FT_FR;
+ else if (!strcmp(argv[2], "hr"))
+ trau2rtp_st.type = OSMO_TRAU8_SPEECH;
+ else if (!strcmp(argv[2], "hr16"))
+ trau2rtp_st.type = OSMO_TRAU16_FT_HR;
+ else if (!strcmp(argv[2], "efr"))
+ trau2rtp_st.type = OSMO_TRAU16_FT_EFR;
+ else
+ goto usage;
+ if (!strcmp(argv[3], "dl"))
+ direction = OSMO_TRAU_DIR_DL;
+ else if (!strcmp(argv[3], "ul"))
+ direction = OSMO_TRAU_DIR_UL;
+ else
+ goto usage;
+ outfname = argv[4];
+
+ process_file(infname, outfname);
+ exit(0);
+
+usage: fprintf(stderr,
+ "usage: %s input-file fr|hr|hr16|efr dl|ul [output-file]\n",
+ argv[0]);
+ exit(1);
+}
diff --git a/tests/trau_conv/rtp2trau_hr_dl.ok b/tests/trau_conv/rtp2trau_hr_dl.ok
new file mode 100644
index 0000000..18e7cf2
--- /dev/null
+++ b/tests/trau_conv/rtp2trau_hr_dl.ok
@@ -0,0 +1,17 @@
+00884486f1d7d8b98ff2c089a69c8080808080bf
+00884486f1d7d8b98ff2c089a69c8080808080bf
+0088469fe9dbdc8080d0808080808080808080bf
+0088469fe3eedf90dd9c9dddc7f193a9e5c587bf
+008845fef4fd9ba986ddabfceac589d38ab3febf
+008846bfe3eedab7e4aed7eb88b4a4a4f997ccff
+008846eef98bbf8fd9a097e4eeababa7ebd1bfff
+00884486f1d7d8b98ff2c089a69c8080808080bf
+00884486f1d7d8b98ff2c089a69c8080808080bf
+00884481d9f599b9c9cce0b8ccb6c099e9f1f6ff
+00884481d9f599b18c9df0b0cdb68099d9f5f6ff
+00884481d9f599b18c9df0b2cdb28099d9f5f6ff
+00884481d9f599b18c9df0b2cdb28099d9f5f6ff
+00884481d9f599b18c9df0b2cdb28099d9f5f6ff
+00884481d9f599b18c9df0b2cdb28099d9f5f6ff
+00884481d9f599b18c9df0b2cdb28099d9f5f6ff
+00885081d9f599bfffffffffffffffffffffffff
diff --git a/tests/trau_conv/tw5reader.c b/tests/trau_conv/tw5reader.c
new file mode 100644
index 0000000..104258b
--- /dev/null
+++ b/tests/trau_conv/tw5reader.c
@@ -0,0 +1,80 @@
+/*
+ * This C module has been adapted from Themyscira Wireless GSM codec libraries
+ * and utilities suite. It implements a function that reads RTP payloads
+ * from hex files in TW-TS-005 format.
+ *
+ * Author: Mychaela N. Falconia <falcon(a)freecalypso.org>, 2025 - however,
+ * Mother Mychaela's contributions are NOT subject to copyright.
+ * No rights reserved, all rights relinquished.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include "tw5reader.h"
+
+static int decode_hex_digit(char c)
+{
+ if (isdigit(c))
+ return c - '0';
+ else if (isupper(c))
+ return c - 'A' + 10;
+ else
+ return c - 'a' + 10;
+}
+
+int twts005_read_frame(FILE *hexf, unsigned *lineno, uint8_t *frame,
+ unsigned *lenp)
+{
+ char linebuf[82];
+ char *cp, *np;
+ uint8_t *dp;
+ unsigned len;
+
+ for (;;) {
+ if (!fgets(linebuf, sizeof(linebuf), hexf))
+ return 0;
+ (*lineno)++;
+ if (!strchr(linebuf, '\n'))
+ return -2;
+ for (cp = linebuf; isspace(*cp); cp++)
+ ;
+ if (*cp != '\0' && *cp != '#')
+ break;
+ }
+ for (np = cp; *cp && !isspace(*cp); cp++)
+ ;
+ if (*cp)
+ *cp++ = '\0';
+ while (isspace(*cp))
+ cp++;
+ if (*cp != '\0' && *cp != '#')
+ return -1;
+ if (!strcasecmp(np, "NULL")) {
+ *lenp = 0;
+ return 1;
+ }
+
+ dp = frame;
+ len = 0;
+ for (cp = np; *cp; cp += 2) {
+ if (!isxdigit(cp[0]) || !isxdigit(cp[1]))
+ return -1;
+ *dp++ = (decode_hex_digit(cp[0]) << 4) |
+ decode_hex_digit(cp[1]);
+ len++;
+ }
+ *lenp = len;
+ return 1;
+}
diff --git a/tests/trau_conv/tw5reader.h b/tests/trau_conv/tw5reader.h
new file mode 100644
index 0000000..dd4d8a4
--- /dev/null
+++ b/tests/trau_conv/tw5reader.h
@@ -0,0 +1,23 @@
+/*
+ * This header file defines the interface to our reader function for
+ * hexadecimal RTP frame sequence files in TW-TS-005 format.
+ *
+ * twts005_read_frame() return values are:
+ * 1 = successfully read valid frame
+ * 0 = normal EOF
+ * -1 = read line with invalid content
+ * -2 = line too long or missing newline
+ *
+ * The reader function skips blank, whitespace-only and comment lines,
+ * returning only actual frames. lineno variable must be initialized to 0
+ * by the application program, but not touched otherwise. In case of an
+ * error, this variable will hold the line number at which the error was
+ * encountered.
+ */
+
+#pragma once
+
+#define TWTS005_MAX_FRAME 40
+
+int twts005_read_frame(FILE *hexf, unsigned *lineno, uint8_t *frame,
+ unsigned *lenp);
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39621?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ia5ca8af6bd3a899253bbcc718b70e43f2265b495
Gerrit-Change-Number: 39621
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39623?usp=email )
Change subject: rtp2trau HR: remove broken TRAU-16k-UL support
......................................................................
rtp2trau HR: remove broken TRAU-16k-UL support
GSM 08.61 defines two TRAU frame formats for HRv1 codec, using
either 16 kbit/s or 8 kbit/s submultiplexing. The 16k format may be
used only on Abis, not in TFO. When we interface to an E1 BTS, we
need to receive TRAU-UL frames and generate TRAU-DL frames - not
any other combination. Untested support for emitting both
TRAU-16k-DL and TRAU-16k-UL frames for HR codec was added in the
very initial version of trau_rtp_conv.c module in 2020 by HW - but
while TRAU-16k-DL output support is potentially useful (if there
exist any historical BTS models that use this format), there is no
code anywhere in Osmocom that uses osmo_rtp2trau() to generate
TRAU-16k-UL frames for HR.
The legacy code that is removed in this patch should be considered
broken. Proper generation of TRAU-16k-UL frames (e.g., in a BTS
emulator) would require ability to generate BFI, UFI, invalid SID,
TAF and other possible happenings in the UL of a call leg, but no
such capabilities exist in the legacy code being removed. We do
support all of these capabilities for TRAU-8k-UL output, using
TW-TS-002 as the matching RTP format, but TW-TS-002 was designed
to feature-match TRAU-8k-UL, not TRAU-16k-UL.
Change-Id: If50036c4de9a11db524abffcd87d053878104982
---
M src/trau/trau_rtp_conv.c
1 file changed, 22 insertions(+), 46 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/23/39623/1
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index d5ac1fa..86d2b77 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -678,6 +678,10 @@
static int rtp2trau_hr16(struct osmo_trau_frame *tf, const uint8_t *data, size_t data_len)
{
+ /* for TRAU-16k form of GSM-HR, we only support TRAU-DL output */
+ if (tf->dir != OSMO_TRAU_DIR_DL)
+ return -ENOTSUP;
+
/* accept both TS 101 318 and RFC 5993 payloads */
switch (data_len) {
case GSM_HR_BYTES:
@@ -695,57 +699,26 @@
tf->type = OSMO_TRAU16_FT_HR;
- if (tf->dir == OSMO_TRAU_DIR_UL) {
- /* C1 .. C5 */
- tf->c_bits[0] = 0;
- tf->c_bits[1] = 0;
- tf->c_bits[2] = 0;
- tf->c_bits[3] = 1;
- tf->c_bits[4] = 1;
- } else {
- /* C1 .. C5 */
- tf->c_bits[0] = 1;
- tf->c_bits[1] = 1;
- tf->c_bits[2] = 1;
- tf->c_bits[3] = 0;
- tf->c_bits[4] = 1;
- }
+ /* C1 .. C5 */
+ tf->c_bits[0] = 1;
+ tf->c_bits[1] = 1;
+ tf->c_bits[2] = 1;
+ tf->c_bits[3] = 0;
+ tf->c_bits[4] = 1;
/* C6.. C11: Time Alignment */
memset(tf->c_bits + 5, 0, 6);
- if (tf->dir == OSMO_TRAU_DIR_UL) {
- /* BFI */
- if (data_len == 0)
- tf->c_bits[11] = 1;
- else
- tf->c_bits[11] = 0;
- if (osmo_hr_check_sid(data, data_len)) {
- /* SID=2 is a valid SID frame */
- tf->c_bits[12] = 1;
- tf->c_bits[13] = 0;
- } else {
- tf->c_bits[12] = 0;
- tf->c_bits[13] = 0;
- }
- /* FIXME: C15: TAF */
+ tf->c_bits[11] = 1; /* C12: UFE */
+ tf->c_bits[12] = 1; /* C13: spare */
+ tf->c_bits[13] = 1; /* C14: spare */
+ tf->c_bits[14] = 1; /* C15: spare */
+ if (osmo_hr_check_sid(data, data_len))
tf->c_bits[15] = 0; /* C16: SP */
- tf->c_bits[16] = 0; /* C17: DTXd shall not be applied */
- } else {
- tf->c_bits[11] = 1; /* C12: UFE */
- tf->c_bits[12] = 1; /* C13: spare */
- tf->c_bits[13] = 1; /* C14: spare */
- tf->c_bits[14] = 1; /* C15: spare */
- if (osmo_hr_check_sid(data, data_len))
- tf->c_bits[15] = 0; /* C16: SP */
- else
- tf->c_bits[15] = 1; /* C16: SP */
- tf->c_bits[16] = 1; /* C17: spare */
- }
+ else
+ tf->c_bits[15] = 1; /* C16: SP */
+ tf->c_bits[16] = 1; /* C17: spare */
memset(tf->c_bits+17, 1, 4); /* C18..C21: spare */
memset(&tf->t_bits[0], 1, 4);
- if (tf->dir == OSMO_TRAU_DIR_UL)
- tf->ufi = 0;
- else
- tf->ufi = 1;
+ tf->ufi = 1; /* spare bit in TRAU-DL */
if (data_len)
osmo_pbit2ubit(tf->d_bits, data, GSM_HR_BYTES * 8);
else
@@ -1693,6 +1666,9 @@
* format for conversion to TRAU-UL is TW-TS-002. RFC 5993 payloads are
* also accepted (because it is a subset of TW-TS-002), but not TS 101 318.
*
+ * - HRv1 conversion to TRAU-UL is supported only in TRAU-8k format, not
+ * TRAU-16k. TFO always uses TRAU-8k format for this codec.
+ *
* - TRAU-UL output for CSD 14.4 kbit/s mode is not currently implemented
* (C-bits are always set according to the rules for TRAU-DL) - but the
* primary application for TRAU-UL frame output via libosmotrau is TFO,
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39623?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: If50036c4de9a11db524abffcd87d053878104982
Gerrit-Change-Number: 39623
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39626?usp=email )
Change subject: rtp2trau HR to DL: validate ToC octet of RFC 5993
......................................................................
rtp2trau HR to DL: validate ToC octet of RFC 5993
This validation serves two purposes:
* Payloads that just happen to be 15 bytes long but aren't valid
RFC 5993 should be rejected;
* Super-5993 extensions of TW-TS-002 are valid only in UL, not in DL
- catch and block them.
Change-Id: Ibbaa1e1e12254eaf75a999dd1b58e2145eff158c
---
M src/trau/trau_rtp_conv.c
1 file changed, 13 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/26/39626/1
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index 1114aaf..9c7ff47 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -664,6 +664,12 @@
case GSM_HR_BYTES:
break;
case GSM_HR_BYTES_RTP_RFC5993:
+ /* Require RFC 5993 valid frame, i.e., no BFIs etc.
+ * Specifically, require (F==0 && (FT==0 || FT==2));
+ * masking with 0xD0 is a clever way of effecting
+ * this check. */
+ if (data[0] & 0xD0)
+ return -EINVAL;
data++;
data_len--;
break;
@@ -707,6 +713,12 @@
case GSM_HR_BYTES:
break;
case GSM_HR_BYTES_RTP_RFC5993:
+ /* Require RFC 5993 valid frame, i.e., no BFIs etc.
+ * Specifically, require (F==0 && (FT==0 || FT==2));
+ * masking with 0xD0 is a clever way of effecting
+ * this check. */
+ if (data[0] & 0xD0)
+ return -EINVAL;
data++;
data_len--;
break;
@@ -1580,7 +1592,7 @@
* defined in ETSI TS 101 318 for FR, HR and EFR; the ones for FR and EFR
* are also duplicated in RFC 3551. In the case of HR codec, RFC 5993 input
* is also appropriate as specified in 3GPP TS 48.103 - as long as the user
- * remembers that the extra header octet is ignored.
+ * remembers that the extra header octet is ignored beyond validation check.
*
* - The only correct way to implement TrFO for GSM, accepting FR/HR/EFR from
* call leg A uplink in TW-TS-001 or TW-TS-002 format and generating TRAU-DL
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39626?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ibbaa1e1e12254eaf75a999dd1b58e2145eff158c
Gerrit-Change-Number: 39626
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39624?usp=email )
Change subject: rtp2trau: remove broken acceptance of 0-length payloads
......................................................................
rtp2trau: remove broken acceptance of 0-length payloads
Since the beginning of osmo_rtp2trau() in 2020, this API accepted
0-length RTP payloads for FR, HR and EFR, for both TRAU-DL and
TRAU-UL output. However, this "support" never worked correctly:
* For FR & EFR in DL direction, previous patch 1d42fcd4ea40
attempted to emit the idle speech frame of TS 48.060 section 5.4,
following sections 6.5.2 and 6.5.3 of the same spec. However,
the actual combination of osmo_rtp2trau() followed by
osmo_trau_frame_encode() resulted in an invalid FR/EFR TRAU-DL
frame being emitted, rather than the intended special idle speech
frame. It is also very uncertain if real E1 BTS would handle
that idle speech frame particularly well even if we did emit one
correctly - it is a strange "feature" of the spec that never
occurs in real operation of a TRAU, neither in free-running
speech encoder state nor in TFO.
* For FR & EFR in UL direction, the same previous patch would turn
0-length payload input (or TW-TS-001 No_Data input with later
patches) into BFI with a peculiar fill pattern. The fill pattern
was all-1s in the case of FR or all-1s plus bad CRC in the case of
EFR. (The 5 CRCs of EFR TRAU frame format just happen to come out
bad when all Dn bits are set to 1 - not intentional CRC inversion.)
TRAU-UL output is not currently used anywhere in Osmocom; there is
a plan to implement TFO in ThemWi software using Osmocom libraries,
but this type of fixed bit fill is not a good choice for TFO frame
output going to foreign GSM network operators.
* For HR speech to TRAU-DL conversion, the effect of 0-length payload
input was emission of a TRAU-DL frame that looks valid, but has all
112 bits of payload set to 0, with correct CRC. All-zeros is a poor
choice of LPC parameter fill for dummy GSM-HR codec frames; if an
application wishes to implement dummy frame fill, it should control
its own fill frame pattern, rather than expect osmo_rtp2trau() to
provide good idle fill.
Solution: simply remove all bogo-support for 0-length RTP payload
input to osmo_rtp2trau() in the case of speech codecs, and return
-EINVAL just like for all other types of invalid RTP input.
Effect on OsmoMGW-E1: the only time when OsmoMGW could pass a 0-length
payload to osmo_rtp2trau() would be if the RTP stream comes from
OsmoBTS (not from another leg on OsmoMGW-E1) with vty option
'rtp continuous-streaming' enabled. Prior to the present patch,
the resulting effect would be bogus output on Abis DL; after this
patch, the MGW behavior will be the same as with no RTP input -
the MGW will insert fixed fill frames at the application level,
going directly to I.460 mux.
Change-Id: Ia41ea2eab1ded094cadcd91dbd33de8800af11ee
---
M src/trau/trau_rtp_conv.c
1 file changed, 30 insertions(+), 108 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/24/39624/1
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index 86d2b77..8d2631b 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -580,18 +580,11 @@
data_len--;
}
- /* now we must have either standard FR or no-data input */
- switch (data_len) {
- case GSM_FR_BYTES:
- if ((data[0] & 0xF0) != 0xD0)
- return -EINVAL;
- break;
- case 0:
- bfi = true;
- break;
- default:
+ /* with or without TW-TS-001 TEH, we require 260-bit GSM-FR payload */
+ if (data_len != GSM_FR_BYTES)
return -EINVAL;
- }
+ if ((data[0] & 0xF0) != 0xD0)
+ return -EINVAL;
tf->type = OSMO_TRAU16_FT_FR;
@@ -606,34 +599,20 @@
tf->c_bits[3] = 1;
tf->c_bits[4] = 0;
} else { /* DL */
- if (data_len == 0) {
- /* C1 .. C5: idle speech */
- tf->c_bits[0] = 0;
- tf->c_bits[1] = 1;
- tf->c_bits[2] = 1;
- tf->c_bits[3] = 1;
- tf->c_bits[4] = 0;
- } else {
- /* C1 .. C5: FR DL */
- tf->c_bits[0] = 1;
- tf->c_bits[1] = 1;
- tf->c_bits[2] = 1;
- tf->c_bits[3] = 0;
- tf->c_bits[4] = 0;
- }
+ /* C1 .. C5: FR DL */
+ tf->c_bits[0] = 1;
+ tf->c_bits[1] = 1;
+ tf->c_bits[2] = 1;
+ tf->c_bits[3] = 0;
+ tf->c_bits[4] = 0;
}
memset(&tf->c_bits[5], 0, 6); /* C6 .. C11: Time Alignment */
if (tf->dir == OSMO_TRAU_DIR_UL) {
tf->c_bits[11] = bfi; /* C12: BFI */
- if (data_len == 0) {
- tf->c_bits[12] = 0; /* C13: SID=0 */
- tf->c_bits[13] = 0; /* C14: SID=0 */
- } else {
- /* SID classification per GSM 06.31 section 6.1.1 */
- sidc = osmo_fr_sid_classify(data);
- tf->c_bits[12] = (sidc >> 1) & 1; /* C13: msb */
- tf->c_bits[13] = (sidc >> 0) & 1; /* C14: lsb */
- }
+ /* SID classification per GSM 06.31 section 6.1.1 */
+ sidc = osmo_fr_sid_classify(data);
+ tf->c_bits[12] = (sidc >> 1) & 1; /* C13: msb */
+ tf->c_bits[13] = (sidc >> 0) & 1; /* C14: lsb */
tf->c_bits[14] = taf; /* C15: TAF (SACCH or not) */
tf->c_bits[15] = 1; /* C16: spare */
tf->c_bits[16] = dtxd; /* C17: DTXd applied or not */
@@ -648,12 +627,6 @@
memset(&tf->c_bits[17], 1, 4); /* C18 .. C21: spare */
memset(&tf->t_bits[0], 1, 4);
- if (!data_len) {
- /* idle speech frame if DL, BFI speech frame if UL */
- memset(&tf->d_bits[0], 1, 260);
- return 0;
- }
-
/* reassemble d-bits */
i = 0; /* counts bits */
j = 4; /* counts input bits */
@@ -690,9 +663,6 @@
data++;
data_len--;
break;
- case 0:
- /* accept no-data input */
- break;
default:
return -EINVAL;
}
@@ -719,10 +689,7 @@
memset(tf->c_bits+17, 1, 4); /* C18..C21: spare */
memset(&tf->t_bits[0], 1, 4);
tf->ufi = 1; /* spare bit in TRAU-DL */
- if (data_len)
- osmo_pbit2ubit(tf->d_bits, data, GSM_HR_BYTES * 8);
- else
- memset(tf->d_bits, 0, GSM_HR_BYTES * 8);
+ osmo_pbit2ubit(tf->d_bits, data, GSM_HR_BYTES * 8);
/* CRC is *not* computed by TRAU frame encoder - we have to do it */
osmo_crc8gen_set_bits(&gsm0860_efr_crc3, tf->d_bits, 44, tf->crc_bits);
@@ -739,9 +706,6 @@
data++;
data_len--;
break;
- case 0:
- /* accept no-data input */
- break;
default:
return -EINVAL;
}
@@ -776,10 +740,7 @@
memset(&tf->t_bits[0], 1, 2);
- if (data_len)
- osmo_pbit2ubit(tf->d_bits, data, GSM_HR_BYTES * 8);
- else
- memset(tf->d_bits, 0, GSM_HR_BYTES * 8);
+ osmo_pbit2ubit(tf->d_bits, data, GSM_HR_BYTES * 8);
/* CRC is *not* computed by TRAU frame encoder - we have to do it */
osmo_crc8gen_set_bits(&gsm0860_efr_crc3, tf->d_bits, 44, tf->crc_bits);
@@ -927,52 +888,30 @@
data_len--;
}
- /* now we must have either standard EFR or no-data input */
- switch (data_len) {
- case GSM_EFR_BYTES:
- if ((data[0] & 0xF0) != 0xC0)
- return -EINVAL;
- break;
- case 0:
- bfi = true;
- break;
- default:
+ /* with or without TW-TS-001 TEH, we require 244-bit GSM-EFR payload */
+ if (data_len != GSM_EFR_BYTES)
return -EINVAL;
- }
+ if ((data[0] & 0xF0) != 0xC0)
+ return -EINVAL;
tf->type = OSMO_TRAU16_FT_EFR;
/* FR Data Bits according to TS 48.060 Section 5.5.1.1.2 */
/* set c-bits and t-bits */
- if (data_len == 0 && tf->dir == OSMO_TRAU_DIR_DL) {
- /* C1 .. C5: idle speech */
- tf->c_bits[0] = 0;
- tf->c_bits[1] = 1;
- tf->c_bits[2] = 1;
- tf->c_bits[3] = 1;
- tf->c_bits[4] = 0;
- } else {
- /* C1 .. C5: EFR */
- tf->c_bits[0] = 1;
- tf->c_bits[1] = 1;
- tf->c_bits[2] = 0;
- tf->c_bits[3] = 1;
- tf->c_bits[4] = 0;
- }
-
+ /* C1 .. C5: EFR */
+ tf->c_bits[0] = 1;
+ tf->c_bits[1] = 1;
+ tf->c_bits[2] = 0;
+ tf->c_bits[3] = 1;
+ tf->c_bits[4] = 0;
memset(&tf->c_bits[5], 0, 6); /* C6 .. C11: Time Alignment */
if (tf->dir == OSMO_TRAU_DIR_UL) {
tf->c_bits[11] = bfi; /* C12: BFI */
- if (data_len == 0) {
- tf->c_bits[12] = 0; /* C13: SID=0 */
- tf->c_bits[13] = 0; /* C14: SID=0 */
- } else {
- /* SID classification per GSM 06.81 section 6.1.1 */
- sidc = osmo_efr_sid_classify(data);
- tf->c_bits[12] = (sidc >> 1) & 1; /* C13: msb */
- tf->c_bits[13] = (sidc >> 0) & 1; /* C14: lsb */
- }
+ /* SID classification per GSM 06.81 section 6.1.1 */
+ sidc = osmo_efr_sid_classify(data);
+ tf->c_bits[12] = (sidc >> 1) & 1; /* C13: msb */
+ tf->c_bits[13] = (sidc >> 0) & 1; /* C14: lsb */
tf->c_bits[14] = taf; /* C15: TAF (SACCH or not) */
tf->c_bits[15] = 1; /* C16: spare */
tf->c_bits[16] = dtxd; /* C17: DTXd applied or not */
@@ -988,12 +927,6 @@
memset(&tf->c_bits[17], 1, 4); /* C18 .. C21: spare */
memset(&tf->t_bits[0], 1, 4);
- if (data_len == 0) {
- /* idle speech frame if DL, BFI speech frame if UL */
- memset(&tf->d_bits[0], 1, 260);
- return 0;
- }
-
/* reassemble d-bits */
tf->d_bits[0] = 1;
for (i = 1, j = 4; i < 39; i++, j++)
@@ -1645,17 +1578,6 @@
* frames for call leg B, is to apply the TFO transform of TS 28.062 section
* C.3.2.1.1, then feed the output of that transform to the present function.
*
- * - The provision whereby a zero-length RTP payload is not treated as an error
- * like other invalid RTP inputs, but is converted to an idle speech frame
- * in TRAU-DL output should be considered a bogon. This condition never
- * occurs when the just-mentioned TFO transform is applied immediately prior
- * to TRAU-DL output, nor does it ever occur in the original GSM architecture
- * where the TRAU either free-runs a speech encoder or applies the same TFO
- * transform - hence it is unlikely to be handled well by real E1 BTSes.
- * Furthermore, this code path in libosmotrau is currently broken (the
- * intended idle speech frame gets turned into a "regular" but invalid FR/EFR
- * speech frame) and should be considered for removal.
- *
* Considerations for TRAU-UL output:
*
* - For FR and EFR codecs, the only correct RTP format for conversion to
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39624?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ia41ea2eab1ded094cadcd91dbd33de8800af11ee
Gerrit-Change-Number: 39624
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Attention is currently required from: laforge, pespin.
daniel has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39611?usp=email )
Change subject: vty: Add cmd to look up route
......................................................................
Patch Set 3: Code-Review+1
(1 comment)
File src/osmo_ss7_vty.c:
https://gerrit.osmocom.org/c/libosmo-sigtran/+/39611/comment/b7fef9bb_87df4… :
PS3, Line 570: pc = osmo_ss7_pointcode_parse(inst, argv[2]);
You don't really seem to do anything with the source PC except validate. I guess that's enough?
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39611?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I4dbe04862c018a1beea253de99404adb88bb7f4b
Gerrit-Change-Number: 39611
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 26 Feb 2025 11:15:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: pespin.
daniel has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39617?usp=email )
Change subject: vty: Improve route status display in show cs7 instance route
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39617?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I7f4ca56f9308803a306e7d6a3cde2faec27c3e7f
Gerrit-Change-Number: 39617
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 26 Feb 2025 10:59:51 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes