This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
osmith gerrit-no-reply at lists.osmocom.orgosmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/18021 )
Change subject: mobile: traffic req check: support EFR
......................................................................
mobile: traffic req check: support EFR
While at it, move to extra function and add a length check.
Related: SYS#4924
Change-Id: Iba84f5d60ff5b1a2db8fb6af5131e185965df7c9
---
M src/host/layer23/src/common/l1ctl.c
1 file changed, 37 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/21/18021/1
diff --git a/src/host/layer23/src/common/l1ctl.c b/src/host/layer23/src/common/l1ctl.c
index b7d0ecd..37a29e6 100644
--- a/src/host/layer23/src/common/l1ctl.c
+++ b/src/host/layer23/src/common/l1ctl.c
@@ -888,6 +888,42 @@
return 0;
}
+#define LOG_TRAFFIC_REQ(mode, level, fmt, args...) \
+ LOGP(DL1C, level, "Traffic Request, mode=%s: " fmt, get_value_string(gsm48_chan_mode_names, mode), ## args)
+
+int traffic_req_frame_verify(enum gsm48_chan_mode mode, uint8_t *frame, size_t frame_len)
+{
+ switch (mode) {
+ case GSM48_CMODE_SPEECH_V1:
+ /* FIXME: this is FR only, check for TCH/F (FR) and TCH/H (HR) */
+ /* RFC 3551, section 4.5.8 GSM */
+ if (frame_len != 13) {
+ LOG_TRAFFIC_REQ(mode, LOGL_ERROR, "incorrect length (%zu != 13)\n", frame_len);
+ return -2;
+ }
+ if ((frame[0] >> 4) != 0xd) {
+ LOG_TRAFFIC_REQ(mode, LOGL_ERROR, "incorrect magic (%u != 0xd)\n", frame[0] >> 4);
+ return -3;
+ }
+ break;
+ case GSM48_CMODE_SPEECH_EFR:
+ /* RFC 3551, section 4.5.9 GSM-EFR */
+ if (frame_len != 31) {
+ LOG_TRAFFIC_REQ(mode, LOGL_ERROR, "incorrect length (%zu != 31)\n", frame_len);
+ return -4;
+ }
+ if ((frame[0] >> 4) != 0xc) {
+ LOG_TRAFFIC_REQ(mode, LOGL_ERROR, "incorrect magic (%u != 0xc)\n", frame[0] >> 4);
+ return -5;
+ }
+ break;
+ default:
+ LOG_TRAFFIC_REQ(mode, LOGL_ERROR, "not implemented\n");
+ return -1;
+ }
+ return 0;
+}
+
/* Transmit L1CTL_TRAFFIC_REQ (Traffic Request to L1) */
int l1ctl_tx_traffic_req(struct osmocom_ms *ms, struct msgb *msg,
uint8_t chan_nr, uint8_t link_id)
@@ -909,9 +945,7 @@
DEBUGP(DL1C, "TRAFFIC REQ len=%zu (%s)\n", frame_len,
osmo_hexdump(frame, frame_len));
- if ((frame[0] >> 4) != 0xd) {
- LOGP(DL1C, LOGL_ERROR, "Traffic Request has incorrect magic "
- "(%u != 0xd)\n", frame[0] >> 4);
+ if (traffic_req_frame_verify(ms->rrlayer.cd_now.mode, frame, frame_len) < 0) {
msgb_free(msg);
return -EINVAL;
}
--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/18021
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Iba84f5d60ff5b1a2db8fb6af5131e185965df7c9
Gerrit-Change-Number: 18021
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200504/4a7c9bf3/attachment.htm>