From 6a5039674f3d3253133ada666368b9342cc18a93 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 8 Mar 2020 17:09:29 +0100 Subject: l1sap: Use msgb_pull_l2() and unify l1sap_tch_ind + l1sap_ph_data_ind In l1sap_ph_data_ind() we can use msgb_pull_l2() which is an exact implementation of the functionality there. In l1sap_tch_ind(), the existing code is actually wrong by making the assumption that the msgb contains exactly an entire osmo_phsap_prim. Better to also dynamically compute the number of bytes to ensure we only pull those ahead of the L2 header, no matter what their exact count. Change-Id: I13f7f8ba93795e40b1fb4a306fe765e059f642cf --- src/common/l1sap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/common/l1sap.c b/src/common/l1sap.c index 05dbb6f8..673430de 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -1355,8 +1355,7 @@ static int l1sap_ph_data_ind(struct gsm_bts_trx *trx, l1sap_tx_ciph_req(lchan->ts->trx, chan_nr, 1, 0); /* SDCCH, SACCH and FACCH all go to LAPDm */ - msgb_pull(msg, (msg->l2h - msg->data)); - msg->l1h = NULL; + msgb_pull_to_l2(msg); lapdm_phsap_up(&l1sap->oph, le); /* don't free, because we forwarded data */ @@ -1393,7 +1392,7 @@ static int l1sap_tch_ind(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap, if (gsm_bts_has_feature(trx->bts, BTS_FEAT_MEAS_PAYLOAD_COMB)) process_l1sap_meas_data(trx, l1sap, PRIM_TCH); - msgb_pull(msg, sizeof(*l1sap)); + msgb_pull_to_l2(msg); /* Low level layers always call us when TCH content is expected, even if * the content is not available due to decoding issues. Content not -- cgit v1.2.3