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 --- include/osmocom/gsm/Makefile.am | 3 +- include/osmocom/gsm/protocol/gsm_04_08.h | 3 + include/osmocom/gsm/sysinfo.h | 40 ++++++++++ src/gsm/Makefile.am | 2 +- src/gsm/sysinfo.c | 131 +++++++++++++++++++++++++++++++ 5 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 include/osmocom/gsm/sysinfo.h create mode 100644 src/gsm/sysinfo.c diff --git a/include/osmocom/gsm/Makefile.am b/include/osmocom/gsm/Makefile.am index c3670ec7..547933ec 100644 --- a/include/osmocom/gsm/Makefile.am +++ b/include/osmocom/gsm/Makefile.am @@ -1,5 +1,6 @@ osmogsm_HEADERS = a5.h comp128.h gsm0808.h gsm48_ie.h mncc.h rxlev_stat.h \ - gsm0480.h gsm48.h gsm_utils.h rsl.h tlv.h abis_nm.h + gsm0480.h gsm48.h gsm_utils.h rsl.h tlv.h abis_nm.h \ + sysinfo.h SUBDIRS = protocol diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 3ad7dfdc..39470e78 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -1257,6 +1257,9 @@ struct gsm48_ra_id { uint8_t rac; /* Routing Area Code */ } __attribute__ ((packed)); +#define GSM48_CELL_CHAN_DESC_SIZE 16 +#define GSM_MACBLOCK_LEN 23 +#define GSM_MACBLOCK_PADDING 0x2b #endif /* PROTO_GSM_04_08_H */ diff --git a/include/osmocom/gsm/sysinfo.h b/include/osmocom/gsm/sysinfo.h new file mode 100644 index 00000000..a66f3f19 --- /dev/null +++ b/include/osmocom/gsm/sysinfo.h @@ -0,0 +1,40 @@ +#ifndef _OSMO_GSM_SYSINFO_H +#define _OSMO_GSM_SYSINFO_H + +#include + +enum osmo_sysinfo_type { + SYSINFO_TYPE_NONE, + SYSINFO_TYPE_1, + SYSINFO_TYPE_2, + SYSINFO_TYPE_3, + SYSINFO_TYPE_4, + SYSINFO_TYPE_5, + SYSINFO_TYPE_6, + SYSINFO_TYPE_7, + SYSINFO_TYPE_8, + SYSINFO_TYPE_9, + SYSINFO_TYPE_10, + SYSINFO_TYPE_13, + SYSINFO_TYPE_16, + SYSINFO_TYPE_17, + SYSINFO_TYPE_18, + SYSINFO_TYPE_19, + SYSINFO_TYPE_20, + SYSINFO_TYPE_2bis, + SYSINFO_TYPE_2ter, + SYSINFO_TYPE_2quater, + SYSINFO_TYPE_5bis, + SYSINFO_TYPE_5ter, + /* FIXME all the various bis and ter */ + _MAX_SYSINFO_TYPE +}; + +typedef uint8_t sysinfo_buf_t[GSM_MACBLOCK_LEN]; + +extern const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE]; + +uint8_t gsm_sitype2rsl(enum osmo_sysinfo_type si_type); +enum osmo_sysinfo_type osmo_rsl2sitype(uint8_t rsl_si); + +#endif /* _OSMO_GSM_SYSINFO_H */ 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 3d79f53284a300f15b4fc8356266dc23ae4ddce3 Mon Sep 17 00:00:00 2001 From: Alexander Huemer Date: Tue, 24 May 2011 15:16:13 +0200 Subject: libosmocore: add missing AC_LANG_SOURCE for current autoconf autoconf >=2.68 demands the body of an AC_COMPILE_IFELSE to be wrapped in an AC_LANG_SOURCE macro, otherwise outputs annoying warnings on the invocation of `autoreconf -i`. this patch follows that demand. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 2e22bb24..b923a218 100644 --- a/configure.in +++ b/configure.in @@ -24,7 +24,7 @@ AC_CHECK_HEADERS(execinfo.h sys/select.h sys/socket.h syslog.h ctype.h) saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden " AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) -AC_COMPILE_IFELSE([char foo;], +AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], [ AC_MSG_RESULT([yes]) SYMBOL_VISIBILITY="-fvisibility=hidden"], AC_MSG_RESULT([no])) -- cgit v1.2.3 From 7d4e2d7a8405462758429fad393a59d58f38bfb0 Mon Sep 17 00:00:00 2001 From: Alexander Huemer Date: Tue, 24 May 2011 15:16:14 +0200 Subject: libosmocore: rename configure.in -> configure.ac rename autoconf input file to align with osmocom-bb host applications, and because that suffix is preferred nowadays. --- configure.ac | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 123 ----------------------------------------------------------- 2 files changed, 123 insertions(+), 123 deletions(-) create mode 100644 configure.ac delete mode 100644 configure.in diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..b923a218 --- /dev/null +++ b/configure.ac @@ -0,0 +1,123 @@ +AC_INIT([libosmocore], + m4_esyscmd([./git-version-gen .tarball-version]), + [openbsc-devel@lists.openbsc.org]) + +AM_INIT_AUTOMAKE([dist-bzip2]) + +dnl kernel style compile messages +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +dnl checks for programs +AC_PROG_MAKE_SET +AC_PROG_CC +AC_PROG_INSTALL +LT_INIT +AC_PROG_LIBTOOL + +AC_CONFIG_MACRO_DIR([m4]) + +dnl checks for header files +AC_HEADER_STDC +AC_CHECK_HEADERS(execinfo.h sys/select.h sys/socket.h syslog.h ctype.h) + +# The following test is taken from WebKit's webkit.m4 +saved_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fvisibility=hidden " +AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) +AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], + [ AC_MSG_RESULT([yes]) + SYMBOL_VISIBILITY="-fvisibility=hidden"], + AC_MSG_RESULT([no])) +CFLAGS="$saved_CFLAGS" +AC_SUBST(SYMBOL_VISIBILITY) + +dnl Generate the output +AM_CONFIG_HEADER(config.h) + +AC_ARG_ENABLE(talloc, + [AS_HELP_STRING( + [--disable-talloc], + [Disable building talloc memory allocator] + )], + [enable_talloc=0], [enable_talloc=1]) +AM_CONDITIONAL(ENABLE_TALLOC, test "x$enable_talloc" = "x1") + +AC_ARG_ENABLE(plugin, + [AS_HELP_STRING( + [--disable-plugin], + [Disable support for dlopen plugins], + )], + [enable_plugin=0], [enable_plugin=1]) +AM_CONDITIONAL(ENABLE_PLUGIN, test "x$enable_plugin" = "x1") + +AC_ARG_ENABLE(tests, + [AS_HELP_STRING( + [--disable-tests], + [Disable building test programs] + )], + [enable_tests=0], [enable_tests=1]) +AM_CONDITIONAL(ENABLE_TESTS, test "x$enable_tests" = "x1") + +AC_ARG_ENABLE(vty, + [AS_HELP_STRING( + [--disable-vty], + [Disable building VTY telnet interface] + )], + [enable_vty=0], [enable_vty=1]) +AM_CONDITIONAL(ENABLE_VTY, test "x$enable_vty" = "x1") + +AC_ARG_ENABLE(panic_infloop, + [AS_HELP_STRING( + [--enable-panic-infloop], + [Trigger infinite loop on panic rather than fprintf/abort] + )], + [panic_infloop=1], [panic_infloop=0]) +if test "x$panic_infloop" = "x1" +then + AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort]) +fi + +AC_ARG_ENABLE(bsc_fd_check, + [AS_HELP_STRING( + [--enable-bsc-fd-check], + [Instrument bsc_register_fd to check that the fd is registered] + )], + [fd_check=1], [fd_check=0]) +if test "x$fd_check" = "x1" +then + AC_DEFINE([BSC_FD_CHECK],[1],[Instrument the bsc_register_fd]) +fi + +AC_ARG_ENABLE(msgfile, + [AS_HELP_STRING( + [--disable-msgfile], + [Disable support for the msgfile], + )], + [enable_msgfile=0], [enable_msgfile=1]) +AM_CONDITIONAL(ENABLE_MSGFILE, test "x$enable_msgfile" = "x1") + + +AC_OUTPUT( + libosmocore.pc + libosmocodec.pc + libosmovty.pc + libosmogsm.pc + include/osmocom/Makefile + include/osmocom/vty/Makefile + include/osmocom/codec/Makefile + include/osmocom/crypt/Makefile + include/osmocom/gsm/Makefile + include/osmocom/gsm/protocol/Makefile + include/osmocom/core/Makefile + include/Makefile + src/Makefile + src/vty/Makefile + src/codec/Makefile + src/gsm/Makefile + tests/Makefile + tests/timer/Makefile + tests/sms/Makefile + tests/msgfile/Makefile + tests/ussd/Makefile + tests/smscb/Makefile + Makefile) diff --git a/configure.in b/configure.in deleted file mode 100644 index b923a218..00000000 --- a/configure.in +++ /dev/null @@ -1,123 +0,0 @@ -AC_INIT([libosmocore], - m4_esyscmd([./git-version-gen .tarball-version]), - [openbsc-devel@lists.openbsc.org]) - -AM_INIT_AUTOMAKE([dist-bzip2]) - -dnl kernel style compile messages -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -dnl checks for programs -AC_PROG_MAKE_SET -AC_PROG_CC -AC_PROG_INSTALL -LT_INIT -AC_PROG_LIBTOOL - -AC_CONFIG_MACRO_DIR([m4]) - -dnl checks for header files -AC_HEADER_STDC -AC_CHECK_HEADERS(execinfo.h sys/select.h sys/socket.h syslog.h ctype.h) - -# The following test is taken from WebKit's webkit.m4 -saved_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -fvisibility=hidden " -AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], - [ AC_MSG_RESULT([yes]) - SYMBOL_VISIBILITY="-fvisibility=hidden"], - AC_MSG_RESULT([no])) -CFLAGS="$saved_CFLAGS" -AC_SUBST(SYMBOL_VISIBILITY) - -dnl Generate the output -AM_CONFIG_HEADER(config.h) - -AC_ARG_ENABLE(talloc, - [AS_HELP_STRING( - [--disable-talloc], - [Disable building talloc memory allocator] - )], - [enable_talloc=0], [enable_talloc=1]) -AM_CONDITIONAL(ENABLE_TALLOC, test "x$enable_talloc" = "x1") - -AC_ARG_ENABLE(plugin, - [AS_HELP_STRING( - [--disable-plugin], - [Disable support for dlopen plugins], - )], - [enable_plugin=0], [enable_plugin=1]) -AM_CONDITIONAL(ENABLE_PLUGIN, test "x$enable_plugin" = "x1") - -AC_ARG_ENABLE(tests, - [AS_HELP_STRING( - [--disable-tests], - [Disable building test programs] - )], - [enable_tests=0], [enable_tests=1]) -AM_CONDITIONAL(ENABLE_TESTS, test "x$enable_tests" = "x1") - -AC_ARG_ENABLE(vty, - [AS_HELP_STRING( - [--disable-vty], - [Disable building VTY telnet interface] - )], - [enable_vty=0], [enable_vty=1]) -AM_CONDITIONAL(ENABLE_VTY, test "x$enable_vty" = "x1") - -AC_ARG_ENABLE(panic_infloop, - [AS_HELP_STRING( - [--enable-panic-infloop], - [Trigger infinite loop on panic rather than fprintf/abort] - )], - [panic_infloop=1], [panic_infloop=0]) -if test "x$panic_infloop" = "x1" -then - AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort]) -fi - -AC_ARG_ENABLE(bsc_fd_check, - [AS_HELP_STRING( - [--enable-bsc-fd-check], - [Instrument bsc_register_fd to check that the fd is registered] - )], - [fd_check=1], [fd_check=0]) -if test "x$fd_check" = "x1" -then - AC_DEFINE([BSC_FD_CHECK],[1],[Instrument the bsc_register_fd]) -fi - -AC_ARG_ENABLE(msgfile, - [AS_HELP_STRING( - [--disable-msgfile], - [Disable support for the msgfile], - )], - [enable_msgfile=0], [enable_msgfile=1]) -AM_CONDITIONAL(ENABLE_MSGFILE, test "x$enable_msgfile" = "x1") - - -AC_OUTPUT( - libosmocore.pc - libosmocodec.pc - libosmovty.pc - libosmogsm.pc - include/osmocom/Makefile - include/osmocom/vty/Makefile - include/osmocom/codec/Makefile - include/osmocom/crypt/Makefile - include/osmocom/gsm/Makefile - include/osmocom/gsm/protocol/Makefile - include/osmocom/core/Makefile - include/Makefile - src/Makefile - src/vty/Makefile - src/codec/Makefile - src/gsm/Makefile - tests/Makefile - tests/timer/Makefile - tests/sms/Makefile - tests/msgfile/Makefile - tests/ussd/Makefile - tests/smscb/Makefile - Makefile) -- 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 --- include/osmocom/gsm/abis_nm.h | 2 ++ include/osmocom/gsm/gsm_utils.h | 26 ++++++++++++++++++++++++++ src/gsm/abis_nm.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/include/osmocom/gsm/abis_nm.h b/include/osmocom/gsm/abis_nm.h index 720b603d..dcc8d4bb 100644 --- a/include/osmocom/gsm/abis_nm.h +++ b/include/osmocom/gsm/abis_nm.h @@ -22,4 +22,6 @@ const char *abis_nm_avail_name(uint8_t avail); const char *abis_nm_test_name(uint8_t test); void abis_nm_debugp_foh(int ss, struct abis_om_fom_hdr *foh); +int abis_nm_chcomb4pchan(enum gsm_phys_chan_config pchan); +enum abis_nm_chan_comb abis_nm_pchan4chcomb(uint8_t chcomb); #endif /* _OSMO_GSM_ABIS_NM_H */ diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 19adb70a..a0ef3c4f 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -114,4 +114,30 @@ int gprs_tlli_type(uint32_t tlli); uint32_t gprs_tmsi2tlli(uint32_t p_tmsi, enum gprs_tlli_type type); +/* Osmocom internal, not part of any gsm spec */ +enum gsm_phys_chan_config { + GSM_PCHAN_NONE, + GSM_PCHAN_CCCH, + GSM_PCHAN_CCCH_SDCCH4, + GSM_PCHAN_TCH_F, + GSM_PCHAN_TCH_H, + GSM_PCHAN_SDCCH8_SACCH8C, + GSM_PCHAN_PDCH, /* GPRS PDCH */ + GSM_PCHAN_TCH_F_PDCH, /* TCH/F if used, PDCH otherwise */ + GSM_PCHAN_UNKNOWN, + _GSM_PCHAN_MAX +}; + +/* Osmocom internal, not part of any gsm spec */ +enum gsm_chan_t { + GSM_LCHAN_NONE, + GSM_LCHAN_SDCCH, + GSM_LCHAN_TCH_F, + GSM_LCHAN_TCH_H, + GSM_LCHAN_UNKNOWN, + GSM_LCHAN_CCCH, + _GSM_LCHAN_MAX +}; + + #endif 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 From 4d3a7b124e08a597d5f01fb2a71f3a4677a360a9 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 24 May 2011 21:31:53 +0200 Subject: socket: Skip ifa's without ifa->ifa_addr Apparently getifaddrs() returns ifa's without an ifa_addr set. --- src/socket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/socket.c b/src/socket.c index 66907c8c..901b8cdf 100644 --- a/src/socket.c +++ b/src/socket.c @@ -169,6 +169,8 @@ int osmo_sockaddr_is_local(struct sockaddr *addr, socklen_t addrlen) } for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { + if (!ifa->ifa_addr) + continue; if (sockaddr_equal(ifa->ifa_addr, addr, addrlen)) return 1; } -- cgit v1.2.3 From 08de66dd5eb57e39bc5d9f4dfcfd3febec458c11 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 29 May 2011 15:26:48 +0200 Subject: socket: remove unused IPv4 related header includes --- src/socket.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/socket.c b/src/socket.c index 901b8cdf..014bbaa2 100644 --- a/src/socket.c +++ b/src/socket.c @@ -6,10 +6,8 @@ #include #include -#include #include #include -#include #include #include -- cgit v1.2.3 From cd623ebb560d33de2b29ad3d93af5ebbd30c85e1 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 29 May 2011 15:37:38 +0200 Subject: bitvec: add missing stdint.h --- include/osmocom/core/bitvec.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h index bbe1641b..7cb8a873 100644 --- a/include/osmocom/core/bitvec.h +++ b/include/osmocom/core/bitvec.h @@ -23,6 +23,7 @@ * */ +#include /* In GSM mac blocks, every bit can be 0 or 1, or L or H. L/H are * defined relative to the 0x2b padding pattern */ -- cgit v1.2.3 From 8c6be75d4f73fe16d0493c9de636019dd52bcf00 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 29 May 2011 15:37:49 +0200 Subject: gsm/sysinfo: don't include netinet/in.h --- src/gsm/sysinfo.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c index 0dbff3ae..73225b15 100644 --- a/src/gsm/sysinfo.c +++ b/src/gsm/sysinfo.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From f2699501bc20a1dc5ee965ca1cbb8f18a3471ff8 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Sun, 29 May 2011 15:39:04 +0200 Subject: gsm/sysinfo: Fix rsl2sitype array size 0xff is the maximum value ... so there is 256 elements. Signed-off-by: Sylvain Munaut --- src/gsm/sysinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gsm/sysinfo.c b/src/gsm/sysinfo.c index 73225b15..9df18877 100644 --- a/src/gsm/sysinfo.c +++ b/src/gsm/sysinfo.c @@ -70,7 +70,7 @@ static const uint8_t sitype2rsl[_MAX_SYSINFO_TYPE] = { [SYSINFO_TYPE_5ter] = RSL_SYSTEM_INFO_5ter, }; -static const uint8_t rsl2sitype[0xff] = { +static const uint8_t rsl2sitype[256] = { [RSL_SYSTEM_INFO_1] = SYSINFO_TYPE_1, [RSL_SYSTEM_INFO_2] = SYSINFO_TYPE_2, [RSL_SYSTEM_INFO_3] = SYSINFO_TYPE_3, -- cgit v1.2.3 From 3710e462f85824cd9d84b3f95e6b2ea694119ff9 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Sun, 29 May 2011 19:48:15 +0200 Subject: gsmtap_util: Remove msg_free from the wq call back write_queue already frees the message after the callback is called. Signed-off-by: Sylvain Munaut --- src/gsmtap_util.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c index 3d20bfc2..95458657 100644 --- a/src/gsmtap_util.c +++ b/src/gsmtap_util.c @@ -197,16 +197,13 @@ static int gsmtap_wq_w_cb(struct osmo_fd *ofd, struct msgb *msg) rc = write(ofd->fd, msg->data, msg->len); if (rc < 0) { perror("writing msgb to gsmtap fd"); - msgb_free(msg); return rc; } if (rc != msg->len) { perror("short write to gsmtap fd"); - msgb_free(msg); return -EIO; } - msgb_free(msg); return 0; } -- cgit v1.2.3 From 271c43b0ae533c0371b2380f91e79dc97bdd0bcc Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 31 May 2011 00:42:38 +0200 Subject: abis_nm: Forward declare the used enums This file is using enums in that might or might not be known to the compiler. Forward declare them. --- include/osmocom/gsm/abis_nm.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/osmocom/gsm/abis_nm.h b/include/osmocom/gsm/abis_nm.h index dcc8d4bb..85345575 100644 --- a/include/osmocom/gsm/abis_nm.h +++ b/include/osmocom/gsm/abis_nm.h @@ -4,6 +4,9 @@ #include #include +enum abis_nm_msgtype; +enum gsm_phys_chan_config; + const enum abis_nm_msgtype abis_nm_reports[4]; const enum abis_nm_msgtype abis_nm_no_ack_nack[3]; const enum abis_nm_msgtype abis_nm_sw_load_msgs[9]; -- cgit v1.2.3 From f9e0746add961552366416e1f55878baf20be44b Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 31 May 2011 17:47:54 +0200 Subject: socket: getaddrinfo(): set AI_PASSIVE if we want to bind This will tell getaddrinfo() that we want a INADDR_ANY style socket --- src/socket.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/socket.c b/src/socket.c index 014bbaa2..0be98b93 100644 --- a/src/socket.c +++ b/src/socket.c @@ -31,6 +31,9 @@ int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto, hints.ai_flags = 0; hints.ai_protocol = proto; + if (connect0_bind1) + hints.ai_flags |= AI_PASSIVE; + rc = getaddrinfo(host, portbuf, &hints, &result); if (rc != 0) { perror("getaddrinfo returned NULL"); -- cgit v1.2.3 From fc90646d489ed85c73b5b809e3b74851fa57b3d9 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 5 Jun 2011 11:22:59 +0200 Subject: abis_nm.h: Add include to gsm_utils.h --- include/osmocom/gsm/abis_nm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/osmocom/gsm/abis_nm.h b/include/osmocom/gsm/abis_nm.h index 85345575..3f5335e2 100644 --- a/include/osmocom/gsm/abis_nm.h +++ b/include/osmocom/gsm/abis_nm.h @@ -2,6 +2,7 @@ #define _OSMO_GSM_ABIS_NM_H #include +#include #include enum abis_nm_msgtype; -- cgit v1.2.3 From ee50081daa3a80586f3044056517337a8e8fac9f Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 5 Jun 2011 19:53:56 +0200 Subject: add missing #include file to sysinfo.h (otherwise 'struct value_string' would not be defined) --- include/osmocom/gsm/sysinfo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/osmocom/gsm/sysinfo.h b/include/osmocom/gsm/sysinfo.h index a66f3f19..6c81134e 100644 --- a/include/osmocom/gsm/sysinfo.h +++ b/include/osmocom/gsm/sysinfo.h @@ -1,6 +1,7 @@ #ifndef _OSMO_GSM_SYSINFO_H #define _OSMO_GSM_SYSINFO_H +#include #include enum osmo_sysinfo_type { -- cgit v1.2.3