jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/32933 )
Change subject: Add support for sending Bter UI frames at lapdm.c ......................................................................
Add support for sending Bter UI frames at lapdm.c
Bter frames may be used on downlink of a main DCCH or SACCH channel. It applies to SAPI 0 and UI frames only. It includes a short layer 2 header with 2 bits only. All other bits are used for the message. The message size is 23 bytes on main DCCH and 21 bytes on SACCH. The length of the L3 messsage is used to distinguish between Bter frames and other (UI) frames.
Note that the L3 message header is different, so that the length of the UI frame will determine which header is used.
Change-Id: Ia3a25c009d1ff09f83258bdb226a85b81466d7a1 --- M src/gsm/lapdm.c 1 file changed, 31 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/33/32933/1
diff --git a/src/gsm/lapdm.c b/src/gsm/lapdm.c index b7f5769..aade046 100644 --- a/src/gsm/lapdm.c +++ b/src/gsm/lapdm.c @@ -1029,7 +1029,7 @@ uint8_t link_id = rllh->link_id; uint8_t sapi = link_id & 7; struct tlv_parsed tv; - int length, ui_bts; + int length, ui_bts, b_ter;
if (!le) { LOGDL(&dl->dl, LOGL_ERROR, "lapdm_datalink without entity error\n"); @@ -1055,8 +1055,10 @@ } msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO); length = TLVP_LEN(&tv, RSL_IE_L3_INFO); + /* check for Bter frame */ + b_ter = (length == ((link_id & 0x40) ? 21 : 23) && sapi == 0); /* check if the layer3 message length exceeds N201 */ - if (length + ((link_id & 0x40) ? 4 : 2) + !ui_bts > 23) { + if (length + ((link_id & 0x40) ? 4 : 2) + !ui_bts > 23 && !b_ter) { LOGDL(&dl->dl, LOGL_ERROR, "frame too large: %d > N201(%d) " "(discarding)\n", length, ((link_id & 0x40) ? 18 : 20) + ui_bts); @@ -1071,11 +1073,14 @@ msgb_trim(msg, length);
/* Push L1 + LAPDm header on msgb */ - msg->l2h = msgb_push(msg, 2 + !ui_bts); - msg->l2h[0] = LAPDm_ADDR(LAPDm_LPD_NORMAL, sapi, dl->dl.cr.loc2rem.cmd); - msg->l2h[1] = LAPDm_CTRL_U(LAPDm_U_UI, 0); - if (!ui_bts) - msg->l2h[2] = LAPDm_LEN(length); + if (!b_ter) { + msg->l2h = msgb_push(msg, 2 + !ui_bts); + msg->l2h[0] = LAPDm_ADDR(LAPDm_LPD_NORMAL, sapi, dl->dl.cr.loc2rem.cmd); + msg->l2h[1] = LAPDm_CTRL_U(LAPDm_U_UI, 0); + if (!ui_bts) + msg->l2h[2] = LAPDm_LEN(length); + } else + msg->l2h = msg->data; if (link_id & 0x40) { msg->l2h = msgb_push(msg, 2); msg->l2h[0] = le->tx_power;