aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-trx/trx_if.c
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2014-04-06 14:39:23 +0200
committerHarald Welte <laforge@gnumonks.org>2015-09-06 14:48:31 +0200
commit67323c43e677d77ad052ac9643c82a1586fe9e3e (patch)
tree8eb39c4752be1f6fc6c183c33bd4139b213ba7c2 /src/osmo-bts-trx/trx_if.c
parentb212c019faa4af2ef8d91e731b755d339fd37163 (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.
Diffstat (limited to 'src/osmo-bts-trx/trx_if.c')
-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;
}