further decouple lapdm code from osmocom_ms and l1ctl
authorHarald Welte <laforge@gnumonks.org>
Thu, 23 Jun 2011 21:55:20 +0000 (23:55 +0200)
committerHarald Welte <laforge@gnumonks.org>
Thu, 23 Jun 2011 21:55:20 +0000 (23:55 +0200)
we introduce a new primitive layer betwen PH and DL, enabling the
use of the LAPDm code in applications that are not based on L1CTL

src/host/layer23/include/osmocom/bb/common/l1ctl.h
src/host/layer23/include/osmocom/bb/common/lapdm.h
src/host/layer23/src/common/Makefile.am
src/host/layer23/src/common/l1ctl.c
src/host/layer23/src/common/l1ctl_lapdm_glue.c [new file with mode: 0644]
src/host/layer23/src/common/lapdm.c
src/host/layer23/src/misc/app_cbch_sniff.c
src/host/layer23/src/misc/cell_log.c
src/host/layer23/src/misc/rslms.c
src/host/layer23/src/mobile/app_mobile.c
src/host/layer23/src/mobile/gsm48_rr.c

index 7eb0c8c..1703d26 100644 (file)
@@ -62,4 +62,8 @@ int l1ctl_tx_pm_req_range(struct osmocom_ms *ms, uint16_t arfcn_from,
 
 int l1ctl_tx_sim_req(struct osmocom_ms *ms, uint8_t *data, uint16_t length);
 
+
+/* LAPDm wants to send a PH-* primitive to the physical layer (L1) */
+int l1ctl_ph_prim_cb(struct osmo_prim_hdr *oph, void *ctx);
+
 #endif
index 7f39920..b966972 100644 (file)
@@ -5,6 +5,52 @@
 
 #include <osmocom/core/timer.h>
 #include <osmocom/core/msgb.h>
+#include <osmocom/gsm/prim.h>
+
+/* primitive related sutff */
+
+enum osmo_ph_prim {
+       PRIM_PH_DATA,           /* PH-DATA */
+       PRIM_PH_RACH,           /* PH-RANDOM_ACCESS */
+       PRIM_PH_CONN,           /* PH-CONNECT */
+       PRIM_PH_EMPTY_FRAME,    /* PH-EMPTY_FRAME */
+       PRIM_PH_RTS,            /* PH-RTS */
+};
+
+/* for PH-RANDOM_ACCESS.req */
+struct ph_rach_req_param {
+       uint8_t ra;
+       uint8_t ta;
+       uint8_t tx_power;
+       uint8_t is_combined_ccch;
+       uint16_t offset;
+};
+
+/* for PH-RANDOM_ACCESS.ind */
+struct ph_rach_ind_param {
+       uint8_t ra;
+       uint32_t fn;
+};
+
+/* for PH-[UNIT]DATA.{req,ind} */
+struct ph_data_param {
+       uint8_t link_id;
+       uint8_t chan_nr;
+};
+
+struct ph_conn_ind_param {
+       uint32_t fn;
+};
+
+struct osmo_phsap_prim {
+       struct osmo_prim_hdr oph;
+       union {
+               struct ph_data_param data;
+               struct ph_rach_req_param rach_req;
+               struct ph_rach_ind_param rach_ind;
+               struct ph_conn_ind_param conn_ind;
+       } u;
+};
 
 enum lapdm_state {
        LAPDm_STATE_NULL = 0,
@@ -70,7 +116,7 @@ struct lapdm_entity {
        void *l1_ctx;   /* context for layer1 instance */
        void *l3_ctx;   /* context for layer3 instance */
 
-       lapdm_cb_t l1_cb;       /* callback for sending stuff to L1 */
+       osmo_prim_cb l1_prim_cb;
        lapdm_cb_t l3_cb;       /* callback for sending stuff to L3 */
 
        struct lapdm_channel *lapdm_ch;
@@ -96,15 +142,12 @@ void lapdm_entity_exit(struct lapdm_entity *le);
 void lapdm_channel_exit(struct lapdm_channel *lc);
 
 /* input into layer2 (from layer 1) */
-int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le, uint8_t chan_nr, uint8_t link_id);
-int l2_ph_data_conf(struct msgb *msg, struct lapdm_entity *le);
-
-/* L1 confirms channel request */
-int l2_ph_chan_conf(struct msgb *msg, struct osmocom_ms *ms, uint32_t frame_nr);
+int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le);
 
 /* input into layer2 (from layer 3) */
 int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc);
 
-int osmol2_register_handler(struct osmocom_ms *ms, lapdm_cb_t cb);
+void lapdm_channel_set_l3(struct lapdm_channel *lc, lapdm_cb_t cb, void *ctx);
+void lapdm_channel_set_l1(struct lapdm_channel *lc, osmo_prim_cb cb, void *ctx);
 
 #endif /* _OSMOCOM_LAPDM_H */
index f6e3f83..aca2eb4 100644 (file)
@@ -3,4 +3,4 @@ AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS)
 
 noinst_LIBRARIES = liblayer23.a
 liblayer23_a_SOURCES = l1ctl.c l1l2_interface.c sap_interface.c lapdm.c \
-       logging.c networks.c sim.c sysinfo.c gps.c
+       logging.c networks.c sim.c sysinfo.c gps.c l1ctl_lapdm_glue.c
index f3c2b74..e53df1e 100644 (file)
@@ -111,6 +111,8 @@ static int rx_l1_fbsb_conf(struct osmocom_ms *ms, struct msgb *msg)
 
 static int rx_l1_rach_conf(struct osmocom_ms *ms, struct msgb *msg)
 {
+       struct lapdm_entity *le = &ms->lapdm_channel.lapdm_dcch;
+       struct osmo_phsap_prim pp;
        struct l1ctl_info_dl *dl;
 
        if (msgb_l2len(msg) < sizeof(*dl)) {
@@ -122,14 +124,17 @@ static int rx_l1_rach_conf(struct osmocom_ms *ms, struct msgb *msg)
 
        dl = (struct l1ctl_info_dl *) msg->l1h;
 
-       l2_ph_chan_conf(msg, ms, ntohl(dl->frame_nr));
+       osmo_prim_init(&pp.oph, SAP_GSM_PH, PRIM_PH_RACH,
+                       PRIM_OP_CONFIRM, msg);
+       pp.u.rach_ind.fn = ntohl(dl->frame_nr);
 
-       return 0;
+       return lapdm_phsap_up(&pp.oph, le);
 }
 
 /* Receive L1CTL_DATA_IND (Data Indication from L1) */
 static int rx_ph_data_ind(struct osmocom_ms *ms, struct msgb *msg)
 {
+       struct osmo_phsap_prim pp;
        struct l1ctl_info_dl *dl;
        struct l1ctl_data_ind *ccch;
        struct lapdm_entity *le;
@@ -230,19 +235,24 @@ printf("Dropping frame with %u bit errors\n", dl->num_biterr);
        msgb_pull(msg, msg->l2h - (msg->l1h-sizeof(struct l1ctl_hdr)));
        msg->l1h = NULL;
 
-       /* send it up into LAPDm */
-       l2_ph_data_ind(msg, le, dl->chan_nr, dl->link_id);
+       osmo_prim_init(&pp.oph, SAP_GSM_PH, PRIM_PH_DATA,
+                       PRIM_OP_REQUEST, msg);
+       pp.u.data.chan_nr = dl->chan_nr;
+       pp.u.data.link_id = dl->link_id;
 
-       return 0;
+       /* send it up into LAPDm */
+       return lapdm_phsap_up(&pp.oph, le);
 }
 
 /* Receive L1CTL_DATA_CONF (Data Confirm from L1) */
 static int rx_ph_data_conf(struct osmocom_ms *ms, struct msgb *msg)
 {
-       struct l1ctl_info_dl *dl;
+       struct osmo_phsap_prim pp;
+       struct l1ctl_info_dl *dl = (struct l1ctl_info_dl *) msg->l1h;
        struct lapdm_entity *le;
 
-       dl = (struct l1ctl_info_dl *) msg->l1h;
+       osmo_prim_init(&pp.oph, SAP_GSM_PH, PRIM_PH_RTS,
+                       PRIM_OP_INDICATION, msg);
 
        /* determine LAPDm entity based on SACCH or not */
        if (dl->link_id & 0x40)
@@ -251,9 +261,7 @@ static int rx_ph_data_conf(struct osmocom_ms *ms, struct msgb *msg)
                le = &ms->lapdm_channel.lapdm_dcch;
 
        /* send it up into LAPDm */
-       l2_ph_data_conf(msg, le);
-
-       return 0;
+       return lapdm_phsap_up(&pp.oph, le);
 }
 
 /* Transmit L1CTL_DATA_REQ */
diff --git a/src/host/layer23/src/common/l1ctl_lapdm_glue.c b/src/host/layer23/src/common/l1ctl_lapdm_glue.c
new file mode 100644 (file)
index 0000000..db071a3
--- /dev/null
@@ -0,0 +1,62 @@
+/* Glue code between L1CTL and LAPDm */
+
+/* (C) 2011 by Harald Welte <laforge@gnumonks.org>
+ *
+ * All Rights Reserved
+ *
+ * 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.
+ *
+ */
+
+#include <stdint.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/gsm/prim.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/lapdm.h>
+
+/* LAPDm wants to send a PH-* primitive to the physical layer (L1) */
+int l1ctl_ph_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
+{
+       struct osmocom_ms *ms = ctx;
+       struct osmo_phsap_prim *pp = (struct osmo_phsap_prim *) oph;
+       int rc = 0;
+
+       if (oph->sap != SAP_GSM_PH)
+               return -ENODEV;
+
+       if (oph->operation != PRIM_OP_REQUEST)
+               return -EINVAL;
+
+       switch (oph->primitive) {
+       case PRIM_PH_DATA:
+               rc = l1ctl_tx_data_req(ms, oph->msg, pp->u.data.chan_nr,
+                                       pp->u.data.link_id);
+               break;
+       case PRIM_PH_RACH:
+               l1ctl_tx_param_req(ms, pp->u.rach_req.ta,
+                                  pp->u.rach_req.tx_power);
+               rc = l1ctl_tx_rach_req(ms, pp->u.rach_req.ra,
+                                      pp->u.rach_req.offset,
+                                      pp->u.rach_req.is_combined_ccch);
+               break;
+       default:
+               rc = -EINVAL;
+       }
+
+       return rc;
+}
index c766e0b..52b06eb 100644 (file)
@@ -62,6 +62,7 @@
 #include <osmocom/gsm/tlv.h>
 #include <osmocom/core/utils.h>
 #include <osmocom/gsm/rsl.h>
+#include <osmocom/gsm/prim.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 #include <osmocom/gsm/protocol/gsm_08_58.h>
 
@@ -69,8 +70,6 @@
 #include <osmocom/bb/common/lapdm.h>
 #include <osmocom/bb/common/logging.h>
 
-#include <osmocom/bb/common/l1ctl.h>
-
 /* TS 04.06 Figure 4 / Section 3.2 */
 #define LAPDm_LPD_NORMAL  0
 #define LAPDm_LPD_SMSCB          1
@@ -307,6 +306,12 @@ static int tx_ph_data_enqueue(struct lapdm_datalink *dl, struct msgb *msg,
                                uint8_t chan_nr, uint8_t link_id, uint8_t n201)
 {
        struct lapdm_entity *le = dl->entity;
+       struct osmo_phsap_prim pp;
+
+       osmo_prim_init(&pp.oph, SAP_GSM_PH, PRIM_PH_RACH,
+                       PRIM_OP_REQUEST, msg);
+       pp.u.data.chan_nr = chan_nr;
+       pp.u.data.link_id = link_id;
 
        /* if there is a pending message, queue it */
        if (le->tx_pending) {
@@ -320,24 +325,27 @@ static int tx_ph_data_enqueue(struct lapdm_datalink *dl, struct msgb *msg,
        /* send the frame now */
        le->tx_pending = 0; /* disabled flow control */
        lapdm_pad_msgb(msg, n201);
-       return l1ctl_tx_data_req(le->l1_ctx, msg, chan_nr, link_id);
+
+       return le->l1_prim_cb(&pp.oph, le->l1_ctx);
 }
 
 /* get next frame from the tx queue. because the ms has multiple datalinks,
  * each datalink's queue is read round-robin.
  */
-int l2_ph_data_conf(struct msgb *msg, struct lapdm_entity *le)
+static int l2_ph_data_conf(struct msgb *msg, struct lapdm_entity *le)
 {
        struct lapdm_datalink *dl;
        int last = le->last_tx_dequeue;
        int i = last, n = ARRAY_SIZE(le->datalink);
-       uint8_t chan_nr, link_id, n201;
+       struct osmo_phsap_prim pp;
+       uint8_t n201;
 
        /* we may send again */
        le->tx_pending = 0;
 
        /* free confirm message */
-       msgb_free(msg);
+       if (msg)
+               msgb_free(msg);
 
        /* round-robin dequeue */
        do {
@@ -352,10 +360,13 @@ int l2_ph_data_conf(struct msgb *msg, struct lapdm_entity *le)
        if (!msg)
                return 0;
 
+       osmo_prim_init(&pp.oph, SAP_GSM_PH, PRIM_PH_DATA,
+                       PRIM_OP_REQUEST, msg);
+
        /* Pull chan_nr and link_id */
-       chan_nr = *msg->data;
+       pp.u.data.chan_nr = *msg->data;
        msgb_pull(msg, 1);
-       link_id = *msg->data;
+       pp.u.data.link_id = *msg->data;
        msgb_pull(msg, 1);
        n201 = *msg->data;
        msgb_pull(msg, 1);
@@ -366,7 +377,8 @@ int l2_ph_data_conf(struct msgb *msg, struct lapdm_entity *le)
        /* Pad the frame, we can transmit now */
        le->tx_pending = 1;
        lapdm_pad_msgb(msg, n201);
-       return l1ctl_tx_data_req(le->l1_ctx, msg, chan_nr, link_id);
+
+       return le->l1_prim_cb(&pp.oph, le->l1_ctx);
 }
 
 /* Create RSLms various RSLms messages */
@@ -1515,7 +1527,7 @@ static int lapdm_ph_data_ind(struct msgb *msg, struct lapdm_msg_ctx *mctx)
 }
 
 /* input into layer2 (from layer 1) */
-int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le, uint8_t chan_nr, uint8_t link_id)
+static int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le, uint8_t chan_nr, uint8_t link_id)
 {
        uint8_t cbits = chan_nr >> 3;
        uint8_t sapi = link_id & 7;
@@ -1600,6 +1612,50 @@ int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le, uint8_t chan_nr, u
        return rc;
 }
 
+static int l2_ph_chan_conf(struct msgb *msg, struct lapdm_entity *le, uint32_t frame_nr);
+
+int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le)
+{
+       struct osmo_phsap_prim *pp = (struct osmo_phsap_prim *) oph;
+       int rc = 0;
+
+       if (oph->sap != SAP_GSM_PH)
+               return -ENODEV;
+
+       if (oph->operation != PRIM_OP_INDICATION)
+               return -ENODEV;
+
+       switch (oph->primitive) {
+       case PRIM_PH_DATA:
+               if (oph->operation != PRIM_OP_INDICATION)
+                       return -ENODEV;
+               rc = l2_ph_data_ind(oph->msg, le, pp->u.data.chan_nr,
+                                   pp->u.data.link_id);
+               break;
+       case PRIM_PH_RTS:
+               if (oph->operation != PRIM_OP_INDICATION)
+                       return -ENODEV;
+               rc = l2_ph_data_conf(oph->msg, le);
+               break;
+       case PRIM_PH_RACH:
+               switch (oph->operation) {
+               case PRIM_OP_INDICATION:
+#warning FIX BTS
+                       //rc = l2_ph_rach_ind(le, pp->u.rach_ind.ra, pp->u.rach_ind.fn);
+                       break;
+               case PRIM_OP_CONFIRM:
+                       rc = l2_ph_chan_conf(oph->msg, le, pp->u.rach_ind.fn);
+                       break;
+               default:
+                       return -EIO;
+               }
+               break;
+       }
+
+       return rc;
+}
+
+
 /* L3 -> L2 / RSLMS -> LAPDm */
 
 /* L3 requests establishment of data link */
@@ -2051,7 +2107,10 @@ static int rslms_rx_chan_rqd(struct lapdm_channel *lc, struct msgb *msg)
 {
        struct abis_rsl_cchan_hdr *cch = msgb_l2(msg);
        void *l1ctx = lc->lapdm_dcch.l1_ctx;
-       int rc;
+       struct osmo_phsap_prim pp;
+
+       osmo_prim_init(&pp.oph, SAP_GSM_PH, PRIM_PH_RACH,
+                       PRIM_OP_REQUEST, NULL);
 
        if (msgb_l2len(msg) < sizeof(*cch) + 4 + 2 + 2) {
                LOGP(DRSL, LOGL_ERROR, "Message too short for CHAN RQD!\n");
@@ -2061,28 +2120,30 @@ static int rslms_rx_chan_rqd(struct lapdm_channel *lc, struct msgb *msg)
                LOGP(DRSL, LOGL_ERROR, "Missing REQ REFERENCE IE\n");
                return -EINVAL;
        }
+       pp.u.rach_req.ra = cch->data[1];
+       pp.u.rach_req.offset = ((cch->data[2] & 0x7f) << 8) | cch->data[3];
+       pp.u.rach_req.is_combined_ccch = cch->data[2] >> 7;
+
        if (cch->data[4] != RSL_IE_ACCESS_DELAY) {
                LOGP(DRSL, LOGL_ERROR, "Missing ACCESS_DELAY IE\n");
                return -EINVAL;
        }
+       /* TA = 0 - delay */
+       pp.u.rach_req.ta = 0 - cch->data[5];
+
        if (cch->data[6] != RSL_IE_MS_POWER) {
                LOGP(DRSL, LOGL_ERROR, "Missing MS POWER IE\n");
                return -EINVAL;
        }
-
-       /* TA = 0 - delay */
-       rc = l1ctl_tx_param_req(l1ctx, 0 - cch->data[5], cch->data[7]);
-
-       rc = l1ctl_tx_rach_req(l1ctx, cch->data[1],
-               ((cch->data[2] & 0x7f) << 8) | cch->data[3], cch->data[2] >> 7);
+       pp.u.rach_req.tx_power = cch->data[7];
 
        msgb_free(msg);
 
-       return rc;
+       return lc->lapdm_dcch.l1_prim_cb(&pp.oph, l1ctx);
 }
 
 /* L1 confirms channel request */
