laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/33081 )
Change subject: HR1 codec: validate ToC header in RFC5993 RTP input
......................................................................
HR1 codec: validate ToC header in RFC5993 RTP input
osmo-bts-trx always accepted (and previously required) HR1 codec RTP
input in RFC 5993 format; currently we accept this RTP format as
input for all BTS models, but no longer require it. However, we
have never applied any checks to this format's ToC header, even
when we previously required it in osmo-bts-trx. Check this header
and reject invalid payloads that just happen to have the same octet
length as valid ones.
Change-Id: If16d38641913bb46bcd7cc11685407ed17136bfe
---
M src/common/rtp_input_preen.c
1 file changed, 31 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/src/common/rtp_input_preen.c b/src/common/rtp_input_preen.c
index e5cef6f..dd526fd 100644
--- a/src/common/rtp_input_preen.c
+++ b/src/common/rtp_input_preen.c
@@ -89,6 +89,20 @@
/* RTP input matches our internal format - we are good */
return PL_DECISION_ACCEPT;
case GSM_HR_BYTES_RTP_RFC5993:
+ /* Validate ToC octet: for payload of this length to be valid,
+ * the F bit must be 0 and the FT field must be either 0 (good
+ * speech) or 2 (good SID). */
+ switch (rtp_pl[0] & 0xF0) {
+ case 0x00:
+ break;
+ case 0x20:
+ /* TODO (next patch): signal this SID to the
+ * fr_hr_efr_dtxd_input() handler in l1sap. */
+ break;
+ default:
+ /* invalid payload */
+ return PL_DECISION_DROP;
+ }
/* Strip ToC octet, leaving only "pure" TS 101 318 payload. */
return PL_DECISION_STRIP_HDR_OCTET;
default:
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/33081
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: If16d38641913bb46bcd7cc11685407ed17136bfe
Gerrit-Change-Number: 33081
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/33082 )
Change subject: HR1 codec: act on SID indication in RFC5993 RTP input
......................................................................
HR1 codec: act on SID indication in RFC5993 RTP input
Suppose we receive RTP from the uplink of another BTS, and the
UL-handling BTS has channel-decoded an HR1 frame which it deems
(per GSM 06.41 section 6.1.1) to be a valid SID, even though it is
not a perfect, error-free SID. How will this SID frame be
represented in RFC 5993 transport? My reading of the RFC tells me
that the UL-handling BTS will need to apply an operation like our
osmo_hr_sid_reset() to the payload before sending it out in RTP -
but because the text of the RFC does not explicitly address this
scenario, others may have interpreted it differently.
If we receive an RFC 5993 RTP payload in which FT is set to 2,
indicating good SID, but the actual HR payload is not a perfect SID
(the SID field is not all 1s), the only reasonable interpretation
of such occurrence is that the sender of this payload was another
BTS whose implementors interpreted the RFC as not requiring them
to rejuvenate the SID codeword prior to RTP output. Therefore, let's
treat such payloads as valid SID for our DTXd logic, and rejuvenate
the SID codeword ourselves.
Change-Id: Ife00de6220a8ca7cc180a61734497f1acb7f5b83
---
M include/osmo-bts/msg_utils.h
M include/osmo-bts/rtp_input_preen.h
M src/common/l1sap.c
M src/common/rtp_input_preen.c
4 files changed, 52 insertions(+), 10 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/include/osmo-bts/msg_utils.h b/include/osmo-bts/msg_utils.h
index 7ddbe88..fb8e11a 100644
--- a/include/osmo-bts/msg_utils.h
+++ b/include/osmo-bts/msg_utils.h
@@ -22,6 +22,9 @@
/* Access 3rd part of msgb control buffer */
#define rtpmsg_ts(x) ((x)->cb[2])
+/* Access 4th part of msgb control buffer */
+#define rtpmsg_is_rfc5993_sid(x) ((x)->cb[3])
+
/**
* Classification of OML message. ETSI for plain GSM 12.21
* messages and IPA/Osmo for manufacturer messages.
diff --git a/include/osmo-bts/rtp_input_preen.h b/include/osmo-bts/rtp_input_preen.h
index 822ee4a..744ae2a 100644
--- a/include/osmo-bts/rtp_input_preen.h
+++ b/include/osmo-bts/rtp_input_preen.h
@@ -17,4 +17,4 @@
enum pl_input_decision
rtp_payload_input_preen(struct gsm_lchan *lchan, const uint8_t *rtp_pl,
- unsigned rtp_pl_len);
+ unsigned rtp_pl_len, bool *rfc5993_sid_flag);
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 75177a5..9d824e3 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -1314,9 +1314,17 @@
* directly coupled to the GSM 05.03 channel decoder,
* and cannot be reconstructed downstream from frame
* payload bits. The only kind of SID we can detect
- * here is the perfect, error-free kind. */
- is_sid = osmo_hr_check_sid(msgb_l2(resp_msg),
- msgb_l2len(resp_msg));
+ * here is the perfect, error-free kind. However,
+ * if we received RFC 5993 payload and the sender
+ * told us it is valid SID, honor that indication
+ * and rejuvenate the SID codeword. */
+ if (rtpmsg_is_rfc5993_sid(resp_msg)) {
+ is_sid = true;
+ osmo_hr_sid_reset(msgb_l2(resp_msg));
+ } else {
+ is_sid = osmo_hr_check_sid(msgb_l2(resp_msg),
+ msgb_l2len(resp_msg));
+ }
}
break;
case GSM48_CMODE_SPEECH_EFR:
@@ -2152,6 +2160,7 @@
{
struct gsm_lchan *lchan = rs->priv;
struct msgb *msg;
+ bool rfc5993_sid = false;
/* if we're in loopback mode, we don't accept frames from the
* RTP socket anymore */
@@ -2159,7 +2168,7 @@
return;
/* initial preen */
- switch (rtp_payload_input_preen(lchan, rtp_pl, rtp_pl_len)) {
+ switch (rtp_payload_input_preen(lchan, rtp_pl, rtp_pl_len, &rfc5993_sid)) {
case PL_DECISION_DROP:
return;
case PL_DECISION_ACCEPT:
@@ -2184,6 +2193,8 @@
rtpmsg_seq(msg) = seq_number;
/* Store RTP header Timestamp in control buffer */
rtpmsg_ts(msg) = timestamp;
+ /* Store RFC 5993 SID flag likewise */
+ rtpmsg_is_rfc5993_sid(msg) = rfc5993_sid;
/* make sure the queue doesn't get too long */
lchan_dl_tch_queue_enqueue(lchan, msg, 1);
diff --git a/src/common/rtp_input_preen.c b/src/common/rtp_input_preen.c
index dd526fd..c418e80 100644
--- a/src/common/rtp_input_preen.c
+++ b/src/common/rtp_input_preen.c
@@ -82,7 +82,8 @@
}
static enum pl_input_decision
-input_preen_hr(const uint8_t *rtp_pl, unsigned rtp_pl_len)
+input_preen_hr(const uint8_t *rtp_pl, unsigned rtp_pl_len,
+ bool *rfc5993_sid_flag)
{
switch (rtp_pl_len) {
case GSM_HR_BYTES:
@@ -96,8 +97,7 @@
case 0x00:
break;
case 0x20:
- /* TODO (next patch): signal this SID to the
- * fr_hr_efr_dtxd_input() handler in l1sap. */
+ *rfc5993_sid_flag = true;
break;
default:
/* invalid payload */
@@ -113,7 +113,7 @@
enum pl_input_decision
rtp_payload_input_preen(struct gsm_lchan *lchan, const uint8_t *rtp_pl,
- unsigned rtp_pl_len)
+ unsigned rtp_pl_len, bool *rfc5993_sid_flag)
{
/* If rtp continuous-streaming is enabled, we shall emit RTP packets
* with zero-length payloads as BFI markers. In a TrFO scenario such
@@ -132,7 +132,7 @@
if (lchan->type == GSM_LCHAN_TCH_F)
return input_preen_fr(rtp_pl, rtp_pl_len);
else
- return input_preen_hr(rtp_pl, rtp_pl_len);
+ return input_preen_hr(rtp_pl, rtp_pl_len, rfc5993_sid_flag);
case GSM48_CMODE_SPEECH_EFR:
return input_preen_efr(rtp_pl, rtp_pl_len);
case GSM48_CMODE_SPEECH_AMR:
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/33082
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ife00de6220a8ca7cc180a61734497f1acb7f5b83
Gerrit-Change-Number: 33082
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/32907 )
Change subject: stream: Add IPA send function/IPA-mode read to srv
......................................................................
Patch Set 3:
(2 comments)
File include/osmocom/netif/stream.h:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-7605):
https://gerrit.osmocom.org/c/libosmo-netif/+/32907/comment/dabb1e4f_0b198775
PS3, Line 75: enum ipaccess_proto_ext pe, struct msgb *msg);
code indent should use tabs where possible
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-7605):
https://gerrit.osmocom.org/c/libosmo-netif/+/32907/comment/92640130_f8d9df08
PS3, Line 75: enum ipaccess_proto_ext pe, struct msgb *msg);
please, no spaces at the start of a line
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/32907
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: arehbein/osmo_io_ipa
Gerrit-Change-Id: I61e1fe59166c46595efe8c1f32b8f2607cb6c529
Gerrit-Change-Number: 32907
Gerrit-PatchSet: 3
Gerrit-Owner: arehbein <arehbein(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 30 May 2023 10:56:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
arehbein has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/32974 )
Change subject: stream: Move helper functions
......................................................................
stream: Move helper functions
Prepare for next commits
Change-Id: I318965538e5329c44d0910694621b5e1f1db0626
---
M src/stream.c
1 file changed, 32 insertions(+), 21 deletions(-)
diff --git a/src/stream.c b/src/stream.c
index 150b85f..d1682c2 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -1184,6 +1184,27 @@
osmo_stream_cli_open(cli);
}
+/* msgb_l1(msg) is expected to be set */
+static inline enum ipaccess_proto msg_get_ipa_proto(struct msgb *msg)
+{
+ struct ipa_head *ih = msgb_l1(msg);
+ OSMO_ASSERT(ih);
+ return ih->proto;
+}
+
+/* msgb->l1h is expected to be set, msgb->l2h is expected to be set if
+ * we have IPAC_PROTO_OSMO specified in the header.
+ * Returns the protocol extension (enum ipaccess_proto) or -ENOPROTOOPT if
+ * we don't have IPAC_PROTO_OSMO specified in the IPA header */
+static inline int msg_get_ipa_proto_ext(struct msgb *msg)
+{
+ if (msg_get_ipa_proto(msg) != IPAC_PROTO_OSMO)
+ return -ENOPROTOOPT;
+ struct ipa_head_ext *ihe = msgb_l2(msg);
+ OSMO_ASSERT(ihe);
+ return ihe->proto;
+}
+
/*! \brief Enqueue data to be sent via an Osmocom stream client
* \param[in] cli Stream Client through which we want to send
* \param[in] msg Message buffer to enqueue in transmit queue */
@@ -1937,27 +1958,6 @@
talloc_free(conn);
}
-/* msgb_l1(msg) is expected to be set */
-static inline enum ipaccess_proto msg_get_ipa_proto(struct msgb *msg)
-{
- struct ipa_head *ih = msgb_l1(msg);
- OSMO_ASSERT(ih);
- return ih->proto;
-}
-
-/* msgb->l1h is expected to be set, msgb->l2h is expected to be set if
- * we have IPAC_PROTO_OSMO specified in the header.
- * Returns the protocol extension (enum ipaccess_proto) or -ENOPROTOOPT if
- * we don't have IPAC_PROTO_OSMO specified in the IPA header */
-static inline int msg_get_ipa_proto_ext(struct msgb *msg)
-{
- if (msg_get_ipa_proto(msg) != IPAC_PROTO_OSMO)
- return -ENOPROTOOPT;
- struct ipa_head_ext *ihe = msgb_l2(msg);
- OSMO_ASSERT(ihe);
- return ihe->proto;
-}
-
/*! \brief Enqueue IPA data to be sent via an Osmocom stream server
* \param[in] conn Stream Server through which we want to send
* \param[in] p Protocol transported by IPA. When set to IPAC_PROTO_UNSPECIFIED, the protocol will be
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/32974
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: arehbein/osmo_io_ipa
Gerrit-Change-Id: I318965538e5329c44d0910694621b5e1f1db0626
Gerrit-Change-Number: 32974
Gerrit-PatchSet: 2
Gerrit-Owner: arehbein <arehbein(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: merged