Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-28 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/18247 )

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..

Implement ITU-T I.460 multiplex / demultiplex

This implements a multiplexer and de-multiplexer for the ITU-T I.460
standard.  The latter covers the transmission of sub-slots of 32/16/8k
inside 64k timeslots.

Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
---
M include/Makefile.am
A include/osmocom/gsm/i460_mux.h
M src/gsm/Makefile.am
A src/gsm/i460_mux.c
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/i460_mux/i460_mux_test.c
A tests/i460_mux/i460_mux_test.ok
M tests/testsuite.at
9 files changed, 999 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  tnt: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/include/Makefile.am b/include/Makefile.am
index 572c880..456b8ef 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -103,6 +103,7 @@
osmocom/gsm/gsm_utils.h \
osmocom/gsm/gsup.h \
osmocom/gsm/gsup_sms.h \
+   osmocom/gsm/i460_mux.h \
osmocom/gsm/ipa.h \
osmocom/gsm/lapd_core.h \
osmocom/gsm/lapdm.h \
diff --git a/include/osmocom/gsm/i460_mux.h b/include/osmocom/gsm/i460_mux.h
new file mode 100644
index 000..2e33b37
--- /dev/null
+++ b/include/osmocom/gsm/i460_mux.h
@@ -0,0 +1,104 @@
+/*! \file i460_mux.h
+ * ITU-T I.460 sub-channel multiplexer + demultiplexer */
+/*
+ * (C) 2020 by Harald Welte 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *  MA  02110-1301, USA.
+ */
+
+#pragma once
+#include 
+#include 
+#include 
+#include 
+
+/* I.460 sub-slot rate */
+enum osmo_i460_rate {
+   OSMO_I460_RATE_NONE,/* disabled */
+   OSMO_I460_RATE_64k,
+   OSMO_I460_RATE_32k,
+   OSMO_I460_RATE_16k,
+   OSMO_I460_RATE_8k,
+};
+
+typedef void (*out_cb_bits_t)(void *user_data, const ubit_t *bits, unsigned 
int num_bits);
+typedef void (*out_cb_bytes_t)(void *user_data, const uint8_t *bytes, unsigned 
int num_bytes);
+
+struct osmo_i460_subchan_demux {
+   /*! bit-buffer for output bits */
+   uint8_t *out_bitbuf;
+   /*! size of out_bitbuf in bytes */
+   unsigned int out_bitbuf_size;
+   /*! offset of next bit to be written in out_bitbuf */
+   unsigned int out_idx;
+   /*! callback to be called once we have received out_bitbuf_size bits */
+   out_cb_bits_t out_cb_bits;
+   out_cb_bytes_t out_cb_bytes;
+   void *user_data;
+};
+
+struct osmo_i460_subchan_mux {
+   /*! list of to-be-transmitted message buffers */
+   struct llist_head tx_queue;
+};
+
+struct osmo_i460_subchan {
+   enum osmo_i460_rate rate;   /* 8/16/32/64k */
+   uint8_t bit_offset; /* bit offset inside each byte of the 
B-channel */
+   struct osmo_i460_subchan_demux demux;
+   struct osmo_i460_subchan_mux mux;
+};
+
+struct osmo_i460_timeslot {
+   struct osmo_i460_subchan schan[8];
+};
+
+/*! description of a sub-channel; passed by caller */
+struct osmo_i460_schan_desc {
+   enum osmo_i460_rate rate;
+   uint8_t bit_offset;
+   struct {
+   /* size (in bits) of the internal buffer; determines 
granularity */
+   size_t num_bits;
+   /*! call-back function called whenever we received num_bits */
+   out_cb_bits_t out_cb_bits;
+   /*! out_cb_bytes call-back function called whenever we received 
num_bits.
+* The user is usually expected to provide either out_cb_bits 
or out_cb_bytes.  If only
+* out_cb_bits is provided, output data will always be provided 
as unpacked bits;  if only
+* out_cb_bytes is provided, output data will always be 
provided as packet bits (bytes).  If
+* both are provided, it is up to the I.460 multiplex to decide 
if it calls either of the two,
+* depending on what can be provided without extra conversion. 
*/
+   out_cb_bytes_t out_cb_bytes;
+   

Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-28 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/18247 )

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..


Patch Set 10: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 10
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: tnt 
Gerrit-Comment-Date: Thu, 28 May 2020 13:08:49 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-21 Thread tnt
tnt has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/18247 )

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..


