pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/34132 )
Change subject: lapdm: Append RSL_IE_OSMO_ABS_FRAME_NUMBER to RSLms msgs towards upper layers ......................................................................
lapdm: Append RSL_IE_OSMO_ABS_FRAME_NUMBER to RSLms msgs towards upper layers
This makes it possible to track GSM time in the upper layers. The existing RSL_IE_FRAME_NUMBER and RSL_IE_STARTNG_TIME cannot be used there, since those are 16bit fields containing Relative FN values.
The IE needs to be added before the L3_INFO one, because user code usually assumes the msgb->l3 pointing to L3_INFO value extends until the end of the message, using msgb3_len(msg). Regarding having an extra IE at the middle, it's not a big problem since the libosmocore version submitting this commit to the upper layers is the same which will also be parsing it through rsl_tlv_parse() later on by the app.
Related: OS#3626 Change-Id: Id62c18f49f270449067b25b7104eb8b47f1955ec --- M include/osmocom/gsm/rsl.h M src/gsm/lapdm.c M src/gsm/rsl.c M tests/lapd/lapd_test.c M tests/lapd/lapd_test.ok 5 files changed, 68 insertions(+), 13 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/32/34132/1
diff --git a/include/osmocom/gsm/rsl.h b/include/osmocom/gsm/rsl.h index 285dbc2..b9d3282 100644 --- a/include/osmocom/gsm/rsl.h +++ b/include/osmocom/gsm/rsl.h @@ -51,6 +51,8 @@ /* Push a RSL RLL header with L3_INFO IE */ void rsl_rll_push_l3(struct msgb *msg, uint8_t msg_type, uint8_t chan_nr, uint8_t link_id, int transparent); +void rsl_rll_push_l3_with_fn(struct msgb *msg, uint8_t msg_type, uint8_t chan_nr, + uint8_t link_id, int transparent, uint32_t fn);
/* Allocate msgb and fill with simple RSL RLL header */ struct msgb *rsl_rll_simple(uint8_t msg_type, uint8_t chan_nr, diff --git a/src/gsm/lapdm.c b/src/gsm/lapdm.c index e96e218..a2e44a3 100644 --- a/src/gsm/lapdm.c +++ b/src/gsm/lapdm.c @@ -503,7 +503,7 @@ int transparent = rsl_is_transparent(msg_type);
/* Add the RSL + RLL header */ - rsl_rll_push_l3(msg, msg_type, mctx->chan_nr, mctx->link_id, transparent); + rsl_rll_push_l3_with_fn(msg, msg_type, mctx->chan_nr, mctx->link_id, transparent, mctx->fn);
/* send off the RSLms message to L3 */ return rslms_sendmsg(msg, mctx->dl->entity); @@ -517,6 +517,8 @@ /* Add the RSL + RLL header */ msgb_tv16_push(msg, RSL_IE_L3_INFO, l3_len);
+ msgb_tv32_push(msg, RSL_IE_OSMO_ABS_FRAME_NUMBER, mctx->fn); + /* Add two non-standard IEs carrying MS power and TA values for B4 (SACCH) */ if (mctx->lapdm_fmt == LAPDm_FMT_B4) { msgb_tv_push(msg, RSL_IE_MS_POWER, mctx->tx_power_ind); @@ -535,6 +537,8 @@ int transparent = rsl_is_transparent(msg_type);
msg = rsl_rll_simple(msg_type, mctx->chan_nr, mctx->link_id, transparent); + /* Add FN to the end to keep backward compat: */ + msgb_tv32_put(msg, RSL_IE_OSMO_ABS_FRAME_NUMBER, mctx->fn);
/* send off the RSLms message to L3 */ return rslms_sendmsg(msg, mctx->dl->entity); @@ -547,6 +551,9 @@ LOGDL(&mctx->dl->dl, LOGL_NOTICE, "sending MDL-ERROR-IND %d\n", cause); msg = rsl_rll_simple(RSL_MT_ERROR_IND, mctx->chan_nr, mctx->link_id, 0); msgb_tlv_put(msg, RSL_IE_RLM_CAUSE, 1, &cause); + /* Add FN to the end to keep backward compat: */ + msgb_tv32_put(msg, RSL_IE_OSMO_ABS_FRAME_NUMBER, mctx->fn); + return rslms_sendmsg(msg, mctx->dl->entity); }
diff --git a/src/gsm/rsl.c b/src/gsm/rsl.c index eac7fd8..a95d294 100644 --- a/src/gsm/rsl.c +++ b/src/gsm/rsl.c @@ -561,6 +561,31 @@ rsl_rll_push_hdr(msg, msg_type, chan_nr, link_id, transparent); }
+/*! Wrap msgb in L3 Info IE and push a RSL RLL header + * \param[in] msg Message Buffer to which L3 Header shall be appended + * \param[in] msg_type RSL Message Type + * \param[in] chan_hr RSL Channel Number + * \param[in] link_id Link Identififer + * \param[in] transparent Transparent to BTS (1) or not (0) + * \param[in] fn Frame Number + */ +void rsl_rll_push_l3_with_fn(struct msgb *msg, uint8_t msg_type, uint8_t chan_nr, + uint8_t link_id, int transparent, uint32_t fn) +{ + uint8_t l3_len = msg->tail - (uint8_t *)msgb_l3(msg); + + /* construct a RSLms RLL message (DATA INDICATION, UNIT DATA + * INDICATION) and send it off via RSLms */ + + /* Push the L3 IE tag and length */ + msgb_tv16_push(msg, RSL_IE_L3_INFO, l3_len); + + msgb_tv32_push(msg, RSL_IE_OSMO_ABS_FRAME_NUMBER, fn); + + /* Then push the RSL header */ + rsl_rll_push_hdr(msg, msg_type, chan_nr, link_id, transparent); +} + /*! Create msgb with RSL RLL header * \param[in] msg_type RSL Message Type * \param[in] chan_nr RSL Channel Number diff --git a/tests/lapd/lapd_test.c b/tests/lapd/lapd_test.c index afea822..791edc8 100644 --- a/tests/lapd/lapd_test.c +++ b/tests/lapd/lapd_test.c @@ -360,7 +360,7 @@ struct abis_rsl_rll_hdr hdr;
printf("MS: Verifying incoming primitive.\n"); - OSMO_ASSERT(msg->len == sizeof(struct abis_rsl_rll_hdr)); + OSMO_ASSERT(msg->len >= sizeof(struct abis_rsl_rll_hdr));
/* verify the header */ memset(&hdr, 0, sizeof(hdr)); diff --git a/tests/lapd/lapd_test.ok b/tests/lapd/lapd_test.ok index a2e5ae3..9a3094f 100644 --- a/tests/lapd/lapd_test.ok +++ b/tests/lapd/lapd_test.ok @@ -1,28 +1,28 @@ I do some very simple LAPDm test. Establishing link. ms_to_bts_l1_cb: MS(us) -> BTS prim message -bts_to_ms_tx_cb: MS->BTS(us) message 25 +bts_to_ms_tx_cb: MS->BTS(us) message 30 BTS: Verifying CM request.
Confirming lapdm_phsap_dequeue_prim(): got rc 0: Success Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x00, FN 0 Message: [L2]> 01 73 41 [L3]> 05 24 31 03 50 18 93 08 29 47 80 00 00 00 00 80 2b 2b 2b 2b -ms_to_bts_tx_cb: BTS->MS(us) message 6 +ms_to_bts_tx_cb: BTS->MS(us) message 11 MS: Verifying incoming primitive.
Sending back to MS lapdm_phsap_dequeue_prim(): got rc 0: Success Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x00, FN 0 Message: [L2]> 03 00 0d [L3]> 05 04 0d 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b -ms_to_bts_tx_cb: BTS->MS(us) message 12 +ms_to_bts_tx_cb: BTS->MS(us) message 17 MS: Verifying incoming MM message: 3 ms_to_bts_l1_cb: MS(us) -> BTS prim message lapdm_phsap_dequeue_prim(): got rc -19: No such device
Sending back to BTS ms_to_bts_l1_cb: MS(us) -> BTS prim message -bts_to_ms_tx_cb: MS->BTS(us) message 14 +bts_to_ms_tx_cb: MS->BTS(us) message 19 BTS: Verifying dummy message. lapdm_phsap_dequeue_prim(): got rc 0: Success MSGB: L3 is undefined @@ -32,7 +32,7 @@ lapdm_phsap_dequeue_prim(): got rc -19: No such device I test RF channel release of an unestablished channel. I test contention resultion by having two mobiles collide and first mobile repeating SABM. -bts_to_ms_tx_cb: MS->BTS(us) message 25 +bts_to_ms_tx_cb: MS->BTS(us) message 30 BTS: Verifying CM request. lapdm_phsap_dequeue_prim(): got rc 0: Success Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x00, FN 0 @@ -60,7 +60,7 @@ I test if desync problems exist in LAPDm
Establishing SAPI=0 -bts_to_ms_dummy_tx_cb: MS->BTS(us) message 25 +bts_to_ms_dummy_tx_cb: MS->BTS(us) message 30
Dumping queue: 00 00 17 [L2]> 01 73 41 [L3]> 05 24 31 03 50 18 93 08 29 47 80 00 00 00 00 80 @@ -70,7 +70,7 @@ Message: [L2]> 01 73 41 [L3]> 05 24 31 03 50 18 93 08 29 47 80 00 00 00 00 80 2b 2b 2b 2b
Sending Classmark Change -bts_to_ms_dummy_tx_cb: MS->BTS(us) message 27 +bts_to_ms_dummy_tx_cb: MS->BTS(us) message 32
Dumping queue: 00 00 17 [L2]> 01 21 01 @@ -87,7 +87,7 @@
Sending GPRS Suspend Request -bts_to_ms_dummy_tx_cb: MS->BTS(us) message 22 +bts_to_ms_dummy_tx_cb: MS->BTS(us) message 27
Dumping queue: 00 00 17 [L2]> 03 40 0d [L3]> 06 35 01 @@ -97,7 +97,7 @@ Message: [L2]> 03 40 0d [L3]> 06 35 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
Sending Cipher Mode Complete -bts_to_ms_dummy_tx_cb: MS->BTS(us) message 11 +bts_to_ms_dummy_tx_cb: MS->BTS(us) message 16
Dumping queue: 00 00 17 [L2]> 01 61 01 @@ -108,7 +108,7 @@ Message: [L2]> 01 61 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
Establishing SAPI=3 -bts_to_ms_dummy_tx_cb: MS->BTS(us) message 6 +bts_to_ms_dummy_tx_cb: MS->BTS(us) message 11
Dumping queue:
@@ -128,7 +128,7 @@ === I test SAPI0/SAPI3 prioritization ===
MS is establishing a SAPI=0 link -bts_to_ms_dummy_tx_cb: MS->BTS(us) message 22 +bts_to_ms_dummy_tx_cb: MS->BTS(us) message 27 BTS is establishing a SAPI=3 link lapdm_phsap_dequeue_prim(): got rc 0: Success Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x00, FN 0