From 61dc63e354e1a68317f72d485bea4b6a0194e863 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 23 May 2011 20:30:17 +0200 Subject: rename abis_nm_adm_name() to abis_nm_adm_state_name() --- src/gsm/abis_nm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c index acea4ed5..8e769df8 100644 --- a/src/gsm/abis_nm.c +++ b/src/gsm/abis_nm.c @@ -392,7 +392,7 @@ static const struct value_string abis_nm_adm_state_names[] = { { 0, NULL } }; -const char *abis_nm_adm_name(uint8_t adm) +const char *abis_nm_adm_state_name(uint8_t adm) { return get_value_string(abis_nm_adm_state_names, adm); } -- cgit v1.2.3 From ea4b12aa5ddc054547926f5eca0e036268c1e98e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 23 May 2011 20:41:31 +0200 Subject: abis_nm: remove abis_nm_obj_class_name / abis_nm_adm_state_name and export the underlying raw value_string arrays instead: abis_nm_obj_class_names / abis_nm_adm_state_names. This permits the caller to use get_string_value() as well as get_value_string(). --- src/gsm/abis_nm.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c index 8e769df8..109c3bba 100644 --- a/src/gsm/abis_nm.c +++ b/src/gsm/abis_nm.c @@ -308,7 +308,7 @@ const struct tlv_definition abis_nm_att_tlvdef = { }, }; -static const struct value_string abis_nm_obj_class_names[] = { +const struct value_string abis_nm_obj_class_names[] = { { NM_OC_SITE_MANAGER, "SITE-MANAGER" }, { NM_OC_BTS, "BTS" }, { NM_OC_RADIO_CARRIER, "RADIO-CARRIER" }, @@ -329,11 +329,6 @@ static const struct value_string abis_nm_obj_class_names[] = { { 0, NULL } }; -const char *abis_nm_obj_class_name(uint8_t oc) -{ - return get_value_string(abis_nm_obj_class_names, oc); -} - const char *abis_nm_opstate_name(uint8_t os) { switch (os) { @@ -384,7 +379,7 @@ const char *abis_nm_test_name(uint8_t test) return get_value_string(test_names, test); } -static const struct value_string abis_nm_adm_state_names[] = { +const struct value_string abis_nm_adm_state_names[] = { { NM_STATE_LOCKED, "Locked" }, { NM_STATE_UNLOCKED, "Unlocked" }, { NM_STATE_SHUTDOWN, "Shutdown" }, @@ -392,15 +387,10 @@ static const struct value_string abis_nm_adm_state_names[] = { { 0, NULL } }; -const char *abis_nm_adm_state_name(uint8_t adm) -{ - return get_value_string(abis_nm_adm_state_names, adm); -} - void abis_nm_debugp_foh(int ss, struct abis_om_fom_hdr *foh) { DEBUGP(ss, "OC=%s(%02x) INST=(%02x,%02x,%02x) ", - abis_nm_obj_class_name(foh->obj_class), foh->obj_class, - foh->obj_inst.bts_nr, foh->obj_inst.trx_nr, + get_value_string(abis_nm_obj_class_names, foh->obj_class), + foh->obj_class, foh->obj_inst.bts_nr, foh->obj_inst.trx_nr, foh->obj_inst.ts_nr); } -- cgit v1.2.3 From b5503136fa234690d5493b19a8aee3a4ef74190d Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 24 May 2011 15:01:53 +0200 Subject: Import sytem information related definitions + code from openbsc --- src/gsm/Makefile.am | 2 +- src/gsm/sysinfo.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 src/gsm/sysinfo.c (limited to 'src') diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 94f137e2..55b772f1 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -8,7 +8,7 @@ AM_CFLAGS = -fPIC -Wall lib_LTLIBRARIES = libosmogsm.la libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c gsm_utils.c \ - rsl.c gsm48.c gsm48_ie.c gsm0808.c \ + rsl.c gsm48.c gsm48_ie.c gsm0808.c sysinfo.c \ gprs_cipher_core.c gsm0480.c abis_nm.c libosmogsm_la_LDFLAGS = -version-info $(LIBVERSION) libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c new file mode 100644 index 00000000..0dbff3ae --- /dev/null +++ b/src/gsm/sysinfo.c @@ -0,0 +1,131 @@ +/* GSM 04.08 System Information (SI) encoding and decoding + * 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */ + +/* (C) 2008-2010 by Harald Welte + * + * All Rights Reserved + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +/* verify the sizes of the system information type structs */ + +/* rest octets are not part of the struct */ +osmo_static_assert(sizeof(struct gsm48_system_information_type_header) == 3, _si_header_size); +osmo_static_assert(sizeof(struct gsm48_rach_control) == 3, _si_rach_control); +osmo_static_assert(sizeof(struct gsm48_system_information_type_1) == 22, _si1_size); +osmo_static_assert(sizeof(struct gsm48_system_information_type_2) == 23, _si2_size); +osmo_static_assert(sizeof(struct gsm48_system_information_type_3) == 19, _si3_size); +osmo_static_assert(sizeof(struct gsm48_system_information_type_4) == 13, _si4_size); + +/* bs11 forgot the l2 len, 0-6 rest octets */ +osmo_static_assert(sizeof(struct gsm48_system_information_type_5) == 18, _si5_size); +osmo_static_assert(sizeof(struct gsm48_system_information_type_6) == 11, _si6_size); + +osmo_static_assert(sizeof(struct gsm48_system_information_type_13) == 3, _si13_size); + +static const uint8_t sitype2rsl[_MAX_SYSINFO_TYPE] = { + [SYSINFO_TYPE_1] = RSL_SYSTEM_INFO_1, + [SYSINFO_TYPE_2] = RSL_SYSTEM_INFO_2, + [SYSINFO_TYPE_3] = RSL_SYSTEM_INFO_3, + [SYSINFO_TYPE_4] = RSL_SYSTEM_INFO_4, + [SYSINFO_TYPE_5] = RSL_SYSTEM_INFO_5, + [SYSINFO_TYPE_6] = RSL_SYSTEM_INFO_6, + [SYSINFO_TYPE_7] = RSL_SYSTEM_INFO_7, + [SYSINFO_TYPE_8] = RSL_SYSTEM_INFO_8, + [SYSINFO_TYPE_9] = RSL_SYSTEM_INFO_9, + [SYSINFO_TYPE_10] = RSL_SYSTEM_INFO_10, + [SYSINFO_TYPE_13] = RSL_SYSTEM_INFO_13, + [SYSINFO_TYPE_16] = RSL_SYSTEM_INFO_16, + [SYSINFO_TYPE_17] = RSL_SYSTEM_INFO_17, + [SYSINFO_TYPE_18] = RSL_SYSTEM_INFO_18, + [SYSINFO_TYPE_19] = RSL_SYSTEM_INFO_19, + [SYSINFO_TYPE_20] = RSL_SYSTEM_INFO_20, + [SYSINFO_TYPE_2bis] = RSL_SYSTEM_INFO_2bis, + [SYSINFO_TYPE_2ter] = RSL_SYSTEM_INFO_2ter, + [SYSINFO_TYPE_2quater] = RSL_SYSTEM_INFO_2quater, + [SYSINFO_TYPE_5bis] = RSL_SYSTEM_INFO_5bis, + [SYSINFO_TYPE_5ter] = RSL_SYSTEM_INFO_5ter, +}; + +static const uint8_t rsl2sitype[0xff] = { + [RSL_SYSTEM_INFO_1] = SYSINFO_TYPE_1, + [RSL_SYSTEM_INFO_2] = SYSINFO_TYPE_2, + [RSL_SYSTEM_INFO_3] = SYSINFO_TYPE_3, + [RSL_SYSTEM_INFO_4] = SYSINFO_TYPE_4, + [RSL_SYSTEM_INFO_5] = SYSINFO_TYPE_5, + [RSL_SYSTEM_INFO_6] = SYSINFO_TYPE_6, + [RSL_SYSTEM_INFO_7] = SYSINFO_TYPE_7, + [RSL_SYSTEM_INFO_8] = SYSINFO_TYPE_8, + [RSL_SYSTEM_INFO_9] = SYSINFO_TYPE_9, + [RSL_SYSTEM_INFO_10] = SYSINFO_TYPE_10, + [RSL_SYSTEM_INFO_13] = SYSINFO_TYPE_13, + [RSL_SYSTEM_INFO_16] = SYSINFO_TYPE_16, + [RSL_SYSTEM_INFO_17] = SYSINFO_TYPE_17, + [RSL_SYSTEM_INFO_18] = SYSINFO_TYPE_18, + [RSL_SYSTEM_INFO_19] = SYSINFO_TYPE_19, + [RSL_SYSTEM_INFO_20] = SYSINFO_TYPE_20, + [RSL_SYSTEM_INFO_2bis] = SYSINFO_TYPE_2bis, + [RSL_SYSTEM_INFO_2ter] = SYSINFO_TYPE_2ter, + [RSL_SYSTEM_INFO_2quater] = SYSINFO_TYPE_2quater, + [RSL_SYSTEM_INFO_5bis] = SYSINFO_TYPE_5bis, + [RSL_SYSTEM_INFO_5ter] = SYSINFO_TYPE_5ter, +}; + +const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE] = { + { SYSINFO_TYPE_1, "1" }, + { SYSINFO_TYPE_2, "2" }, + { SYSINFO_TYPE_3, "3" }, + { SYSINFO_TYPE_4, "4" }, + { SYSINFO_TYPE_5, "5" }, + { SYSINFO_TYPE_6, "6" }, + { SYSINFO_TYPE_7, "7" }, + { SYSINFO_TYPE_8, "8" }, + { SYSINFO_TYPE_9, "9" }, + { SYSINFO_TYPE_10, "10" }, + { SYSINFO_TYPE_13, "13" }, + { SYSINFO_TYPE_16, "16" }, + { SYSINFO_TYPE_17, "17" }, + { SYSINFO_TYPE_18, "18" }, + { SYSINFO_TYPE_19, "19" }, + { SYSINFO_TYPE_20, "20" }, + { SYSINFO_TYPE_2bis, "2bis" }, + { SYSINFO_TYPE_2ter, "2ter" }, + { SYSINFO_TYPE_2quater, "2quater" }, + { SYSINFO_TYPE_5bis, "5bis" }, + { SYSINFO_TYPE_5ter, "5ter" }, + { 0, NULL } +}; + +uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type) +{ + return sitype2rsl[si_type]; +} + +enum osmo_sysinfo_type osmo_rsl2sitype(uint8_t rsl_si) +{ + return rsl2sitype[rsl_si]; +} -- cgit v1.2.3 From 11c7193ad8ceb4f3898799dc44b700b8b93a59b8 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 24 May 2011 17:15:12 +0200 Subject: Import abis_nm_{chcomb4pchan,pchan4chcomb}() from openbsc --- src/gsm/abis_nm.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/gsm/abis_nm.c b/src/gsm/abis_nm.c index 109c3bba..a82194fd 100644 --- a/src/gsm/abis_nm.c +++ b/src/gsm/abis_nm.c @@ -21,9 +21,12 @@ */ #include +#include + #include #include #include +#include #include #include @@ -394,3 +397,32 @@ void abis_nm_debugp_foh(int ss, struct abis_om_fom_hdr *foh) foh->obj_class, foh->obj_inst.bts_nr, foh->obj_inst.trx_nr, foh->obj_inst.ts_nr); } + +static const enum abis_nm_chan_comb chcomb4pchan[] = { + [GSM_PCHAN_CCCH] = NM_CHANC_mainBCCH, + [GSM_PCHAN_CCCH_SDCCH4] = NM_CHANC_BCCHComb, + [GSM_PCHAN_TCH_F] = NM_CHANC_TCHFull, + [GSM_PCHAN_TCH_H] = NM_CHANC_TCHHalf, + [GSM_PCHAN_SDCCH8_SACCH8C] = NM_CHANC_SDCCH, + [GSM_PCHAN_PDCH] = NM_CHANC_IPAC_PDCH, + [GSM_PCHAN_TCH_F_PDCH] = NM_CHANC_IPAC_TCHFull_PDCH, + /* FIXME: bounds check */ +}; + +int abis_nm_chcomb4pchan(enum gsm_phys_chan_config pchan) +{ + if (pchan < ARRAY_SIZE(chcomb4pchan)) + return chcomb4pchan[pchan]; + + return -EINVAL; +} + +enum abis_nm_chan_comb abis_nm_pchan4chcomb(uint8_t chcomb) +{ + int i; + for (i = 0; i < ARRAY_SIZE(chcomb4pchan); i++) { + if (chcomb4pchan[i] == chcomb) + return i; + } + return GSM_PCHAN_NONE; +} -- cgit v1.2.3