dexter has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-bts/+/30725 )
Change subject: l1sap: Accept RFC5993 and TS 101.318 HR GSM payload
......................................................................
l1sap: Accept RFC5993 and TS 101.318 HR GSM payload
Unfotunately there are two different RTP formats for HR GSM specified
and it is unclear which should be used with GSM networks. Also esch BTS
model may have a preference for either one or the other format.
Lets set internal flags to determine the preference for each BTS model
and then lets use this information to convert incoming RTP packets into
the prefered format. Doing so we will make sure that always both formats
are accepted.
Change-Id: I17f0b546042fa333780fd2f5c315898ab0df574c
Related: OS#5688
---
M src/common/l1sap.c
M src/osmo-bts-lc15/main.c
M src/osmo-bts-oc2g/main.c
M src/osmo-bts-sysmo/main.c
M src/osmo-bts-trx/main.c
M src/osmo-bts-virtual/main.c
6 files changed, 66 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/25/30725/1
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 22b5e8c..410fb91 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -1253,6 +1253,35 @@
osmo_hexdump(resp_msg->data, resp_msg->len));
return false;
}
+
+ /* Avoid sending an incompatible HR GSM RTP format to lower layers. Two
+ * formats exist: ETSI TS 101.318 and RFC 5993. This check is only
+ * carried out when the BTS model explicitly states a preference. */
+ if (lchan->tch_mode == GSM48_CMODE_SPEECH_V1 && lchan->type ==
GSM_LCHAN_TCH_H) {
+ if (bts_internal_flag_get(lchan->ts->trx->bts,
BTS_INTERNAL_FLAG_SPEECH_H_V1_RFC5993)) {
+ if (resp_msg->len != GSM_HR_BYTES + 1) {
+ LOGPLCHAN(lchan, DL1P, LOGL_NOTICE,
+ "RTP->L1: Dropping unexpected HR GSM encoding (expected RFC 5993, got TS
101.318?) %s\n",
+ osmo_hexdump(resp_msg->data, resp_msg->len));
+ return false;
+ }
+ } else if (bts_internal_flag_get(lchan->ts->trx->bts,
BTS_INTERNAL_FLAG_SPEECH_H_V1_TS101318)) {
+ if (resp_msg->len != GSM_HR_BYTES) {
+ LOGPLCHAN(lchan, DL1P, LOGL_NOTICE,
+ "RTP->L1: Dropping unexpected HR GSM encoding (expected TS 101.318, got
RFC 5993?) %s\n",
+ osmo_hexdump(resp_msg->data, resp_msg->len));
+ return false;
+ }
+ } else {
+ /* NOTE: Each BTS model must specify which HR GSM RTP format it supports. Since
forwarding a
+ * random payload format might lead to unexpected effects and unreliable operation in
the field
+ * it is better to drop the payload early. */
+ LOGPLCHAN(lchan, DL1P, LOGL_ERROR,
+ "BTS model does not specify HR GSM RTP format (RFC5993 or ETSI TS 101.318?),
dropping payload!\n");
+ return false;
+ }
+ }
+
return true;
}
@@ -1888,10 +1917,37 @@
if (lchan->loopback)
return;
- msg = l1sap_msgb_alloc(rtp_pl_len);
- if (!msg)
- return;
- memcpy(msgb_put(msg, rtp_pl_len), rtp_pl, rtp_pl_len);
+ /* There are two different specifications that describe how HR GSM audio should be
encapsulated in RTP frames:
+ * RFC 5993 and ETSI TS 101.318 (TIPHON). In order to be able to accept both formats we
convert them on
+ * reception depending on what the particular BTS model supports. */
+ switch (lchan->tch_mode) {
+ case GSM48_CMODE_SPEECH_V1:
+ if (lchan->type == GSM_LCHAN_TCH_H && rtp_pl_len == GSM_HR_BYTES
+ && bts_internal_flag_get(lchan->ts->trx->bts,
BTS_INTERNAL_FLAG_SPEECH_H_V1_RFC5993)) {
+ msg = l1sap_msgb_alloc(rtp_pl_len + 1);
+ if (!msg)
+ return;
+ /* Note: The only difference between both formats is that RFC 5993 specifies an
additional one
+ * byte TOC header in front of the audio payload. (See also: RFC 5993, section 5.2)
*/
+ msgb_put_u8(msg, 0x00);
+ memcpy(msgb_put(msg, rtp_pl_len), rtp_pl, rtp_pl_len);
+ break;
+ } else if (lchan->type == GSM_LCHAN_TCH_H && rtp_pl_len == GSM_HR_BYTES + 1
+ && bts_internal_flag_get(lchan->ts->trx->bts,
BTS_INTERNAL_FLAG_SPEECH_H_V1_TS101318)) {
+ msg = l1sap_msgb_alloc(rtp_pl_len - 1);
+ if (!msg)
+ return;
+ memcpy(msgb_put(msg, rtp_pl_len - 1), rtp_pl + 1, rtp_pl_len - 1);
+ break;
+ }
+ /* fallthrough, no conversion required */
+ default:
+ msg = l1sap_msgb_alloc(rtp_pl_len);
+ if (!msg)
+ return;
+ memcpy(msgb_put(msg, rtp_pl_len), rtp_pl, rtp_pl_len);
+ }
+
msgb_pull(msg, sizeof(struct osmo_phsap_prim));
/* Store RTP header Marker bit in control buffer */
diff --git a/src/osmo-bts-lc15/main.c b/src/osmo-bts-lc15/main.c
index cb2a9ac..dd82f5e 100644
--- a/src/osmo-bts-lc15/main.c
+++ b/src/osmo-bts-lc15/main.c
@@ -113,6 +113,7 @@
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP);
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_NM_RCHANNEL_DEPENDS_RCARRIER);
+ bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_SPEECH_H_V1_TS101318);
return 0;
}
diff --git a/src/osmo-bts-oc2g/main.c b/src/osmo-bts-oc2g/main.c
index 4484d58..560c6c3 100644
--- a/src/osmo-bts-oc2g/main.c
+++ b/src/osmo-bts-oc2g/main.c
@@ -114,6 +114,7 @@
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP);
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_NM_RCHANNEL_DEPENDS_RCARRIER);
+ bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_SPEECH_H_V1_TS101318);
return 0;
}
diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c
index 95492eb..e2a9882 100644
--- a/src/osmo-bts-sysmo/main.c
+++ b/src/osmo-bts-sysmo/main.c
@@ -81,6 +81,7 @@
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_MEAS_PAYLOAD_COMB);
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_MS_PWR_CTRL_DSP);
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_NM_RCHANNEL_DEPENDS_RCARRIER);
+ bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_SPEECH_H_V1_TS101318);
return 0;
}
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index 4bd7f0f..19aaa8c 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -157,6 +157,7 @@
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_MEAS_PAYLOAD_COMB);
bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_INTERF_MEAS);
+ bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_SPEECH_H_V1_RFC5993);
return 0;
}
diff --git a/src/osmo-bts-virtual/main.c b/src/osmo-bts-virtual/main.c
index 20b480f..ad0d27e 100644
--- a/src/osmo-bts-virtual/main.c
+++ b/src/osmo-bts-virtual/main.c
@@ -71,6 +71,8 @@
osmo_bts_set_feature(bts->features, BTS_FEAT_SPEECH_H_AMR);
osmo_bts_set_feature(bts->features, BTS_FEAT_SPEECH_H_V1);
+ bts_internal_flag_set(bts, BTS_INTERNAL_FLAG_SPEECH_H_V1_RFC5993);
+
return 0;
}
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bts/+/30725
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I17f0b546042fa333780fd2f5c315898ab0df574c
Gerrit-Change-Number: 30725
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange