Commit Graph

1032 Commits

Author SHA1 Message Date
Neels Hofmeyr 5b34f773e4 remove unused local variable in get_rate_ctr()
Unused after 22886d9e32
"Fix retrieving rate_ctr over control interface"

Change-Id: Ib5411da80c4eb4f905a5ed87c60477eca2cdff42
2016-09-19 14:18:38 +02:00
Neels Hofmeyr 2e38d358b6 remove unused function get_rate_ctr_group()
Unused after 22886d9e32
"Fix retrieving rate_ctr over control interface"

Change-Id: I405367ef6ba5833957778a79dd398ce5ea29307e
2016-09-19 14:18:38 +02:00
Anatoly Orlov 6320934e6a libosmocodec link fix on MacOSX
Fixes the following bug:

  CCLD     libosmocodec.la
Undefined symbols for architecture x86_64:
  "_bitvec_get_bit_pos", referenced from:
      _osmo_fr_check_sid in gsm610.o
  "_bitvec_get_uint", referenced from:
      _osmo_hr_check_sid in gsm620.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libosmocodec.la] Error 1

Change-Id: Id7358b94e274b529a8da38a0b2ef8c892b6dd7a5
2016-09-09 06:35:21 +00:00
Neels Hofmeyr 0318f6b6ca IuPS: add GMM Service Request related constants and value_str
Change-Id: Ie023fc78099932f95cc8f1b3a04fe25dfd14bc35
2016-08-29 13:56:17 +02:00
Neels Hofmeyr b7f191febb fix printf format for commit 'osmo_sock_init(): include host and port in error messages'
Related: CID#143566
Change-Id: I75c542089749a0875d3d1913151fe838d7722ff2
2016-08-29 11:22:39 +02:00
Neels Hofmeyr f0f07d9c9b osmo_sock_init(): include host and port in error messages
For programs like osmo-hnbgw with numerous sockets, the message that some
unspecified connection was refused is not very helpful. Also output the host
and port where an error occured.

Instead of perror, use fprintf(stderr, ..., strerror()) to be able to include a
format string and print host and port as passed to osmo_sock_init().

Change-Id: I8d0343f51310699b78fcb83fd76fd93764acf3dc
2016-08-27 02:01:20 +00:00
Neels Hofmeyr 898e1d878e vty: use VTY_BIND_ADDR_DEFAULT instead of "127.0.0.1"
Change-Id: Ice0688ac9847524cb546f6d41547090b6a3cb3d8
2016-08-20 16:33:47 +02:00
Harald Welte 460f9ef7da fsm: Make sure we call 'onenter' of new state, not old state
Change-Id: I1a0181c25d9debe935e86d97ddffc24675e56a5f
2016-08-01 00:38:36 +02:00
Harald Welte f92e44c539 lapd_core: Fix crash in lapd_dl_flush_hist()
When lapd_dl_flush_hist() was called before we actually had started a
transmit history from lapd_dl_init(), we woul segfault before this
patch.

Change-Id: Ifa677c9b335dd2884b4f3e44699d901957a0500b
2016-08-01 00:27:37 +02:00
Tom Tsou 9a5bbf36b5 egprs: Add CPS tables from TS 04.60
Includes EGPRS coding and puncturing scheme (CPS) tables from 3GPP
TS 04.60. Currently osmo-bts-trx is the only user of CPS table
values, but this may change with gprsdecode and other utilities.

Change-Id: I09fe6514a0e2e51bb3206f8387633f7e0255345f
2016-07-25 18:33:26 +00:00
Neels Hofmeyr 47390764dd rsl: add rsl_act_type_name()
Change-Id: Ie90c76d8aef42d5e2c9be94f4b206d4994e305f8
2016-07-23 15:32:55 +02:00
Neels Hofmeyr fd80f5a042 dyn TS: add definitions for dynamic TCH/F_TCH/H_PDCH
Add:
* GSM_PCHAN_TCH_F_TCH_H_PDCH
* NM_CHANC_OSMO_TCHFull_TCHHalf_PDCH
* RSL_CHAN_OSMO_PDCH
* RSL_ACT_OSMO_PDCH

Related: OS#1776
Change-Id: Ib1a8b11f37af4686d00ac88beba38557aa29edc2
2016-07-23 15:32:55 +02:00
Neels Hofmeyr 505adee93b fix compiler warning: gsup.c: missing braces
osmo_auth_vector's first member is an array, so for a zero initializer, we
should add a second set of array braces.

Change-Id: Iace448caca8152e46244f26c3af250f2035c99eb
2016-07-17 07:44:11 +00:00
Holger Hans Peter Freyther 511b448fe3 bitvec: Force inlining of bitvec_set_bit_pos/bitvec_set_bit
The PCU is using bitvec_write_field a lot but on the
arm-poky-linux-gnueabi-gcc v4.8.1 the calls to set_bit and
set_bit_pos are not inlined. The inlined variant has been
a more quick for the PCU compressed bitmap decompression
testcase.

Used objdump -d to look at the bitvec_write_field before and
after the change. The branch to bitvec_set_bit is gone and a
inlined version has been used.

Change-Id: I0b6b90610f4c17f02e4efa064c3bf1ac2dccb22a
2016-07-16 21:02:41 +00:00
Max 4f169500df Add GEA3 & GEA4 ciphers
Corresponding test code include both official test vectors from the
specs and data from over-the-air tests.

This obsoletes libosmo-crypt-a53 as it was last missing piece
unimplemented in libosmogsm.

Change-Id: I939e4f6b91b4a7c591ef3761fe2d46ed1c2fb2d3
Related: OS#1582
2016-07-11 19:15:24 +00:00
Harald Welte 02a6672885 fsm: delete the timer when changing state
In osmo_fsm_inst_state_chg(), we need to stop any not-yet-expired timer
of the old state before transitioning into the new state.

Change-Id: I2558f9a7027a877ea8263785ed3c8d70d2513996
2016-07-10 15:13:51 +02:00
Harald Welte f3239113db fsm: talloc + copy the 'id' passed into a FSM
The 'id' is used to generate the human-readable name of the FSM.
However, when the FSM creates slave FSMs later, the caller-passed "ID"
mgiht long be gone again (e.g. it was on stack memory).  So let's copy
the 'id' string to a chunk of dynamically-allocated memory at time of
FSM start to ensure we have it later when creating child FSMs.

Change-Id: Ib88a2c02c5c91f17b4ec1e9db57a06d6d66465fb
2016-07-10 15:11:45 +02:00
Harald Welte 673018fed9 fsm: call 'onenter' as last step of a state change
This is useful to allow the user to terinate the fsm from the onenter()
callback.

Change-Id: Ia45a1f3279e702028250e10dc54b2d46a4039905
2016-07-10 15:09:43 +02:00
Max f5f773f013 Add strings with GPRS GMM messages
Change-Id: I48477b733e2da72f59349c00554dd3e080c9f445
Related: OS#1582
2016-07-08 15:08:17 +00:00
Max fdca25dfb8 Add function to check GMM encryptability
Check if particular GMM message can be encrypted according to 3GPP TS
24.008 § 4.7.1.2

Related: OS#1582
Change-Id: I7ad0e03c2c738d174dd6bc3453f332eeb8da1e7d
2016-07-07 12:55:46 +00:00
Max 92ce39f3d1 Add missing osmo_c4 export
Change-Id: Iaf53b31b4fa3860301054e970907ada061360b28
Related: OS#1741
2016-07-07 13:00:43 +02:00
Harald Welte 0ee90f8614 lapd_dl_flush_hist(): Don't flush a non-existant history
If lapd_dl_flush_hist() is called after lapd_dl_exit(), dl->tx_hist has
already been free'd and set to NULL.  Check for this before attempting
to de-reference a NULL pointer.

This bug breaks OpenBSC with any E1 based BTSs using DAHDI.

Change-Id: I117ba3445fa5e8097e21c11c5a6337de6ba46c7d
Related: OS#1760
2016-07-03 20:47:06 +02:00
Max a337b9c37a Add function to check MS GEA capabilities
Add function which parses MS network capability IE value for bits
indicating support for particular version of GEA.

Change-Id: I785cef37dd272a2fab9b172f6e1392f865174e9a
Relates: OS#1582
2016-06-29 16:33:25 +00:00
Max ceae123752 Make C4 function globally available
This function perform 64 -> 128 bit key expansion which useful for
converting between UMTS CK and GSM Kc, A5/3 and A5/4, GEA3 and GEA4
keys.

Change-Id: I5a6c6deef6027cd6af144c9062d4c9166be26904
Related: OS#1582
2016-06-29 16:32:55 +00:00
Max b897c42993 Add strings for GPRS ciphers
Change-Id: I050bda5fb50aad42fe2d72de39f8256b4fb12fb2
Related: OS#1582
2016-06-29 16:32:27 +00:00
Harald Welte 14bf28a43d Mark input parameter to bitvec_set_bits() as 'const'
The input data is accessed in a read-only manner, so it should be marked
with the const qualifier.

Change-Id: I0d6b86289fa647594f3da1f1c0e0168685307a37
2016-06-27 15:19:10 +02:00
Harald Welte f627c0f0af fsm: Introduce default time-out handling
If a FSM doesn't specify any timer_cb, simply terminate the FSM by
default on time-out.  This is a reasonable default for most cases, and
avoids copy+pasting a one-line timer_cb function in every FSM.

Also, even if there is a timer_cb, let it have a return value to decide
if the core should terminate after return from timer_cb or not.

Change-Id: I0461a9593bfb729c82b7d1d1cf9f30b1079d0212
2016-06-27 15:17:53 +02:00
Max d826f1771c Fix potential segfault in msg_dequeue
Change-Id: I06e9c5ba3e00c73a4e52d2583ce3492f236275ce
2016-06-23 20:00:33 +00:00
Max e0a7d9e2c2 Add octet-aligned/unaligned shift functions
The actual code is from OsmoBTS' tch.c by Harald Welte. Add unit tests,
doxygen annotation and extra memory safety check. Those functions are
used in several BTS implementations but seems generic enough to be
generally useful.

Change-Id: I2b1901c4161e8035f059585901dca593b661556d
2016-06-20 19:02:56 +02:00
Harald Welte 136e73764e Add Finite State Machine abstraction code
This code is supposed to formalize some of the state machine handling in
Osmocom code.

Change-Id: I0b0965a912598c1f6b84042a99fea9d522642466
Reviewed-on: https://gerrit.osmocom.org/163
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-16 21:43:45 +00:00
Harald Welte 82f94ef50f Add UMTS AKA related MM/GMM message type and IE definitions
Change-Id: Id45ea2c631ee589a4df1f8213da6f7e7d1bf6616
Reviewed-on: https://gerrit.osmocom.org/305
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-16 21:43:21 +00:00
Harald Welte db78d2172b gsup.c: Fix encoding of UMTS auth vectors
Encoding auth vectors worked fine for GSM authentication, but didn't
yet include the new IEs for UMTS authentication yet.

