fixeria has uploaded this change for review. ( 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 include/osmocom/gprs/rlcmac/gprs_rlcmac.h M src/rlcmac/ts_44_018.c M src/rlcmac/ts_44_060.c 3 files changed, 55 insertions(+), 12 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/95/29195/1
diff --git a/include/osmocom/gprs/rlcmac/gprs_rlcmac.h b/include/osmocom/gprs/rlcmac/gprs_rlcmac.h index f83a3f9..75128a2 100644 --- a/include/osmocom/gprs/rlcmac/gprs_rlcmac.h +++ b/include/osmocom/gprs/rlcmac/gprs_rlcmac.h @@ -5376,3 +5376,6 @@ int osmo_gprs_rlcmac_decode_ms_ra_cap(struct bitvec *vector, MS_Radio_Access_capability_t * data); 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); diff --git a/src/rlcmac/ts_44_018.c b/src/rlcmac/ts_44_018.c index 10ff872..eb70f14 100644 --- a/src/rlcmac/ts_44_018.c +++ b/src/rlcmac/ts_44_018.c @@ -30,6 +30,14 @@ #include <osmocom/csn1/csn1.h> #include <osmocom/gprs/rlcmac/gprs_rlcmac.h>
+/* FIXME: configurable logging category */ +#define DRLCMACDATA DLGLOBAL + +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 +400,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 +439,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 +607,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(DRLCMACDATA, 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 aa12abc..59d2d44 100644 --- a/src/rlcmac/ts_44_060.c +++ b/src/rlcmac/ts_44_060.c @@ -55,7 +55,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), @@ -243,7 +243,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), @@ -278,7 +278,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), @@ -305,7 +305,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),