From 087116aca771ae3cd2dcbcbd8cb63a91dfc75f20 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 18 Jun 2013 21:41:34 +0200 Subject: lapd_core: msgb_trim() the L2 padding from ESTABLISH.ind When a SABM(E) frame arrives, we have to trim the L2 padding (0x2b for gsm) before handing the data off to L3, just like we do with I frames. Also, we should use mggb_trim() or even msgb_l3trim() instead of manually fiddling with msgb->length and ->tail pointers. --- src/gsm/lapd_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c index 9dbdfcf9..116e3116 100644 --- a/src/gsm/lapd_core.c +++ b/src/gsm/lapd_core.c @@ -899,6 +899,7 @@ static int lapd_rx_u(struct msgb *msg, struct lapd_msg_ctx *lctx) msgb_free(msg); } else { /* 5.4.1.4 Contention resolution establishment */ + msgb_trim(msg, length); rc = send_dl_l3(prim, op, lctx, msg); } break; @@ -1016,6 +1017,7 @@ static int lapd_rx_u(struct msgb *msg, struct lapd_msg_ctx *lctx) msgb_free(msg); return 0; } + msgb_trim(msg, length); rc = send_dl_l3(PRIM_DL_UNIT_DATA, PRIM_OP_INDICATION, lctx, msg); break; @@ -1545,8 +1547,7 @@ static int lapd_rx_i(struct msgb *msg, struct lapd_msg_ctx *lctx) if (!lctx->more && !dl->rcv_buffer) { LOGP(DLLAPD, LOGL_INFO, "message in single I frame\n"); /* send a DATA INDICATION to L3 */ - msg->len = length; - msg->tail = msg->data + length; + msgb_trim(msg, length); rc = send_dl_l3(PRIM_DL_DATA, PRIM_OP_INDICATION, lctx, msg); } else { -- cgit v1.2.3