fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/29195 )
Change subject: rlcmac: add osmo_gprs_rlcmac_decode_si13ro() ......................................................................
rlcmac: add osmo_gprs_rlcmac_decode_si13ro()
Change-Id: Ic8446509ef474b8496e5557aab3d2a9e94e11897 --- M configure.ac M include/osmocom/gprs/rlcmac/gprs_rlcmac.h M src/rlcmac/ts_44_018.c M src/rlcmac/ts_44_060.c M tests/Makefile.am M tests/testsuite.at A tests/ts_44_018/Makefile.am A tests/ts_44_018/ts_44_018_test.c A tests/ts_44_018/ts_44_018_test.err A tests/ts_44_018/ts_44_018_test.ok 10 files changed, 189 insertions(+), 12 deletions(-)
Approvals: fixeria: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved
diff --git a/configure.ac b/configure.ac index 0606cf5..0275362 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,7 @@ src/csn1/Makefile src/rlcmac/Makefile tests/Makefile + tests/ts_44_018/Makefile tests/ts_44_060/Makefile Makefile contrib/libosmo-gprs.spec]) diff --git a/include/osmocom/gprs/rlcmac/gprs_rlcmac.h b/include/osmocom/gprs/rlcmac/gprs_rlcmac.h index 7163b7e..81410ef 100644 --- a/include/osmocom/gprs/rlcmac/gprs_rlcmac.h +++ b/include/osmocom/gprs/rlcmac/gprs_rlcmac.h @@ -5377,4 +5377,7 @@ int osmo_gprs_rlcmac_encode_ms_ra_cap(struct bitvec *vector, MS_Radio_Access_capability_t * data); int osmo_gprs_rlcmac_decode_egprs_pkt_ch_req(guint16 ra, EGPRS_PacketChannelRequest_t *data);
+int osmo_gprs_rlcmac_decode_si13ro(SI_13_t *storage, + const uint8_t *data, size_t data_len); + void osmo_gprs_rlcmac_set_log_cat(int cat); diff --git a/src/rlcmac/ts_44_018.c b/src/rlcmac/ts_44_018.c index 10ff872..c9e63e7 100644 --- a/src/rlcmac/ts_44_018.c +++ b/src/rlcmac/ts_44_018.c @@ -30,6 +30,13 @@ #include <osmocom/csn1/csn1.h> #include <osmocom/gprs/rlcmac/gprs_rlcmac.h>
+extern int g_log_cat; + +CSN_DESCR_EXTERN(GPRS_Mobile_Allocation_t); +CSN_DESCR_EXTERN(PBCCH_Not_present_t); +CSN_DESCR_EXTERN(PBCCH_present_t); +CSN_DESCR_EXTERN(StartingTime_t); + /*<P1 Rest Octets>*/ /*<P2 Rest Octets>*/ #if 0 @@ -392,34 +399,27 @@ CSN_DESCR_END (IA_PacketAssignment_t) #endif
-#if 0 static const CSN_DESCR_BEGIN(SI13_AdditionsR6) M_NEXT_EXIST (SI13_AdditionsR6, Exist_LB_MS_TXPWR_MAX_CCH, 1), M_UINT (SI13_AdditionsR6, LB_MS_TXPWR_MAX_CCH, 5), M_UINT (SI13_AdditionsR6, SI2n_SUPPORT, 2), CSN_DESCR_END (SI13_AdditionsR6) -#endif
-#if 0 static const CSN_DESCR_BEGIN(SI13_AdditionsR4) M_UINT (SI13_AdditionsR4, SI_STATUS_IND, 1), M_NEXT_EXIST_OR_NULL_LH (SI13_AdditionsR4, Exist_AdditionsR6, 1), M_TYPE (SI13_AdditionsR4, AdditionsR6, SI13_AdditionsR6), CSN_DESCR_END (SI13_AdditionsR4) -#endif
-#if 0 static const CSN_DESCR_BEGIN(SI13_AdditionR99) M_UINT (SI13_AdditionR99, SGSNR, 1), M_NEXT_EXIST_OR_NULL_LH (SI13_AdditionR99, Exist_AdditionsR4, 1), M_TYPE (SI13_AdditionR99, AdditionsR4, SI13_AdditionsR4), CSN_DESCR_END (SI13_AdditionR99) -#endif
-#if 0 static const CSN_DESCR_BEGIN (SI_13_t) M_THIS_EXIST_LH (SI_13_t), @@ -438,7 +438,6 @@ M_NEXT_EXIST_OR_NULL_LH(SI_13_t, Exist_AdditionsR99, 1), M_TYPE (SI_13_t, AdditionsR99, SI13_AdditionR99), CSN_DESCR_END (SI_13_t) -#endif
/* Enhanced Measurement Report */ #if 0 @@ -607,3 +606,43 @@ M_VAR_TARRAY (EnhancedMeasurementReport_t, REPORTING_QUANTITY_Instances, REPORTING_QUANTITY_Instance_t, Count_REPORTING_QUANTITY_Instances), CSN_DESCR_END (EnhancedMeasurementReport_t) #endif + +static int _osmo_gprs_rlcmac_decode(void *storage, + const CSN_DESCR *descr, + const char *descr_name, + const uint8_t *data, + size_t data_len) +{ + unsigned int readIndex = 0; + csnStream_t ar; + int ret; + + osmo_csn1_stream_init(&ar, 0, 8 * data_len); + + struct bitvec bv = { + .data = (uint8_t *)data, + .data_len = data_len, + }; + + LOGP(DLCSN1, LOGL_INFO, "osmo_csn1_stream_decode (%s): ", descr_name); + ret = osmo_csn1_stream_decode(&ar, descr, &bv, &readIndex, storage); + LOGPC(DLCSN1, LOGL_INFO, "\n"); + + if (ret > 0) { + LOGP(g_log_cat, LOGL_NOTICE, + "%s: %d remaining bits unhandled by decoder\n", + descr_name, ret); + ret = 0; + } + + return ret; +} + +int osmo_gprs_rlcmac_decode_si13ro(SI_13_t *storage, + const uint8_t *data, size_t data_len) +{ + return _osmo_gprs_rlcmac_decode(storage, + CSNDESCR(SI_13_t), + "SI13 Rest Octets", + data, data_len); +} diff --git a/src/rlcmac/ts_44_060.c b/src/rlcmac/ts_44_060.c index e07d737..e557ae8 100644 --- a/src/rlcmac/ts_44_060.c +++ b/src/rlcmac/ts_44_060.c @@ -54,7 +54,7 @@ M_UINT (PLMN_t, MNC1, 4), CSN_DESCR_END (PLMN_t)
-static const +const CSN_DESCR_BEGIN(StartingTime_t) M_UINT (StartingTime_t, N32, 5), M_UINT (StartingTime_t, N51, 6), @@ -242,7 +242,7 @@ M_REC_ARRAY (ARFCN_index_list_t, ARFCN_INDEX, ElementsOf_ARFCN_INDEX, 6), CSN_DESCR_END (ARFCN_index_list_t)
-static const +const CSN_DESCR_BEGIN(GPRS_Mobile_Allocation_t) M_UINT (GPRS_Mobile_Allocation_t, HSN, 6), M_REC_ARRAY (GPRS_Mobile_Allocation_t, RFL_NUMBER, ElementsOf_RFL_NUMBER, 4), @@ -277,7 +277,7 @@ M_TYPE (GPRS_Cell_Options_t, Extension_Bits, Extension_Bits_t), CSN_DESCR_END (GPRS_Cell_Options_t)
-static const +const CSN_DESCR_BEGIN(PBCCH_Not_present_t) M_UINT (PBCCH_Not_present_t, RAC, 8), M_UINT (PBCCH_Not_present_t, SPGC_CCCH_SUP, 1), @@ -304,7 +304,7 @@ M_CHOICE (PBCCH_Description_t, UnionType, SI13_PBCCH_Description_Channel, ElementsOf(SI13_PBCCH_Description_Channel)), CSN_DESCR_END (PBCCH_Description_t)
-static const +const CSN_DESCR_BEGIN(PBCCH_present_t) M_UINT (PBCCH_present_t, PSI1_REPEAT_PERIOD, 4), M_TYPE (PBCCH_present_t, PBCCH_Description, PBCCH_Description_t), diff --git a/tests/Makefile.am b/tests/Makefile.am index bcde16f..f4b4dbf 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,5 @@ SUBDIRS = \ + ts_44_018 \ ts_44_060 \ $(NULL)
diff --git a/tests/testsuite.at b/tests/testsuite.at index 1aee874..53e5ab2 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -1,6 +1,13 @@ AT_INIT AT_BANNER([Regression tests])
+AT_SETUP([rlcmac/ts_44_018]) +AT_KEYWORDS([rlcmac ts_44_018]) +cat $abs_srcdir/ts_44_018/ts_44_018_test.ok > expout +cat $abs_srcdir/ts_44_018/ts_44_018_test.err > experr +AT_CHECK([$abs_top_builddir/tests/ts_44_018/ts_44_018_test], [0], [expout], [experr]) +AT_CLEANUP + AT_SETUP([rlcmac/ts_44_060]) AT_KEYWORDS([rlcmac ts_44_060]) cat $abs_srcdir/ts_44_060/ts_44_060_test.ok > expout diff --git a/tests/ts_44_018/Makefile.am b/tests/ts_44_018/Makefile.am new file mode 100644 index 0000000..13c0afa --- /dev/null +++ b/tests/ts_44_018/Makefile.am @@ -0,0 +1,25 @@ +AM_CFLAGS = \ + -Wall \ + $(LIBOSMOCORE_CFLAGS) \ + -I$(top_srcdir)/include/ \ + $(NULL) + +AM_LDFLAGS = \ + -no-install \ + $(NULL) + +check_PROGRAMS = \ + ts_44_018_test \ + $(NULL) + +EXTRA_DIST = \ + ts_44_018_test.ok \ + ts_44_018_test.err \ + $(NULL) + +ts_44_018_test_SOURCES = ts_44_018_test.c +ts_44_018_test_LDADD = \ + $(LIBOSMOCORE_LIBS) \ + $(top_builddir)/src/csn1/libosmo-csn1.la \ + $(top_builddir)/src/rlcmac/libosmo-gprs-rlcmac.la \ + $(NULL) diff --git a/tests/ts_44_018/ts_44_018_test.c b/tests/ts_44_018/ts_44_018_test.c new file mode 100644 index 0000000..dd6f4f7 --- /dev/null +++ b/tests/ts_44_018/ts_44_018_test.c @@ -0,0 +1,80 @@ +/* RLCMACTest.c + * + * Copyright (C) 2011 Ivan Klyuchnikov + * Contributions by sysmocom - s.f.m.c. GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <stdint.h> +#include <stdio.h> + +#include <osmocom/core/application.h> +#include <osmocom/core/logging.h> +#include <osmocom/core/utils.h> +#include <osmocom/core/msgb.h> + +#include <osmocom/csn1/csn1.h> +#include <osmocom/gsm/protocol/gsm_04_08.h> +#include <osmocom/gprs/rlcmac/gprs_rlcmac.h> + +static void *tall_ctx = NULL; + +static void test_si13ro(void) +{ + printf("*** %s ***\n", __func__); + + static const char *testData[] = { + "9000185a6fc9f2b5304208eb2b2b2b2b2b2b2b2b", // osmo-pcu, with EGPRS + "a000185a6fc9f14608411b2b2b2b2b2b2b2b2b2b", // osmo-pcu, without EGPRS + "90005847eb4a93e51a218a16ab2b2b2b2b2b2b2b", // real network (Iran, Tehran) + "90005847eb4a93e50a218a162b2b2b2b2b2b2b2b", // real network (Turkey, Istanbul) + "b0005840654a92b53c2942db2b2b2b2b2b2b2b2b", // real network (Turkey, Trabzon) + }; + + for (unsigned int i = 0; i < ARRAY_SIZE(testData); i++) { + uint8_t buf[GSM_MACBLOCK_LEN - 3]; + SI_13_t si13ro = { 0 }; + int rc; + + printf("testData[%d] = %s\n", i, testData[i]); + + rc = osmo_hexparse(testData[i], &buf[0], sizeof(buf)); + OSMO_ASSERT(rc == sizeof(buf)); + + rc = osmo_gprs_rlcmac_decode_si13ro(&si13ro, &buf[0], sizeof(buf)); + printf("osmo_gprs_rlcmac_decode_si13ro() returns %d\n", rc); + } +} + +static const struct log_info_cat test_log_categories[] = { }; +static const struct log_info test_log_info = { + .cat = test_log_categories, + .num_cat = ARRAY_SIZE(test_log_categories), +}; + +int main(int argc, char *argv[]) +{ + tall_ctx = talloc_named_const(NULL, 1, __FILE__); + + osmo_init_logging2(tall_ctx, &test_log_info); + log_parse_category_mask(osmo_stderr_target, "DLGLOBAL,1:DLCSN1,1:"); + + log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE); + log_set_print_category_hex(osmo_stderr_target, 0); + log_set_print_category(osmo_stderr_target, 1); + log_set_print_level(osmo_stderr_target, 1); + log_set_use_color(osmo_stderr_target, 0); + + test_si13ro(); + + talloc_free(tall_ctx); +} diff --git a/tests/ts_44_018/ts_44_018_test.err b/tests/ts_44_018/ts_44_018_test.err new file mode 100644 index 0000000..ebea6e0 --- /dev/null +++ b/tests/ts_44_018/ts_44_018_test.err @@ -0,0 +1,10 @@ +DLCSN1 INFO osmo_csn1_stream_decode (SI13 Rest Octets): Exist = 1 | BCCH_CHANGE_MARK = 1 | SI_CHANGE_FIELD = 0 | Exist_MA = 0 | u.PBCCH_Not_present = 0 | : u.PBCCH_Not_present | RAC = 0 | SPGC_CCCH_SUP = 0 | PRIORITY_ACCESS_THR = 6 | NETWORK_CONTROL_ORDER = 0 | : GPRS_Cell_Options | NMO = 1 | T3168 = 3 | T3192 = 2 | DRX_TIMER_MAX = 3 | ACCESS_BURST_TYPE = 0 | CONTROL_ACK_TYPE = 1 | BS_CV_MAX = 15 | Exist_PAN = 1 | PAN_DEC = 1 | PAN_INC = 1 | PAN_MAX = 7 | Exist_Extension_Bits = 1 | : Extension_Bits | extension_length = 11 | Extension_Info = 212 | Extension_Info = 6 | : End Extension_Bits | : End GPRS_Cell_Options | : GPRS_Power_Control_Parameters | ALPHA = 0 | T_AVG_W = 16 | T_AVG_T = 16 | PC_MEAS_CHAN = 0 | N_AVG_I = 8 | : End GPRS_Power_Control_Parameters | : End u.PBCCH_Not_present | Exist_AdditionsR99 = 1 | : AdditionsR99 | SGSNR = 1 | Exist_AdditionsR4 = 0 | : End AdditionsR99 | +DLGLOBAL NOTICE SI13 Rest Octets: 69 remaining bits unhandled by decoder +DLCSN1 INFO osmo_csn1_stream_decode (SI13 Rest Octets): Exist = 1 | BCCH_CHANGE_MARK = 2 | SI_CHANGE_FIELD = 0 | Exist_MA = 0 | u.PBCCH_Not_present = 0 | : u.PBCCH_Not_present | RAC = 0 | SPGC_CCCH_SUP = 0 | PRIORITY_ACCESS_THR = 6 | NETWORK_CONTROL_ORDER = 0 | : GPRS_Cell_Options | NMO = 1 | T3168 = 3 | T3192 = 2 | DRX_TIMER_MAX = 3 | ACCESS_BURST_TYPE = 0 | CONTROL_ACK_TYPE = 1 | BS_CV_MAX = 15 | Exist_PAN = 1 | PAN_DEC = 1 | PAN_INC = 1 | PAN_MAX = 7 | Exist_Extension_Bits = 1 | : Extension_Bits | extension_length = 6 | Extension_Info = 6 | : End Extension_Bits | : End GPRS_Cell_Options | : GPRS_Power_Control_Parameters | ALPHA = 0 | T_AVG_W = 16 | T_AVG_T = 16 | PC_MEAS_CHAN = 0 | N_AVG_I = 8 | : End GPRS_Power_Control_Parameters | : End u.PBCCH_Not_present | Exist_AdditionsR99 = 1 | : AdditionsR99 | SGSNR = 1 | Exist_AdditionsR4 = 0 | : End AdditionsR99 | +DLGLOBAL NOTICE SI13 Rest Octets: 74 remaining bits unhandled by decoder +DLCSN1 INFO osmo_csn1_stream_decode (SI13 Rest Octets): Exist = 1 | BCCH_CHANGE_MARK = 1 | SI_CHANGE_FIELD = 0 | Exist_MA = 0 | u.PBCCH_Not_present = 0 | : u.PBCCH_Not_present | RAC = 1 | SPGC_CCCH_SUP = 0 | PRIORITY_ACCESS_THR = 6 | NETWORK_CONTROL_ORDER = 0 | : GPRS_Cell_Options | NMO = 1 | T3168 = 0 | T3192 = 7 | DRX_TIMER_MAX = 7 | ACCESS_BURST_TYPE = 0 | CONTROL_ACK_TYPE = 1 | BS_CV_MAX = 6 | Exist_PAN = 1 | PAN_DEC = 1 | PAN_INC = 2 | PAN_MAX = 4 | Exist_Extension_Bits = 1 | : Extension_Bits | extension_length = 16 | Extension_Info = 148 | Extension_Info = 104 | : End Extension_Bits | : End GPRS_Cell_Options | : GPRS_Power_Control_Parameters | ALPHA = 8 | T_AVG_W = 12 | T_AVG_T = 10 | PC_MEAS_CHAN = 0 | N_AVG_I = 2 | : End GPRS_Power_Control_Parameters | : End u.PBCCH_Not_present | Exist_AdditionsR99 = 1 | : AdditionsR99 | SGSNR = 1 | Exist_AdditionsR4 = 1 | : AdditionsR4 | SI_STATUS_IND = 1 | Exist_AdditionsR6 = 0 | : End AdditionsR4 | : End AdditionsR99 | +DLGLOBAL NOTICE SI13 Rest Octets: 62 remaining bits unhandled by decoder +DLCSN1 INFO osmo_csn1_stream_decode (SI13 Rest Octets): Exist = 1 | BCCH_CHANGE_MARK = 1 | SI_CHANGE_FIELD = 0 | Exist_MA = 0 | u.PBCCH_Not_present = 0 | : u.PBCCH_Not_present | RAC = 1 | SPGC_CCCH_SUP = 0 | PRIORITY_ACCESS_THR = 6 | NETWORK_CONTROL_ORDER = 0 | : GPRS_Cell_Options | NMO = 1 | T3168 = 0 | T3192 = 7 | DRX_TIMER_MAX = 7 | ACCESS_BURST_TYPE = 0 | CONTROL_ACK_TYPE = 1 | BS_CV_MAX = 6 | Exist_PAN = 1 | PAN_DEC = 1 | PAN_INC = 2 | PAN_MAX = 4 | Exist_Extension_Bits = 1 | : Extension_Bits | extension_length = 16 | Extension_Info = 148 | Extension_Info = 40 | : End Extension_Bits | : End GPRS_Cell_Options | : GPRS_Power_Control_Parameters | ALPHA = 8 | T_AVG_W = 12 | T_AVG_T = 10 | PC_MEAS_CHAN = 0 | N_AVG_I = 2 | : End GPRS_Power_Control_Parameters | : End u.PBCCH_Not_present | Exist_AdditionsR99 = 1 | : AdditionsR99 | SGSNR = 1 | Exist_AdditionsR4 = 1 | : AdditionsR4 | SI_STATUS_IND = 0 | Exist_AdditionsR6 = 0 | : End AdditionsR4 | : End AdditionsR99 | +DLGLOBAL NOTICE SI13 Rest Octets: 62 remaining bits unhandled by decoder +DLCSN1 INFO osmo_csn1_stream_decode (SI13 Rest Octets): Exist = 1 | BCCH_CHANGE_MARK = 3 | SI_CHANGE_FIELD = 0 | Exist_MA = 0 | u.PBCCH_Not_present = 0 | : u.PBCCH_Not_present | RAC = 1 | SPGC_CCCH_SUP = 0 | PRIORITY_ACCESS_THR = 6 | NETWORK_CONTROL_ORDER = 0 | : GPRS_Cell_Options | NMO = 1 | T3168 = 0 | T3192 = 0 | DRX_TIMER_MAX = 3 | ACCESS_BURST_TYPE = 0 | CONTROL_ACK_TYPE = 0 | BS_CV_MAX = 10 | Exist_PAN = 1 | PAN_DEC = 1 | PAN_INC = 2 | PAN_MAX = 4 | Exist_Extension_Bits = 1 | : Extension_Bits | extension_length = 11 | Extension_Info = 212 | Extension_Info = 7 | : End Extension_Bits | : End GPRS_Cell_Options | : GPRS_Power_Control_Parameters | ALPHA = 8 | T_AVG_W = 10 | T_AVG_T = 10 | PC_MEAS_CHAN = 0 | N_AVG_I = 2 | : End GPRS_Power_Control_Parameters | : End u.PBCCH_Not_present | Exist_AdditionsR99 = 1 | : AdditionsR99 | SGSNR = 1 | Exist_AdditionsR4 = 1 | : AdditionsR4 | SI_STATUS_IND = 1 | Exist_AdditionsR6 = 0 | : End AdditionsR4 | : End AdditionsR99 | +DLGLOBAL NOTICE SI13 Rest Octets: 67 remaining bits unhandled by decoder diff --git a/tests/ts_44_018/ts_44_018_test.ok b/tests/ts_44_018/ts_44_018_test.ok new file mode 100644 index 0000000..864e03c --- /dev/null +++ b/tests/ts_44_018/ts_44_018_test.ok @@ -0,0 +1,11 @@ +*** test_si13ro *** +testData[0] = 9000185a6fc9f2b5304208eb2b2b2b2b2b2b2b2b +osmo_gprs_rlcmac_decode_si13ro() returns 0 +testData[1] = a000185a6fc9f14608411b2b2b2b2b2b2b2b2b2b +osmo_gprs_rlcmac_decode_si13ro() returns 0 +testData[2] = 90005847eb4a93e51a218a16ab2b2b2b2b2b2b2b +osmo_gprs_rlcmac_decode_si13ro() returns 0 +testData[3] = 90005847eb4a93e50a218a162b2b2b2b2b2b2b2b +osmo_gprs_rlcmac_decode_si13ro() returns 0 +testData[4] = b0005840654a92b53c2942db2b2b2b2b2b2b2b2b +osmo_gprs_rlcmac_decode_si13ro() returns 0