pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32972 )
Change subject: rlcmac: Add APIs to decode P1/P2 Rest Octets ......................................................................
rlcmac: Add APIs to decode P1/P2 Rest Octets
Change-Id: I59c6723d969880a4481e3b86a172d59f0edeb1e4 --- M include/osmocom/gprs/rlcmac/csn1_defs.h M src/rlcmac/csn1_ts_44_018.c M tests/rlcmac/csn1_ts_44_018_test.c M tests/rlcmac/csn1_ts_44_018_test.err M tests/rlcmac/csn1_ts_44_018_test.ok 5 files changed, 72 insertions(+), 20 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved
diff --git a/include/osmocom/gprs/rlcmac/csn1_defs.h b/include/osmocom/gprs/rlcmac/csn1_defs.h index 5e4b599..f4c7870 100644 --- a/include/osmocom/gprs/rlcmac/csn1_defs.h +++ b/include/osmocom/gprs/rlcmac/csn1_defs.h @@ -5365,3 +5365,7 @@ const uint8_t *data, size_t data_len); int osmo_gprs_rlcmac_decode_imm_ass_ro(IA_RestOctets_t *storage, const uint8_t *data, size_t data_len); +int osmo_gprs_rlcmac_decode_p1ro(P1_Rest_Octets_t *storage, + const uint8_t *data, size_t data_len); +int osmo_gprs_rlcmac_decode_p2ro(P2_Rest_Octets_t *storage, + const uint8_t *data, size_t data_len); diff --git a/src/rlcmac/csn1_ts_44_018.c b/src/rlcmac/csn1_ts_44_018.c index cc62c62..40275f4 100644 --- a/src/rlcmac/csn1_ts_44_018.c +++ b/src/rlcmac/csn1_ts_44_018.c @@ -35,40 +35,31 @@
/*<P1 Rest Octets>*/ /*<P2 Rest Octets>*/ -#if 0 static const CSN_DESCR_BEGIN(MobileAllocationIE_t) M_UINT (MobileAllocationIE_t, Length, 8), M_VAR_ARRAY (MobileAllocationIE_t, MA, Length, 0), CSN_DESCR_END (MobileAllocationIE_t) -#endif
-#if 0 static const CSN_DESCR_BEGIN(SingleRFChannel_t) M_UINT (SingleRFChannel_t, spare, 2), M_UINT (SingleRFChannel_t, ARFCN, 10), CSN_DESCR_END (SingleRFChannel_t) -#endif
-#if 0 static const CSN_DESCR_BEGIN(RFHoppingChannel_t) M_UINT (RFHoppingChannel_t, MAIO, 6), M_UINT (RFHoppingChannel_t, HSN, 6), CSN_DESCR_END (RFHoppingChannel_t) -#endif
-#if 0 static const CSN_DESCR_BEGIN(MobileAllocation_or_Frequency_Short_List_t) M_UNION (MobileAllocation_or_Frequency_Short_List_t, 2), M_BITMAP (MobileAllocation_or_Frequency_Short_List_t, u.Frequency_Short_List, 64), M_TYPE (MobileAllocation_or_Frequency_Short_List_t, u.MA, MobileAllocationIE_t), CSN_DESCR_END (MobileAllocation_or_Frequency_Short_List_t) -#endif
-#if 0 static const CSN_DESCR_BEGIN(Channel_Description_t) M_UINT (Channel_Description_t, Channel_type_and_TDMA_offset, 5), @@ -79,9 +70,7 @@ M_TYPE (Channel_Description_t, u.SingleRFChannel, SingleRFChannel_t), M_TYPE (Channel_Description_t, u.RFHoppingChannel, RFHoppingChannel_t), CSN_DESCR_END(Channel_Description_t) -#endif
-#if 0 static const CSN_DESCR_BEGIN(Group_Channel_Description_t) M_TYPE (Group_Channel_Description_t, Channel_Description, Channel_Description_t), @@ -89,9 +78,7 @@ M_NEXT_EXIST (Group_Channel_Description_t, Exist_Hopping, 1), M_TYPE (Group_Channel_Description_t, MA_or_Frequency_Short_List, MobileAllocation_or_Frequency_Short_List_t), CSN_DESCR_END (Group_Channel_Description_t) -#endif
-#if 0 static const CSN_DESCR_BEGIN(Group_Call_Reference_t) M_UINT (Group_Call_Reference_t, value, 27), @@ -100,9 +87,7 @@ M_UINT (Group_Call_Reference_t, call_priority, 3), M_UINT (Group_Call_Reference_t, Ciphering_information, 4), CSN_DESCR_END (Group_Call_Reference_t) -#endif
-#if 0 static const CSN_DESCR_BEGIN(Group_Call_information_t) M_TYPE (Group_Call_information_t, Group_Call_Reference, Group_Call_Reference_t), @@ -110,9 +95,7 @@ M_NEXT_EXIST (Group_Call_information_t, Exist_Group_Channel_Description, 1), M_TYPE (Group_Call_information_t, Group_Channel_Description, Group_Channel_Description_t), CSN_DESCR_END (Group_Call_information_t) -#endif
-#if 0 static const CSN_DESCR_BEGIN (P1_Rest_Octets_t) M_NEXT_EXIST_LH(P1_Rest_Octets_t, Exist_NLN_PCH_and_NLN_status, 2), @@ -131,9 +114,7 @@ M_UINT_LH (P1_Rest_Octets_t, Packet_Page_Indication_1, 1), M_UINT_LH (P1_Rest_Octets_t, Packet_Page_Indication_2, 1), CSN_DESCR_END (P1_Rest_Octets_t) -#endif
-#if 0 static const CSN_DESCR_BEGIN (P2_Rest_Octets_t) M_NEXT_EXIST_LH(P2_Rest_Octets_t, Exist_CN3, 1), @@ -154,7 +135,6 @@
M_UINT_LH (P2_Rest_Octets_t, Packet_Page_Indication_3, 1), CSN_DESCR_END (P2_Rest_Octets_t) -#endif
static const CSN_DESCR_BEGIN(DynamicAllocation_t) @@ -672,3 +652,21 @@ "IA Rest Octets", data, data_len); } + +int osmo_gprs_rlcmac_decode_p1ro(P1_Rest_Octets_t *storage, + const uint8_t *data, size_t data_len) +{ + return _osmo_gprs_rlcmac_decode(storage, + CSNDESCR(P1_Rest_Octets_t), + "P1 Rest Octets", + data, data_len); +} + +int osmo_gprs_rlcmac_decode_p2ro(P2_Rest_Octets_t *storage, + const uint8_t *data, size_t data_len) +{ + return _osmo_gprs_rlcmac_decode(storage, + CSNDESCR(P2_Rest_Octets_t), + "P2 Rest Octets", + data, data_len); +} diff --git a/tests/rlcmac/csn1_ts_44_018_test.c b/tests/rlcmac/csn1_ts_44_018_test.c index bef4e8b..e62df0a 100644 --- a/tests/rlcmac/csn1_ts_44_018_test.c +++ b/tests/rlcmac/csn1_ts_44_018_test.c @@ -86,6 +86,40 @@ printf("\n"); }
+static void test_p1ro(void) +{ + printf("*** %s ***\n", __func__); + + static const char * const testData[] = { + /* P1 Rest Octets + * L... .... = NLN(PCH): Not Present + * .L.. .... = Priority 1: Not Present + * ..L. .... = Priority 2: Not Present + * ...L .... = Group Call Information: Not Present + * .... H... = Packet Page Indication 1: For GPRS + * .... .H.. = Packet Page Indication 2: For GPRS + * Padding Bits: default padding + */ + "272b2b2b2b2b2b2b2b2b", + }; + + for (unsigned int i = 0; i < ARRAY_SIZE(testData); i++) { + uint8_t buf[17]; + P1_Rest_Octets_t p1ro = { 0 }; + int rc; + + printf("testData[%d] = %s\n", i, testData[i]); + + rc = osmo_hexparse(testData[i], &buf[0], sizeof(buf)); + OSMO_ASSERT(rc >= 0); + + rc = osmo_gprs_rlcmac_decode_p1ro(&p1ro, &buf[0], rc); + printf("osmo_gprs_rlcmac_decode_p1ro() returns %d\n", rc); + } + + printf("\n"); +} + static const struct log_info_cat test_log_categories[] = { }; static const struct log_info test_log_info = { .cat = test_log_categories, @@ -107,6 +141,7 @@
test_si13ro(); test_imm_ass_ro(); + test_p1ro();
talloc_free(tall_ctx); } diff --git a/tests/rlcmac/csn1_ts_44_018_test.err b/tests/rlcmac/csn1_ts_44_018_test.err index 61d77c8..0f3d92b 100644 --- a/tests/rlcmac/csn1_ts_44_018_test.err +++ b/tests/rlcmac/csn1_ts_44_018_test.err @@ -8,3 +8,5 @@ DLCSN1 INFO osmo_csn1_stream_decode (IA Rest Octets): u.hh = 3 | : u.hh | u.UplinkDownlinkAssignment = 0 | : u.UplinkDownlinkAssignment | ul_dl.Packet_Downlink_ImmAssignment = 1 | : ul_dl.Packet_Downlink_ImmAssignment | TLLI = 0xd6e1ae5a | Exist_TFI_to_TA_VALID = 1 | TFI_ASSIGNMENT = 3 | RLC_MODE = 0 | Exist_ALPHA = 0 | GAMMA = 15 | POLLING = 0 | TA_VALID = 0 | Exist_TIMING_ADVANCE_INDEX = 0 | Exist_TBF_STARTING_TIME = 0 | Exist_P0_PR_MODE = 1 | P0 = 0 | BTS_PWR_CTRL_MODE = 0 | PR_MODE = 1 | Exist_AdditionsR99 = 0 | : End ul_dl.Packet_Downlink_ImmAssignment | : End u.UplinkDownlinkAssignment | Exist_AdditionsR10 = 0 | Exist_AdditionsR13 = 0 | : End u.hh | Padding = 0|86|86|-22| DLCSN1 INFO osmo_csn1_stream_decode (IA Rest Octets): u.lh = 1 | : u.lh | lh0x = 0 | : lh0x | u.EGPRS_PktUlAss = 0 | : u.EGPRS_PktUlAss | ExtendedRA = 12 | AccessTechnologyType = Exist | AccessTechnologyType = 0 | AccessTechnologyType = Exist | AccessTechnologyType = 3 | AccessTechnologyType = 0 | Access.OnePhaseAccess = 1 | : Access.OnePhaseAccess | TFI_ASSIGNMENT = 7 | POLLING = 0 | Allocation.DynamicAllocation = 0 | : Allocation.DynamicAllocation | USF = 3 | USF_GRANULARITY = 0 | Exist_P0_PR_MODE = 0 | : End Allocation.DynamicAllocation | EGPRS_CHANNEL_CODING_COMMAND = 2 | TLLI_BLOCK_CHANNEL_CODING = 1 | Exist_BEP_PERIOD2 = 1 | BEP_PERIOD2 = 5 | RESEGMENT = 1 | EGPRS_WindowSize = 4 | Exist_ALPHA = 0 | GAMMA = 13 | Exist_TIMING_ADVANCE_INDEX = 1 | TIMING_ADVANCE_INDEX = 0 | Exist_TBF_STARTING_TIME = 0 | : End Access.OnePhaseAccess | : End u.EGPRS_PktUlAss | : End lh0x | : AdditionsR13 | Exist_AdditionsR13 = 0 | : End AdditionsR13 | : End u.lh | Padding = 0|172|172|-22| DLCSN1 INFO osmo_csn1_stream_decode (IA Rest Octets): u.lh = 1 | : u.lh | lh0x = 0 | : lh0x | u.EGPRS_PktUlAss = 0 | : u.EGPRS_PktUlAss | ExtendedRA = 8 | AccessTechnologyType = Exist | AccessTechnologyType = 0 | AccessTechnologyType = Exist | AccessTechnologyType = 3 | AccessTechnologyType = 0 | Access.TwoPhaseAccess = 0 | : Access.TwoPhaseAccess | Exist_ALPHA = 0 | GAMMA = 13 | : TBF_STARTING_TIME | N32 = 20 | N51 = 45 | N26 = 0 | : End TBF_STARTING_TIME | NR_OF_RADIO_BLOCKS_ALLOCATED = 1 | Exist_P0_BTS_PWR_CTRL_PR_MODE = 0 | : End Access.TwoPhaseAccess | : End u.EGPRS_PktUlAss | : End lh0x | : AdditionsR13 | Exist_AdditionsR13 = 0 | : End AdditionsR13 | : End u.lh | Padding = 0|86|86|86|86|-22| +DLCSN1 INFO osmo_csn1_stream_decode (P1 Rest Octets): Exist_NLN_PCH_and_NLN_status = 0 | Exist_Priority1 = 0 | Exist_Priority2 = 0 | Exist_Group_Call_information = 0 | Packet_Page_Indication_1 = 1 | Packet_Page_Indication_2 = 1 | +DLGLOBAL NOTICE P1 Rest Octets: 74 remaining bits unhandled by decoder diff --git a/tests/rlcmac/csn1_ts_44_018_test.ok b/tests/rlcmac/csn1_ts_44_018_test.ok index 6847f07..d720061 100644 --- a/tests/rlcmac/csn1_ts_44_018_test.ok +++ b/tests/rlcmac/csn1_ts_44_018_test.ok @@ -22,3 +22,7 @@ testData[4] = 444261b4b40b2b2b2b2b2b osmo_gprs_rlcmac_decode_imm_ass_ro() returns 0
+*** test_p1ro *** +testData[0] = 272b2b2b2b2b2b2b2b2b +osmo_gprs_rlcmac_decode_p1ro() returns 0 +