add initializer function for subchan_demux
diff --git a/include/openbsc/subchan_demux.h b/include/openbsc/subchan_demux.h
index 024e94c..373cf4a 100644
--- a/include/openbsc/subchan_demux.h
+++ b/include/openbsc/subchan_demux.h
@@ -40,6 +40,7 @@
void *data;
};
+int subch_demux_init(struct subch_demux *dmx);
int subch_demux_in(struct subch_demux *dmx, u_int8_t *data, int len);
int subch_demux_activate(struct subch_demux *dmx, int subch);
int subch_demux_deactivate(struct subch_demux *dmx, int subch);
diff --git a/src/subchan_demux.c b/src/subchan_demux.c
index 34a5af0..da1b090 100644
--- a/src/subchan_demux.c
+++ b/src/subchan_demux.c
@@ -92,6 +92,19 @@
sch->out_idx = SYNC_HDR_BITS;
}
+int subch_demux_init(struct subch_demux *dmx)
+{
+ int i;
+
+ dmx->chan_activ = 0;
+ for (i = 0; i < NR_SUBCH; i++) {
+ struct subch *sch = &dmx->subch[i];
+ sch->out_idx = 0;
+ memset(sch->out_bitbuf, 0xff, sizeof(sch->out_bitbuf));
+ }
+ return 0;
+}
+
/* input some arbitrary (modulo 4) number of bytes of a 64k E1 channel,
* split it into the 16k subchannels */
int subch_demux_in(struct subch_demux *dmx, u_int8_t *data, int len)