-int l2_ph_chan_conf(struct msgb *msg, struct osmocom_ms *ms, uint32_t frame_nr)
+static int l2_ph_chan_conf(struct msgb *msg, struct lapdm_entity *le, uint32_t frame_nr)
 {
        struct abis_rsl_cchan_hdr *ch;
        struct gsm_time tm;
@@ -2102,7 +2163,7 @@ int l2_ph_chan_conf(struct msgb *msg, struct osmocom_ms *ms, uint32_t frame_nr)
        ref->t3_low = tm.t3 & 0x7;
        ref->t3_high = tm.t3 >> 3;
        
-       return rslms_sendmsg(msg, &ms->lapdm_channel.lapdm_dcch);
+       return rslms_sendmsg(msg, le);
 }
 
 /* Names for Radio Link Layer Management */
@@ -2304,12 +2365,18 @@ int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc)
        return rc;
 }
 
-int osmol2_register_handler(struct osmocom_ms *ms, lapdm_cb_t cb)
+void lapdm_channel_set_l1(struct lapdm_channel *lc, osmo_prim_cb cb, void *ctx)
 {
-       ms->lapdm_channel.lapdm_acch.l3_cb = cb;
-       ms->lapdm_channel.lapdm_dcch.l3_cb = cb;
-       ms->lapdm_channel.lapdm_acch.l3_ctx = ms;
-       ms->lapdm_channel.lapdm_dcch.l3_ctx = ms;
+       lc->lapdm_dcch.l1_prim_cb = cb;
+       lc->lapdm_acch.l1_prim_cb = cb;
+       lc->lapdm_dcch.l1_ctx = ctx;
+       lc->lapdm_acch.l1_ctx = ctx;
+}
 
