aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMychaela N. Falconia <falcon@freecalypso.org>2023-05-08 19:09:16 +0000
committerMychaela N. Falconia <falcon@freecalypso.org>2023-05-08 19:09:16 +0000
commit5755946beb6d129b00c02d1d29c18463558427b1 (patch)
treea3bbdb75e15339296f0a8fd1720bc6bb580cd2f6
parent8b306b6f93bcbabb46ed3b6faeff6bbaee45dbf7 (diff)
RTP input, FR & EFR: preen incoming payloads for SID errors
Those network elements which receive a stream of codec frames that may come from the uplink of GSM call A and which are responsible for preparing the frame stream for the downlink of GSM call B (such as OsmoBTS receiving RTP and feeding DL to its PHY) must be prepared for the possibility that their incoming frame stream may contain corrupted SID frames, presumably from bit errors on radio link A. Per the rules of section 6.1.1 of GSM 06.31 for FR and GSM 06.81 for EFR, SID frames with just one errored bit are still to be accepted as valid, whereas frames with more corrupted bits which are still recognizable as SID are classified as invalid SID. In the case of a TrFO call, the entity switching from leg A UL to leg B DL is responsible for *not* transmitting invalid SID frames on the destination leg (they should be treated like BFIs), and any deemed-valid SID frames that are forwarded should be preened, correcting that one bit error they may exhibit. Implement this functionality in OsmoBTS. Change-Id: I89df2f12c49dd5378667cf149d19bde654f80134
-rw-r--r--src/common/l1sap.c49
-rw-r--r--src/osmo-bts-omldummy/Makefile.am1
2 files changed, 41 insertions, 9 deletions
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index a7eb8308..f24bc2f7 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -37,6 +37,8 @@
#include <osmocom/core/gsmtap_util.h>
#include <osmocom/core/utils.h>
+#include <osmocom/codec/codec.h>
+
#include <osmocom/trau/osmo_ortp.h>
#include <osmo-bts/logging.h>
@@ -1241,6 +1243,24 @@ static bool rtppayload_is_octet_aligned(const uint8_t *rtp_pl, uint8_t payload_l
return true;
}
+static bool rtppayload_validate_fr(struct msgb *msg)
+{
+ if (msg->len != GSM_FR_BYTES)
+ return false;
+ if ((msg->data[0] & 0xF0) != 0xD0)
+ return false;
+ return osmo_fr_sid_preen(msg->data);
+}
+
+static bool rtppayload_validate_efr(struct msgb *msg)
+{
+ if (msg->len != GSM_EFR_BYTES)
+ return false;
+ if ((msg->data[0] & 0xF0) != 0xC0)
+ return false;
+ return osmo_efr_sid_preen(msg->data);
+}
+
static bool rtppayload_is_valid(struct gsm_lchan *lchan, struct msgb *resp_msg)
{
/* If rtp continuous-streaming is enabled, we shall emit RTP packets
@@ -1255,16 +1275,27 @@ static bool rtppayload_is_valid(struct gsm_lchan *lchan, struct msgb *resp_msg)
if (resp_msg->len == 0)
return false;
- /* Avoid forwarding bw-efficient AMR to lower layers, most bts models
- * don't support it. */
- if (lchan->tch_mode == GSM48_CMODE_SPEECH_AMR &&
- !rtppayload_is_octet_aligned(resp_msg->data, resp_msg->len)) {
- LOGPLCHAN(lchan, DL1P, LOGL_NOTICE,
- "RTP->L1: Dropping unexpected AMR encoding (bw-efficient?) %s\n",
- osmo_hexdump(resp_msg->data, resp_msg->len));
- return false;
+ switch (lchan->tch_mode) {
+ case GSM48_CMODE_SPEECH_V1:
+ if (lchan->type == GSM_LCHAN_TCH_F)
+ return rtppayload_validate_fr(resp_msg);
+ else
+ return true; /* FIXME: implement preening for HR1 */
+ case GSM48_CMODE_SPEECH_EFR:
+ return rtppayload_validate_efr(resp_msg);
+ case GSM48_CMODE_SPEECH_AMR:
+ /* Avoid forwarding bw-efficient AMR to lower layers,
+ * most bts models don't support it. */
+ if (!rtppayload_is_octet_aligned(resp_msg->data, resp_msg->len)) {
+ LOGPLCHAN(lchan, DL1P, LOGL_NOTICE,
+ "RTP->L1: Dropping unexpected AMR encoding (bw-efficient?) %s\n",
+ osmo_hexdump(resp_msg->data, resp_msg->len));
+ return false;
+ }
+ return true;
+ default:
+ return true;
}
- return true;
}
/* TCH-RTS-IND prim received from bts model */
diff --git a/src/osmo-bts-omldummy/Makefile.am b/src/osmo-bts-omldummy/Makefile.am
index 81da29b6..f7a05047 100644
--- a/src/osmo-bts-omldummy/Makefile.am
+++ b/src/osmo-bts-omldummy/Makefile.am
@@ -20,6 +20,7 @@ COMMON_LDADD = \
$(LIBOSMOABIS_LIBS) \
$(LIBOSMOTRAU_LIBS) \
$(LIBOSMONETIF_LIBS) \
+ $(LIBOSMOCODEC_LIBS) \
-ldl \
$(NULL)