Change-Id: I7fa5ba1c950292bd0a9874b3102a27f221ce390d
Reviewed-on: https://gerrit.osmocom.org/302
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-16 21:25:18 +00:00
Harald Welte f624c33ef2 vty: Fix documentation of 'show asciidoc counters' VTY command
VTY documentations strings follow a certain structure, and we need to
follow that to make the interactive help work.

Change-Id: I0bb0bda68dbbf9995338ec555ff99d73a223162c
Reviewed-on: https://gerrit.osmocom.org/276
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Harald Welte <laforge@gnumonks.org>
2016-06-15 09:39:20 +00:00
Max 22886d9e32 Fix retrieving rate_ctr over control interface
Allow getting either particular
counter (e. g. rate_ctr.per_hour.e1inp.0.hdlc.abort) or entire rate
counter group for a given index (e. g. rate_ctr.per_hour.e1inp.0).

Change-Id: I2b0109536170f7b5388d3236df30b98f457aa98d
Fixes: OS#1730
Reviewed-on: https://gerrit.osmocom.org/274
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-14 22:21:24 +00:00
Alexander Couzens ad580ba7c4 add vty call show asciidoc: generate a documentation for counters
For each counter group a ascii doc table is generated
containing all single counter with a reference to a section to
add additional information to the counter

Change-Id: Ia8af883167e5ee631059299b107ea83c8bbffdfb
Reviewed-on: https://gerrit.osmocom.org/70
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Harald Welte <laforge@gnumonks.org>
2016-06-14 10:38:17 +00:00
Neels Hofmeyr 0167e3f355 add rsl_or_ipac_msg_name() for both standard and ip.access msg types
Context: in osmo-bts, I want to look up an RSL message name in rsl_msgt_names
and fall back to rsl_ipac_msgt_names if not found, because the IPAC PDCH ACT
and DEACT messages are sent in a standard ABIS_RSL_MDISC_DED_CHAN.

Change-Id: Ic9ba721a1469cf51aed97ab0f44a7fe055c94b1f
Reviewed-on: https://gerrit.osmocom.org/231
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-13 17:46:48 +00:00
Neels Hofmeyr 8d6dcd9bca add get_value_string_or_null() to handle unknown items
Add get_value_string_or_null() to return NULL in case the given value is not
found in the list of strings, to be able to cleanly fall back to another list
of strings. Absorb the lookup loop from get_value_string().

Context: in osmo-bts, I want to look up an RSL message name in rsl_msgt_names
and fall back to rsl_ipac_msgt_names if not found, because the IPAC PDCH ACT
and DEACT messages are sent in a standard ABIS_RSL_MDISC_DED_CHAN.
In a subsequent commit, get_value_string_or_null() will be used by new
rsl_or_ipac_msg_name().

Change-Id: I1fa3907e28d528d2758bc3eae9d19e6c1168f5e5
Reviewed-on: https://gerrit.osmocom.org/230
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-13 17:46:20 +00:00
Neels Hofmeyr 8a3c83ed00 api doc: get_value_string(): mention composition in static buffer
Change-Id: I93dad98711ef69f8a1e196efa029a842a1ff5bd6
Reviewed-on: https://gerrit.osmocom.org/229
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-13 17:45:52 +00:00
Max ec8f192fec Add functions to detect HR/FR SID frames
Add functions which check if given FR or HR frame (packed in RTP)
contains SID (SIlence Descriptor) and corresponding tests.

Related: OS#22
Change-Id: I4051e3c0d4fb9ee93d7e9e0ef4abaf9f18e227ca
Reviewed-on: https://gerrit.osmocom.org/160
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-01 10:44:06 +00:00
Max 92db150488 Add helper functions for AMR codec
* add functions to encode/decode various codec paramters from RTP payload with
  AMR frame according to RFC 4867
* those functions are extended version based on code from osmo-bts'
  amr.c by Andreas Eversberg
* add corresponding enum types and strings for logging
* add regression tests

It's useful both to replace manual parsing in osmo-bts with fuctions
covered by test suite and as a debugging helpers for issues related to
AMR.

Change-Id: Ia217679a07d3fbc970f435e20f6eac33d34bd597
Related: OS#1562
Reviewed-on: https://gerrit.osmocom.org/118
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-31 10:11:51 +00:00
Max adef12a349 Add strings with PH primitive names
It's useful debugging helper while troubleshooting L1-related issues.

Change-Id: Id7a6d478fd725c51f54ad746bdf9b9095579ff77
Reviewed-on: https://gerrit.osmocom.org/117
Tested-by: Jenkins Builder
Reviewed-by: Max <msuraev@sysmocom.de>
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-30 21:21:20 +00:00
Ruben Undheim 029f5a1c0d misc: Some spelling errors corrected
Change-Id: Ibfc239b84879556624ca6020ae6a63d102640c94
Reviewed-on: https://gerrit.osmocom.org/114
Tested-by: Jenkins Builder
Reviewed-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
2016-05-25 19:43:56 +00:00
Holger Freyther 45abec20dd Revert "gsm48: move to hex TMSI representation"
This is a "flag" day change. Old OpenBSC break with new libosmocore
because suddenly there is the 0x in front. I am afraid we need to
find a better solution here. I think we will need to create a
gsm48_mi_to_string variant that takes a mode parameter to enable the
TMSI mode and deprecate the old method.

Right now we should not break old versions of OpenBSC.

This reverts commit 78ad042f94.

Change-Id: I2f61e626f2f9088b492e1b643c3dcc9bce77d52b
Reviewed-on: https://gerrit.osmocom.org/86
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-20 19:42:50 +00:00
Arran Cudbard-Bell cc3694b650 Fix build for OSX
Change-Id: I580a500edcf4812e570be586890abef746083a8c
Reviewed-on: https://gerrit.osmocom.org/74
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-20 16:32:58 +00:00
Vadim Yanitskiy 78ad042f94 gsm48: move to hex TMSI representation
Previously, we traditionally displayed a TMSI in its integer
representation, which is quite unusual in the telecom world.
A TMSI is normally printed as a series of 8 hex digits.

Review at https://gerrit.osmocom.org/57/
Change-Id: Ifd25365bfa3b4ee95b16979740c3229948ce17f2
Reviewed-on: https://gerrit.osmocom.org/57
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-20 16:26:51 +00:00
Max 764b022fc6 Add function to make Uplink Measurement
It assembles RSL Uplink Measurement IE according to 3GPP TS 08.58
§9.3.25. The function is based on lchan_build_rsl_ul_meas() from OsmoBTS
but optionally includes DTX information.

Change-Id: Ib37107bcc9909e5105ea711de42d3fb1db7e8d9e
Reviewed-on: https://gerrit.osmocom.org/44
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-05-17 16:10:31 +00:00
Max fe65fa7e36 Set DTX in Cell Options
* rename field of struct gsm48_cell_options to better match the spec
* add comments with spec references
* add function for setting DTX in cell options struct
* add necessary enum type

Change-Id: I5a8924f57669c951b2e51b663d95f1d360062a54
Reviewed-on: https://gerrit.osmocom.org/39
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-05-12 15:56:39 +00:00
Neels Hofmeyr c7bf8d0c84 api doc: auth_core.c: add \returns, cosmetic
Add various missing \returns doxygen entries.

In osmo_auth_3g_from_2g(), also adjust two comment-closing instances to
match common style and add a period to end a sentence.

(The recent addition of osmo_auth_3g_from_2g() raised my attention, and I added
more return value docs while at it.)

Change-Id: Iea71eb666bc061acb6b14215f398bd38d17b3ad3
Reviewed-on: https://gerrit.osmocom.org/33
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-10 11:05:27 +00:00
Harald Welte 766da86877 GSUP: Add support for RAND in SendAuthInfo.req
In the autentication re-sync case, we need not only the AUTS from
the MS/UE, but also the RAND that we sent as part of the failed
authentication challenge.
2016-05-06 11:22:05 +02:00
Harald Welte 48dc1a5a64 GSUP: Add OSMO_GSUP_CN_DOMAIN_IE to differentiate CS and PS plane
We're starting to use GSUP for circuit-switched (CS) plane, so we need
to differentiate the two planes somehow from each other.
2016-05-06 11:21:25 +02:00
Harald Welte 3b6fb0880c import gprs_gsup_message.[ch] from openbsc as gsup.[ch]
Move those routines from OpenBSC to libosmogsm, so they can be
re-used from other programs.  I think it was a mistake to add them only
inside the openbsc repository in the first place.  We need to pay more
attention to this in the future.
2016-05-06 11:21:06 +02:00
Harald Welte 9709b2e6fd Import osmo_{encode,decode}_big_endian() from openbsc 2016-05-05 18:49:27 +02:00
Harald Welte fbd02fa8cc tlv: Import osmo_shift_* and osmo_match_shift_* from openbsc
These routines have nothing to do with specifically the BSC, so import
them to the TLV parser we keep in libosmogsm.
2016-05-05 18:49:27 +02:00
Harald Welte 2d2e2cca0d Update doxygen annotations in libosmocore
This adds and improves doxygen API descriptions all over libosmocore,
reducing the 'white spots' that don't have any documentation.
2016-05-05 18:49:27 +02:00
Harald Welte 64f38c0410 import gsm_04_08_gprs.[ch] from openbsc.git
The definitions in this header file (and associated strings in the
c file) are generic about the GPRS Layer3 signalling protocols, and
thus should be part of the library.
2016-05-05 18:49:27 +02:00
Harald Welte 69e6c3c7cd Add log_fini() function to release all memory allocated by logging framework
This is e.g. quite useful to call at the end of test code, in order to
show that all memory allocated actually is released before exit().
2016-05-05 18:49:22 +02:00
Harald Welte cd9cb90f45 auth_core: Add osmo_auth_3g_from_2g() to compute CK+IK from Kc
This function performs the C5+C4 conversion to derive UMTS key
material from a 2G-only subscriber.
2016-05-05 18:48:05 +02:00
Holger Hans Peter Freyther 3a96d2837c conv_gen: Use python2 to execute the script
The script does not work with python3:

$ python3 utils/conv_gen.py
  File "utils/conv_gen.py", line 124
    def _print_term(self, fi, num_states, pack = False):

Second there is no 'python' on FreeBSD and one needs to select
the major version to use.

  GEN      conv_cs3_gen.c
  GEN      conv_xcch_gen.c
  GEN      conv_cs2_gen.c
python: not found
python: not found
python: not found

By using python2 we solve both issues. On Debian python2 is located
inside the python-minimal package.
2016-04-29 21:24:48 +02:00
Harald Welte 84da22f964 Add code generator for convolutional codes
Add python utility to generate .c code with convolutional
encoder/decoder based on polynomial description of the code. If argument
given it'll be interpreted as intended output directory, otherwise
current working directory is used.