-       return 0;
+void lapdm_channel_set_l3(struct lapdm_channel *lc, lapdm_cb_t cb, void *ctx)
+{
+       lc->lapdm_dcch.l3_cb = cb;
+       lc->lapdm_acch.l3_cb = cb;
+       lc->lapdm_dcch.l3_ctx = ctx;
+       lc->lapdm_acch.l3_ctx = ctx;
 }
index 83c5468..f10b30f 100644 (file)
@@ -182,7 +182,7 @@ int l23_app_init(struct osmocom_ms *ms)
        /* don't do layer3_init() as we don't want an actualy L3 */
 
        g_ms = ms;
-       osmol2_register_handler(ms, &rcv_rsl);
+       lapdm_channel_set_l1(&ms->lapdm_channel, &rcv_rsl, ms);
 
        l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
        /* FIXME: L1CTL_RES_T_FULL doesn't reset dedicated mode
index ac0d206..4e0324f 100644 (file)
@@ -786,7 +786,7 @@ int scan_init(struct osmocom_ms *_ms)
        ms = _ms;
        osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
        memset(&timer, 0, sizeof(timer));
-       osmol2_register_handler(ms, &rcv_rsl);
+       lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
        g.enable = 1;
        osmo_gps_init();
        if (osmo_gps_open())
index 02113a3..642840c 100644 (file)
@@ -44,7 +44,7 @@ int rslms_tx_rll_req(struct osmocom_ms *ms, uint8_t msg_type,
 
        msg = rsl_rll_simple(msg_type, chan_nr, link_id, 1);
 
-       return lapdm_rslms_recvmsg(msg, ms);
+       return lapdm_rslms_recvmsg(msg, &ms->lapdm_channel);
 }
 
 /* Send a RLL request (including L3 info) to L2 */
