aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-trx/trx_if.c
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-04-14 21:32:56 +0200
committerlaforge <laforge@osmocom.org>2021-04-24 08:47:00 +0000
commit974bf725a4f88578dca79b67fb983d2058f2ae1d (patch)
tree4aecfff68966e6bf70222bc6bc2d3cb5d63116b1 /src/osmo-bts-trx/trx_if.c
parent16c299806931172256c99c1d08c8c28c229dd29e (diff)
osmo-bts-trx: discard TRXD PDUs with unexpected version
Diffstat (limited to 'src/osmo-bts-trx/trx_if.c')
-rw-r--r--src/osmo-bts-trx/trx_if.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index 912ab422..5ce18891 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -945,8 +945,18 @@ static int trx_data_read_cb(struct osmo_fd *ofd, unsigned int what)
/* Pre-clean (initialize) the flags */
bi.flags = 0x00;
- /* Parse header depending on the PDU version */
+ /* Parse PDU version first */
pdu_ver = buf[0] >> 4;
+
+ /* Make sure that PDU version matches our expectations */
+ if (pdu_ver != l1h->config.trxd_pdu_ver_use) {
+ LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,
+ "Rx TRXD PDU with unexpected version %u (expected %u)\n",
+ pdu_ver, l1h->config.trxd_pdu_ver_use);
+ return -EIO;
+ }
+
+ /* Parse header depending on the PDU version */
switch (pdu_ver) {
case 0:
/* Legacy protocol has no version indicator */
@@ -956,9 +966,8 @@ static int trx_data_read_cb(struct osmo_fd *ofd, unsigned int what)
hdr_len = trx_data_handle_hdr_v1(l1h, &bi, buf, buf_len);
break;
default:
- LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,
- "TRXD PDU version %u is not supported\n", pdu_ver);
- return -ENOTSUP;
+ /* Shall not happen */
+ OSMO_ASSERT(0);
}
/* Header parsing error */