aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2014-04-06 14:39:23 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2014-04-06 14:39:23 +0200
commitd7a3b630b4f20905d3da7da80f9e895f103571ec (patch)
treed28330cbfbe8607b51c666eac9cb517c20c9eb67
parent5a8afc1957877aa2ce08283b30c4fdbceef02485 (diff)
TRX: Check if Transceiver indicates an out of range clock
If frame number is out of range (>= 2715648), the scheduler's process would end up in an infinite loop. This is because the loop would schedule bursts until the indicated frame number is reached, which would not be possible. The openbts, calypso-bts and osmo-trx might send out out of range clock indications every 3.5 hour.
-rw-r--r--src/osmo-bts-trx/trx_if.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index bc80150b..8993de64 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -123,21 +123,29 @@ static int trx_clk_read_cb(struct osmo_fd *ofd, unsigned int what)
{
char buf[1500];
int len;
+ uint32_t fn;
len = recv(ofd->fd, buf, sizeof(buf) - 1, 0);
if (len <= 0)
return len;
buf[len] = '\0';
- if (!strncmp(buf, "IND CLOCK ", 10)) {
- uint32_t fn;
-
- sscanf(buf, "IND CLOCK %u", &fn);
- LOGP(DTRX, LOGL_INFO, "Clock indication: fn=%u\n", fn);
- trx_sched_clock(fn);
- } else
+ if (!!strncmp(buf, "IND CLOCK ", 10)) {
LOGP(DTRX, LOGL_NOTICE, "Unknown message on clock port: %s\n",
buf);
+ return 0;
+ }
+
+ sscanf(buf, "IND CLOCK %u", &fn);
+ LOGP(DTRX, LOGL_INFO, "Clock indication: fn=%u\n", fn);
+
+ if (fn >= 2715648) {
+ fn %= 2715648;
+ LOGP(DTRX, LOGL_ERROR, "Indicated clock's FN is not wrapping "
+ "correctly, correcting to fn=%u\n", fn);
+ }
+
+ trx_sched_clock(fn);
return 0;
}