Codes for *CCH, CS2/3 and TCH/AFS are generated. Corresponding manual
implementations are removed from tests. This introduce build-time
dependency on python.

The main work for this patch was generously contributed by Sylvain
Munaut.

Fixes: OS#1629
2016-04-29 13:17:22 +02:00
Holger Hans Peter Freyther aa16d63c27 milenage/aes: Address undefined behavior on bitshift
Extend the u8 to u32 before going to shift it.

Fixes:
milenage/aes-internal.c:799:4: runtime error: left shift of 128 by 24 places cannot be represented in type 'int'
    #0 0x7f84e9fe86a2 in rijndaelKeySetupEnc (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xfa6a2)
    #1 0x7f84e9febad8 in aes_encrypt_init (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xfdad8)
    #2 0x7f84e9fe7d14 in aes_128_encrypt_block (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xf9d14)
    #3 0x7f84e9febe7d in milenage_f1 (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xfde7d)
    #4 0x7f84e9fee2ce in milenage_generate (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0x1002ce)
    #5 0x7f84e9fe76d7 in milenage_gen_vec (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xf96d7)
    #6 0x7f84e9fe6c08 in osmo_auth_gen_vec (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xf8c08)
    #7 0x401441 in main (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/tests/auth/.libs/lt-milenage_test+0x401441)
    #8 0x7f84e8e33a3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
    #9 0x400e58 in _start (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/tests/auth/.libs/lt-milenage_test+0x400e58)
2016-04-24 20:57:30 +02:00
Max 27e8036d41 Fix unaligned access found by addr. sanitizer
gprs_bssgp.c:461:9: runtime error: load of misaligned address
0x62100001a66b for type 'uint32_t', which requires 4 byte alignment