@@ -53,7 +53,7 @@ int rslms_tx_rll_req_l3(struct osmocom_ms *ms, uint8_t msg_type,
 {
        rsl_rll_push_l3(msg, msg_type, chan_nr, link_id, 1);
 
-       return lapdm_rslms_recvmsg(msg, ms);
+       return lapdm_rslms_recvmsg(msg, &ms->lapdm_channel);
 }
 
 static int rslms_rx_udata_ind(struct msgb *msg, struct osmocom_ms *ms)
@@ -144,5 +144,7 @@ static int layer3_from_layer2(struct msgb *msg, struct osmocom_ms *ms)
 
 int layer3_init(struct osmocom_ms *ms)
 {
-       return osmol2_register_handler(ms, &layer3_from_layer2);
+       lapdm_channel_set_l3(&ms->lapdm_channel, &layer3_from_layer2, ms);
+
+       return 0;
 }
index 1766d7e..d9c07e1 100644 (file)
@@ -161,11 +161,10 @@ int mobile_init(struct osmocom_ms *ms)
        int rc;
 
        gsm_settings_arfcn(ms);
-       ms->lapdm_channel.lapdm_dcch.l1_ctx = ms;
-       ms->lapdm_channel.lapdm_dcch.l3_ctx = ms;
-       ms->lapdm_channel.lapdm_acch.l1_ctx = ms;
-       ms->lapdm_channel.lapdm_acch.l3_ctx = ms;
+
        lapdm_channel_init(&ms->lapdm_channel);
+       lapdm_channel_set_l1(&ms->lapdm_channel, l1ctl_ph_prim_cb, ms);
+
        gsm_sim_init(ms);
        gsm48_cc_init(ms);
        gsm_subscr_init(ms);
index 502a750..cd15cf9 100644 (file)
@@ -5059,7 +5059,7 @@ int gsm48_rr_init(struct osmocom_ms *ms)
        INIT_LLIST_HEAD(&rr->downqueue);
        /* downqueue is handled here, so don't add_work */
 
-       osmol2_register_handler(ms, &rcv_rsl);
+       lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
 
        start_rr_t_meas(rr, 1, 0);