Patch Set 10: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 10
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: tnt 
Gerrit-Comment-Date: Thu, 21 May 2020 16:33:01 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-21 Thread laforge
Hello tnt, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/18247

to look at the new patch set (#10).

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..

Implement ITU-T I.460 multiplex / demultiplex

This implements a multiplexer and de-multiplexer for the ITU-T I.460
standard.  The latter covers the transmission of sub-slots of 32/16/8k
inside 64k timeslots.

Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
---
M include/Makefile.am
A include/osmocom/gsm/i460_mux.h
M src/gsm/Makefile.am
A src/gsm/i460_mux.c
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/i460_mux/i460_mux_test.c
A tests/i460_mux/i460_mux_test.ok
M tests/testsuite.at
9 files changed, 999 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/47/18247/10
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 10
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: tnt 
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-21 Thread tnt
tnt has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/18247 )

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..


Patch Set 9: Code-Review+1

(1 comment)

lgtm !

https://gerrit.osmocom.org/c/libosmocore/+/18247/7/tests/i460_mux/i460_mux_test.c
File tests/i460_mux/i460_mux_test.c:

https://gerrit.osmocom.org/c/libosmocore/+/18247/7/tests/i460_mux/i460_mux_test.c@179
PS7, Line 179:  /* pull byteso out of mux (should be all 0xff) */
typo



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 9
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Reviewer: tnt 
Gerrit-Comment-Date: Thu, 21 May 2020 06:37:45 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/18247 )

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..


Patch Set 9:

(1 comment)

https://gerrit.osmocom.org/c/libosmocore/+/18247/5/src/gsm/i460_mux.c
File src/gsm/i460_mux.c:

https://gerrit.osmocom.org/c/libosmocore/+/18247/5/src/gsm/i460_mux.c@208
PS5, Line 208: static uint8_t mux_timeslot_provide_bits(struct 
osmo_i460_timeslot *ts)
> According to the specs, any bits that's not used by a subchannel should be 
> set to 1. […]
Done



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 9
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-CC: tnt 
Gerrit-Comment-Date: Thu, 21 May 2020 06:24:05 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: tnt 
Gerrit-MessageType: comment


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-21 Thread laforge
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/18247

