Commit Graph

1872 Commits

Author SHA1 Message Date
Harald Welte 4a1cb09a40 telnet_interface: Handle osmo_fd_register() eror return code
Change-Id: I5bc1c2cbb04e363d868355b5ed866b4840f16c61
Fixes: Coverity 57637
2016-11-26 10:24:19 +01:00
Harald Welte 0fc315dd9e osmo_sock_init(): Fix memory leak in error path
We forgot to call freeaddrinfo() in an error path.

Change-Id: Iccbd3beef4c4a70dc443131b909c45e650d8c6a2
Fixes: Coverity CID 135217
2016-11-26 10:24:19 +01:00
Harald Welte 9d862c8998 Fix unchecked return valueof osmo_fd_register()
Change-Id: Ib040a7f94eb1bbec8270b66fd4c2aedef9d5346a
Fixes: Coverity CID 57636
2016-11-26 00:10:07 +01:00
Neels Hofmeyr 96831049d9 build: make check: disable sim_test when built with --disable-pcsc
Numerous issues caused sim_test to be attempted even though libosmosim was not
built:

In configure.ac, the ENABLE_PCSC variable lacked an AC_SUBST() to be exported.

Furthermore in configure.ac, no value 'yes'/'no' was assigned to the
ENABLE_PCSC variable, only to the enable_pcsc value.

In testsuite.at, encapsulating the sim_test in 'if ENABLE_PCSC' seems to have
no effect, regardless (not even when using a variable that should be defined
accurately).

So fix with these steps, similarly to how we do it in openbsc:

In AC_ARG_ENABLE, directly use 'ENABLE_PCSC' to assign 'yes'/'no'.
Export the same using AC_SUBST().
Add tests/atlocal.in to translate ENABLE_PCSC to enable_sim_test (also add
atlocal to AC_OUTPUT and distclean).
Use enable_sim_test in testuite.at, as seen in openbsc: use AT_CHECK() to
indicate skipping the test if enable_sim_test isn't 'yes'.

Change-Id: I9e8740c7d2dfbd272e22fee85972ef3fda7184a8
2016-11-16 16:40:44 +00:00
Harald Welte 6e363e7e31 gsm_08_58.h: Add more Ericsson specific RSL IE Identifiers
Change-Id: Ib43948da956f23609b1b0995ecac0c796cc7c629
2016-11-16 16:58:52 +01:00
Philipp Maier 00b1539007 RSL: Add defines for ericsson systinfo SI13
Ericsson uses non standard information element tags when setting
up the SI13 system information configuration. This applies to
RSL_SYSTEM_INFO_13, which is normally 0x28, instead Ericsson
uses RSL_ERIC_SYSTEM_INFO_13, which is set to 0x0C. Furthermore,
Ericsson adds a propritary field called BCCH-Mapping, which is
tagged as 0xf2 (RSL_IE_ERIC_BCCH_MAPPING)

This patch addes these two information element tags in
gsm_08_58.h

Change-Id: Idc27352e286b9b8bbcbf0b31bdb676c3d13487a9
2016-11-16 10:08:54 +00:00
Max 9b4d065ba5 Extend IPA error logging
Output more information in case of IPA protocol errors to make debugging
easier.

Change-Id: I7632d6e679e076bfbec9abc12da4a46cc27ccea1
Related: SYS#3028
2016-11-16 09:29:23 +00:00
Daniel Willmann 55363a9f62 vty: Skip printing non-initialized log categories
Without this patch the vty command show logging vty will cause a segfault if
not all elements of the log_categories array are defined.

Ticket: OW#3053
Sponsored-by: On-Waves ehf
Change-Id: Ieeba649c3bde6c9376d8e32b00b92beb37c08ef2
2016-11-15 22:31:19 +00:00
Harald Welte 8593f1f57a msgb: add msgb_push_u{8,16,32}() functions
Those work analoguous to msgb_put_*() but pre-pend the given value
into the msg headroom, rather than appending it to the end.

Change-Id: I7de63e9d04c2d2b678f1f20eef37f9be2c4f5ec2
2016-11-11 19:28:32 +01:00
Harald Welte 6176b6e092 bssgp_rx_paging(): Fix parsing of P-TMSI IE in Paging message
This was actually discovered by the following compiler warning in
gcc-6.2.0:

  CC       gprs_bssgp_bss.lo
