aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2009-02-19 17:05:13 +0000
committerHarald Welte <laforge@gnumonks.org>2009-02-19 17:05:13 +0000
commitf1e6f966542b4954308d3a5986d3d8c50ac6a90c (patch)
treea1420dd4ca6d6bbb644d96290d5b023788c18bc9
parent26aa6a1166f2593e93f926285a5a5476a9724195 (diff)
don't pass subchannel data to the TRAU decoder if we're not synchronized yet
-rw-r--r--include/openbsc/subchan_demux.h3
-rw-r--r--src/subchan_demux.c6
2 files changed, 8 insertions, 1 deletions
diff --git a/include/openbsc/subchan_demux.h b/include/openbsc/subchan_demux.h
index a5c5d8ea4..9661b0481 100644
--- a/include/openbsc/subchan_demux.h
+++ b/include/openbsc/subchan_demux.h
@@ -35,7 +35,10 @@
struct demux_subch {
u_int8_t out_bitbuf[TRAU_FRAME_BITS];
u_int16_t out_idx; /* next bit to be written in out_bitbuf */
+ /* number of consecutive zeros that we have received (for sync) */
unsigned int consecutive_zeros;
+ /* are we in TRAU frame sync or not? */
+ unsigned int in_sync;
};
struct subch_demux {
diff --git a/src/subchan_demux.c b/src/subchan_demux.c
index 86ddc86cd..c6b9a67e4 100644
--- a/src/subchan_demux.c
+++ b/src/subchan_demux.c
@@ -62,6 +62,7 @@ static void resync_to_here(struct demux_subch *sch)
/* set index in a way that we can continue receiving bits after
* the end of the SYNC header */
sch->out_idx = SYNC_HDR_BITS;
+ sch->in_sync = 1;
}
int subch_demux_init(struct subch_demux *dmx)
@@ -126,8 +127,11 @@ int subch_demux_in(struct subch_demux *dmx, u_int8_t *data, int len)
/* once we have reached TRAU_FRAME_BITS, call
* the TRAU frame handler callback function */
if (sch->out_idx >= TRAU_FRAME_BITS) {
- dmx->out_cb(dmx, c, sch->out_bitbuf,
+ if (sch->in_sync) {
+ dmx->out_cb(dmx, c, sch->out_bitbuf,
sch->out_idx, dmx->data);
+ sch->in_sync = 0;
+ }
sch->out_idx = 0;
}
}