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>