Commit Graph

1894 Commits

Author SHA1 Message Date
Neels Hofmeyr dd97950d26 gsm/oap: more robust: decode presence as clearly either 1 or 0
Prepares for the unit test, which can now simply check for encode/decode
identity.

Change-Id: I410ff120d868e8d55df9cb19ba6eefd99749cdf0
2016-12-11 03:42:58 +01:00
Harald Welte c0f0007292 import oap message parsing / encoding from openbsc.git; AGPL->GPL
In the process, also:
* Change the license from AGPLv3 to GPLv2-or-later;
* correct spelling of 'sysmocom' to lowercase;
* add '2016' to the copyright;
* rename to osmo_*;
* add API docs;
* add logging category DLOAP: define id and add to internal_cat;
* redirect all oap.c logging to DLOAP.

A unit test will follow in a subsequent patch, since it needs a minor tweak for
decoding of boolean values.

The related openbsc change-id is I2f06aaa6eb54eafa860cfed8e72e41d82ff1c4cf.

Tweaked-by: Neels Hofmeyr
Change-Id: If5099e60681a215e798b6675f21813f26769c253
2016-12-11 03:42:58 +01:00
Neels Hofmeyr 9795cf1b12 fix: DLGSUP logging category "unusable"
All DL* categories are typically negative, but DLGSUP isn't, and it's also not
in libosmocore's internal_cat array.
See: 3b6fb0880c

This means that a program using DLGSUP has to include DLGSUP in its own logging
cat array (typically not needed for DL* categories), which means for osmo-nitb
that DLGSUP (11) replaces DMGCP (also 11), and DMGCP becomes unusable.

Fix this: make DLGSUP -11 and include in internal_cat.

In gsup_test.c, no longer add DLGSUP to the logging categories array.

External follow-ups are otherwise needed only in osmo-hlr.git and some pending
patches for openbsc (Id3938267fa062e1a997d3704cd678874306f86ee).

Change-Id: Id974c7be158e4d60421a98110f5c807aefd31119
2016-12-11 03:42:58 +01:00
Neels Hofmeyr fd9ec3bc7d Fix VTY: add missing doc for 'log gsmtap [HOSTNAME]'
Add missing doc string for the HOSTNAME arg.

Added in commit aa00f99be2, this breaks the VTY
tests for openbsc and hence breaks our jenkins build jobs.

Change-Id: I734b22c950242541322e902887bf779c14ba10fd
2016-12-11 01:48:26 +01:00
Harald Welte aa00f99be2 Implement GSMTAP log target
This target wraps the to-be-logged string (With metadata) into a GSMTAP
packet and sends it to the configured destination address.

Change-Id: I9a7e72b8c9c6f6f2d76d1ea2332dcdee12394625
2016-12-09 17:59:58 +01:00
Harald Welte a65e99331a gsmtap: Add defintions for GSMTAP based remote logging
Often it is useful to have log statements from the osmocom programs
synchronized with protocol traces.  So rather than having to open the
pcap file with GSMTAP or other protocol data side-by-side with the
textual log of one or more network elements, we simply pass the log
lines around as GSMTAP messages, which can then be displayed in-order
and interspersed with the protocol messages inside wireshark.

Change-Id: I33ab530e10ef0311b6f80b731e61894f20b4b3e7
2016-12-09 17:59:58 +01:00
Harald Welte a24be85dc4 Fix msgb_test on 64 bit architectures
truncating the unsigned long pointer msg->data to 'int' and then passin
git into msgb_resize_area() is unsafe as depending on the 32rd address
bit it will be eiether negative or positive.  That will in turn change
the expected "Sub area is not fully contained in the msg data\n" error
message into "Negative sizes are not allowed\n" which is not what the
autotest case expects.

Change-Id: I87ce13c265704d4ba8724e7dc7ed874c1128e0fa
2016-12-09 17:59:58 +01:00
Neels Hofmeyr 665d48bf15 cosmetic: gsup comments: write 'Generic' for the G in GSUP
The G used to mean GPRS, but the scope is larger now. To satisfy the curious
reader, give the G a name in gsup files' header comments. BTW, logging.h and
gsup_test.c already mentioned "Generic" before this.

Change-Id: I6ac5cf94c215e156ceff6a58da3d9e520ca942d9
2016-12-09 16:47:05 +01:00
Neels Hofmeyr 5f460dee3d license: gsup: libosmogsm requires GPL, not AGPL; say 'sysmocom'
The copyright in gsup.h differed from the one in gsup.c: gsup.c names the GNU
Affero GPL, gsup.h only the GNU GPL. Change both to GPL-v2-or-later.

In gsup.c/h's copyright notice, 'sysmocom' should be spelled lower case.

Change-Id: Ia5748c275501889b9086aef7d20ccb5c9edb8031
2016-12-09 16:47:05 +01:00
Neels Hofmeyr dda5e7991c doc: fsm timer_cb: explain return value
Change-Id: Ic6fbe95737862ed8b8de78058989c8b2ae330006
2016-12-09 16:10:46 +01:00
Neels Hofmeyr 0898a007ba contrib: add fsm-to-dot.py to draw osmo_fsm dotty graphs
Add a first version of a python script that tries to analyze .c source files to
draw graphs of osmo_fsm implementations. So far it uses quick-and-dirty
regexes.

Change-Id: I155f57a608d600f59aedfd27ef66eb9772c124e7
2016-12-09 11:29:06 +00:00
Holger Hans Peter Freyther c7f52c4c84 wqueue: Reject messges if queue is considered full
The write queue was always meant to not queue more than the
max_length messages but the implementation never rejected a
message.

Begin to log and enforce the queue size limit, add a testcase
to verify the code and initialize except_cb as part of a fix
for that new test case.