gprs_bssgp_bss.c: In function ‘bssgp_rx_paging’:
gprs_bssgp_bss.c:544:2: warning: this ‘if’ clause does not guard...
[-Wmisleading-indentation]
  if (TLVP_PRESENT(&tp, BSSGP_IE_TMSI) &&
  ^~
gprs_bssgp_bss.c:548:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
   *(pinfo->ptmsi) = ntohl(*(uint32_t *)
   ^

This is an actual bug.  If we recevied a BSSGP Paging Request without
P-TMSI, we might crash or report some random memory as P-TMSI to the
caller in the output data structure.

Change-Id: Ib4f307827cd7cccc91c1415a6fb5428d7cf8416d
2016-11-11 14:49:31 +00:00
Harald Welte c4193d30e8 gan: Mark gan_pdisc_vals[] as public / non-static symbol
It is actually listed in libosmogsm.map, but still used to be a static
symbol.  That couldn't have worked.

Change-Id: I6f3f04b683d906674ee7da9bab5762bb00cea916
2016-11-11 14:49:14 +00:00
Harald Welte 684cf32243 bssgp_vty: Remove dead code and compiler warning
gprs_bssgp_vty.c:48:34: warning: ‘gprs_bssgp_timer_strs’ defined but not used [-Wunused-const-variable=]
 static const struct value_string gprs_bssgp_timer_strs[] = {
                                  ^~~~~~~~~~~~~~~~~~~~~

Change-Id: Ia41ccb7b227c41996cdef51dc6779bfc5b5a8d48
2016-11-11 15:24:29 +01:00
Harald Welte 1554f80f5e statsd: Fix compiler warning (int32_t vs. int64_t)
Fixes the following compiler warning:

stats_statsd.c: In function ‘osmo_stats_reporter_create_statsd’: stats_statsd.c:54:18: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
  srep->send_item = osmo_stats_reporter_statsd_send_item;

Change-Id: Id36914906e0982f6ac092a311210727de66b343a
2016-11-11 15:24:24 +01:00
Holger Hans Peter Freyther bf173a3df5 bitcomp: Remove the t4 decoding from libosmocore
As outlined by mail on the 13th of July the tree based approach to
decoding in the PCU is faster by order of magnitude. Instead of having a
slow implementation in the library and a quick one in the PCU, let's
only have a quick one in the PCU and at some point in the future move it
to libosmocore.

Execute the plan and remove t4_decode.

Change-Id: I021424444625a097560d086c217c81eac4a5ee44
2016-11-10 17:07:45 +00:00
Max 3de97e1926 Add logging and testing for FSM deallocation
osmo_fsm_inst_alloc() logs allocation but osmo_fsm_inst_free() is
silent. Fix this by adding log message for deallocation to make FSM
lifecycle tracking easier. Also make sure it's covered by test suite.

Change-Id: I7e5b55a1fff8e36cf61c7fb61d3e79c1f00e29d2
2016-11-08 19:35:19 +00:00
Max e9e5f8e4e9 Add null-pointer check to osmo_amr_rtp_dec()
Check that RTP payload we're about to decode is not NULL and return
proper error code instead of segfaulting. Add corresponding test case.

Change-Id: Ib6cda9900a41ed16bbfbde9df3de9d38e0a7469b
2016-11-07 15:19:47 +01:00
Max 8b25a3f5c3 Add osmo_fsm_unregister() to header
Previously function was defined but not exposed so there were a way to
register FSM but no way to unregister it.

Change-Id: I2e749d896009784b77d6d5952fcc38e1c131db2b
2016-11-02 08:56:29 +00:00
Vadim Yanitskiy f9c2c56c7d utils/conv_gen.py: explicitly import reduce()
This change finally makes the script able to be executed
in Python 3 environment. Due to new Python 3 restrictions,
the reduce() should be imported explicitly.

Change-Id: Icbc81c29f1a226aeed2c1245a5d60809fe124005
2016-11-02 08:37:55 +00:00
Vadim Yanitskiy 45ebc523c6 utils/conv_gen.py: don't mix print and write()
This is mostly a code style change, but it also
increases the compatibility with Python 3.

Change-Id: I5c8271d973f766aeb9cbcab30c4eddfdab54fcbb
2016-11-02 08:37:55 +00:00
Max 61281f4c47 Fix typo in osmo_fsm_log_addr()
Previously function parameter was ignored, fsm_log_addr was always set
to false.

Change-Id: I74f06eab2dfa81dbb95e01f0b4b26448fd1b98f8
2016-11-01 10:49:31 +01:00
Philipp Maier 72e43f02c3 gsm0408: Completing GSM 04.08 RR message types
- Add missing message types to be up to date with the
  latest specification release (3GPP TS 04.18)

- Add value strings to translate RR message type identifiers
  into human readable strings. (see gsm48_rr_msg_name() in
  gsm48.h

Change-Id: I3ceb070bf4dc8f5a071a5d43c6aa2d4e84c2dec6
2016-10-27 13:36:42 +02:00
Philipp Maier ada0042c58 COSMETIC: moving rr_cause_name() in gsm48.c
rr_cause_name() is located a far of from
value_string rr_cause_names[] while other value string
functions are located right below their related value
string definitions. This commit moves rr_cause_name()
below rr_cause_names[] as it should be

Change-Id: Ie6c03a6ea02c370d8733db5ba2a709610cd70ce7
2016-10-27 13:36:42 +02:00
Vadim Yanitskiy a6b5216ab4 utils/conv_gen.py: add EDGE MCS 1-9 definitions
Change-Id: Ie1452342f524a8b60f2babc07398a1d9c9e06aa3
2016-10-23 07:38:16 +00:00
Vadim Yanitskiy 84fc2ce210 utils/conv_gen.py: fix some typos
Change-Id: I3327b92715744af4ef61496ef0121555d9d24799
2016-10-23 07:38:16 +00:00
Vadim Yanitskiy f3d38c4937 utils/conv_gen.py: add RACH, SCH and TCH/AHS definitions
Change-Id: I0ea7151f4e8119a8798a9e129b951559e56b0d93
2016-10-23 07:38:15 +00:00
Vadim Yanitskiy c7a01d554e gsm/gsm0503.h: fix typo
Change-Id: I263d61111544eeb7227e1e0e8f2d14479eae2079
2016-10-23 07:38:15 +00:00
Vadim Yanitskiy 6908fa783d utils/conv_gen.py: improve output formatting
To keep the generated tables readable, line with should be limited.
So, now there are the following limitations:

 - _print_term(): up to 12 numbers per line,
 - _print_puncture(): up to 12 numbers per line,
 - _print_x(): up to 4 blocks per line.

Change-Id: I95256c4ad402a3c088bdb6c5a5cda8b17c31881c
2016-10-23 07:38:15 +00:00
Vadim Yanitskiy d2d9760c08 utils/conv_gen.py: generate a single file
Instead of generating every convolutional code into a separate
file (such as conv_xcch_gen.c, conv_cs3_gen.c), it is better to
have a single file, containing all definitions, because as many
convolutional codes we add, as many entries we will have to add
into 'src/gsm/Makefile.am'. This approach increases readability
of the Makefile.am, and also makes us able to share some data
between some convolutional code definitions.

For example: xCCH, RACH, SCH, TCH/F, both CS2 and CS3 may use
the same *_state[][2] and *_output[][2] arrays within a single
file. This optimization is currently WIP.

Change-Id: Ib4e4ee5fdde38429e68e3b2fa50ec03a18f59daa
2016-10-23 07:38:15 +00:00
Neels Hofmeyr 694f72d148 Revert "Constify ctrl_cmd struct fields where appropriate"
This reverts commit ed9d6da5df.

The commit is good as such, but it causes many compiler warnings in the OpenBSC
build. We want this to be re-applied as soon as we have patches ready that fix
the fallout in openbsc.git.

See also https://lists.osmocom.org/pipermail/openbsc/2016-October/009802.html

Related: OS#1829
Change-Id: I722ad60232a6ef5b4cb984b92c42851de26b3ccd
2016-10-20 17:53:10 +02:00
Alexander Couzens eb604cf44f vty/show asciidoc: counters: improve table headers
add [options=header] to every table header
vty/show asciidoc: rename reference field into "Reference"
vty/show asciidoc: capilize table header field names

Change-Id: Ie991f4db77a60afb86a2a0b35c137586527f6228
2016-10-18 12:19:13 +02:00
Alexander Couzens e052dc285d vty/show asciidoc: add user readable description of the version
Change-Id: Ie0f1b3894361c58386da9defb225979fa0ee6a18
2016-10-18 10:15:23 +00:00
Alexander Couzens 27a35ed47c stats_statsd: use int64_t instead of int for value and delta.
The stats infrastructure use int64_t for values and delta. So the
statsd reporter get call with int64_t.

Change-Id: I33df86de60007a64fa853d6d3af9b609877a8fc6
2016-10-18 09:52:13 +00:00
Alexander Couzens 3e432e1912 vty/osmo_counter: use name if description is NULL
`show stats` shows (null) for osmocom_counters when
description is null.

OpenBSC> show  stats
Ungrouped counters:
 (null):        4

Change-Id: I553b88a6fca688924b1f2b49e8cb17e90f057bb1
2016-10-13 11:04:48 +00:00
Neels Hofmeyr a23817622b configure: add --enable-sanitize, use in jenkins.sh
--enable-sanitize adds address sanitizer CFLAGS/CPPFLAGS to the entire build.
Also pass UBSAN_OPTIONS to the test suite run (only has effect during runtime).

Add this flag to jenkins.sh's configure step. To ensure that we get the
sanitize results, add 'make check' to jenkins to catch sanitize failures;

Keep 'make distcheck' without ASAN; it has its own configure which omits
--enable-sanitize. This way we test both with and without ASAN.

Change-Id: Idf7f46fa048608c2951f2473cb528f6c8dc2681d
2016-10-12 22:50:24 +00:00
Neels Hofmeyr 2b3c228416 gsm/Makefile.am: use proper top_builddir/top_srcdir paths
This fixes the conv*gen.c targets when building in a different directory
than the source tree.

Notably, building in a different dir worked when the generated sources were
already present from a previous build inside the source directory.

Change-Id: I5a9b780ad4ba607ea39854dcf7207ed05f5447bc
2016-10-12 22:50:24 +00:00
Max bc067eb0a2 Add function to send TRAP over Control Interface
Change-Id: Ic0b8d88c4f5c4d42c3f8fb754f8eabf049c9e388
Related: OS#1646
2016-10-12 11:37:49 +00:00
Neels Hofmeyr 530736f315 jenkins.sh: drop unecessary PATH, now in slave config
Change-Id: Ifaff3e5e13c920eb716a5609bfec2f96e10f17b0
2016-10-12 11:28:33 +00:00
Philipp Maier 349784c72d gsm0408: Adding 3g spcific RR message types
GSM 04.18, which is the successor of GSM 04.08, describes
additional RR 3g specific message types. This commit adds
four new message types related to paging and notifiction

See also 3GPP TS 04.18, section 10.4, table 10.4.1

Change-Id: I071cc9ecac342b5221fa0ec0b782b04b51b40e93
2016-10-12 09:29:35 +00:00
Neels Hofmeyr a95ee5e6e1 fix USSD: SS message type mask should be 0x3f, not 0xbf
See 04.80[1], section 3.4: the highest two bits are used as counter or ignored
and do not contribute to the SS "Miscellaneous message group". Previous mask of
0xbf included the highest bit, fix to 0x3f.

Observed a value of 0xbb that should mean 0x3b="Register" during testing of 3G
USSD requests, which seem to be the first to send a nonzero highest bit to our
code. The erratic mask of 0xbf lead to an unhandled message type of 0xbb.

[1] 3GPP TS 24.080 version 7.2.0 Release 7 / ETSI TS 124 080 V7.2.0 (2006-09)

Change-Id: I299001a9e36c16f55622a0acd5d4a55ca49d0055
2016-10-12 09:26:52 +00:00
Max ed9d6da5df Constify ctrl_cmd struct fields where appropriate
Change-Id: I3f55c1d4b965d215dc9b16f4b284b7fea4bde9e9
2016-10-11 18:27:22 +02:00
Neels Hofmeyr cbdfa65dbe build: be robust against install-sh files above the root dir
Explicitly set AC_CONFIG_AUX_DIR.

To reproduce the error avoided by this patch:

  rm install-sh        # in case it was already generated.
  touch ../install-sh  # yes, outside this source tree
  autoreconf -fi

This will produce an error like

  ...
  configure.ac:16: error: required file '../ltmain.sh' not found
  configure.ac:5: installing '../missing'
  src/Makefile.am: installing '../depcomp'
  autoreconf: automake failed with exit status: 1

See also automake (vim `which automake`) and look for 'sub locate_aux_dir'.

Change-Id: If2afbe62e9ceeac8052c7b882ff92a548f3af0bf
2016-10-01 00:58:53 +02:00
Max 2bb65be159 Mark inline header function as static
Change-Id: Ib751f7467d54cbcae76f72448a38e30f2ecc63d4
2016-09-30 12:31:50 +00:00
Neels Hofmeyr 56155c16b9 jenkins.sh: output all test logs when 'make check' failed
Assume that cat-testlogs.sh from osmo-ci is installed in $HOME/osmo-ci/scripts,
and call from jenkins.sh upon 'make check' failure.

Change-Id: I18a08e7ade1a53783d5a4171fe825f61b49457be
2016-09-30 00:58:13 +00:00
Neels Hofmeyr 9c0751fc60 osmo_select_main(): drop useless call to osmo_timers_check()
osmo_timers_check() does nothing more than counting the active timers. It is of
no use to count them when not using the return value in any way.

Change-Id: I8d35ca90a4c16d6f1c7f9793d663e5479783efed
2016-09-28 10:48:46 +00:00
Max 74a8f0831d AMR: add function to check speech frames
Add convenience function osmo_amr_is_speech() to check if given AMR
frame is speech frame: non-speech frames often require special
processing.

Change-Id: Ifaab02a2f581acc302b367d34fd2fc28a4d1e2e3
2016-09-28 10:34:02 +00:00
Neels Hofmeyr 8a3409c4b7 gsm0408_test: initialize msgb talloc ctx
Change-Id: Ib26214add1932e93651c248cc09fbc68339b4dce
2016-09-27 11:46:38 +02:00
Neels Hofmeyr f45334be29 msgb: add msgb_talloc_ctx_init(), deprecate msgb_set_talloc_ctx()
So far each and every main() scope creates a msgb talloc context and either
passes it to msgb_set_talloc_ctx() or sets tall_msgb_ctx directly (by defining
it extern first).

Remove some code duplication: add one central function that creates the "msgb"
talloc context for all.

Most users of msgb employ a talloc_named_const(), but osmo-bts uses a
talloc_pool() instead. Offer both ways by means of the pool_size argument, and
for both ways make sure the context is called "msgb".

Suggest that msgb users should move to this new function: deprecate
msgb_set_talloc_ctx(). To be able to do so, include core/defs.h in msgb.h.

There's a tradeoff between hiding the msgb talloc context behind API that tries
to guess all use cases versus avoiding code dup. This patch opts against code
dup and boldly assumes that all future use is covered.

Also, the new function suggests to not access tall_msgb_ctx directly, which can
be considered a style improvement.

It seems that not all main scopes that use msgb actually initialize the msgb
ctx. As a fallback for these, explicitly initialize tall_msgb_ctx to NULL.

Change-Id: I747fbbf977c4d2c868c8dead64cfc5fd86eb8d4c
2016-09-27 11:46:38 +02:00
Neels Hofmeyr 8319a6799f bitrev_test: don't omit last byte from test result check
The osmo_hexdump of the output in sh_chk() omitted the last byte of the
returned bytes from the osmo_nibble_shift_*() functions.

Determine the number of bytes from nibbles divided by two plus one for any odd
nibble number. Output this number of bytes of output data.

Memset the output buffer to get well-defined bytes for unwritten places.

Also assert that we have enough buffer length for all nibbles.

Change-Id: I011f42bca555caec0dfe8688ff1f28303fa04fad
2016-09-26 00:35:30 +00:00
Max 4fd6023b03 Fix ASAN failure in bitrev_test
Previously while testing osmo_nibble_shift_left_unal() following error was
triggered by AddressSanitizer upon offs == 12 and the last sh_chk line, i.e.
shift left of 12 nibbles from in2:

==3890== ERROR: AddressSanitizer: stack-buffer-overflow on address 0xbff5b5b6 at pc 0xb6186862 bp 0xbff5b4a8 sp 0xbff5b49c
READ of size 1 at 0xbff5b5b6 thread T0
    #0 0xb6186861 (/home/msuraev/source/gsm/libosmocore/src/.libs/libosmocore.so.7.0.0+0xc861)
    #1 0x8049d8b (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x8049d8b)
    #2 0x804a9d1 (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x804a9d1)
    #3 0xb5fe3af2 (/lib/i386-linux-gnu/libc-2.19.so+0x19af2)
    #4 0x8048a30 (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x8048a30)
Address 0xbff5b5b6 is located at offset 38 in frame <main> of T0's stack:
  This frame has 3 object(s):
    [32, 38) 'in2'
    [96, 104) 'out'
    [160, 168) 'in1'

The reason is incorrect range in test cycle. Fix it and adjust test
output accordingly.

Tweaked-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
Fixes: OW#1589 ("undefined behavior in libosmocore triggered by tests")
Change-Id: I5eb3f600290c05b4ab9ac2450a28d616e6b415fd
2016-09-26 00:35:30 +00:00
Vadim Yanitskiy e31cf8057f utils/conv_gen.py: code style changes (line width, tabs, etc.)
Change-Id: I8550910b9f5c16efc6f15f23c7ee52122c588752
2016-09-24 03:37:52 +00:00