gprs_ns.c:937:16: runtime error: load of misaligned address
0x61d00002a97f for type 'uint16_t', which requires 2 byte alignment
2016-04-24 11:12:41 +02:00
Max 8a5346ba2f Add function for appending range1024 to bitvec
Add convenience function to append range1024 encoded data (see 3GPP TS
44.018 Annex J) to a given bitvec.
2016-04-23 16:37:05 +02:00
Max 1f9d8183be Deprecate comp128
Mark function as deprecated to discourage its usage: people should use
generic API in osmocom/crypt/auth.h
2016-04-22 15:10:55 +02:00
Max fdb3d8ce78 Deprecate osmo_a5_1 and osmo_a5_2
Mark the functions as deprecated to discourage their use: people should
use unified osmo_a5 which supports all the A5/1-4 ciphers.
2016-04-22 15:10:53 +02:00
Max aead05da32 Improve code reuse
Use generic functions covered by testsuit for SQN calculations.
2016-04-22 15:09:49 +02:00
Max bf990bb8fd Update internal GPRS cipher API
Update internal API (for GPRS cipher implementors): make it compliant
with ETSI TS 155.22. External API left untouched.
2016-04-22 15:09:27 +02:00
Max fbb8bfa514 Add function to get osmo_earfcn bit size
This function returns the number of bits necessary to pack osmo_earfcn
into Repeated E-UTRAN Neighbour Cells IE (3GPP TS 44.018 Table
10.5.2.33b.1).
2016-04-16 13:41:56 +02:00
Neels Hofmeyr da1b20cd4f logging.c: assert category_token allocation (CID #57871) 2016-04-16 13:31:15 +02:00
Max d8fb14226f Add ubit <-> sbit convertors
Move functions for conversion between soft and unpacked bits to main
library as they are generally useful.
2016-04-12 10:10:44 -04:00
Max 93bc64f99d gb: Add bssgp_pdu_str to libosmogb namespace
[hfreyther: To be used by osmo-pcu]
2016-04-12 10:08:20 -04:00
Max b9bb0b02ac Add missing docs for bssgp bvc reset vty command
Fixes the build failure with extended tests enabled.
2016-04-07 12:38:12 +02:00
Max ea50732df2 Add vty command to explicitly reset given BVCI
It's useful for debugging and is similar to existing reset command for
nsvc.
2016-04-05 22:33:14 +02:00
Holger Hans Peter Freyther 61f28880d5 select: Externalize fd_set filling and dispatch
To integrate with an external event loop (in this case glib) we
need to allow an application to get a filled out fd_set and then
dispatch it. osmo_fds and maxfds are static and I decided to keep
it that way and instead create two routines to fill the fdset and
then one to dispatch the result.

The public header file does not include sys/select.h and we can
compile the library without select, so I didn't want to require
having to include this file, and used void * for the parameter.

Mark the routines as inline to avoid a call from the select
function. I have confirmed that inlining has an effect on x86
using Debian's gcc-4.9.2-10 compiler
2016-03-31 16:56:51 +02:00
Max fb348eeff2 Export names for gsm_chan_t and gsm48_chan_mode
This can be used with get_value_string() to improve debugging output.
2016-03-30 21:50:44 +02:00
Harald Welte 932d2d4ce3 sim: make osim_reader_ops public 2016-03-19 21:18:40 +01:00
Harald Welte 6c33ae2605 Add new osmo_fd_get_by_fd() function
This function can be used to obtain the osmo_fd corresponding to a given
fd.  The latter can be useful when integrating libosmocore main loop
with other libraries.
2016-03-19 21:17:58 +01:00
Harald Welte 4acaa13433 sim: add class_tables / card profiles
The tables permit code to determine the APDU class of an APDU
based on it APDU/TPDU header (CLA/INS/P1/P2/P3).
2016-03-17 16:55:11 +01:00
Max 2c34ab4a80 Improve BSSGP debug output
Print string representation of Cause IE and PDU type instead of
numerical value.
2016-03-17 16:55:11 +01:00
Max ea345cdaaa Rename struct to better match libosmocore conventions 2016-03-17 16:49:15 +01:00
Harald Welte c79b3972fa Revert "gsm48: move to hex TMSI representation"
This reverts commit f451ce66eb.
2016-03-17 14:43:02 +01:00
Vadim Yanitskiy f451ce66eb gsm48: move to hex TMSI representation
Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
2016-03-17 14:13:18 +01:00
Max 03309b57e8 Add basic EARFCN support
Add structure representing group of EARFCNs with common priority,
threshold etc.
Add functions to populate this structure.
2016-03-17 14:07:19 +01:00
Max d4793212b5 Add function to add bits from array to bitvec
Add function which adds specified number of bits from each element of
array to the bit vector prefixing each addition with one and finishing
entire sequence with adding 0. This is very common patter for various
repetitive data structures described with CSN.1 in 3GPP standards.

Corresponding test vectors and doxygen headers are added too.
2016-03-17 14:07:19 +01:00
Neels Hofmeyr bdccc1b144 gsm48: factor out MCC+MNC BCD parsing for re-use in UMTS
For 3G, I need a BCD composer/parser similar to gsm48_generate_lai()/
gsm48_decode_lai(). Those functions also handle a trivial extra
member (lac) which I don't need in this way for 3G.

So create new functions to take on the MCC+MNC BCD handling and call those
from gsm48_generate_lai() and gsm48_decode_lai(). In this way, the 3G code
in openbsc can use only the BCD functionality without code duplication.
2016-03-15 14:30:41 +01:00
Neels Hofmeyr 282e908434 04.08: add inline funcs for pdisc + msg type bitmasks
Add inline functions for both release <= 98 and release >= 99 as well as a
default define. Use the release 98 by default since the current code base uses
the r98 bitmasks.

These inline functions relieve callers of the decision on masking bits of the
protocol discriminator and message type octets.

Also add a define for the protocol discriminator extension to one octet length
(GSM48_PDISC_EXTEND).

Apply new pdisc function in gsm0480.c.

[hfreyther: Make the hdr param const]
2016-03-15 14:10:45 +01:00
Max c0d9a6c083 Add helper function to convert numerical BSSGP PDU type to string 2016-03-11 22:29:39 +07:00
Harald Welte 5ffb50371e rename osim_file_find_* to osim_file_desc_find_*
they return an osim_file_desc, and not an osim_file, so fix the naming
2016-03-11 22:05:25 +07:00
Harald Welte c28f4cdd6d sim: Add osim_file_find_{fid,sfid}() functions
We don't always want to look-up by name, but the latter is the only
implemented 'find' function so far.  Let's change that.
2016-03-11 22:05:25 +07:00
Holger Hans Peter Freyther ed0ce47fa9 logging: Remove unused variable after recent changes
The variable is not used anymore as the decision is done in the
newly added check_log_to_target method.
2016-02-29 14:41:12 +01:00
Holger Hans Peter Freyther 79599acd66 logging: Move the filter check up as well
There doesn't seem to be a reason not to check the filter. Update
and extend the test. Currently the filter function will be called
once for the log check and once for the output of it.
2016-02-29 14:30:14 +01:00
Holger Hans Peter Freyther e0dc6a1c7c logging: Remove some code duplication
Extract the mapping of the subsystem number and the checking for
the loglevel to a inline method that is shared between the new
and old.
2016-02-29 14:30:14 +01:00
Jacob Erlbeck de6dd72dbb log: Add log_check_level function
This commit adds this predicate function which can be used to
avoid the execution of code if a certain log level is not enabled.

The function will only return 0 (false), if it is sure that a logging
call for the same facility and level will not produce any output.
This safety criterion shall ensure, that no logging output is lost
due to the use of this predicate as a guard. On the other hand, even
if the predicate returns != 0 (true), no logging output might get
generated by a similar logging command.

Note that the current implementation is not focussed on performance,
which could be improved by using a lookup table instead of iterating
through every target.

Sponsored-by: On-Waves ehf
2016-02-29 14:30:14 +01:00
Neels Hofmeyr f20f5fd508 comment typo 2016-02-29 09:56:39 +01:00
Neels Hofmeyr f81eb328b6 vty: add ctrl section for Control interface bind address
This may seem like overkill for a mere const char * config item, but it makes
the Control interface VTY commands reusable in any main() scope (inspired by
libosmo-abis' VTY config).

Add API functions ctrl_vty_init() and ctrl_vty_get_bind_addr(), in new files
src/ctrl/control_vty.c and include/osmocom/ctrl/control_vty.h, compiled and/or
installed dependent on ENABLE_VTY.

Using these functions allows configuring a static const char* with the VTY
commands

    ctrl
     bind A.B.C.D

which callers shall subsequently use to bind the Control interface to a
specific local interface address, by passing the return value of
ctrl_vty_get_bind_addr() to control_interface_setup().

Add CTRL_NODE to enum node_type, "eating" RESERVED4_NODE to heed that comment
on avoiding ABI changes.
2016-02-25 11:02:35 +01:00
Neels Hofmeyr 4934309dab add ctrl_interface_setup_dynip() for bind address
Make the ctrl interface bind address configurable, so that it may be made
available on other addresses than 127.0.0.1. The specific aim is to allow
running multiple osmo-nitbs alongside each other (commits in openbsc follow).
2016-02-25 11:02:35 +01:00
Neels Hofmeyr 96172f0100 vty: add bind command for telnet vty line
Add VTY command
    line vty
     bind A.B.C.D

The command merely stores the configured IP-address, which can then be used by
the calling main program to set the telnet port of the VTY line. (Commits in
openbsc and osmo-iuh will follow up on this.)

Add function vty_get_bind_addr() to publish the address in the vty.h API.

Add static vty_bind_addr to store.

For allocation/freeing reasons, a NULL address defaults to 127.0.0.1.

BTW, I decided against allowing keywords 'any' and 'localhost' in place of an
actual IP address to make sure a written config is always identical to the
parsed config.
2016-02-25 11:02:34 +01:00
Jacob Erlbeck f78ec5ce0d gb: Add bssgp_msgb_copy function
This function originates from openbsc/src/gprs but is just specific
to BSSGP/Gb on the same level like bssgp_msgb_alloc.

This commit puts the former gprs_msgb_copy function beside
bssgp_msgb_alloc.

Renamed function:

  gprs_msgb_copy -> bssgp_msgb_copy

Sponsored-by: On-Waves ehf
2016-02-22 10:20:49 +01:00
Holger Hans Peter Freyther ab0eb96dd9 bitvec: Untested speculative UBAN fix for the new routine
int << 31 does not seem to be defined, let's try to make it an
unsigned variable and see if that is pleasing the system.

Fixes:
bitvec.c:219:15: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
2016-02-18 20:28:25 +01:00
Max 5c18e26bc2 Add T4 bit map compression routines
Add bit map encoder and decoder functions: decoder is fully functional
while encoder is good enough for testing - no backtracking to find
the best possible compression is implemented. If somebody is willing to
implement MS side of EDGE than this has to be expanded.
Add corresponding tests.
N. B: the encoding is implemented according to ETSI TS 44.060 which is
slightly different from T4 used for fax according to CCITT G31D (RFC 804).

Ticket: OW#2407
Sponsored-by: On-Waves ehf

Signed-off-by: Max <msuraev@sysmocom.de>
2016-02-18 19:45:44 +01:00
Max 0a59e9899f Expand bitvec interface
Add bit filling, shifting and other functions necessary for bit
compression implementation. Add corresponding tests.
2016-02-18 19:45:40 +01:00
Holger Hans Peter Freyther a9301a1a1f bitvec: Test and fix regression for C++->C conversion
bitvec_read_field/bitvec_write_field in the PCU used a C++ reference
and when porting to C it was decided to pass the parameter by value
and this lost the "back propagation" of the new index. Change the
parameter to be an in/out parameter and this way do not have a silent
semantic break in the osmo-pcu (where we copy the reference in csn.1
by value) and have a true compile failure.

Add Max's simple test for bitvec_unhex function leaving the checking
of bitvec_read_field and the side effect in the datastructure about
the number of bits still open.
2016-01-30 10:54:43 +01:00
Max 912bc6ff50 Add doxygen comments to clarify function use 2016-01-30 10:18:38 +01:00
Holger Hans Peter Freyther 2745b48940 bitvec: Fix build on older gcc
bitvec.c: In function 'bitvec_unhex':
bitvec.c:389: error: 'for' loop initial declarations are only allowed in C99 mode
bitvec.c:389: note: use option -std=c99 or -std=gnu99 to compile your code
2016-01-27 17:08:02 +01:00
Max a15f05f1b4 Add bitvec-related functions from Osmo-PCU
Allocation, pack/unpack, field access and helper routines used
extensively by Osmo-PCU. Whenever memory allocation happens, alocator
context is passed explicitly by caller.
2016-01-26 11:01:23 +01:00
Holger Hans Peter Freyther ee6652b4bc ipa: recv is declared in different headers on BSD
Include the headers mentioned by the manpage

ipa.c:346:9: warning: implicit declaration of function 'recv' is invalid in C99
      [-Wimplicit-function-declaration]
                ret = recv(fd, msg->tail, needed, 0);
2015-11-09 16:21:19 +00:00
Holger Hans Peter Freyther d56c3cbb2c vty: Use NULL to have a null pointer instead of '\0'
'\0' gets translated to zero but the argument to vector_set is
a pointer and it gets converted to a pointer.

vty.c:985:21: warning: expression which evaluates to zero treated as a null pointer constant of type
      'void *' [-Wnon-literal-null-conversion]
                vector_set(vline, '\0');
                                  ^~~~
vty.c:1095:21: warning: expression which evaluates to zero treated as a null pointer constant of type
      'void *' [-Wnon-literal-null-conversion]
                vector_set(vline, '\0');
                                  ^~~~
vty.c:1097:21: warning: expression which evaluates to zero treated as a null pointer constant of type
      'void *' [-Wnon-literal-null-conversion]
                vector_set(vline, '\0');
                                  ^~~~
2015-11-09 16:16:00 +00:00
Max e49af08f5b bitvec: Fix interface to consistently use unsigned int
Use unsigned int for the length throughout the interface. We will
never have a a negative length.

Sponsored-by: On-Waves ehf
2016-01-22 23:22:48 +01:00
Max 08621a8ebb bitvec: Fix unaligned memory access in osmo_revbytebits_buf
The undefined behavior sanitizer found the 32bit load from an
unaligned memory address. This will cause an exception on ARMv5te
and a manual fix-up.

[hfreyther: On armv6, x86 the usage of memcpy leads to shorter
amount of instructions but on armv5te the memcpy is not expanded
leading to a branch. Use the version of max until we have the time
to benchmark it]

Sponsored-by: On-Waves ehf
2016-01-22 23:21:58 +01:00
Max cf37c4cd29 Fix sporadic out-of-bounds error
This code dealing with bit shifting sometimes gets 1 byte beyond array
boundary while calculating index. This is now explicitly checked and prevented.

Ticket: OW#1198
Sponsored-by: On-Waves ehf
2016-01-22 23:08:12 +01:00
Jacob Erlbeck 5f349be820 bitvec: Add get/set byte sequences
The new functions bitvec_get_bytes and bitvec_set_bytes copy
byte sequences from bitvecs to uint8_t arrays and vice versa.
While the bytes in the bitvecs do not need to be aligned, the uint8_t
arrays always are. In case the bytes in the bitvec are aligned, the
implementation uses memcpy.

Note that the implementation like the other existing functions assume
MSB first encoding.

[hfreyther: Squash the comment fix into this commit as well]

Sponsored-by: On-Waves ehf
2016-01-15 14:51:32 +01:00
Jacob Erlbeck 8114294bf2 gsm: Add APN conversion functions
These functions are currently part of openbsc but also needed by
other projects.

The function have been renamed as follows:

  gprs_apn_to_str -> osmo_apn_to_str
  gprs_str_to_apn -> osmo_apn_from_str

Sponsored-by: On-Waves ehf
2016-01-15 14:46:19 +01:00
Neels Hofmeyr 42fff58a45 Fix some recently added formats on 64bit
86ec311896 adds compiler warnings on 64bit. The build is clean otherwise,
so let's keep it that way.
2015-12-24 16:17:21 +01:00
Harald Welte a2db75f28c Add osmo_prim_op_names[] symbol and _SAP_SS7_BASE define 2015-12-23 14:11:54 +01:00
Jacob Erlbeck 86ec311896 msgb: Let msgb_hexdump be more tolerant
This patch makes msgb_hexdump accept out of range lXh pointers and
shows info about them instead of aborting the dump entirely.

Sponsored-by: On-Waves ehf
2015-12-21 16:14:50 +01:00
Jacob Erlbeck cdd05f0ed4 msgb: Add msgb_resize_area and msgb_copy
These functions originate from openbsc/src/gprs but are generic
msgb helper functions.

  msgb_copy:  This function allocates a new msgb, copies the data
              buffer of msg, and adjusts the pointers (incl. l1h-l4h)
              accordingly.

  msgb_resize_area:
              This resizes a sub area of the msgb data and adjusts the
              pointers (incl. l1h-l4h) accordingly.

Sponsored-by: On-Waves ehf
2015-12-21 16:14:23 +01:00
Neels Hofmeyr 9e57a5a697 some comments / fixed typos 2015-12-21 11:25:05 +01:00
Harald Welte 1a87c1b189 LaPDm: Refuse SUSPEND/RESUME/RECONNECT in BTS mode
The primitives for SUSPEND, RESUME and RECONNECT are only permitted on
the MS side of the LAPDm link, not on the BTS side.  So we should check
for this and reject, accordingly.
2015-12-19 17:06:57 +01:00
Jacob Erlbeck cc6ac4cdc4 ns: Force a defined state when sending NS RESET
Currently the state is assumed to remain the same while the reset
procedure is active. While this works correctly in general, a single
unexpected BLOCK_ACK or UNBLOCK_ACK can change the state but will not
stop the reset procedure. The leads to repeated RESET messages, where
the corresponding RESET_ACK is ignored. This is a stable state which
can only be left by manual intervention or by reception of a RESET
message from the peer.

This commit changes the RESET timeout handler to set the state to
BLOCKED/RESET when sending the new NS RESET message.

Note that this should ensure a clean restart even if the state has been
screwed up. It does not fix the handling of BLOCK_ACK or UNBLOCK_ACK
in abnormal cases.

Addresses:
 gprs_ns.c:349 NSEI=8895 Tx NS RESET (NSVCI=8895, cause=O&M intervention)
 gprs_ns.c:878 NSVCI=8895 Rx NS RESET ACK (NSEI=8895, NSVCI=8895)
 gprs_ns.c:887 NS RESET ACK Discarding unexpected message for NS-VCI 8895 from SGSN NSEI=8895

Ticket: OW#1551
Sponsored-by: On-Waves ehf
2015-12-17 14:16:50 +01:00
Holger Hans Peter Freyther 5ab8e2cdfc stats: Fix compiler warning about losing const
stats_statsd.c: In function ‘osmo_stats_reporter_statsd_send_item’:
stats_statsd.c:154:15: warning: initialization discards ‘const’ qualifier from pointer target type
  char *unit = desc->unit;
               ^
2015-12-17 14:13:22 +01:00
Jacob Erlbeck 0975a7f36c ns/stats: Add missing osmo_stat_item_group_free to gprs_nsvc_delete
The stat item group is not removed by gprs_nsvc_delete which will
corrupt the group list.

Addresses:
  valgrind tests/gbproxy/gbproxy_test
  [...]
  ==4541== Invalid write of size 4
  ==4541==    at 0x4071ACA: __llist_add (linuxlist.h:65)
  ==4541==    by 0x4071ACA: llist_add (linuxlist.h:81)
  ==4541==    by 0x4071ACA: osmo_stat_item_group_alloc
  (stat_item.c:112)
  ==4541==    by 0x407EDFD: gprs_nsvc_create (gprs_ns.c:244)
  ==4541==    by 0x408109D: gprs_ns_instantiate (gprs_ns.c:1388)
  ==4541==    by 0x804CFD3: test_gbproxy_ident_changes
  (gbproxy_test.c:1501)
  ==4541==    by 0x805FBD3: main (gbproxy_test.c:5803)

Sponsored-by: On-Waves ehf
2015-12-17 14:01:16 +01:00
Harald Welte fad5752ab5 RSL: Add enum + TLV definitions for ip.access style embedded IEs 2015-12-13 21:57:29 +01:00
Jacob Erlbeck ac4ed17dbd stats: Add OSMO prefix to STAT_ITEM_NOVALUE_ID
This symbol is globally visible and therefore should have an OSMO
prefix like the other identifiers exported by stat_item.h.

Sponsored-by: On-Waves ehf
2015-12-08 10:33:15 +01:00
Jacob Erlbeck af5bad5ed0 stat: Explicitly support stat_items without unit
Add OSMO_STAT_ITEM_NO_UNIT for stat items without an unit. The
statsd reporter uses gauges ("g") to report them.

Sponsored-by: On-Waves ehf
2015-12-08 10:33:04 +01:00
Harald Welte 90e614f7cc remove our internal copy of talloc, use system libtalloc
Shipping our own private copy of talloc was a good idea in 2008,
when it was not readily available on most target platforms.  Today,
the situation is quite different, as it is a standard library on
major Linux distributions.
2015-12-05 23:38:18 +01:00
Jacob Erlbeck ee702cd590 stats: Add TODO comment to rate_ctr
Currently the counters are scanned twice, once for interval
computation and once for reporting.

This adds a reminder to move the interval computation code to a
special stats reporter which just shall update the fields.

Sponsored-by: On-Waves ehf
2015-11-26 12:53:12 +01:00
Jacob Erlbeck 2e8f9ed556 stats: Reorder functions in stats.c
Due to prior refactoring, the functions do not have an sensible order
in the file. This commit tries to improve that a little bit.

Sponsored-by: On-Waves ehf
2015-11-26 12:52:24 +01:00
Jacob Erlbeck b6e6bea4ec stats: Move statsd related code into a separate file
This commit moves the stats specific code parts into stats_statsd.c
while keeping the generic parts in stats.c. The code in stats.c no
longer contains references to statsd symbols.

Note that the VTY code still needs to know about every stats reporter
backend.

Sponsored-by: On-Waves ehf
2015-11-26 12:52:24 +01:00
Harald Welte b32a19467f stat_item.c: Fix compiler warnings
CC       stat_item.lo
stat_item.c: In function 'osmo_stat_item_group_alloc': stat_item.c:84:28: warning: cast to pointer from integer of different
size [-Wint-to-pointer-cast]
   group->items[item_idx] = (void *)items_size;
                            ^
stat_item.c:98:24: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    ((uint8_t *)items + (int)group->items[item_idx]);
                        ^
2015-11-20 10:22:14 +01:00
Harald Welte a99d45ac59 vty: Don't call exit() but rather use OSMO_ASSERT()
This was pointed out by Jaroslav Skarvada during fedora packaging,
and he has a valid point...
2015-11-12 13:48:23 +01:00
Jaroslav Škarvada 2b82c1c6c8 fix FSF address in sources/headers
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-11-12 13:46:05 +01:00
Jacob Erlbeck 01e8c91df5 stats: Fix not reported stat item values
Currently the global stat item index is being advanced in
osmo_stat_item_group_handler, so that the second and further groups
in the list will skip new item values.

This commit moves the call to osmo_stat_item_discard_all into
osmo_stats_report to a place where all groups have been processed
already.

Sponsored-by: On-Waves ehf
2015-11-09 14:49:52 +01:00
Jacob Erlbeck 8a97cb9111 stats: Fix handling of multiple resporters
Currently the reporter loop is aborted, if the event would be ignored
due to an insufficient max_level. Thus the reporters that happen to
be stored afterwards would be skipped even if their level were
sufficient.

This commit replaces the conditional 'return' statement by a
considtional 'continue' statement to ensure the processing of the
list tail.

Sponsored-by: On-Waves ehf
2015-11-09 14:49:52 +01:00
Jacob Erlbeck aed7c125fd stats: Send all values on reporter update
Currently only counter changes and new item values are being
reported. This makes it cumbersome to configure reporting clients,
since there is nothing like a list of all parameters.

This commit changes this behaviour such that all currently existing
counters and items that would be reported eventually, are passed to
the reporter when it has been reconfigured or enabled. If a counter
has not been incremented, 0 is sent. If a stat item value has not
been added, the last item value (or the default value if there is
none) is resent again.

Note that this will not catch transient counters/items that will be
created later on, e.g. triggered by new peers or subscribers.

To just force this kind of dump on a running reporter, it is
sufficient to invoke the 'enable' command in its configuration node.

Sponsored-by: On-Waves ehf
2015-11-09 14:49:49 +01:00
Jacob Erlbeck 916423ef95 stats: Fix name prefix handling
Currently the having an unset prefix leads to an abort() in the
statsd reporter due to an fprintf format string error. In addition
the prefix cannot be reset to its initial state (NULL) by using 'no
prefix', which just sets the prefix to the empty string, causing a
single leading dot to appear in front of the name.

This commit changes the implemenation to consistly use NULL for
the unset name prefix ('no prefix') and to handle this case correctly
in the statsd reporter.

Sponsored-by: On-Waves ehf
2015-11-09 10:52:19 +01:00
Holger Hans Peter Freyther 834819471a stats: Document the level in show stats level options
Potentially Fixes:

<command id='show stats level (global|peer|subscriber)'>
        <param name='subscriber' doc='(null)' />
2015-11-07 21:11:14 +01:00
Holger Hans Peter Freyther 495b0dbd24 gprs-ns/stats: When the NSVCI is updated, update the stats counter
The NS object is created with an unknown identity and only after
the reset procedure has progressed (completed?) we know the real
ID for this peer. Before nobody has looked at the idx values (this
could have been seen with the CTRL interface) but with statsd the
wrong NSVCI becomes obvious.

Add routines to update the idx and I don't know if the change of
idx is causing any issues but we will find that out soon.
2015-11-04 14:39:37 +01:00
Jacob Erlbeck 59b90bc444 stats/vty: Add selective show stats command
Currently there is only the 'show stats' command which shows all
counter and stat_item values. This can lead to many lines of output
if there are per-subscriber rate counters.

The new command added by this commit allows it to only show groups of
a certain level (class_id), similar to the 'level' configuration
command for stats reporter.

The new command is

  show stats level (global|peer|subscriber)

Sponsored-by: On-Waves ehf
2015-08-22 01:47:55 +00:00
Jacob Erlbeck fed2a488b9 ns/stats: Fix class_id of "NSVC Peer Statistics" rate_ctr group
Currently the class_id is not set which effectively puts these groups
into the 'subscriber' class.

This commit adds the missing initialisation value.

Sponsored-by: On-Waves ehf
2015-08-22 01:35:24 +00:00
Holger Hans Peter Freyther 8649d57f50 misc: Prepare the release of libosmocore 0.9.0
Bump the ABI version of libosmovty and we need to do this
recursively to force rebuilds of our software.
2015-11-03 09:32:32 +01:00
Holger Hans Peter Freyther c337693c4c stats: Fix build on FreeBSD
include stdint.h for int64_t and use netinet/in.h and not
netinet/ip.h for getting sockaddr_in and such.
2015-08-21 19:56:54 +00:00
Holger Hans Peter Freyther 3f838b717e timer: Fix compiler warning about timeval
timer.c:27:23: warning: tentative definition of variable with internal linkage has incomplete
      non-array type 'struct timeval' [-Wtentative-definition-incomplete-type]
static struct timeval nearest;
                      ^
timer.c:27:15: note: forward declaration of 'struct timeval'
static struct timeval nearest;
2015-08-21 19:45:08 +00:00
Neels Hofmeyr 667e83d71e fix some typos
Sponsored-by: On-Waves ehi
2015-11-02 20:23:34 +01:00
Holger Hans Peter Freyther 8f0374f752 stats: Fix handling of the no mtu command
For the atoi we need to pass the val as a string. This means
we need to write "0" which then gets parsed to 0.

[src/vty/stats_vty.c:90]: (error) Possible null pointer dereference: val
2015-11-02 15:53:09 +01:00
Holger Hans Peter Freyther 7921975989 stats: Do not assign the wrong addresss
we need to put the default value into inaddr and not put a
32bit value into the addr pointer.

Spotted by cppcheck:
[src/stats.c:231]: (error) Uninitialized variable: inaddr
2015-11-02 15:50:32 +01:00
Holger Hans Peter Freyther 837e940627 stats: Remove warnings about never read variables
Nothing is being done with these return values. Remove them
for now and update the TODO entry that is present at two of
the three places.

stats.c: In function ‘rate_ctr_handler’:
stats.c:570:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
      ^
stats.c: In function ‘osmo_stat_item_handler’:
stats.c:617:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
      ^
stats.c: In function ‘handle_counter’:
stats.c:651:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
2015-11-02 15:44:26 +01:00
Jacob Erlbeck 79125ecf7d log: Add new DLSTATS log level
This log level is used by the stats subsystem log reporter to report
statistics to level INFO. Note that the default level of DLSTATS is
NOTICE.

Sponsored-by: On-Waves ehf
2015-11-02 15:39:31 +01:00
Jacob Erlbeck bc9d9aced8 stats: Limit reporting by class id
This commit adds class_id fields to the rate_ctr and stat_item group
descriptions. The stats reporter code is extended to only process
groups whose class_id does not exceed a per reporter max_class level.

If the class_id is not set, the code assumes 'global' for groups with
idx == 0 and 'subscriber' otherwise.

The following vty command is added to config-stats:

  level (global|peer|subscriber)  Set the maximum group level

Sponsored-by: On-Waves ehf
2015-11-02 15:39:31 +01:00
Jacob Erlbeck 16fe8dab7c stats: Report group indices as unsigned int
Currently the unsigned group index value is silently being cast to
(signed) int in the log and statsd reporter code. If the resulting
value is negative (which can happen for instance with MMCTX
counters), the index is assumed to be unset.

This commit changes the affected types to unsigned. The index value 0
is then the only value indicating an unset group.

Sponsored-by: On-Waves ehf
2015-11-02 15:39:31 +01:00
Jacob Erlbeck fc9533d6c4 stats: Add osmo_ name prefix to identifiers
Since the the stat_item and stats functions and data types are meant
to be exported, they get an osmo_ prefix.

Sponsored-by: On-Waves ehf

[hfreyther: Prepended the enum values too. This was requested by
Jacob]
2015-11-02 15:39:01 +01:00
Jacob Erlbeck bc4f7ae512 stats: Add log reporter
This reporter passes the measurement values to the logging subsystem
as DSTATS (which is currently DLGLOBAL) level INFO messages.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:07 +01:00
Jacob Erlbeck 490b38f57a stats: Use function pointers in reporter objects
Currently case statements are used to select the right reporter
functions. This makes it difficult to add new reporter types,
especially if they are not going to reside in the same file.

This commit introduces per reporter function pointer for
open, close, send_count, and send_item. They are checked for
non-NULL before being called or skipped.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:07 +01:00
Jacob Erlbeck ed197fd4f9 stats: Make net config optional
To support reporters without network configuration, this commit
introduces the have_net_config flag to provide corresponding error
messages.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck 4aa1177062 stats: Add missing mtu command to 'write' output
Currently the config_write_stats_reporter function does not output
the mtu value, which is fixed by this commit.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck d01acfcc75 stats: Support statsd Multi-Metric Packets
If the MTU is given, combine several messages into a single UDP
packet until the limit is reached. Flush all reporters after the
values have been scanned.

New vty commands (node config-stats):
  mtu <100-65535>     Enable multi-metric packets and set the maximum
                      packet size (in byte)
  no mtu              Disable multi-metric packets

Note that single messages that are longer than the given MTU (minus
28 octets protocol overhead) will be dropped.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck c8f47b600f stats: Add support for osmo_counters
This commit changes the reporting code to also show all modified
osmo_counter values. Since there is no grouping of these values, the
name string just consists of the optional prefix and the counter
name.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck 80db4ec387 core: Add difference function to osmo_counter
The osmo_counter_difference returns the counter value difference
since the last call of this function with the given counter object.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck c27671c109 stats: Report stat item values
Currently only rate counter are being supported.

This commit adds support for stat items. All groups are polled for
changed values.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck b1dbfb4c41 stats: Implement timer based reporting
This calls stats_flush in regular intervals which polls the
statistical values and calls the active reporters when values have
changed.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck adc900e0e3 stats/vty: Add stats configuration
This commit provides stats configuration similar to the log
configuration.

The following vty commands are added to the config node:
  stats reporter statsd          Create/Modify a statsd reporter
  no stats reporter statsd       Remove a statsd reporter

To actually configure a reporter, the config-stats node is entered
when the "stats reporter" command has succeeded. The following new
vty commands are available there:
  local-ip ADDR          Set the IP address to which we bind locally
  no local-ip            Do not bind to a certain IP address
  remote-ip ADDR         Set the remote IP address to which we connect
  remote-port <1-65535>  Set the remote port to which we connect
  prefix PREFIX          Set the item/counter name prefix
  no prefix              Do not use a prefix
  enable                 Enable the reporter
  disable                Disable the reporter

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck 95bf828003 stats: Add the reporting framework
This commit provides the stats reporting framework that can manage
several types of measurement reporters. Initially support for
rate_ctr and the statsd protocol is included.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:03 +01:00
Jacob Erlbeck 45513e6040 stats/vty: Add stats_vty.c
This file will contain the VTY code related to statistics.

This commit adds a minimal file with just as single VTY command:

- show stats    This command shows all statistical values

To enable this and future commands, the main program needs to call
stats_vty_add_cmds().

Sponsored-by: On-Waves ehf
2015-10-29 00:09:04 +01:00
Jacob Erlbeck 7211fe157e stat/vty: Add vty_out_statistics_full to show all statistics
This functions shows the state of all osmo_counters, stat_item
groups, and counter groups.

Sponsored-by: On-Waves ehf
2015-10-28 23:53:46 +01:00
Jacob Erlbeck aec583f687 stat/vty: Use the iterator algorithms to show ctrg and statg
Currently the groups for stat_items and counter are iterated
manually.

This commit makes use of the new iterator functions to access the
single elements via handlers.

Sponsored-by: On-Waves ehf
2015-10-28 23:53:45 +01:00
Jacob Erlbeck c6a7108828 stats: Add stat_item_for_each functions
This commit adds the following functions:

  stat_item_for_each_group     Call a handler for each group
  stat_item_for_each_item      Call a handler for each item of a
                               group

Sponsored-by: On-Waves ehf
2015-10-28 23:51:24 +01:00
Jacob Erlbeck 423c1e5a4f core: Extend rate_ctr by helper functions
For global value reporting, some additional helper functions are
needed. The statsd protocol expects differential counter values,
which are currently not provided by rate_ctr (except for s/m/h/d
intervals).

This commit adds several helper functions to rate_ctr:

- rate_ctr_difference  returns the counter delta since the last
                       call to this function for a given counter
- rate_ctr_for_each_counter
                       iterates through each counter of a group
- rate_ctr_for_each_group
                       iterates through all globally registered
                       counter groups

Note that the rate_ctr_difference function can only be used by a
single backend, since it modifies the 'previous' field in the
rate_ctr obj.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:24 +01:00
Jacob Erlbeck b27b352e93 stats: Use a global index for stat item values
Currently each stat item has a separate index value which basically
counts each single value added to the item and which can be used by
a reporter to get all new values that have not been reported yet.
The drawback is, that such an index must be stored for each stat
item.

This commit introduces a global index which is incremented for each
new stat item value. This index is then stored together with the item
value. So a single stored index per reporter is sufficient to make
sure that only new values are reported.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:24 +01:00
Jacob Erlbeck 0a1400fc83 ns: Add statistics for some events
The following counters are added to the ns.nsvc counter group:
  lost.alive             The number of missing ALIVE ACK messages
  lost.reset             The number of missing RESET ACK messages

The following items are added to the ns.nsvc stat item group:
  alive.delay            The time in ms between sending ALIVE and
                         receiving the next ALIVE ACK

Sponsored-by: On-Waves ehf
2015-10-28 23:51:24 +01:00
Jacob Erlbeck 738d9e2210 stats: Add vty_out_stat_item_group
This functions dumps a whole stat item group to the VTY.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:12 +01:00
Jacob Erlbeck 9732cb4a92 stats: Add stat_item for value monitoring
This commit adds instrumentation function to gather measurement
and statistical values similar to counter groups.

Multiple values can be stored per item, which can be retrieved in
FIFO order. Getting values from the item does not modify its state to
allow for multiple independant backends (e.g. VTY and statd).

When a new value is set, the oldest value gets silently overwritten.
Lost values are skipped when getting values from the item.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:04 +01:00
Neels Hofmeyr 3de7b05d85 utils: add 'returns' doc to osmo_hexparse(). 2015-09-23 23:16:53 +02:00
Jan Engelhardt c2ddc4f555 build: have a disable-static build succeed
When using configure --disable-static, no libosmogsm.a will be
created, and the tests fail to link because symbols like _a5_3 and
_a5_4 are not exported through the only remaining libosmogsm.so.

A method to overcome this is an intermediate private non-distributed
library, examples of which are present in e.g. libabc, kmod and
systemd.

With this, disable-static can now be the default and practical compile
time be halved.
2015-09-16 18:08:48 +02:00
Holger Hans Peter Freyther d452a48ac6 Prepare new upstream release 2015-08-23 17:39:14 +02:00
Harald Welte 1a8c4e05fb Introduce gsm48_mi_type_name() function 2015-08-18 19:32:33 +02:00
Harald Welte 1f6aad1c04 Add G-RNTI derived TLLI types defined in 23.003 2015-08-18 19:32:33 +02:00
Holger Hans Peter Freyther a9e5252128 vty: Change API to have node installation be done by int
We are mixing enums and hope that no short-enums are used. This
is leading to a lot compiler warnings generated by clang. Change
the API to work with integers.

Porting:
The go_parent_cb implementations in the applications need to be
fixed. The API change leads to a compile time warning.

Fixes:
abis_om2000_vty.c:46:2: warning: implicit conversion from enumeration type 'enum bsc_vty_node' to
      different enumeration type 'enum node_type' [-Wenum-conversion]
        OM2K_NODE,
        ^~~~~~~~~
2015-08-05 04:22:56 +00:00
Holger Hans Peter Freyther c136da587f release: Prepare the 0.8.2 release
I have kind of used 0.8.1 by accident already so let us move
to 0.8.2 now.
2015-08-01 20:20:24 +02:00
Jacob Erlbeck c1cb75eff5 bssgp: Fix IMSI buffer size (Coverity)
Currently the size of the IMSI pointer is used instead of the size of
the talloc'ed buffer.

This commit changes the call to gsm48_mi_to_string to use the same
value that has been used with talloc_zero_size(). The length is
changed to 17 since that value is used for GSM_IMSI_LENGTH in
openbsc.

Fixes: Coverity CID 1040663
Sponsored-by: On-Waves ehf
2015-06-19 20:54:28 +02:00
Jacob Erlbeck 7f31c90b80 ipa: Add libosmogsm.map entry for ipa_ccm_idtag_parse_off
Addresses:
  CCLD     utils/utils_test
  utils_test.o: In function `test_idtag_parsing':
  git/libosmocore/tests/utils/utils_test.c:64: undefined reference to `ipa_ccm_idtag_parse_off'

Sponsored-by: On-Waves ehf
2015-06-04 08:52:36 +02:00
Holger Hans Peter Freyther f558ed4bb9 ipa: Properly parse LV stream of a ID_GET request
For some reason the structure is closer to be a LV (length
and value). The value is actually a tag but it is counted
inside the length. Introduce an overload of the parse function
to provide an offset for the length. This will be taken from
the returned length.
2015-06-02 15:52:06 +02:00
Harald Welte 908085ccbc Add APN utility function to libosmogsm
The current functions are used to 'qualify' an APN from the
user-supplied APN name (name identifier) towards the fully-qualified
APN name which is used in the .grps DNS zone.
2015-05-25 11:12:16 +08:00
Andreas Rottmann 9eb1c80020 build: Fix out-of-tree builds
Fixes:
In file included from ../../../include/osmocom/core/msgb.h:25:0,
                 from ../../../include/osmocom/sim/sim.h:4,
                 from ../../../src/sim/reader_pcsc.c:30:
../../../include/osmocom/core/bits.h:6:35: fatal error: osmocom/core/bit16gen.h: No such file or directory
 #include <osmocom/core/bit16gen.h>

In file included from ../../include/osmocom/core/msgb.h:25:0,
                 from ../../utils/osmo-sim-test.c:26:
../../include/osmocom/core/bits.h:6:35: fatal error: osmocom/core/bit16gen.h: No such file or directory
 #include <osmocom/core/bit16gen.h>
2015-05-17 19:19:09 +02:00
Jacob Erlbeck 9385d1e01b bssgp: Fix bssgp_tx_fc_bvc parameter type
Currently large values for Bmax default MS get sliced since a uint16_t is
used as the type of the corresponding parameter of bssgp_tx_fc_bvc.
GSM 48.018, 11.3.2 which in turn refers to 11.3.5 specifies a maximum
of 6MB (0xffff * 100).

This commit changes the type to uint32_t to cover the full value
range.

Sponsored-by: On-Waves ehf
2015-05-06 17:55:55 +02:00
Jacob Erlbeck 9731935984 bssgp: Fix call to llist_entry in fc_queue_timer_cfg
Currently the DL sometimes hangs and sometimes a lot of messages
(still not able to send PDU) are logged. This is caused by an invalid
timer delay computation, setting msecs either to 0 or to some big value.

This is due to an '&' operator at the wrong place, accessing some
parts in fc instead of the first element of the list.

This commit fixes that issue.

Sponsored-by: On-Waves ehf
2015-04-30 20:02:09 +02:00
Jacob Erlbeck 580af4be00 bssgp: Fix encoding of BVC_FLOW_CONTROL
Currently all 2 byte IE of the message are transmitted in the little
endian byte ordering.

This commit adds htons to the encoding expressions.

Sponsored-by: On-Waves ehf
2015-04-29 15:48:09 +02:00
Jacob Erlbeck 1bda44213e bssgp: Fix output of the VTY 'show bssgp stats' command
The output is terminated by a '\n' instead of VTY_NEWLINE.

This is fixed by the commit.

Sponsored-by: On-Waves ehf
2015-04-29 15:47:25 +02:00
Holger Hans Peter Freyther c2b4458e07 sim: Use extern for these structs to generate a linkage
Fixes:
duplicate symbol _ts102221_fcp_vals in:
    .libs/core.o
    .libs/card_fs_usim.o
duplicate symbol _pcsc_reader_ops in:
    .libs/reader.o
    .libs/card_fs_usim.o
2015-04-11 19:31:03 +02:00
Holger Hans Peter Freyther 1885395551 macaddr: Use the BSD code for Darwin as well
It simply compiles, no other testing has been done.
2015-04-11 19:29:52 +02:00
Holger Hans Peter Freyther 9a1a5a1c0a utils: Disable the weak symbol for darwin
We should consider simply removing the alias as we have
had several ABI changes since introducint the alias

utils.c:223:23: error: only weak aliases are supported on darwin
        __attribute__((weak, alias("osmo_hexdump_nospc")));
2015-04-11 19:28:00 +02:00
Jacob Erlbeck a84db61673 gprs: Add assertion for msg != NULL to bssgp_msgb_alloc (Coverity)
Currently out-of-memory is not handled by bssgp_msgb_alloc, leading
to SEGV failures if msgb_alloc_headroom returns NULL.

This commit adds an OSMO_ASSERT to catch this case, which improves
the situation only slightly. But bssgp_msgb_alloc is used in many
places without checking the return value, so just adding a
conditional early NULL return would not fix the issue either.

Fixes: Coverity CID 1293377
Sponsored-by: On-Waves ehf
2015-04-10 08:44:35 +02:00
Jacob Erlbeck d154f8bda2 msgb: Check the return value of msgb_alloc (Coverity)
In some places, the return value of msgb_alloc/msgb_alloc_headroom
is not checked before it is dereferenced.

This commit adds NULL checks to return with -ENOMEM from the calling
functions if the alloc function has failed.

Fixes: Coverity CID 1249692, 1293376
Sponsored-by: On-Waves ehf
2015-04-10 08:44:15 +02:00
Jacob Erlbeck 8d192d7153 ns: Log when sending fails (Coverity)
Currently the return value of the gprs_ns_tx family of functions is
often ignored. This is not a serious issue, since the successful
delivery of the messages is neither guaranteed nor acknowledged by
the network layer anyway.

Nevertheless this commit adds logging (level INFO) to gprs_ns_tx and
gprs_ns_msgb_alloc. The definition of the latter has been moved from
the header file to gprs_ns.c.

Fixes: Coverity CID 1040678, 1040679, 1040680, 1040681, 1040682,
   1040683, 1040684, 1040686, 1040687, 1040688, 1111545,
   1240203, 1240204
Sponsored-by: On-Waves ehf
2015-04-07 20:10:23 +02:00
Jacob Erlbeck b535e391b0 bssgp: Ensure non-NULL bctx before calling bssgp_rx_ptp (Coverity)
Currently bssgp_rx_ptp might be called with bctx being NULL, when the
NS BVCI is neither BVCI_SIGNALLING nor BVCI_PTM, but the message is
a BVC_RESET or it contains an BVCI IE != BVCI_SIGNALLING where the
BVCI is not known.

This patch ensures that bssgp_rx_ptp will only be called with a
non-NULL bctx. A log message will be issued, if the bctx is NULL when
this was not expected.

Fixes: Coverity CID 1040674
Sponsored-by: On-Waves ehf
2015-04-07 20:10:09 +02:00
Jacob Erlbeck c641591ae9 bssgp: Always expect dup != NULL in bssgp_tx_dl_ud (Coverity)
Currently the implementation of bssgp_tx_dl_ud conditionally adds
some optional IE if dup != NULL. Later on is dereferences dup to
access qos_profile and fc, but this without checking dup in advance.
This may lead to an segmentation violation fault.

This commit changes the value range of the function to only accept
dup != NULL. An assertion will fail otherwise. All other explicit
checks for non-NULL are removed.

Fixes: Coverity CID 1040673
Sponsored-by: On-Waves ehf
2015-04-07 20:09:48 +02:00
Holger Hans Peter Freyther 5fb265eaa7 ctrl: Avoid accessing cmd_desc->command out of bounds
We check that the amount of commands is not more than
we have but we don't check it the other way. It appears
that the vector is allowed to be bigger than the amount
of commands. So we match a prefix of a longer command
depending on the installation order.
2015-04-05 14:40:10 +02:00
Max f8699ca51e gsm: Add A5/3-4 cipher support
Signed-off-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-03-28 18:07:05 +01:00
Michael McTernan 789334640f vty: Fix writing the logging of category
Fix copy and paste issue introduced by Holger in
2d6ad13d8d.
2015-03-20 15:31:30 +01:00
Holger Hans Peter Freyther 267fd86e7d libctrl: Include config.h so we can include netinet/tcp.h
In e15ac060e7 we tried to fix
the nuttx build but we never included "netinet/tcp.h" after
it and the compiler warned about the unused "on" parameter
which we didn't notice because of the other warnings...

Include config.h so we can see if there is a tcp.h and then
include it.
2015-03-18 21:54:37 +01:00
Holger Hans Peter Freyther 6cce3d7153 msgfile: Fix warning on BSDs stdio
msgfile.c:116:16: warning: implicit declaration of function 'getline' is invalid in C99
      [-Wimplicit-function-declaration]
        while (getline(&line, &n, file) != -1) {
2015-03-18 21:54:37 +01:00
Holger Hans Peter Freyther ca8dcb7bff gsm0808: Remove duplicate initialization
These types were compatible so simply remove one.

Fixes:
gsm0808.c:323:37: warning: initializer overrides prior initialization  CC       gsm0480.lo
 of this subobject
        CC       abis_nm.lo
[-Winitializer-overrides]
                [GSM0808_IE_LSA_INFORMATION]            = { TLV_TYPE_TLV },
                                                            ^~~~~~~~~~~~
gsm0808.c:316:36: note: previous initialization is here
                [GSM0808_IE_LSA_INFORMATION]    = { TLV_TYPE_TLV },
                                                    ^~~~~~~~~~~~
2015-03-18 21:54:37 +01:00
Jacob Erlbeck 36153dc61a bssgp: Handle BSSGP STATUS messages
Currently incoming BSSGP STATUS messages are just logged and no other
action is taken. This makes it impossible for higher layers to react
to failures which are indicated by corresponding STATUS messages
unless a timeout is triggered as a result of that failure later on.

This commit adds a bssgp_rx_status() function and calls it on
incoming STATUS messages. That function logs a message, increments the
new BSSGP_CTR_STATUS counter if the bctx context exists and invokes
an NM_STATUS status indication. The latter will allow the application
to handle failures immediately. Since all STATUS messages should be
handled, the function is already called in bssgp_rcvmsg and the
message is no longer handled in (and will not reach) bssgp_rx_sign
and bssgp_rx_ptp.

Ticket: OW#1414
Sponsored-by: On-Waves ehf
2015-03-18 21:54:37 +01:00
Jacob Erlbeck 49ed9beed1 bssgp: Don't reply with STATUS when receiving a PtP STATUS message
Currently each incoming PtP BSSGP STATUS message is handled as 'not
yet implemented' and a BSSGP STATUS message (cause
BSSGP_CAUSE_PROTO_ERR_UNSPEC) is sent back to the peer. This will
cause endless messages loops if both peers use this BSSGP stack
implementation. This does not apply to signalling messages.

This commit changes the implementation of bssgp_rx_ptp() to just do
logging in this case.

Sponsored-by: On-Waves ehf
2015-03-18 21:54:37 +01:00
Jacob Erlbeck b61b2ca1a0 logging: Implement subsecond resolution of extended timestamps
Currently when using 'logging print extended-timestamp 1', the
subsecond part (milliseconds) of the printed timestamp is always 0.
This makes it difficult to correlate log entries with PCAP file
entries if there are many of them per second.

This patch changes _output in logging.c to use gettimeofday() instead
of time() when extended timestamps are enabled and replaces the '000'
by the milliseconds computed from tv_usec.

Sponsored-by: On-Waves ehf
2015-03-18 21:54:37 +01:00
Holger Hans Peter Freyther 879acef394 vty: Fix typo in the state creation
This got introduced in 2d6ad13d8d
and I thought that our vty tests would have caught such mistakes.
2015-01-27 11:08:27 +01:00
Holger Hans Peter Freyther 25aeab7a82 Prepare a new libosmocore release 2015-01-18 19:20:42 +01:00
Holger Hans Peter Freyther 4deb2dfa25 ctrl: Link to libraries we use symbols from
Fixes:
dpkg-shlibdeps: warning: symbol vector_free used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_set used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_set_index used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol tall_vty_vec_ctx used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol ipa_msg_recv_buffered used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol cmd_free_strvec used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_lookup used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_lookup_ensure used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol cmd_make_strvec used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_init used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
2015-01-18 19:20:42 +01:00
Holger Hans Peter Freyther c869069950 sim: Link to libosmocore and libosmogsm
The big LIBOSMOCORE_CFLAGS and LIBOSMOCORE_LIBS macros are not
defined when building linosmocore. Use the .la files directly

Fixes:
dpkg-shlibdeps: warning: symbol osmo_hexdump used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol gsm48_parse_ra used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol _talloc_zero used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol _talloc_memdup used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol talloc_strndup used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol msgb_length used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol msgb_alloc used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol msgb_free used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol talloc_strdup used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol talloc_free used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
2015-01-18 19:18:36 +01:00
Tobias Engel 419684e30c Supplementary Services (de)activation, interrogation added
These patches enhance the Supplementary Service (SS) processing from
only being able to handle USSD to other SS, specifically activation,
deactivation and interrogation of those SS. Registration is not yet
implemented.

include/osmocom/gsm/protocol/gsm_09_02.h has been added with needed
values for SS.

Modified by Harald Welte to keep the old ussd-only functiosn for API/ABI
stability.
2015-01-01 14:19:17 +01:00
Harald Welte 63b156a9e0 fixup 2014-12-30 00:43:32 +01:00
Harald Welte 783d073a37 add gsm0341_test to generate SMSCB hex strings
Those hex strings can then be copy+pasted into the OSmoNITB VTY
2014-12-29 17:09:11 +01:00
Holger Hans Peter Freyther 6ec6bd9d88 log: "logging level everything" is a badly named option.
We tried to fix it but it isn't that easy. The original fix was
cd6ed82d1f but we had to revert it
as "everything" is present/used in existing config files.

If we ever change the ABI we can make everything be something
that is > 0. For now use a wording that makes it obvious that
people should not use "everything".
2014-12-28 18:30:59 +01:00
Harald Welte 1b12d16c4c libosmo-gsm: Add PCHAN/LCHAN types for CBCH 2014-12-28 13:37:01 +01:00
Jacob Erlbeck a6be224b88 ipa: Return -errno instead of -1 in ipa_send
Currently, the ipa_send function returns -1 in one execution branch
to indicate an error and -EIO in another. This is not consistent and
can lead to a misinterpretation of the error code, since -1 is -EPERM
and in general, EPERM is not returned by write(2).

This patch changes the return code to -errno instead of -1 for the
case that write(2) fails for same reason. So -rc is always a sensible
error value if there is a failure.

Sponsored-by: On-Waves ehf
2014-12-22 14:44:59 +01:00
Holger Hans Peter Freyther 5f91a40068 logging: Call color only once and use the result
First we check if a color is defined and then we call it again
and use the result. Avoid the second call and use the result of
the previous call.
2014-12-05 10:29:45 +01:00
Holger Hans Peter Freyther 2d6ad13d8d logging: Make it possible to print category/subsys and timestamps
We want to see from which category/subsystem a certain log message
is coming from and use a different timestamp format as well. Add
two new bitfields. This doesn't change the size of the structure
and on 32bit we still have 27bits left.

The extended timestamp will take preference over the current and
default timestamp format.

Fixes: SYS#602
2014-12-05 10:23:28 +01:00
Holger Hans Peter Freyther a5dc19dc40 gtp: Add a global region for the gtp library of OpenGGSN
We want to use libosmocore/libosmovty in the GGSN sourcecode
and reserve a global region here.
2014-12-04 14:39:14 +01:00
Holger Hans Peter Freyther 9f0f978c8d vty: Check with the application before writing the config
For the BSC/NITB application we see that people modify the band
without modifying the ARFCN. This creates an unbootable config.
Using the new hook the BSC/NITB can check if the config is
consistent and prevent the config file being written.

Related: SYS#739
2014-12-04 14:39:14 +01:00
Harald Welte e15ac060e7 fix libosmocore build for NuttX target
this fixes some compilation issues with libosmocore under NuttX,
particularly as some #defines are missing or some header files are
slightly different.
2014-12-04 14:15:36 +01:00
Harald Welte 20144f7bc5 vty/vector.c: Use string.h, not memory.h 2014-11-14 15:22:37 +01:00
Harald Welte 78a870ed0f remove references to u_long type, use 'unsigned long' instead
.. Nuttx doesn't know u_long
2014-11-14 15:22:22 +01:00
Harald Welte 7b74dda31b remove references to u_char type, use 'unsigned char' instead
... u_char not being defined on Nuttx.
2014-11-14 15:22:14 +01:00
Harald Welte b592ab71a7 strrb.c: Use string.h, not strings.h
Not all systems have strings.h
2014-11-14 15:21:18 +01:00
Harald Welte 9e166e8e08 select.c: Add missing #include lines for string.h and sys/select.h
This is needed on Nuttx.
2014-11-14 15:21:01 +01:00
Jacob Erlbeck 0673b70f7d bssgp: Fix VTY command 'show bssgp nsei N'
Currently this command segfaults (at least when ASAN is enabled),
because when getting the NSEI the index to argv is wrong and out of
bounds.

This patch fixes the offset.

Sponsored-by: On-Waves ehf
2014-11-10 08:40:59 +01:00
Harald Welte 881b5169e5 sim: reader_pcsc:Remove dead code
PCSC_ERROR() macro is already performing error checking.

Found by coverity.
2014-10-27 20:46:40 +01:00
Holger Hans Peter Freyther b0310dd376 pcsc: Fix the include path
The pkg-config file already points into the PCSC directory. This
is needed for FreeBSD where /usr/local/include is not in the
default compiler search path.

On Debian
$ pkg-config --cflags libpcsclite
-pthread -I/usr/include/PCSC

On FreeBSD
$ pkg-config --cflags libpcsclite
-I/usr/local/include/PCSC -D_THREAD_SAFE -pthread
2014-10-27 12:00:37 +01:00
Harald Welte 33e940b862 sttrb / loggingrb: Use GPLv2+ as license, not AGPLv3+
according to Holger, using AGPLv3+ at the time was a mistake and the
license should always have indicated GPLv2+.
2014-10-26 20:52:25 +01:00
Harald Welte fd5ad17c5c Change copyright notice of ipa.c to GPLv2+
... which it should have been all along.
2014-10-26 20:50:31 +01:00
Harald Welte 388fb03406 Change license of gsm0411_smc/smr to GPLv2+
libosmocore.{so,a} should always have been GPLv2+.  However, when
migrating some code from OpenBSC or OsmocomBB, we sometimes introduced
it with a wrong license header.
2014-10-26 20:50:31 +01:00
Harald Welte 7fa89c2e88 Change license of libosmogb from AGPLv3+ to GPLv2+
The copyright holders Harald Welte, Holger Freyther, Andreas Eversberg
and sysmocom - s.f.m.c. GmbH (represented by Holger and Harald) agree
that the license of libosmogb should be GPLv2+ and not AGPLv3+.

The reason the source files stated AGPLv3+ is due to the history, as
they were moved from OpenBSC to libosmocore at the time we needed to use
them from osmo-pcu.  It was an oversight back then to not re-license
them accordingly.
2014-10-26 20:50:19 +01:00
Harald Welte 6729a9776a make sure to register DF.TELECOM and DF.GSM for SIM, USIM + TSIM
before we only did it partially, and by exporting data from sim,
rather than the new osim_int_cprof_add_{gsm,telecom}() functions.
2014-10-26 19:50:55 +01:00
Harald Welte db2b52ee84 sim: More talloc return NULL checking 2014-10-26 19:50:55 +01:00
Harald Welte 55790aa09a sim: Prepare infrastructure for protocols != T=0 and other drivers 2014-10-26 19:50:51 +01:00
Harald Welte aad7e0664b sim: Make TETRA SIM (TSIM) support compile 2014-10-26 19:09:24 +01:00
Harald Welte 30115dbd72 sim: Only one default_decode() function for all card types 2014-10-26 19:09:24 +01:00
Harald Welte 171c5b1ec7 sim: Add 3GPP TS 31.103 ISIM definitions 2014-10-26 19:09:24 +01:00
Harald Welte bb5f3c7e04 sim: Update to latest SIM/USIM specs and include size information 2014-10-26 19:09:23 +01:00
Harald Welte 0d24644f52 sim: reader_pcsc.c: Avoid compiler warnings by using pcsc-lite LONG 2014-10-26 19:09:23 +01:00
Harald Welte e8dd2bd4b5 sim: mark osim_msgb_cb as __may_alias__ to avoid gcc warnings 2014-10-26 19:09:23 +01:00
Harald Welte d83d29610a sim: further updates/fixes 2014-10-26 19:09:23 +01:00
Harald Welte 7674960ffa sim: add decoding of status words 2014-10-26 19:09:23 +01:00
Kevin Redon 43eabeeeaa sim: replaced function/structure comments with doxygen comments
affected files: sim.h, sim/core.c
affected funtions/strucutres: osim_new_apdumsg, osim_apdu_case,osim_apdu_cmd_hdr, osim_msgb_cb
2014-10-26 19:09:23 +01:00
Kevin Redon e07967f689 sim: renamed case to the one defined in ISO7816-3
APDU_CASE_2 becomes APDU_CASE_2S
APDU_CASE_2_EXT becmoes APDU_CASE_2E
APDU_CASE_3 becomes APDU_CASE_3S
APDU_CASE_3_EXT becmoes APDU_CASE_3E
APDU_CASE_4 becomes APDU_CASE_4S
APDU_CASE_4_EXT becmoes APDU_CASE_4E
2014-10-26 19:09:23 +01:00
Kevin Redon 0f0ee32d81 sim: comment/explain signature of osim_new_apdumsg 2014-10-26 19:09:22 +01:00
Harald Welte a5c9255baa sim: strip the SW from the returned data, as SW is passed in msgb->cb 2014-10-26 19:09:22 +01:00
Harald Welte 495fe2682c sim: Use autotools for libpcsc-lite linkage 2014-10-26 19:09:22 +01:00
Harald Welte ad41863b8d sim: add copyright notices and merge file_codec.c into core.c 2014-10-26 19:09:22 +01:00
Harald Welte d54c2ee8c5 initial checkin of 'libosmosim' 2014-10-26 19:09:22 +01:00
Jacob Erlbeck b43baf20c5 gprs: Don't discard SUSPEND/RESUME in bssgp_rcvmsg
Currently sending SUSPEND/RESUME messages to this function (like it
is done in the osmo-sgsn) results in STATUS messages complaining
about an unknown BVCI. The reason is, that these messages rely on a
TLLI/RAI pair to identify the context and do not contain an explicit
BVCI.

This patch modifies bssgp_rcvmsg() to only complain about and unknown
BVCI if one is given but a matching context is not found (except for
RESET messages). The ctx argument is removed from the functions
handling SUSPEND and RESUME since it will always be NULL then.

Sponsored-by: On-Waves ehf
2014-10-23 18:53:02 +02:00
Max 862ba65bd6 Move common socket routine into separate function
Signed-off-by: Max <max.suraev@fairwaves.co>
2014-10-13 21:29:42 +02:00
Holger Hans Peter Freyther 10dd73cf6a bssgp: Free msgb in case of error when calling into gprs_ns_sendmsg
In the OsmoSGSN we have a crash with a DEAD/BLOCKED GPRS-NS and
segmented SN-UNITDATA. For the caller it is not easy to know if
the passed msg buffer has been freed or not. The most easy solution
is to always take the ownership and either pass it on or free it
in case of an error.

Adjust indirect and direct callers of gprs_ns_sendmsg. I found
the following call-chains with an external msgb parameter.

gprs_ns_sendmsg
  <- _bssgp_tx_dl_ud
     <- bssgp_fc_in
        <- bssgp_tx_dl_ud

Update the test to allocate a real msgb because for the test with
'1000' we will msgb_free it right away.

Sponsored-by: On-Waves ehf
2014-10-10 17:55:13 +02:00