Real applications might now run into the queue limit and drop
messages where they just queued them before. It is unfortunate
but I still think it is good to implement the routine as it was
intended. We need to review osmo_wqueue_enqueue once more to
see that no msgb is leaked.

Change-Id: I1e6aef30f3e73d4bcf2967bc49f0783aa65395ae
2016-12-09 11:37:37 +01:00
Harald Welte d7c0a373ff logging: Extend log_target with call-back for un-formatted log line
Some targets might not want to receive only an opaque, pre-formatted
string, but rather the unformatted arguments with metadata like
sub-system/level/file/line.  We solve this by introducing a
log_target->output_raw() function pointer.  If a target specifies this
function, it takes precedence over the regular log_target->output()
function.

Change-Id: I9dc9205d70dce9581458e7e9dc2d8a92991897bd
2016-12-02 13:52:59 +01:00
Neels Hofmeyr 909cbecbb9 Revert "gsm0408: add chreq_type for CHREQ_T_PDCH_ONE_PHASE and CHREQ_T_PDCH_TWO_PHASE"
This reverts commit c3c28528de.

The reason is that this breaks a static assert in openbsc.
See https://lists.osmocom.org/pipermail/openbsc/2016-December/009906.html

Enlarging the ctype_by_chreq struct and breaks the static assert for
gsm_network->ctype_by_chreq's size:

../../../src/libbsc/gsm_04_08_utils.c:138:1: error: size of array ‘dummyassert_size’ is negative
 osmo_static_assert(sizeof(ctype_by_chreq) ==
 ^

What this patch lacks is, in openbsc.git:

* adjustment of ctype_by_chreq[] according to the new additions in
  libbsc/gsm_04_08_utils.c
* same for reason_by_chreq[], also in libbsc/gsm_04_08_utils.c
* enlarge ctype_by_chreq[] in gsm_network to 18, in openbsc/gsm_data.h.

Leaving it up to the original authors to follow up and commit a complete patch
series in one go.
2016-12-02 02:30:51 +01:00
Neels Hofmeyr bc1d758299 gsm0480: add gsm0480_create_ussd_notify() and *_release_complete()
Add two functions to create USSD messages. Moves and generalizes code from
openbsc. Pending: use the new functions in openbsc.

It looks like _release_complete() should also set trans_id and direction flag;
but since this is moving code from openbsc that is apparently working, just
place a fixme comment and don't change the functionality.

Change-Id: Ia80e32c7105359915bfad3cc5621a1c09caf20f0
2016-12-01 15:54:35 +00:00
Neels Hofmeyr 25774b9839 gsm0480: code dup: introduce and use gsm0480_l3hdr_push()
Add function gsm0480_l3hdr_push() to push a struct gsm48_hdr to the start of a
msgb. Use in gsm0480.c and gsm0411_utils.c. Further callers of the new function
will follow in openbsc as well as another libosmocore patch for ussd.

Change-Id: I54fce6053ab8362015686fe22dbcd38bf1366700
2016-12-01 15:54:34 +00:00
Alexander Couzens c3c28528de gsm0408: add chreq_type for CHREQ_T_PDCH_ONE_PHASE and CHREQ_T_PDCH_TWO_PHASE
For BSC-located pcu the BSC must understand the PDCH chan request.

Change-Id: Ice44dcaaf798f93af3652a96c567f8e16a6cf784
2016-12-01 15:26:29 +00:00
Alexander Couzens ec9bd52628 timer: only call the callback if not NULL
Fix a crash in osmo-sgsn.

Change-Id: I04d58d9580708cc0f6d0f4aa17d3e9f2c6235c8e
2016-11-28 23:23:09 +01:00
Harald Welte edf6fe75b7 ctrl_cmd_parse: Make coverity FORWARD_NULL happy
The 'strtok_r' function requires passing a NULL as the first parameter
on subsequent calls in order to ensure the code picks up where it left
off on a previous call.  However, Coverity doesn't quite realize this
and points out that if a NULL was passed in as the third argument it
would result in a possible NULL deref because the strtok_r function will
assign the third argument to the first in the call is NULL.

Change-Id: I7a9d08d0d4eae76a5207d285e32a25d1b384a57f
Fixes: Coverity CID 135186
2016-11-26 18:37:57 +00:00
Harald Welte aeecc48c45 Introduce osmo_strlcpy() function so we can stop using strncpy()
I'm aware of the existing criticism on stlrcpy(), but I think it is
still better than what we have now: stnrcpy(), sometimes with Coverity
warnings and sometimes with a manual setting of the termination byte.

The implementation follows the linux kernel strlcpy() which is claimed
to be BSD compatible.

We could of course link against libbsd on Linux instead, but I think
it's reasonably small and simple to provide our own implementation.
Future versions of libosmocore could use some autoconf magic and
preprocessor macros to use the system-provided strlcpy() if it exists.

Change-Id: Ifdc99b0e3b8631f1e771e58acaf9efb00a9cd493
2016-11-26 16:42:17 +00:00
Harald Welte 1fa78567e4 osmo_gsup_encode(): Make coverity happy by invariant checking
gsm48_encode_bcd_number() can theoretically return a length in excess of
the size of the bcd_buf, but only in case an overly-long IMSI is passed
into the function (which would be illegal in the first place).

Change-Id: If3dc68ee13ff784b487bbc686b777cec9057d537
Fixes: Coverity CID 135216
2016-11-26 13:47:14 +00:00
Harald Welte 9533631e53 osmo-sim-test.c: Fix rmsg check
we wanted to check for !rmsg, but used to check for !msg, missing error
returns from read_record_nr().

Change-Id: I79b6a94b1aa947c8329317b0626865c3cd4159c1
Fixes: Coverity CID 57672
2016-11-26 14:03:04 +01:00
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