diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h index 1380a6cba..b920e3be0 100644 --- a/openbsc/include/openbsc/gsm_data_shared.h +++ b/openbsc/include/openbsc/gsm_data_shared.h @@ -535,10 +535,13 @@ struct gsm_bts_model { struct tlv_definition nm_att_tlvdef; + /* features of a given BTS model set via gsm_bts_model_register() locally */ struct bitvec features; uint8_t _features_data[MAX_BTS_FEATURES/8]; }; +/* N. B: always add new features to the end of the list (right before _NUM_BTS_FEAT) to avoid breaking compatibility + with BTS compiled against earlier version of this header */ enum gsm_bts_features { BTS_FEAT_HSCSD, BTS_FEAT_GPRS, @@ -549,8 +552,11 @@ enum gsm_bts_features { BTS_FEAT_OML_ALERTS, BTS_FEAT_AGCH_PCH_PROP, BTS_FEAT_CBCH, + _NUM_BTS_FEAT }; +extern const struct value_string gsm_bts_features_descs[]; + /* * This keeps track of the paging status of one BTS. It * includes a number of pending requests, a back pointer @@ -682,6 +688,10 @@ struct gsm_bts { char version[MAX_VERSION_LENGTH]; char sub_model[MAX_VERSION_LENGTH]; + /* features of a given BTS set/reported via OML */ + struct bitvec features; + uint8_t _features_data[MAX_BTS_FEATURES/8]; + /* Connected PCU version (if any) */ char pcu_version[MAX_VERSION_LENGTH]; @@ -911,6 +921,18 @@ static inline char *gsm_lchan_name(const struct gsm_lchan *lchan) return lchan->name; } +static inline int gsm_bts_set_feature(struct gsm_bts *bts, enum gsm_bts_features feat) +{ + OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES); + return bitvec_set_bit_pos(&bts->features, feat, 1); +} + +static inline bool gsm_bts_has_feature(const struct gsm_bts *bts, enum gsm_bts_features feat) +{ + OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES); + return bitvec_get_bit_pos(&bts->features, feat); +} + void gsm_abis_mo_reset(struct gsm_abis_mo *mo); struct gsm_abis_mo * diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c index 2c7ea0a94..8830ce144 100644 --- a/openbsc/src/libcommon/gsm_data.c +++ b/openbsc/src/libcommon/gsm_data.c @@ -225,11 +225,13 @@ struct gsm_meas_rep *lchan_next_meas_rep(struct gsm_lchan *lchan) int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum gsm_bts_features feat) { + OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES); return bitvec_set_bit_pos(&model->features, feat, 1); } bool gsm_btsmodel_has_feature(struct gsm_bts_model *model, enum gsm_bts_features feat) { + OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES); return bitvec_get_bit_pos(&model->features, feat); } diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c index f40436342..7743b6902 100644 --- a/openbsc/src/libcommon/gsm_data_shared.c +++ b/openbsc/src/libcommon/gsm_data_shared.c @@ -106,6 +106,19 @@ const char *btstype2str(enum gsm_bts_type type) return get_value_string(bts_type_names, type); } +const struct value_string gsm_bts_features_descs[] = { + { BTS_FEAT_HSCSD, "HSCSD" }, + { BTS_FEAT_GPRS, "GPRS" }, + { BTS_FEAT_EGPRS, "EGPRS" }, + { BTS_FEAT_ECSD, "ECSD" }, + { BTS_FEAT_HOPPING, "Frequency Hopping" }, + { BTS_FEAT_MULTI_TSC, "Multi-TSC" }, + { BTS_FEAT_OML_ALERTS, "OML Alerts" }, + { BTS_FEAT_AGCH_PCH_PROP, "AGCH/PCH proportional allocation" }, + { BTS_FEAT_CBCH, "CBCH" }, + { 0, NULL } +}; + const struct value_string gsm_chreq_descs[] = { { GSM_CHREQ_REASON_EMERG, "emergency call" }, { GSM_CHREQ_REASON_PAG, "answer to paging" }, @@ -343,6 +356,8 @@ struct gsm_bts *gsm_bts_alloc(void *ctx) bts->rach_b_thresh = -1; bts->rach_ldavg_slots = -1; bts->paging.free_chans_need = -1; + bts->features.data = &bts->_features_data[0]; + bts->features.data_len = sizeof(bts->_features_data); /* si handling */ bts->bcch_change_mark = 1;