to look at the new patch set (#9).

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..

Implement ITU-T I.460 multiplex / demultiplex

This implements a multiplexer and de-multiplexer for the ITU-T I.460
standard.  The latter covers the transmission of sub-slots of 32/16/8k
inside 64k timeslots.

Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
---
M include/Makefile.am
A include/osmocom/gsm/i460_mux.h
M src/gsm/Makefile.am
A src/gsm/i460_mux.c
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/i460_mux/i460_mux_test.c
A tests/i460_mux/i460_mux_test.ok
M tests/testsuite.at
9 files changed, 951 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/47/18247/9
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 9
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: tnt 
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-20 Thread laforge
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/18247

to look at the new patch set (#8).

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..

Implement ITU-T I.460 multiplex / demultiplex

This implements a multiplexer and de-multiplexer for the ITU-T I.460
standard.  The latter covers the transmission of sub-slots of 32/16/8k
inside 64k timeslots.

Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
---
M include/Makefile.am
A include/osmocom/gsm/i460_mux.h
M src/gsm/Makefile.am
A src/gsm/i460_mux.c
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/i460_mux/i460_mux_test.c
A tests/i460_mux/i460_mux_test.ok
M tests/testsuite.at
9 files changed, 909 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/47/18247/8
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 8
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: tnt 
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-14 Thread tnt
tnt has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/18247 )

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..


Patch Set 5:

(1 comment)

https://gerrit.osmocom.org/c/libosmocore/+/18247/5/src/gsm/i460_mux.c
File src/gsm/i460_mux.c:

https://gerrit.osmocom.org/c/libosmocore/+/18247/5/src/gsm/i460_mux.c@208
PS5, Line 208: static uint8_t mux_timeslot_provide_bits(struct 
osmo_i460_timeslot *ts)
According to the specs, any bits that's not used by a subchannel should be set 
to 1.
This doesn't do that AFAICT.



--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 5
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: tnt 
Gerrit-Comment-Date: Thu, 14 May 2020 11:05:57 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-14 Thread laforge
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/18247

to look at the new patch set (#4).

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..

Implement ITU-T I.460 multiplex / demultiplex

This implements a multiplexer and de-multiplexer for the ITU-T I.460
standard.  The latter covers the transmission of sub-slots of 32/16/8k
inside 64k timeslots.

Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
---
M include/Makefile.am
A include/osmocom/gsm/i460_mux.h
M src/gsm/Makefile.am
A src/gsm/i460_mux.c
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/i460_mux/i460_mux_test.c
A tests/i460_mux/i460_mux_test.ok
M tests/testsuite.at
9 files changed, 898 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/47/18247/4
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 4
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-14 Thread laforge
laforge has uploaded a new patch set (#3). ( 
https://gerrit.osmocom.org/c/libosmocore/+/18247 )

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..

Implement ITU-T I.460 multiplex / demultiplex

This implements a multiplexer and de-multiplexer for the ITU-T I.460
standard.  The latter covers the transmission of sub-slots of 32/16/8k
inside 64k timeslots.

Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
---
M include/Makefile.am
A include/osmocom/gsm/i460_mux.h
M src/gsm/Makefile.am
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/i460_mux/i460_mux_test.c
A tests/i460_mux/i460_mux_test.ok
M tests/testsuite.at
8 files changed, 568 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/47/18247/3
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-14 Thread laforge
laforge has uploaded a new patch set (#2). ( 
https://gerrit.osmocom.org/c/libosmocore/+/18247 )

Change subject: Implement ITU-T I.460 multiplex / demultiplex
..

Implement ITU-T I.460 multiplex / demultiplex

This implements a multiplexer and de-multiplexer for the ITU-T I.460
standard.  The latter covers the transmission of sub-slots of 32/16/8k
inside 64k timeslots.

Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
---
M include/Makefile.am
A include/osmocom/gsm/i460_mux.h
M src/gsm/Makefile.am
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/i460_mux/i460_mux_test.c
A tests/i460_mux/i460_mux_test.ok
M tests/testsuite.at
8 files changed, 568 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/47/18247/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/18247
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
Gerrit-Change-Number: 18247
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: Implement ITU-T I.460 multiplex / demultiplex

2020-05-14 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/18247 )


Change subject: Implement ITU-T I.460 multiplex / demultiplex
..

Implement ITU-T I.460 multiplex / demultiplex

This implements a multiplexer and de-multiplexer for the ITU-T I.460
standard.  The latter covers the transmission of sub-slots of 32/16/8k
inside 64k timeslots.

Change-Id: Id522f06e73b77332b437b7a27e4966872da70eda
---
M include/Makefile.am
A include/osmocom/gsm/i460_mux.h
M src/gsm/Makefile.am
M src/gsm/libosmogsm.map
4 files changed, 88 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/47/18247/1

diff --git a/include/Makefile.am b/include/Makefile.am
index 572c880..456b8ef 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -103,6 +103,7 @@
osmocom/gsm/gsm_utils.h \
osmocom/gsm/gsup.h \
osmocom/gsm/gsup_sms.h \
+   osmocom/gsm/i460_mux.h \
osmocom/gsm/ipa.h \
osmocom/gsm/lapd_core.h \
osmocom/gsm/lapdm.h \
diff --git a/include/osmocom/gsm/i460_mux.h b/include/osmocom/gsm/i460_mux.h
new file mode 100644
index 000..759e392
--- /dev/null
+++ b/include/osmocom/gsm/i460_mux.h
@@ -0,0 +1,79 @@
+#pragma once
+#include 
+#include 
+#include 
+#include 
+
+/* I.460 sub-slot rate */
+enum osmo_i460_rate {
+   OSMO_I460_RATE_NONE,/* disabled */
+   OSMO_I460_RATE_64k,
+   OSMO_I460_RATE_32k,
+   OSMO_I460_RATE_16k,
+   OSMO_I460_RATE_8k,
+};
+
+typedef void (*out_cb_bits_t)(void *user_data, const ubit_t *bits, unsigned 
int num_bits);
+typedef void (*out_cb_bytes_t)(void *user_data, const uint8_t *bytes, unsigned 
int num_bytes);
+
+struct osmo_i460_subchan_demux {
+   /*! bit-buffer for output bits */
+   uint8_t *out_bitbuf;
+   /*! size of out_bitbuf in bytes */
+   unsigned int out_bitbuf_size;
+   /*! offset of next bit to be written in out_bitbuf */
+   unsigned int out_idx;
+   /*! callback to be called once we have received out_bitbuf_size bits */
+   out_cb_bits_t out_cb_bits;
+   out_cb_bytes_t out_cb_bytes;
+   void *user_data;
+};
+
+struct osmo_i460_subchan_mux {
+   /*! list of to-be-transmitted message buffers */
+   struct llist_head tx_queue;
+};
+
+struct osmo_i460_subchan {
+   enum osmo_i460_rate rate;   /* 8/16/32/64k */
+   uint8_t bit_offset; /* bit offset inside each byte of the 
B-channel */
+   struct osmo_i460_subchan_demux demux;
+   struct osmo_i460_subchan_mux mux;
+};
+
+struct osmo_i460_timeslot {
+   struct osmo_i460_subchan schan[8];
+};
+
+/*! description of a sub-channel; passed by caller */
+struct osmo_i460_schan_desc {
+   enum osmo_i460_rate rate;
+   uint8_t bit_offset;
+   struct {
+   /* size (in bits) of the internal buffer; determines 
granularity */
+   size_t num_bits;
+   /*! call-back function called whenever we received num_bits */
+   out_cb_bits_t out_cb_bits;
+   /*! out_cb_bytes call-back function called whenever we received 
num_bits.
+* The user is usually expected to provide either out_cb_bits 
or out_cb_bytes.  If only
+* out_cb_bits is provided, output data will always be provided 
as unpacked bits;  if only
+* out_cb_bytes is provided, output data will always be 
provided as packet bits (bytes).  If
+* both are provided, it is up to the I.460 multiplex to decide 
if it calls either of the two,
+* depending on what can be provided without extra conversion. 
*/
+   out_cb_bytes_t out_cb_bytes;
+   /* opaque user data pointer to pass to out_cb */
+   void *user_data;
+   } demux;
+};
+
+void osmo_i460_demux_in(struct osmo_i460_timeslot *ts, const uint8_t *data, 
size_t data_len);
+
+void osmo_i460_mux_enqueue(struct osmo_i460_subchan *schan, struct msgb *msg);
+int osmo_i460_mux_out(struct osmo_i460_timeslot *ts, uint8_t *out, size_t 
out_len);
+
+void osmo_i460_ts_init(struct osmo_i460_timeslot *ts);
+
+struct osmo_i460_subchan *
+osmo_i460_subchan_add(void *ctx, struct osmo_i460_timeslot *ts, const struct 
osmo_i460_schan_desc *chd);
+
+void osmo_i460_subchan_del(struct osmo_i460_subchan *schan);
diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
index 6935eab..eeb1164 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -32,7 +32,7 @@
milenage/milenage.c gan.c ipa.c gsm0341.c apn.c \
gsup.c gsup_sms.c gprs_gea.c gsm0503_conv.c oap.c 
gsm0808_utils.c \
gsm23003.c mncc.c bts_features.c oap_client.c \
-   gsm29118.c gsm48_rest_octets.c cbsp.c