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
This commit is contained in:
Harald Welte 2020-03-08 17:09:29 +01:00
parent 3f35ab258d
commit 6a5039674f
1 changed files with 2 additions and 3 deletions

View File

@ -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