aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2014-04-06 14:39:23 +0200
committerHarald Welte <laforge@gnumonks.org>2015-09-22 16:41:30 +0200
commitdeb01a26528a0f61ae0e20a3b793db560d4c81dc (patch)
tree457f90488ce528362e8a3dfa07543563eff38d83
parent3cfc9d5fa34bf144c7390c9b6d9ce867b4e5c2e4 (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;
}