/* 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) { int i, c; /* we avoid partially filled bytes in outbuf */ if (len % 4) return -EINVAL; for (i = 0; i < len; i++) { u_int8_t inbyte = data[i]; for (c = 0; c < NR_SUBCH; c++) { struct demux_subch *sch = &dmx->subch[c]; u_int8_t inbits; u_int8_t bit; /* ignore inactive subchannels */ if (!(dmx->chan_activ & (1 << c))) continue; inbits = inbyte >> (c << 1); /* two bits for each subchannel */ if (inbits & 0x01) bit = 1; else bit = 0; append_bit(sch, bit); if (sync_hdr_complete(sch, bit)) resync_to_here(sch); if (inbits & 0x02) bit = 1; else bit = 0; append_bit(sch, bit); if (sync_hdr_complete(sch, bit)) resync_to_here(sch); /* FIXME: verify the first bit in octet 2, 4, 6, ... * according to TS 08.60 4.8.1 */ /* once we have reached TRAU_FRAME_BITS, call * the TRAU frame handler callback function */ if (sch->out_idx >= TRAU_FRAME_BITS) { 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; } } } return i; }
error_type append(Si::iterator_range<element_type const *> data) { for (element_type value : data) { error_type error = append_bit(value); if (error) { return error; } } return error_type(); }