pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/34130 )
Change subject: lapdm: Track fn of primitives in struct lapdm_msg_ctx ......................................................................
lapdm: Track fn of primitives in struct lapdm_msg_ctx
This field will be used in follow-up commits to provide FN information in RSLms primitives towars upper layers. This is needed for instance on the MS side when a CCCH_DATA.ind is received containing a TBF ImmAss with a relative FN indicating the Starting Time. Without tracking FN advance, the uppers layers are not capable of figuring out the absolute FN of the TBF Starting time.
The struct lapdm_msg_ctx is not really used outside of libosmocore, so we are safe extending it.
Related: OS#3626 Change-Id: Icf986f4202703eb452bedc1b749bb8ce0c73706f --- M include/osmocom/gsm/lapdm.h M src/gsm/lapdm.c M tests/lapd/lapd_test.c M tests/lapd/lapd_test.ok 4 files changed, 44 insertions(+), 19 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/30/34130/1
diff --git a/include/osmocom/gsm/lapdm.h b/include/osmocom/gsm/lapdm.h index 0e99743..1a39fca 100644 --- a/include/osmocom/gsm/lapdm.h +++ b/include/osmocom/gsm/lapdm.h @@ -24,6 +24,7 @@ uint8_t link_id; uint8_t ta_ind; /* TA indicated by network */ uint8_t tx_power_ind; /* MS power indicated by network */ + uint32_t fn; };
/*! LAPDm datalink like TS 04.06 / Section 3.5.2 */ diff --git a/src/gsm/lapdm.c b/src/gsm/lapdm.c index 4a82c4d..e96e218 100644 --- a/src/gsm/lapdm.c +++ b/src/gsm/lapdm.c @@ -700,7 +700,7 @@
/* input into layer2 (from layer 1) */ static int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le, - uint8_t chan_nr, uint8_t link_id) + uint8_t chan_nr, uint8_t link_id, uint32_t fn) { uint8_t cbits = chan_nr >> 3; uint8_t sapi; /* we cannot take SAPI from link_id, as L1 has no clue */ @@ -715,6 +715,7 @@ memset(&mctx, 0, sizeof(mctx)); mctx.chan_nr = chan_nr; mctx.link_id = link_id; + mctx.fn = fn;
/* check for L1 chan_nr/link_id and determine LAPDm hdr format */ if (cbits == 0x10 || cbits == 0x12) { @@ -916,7 +917,7 @@ switch (OSMO_PRIM_HDR(oph)) { case OSMO_PRIM(PRIM_PH_DATA, PRIM_OP_INDICATION): rc = l2_ph_data_ind(oph->msg, le, pp->u.data.chan_nr, - pp->u.data.link_id); + pp->u.data.link_id, pp->u.data.fn); break; case OSMO_PRIM(PRIM_PH_RTS, PRIM_OP_INDICATION): rc = l2_ph_data_conf(oph->msg, le); diff --git a/tests/lapd/lapd_test.c b/tests/lapd/lapd_test.c index 739f9b7..afea822 100644 --- a/tests/lapd/lapd_test.c +++ b/tests/lapd/lapd_test.c @@ -184,6 +184,7 @@ /* LAPDm requires those... */ pp.u.data.chan_nr = 0; pp.u.data.link_id = 0; + pp.u.data.fn = 0; /* feed into the LAPDm code of libosmogsm */ rc = lapdm_phsap_up(&pp.oph, &chan->lapdm_dcch); OSMO_ASSERT(rc == 0 || rc == -EBUSY); @@ -206,6 +207,7 @@ /* LAPDm requires those... */ pp.u.data.chan_nr = 0; pp.u.data.link_id = 0; + pp.u.data.fn = 0; /* feed into the LAPDm code of libosmogsm */ rc = lapdm_phsap_up(&pp.oph, &chan->lapdm_dcch); OSMO_ASSERT(rc == 0 || rc == -EBUSY); @@ -337,11 +339,12 @@
printf("Took message from %s queue: " "L2 header size %d, L3 size %d, " - "SAP %#x, %d/%d, Link 0x%02x\n", + "SAP %#x, %d/%d, Link 0x%02x, FN %u\n", queue_name, l2_header_len, l3_len, pp->oph.sap, pp->oph.primitive, pp->oph.operation, - pp->u.data.link_id); + pp->u.data.link_id, + pp->u.data.fn); printf("Message: %s\n", msgb_hexdump(pp->oph.msg));
return rc; diff --git a/tests/lapd/lapd_test.ok b/tests/lapd/lapd_test.ok index 065886c..a2e5ae3 100644 --- a/tests/lapd/lapd_test.ok +++ b/tests/lapd/lapd_test.ok @@ -6,14 +6,14 @@
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 +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: 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 +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: Verifying incoming MM message: 3 @@ -26,7 +26,7 @@ BTS: Verifying dummy message. lapdm_phsap_dequeue_prim(): got rc 0: Success MSGB: L3 is undefined -Took message from DCCH queue: L2 header size 23, L3 size 0, SAP 0x1000000, 0/0, Link 0x00 +Took message from DCCH queue: L2 header size 23, L3 size 0, SAP 0x1000000, 0/0, Link 0x00, FN 0 Message: [L2]> 01 21 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b lapdm_phsap_dequeue_prim(): got rc -19: No such device lapdm_phsap_dequeue_prim(): got rc -19: No such device @@ -35,17 +35,17 @@ bts_to_ms_tx_cb: MS->BTS(us) message 25 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 +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 lapdm_phsap_dequeue_prim(): got rc -19: No such device 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 +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 I test RF channel establishment. Testing SAPI3/SDCCH lapdm_rslms_recvmsg(): got rc 0: Success 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 0x03 +Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x03, FN 0 Message: [L2]> 0f 3f 01 [L3]> 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b lapdm_phsap_dequeue_prim(): got rc -19: No such device lapdm_phsap_dequeue_prim(): got rc -19: No such device @@ -53,7 +53,7 @@ lapdm_rslms_recvmsg(): got rc 0: Success lapdm_phsap_dequeue_prim(): got rc -19: No such device lapdm_phsap_dequeue_prim(): got rc 0: Success -Took message from ACCH queue: L2 header size 5, L3 size 18, SAP 0x1000000, 0/0, Link 0x43 +Took message from ACCH queue: L2 header size 5, L3 size 18, SAP 0x1000000, 0/0, Link 0x43, FN 0 Message: [L2]> 00 00 0f 3f 01 [L3]> 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b lapdm_phsap_dequeue_prim(): got rc -19: No such device lapdm_phsap_dequeue_prim(): got rc -19: No such device @@ -66,7 +66,7 @@ 00 00 17 [L2]> 01 73 41 [L3]> 05 24 31 03 50 18 93 08 29 47 80 00 00 00 00 80
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 +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
Sending Classmark Change @@ -77,7 +77,7 @@
lapdm_phsap_dequeue_prim(): got rc 0: Success MSGB: L3 is undefined -Took message from DCCH queue: L2 header size 23, L3 size 0, SAP 0x1000000, 0/0, Link 0x00 +Took message from DCCH queue: L2 header size 23, L3 size 0, SAP 0x1000000, 0/0, Link 0x00, FN 0 Message: [L2]> 01 21 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
Enqueueing Ciphering Mode Command @@ -93,7 +93,7 @@ 00 00 17 [L2]> 03 40 0d [L3]> 06 35 01
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 +Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x00, FN 0 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 @@ -104,7 +104,7 @@
lapdm_phsap_dequeue_prim(): got rc 0: Success MSGB: L3 is undefined -Took message from DCCH queue: L2 header size 23, L3 size 0, SAP 0x1000000, 0/0, Link 0x00 +Took message from DCCH queue: L2 header size 23, L3 size 0, SAP 0x1000000, 0/0, Link 0x00, FN 0 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 @@ -113,7 +113,7 @@ Dumping queue:
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 0x03 +Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x03, FN 0 Message: [L2]> 0d 73 01 [L3]> 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
Sending CP-DATA @@ -122,7 +122,7 @@
lapdm_phsap_dequeue_prim(): got rc 0: Success MSGB: L3 is undefined -Took message from DCCH queue: L2 header size 23, L3 size 0, SAP 0x1000000, 0/0, Link 0x03 +Took message from DCCH queue: L2 header size 23, L3 size 0, SAP 0x1000000, 0/0, Link 0x03, FN 0 Message: [L2]> 0d 21 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
=== I test SAPI0/SAPI3 prioritization === @@ -131,10 +131,10 @@ bts_to_ms_dummy_tx_cb: MS->BTS(us) message 22 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 +Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x00, FN 0 Message: [L2]> 01 73 35 [L3]> 06 27 07 03 50 58 92 05 f4 44 59 ba 63 2b 2b 2b 2b 2b 2b 2b 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 0x03 +Took message from DCCH queue: L2 header size 3, L3 size 20, SAP 0x1000000, 0/0, Link 0x03, FN 0 Message: [L2]> 0f 3f 01 [L3]> 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b Checking the func=UA message: OK Checking the func=SABM message: OK