Commit Graph

1034 Commits

Author SHA1 Message Date
Philipp Maier 7c900c20db ipaccess: make ipaccess-config build again
The nanobts related tool ipaccess-config is currently not built due
to dependancy issues added by GSCON FSM.

- Re-Add ipacces-config to makefile.am
- Add dependencies and stubs

Change-Id: I1d0a45bed61b45352ed305b6b1fd8d9b3d3cecae
Related: OS#2823
2018-03-22 19:05:57 +00:00
Harald Welte ead291aaf2 bssmap: State correct speech codec in ASSIGNMENT COMPLETE
Correctly compute the TS 48.008 "speech mode" (codec) for AMR on TCH/F.

There are way too many different ways how to express a given voice
codec.  There are two different schemes in TS 48.008 alone, plus one
on TS 48.058 and one in 04.08 / 44.018.  Let's avoid unneeded
conversion (that we might get wrong) and avoid storing information in
a sub-struct of the lchan if we can simply derive it from the lchan
at the time we need it.

Also, move BSSAP related encoding/conversion functions closer to the
user (osmo_bsc_bssap), rather than in libbsc.

Without this patch, TCH/F with AMR was erroneously reported as TCH/H
with AMR in the BSSMAP ASSIGNMENT COMPLETE.  After this patch, it's
reported correctly.

Change-Id: I6feebfae77fdc93a7ce333a25dd9b9267c5a4a2e
Related: OS#3094
Related: OS#3095
Related: OS#3096
2018-03-22 15:15:12 +00:00
Harald Welte 6900f81236 GSCON FSM: Fix argument order when calling gsm0808_assign_req()
The first argument is the channel mode (codec), the second one is
a flag whether or not it's a full-rate channel.

Before this patch the two arguments are reversed, resulting in
* all assignments being TCH/F in general
* all assignments have FR1 as codec, as the full_Rate=1 is interpreted as FR1

Change-Id: I80f2a016a7646252bce8d86ed0bab236f3adbfca
Related: OS#3094
2018-03-22 15:15:12 +00:00
Harald Welte 31a6368703 BSSAP: document match_codec_pref() more thoroughly
Change-Id: If08c2c2db674d6ddc43339744a78b1632d075d4a
2018-03-22 15:15:11 +00:00
Harald Welte b360ec1b4a BSSAP: Fix test_codec_pref() implementation for AMR
In AMR-type cahnels, the gsm0808_speech_codec doesn't only include
the codec (like EFR/FR/AMR) but also the specific codec configuration,
i.e. the sub-set of AMR modes.

Hence, we cannot convert from a channel type (just the codec) to the
full gsm0808_speech_codec and then memcmp() that with the codec config
received from the MSC.  Rather, we must only compare the *type*.

Change-Id: I0a3f362667a689135d5b62d151d491490dfd2976
Related: OS#3094
2018-03-22 15:15:11 +00:00
Philipp Maier 12e3c81dd1 cosmetic: remove old, already commented-out code
Change-Id: Ief994b840e3fe694b37330c46c3899746d810a39
Related: OS#2823
2018-03-22 12:55:47 +00:00
Philipp Maier 5444f13387 cosmetic: remove dead code and obsolete fixmes
Change-Id: Ib171f4b5697c04603a20ffc6ebd617260a38ccb4
Related: OS#2823
2018-03-22 12:55:46 +00:00
Philipp Maier 70fcde63a1 Cosmetic: fix missing semicolon after osmo-assert
- add the missing semicolong,
- correct wrong indentation caused by the missing semicolon

Change-Id: I9a1144b70ab82156175c6cdee32a6d22b4b53539
Related: OS#2823
2018-03-22 12:55:46 +00:00
Philipp Maier 393165cb67 cosmetic: fix incomplete sentence in comment.
Change-Id: I6a04811704750cf715e72eba2959d08e761ced29
Related: OS#2823
2018-03-22 12:55:44 +00:00
Philipp Maier 8ff02fc065 cosmetic: remove needless fixme note.
Change-Id: I4860412f8228756f7cd5669c4f6c7d845904e36b
Related: OS#2823
2018-03-22 12:55:43 +00:00
Philipp Maier 4be98dc5d6 cosmetic: fix argument order of forward_dtap()
The order of the arguments for forward_dtap() differs from
submit_dtap() and sigtran_send()

- bring arguments into a uniform order for all three functions

Change-Id: Ida77c82e600f99d690ffa1850450925359e33ae8
Related: OS#2823
2018-03-22 12:55:43 +00:00
Philipp Maier 458d8a19c9 cosmetic: remove unused enum members
The enum gscon_fsm_event has three unused members.

- remove GSCON_EV_RR_HO_ACC, GSCON_EV_RR_HO_COMPL, GSCON_EV_RR_HO_FAIL

Change-Id: I301f7160b9ec8380849f9c9906b41c121a54f49f
Related: OS#2823
2018-03-22 12:55:40 +00:00
Neels Hofmeyr 48213a2750 fixup: apply mnc3 change also in ipaccess/network_listen.c
Preceding commit I38ac98a4d25159cfd4f686efbfbaf8f00625a6d8 changed the
ipac_bcch_info.cgi type to osmo_cell_global_id, but did not carry out
corresponding changes in ipaccess/network_listen.c.

The reason this was not caught is that recent commit
I68286d26e2014048b054f39ef29c35fef420cc97 adding the new gscon FSM actually
disables ipaccess-config in the build.

Fix the build, given that ipaccess-config were re-enabled.

Change-Id: I15cd58e8ba0563ce4e42a61e79d01394b61593dd
2018-03-22 05:33:22 +01:00
Neels Hofmeyr da5b09a08e cosmetic: abis_nm: use osmo_cell_global_id, parse 3-digit MNC
Instead of a local redefinition, use osmo_cell_global_id.

This change is cosmetic because the decoded PLMN is currently actually never
used.

Change-Id: I38ac98a4d25159cfd4f686efbfbaf8f00625a6d8
2018-03-22 04:13:09 +00:00
Stefan Sperling 9cf2babed9 fix an error message in bssmap_handle_paging()
This error message suggested that parsing a cell identifier list
failed because the list was too short. While, in fact, this code
has no insight into the reason behind the parsing failure.
A generic error message is more appropriate.

Change-Id: I033747e2183984159f1505e772d7c9494b759058
Related: OS#3073
2018-03-19 13:38:15 +01:00
Pau Espin 9d075ea6f7 pcu_sock.c: Avoid breaking strict-aliasing on ptr derreference
Fixes following warning:
pcu_sock.c: In function 'pcu_rx_data_req':
pcu_sock.c:406:3: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
   tlli = *((uint32_t *)data_req->data);
   ^

Change-Id: I5c93487c72d15b061e73ed4f9acbf2e77dec967a
2018-03-18 17:31:49 +00:00
Harald Welte f94cbf607b RR: Send RR STATUS in case of unsupported/unknown message
This fixes BSC_Tests.TC_err_84_unknown_msg

Related: OS#2903
Change-Id: I7ecb48971c6a162c7f4c749d128c31d0dbc4916f
2018-03-17 21:46:56 +01:00
Harald Welte 4a1580b7ff paging: Unify formatting of log messages with (bts=%d) prefix
Change-Id: I3eabe8b7553711a4de02fe87994163bfe8955509
2018-03-17 19:15:26 +01:00
Harald Welte fe00edae7f abis_nm: Improve and fix OML logging
This code is among the oldest surviving parts of old bsc_hack/OpenBSC,
and it shows.  We used arcane constructs to puzzle together log
messages, attempting to switch the log level between a LOGP and LOPGC
[which doesn't work], not properly used log levels in general, ...

Let's fix this up by using the new abis_nm_dump_foh() function
introduced in libosmocore I9b2c2afec28882b817d104d5b062651ade7aadd8

Change-Id: Ibd757836c39edd2d1ce59e528342f8923a9e75e4
2018-03-17 19:15:22 +01:00
Harald Welte e9903fdec4 cosmetic: Fix infinite number of formatting errors in gscon_fsm_states
I'm not sure how this got past our review :/  Guess I need to be extra
careful.

Change-Id: I8724cadda774c96f13f957d6d5e708bebb81e3ba
2018-03-17 17:14:28 +01:00
Pau Espin 55677de7a5 bsc_subscr_conn_fsm.c: Fix wrong param list passed to LOGPFSML
Fixes: 3561bd4897

Change-Id: Ifbf84bd3b64eea5bf315b83c95561e4534acc3b7
2018-03-17 01:12:55 +01:00
Pau Espin f73886992d bsc_api.c: bsc_handle_lchan_signal: Remove unused variable
Variable is unused since 3561bd4897.

Change-Id: I8ecff940ae848b965b26b7dc07153dd88b365fe4
2018-03-17 01:00:12 +01:00
Pau Espin b1b8b624a6 ipaccess-config: Check cmdlie arg unit-id format
Print a clear error when the format in not correct. I was in the
situation several times in which I was passing "123" instead of
"123/0/0", and spent a while seeing what was wrong.

Change-Id: I70906939b3320473c56a87929c4886aac9d7d064
2018-03-16 18:54:44 +00:00
Pau Espin 8972f3fe4c abisip-find: Improve use information output
Interestingly, SO_BINDTODEVICE used to bind to a specific iface
requires root permissions. However, the same target can be accomplished
by binding to a local IP addr set on the target interface, which doesn't
require root permissions in this case.

Change-Id: Ie123c45005d68b186cb06538f7bd31f3b2513007
2018-03-16 18:54:44 +00:00
Harald Welte 3561bd4897 introduce an osmo_fsm for gsm_subscriber_connection
In the current implementation of osmo-bsc, the subscriber connection is
not handled (very) statefully. However, there is some state keeping in the
code that handles the mgcp connection, but there are still to much loose ends
which allow odd situations to happen, which then lead severe error situations
(see also closes tags at the end) This commit adds a number of improvements
to fix those problems.

- Use an osmo-fsm to control the gsm_subscriber_connection state and
  make sure that certain operations can only take place at certain states
  (e.g let connection oriented SCCP traffic only pass when an SCCP connection
  actually exists.

  Remove the old osmo_bsc_mgcp.c code. Use the recently developed MGCP client
  FSM to handle the MGCP connections.

  Also make sure that stuff that already works does not break. This in
  particular refers to the internal handover capability and the respective
  unit-tests.

  See also OS#2823, OS#2768 and OS#2898

- Fix logic to permit assignment to a signalling channel. (OS#2762)

- Introduce T993210 to release lchan + subscr_conn if MSC fails to respond

  The GSM specs don't have an explicit timer for this, so let's introdcue
  a custom timer (hence starting with 99).

  This timeout catches the following situation:
  * we send a SCCP CR with COMPL_L3_INFO from the MS to the MSC,
  * the MSC doesn't respond (e.g. SCCP routing failure, program down, ...)

  The MS is supposed to timeout with T3210, 3220 or 3230.  But the BSC
  shouldn't trust the MS but have some timer on its own.

  SCCP would have a timer T(conn est), but that one is specified to be
  1-2min and hence rather long.

  See also: OS#2775

- Terminate bsc_subscr_conn_fsm on SCCP N-DISC.ind from MSC

  If the MSC is disconnecting the SCCP channel, we must terminate the FSM
  which in turn will release all lchan's and other state.

  This makes TC_chan_rel_hard_rlsd pass, see also OS#2731

  As a side-effect, this fixes TC_chan_act_ack_est_ind_refused(),
  where the MSC is answering with CREF to our CR/COMPL_L3.

- Release subscriber connection on RLL RELEASE IND of SAPI0 on main DCCH

  The subscriber connection isn't really useful for anything after the
  SAPI0 main signalling link has been released.  We could try to
  re-establish, but our best option is probably simply releasing the
  subscriber_conn and anything related to it.

  This will make TC_chan_rel_rll_rel_ind pass, see also OS#2730

This commit has been tested using the BSC_Tests TTCN3 testsuit and the
following tests were passed:

TC_chan_act_noreply
TC_chan_act_ack_noest
TC_chan_act_ack_est_ind_noreply
TC_chan_act_ack_est_ind_refused
TC_chan_act_nack
TC_chan_exhaustion
TC_ctrl
TC_chan_rel_conn_fail
TC_chan_rel_hard_clear
TC_chan_rel_hard_rlsd
TC_chan_rel_a_reset
TC_rll_est_ind_inact_lchan
TC_rll_est_ind_inval_sapi1
TC_rll_est_ind_inval_sapi3
TC_rll_est_ind_inval_sacch
TC_assignment_cic_only
TC_assignment_csd
TC_assignment_ctm
TC_assignment_fr_a5_0
TC_assignment_fr_a5_1_codec_missing
TC_assignment_fr_a5_1
TC_assignment_fr_a5_3
TC_assignment_fr_a5_4
TC_paging_imsi_nochan
TC_paging_tmsi_nochan
TC_paging_tmsi_any
TC_paging_tmsi_sdcch
TC_paging_tmsi_tch_f
TC_paging_tmsi_tch_hf
TC_paging_imsi_nochan_cgi
TC_paging_imsi_nochan_lac_ci
TC_paging_imsi_nochan_ci
TC_paging_imsi_nochan_lai
TC_paging_imsi_nochan_lac
TC_paging_imsi_nochan_all
TC_paging_imsi_nochan_plmn_lac_rnc
TC_paging_imsi_nochan_rnc
TC_paging_imsi_nochan_lac_rnc
TC_paging_imsi_nochan_lacs
TC_paging_imsi_nochan_lacs_empty
TC_paging_imsi_a_reset
TC_paging_counter
TC_rsl_drop_counter
TC_classmark
TC_unsol_ass_fail
TC_unsol_ass_compl
TC_unsol_ho_fail
TC_err_82_short_msg
TC_ho_int

Authors:
Harald Welte <laforge@gnumonks.org>
Philipp Maier <pmaier@sysmocom.de>
Neels Hofmeyr <neels@hofmeyr.de>

Closes: OS#2730
Closes: OS#2731
Closes: OS#2762
Closes: OS#2768
Closes: OS#2775
Closes: OS#2823
Closes: OS#2898
Closes: OS#2936
Change-Id: I68286d26e2014048b054f39ef29c35fef420cc97
2018-03-16 18:49:47 +00:00
Stefan Sperling 2cf46b97d3 use libosmocore to parse cell identifiers in osmo-bsc
This replaces custom cell identifier parsing in the paging code with
calls to the new cell identifier parser implementation in libosmocore
(which was derived from the code that is now being replaced here).

The bssap tests will fail unless this other change is merged to
libosmocore as well: https://gerrit.osmocom.org/#/c/7288/

Related: OS#2847
Change-Id: I9e2002fbbe135287e9ce09caa3f0a85a84529463
Depends: I7f3e8ace26176e9cbfe2542961d2a95662aa4d97
2018-03-14 21:02:33 +00:00
Pau Espin b4d39eb67e ipaccess-config: Improve handling of last parameter
Check exact number of parameters to avoid explicit void params ("") to
be used as BTS IP by an incorrect caller.
Exit successfully if firmware analysis is requested and there's no BTS
IP provided (meaning no BTS set up is required).
Save BTS IP into bts_ip variable as using optind is tricky.
Use new bts_ip variable to print the IP of the BTS we are trying to
connect to.

Change-Id: I8071aaf2be217207261ad698f87344f7ca15ccc4
2018-03-13 08:40:03 +00:00
Pau Espin c80b876344 ipaccess-config: Add missing path with log error
Change-Id: Id903e3e20e12a143cedab72dc14669c07f4d11ac
2018-03-13 08:40:01 +00:00
Pau Espin 5e2812c94d ipaccess-config: Enable logging all categories to print errors
log_parse_category_mask is preventing errors from being printed, which
makes debugging issues with the application harder.

Change-Id: I69ee2de921979f8bfaa8b501c6b05db1717b0c36
2018-03-13 08:39:52 +00:00
Pau Espin 34b59acc83 abisip-find: Add --format-json option
This format outputs json format which can be more easily parsed if
launched by scripting launguage with json support like python.

Change-Id: Ib2d461c79fbc242141dc342578467c3e9c6ed5fc
2018-03-12 17:58:36 +00:00
Pau Espin e845b0fc0f abisip-find: Force stdout buffer flush
If list-view is not enabled, then a line with the new BTS is printed to
stdout buffer. That's fine if stdout goes to the terminal, since it's
line buffered, but if abisip-find write to a pite or to a file, then the
buffer won't be flushed until a full page is full, which may take a
while, and produce delays in scripts using abisip-find.

Change-Id: I19f8c7f747fa7a130a436e5e07a8648932404bf0
2018-03-12 17:58:36 +00:00
Pau Espin 4becc845b8 abisip-find: Add option to bind to a specific source address
When the BTS answers, it uses the src addr used by abisip-find to send
the boardcast packets. This way a different IP than the one
automatically specified by default routing can be used.
An extra benefit: more than one abisip-find process can now be run in
parallel on the same interface.

Change-Id: I6b805f22d261003239d7002d9e568ea4797a2b0b
2018-03-12 17:58:36 +00:00
Philipp Maier f27dbc5f88 bsc_vty: display bts features in show bts
The command show bts displays all kind of BTS related info, but it
does not display the bts features yet.

- display bts specific features in vty-command show bts

Change-Id: I650133563436349d4ce55f292ea683dbb2ae68d7
2018-03-12 10:18:07 +00:00
Philipp Maier 8c498fc26b gsm_data: use feature list from libosmocore
In order to avoid code duplication the feature list (bit masks) and
the desciptive value strings as well as the function to set and get
the feature bits have been moved to libosmocore.

- use feature list functionality provided by libosmocore

Depends: libosmocore Change-Id Id0c35aef11aa49aa40abe7deef1f9dbd12210776
Change-Id: I3e80517539cc5d0e5d8189d434a5e3cc0fdea1a0
2018-03-12 10:18:05 +00:00
Harald Welte d6012ffc19 sysinfo: Fix regression causing missing L2 Pseudo-Length in SI5/SI6
Fixes a regression in the code generating SI5* and SI6 on SACCH,
where the L@ pseudo-length is not part of the 'struct' definition
we have in gsm_04_08.h and hence has to be encoded manually into
the first byte of the SI buffer.

We were doing this correctly until April 2017, when the following
patch was merged:

> commit 6f0e50c833
> Author: Max <msuraev@sysmocom.de>
> Date:   Wed Apr 12 15:30:54 2017 +0200
>
>     Prepare for extended SI2quater support

This patch cacidentially overwrote the l2_plen that was just enoded,
as the 'struct' was no longer pointing to 'output' (si_buf+1), but
now directly to the start of the si_buf.

NOTE: The Wireshark RSL dissector (and more recently also LAPDm)
contain a similar bug, so the SACCH will not be decoded correctly
after applying this patch. Nevertheless, it's correct.

Change-Id: Ie8c907b1317566670aeb68f933ceefd552c17565
Closes: #3059
Related: #2963
2018-03-12 00:28:58 +01:00
Neels Hofmeyr 4ac7763bc7 pcu_if: implement support for 3-digit MNC
Add the mnc_3_digits member to the info_ind.

Instead of changing to e.g. osmo_plmn_id, add the flag separately, and instead
of bool use a uint8_t, to not raise any struct packing issues and clarify the
flag's size beyond any doubt.

Bump the PCU interface version to 9.
This is one part of the three identical pcuif_proto.h patches:
- I49cd762c3c9d7ee6a82451bdf3ffa2a060767947 (osmo-bts)
- I787fed84a7b613158a5618dd5cffafe4e4927234 (osmo-pcu)
- I78f30aef7aa224b2e9db54c3a844d8f520b3aee0 (osmo-bsc)

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore)
Change-Id: I78f30aef7aa224b2e9db54c3a844d8f520b3aee0
2018-03-11 00:45:45 +01:00
Neels Hofmeyr 7ec27564c9 cosmetic: typo in log: handover_decision2.c: 'measuements'
Change-Id: I8a92a03feb7dbef2bb008016310ec243226a7c7a
2018-03-08 03:33:21 +01:00
Neels Hofmeyr 7e52ae1e73 cosmetic: hodec2: log nr of neighbors in meas report
Rationale: explicitly indicate the case of zero neighbors.

Change-Id: I09ddfd5b09883ec0124fe485346d9ed26de454e8
2018-03-08 03:32:52 +01:00
Neels Hofmeyr f0141b95cd gsm48_parse_meas_rep(): set num_cell=0 if no neighbor cells are reported
Set mr->num_cell to 0 if the bits reflect 0x7, which means that no neighbor
cell measurements are enclosed in the report.

The code in gsm48_parse_meas_rep() acknowledges that, but nevertheless left
num_cell == 7, and evaluating code commonly runs into the mistake of assuming
that actually seven neighbors are being reported on, like:

 MEASUREMENT REPORT
   0: arfcn=0 bsic=0 neigh_idx=0 rxlev=0 flags=0
   1: arfcn=0 bsic=0 neigh_idx=0 rxlev=0 flags=0
   2: arfcn=0 bsic=0 neigh_idx=0 rxlev=0 flags=0
   3: arfcn=0 bsic=0 neigh_idx=0 rxlev=0 flags=0
   4: arfcn=0 bsic=0 neigh_idx=0 rxlev=0 flags=0
   5: arfcn=0 bsic=0 neigh_idx=0 rxlev=0 flags=0
   6: arfcn=0 bsic=0 neigh_idx=0 rxlev=0 flags=0

There are only up to 6 slots for neighbors, the above listing actually printed
7, because num_cell == 7, which is a potential segfault.  (sometimes it printed
uninitialized values instead of 0)

We could fix all meas rep consumers to know what num_cell == 7 means, but
instead setting it to 0 trivially fixes all of them.

Change-Id: Ie12210660a04f2d664ddc92e7ad7fc39ee474180
2018-03-08 03:28:54 +01:00
Neels Hofmeyr f93970b167 implement support for 3-digit MNC with leading zeros
Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout
the code base to be able to handle an MNC < 100 that has three digits (leading
zeros).

The changes to abis_test and gsm0408_test show that this code now handles
3-digit MNC correctly, by not dropping the leading zero as 0xf in the encoded
PLMN.

Re-implement CTRL commands 'mcc', 'mnc' and 'mcc-mnc-apply' to preserve the
presence of the third digit of the MNC. Always reply with all leading zeros.
Adjust the expected results in ctrl_test_runner.py, to show that it works.

In VTY and CTRL, the parsing of MCC and MNC is inherently made stricter by use
of osmo_{mcc,mnc}_from_str() -- they will no longer allow surplus characters
and detect errno returned by strtol() (in contrast to atoi()).

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore),
	 Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore),
	 I020a4f11791c61742a3d795f782805f7b7e8733e (libosmocore)
Change-Id: I8e722103344186fde118b26d8353db95a4581daa
2018-03-07 15:34:48 +00:00
Vadim Yanitskiy 56dec0c753 libbsc/bsc_vty.c: prevent uninitialized access
If an out of range 'Last Valid Block' value for 'smscb-command'
is passed, a 'last_block' of the 'rsl_ie_cb_cmd_type' struct
could be uninitialized. Let's prevent this.

Found using Clang Static Analyzer.

Change-Id: I57635f2f482ff476ab697b1b9e872ce90aafb999
2018-03-06 17:18:25 +07:00
Neels Hofmeyr f7a6329bbd cosmetic: bsc_network_init(): imply default 001-01 PLMN
All callers pass mcc=1, mnc=1, so just have it as default.
(Prepare for net->country_code etc to be replaced by net->plmn)

Change-Id: Ic16bc0bab3f2d4721e86a1a04f9d9f988d777df2
2018-03-05 05:37:54 +01:00
Neels Hofmeyr 4d358c00e1 gsm48_ra_id_by_bts(): struct gsm48_ra_id* instead of buf
Move from using deprecated gsm48_construct_ra(), which uses a buf, to
gsm48_encode_ra(), which uses a gsm48_ra_id argument. Pass struct gsm48_ra_id
around instead of a buf.

struct gsm48_ra_id is the "encoded" representation of the bytes in a typical
MCC-MNC-LAC-RAC (04.08 Routing Area Id IE, 3GPP TS 24.008 § 10.5.5.15). Using
the struct spares using magic numbers for byte offsets.

In the process, fix a sanitizer warning for unaligned access by using memcpy()
instead of pointer assignment:

  osmo-bsc/src/libbsc/abis_nm.c:2857:27: runtime error: store to misaligned address 0x7ffe8e0d6695 for type 'uint16_t', which requires 2 byte alignment

Note that (besides removing a now unnecessary cast) the gsm0408_test and
abis_test tests of RAI / CGI encoding remain stable, which indicates that the
new code is still correct.

Change-Id: I0d3908fb8ca1e2e669d257b5d59b40675fa85d06
2018-03-05 05:35:54 +01:00
Neels Hofmeyr 302f8659b4 compiler warning: chan_compat_with_mode(): clearly handle all enum vals
Change-Id: I5b3a9a9f0e88b42eed1591632dee1fa00e79f3a3
2018-03-05 00:59:44 +01:00
Harald Welte 0bfd8d9d37 bsc_vty: Merge more VTY documentation string #defines
Change-Id: I3fcbcd319813e3b220daf8170cadd4ebb2aefa0f
2018-03-04 09:00:29 +00:00
Harald Welte 383a059a12 Revert "Generate the S_L_INP_TEI_UP signal earlier."
This reverts commit faf0982ae2, as it
introduces a severe regression: No more BCCH FILL / SACCH INFO are sent
upon RSL establishment to the BTS.  See OS#2719 for more details

Change-Id: I8a4f3be9928bc3a0b61f23dc3e41200105204651
Related: OS#2719
2018-03-02 14:15:23 +00:00
Philipp Maier 3d5818a901 a_reset: Add FSM event names
The FSM lacks a proper definition of the FSM event names. This
causes problems when inspecting the FSM using the VTY.

- Add proper FSM Event names

Change-Id: Ief1eff45a896d6191bdc64c232be69e85bfc63dc
Related: OS#2924
2018-03-01 23:08:15 +00:00
Neels Hofmeyr 0a5a47addf fix build: gprs_ra_id_by_bts(): ensure to init all values
After recent libosmocore commit "implement support for 3-digit MNC with leading
zeros" c4fce1425e19d604c199c895e227dc2519110456
Id2240f7f518494c9df6c8bda52c0d5092f90f221, struct gprs_ra_id has a new member,
namely mnc_3_digits. In gprs_ra_id_by_bts(), this new member is now not
initialized and may end up having an arbitrary value, which then may amount to
mnc_3_digits == true. Hence the resulting BCD representation of the MCC-MNC may
inadvertently and randomly indicate a leading zero on the MNC.

Use a struct assignment so that all members are guaranteed to be set, and so
that mnc_3_digits will be zero in all cases.

Since above libosmocore commit, nanobts_omlattr_test fails "randomly", fixed by
this patch.

Change-Id: I872ae3b2b0a0cd8f932f3a5fbc77c0dbfcb28bbf
2018-03-01 19:54:40 +01:00
Stefan Sperling faf0982ae2 Generate the S_L_INP_TEI_UP signal earlier.
The S_L_INP_TEI_UP signal was generated when the first message from a BTS
arrives on the OML/RSL link, rather than when the OML/RSL link comes up.
Instead, generate this signal when the link is brought up, so we
intitialize state regardless of how a particular BTS behaves.

Tested with osmo-bts-virtual and virtphy/mobile programs,
and with a sysmobts.

Change-Id: I3b76ae6b00043e706dddc78209311e00ace85bb7
Related: OS#2719
2018-02-28 18:21:14 +01:00
Harald Welte b22dcb87cf Align syntax of "handover" + "assignment" command with that of lchan act/deact
We already have other commands that operate on a given bts/trx/ts/ss,
let's make sure they have a shared/common syntax for consistency.

This also fixes the issue that the handover/assignment commands were
active already in VIEW_NODE, while they should only have been in
ENABLE_NODE.

Change-Id: I1f31e9adf9c75348809ebf9f40f6c69fab248e43
2018-02-28 15:08:56 +00:00
Stefan Sperling 6442e4327b Add support for Access Control Class ramping.
Access Control Class (ACC) ramping is used to slowly make the cell
available to an increasing number of MS. This avoids overload at
startup time in cases where a lot of MS would discover the new
cell and try to connect to it all at once.

Ramping behaviour can be configured with new VTY commands:

  [no] access-control-class-ramping
  access-control-class-ramping-step-interval (<30-600>|dynamic)
  access-control-class-ramping-step-size (<1-10>)

(The minimum and maximum values for these parameters are hard-coded,
but could be changed if they are found to be inadequate.)

The VTY command 'show bts' has been extended to display the
current ACC ramping configuration.

By default, ACC ramping is disabled.

When enabled, the default behaviour is to enable one ACC per
ramping step with a 'dynamic' step interval. This means the
ramping interval (time between steps) is scaled to the channel
load average of the BTS, i.e. the number of used vs. available
channels measured over a certain amount of time.

Below is an example of debug log output with ACC ramping enabled,
while many 'mobile' programs are concurrently trying to connect
to the network via an osmo-bts-virtual BTS. Initially, all ACCs
are barred, and then only one class is allowed. Then the current
BTS channel load average is consulted for scheduling the next
ramping step. While the channel load average is low, ramping
proceeds faster, and while it is is high, ramping proceeds slower:

(bts=0) ACC RAMP: barring Access Control Class 0
(bts=0) ACC RAMP: barring Access Control Class 1
(bts=0) ACC RAMP: barring Access Control Class 2
(bts=0) ACC RAMP: barring Access Control Class 3
(bts=0) ACC RAMP: barring Access Control Class 4
(bts=0) ACC RAMP: barring Access Control Class 5
(bts=0) ACC RAMP: barring Access Control Class 6
(bts=0) ACC RAMP: barring Access Control Class 7
(bts=0) ACC RAMP: barring Access Control Class 8
(bts=0) ACC RAMP: barring Access Control Class 9
(bts=0) ACC RAMP: allowing Access Control Class 0
(bts=0) ACC RAMP: step interval set to 30 seconds based on 0% channel load average
(bts=0) ACC RAMP: allowing Access Control Class 1
(bts=0) ACC RAMP: step interval set to 354 seconds based on 59% channel load average
(bts=0) ACC RAMP: allowing Access Control Class 2
(bts=0) ACC RAMP: step interval set to 30 seconds based on 0% channel load average
(bts=0) ACC RAMP: allowing Access Control Class 3
(bts=0) ACC RAMP: step interval set to 30 seconds based on 0% channel load average

Change-Id: I0a5ac3a08f992f326435944f17e0a9171911afb0
Related: OS#2591
2018-02-27 14:29:39 +00:00
Harald Welte 5d22458169 osmo-bts/nanobts: Set RACH_Busy Threshold to -90 dBm
In the past we used to set this to "-10 dBm" which means that basically
no RACH ever passed that treshold and in the associated CCCH LOAD IND
the number of busy slots was always zero.

Let's set the default to -90dBm.  The user can of course always
configure a different value in the VTY.

This means that now any RACH slot signal level >= 90 dBm counts as
"busy" in those CCCH LOAD IND (RACH).

Change-Id: Ib9cbb786d19acc74f0951930b0dc9284854c6000
Closes: OS#3004
Related: OS#3003
2018-02-27 10:09:43 +01:00
Philipp Maier c9b0b262c3 paging: fix paging attemt rate counter
The rate counter BSC_CTR_PAGING_ATTEMPTED does not increment when
a paging request is sent to the BSC. The reson for this is that the
function call to rate_ctr_inc() is located in a dead code section.

- Move the function call to rate_ctr_inc() to osmo_bsc_bssmap.c.
  incremanet on any paging attempt (valid or not) that is recived
  on the A-Interface.

- Remove dead code from paging.c

Change-Id: Iec3eb6724bc655806c3ce3c28448069590d99f91
2018-02-27 07:03:56 +00:00
Philipp Maier 0063752ec5 paging: page all bts when no cell is associated
When the cell identifier list of the BSSMAP paging contains an
"No cell is associated with the transaction." entry then the
paging is dropped and no paging is started at all. This is not
correct. When no cell is associated, the BSS should page the
whole BSS instead.

- Replace respective error case with a paging request to all
  bts.

Change-Id: Id85e3a7540bdc13cd0e780e7870f16c35c6a6a50
2018-02-27 07:03:38 +00:00
Neels Hofmeyr ec00fcfe63 bsc_api.c: fix log string format
Fix string format error introduced by recent commit:

"bsc_api: drop unknown RR messages."
I0a4d311f6939a4fcee59129daa18da4a2ab510ae
e4b0ebb25b

Change-Id: Iab11ec6c44eb235d327b3776d5f1d82267ddadaa
2018-02-27 03:19:23 +01:00
Philipp Maier e4b0ebb25b bsc_api: drop unknown RR messages.
Radio Resource (RR) handling is entirely done inside the BSC. However,
the current implementation forwards unknown RR messages to the MSC.
This is not compliant to the specification.

- Remove the forwarding and drop any unknown RR message.

Change-Id: I0a4d311f6939a4fcee59129daa18da4a2ab510ae
2018-02-26 17:54:39 +01:00
Neels Hofmeyr 00727558a9 HO: fix minor issues found by coverity
handover_decision_2:
- lchan->conn should never be NULL, but if it is, don't crash in LOGPHO*
  macros.
- make certain to avoid modulo-zero. It's cosmetic since that config item is
  not allowed to be zero.

handover_test:
- check return value of gsm_generate_si().
- safer evaluation of main()'s argv.

Fixes: CID#182929, CID#182928, CID#182927, CID#182926
Change-Id: I68e8ed3a1e8659edb47ac3e8a10508f17a3f5670
2018-02-21 14:40:16 +01:00
Neels Hofmeyr 162a3fe5dd drop unused libbsc/meas_proc.c
The file meas_proc.c seems to be an earlier stage of development of the meas
rep handling now in handover_decision.c, and to have been inadvertently added
to the git tree in:

  commit 9af6ddfcec
  Date:   Sat Jan 1 15:25:50 2011 +0100
  License change: We are now AGPLv3+ instead of GPLv2+

The file has never been part of Makefile.am.

Change-Id: If30724e3c638b191d20d00b897731762fb4896d5
2018-02-20 15:26:40 +00:00
Neels Hofmeyr bedbef4ba2 HO: vty: clearly mark 'handover foo' as legacy alias for 'handover1 foo'
The ALIAS_DEPRECATED causes the legacy commands to no longer show up in the
command listing, hence making it more clear which commands are general and
which are for hodec1 only:

== BEFORE: ==

OsmoBSC(config-net)# list
  ...
  handover (0|1|default)
  handover algorithm (1|2|default)
  handover1 window rxlev averaging (<1-10>|default)
  ...
  handover2 window rxlev averaging (<1-10>|default)
  ...
  handover2 retries (<0-9>|default)
  handover window rxlev averaging (<1-10>|default)          <-- legacy
  handover window rxqual averaging (<1-10>|default)
  handover window rxlev neighbor averaging (<1-10>|default)
  handover power budget interval (<1-99>|default)
  handover power budget hysteresis (<0-999>|default)
  handover maximum distance (<0-9999>|default)
  handover2 congestion-check (disabled|<1-999>|now)

OsmoBSC(config-net)# handover ?
  0          Disable in-call handover
  1          Enable in-call handover
  default    Enable/disable handover: Use default (0), remove explicit setting on this node
  algorithm  Choose algorithm for handover decision
  window     Measurement averaging settings                 <-- legacy
  power      Neighbor cell power triggering
  maximum    Maximum Timing-Advance value (i.e. MS distance) before triggering HO

OsmoBSC(config-net)# handover?
  handover  Handover general config                         <-- unchanged

== AFTER: ==

OsmoBSC(config-net)# list
  ...
  handover (0|1|default)
  handover algorithm (1|2|default)
  handover1 window rxlev averaging (<1-10>|default)
  ...
  handover2 window rxlev averaging (<1-10>|default)
  ...
  handover2 retries (<0-9>|default)
  handover2 congestion-check (disabled|<1-999>|now)      <-- no more legacy

OsmoBSC(config-net)# handover ?
  0          Disable in-call handover
  1          Enable in-call handover
  default    Enable/disable handover: Use default (0), remove explicit setting on this node
  algorithm  Choose algorithm for handover decision
                                                         <-- no more legacy

OsmoBSC(config-net)# handover?
  handover  Handover general config                      <-- unchanged

The "Legacy" doc string actually never shows on the VTY console, but it will
show in the reference manual.

(Even with ALIAS(), a 'handover?' would only show the "Handover general config"
doc string, so no loss there from using ALIAS_DEPRECATED().)

Change-Id: I86be674d82242f9ca73a4d0040015c1c79f2422d
2018-02-19 19:01:13 +01:00
Neels Hofmeyr 5f2204a3fb cosmetic: adjust copyrights on handover_cfg.c,_vty.c
They are based on work by jolly, so it can't hurt to mark his copyright.

Change-Id: Id3856cf34d85d6354510a94960fe5ce810c10bc7
2018-02-19 16:31:10 +00:00
Neels Hofmeyr 444f9e2bb0 HO: vty: rename ho decision 1 vty to 'handover1' with 'handover' alias
Handover decision 2 arguments are now configured by 'handover2 foo'. To match
that scheme, rename the previously 'handover foo' args for handover decision 1
to 'handover1 foo'.

For backwards compatibility, still provide aliases of the original VTY
commands. Writing back the config will result in 'handover1' though.

Change-Id: I7305ae7c04cc70082cd80d42b2ba32ffa399f51a
2018-02-19 17:11:47 +01:00
Neels Hofmeyr 909e972787 HO: Implement load based handover, as handover_decision_2.c
Change-Id: Ie597eae82722baf32546331e443dd9d94f1f25e6
2018-02-19 17:11:47 +01:00
Neels Hofmeyr 8489b463f9 HO: cosmetic: getting a chan activ nack on a non-ho lchan is not an error
Change-Id: I66c4f45afda614f874c9cdf0c22552f492315b71
2018-02-19 17:11:47 +01:00
Neels Hofmeyr 45e46d2c88 HO: introduce ho decision callbacks
Instead of reacting on S_LCHAN* signals in the handover decision code,
introduce callbacks for the handover decision to be invoked by handover_logic.c
at the appropriate time.

The rationale is explained in a comment to struct handover_decision_callbacks,
quoting:

"
All events that are interesting for handover decision are actually communicated
by S_LCHAN_* signals, so theoretically, each handover algorithm could evaluate
those.  However, handover_logic.c cleans up handover operation state upon
receiving some of these signals. To allow a handover decision algorithm to take
advantage of e.g. the struct bsc_handover before it is discarded, the handover
decision event handler needs to be invoked before handover_logic.c discards the
state. For example, if the handover decision wants to place a penalty timer
upon a handover failure, it still needs to know which target cell the handover
failed for; handover_logic.c erases that knowledge on handover failure, since
it needs to clean up the lchan's handover state.

The most explicit and safest way to ensure the correct order of event handling
is to invoke the handover decision algorithm's actions from handover_logic.c
itself, before cleaning up. This struct provides the callback functions for
this purpose.

For consistency, also handle signals in this way that aren't actually in danger
of interference from handover_logic.c (which also saves repeated lookup of
handover state for lchans). Thus, handover decision algorithms should not
register any signal handler at all.
"

Also:
- Publish struct bsc_handover to use it as argument to above callbacks.
- Add enum hodec_id to struct bsc_handover, to be able to signal the
  appropriate hodec algorithm per event.
- Add hodec_id argument to bsc_handover_start*() to be placed in the
  bsc_handover struct.
- Publish the LOGPHO logging macros in handover.h along with struct
  bsc_handover, convenient for logging in callback implementations.

Replace handover_decision.c's signal handler with a registered
handover_decision_callbacks instance.

(Upcoming handover_decision_2 will use all of the callbacks introduced here.)

Change-Id: Id5b64504007fe03e0406a4b395cd0359232b77d2
2018-02-19 17:11:47 +01:00
Neels Hofmeyr 047ac0dc00 HO: cosmetic: handover_decision.c: make process_meas_rep() return void
The function's return value is ignored. An upcoming patch will use this as
callback function and requires a void return.

Change-Id: Id455a8becbb43884e8205d87b0371b216d0119fc
2018-02-19 17:11:47 +01:00
Neels Hofmeyr ec42264113 HO: clearly mark conn penalty timer member for hodec2
The conn's penalty timers will be used only for handover decision 2, make it
clear by a sub-struct.

hodec2 will also initialize the penalty timer list on demand only, so no need
to always initialize.

Change-Id: Ie6c2bc2b10dc424dfd94a9e11a9a62f51c48aa10
2018-02-19 17:11:29 +01:00
Neels Hofmeyr 35ba85c37d HO: lchan: store last seen measurement report nr, tweak log
Handover decision 2 will also store the last seen mr nr for neighbor cell
measurements and hence can tell whether a neighbor's measurement is outdated.

Change-Id: Ic1148364597f91b5a55666c80c758b61fa56f582
2018-02-19 15:51:18 +00:00
Neels Hofmeyr dd42eb9f90 HO: cfg: separate hodec1 from hodec2 parameters
Do not share config items between the current handover decision and the
upcoming handover_decision_2.

Rename current handover config items to hodec2_* and duplicate the ones
relevant to handover decision algorithm 1 with name prefix of hodec1_*.

I considered moving hodec2 parameters to an entirely separate .c file and
struct, but that causes considerable code bloat. Rather use the nice
handover_cfg net/bts level mechanism as-is, and simply prefix the names.

In the VTY, the hodec1 parameters are configurable by 'handover foo 23'
commands, while the hodec2 parameters are by 'handover2 foo 23'. The generic
VTY commands to enable/disable handover and to choose the algorithm are still
'handover (0|1)' and 'handover algorithm (1|2)'.

(Note, a subsequent commit will rename the 'handover foo' for hodec1 to
'handover1 foo' and add backwards-compat aliases.)

For example, the 'window rxlev averaging 5' command now exists both for
handover decision 1 and handover decision 2, and its values are independent.
This is valid config:

    network
     # set up handover decision algorithm 1
     # (pending rename of these items to 'handover1 ...')
     handover window rxlev averaging 5
     handover window rxlev neighbor averaging 5

     # set up handover decision algorithm 2
     handover2 window rxlev averaging 7
     handover2 window rxlev neighbor averaging 7
     handover2 penalty-time max-distance 10

     # enable handover
     handover 1

     bts 0
      handover algorithm 1
     bts 1
      handover algorithm 2

In this example, bts 0 uses algo 1 with rxlev averaging of 5, while bts 1 uses
algorithm 2 where rxlev averaging of 7 is in effect.

Change-Id: I6475b2543b18d21710a6d774b214cb484f36ec8e
2018-02-19 15:51:17 +00:00
Harald Welte 04cc5d64c6 chan_compat_with_mode: signalling works over all channel types
chan_compat_with_mode() currently only considered the requirements of
voice/csd services.  It failed to realize that GSM48_CMODE_SIGN
can also be performed over a SDCCH, resulting in unneeded channel
allocation/assignment to TCH type channels, e.g. for SMS.

This makes TC_assignment_sign pass.

Change-Id: I85ffcbd32ccd2617c897edb3b904f56bacd0684f
Closes: OS#2762
2018-02-19 11:43:07 +01:00
Harald Welte c8b0e92230 bssmap_handle_assignm_req(): Don't print log statemens in malloc failure case
Change-Id: I85528689b5298a13c60ae80fabd8d66459f730a9
2018-02-19 11:43:07 +01:00
Harald Welte c1a676e75e bssmap_handle_assignm_req(): Use more conscise error/log message texts
Change-Id: Iffbdfd7591aaeedf24ff0de5f34093be78e2833a
2018-02-19 11:43:07 +01:00
Harald Welte d387ac8ad7 bssmap_handle_assignm_req(): Use proper cause values
The BSSMAP Cause value should give a clear indication of why a given
operation failed.  Previously we were unconditionally sending
GSM0808_CAUSE_NO_RADIO_RESOURCE_AVAILABLE  even in cases where mandatory
IEs were missing or other errors occurred unrelated to resource
availability.

Closes: OS#2759
Change-Id: I86adcae2950cbea6dcac4551cfde1054cb0abad1
2018-02-19 11:43:07 +01:00
Harald Welte 51e4bf3298 Permit set of multiple different A5 ciphers
So far, the administrator had to pick one particular cipher which
would then be used throughout all subscribers/phones. This is a bit
impractical, as e.g. not all phones support A5/3.  Extend the VTY
command syntax in a backwards-compatible way to permit for multiple
ciphers.

The bit-mask of permitted ciphers from the MSC (sent in ASSIGNMENT
COMMAND) is intersected with the vty-configured mask a the BSC.
Finally, the best (highest) possible cipher is chosen.

Change-Id: I1d1c8131855bcab2392b4f27f6216bdb2fae10e0
Closes: OS#2461
2018-02-19 11:43:07 +01:00
Harald Welte 86a8031e9c logging: Remove obsolete log categories
About half of our log categories/subsystems were inherited from
OsmoNITB, and are no longer used but may confuse the user.

Change-Id: I8b39429f71c0faefdf8158a82093cfb19f44809e
2018-02-19 10:47:50 +01:00
Philipp Maier c3ad40ca4e SIGTRAN: correct wrong log category
osmo_bsc_sigtran.c uses DRANAP instead of DMSC in two places,
this is not correct.

- change wrong DRANAP to DMSC

Change-Id: I1594d1906cf7d053d00fff52e9dc0ddfd097ed6e
2018-02-19 10:44:52 +01:00
Harald Welte 3849ad4634 vty: Permit codec-list containing both full-rate and half-rate codecs
Once upon a time, in the old osmo-bsc-sccplite, there was a restriction
of not being able to handle configurations with both TCH/F and TCH/H
type codecs.  This time is long gone, so let's remove this constraint.

Change-Id: Iba0822f57c41cedeeb7f069be540f3a851752a23
Closes: OS#2763
2018-02-19 08:35:55 +00:00
Harald Welte 519c7e1d42 Structural reform: Get rid of osmo_bsc_sccp_con
There was always a 1:1 correspondence between gsm_subscriber_connection
and osmo_bsc_sccp_con, so there's really no point in having two separate
dynamically allocated data structures with pointers back and forth and
another linked list around.

Let's merge osmo_bsc_sccp_con into gsm_subscriber_connection for
simplicity.

The resulting code might not be elegant in places, but I've tried to
do only the most simple changes in this patch, while further
simplifications can be done in later subsequent patches.

As a side-effect, this patch also fixes lchan clearing if the MSC
(or the local SCCP provider) hard-disconnects the SCCP connection.

Change-Id: Idd2b733477ee90d24dec369755a00f1c39c93f39
2018-02-19 08:20:35 +00:00
Neels Hofmeyr c1db52f132 vty: 'show bts': print neighbor cells
Print out the current neighbor cell list, works both for manual and
automatically populated modes.

Examples of output for various configs:

  Neighbor Cells: Automatic, ARFCNs: (none)
  Neighbor Cells: Automatic, ARFCNs: 868 (1)
  Neighbor Cells: Manual, ARFCNs: 123 125 (2)
  Neighbor Cells: Manual/separate SI5, ARFCNs: 123 125 (2) SI5: 321 (1)

Change-Id: I57dae0e01b81a6f028b39f3edcaf430251ca8fe2
2018-02-16 17:23:12 +00:00
Neels Hofmeyr 097a6e77fc vty: 'show bts': list the TRXs' ARFCNs
Change-Id: I56ee2edc7473dc5e9f3c3463194369024cd64995
2018-02-16 17:23:12 +00:00
Neels Hofmeyr dfd36da120 HO: cfg: tweak vty write
Have expicitly named vty write functions for bts and net levels, so that it is
trivial to add commands that exist only on one of each (like the upcoming
congestion check timer config for hodec2).

Change-Id: Ibea4c20abc50c3d655f6bbb1a643477dfc722c8e
2018-02-16 16:11:16 +01:00
Neels Hofmeyr a60f344212 HO: store speech codec list from BSSMAP Assignment in conn
On BSSMAP Assignment Request received from the MSC, store the Speech Codec List
in the subscr conn, so that we may evaluate available codecs during handover
decision. (Will be used, e.g., by handover_decision_2.)

Change-Id: I8222d73085eb777696e365c94214c05d56e6d129
2018-02-16 16:11:16 +01:00
Neels Hofmeyr cbdfb78f7b HO: move penalty timers to own file as proper API
Separate penalty timers API from specific struct members and move to own .h/.c
file, so that future code may re-use the API arbitrarily.

Change-Id: Ife975a1c7c17a500b1693be620475a8bea72f86f
2018-02-16 16:11:16 +01:00
Neels Hofmeyr cbc999cb93 HO: logging: more logs, and more concise logging
Explicitly log "Handover" or "Assignment", add more info to existing log
statements and add more log statements.

Log ho failure both on RR and HO log categories: RR receives the HO failure
message, while the HO failure is an important event to note when watching the
HO category.

Change-Id: Ia3999755cdd4e0c2861582b20e2dbb7e1538e074
2018-02-16 16:11:16 +01:00
Neels Hofmeyr 05a3a2d5a7 HO: bsc_handover_start_lchan_change(): set MS to max power on handover
For re-assignment within the same cell, keep the same MS power. But for
handover to another cell, start off with that cell's configured maximum MS
power.

Change-Id: Ia91766d8bb8f543f514726ce9508b7747bb2bcb5
2018-02-16 16:11:16 +01:00
Neels Hofmeyr 3fb5dcfee3 HO: always do async handover
We're really only interested in async handover so far.
Set ho->async to true always.

Change-Id: I48715864d4b953987c86d93fe1b3a5456f0c4e0f
2018-02-16 16:11:16 +01:00
Neels Hofmeyr 4e3db634da HO: cosmetic: bsc_handover_start_lchan_change(): tweak local vars
To keep this cosmetic change apart from subsequent functional changes:
have a local do_assigment flag and a local network pointer.

Change-Id: I09684dcf2a00e3d930e058cc1c925ad6e59b1468
2018-02-16 16:11:16 +01:00
Neels Hofmeyr 6dff51d583 HO: add new_lchan_type arg to bsc_handover_start()
Upcoming handover_decision_2 will want to be able to handover to a differing
TCH type, hence add a parameter to bsc_handover_start(); adjust current callers
to pass the old lchan type.

Tweak the 'bts' argument to 'new_bts'.

Change-Id: I4478ebcaada00897cc38c5a299e07661139ed3c5
2018-02-16 16:11:16 +01:00
Neels Hofmeyr ef497b86ba HO: cosmetic: bsc_handover_start(): "fix" memcpy for AMR config
memcpy obviously needs the byte size, not the ARRAY_SIZE. For the uint8_t
arrays, these are incidentally the same number, but semantically it should be
sizeof.

Change-Id: I97b6ac05192ad477b246a23ce00c5c91abfd938a
2018-02-16 16:11:16 +01:00
Neels Hofmeyr b57ff5ab85 HO: process_meas_rep: guard against modulo zero
Fixes: CID#182318
Change-Id: I3ad9d01cbffa287adce55b3569667b58a2d3556b
2018-02-16 16:11:16 +01:00
Neels Hofmeyr b037053413 handover_logic.c: on HO command, send new lchan's MS power
Change-Id: I90eda8405f2d2eddfb041ca38b34fe30c397e09d
2018-02-16 16:11:16 +01:00
Neels Hofmeyr 063868e1e6 handover_logic.c: always do inter-cell channel activation
In commit [1], the channel activation kind was modified out-of-context to use
Immediate Assignment in case of intra-cell re-assignment. This so far hasn't
worked out in tests, so instead stay with the strategy to use
RSL_ACT_INTER_ASYNC also for re-assignment within the same cell. We may move to
RSL_ACT_INTRA_IMM_ASS in a separate patch after proper testing.

[1]: 5eaa4fb821,
     I2d91765c1f9719c64fd99426a872cecc724215db
     "HO: add indicators for inter-cell and async ho, use for chan act type",

Note that so far, no re-assignment within cells is triggered by the current
handover decision algorithm, so the effect will be really noticeable with
handover decision 2 that is coming up.

See feature OS#2949 which asks for implementing actual RR Assignment to
handover within a cell.

Related: OS#2949
Change-Id: Ia3d979094fa16620f1acc5933418797829710ba8
2018-02-16 16:11:16 +01:00
Neels Hofmeyr f802f7fd7a bts chan_load: ignore unusable BTS
For unconnected BTS, the channel load would report a "bogus channel load
sample" every second (on RLL debug). Instead, skip unusable BTS.

This follows up on commit 6cee893a0f /
I57e38f6d6ba3b23cc6e1f9520b90261dbb1f1cec
'Make "waiting indicator" of IMMEDIATE ASSIGN REJECT dynamic.'

Change-Id: I627fe10e1f5c1f2f23745c906320871024b5c8c3
2018-02-15 18:47:32 +01:00
Neels Hofmeyr 97d110e3cf vty: 'show bts': fix indenting
Add two-space indent to many items.

Change-Id: I34e3c8928871fc41b9551ab0502a42140ccbdda8
2018-02-15 15:21:31 +01:00
Neels Hofmeyr 9abc652b5e vty: 'show bts': write '(none)' if none are found.
Change-Id: I77039824b85a14b9d7bdfe6d2f717679b6886915
2018-02-15 15:21:31 +01:00
Neels Hofmeyr d23ce86c25 drop libcommon-cs completely
Change-Id: I07d4a48af3154ee4d904686f230a51b8b8a94ff9
2018-02-14 12:55:45 +01:00
Neels Hofmeyr 6dd5a9b017 libcommon-cs: move vty bits to libbsc/bsc_vty.c
The gsm_network VTY was partly shared between libmsc and libbsc in the old
openbsc.git; now osmo-bsc.git has its own copy, so merge all of it into
bsc_vty.c.

This leaves common_cs_vty.c practically empty; leave removal of the file to
later, when we drop the entire libcommon-cs in
I07d4a48af3154ee4d904686f230a51b8b8a94ff9.

Note that gsmnet_from_vty() is also already declared in bsc/vty.h.

Change-Id: I6f3a596f31762b48afed39a85a343c400826300f
2018-02-14 12:55:45 +01:00
Neels Hofmeyr b5400776d8 libcommon_cs: move gsm48 bits to libbsc
These functions were originally shared between libmsc and libbsc in the old
openbsc.git; now osmo-bsc.git has its own copies, so move them into libbsc.

Change-Id: Ie411c2ce8008accee54782a442d6361e50777a54
2018-02-14 12:55:45 +01:00
Neels Hofmeyr d85e4cb711 gsm_network: drop unused trans_list
Change-Id: I7910ce8098d5431e41409bf09429ae4221efb360
2018-02-14 12:55:45 +01:00
Neels Hofmeyr ab1b381d1b libcommon-cs: move gsm_network_init() into bsc_network_init()
Some part of the network init was common between libbsc and libmsc in the old
openbsc.git repository. Now osmo-bsc.git is independent with its own copy of
the gsm_network initialization. So move it over to libbsc.

Change-Id: I8968787a5f0b078619264f0cb42349a9bc7943af
2018-02-14 12:55:45 +01:00
Neels Hofmeyr f088e790f7 libcommon-cs: move a_reset.c into libbsc
a_reset.c was originally used by both libmsc and libbsc in the old openbsc.git
repository. Now osmo-msc.git has its own copy, and the idea of sharing
libcommon-cs is no longer applicable. Move it to libbsc where it belongs.

Change-Id: I30e4b5dab9c6d761d20a3a0e5b9ec2d65e64ebc5
2018-02-14 12:55:45 +01:00
Neels Hofmeyr 421059a2c0 drop libcommon completely, move remaining files to libbsc
Move gsm_data.c and handover_cfg.c to libbsc, where they belong.

This leaves libcommon utterly empty, drop it.

Change-Id: I6178061fa30c7e1a4c22c29d3c8f508b1033569f
2018-02-14 12:54:38 +01:00
Neels Hofmeyr 104851632d libcommon: join gsm_data_shared.* into gsm_data.*
The separation of gsm_data_shared.* from gsm_data.* historically allowed
compiling parts of it into osmo-bts, which we have dropped since (osmo-bts has
its own copy now). Even though gsm_data.* now becomes rather large by it,
remove the legacy separation to get rid of the "shared" naming, which is no
longer meaningful. A future patch might separate into meaningful smaller bits,
if we get the time.

Change-Id: Ie247bc492efb331871d970c56700595ad3f7e201
2018-02-14 12:15:40 +01:00
Neels Hofmeyr 87592b8967 ipaccess-proxy: don't redefine tall_bsc_ctx
Curiously, ipaccess-proxy.c is able to define its own tall_bsc_ctx even though
the same should already be linked from gsm_data.c. Declare it extern instead
and hence use the one from gsm_data.c.

A linking error actually occured as soon as I joined gsm_data_shared.c into
gsm_data.c, which is how my attention was drawn to this. I assume that linking
didn't necessarily pull in gsm_data.c before and a separate tall_bsc_ctx was
permitted. As soon as the next commit merges those files
(Ie247bc492efb331871d970c56700595ad3f7e201), it becomes impossible to define a
second tall_bsc_ctx in ipaccess-proxy.c.

Change-Id: I9c9c8540419876696e65a690717144d497d60fb2
2018-02-14 12:15:40 +01:00
Neels Hofmeyr cc6240aeb2 libcommon: eliminate talloc_ctx.c
Interestingly enough, talloc_ctx_init() actually had not a single caller.

While dropping it, see to it that the few contexts that are actually used in
osmo-bsc.git are indeed initialized in all the main scopes.

Also initialize two void* ctxts as NULL explicitly, to allocate under the NULL
context in case some main scope forgets to branch it off another root context.
(That's bsc, fle and paging, all others actually come in from other libraries.)

Change-Id: I344a3d07e146999e154824837ed95db2b9879356
2018-02-14 12:15:40 +01:00
Neels Hofmeyr 978f58cd2e libcommon: eliminate socket.c
Replace calls to make_sock() with osmo_sock_init_ofd().
Shame on me for not testing every single one in practice, I hope for peer
review to confirm that this should be correct... Read closely please!

The IPPROTO_GRE define seems to be unused (at least in osmo-bsc.git), drop it
completely.

Change-Id: Ia6e4e0e1eed3328fa25b3b90be376d532ad0e56b
2018-02-14 12:15:40 +01:00
Neels Hofmeyr 7997bf4bed libcommon: eliminate debug.c
Provide concise log categories for each main scope.

Move the complete log categories 1:1 to osmo_bsc_main.c.

In bsc_nat.c, omit obviously unused log categories.

In tests, omit almost all log categories, except for those explicitly tested as
the expected output.

Note: should any logging occur for a log category that is omitted by accident,
such will end up being logged as DLGLOBAL, so it will show up and we can fix
it, and it will not get lost silently.

Change-Id: Ib524e49ec211662e0dfde8161495a72aa8ad76cf
2018-02-14 12:15:40 +01:00
Neels Hofmeyr ec1bb16eef libcommon: eliminate common_vty.c
Move bsc_vty_go_parent() to osmo_bsc_main.c and bsc_nat.c, and drop those nodes
that aren't used in the respective main scope.

Change-Id: I22ebb76742e9c5ab9dd608ac089a5c558aceeb36
2018-02-14 12:15:13 +01:00
Neels Hofmeyr e161bca800 libcommon: eliminate bsc_version.c
Move the copyright string into osmo_bsc_main.c. No other users of it exist.

Change-Id: I7f48924f484e4e4b98be4ca8bee253e6ea9c0576
2018-02-14 11:27:53 +01:00
Harald Welte 2f4f4b8604 osmo-bsc: Add talloc context introspection via VTY
This requires libosmocore with Change-Id
I43fc42880b22294d83c565ae600ac65e4f38b30d or later.

Change-Id: I1245b6818eb54f5c0c8adddcd3a01ecc7363fb42
2018-02-14 00:56:07 +00:00
Stefan Sperling 73acbca50f Make RSL connection attempts time out.
If a BTS/TRX does not respond to the "IPA RSL Connect" command,
pretend that the BTS has sent a NACK for the connection.

To ensure that osmo_timer_del(&trx->rsl_connection_timeout) is not called
before this timer is initialized with osmo_timer_setup(), the E1 layer now
drops incoming RSL messages from a BTS/TRX in LOCKED administrative state.

We cancel the timeout if we receive an RSL Connect ACK or NACK from the BTS,
and if the underlying E1 link does down.

While here, add a missing message buffer free() in bts_isdn_sign_link().
The callers do not free it.

Change-Id: Ia72b65a0f15f47dcb8a6f944f6c3695a4a64b923
Related: OS#2716
2018-02-13 18:08:28 +01:00
Philipp Maier aa4adb8fbf abis_rsl: do not allow SACCH in MF mode on SAPI=0
osmo-msc does currently not check if an MS attemts to establish an
SACCH link on SAPI=0. This combination is not permitted and should
be dropped.

- Make sure that establish indication for SAPI=0 and channel-type=SACCH
  is not permitted

See also TTCN3 Testcase:
BSC_Tests.TC_rll_est_ind_inval_sacch

Change-Id: I12962072c0ea689d2b9b5c2899ffb59be9310dcb
Closes: OS#2750
2018-02-06 19:39:57 +01:00
Philipp Maier cc48efe400 abis_rsl: permit first EstablishInd only on SAPI=0
When the first EstablishInd (DCCH) is made by the MS, then it must by
definition happen on SAPI=0. The MS may establish multiple connection
on other SAPIs afterwards. At the moment osmo-bsc does not check the
SAPI when an EstablishInd message is received.

- For SAPIs other than 0, check if SAPI=0 has already been
  established

See also TTCN3 testcases:
BSC_Tests.TC_rll_est_ind_inval_sapi1
BSC_Tests.TC_rll_est_ind_inval_sapi3

Change-Id: Ibf4fca0bd42dfe5bc63e8b08754ebbe0a5e252c3
Closes: OS#2750
2018-02-06 19:39:57 +01:00
Stefan Sperling 81dc9e7455 Add stat items for the BTS's channel load average and T3122.
In addition to logging the current values of a BTS's channel load
average and T3122 override, maintain stat items for these values.
This allows for plotting these values over time, for instance.

These values show up in the VTY under 'show stats' like this:

base transceiver station:
 Channel load average.:       25 %
 T3122 IMMEDIATE ASSIGNMENT REJECT wait indicator.: 32 s

Change-Id: Icace0176e8b1d23d7c7b4816f7c67c65312844fa
Suggested-by: laforge
2018-02-05 22:36:54 +00:00
Harald Welte 5f45a4a825 vty: print RTP IP of lchan if actually bound; print remote (mgw) IP
Change-Id: I87840aa0f5b9c04d7736bf5f649142219853711a
2018-02-05 21:33:34 +01:00
Stefan Sperling 6cee893a0f Make "waiting indicator" of IMMEDIATE ASSIGN REJECT dynamic.
The IMMEDIATE ASSIGN REJECT message contains a wait indicator which
tells an MS requesting a channel to wait for a specified amount of
time before trying to request a channel again, i.e. the wait indicator
controls the T3122 timeout value in the MS.

Previously, the wait indicator was fixed to 10 seconds.
This is not sufficient if there are a lot of MS requesting channels
because the MS will retry too soon. Instead of using a fixed value,
maintain a dynamic wait indicator value based on average channel load.

The load (used vs. available channels on a BTS) is sampled once per
second, and once 8 samples have been collected we update a BTS-specific
T3122 wait indicator based on the measured load.

While the wait indicator could go up to 255 seconds, this initial
implementation keeps it in the range from 10 to 128 seconds.

Further experimentation and testing will show whether higher wait
indicator values are desirable, if the sampling rate needs to change,
or if the function mapping the load measurement to a wait indicator
value should change (currently we map the load average linearly into
the range [10, 128] inclusive).

Change-Id: I57e38f6d6ba3b23cc6e1f9520b90261dbb1f1cec
Related: OS#2592
2018-02-05 13:58:17 +01:00
Harald Welte b794887cab remove obsolete gsm_subscriber_connection.bts member
This member was merely a cache for conn->lchan->ts->trx->bts,
so let's avoid having to keep copies of the same data (which needs
to be kept up to date).

Change-Id: Id3bff8b18425ef5d45eb460ac9eb620023013ba0
2018-01-28 03:23:00 +01:00
Harald Welte 720de68cb0 bssmap_handle_assignm_req(): Decode channel type as first step
The decision on how to further process the request depends significantly
on the contents of the only mandatory IE of the ASSIGNMENT REQ.  Let's
decode it first.

Change-Id: I030b5ad6f4fc33da9155c8a6061fd982312b20fb
2018-01-28 03:07:21 +01:00
Harald Welte c751513c04 cosmetic: Remove data/len variables in bssmap_handle_assignm_req()
There's nothing wrong with passing the TLVP_VAL/TLVP_LEN directly into
the gsm0808 decoder functions, let's avoid variables that get assigned
and used only once - particularly with such generic names.

Change-Id: I8557b4a9ff4de28b76c7d618631a4700176a8669
2018-01-28 03:07:16 +01:00
Stefan Sperling 56dd9815eb Improve an error message in page_lai_and_lac()
This error message is now contained in a loop, and the current iteration
does not know whether paging will fail entirely or if later iterations
will succeed. Update the error message accordingly.
This also makes the error message consistent with the one in page_cgi().

Change-Id: I8ec229702343343dedcbb242b6d0ed170c858511
2018-01-26 02:29:32 +00:00
Stefan Sperling 774020a843 Remove an unused variable.
Local variable is_lu in rsl_rx_chan_rqd() has been unused
since commit 6082a377f5.

Change-Id: I67594afcfa4104e91352d50f40ae9f2bc20f4cd1
2018-01-25 16:09:33 +01:00
Max 537b655b99 cosmetic: log prim operation as text
When logging SCCP error, log failed primitive operation as text.

Change-Id: I91f739cea9f518a24fff6870f7dceab8175c9646
Related: OS#2851
2018-01-24 14:10:51 +01:00
Andreas Eversberg 084b421fba HO: Add a penalty timer list to the subscriber connection entity
This penalty timer is used to temporarily block cells where handover
or assignment failed or where handover is not allowed. This is usefull
to prevent repeated handover attempts to broken cells or cells that have
limited allowed distance.

Change-Id: I95cb7e3211b2470b773965e7aa94d8eb6c8c1a3a
2018-01-22 01:57:50 +00:00
Andreas Eversberg 83594847a8 Fix: meas_rep.c will only use valid DL measurement reports
When averaging measurements, only the valid reports are used. If there is
no valid report in the averaging window at all, an error is returned.

Change-Id: I33056225ead788340755e98113d72e1cbf3ebce6
2018-01-21 19:06:58 +00:00
Andreas Eversberg 935e5d76dd HO: add queue to cache DTAP messages during handover/assignment
Add ho_dtap_cache to gsm_subscriber_connection, a stock msgb queue to be used
with msgb_enqueue() and msgb_dequeue().

Keep a counter of queue length, to enforce a sane maximum counter for cached
messages. So far a hardcoded maximum of 23 messages will be cached.

Have balanced ho_dtap_cache_add() and ho_dtap_cache_flush() functions.

The original patch was by jolly, but I have basically completely replaced it
with the simpler msgb queue pattern.

Change-Id: I6e4d93628befb3d97e5cee0343cd9f8ba0b8620c
2018-01-19 22:09:19 +00:00
Neels Hofmeyr 2660c0412d HO: make bts_by_arfcn_bsic() public
Change-Id: Ie746f76433f6b46a71a91b7714cc034c4355d993
2018-01-19 22:09:19 +00:00
Neels Hofmeyr 1c251f0c9f HO: rename gsm_bts_neighbor() to bts_by_arfcn_bsic()
The name sounds like it is looking up neighbors, instead it simply traverses
the global list of BTSes. Rename to reflect what it does.

Move FIXME comment to its logical place: at the invocation of
bts_by_arfcn_bsic().

Change-Id: I063870d09f782a4f18e85d87c7cd17fe660cb3fd
2018-01-19 22:09:19 +00:00
Andreas Eversberg df65c9afee HO: Count number of free timeslot on a given BTS
This is needed for handover algorithm to balance free slots and to prevent
congestion of one cell, while other cells still have free capacities.

Change-Id: Ic8bee8a515ee8aa9a99af71756fe60b8dd8f868b
2018-01-19 18:19:00 +01:00
Andreas Eversberg 81260a6795 HO: Change debug category at handover decision: DHO -> DHODEC
Change-Id: I7322b790f647b681bfe3a9c95b04516fbc7cbf88
2018-01-19 16:03:16 +01:00
Neels Hofmeyr 87b5eb667b HO: add handover algo 2 parameters; skip HO 1 if HO 2 is configured
Change-Id: I8811ee8a75be09048042b511ee4bd9bc1de63976
2018-01-19 16:03:16 +01:00
Neels Hofmeyr c561515ae0 HO: enable handover by initializing at startup; rename init function
Change-Id: I224884c84895ebf6c8cf498c16616214cb2b5779
2018-01-19 16:03:16 +01:00
Andreas Eversberg 30b6df607e Correctly set T3105 for ipaccess BTS type
The given value is 10 * ms, so 13 is used instead of 128.

If T3105 is set at config to something greater 0, it is used instead of
the default value.

Adjusst nanobts_omlattr_test.c accordingly.

Change-Id: I3d9687619ba4de35f5d2eff3026d903534b2bbd4
2018-01-19 16:03:16 +01:00
Andreas Eversberg 5d45c0732a Allow assignment to TCH channel with signalling only mode
This makes sense, if silent call is used. Assignment allows to change from
SDCCH (or whatever was available) to given TCH rate.

Change-Id: I2efe9d7ab429e902581ebb9e0e006f2aec6d8972
2018-01-19 16:03:16 +01:00
Andreas Eversberg 3106c16b4f Do not perform assignment, if the new channel equals the current one
This can happen, if a TCH/H was requested, but because it is not available,
a TCH/F is allocated. If the old channel was TCH/F already, it makes no
sense to assign it.

Change-Id: I284125483fc14b8f82e32ee61aa3866746238eae
2018-01-19 16:03:16 +01:00
Andreas Eversberg 7df80d38f3 HO: Add handover decision debugging category
Change-Id: Iaf99d4e9ae08c38bf364dbb37d42098f976f6b8c
2018-01-19 16:03:16 +01:00
Andreas Eversberg e0cba56dad HO: If handover logic is used to do assignment, signal assignment result
Change-Id: I465caef03626e67d9b3a21bdf730589b9852c211
2018-01-19 16:03:16 +01:00
Andreas Eversberg 869121c09a HO: Always update rqd_ta after receiving measurement report
The up-to-date rqd_ta is required for assignment command. If the phone
moves, the timing advance might change. The rqd_ta will be updated by
each measurement report.

Change-Id: If1a592e590cfed55ff3dca5be89e2946e8017a22
2018-01-19 16:03:16 +01:00
Andreas Eversberg 7c41cd1ac5 HO: Changed availablilty of ts_is_usable() from static to extern
Change-Id: I3471e38327c4b98490faed9b604fb76438ba9954
2018-01-19 16:03:16 +01:00
Neels Hofmeyr f9b8cb19e2 fixup: neigh_meas_avg: fix condition to reduce window size
Change-Id: Ia2269be448436d676289c84b9b05da7f51ee4a85
2018-01-19 16:03:16 +01:00
Neels Hofmeyr 186e478164 fixup: neigh_meas_avg: detect invalid window size as <=0, log if invalid
Change-Id: I8c5d0642aeb4fbee73a035b9f73cf3a09b1bcf90
2018-01-19 16:03:16 +01:00
Andreas Eversberg 11e31c7066 HO: Count neighbor measurements and reduce window of neigh_meas_avg
Always start with a counter of 0 for a new measurement report. If the
neigh_meas_avg is caluclated over the given window, the window is
reduced, if there are less measurement reports received so far.

Change-Id: I1c74f27f9663a3083610c985a080fca331c19bd3
2018-01-19 16:03:16 +01:00
Andreas Eversberg 970b43486f HO: Count the actual meas.rep. get_meas_rep_avg fails if not reached
get_meas_rep_avg will return -EINVAL, if the required number of
measurements are not reached. There will be no handover possible until the
given number of measurements are available.

Change-Id: Ibc4410b4e162cdb6c070128d2c63946bb79d6d65
2018-01-19 16:03:16 +01:00
Andreas Eversberg 4d3baa6bdf Fix of checking TCH rate at chan_compat_with_mode
In case of current channel equals TCH/F and we request half rate, we
must return 0, so the calling function will trigger assignment.

Change-Id: Ibb4cb9aef1a1146f984d7c969bfba53c647cae07
2018-01-19 16:03:16 +01:00
Andreas Eversberg 6082a377f5 HO: Assign SDCCH on channel request
This is needed, so channel can be negotiated before the actual channel
type is assigned.

In case there is no SDCCH available, try to assign what ever the MS requested.
If this is not possible try to assign TCH/F. If this is still not possible,
reject channel request.

Change-Id: I10fc9f60c58c6b7ed424a86ce23bf6b9802c9eb1
2018-01-19 16:03:16 +01:00
Andreas Eversberg c8a7823b4b Fix: If paging for half rate was requested, use hr, if supported by MS
Change-Id: I6d1c9701808ee542771fee145250927019a2f5f6
2018-01-19 16:03:16 +01:00
Neels Hofmeyr c766c9edad cosmetic: explicitly init ho_ref start value
The static ho_ref seems to be implicitly initialized to zero, but let's make it
explicit for code readability.

Change-Id: I00493bcb7ef3e38fb8e0077c60c5bac7199f1073
2018-01-19 16:03:16 +01:00
Andreas Eversberg a91800034e HO: Add function to count currently ongoing handovers to a given BTS
In order to keep processing power at BTS at a defined level, the handover
decision might want to limit maximum number of slots that require RACH
detection.

Change-Id: I8908e37fe0d8d2eda906cc6301ba0969b25a5575
2018-01-19 16:03:16 +01:00
Neels Hofmeyr 5eaa4fb821 HO: add indicators for inter-cell and async ho, use for chan act type
Change-Id: I2d91765c1f9719c64fd99426a872cecc724215db
2018-01-19 16:03:16 +01:00
Andreas Eversberg a49d7b2684 HO: Send Channel Mode and Multirate IE along with handover command
This is needed, if the channel mode should change when doing handover.
A change in channel mode makes sense, if available resources at the new
BTS are different.

Change-Id: Ib6b17a9be252f1655006ab6773483868017d7926
2018-01-19 16:03:16 +01:00
Neels Hofmeyr e25018b8c1 HO prep: introduce per-BTS handover config, with defaults on net node
It is desirable to allow configuring handover for each individual network cell.
At the same time, it is desirable to set global defaults.

Treat the 'network' node handover parameters as global defaults, add another
set of parameters for each individual BTS.

This raises questions on how the 'network' node should affect the individual
BTS. The simplistic solution would have been: on creating a BTS in the config,
just copy the current defaults; with serious drawbacks:
- tweaking any parameter in the telnet VTY on network node will never affect
  any running BTS.
- network node defaults *must* be issued before the bts sections in the config
  file.
- when writing a config back to file, we would copy all net node defaults to
  each BTS node, making the network node configs pointless.

Instead, add a handover_cfg API that tracks whether a given node has a value
set or not. A bts node ho_cfg gets a pointer to the network node config and
returns those values if locally unset. If no value is set on any node, use the
"factory" defaults, which are hardcoded in the API. Only write back exactly
those config items that were actually issued in a config file / on the telnet
VTY. (ho_cfg API wise, we could trivially add another ho_cfg level per TRX if
we so desire in the future.)

Implement ho parameters as an opaque config struct with getters and setters to
ensure the tracking is always heeded. Opaqueness dictates allocating instead of
direct embedding in gsm_network and gsm_bts structs, ctx is gsm_net / bts.

This is 100% backwards compatible to
old configs.
- No VTY command syntax changes (only the online help).
- If a 'bts' sets nothing, it will use the 'network' defaults.
- The 'show network' output only changes in presence of individual BTS configs.

On 'show network', say "Handover: On|Off" as before, iff all BTS reflect
identical behavior. Otherwise, output BTS counts of handover being enabled or
not.

Use the same set of VTY commands (same VTY cmd syntax as before) on network and
BTS nodes, i.e. don't duplicate VTY code. From the current vty->node, figure
out which ho_cfg to modify.

For linking, add handover_cfg.c (the value API) in libcommon, while the
handover_vty.c is in libbsc. This is mainly because some utility programs use
gsm_network and hence suck in the ho stuff, but don't need the VTY commands.

Review the VTY online help strings.

Add VTY transcript test for handover options, testing config propagation from
network to bts nodes, 'show network' output and VTY online help strings.
(Needs recent addition of '... !' wildcard to osmo_interact_common.py.)

I considered leaving parts of this more readable, but in the end decided for
heavy use of macros to define and declare the API, because more values will be
added in upcoming patches and I want to prevent myself from messing them up.

Inspired-by: jolly/new_handover branch, which moves the config to 'bts' level
Depends: I7c1ebb2e7f059047903a53de26a0ec1ce7fa9b98 (osmo-python-tests)
Change-Id: I79d35f6d3c0fbee67904378ad7f216df34fde79a
2018-01-19 16:03:16 +01:00
Neels Hofmeyr be1131df42 HO: fix recovery from failed handover
Do not instruct the MGW to move the RTP to the new lchan before we have
received a HANDOVER DETECT.

Before:

  Chan Activ
  Chan Activ Ack
  IPACC-CRCX
   -ACK
  IPACC-MDCX
   -ACK
  MGCP MDCX --> MGW
  ...
  HANDOVER DETECT
  Call continues on new lchan

In above sequence, if the HANDOVER DETECT times out, the MGW has moved to the
new lchan which never becomes used and is released. Furthermore, from the IPACC
MDCX until the HANDOVER DETECT, the RTP stream would break off momentarily.

After:

  Chan Activ
  Chan Activ Ack
  IPACC-CRCX
   -ACK
  IPACC-MDCX
   -ACK
  ...
  HANDOVER DETECT
  MGCP MDCX --> MGW
  Call continues on new lchan

If the HANDOVER DETECT times out, the call happily continues on the old lchan.

This change is inspired by Ivan Kluchnikov's HO work, who implemented a similar
fix in the openbsc.git codebase (branch fairwaves/master-rebase): his patch
moves ipacc_mdcx() to connect RTP to the new lchan from switch_for_handover()
(which triggered on S_ABISIP_CRCX_ACK, i.e. creation of the new lchan) to later
on in ho_detect() a.k.a. the S_LCHAN_HANDOVER_DETECT signal handler:
http://git.osmocom.org/openbsc/commit/?h=fairwaves/master-rebase&id=9507a7a1ea627e07370c9d264816bb190b3b91b8

This patch does essentially the same: remove the mgcp_handover() call from the
MDCX-ACK handling (creation of the new lchan), and add a signal handler for
S_LCHAN_HANDOVER_DETECT to osmo_bsc_mgcp.c to effect the MGW switchover.

Note, it would have been possible to call mgcp_handover() directly from rx of
the HANDOVER DETECT message, but that produces linking fallout in some utils/
projects, which then need to link the mgcp code as well. That is because those
aren't properly separated from the more complex parts of libbsc. Using the
signal is a bit bloaty, but saves the linking hell for now. I've faced a
similar problem twice recently, it would pay off to separate out the simpler
utils/ and ipaccess/ tools so that they don't need to link all of libbsc and
osmo-bsc, at some point (TM).

Change-Id: Iec58c5fcc5697f1775da7ec0111135108ed1fc8f
2018-01-19 16:03:15 +01:00
Neels Hofmeyr 9af36d7844 osmo_bsc_mgcp: cosmetic: introduce mgcp_init(), soak up fsm init
A subsequent patch will add registration of a signal; cosmetically prepare by
creating a common mgcp_init() function. It makes sense for the FSM registration
to move to it.

Change-Id: I510e1081171706eb3d9fb2db50a9aa4f768929b5
2018-01-19 16:03:15 +01:00
Neels Hofmeyr b99e0251a1 vty: add various manual handover and assignment trigger commands
Change-Id: I9745609f2620baa09a693b713d76e355e798abc7
2018-01-19 16:03:01 +01:00
Neels Hofmeyr 70c5fd2bfa vty: cosmetic: use common BTS, TRX, TS, LCHAN strings
Change-Id: Ic015ebd3a330769638dddeab2f52321b0302a5a1
2018-01-19 15:55:14 +01:00
Neels Hofmeyr 0f483f6f9a vty: change handover command's arg LCHAN_NR to <0-7>
Even thought the lchan number range depends on the pchan, using LCHAN_NR allows
passing arbitrary arguments. Limit it to 0-7.

Change-Id: I2c078b420b6183862acb5c18d1230cf8f6c9f0ce
2018-01-19 15:46:02 +01:00
Neels Hofmeyr e5b5a894c2 vty: fix 'show lchan ...' arg [lchan_nr] to [<0-7>]
A lower-case argument is a keyword, not a variable placeholder. Hence the user
would not be able to pass a number, just the "lchan_nr" string itself, hence
this would never work.

Depending on pchan, lchans can range 0..7, so use that instead.

Change-Id: Ib9a0b43b68c4682cd6de24d01c0de421c9ce957a
2018-01-19 15:41:25 +01:00
Stefan Sperling e74038424a Split paging cases in bssmap_handle_paging() off into helper functions.
This is mostly no-op code refactoring which makes it easier to maintain the
code for each paging case and reduces the scope of several local variables.

Also, ensure that paging failures where no matching BTS was found are logged
consistently in all cases. The log level changes from ERROR to NOTICE since
this is not necessarily a fatal condition.

Change-Id: If8fdf425145791f4904a70e295bdc3c7d0f4d5f6
2018-01-17 10:01:53 +00:00
Ivan Kluchnikov 1c8b4a5a77 handover_decision: log HO causes more accurately
Tweaked-by: nhofmeyr@sysmocom.de
Change-Id: Ib0a0787ac8b877ac63455d72886389b546e7a337
2018-01-16 15:29:59 +01:00
Ivan Kluchnikov 864f553d90 handover_decision: Fix condition for power budget handover attempt
Handover attempt for power budget case should be performed every N SACCH frames,
where N = Power Budget Interval.
First measurement report with mr->nr = 0 was used for the first handover attempt
in this case, which is not correct, because first usable report should have
mr->nr = net->handover.pwr_interval-1.
Moreover using the first measurement report with mr->nr = 0 for handover attempt
could lead to unnecessary handover, because usually av_rxlev for first measurement report
from MS is worse than for following reports.

Change-Id: If7f54a4cb179eaa9e5eb147b9477633ac618e69e
2018-01-16 15:28:57 +01:00
Stefan Sperling d2474cad81 Show the BTS number for outgoing paging commands in debug log.
Change-Id: I7b6e03087fc2dfecb6235c5ed1494d3c9b4bbf0e
2018-01-16 13:40:31 +00:00
Stefan Sperling 95543427f9 Implement support for paging based on LAC and CI.
This is a simple combination of the LAC and CI cases which have
already been implemented.

The BSC_Tests.TC_paging_imsi_nochan_lac_ci ttcn3 test passes.

The switch statement in bssmap_handle_paging() is getting a bit large,
and scoping of local variables could be improved. I will focus on
cleaning this up later once paging functionality is complete.

Change-Id: If7f596663a97a1db1a00f115a366f4a5a271c127
Depends: Id83f8b3b1ce80a39417176d99fd09f3b394fd19c
Related: OS#2752
2018-01-16 14:18:21 +01:00
Stefan Sperling c7b017658d Implement support for paging based on a Cell Global Identifier.
This is essentially a case which combines paging by LAI and CI.

Depends: Ic1c72c7f83e53988eb9fedf314b1dc459836833d
Change-Id: Id83f8b3b1ce80a39417176d99fd09f3b394fd19c
Related: OS#2751
2018-01-16 14:17:23 +01:00
Stefan Sperling 714c2f9552 Move BTS selection for paging from osmo_bsc_grace.c into osmo_bsc_bssap.c.
We can now either page an invidual BTS directly or page several BTS in a
given location area. This decision is taken based on the contents of the
cell identifier list in the paging request. Select a set of BTS for paging
while processing the cell identifier list, rather than requiring the
paging layer to loop over all BTS in the MSC.

This change requires some adjustment in bssap_test. In particular,
this test must now add a BTS to its network in order to pass.

The purpose of this change is to make the layering a bit cleaner.
There is one functional change: We no longer abort paging if paging fails
for a particular BTS. Instead, we keep trying to page on other BTS.

Change-Id: Ic1c72c7f83e53988eb9fedf314b1dc459836833d
Suggested-by: Harald Welte
Depends: Ic7772e75c3d7fb0df6e17e118bb33b3248352d4d
Related: OS#2753
2018-01-16 14:14:01 +01:00
Harald Welte 74b8cdb8e9 Make libcommon, libcommon-cs, libfilter, utils depend on mgcp/sigtran
The stow-enabled jenkins builds are currently failing like below:

make[3]: Entering directory '/build/src/libcommon'
  CC       bsc_version.o
  CC       common_vty.o
  CC       debug.o
  CC       gsm_data.o
In file included from debug.c:34:0:
../../include/osmocom/bsc/gsm_data.h:15:38: fatal error: osmocom/sigtran/sccp_sap.h: No such file or directory
 #include <osmocom/sigtran/sccp_sap.h>
                                      ^
compilation terminated.
In file included from common_vty.c:27:0:
../../include/osmocom/bsc/gsm_data.h:15:38: fatal error: osmocom/sigtran/sccp_sap.h: No such file or directory
 #include <osmocom/sigtran/sccp_sap.h>
                                      ^
compilation terminated.
In file included from gsm_data.c:37:0:
../../include/osmocom/bsc/gsm_data.h:15:38: fatal error: osmocom/sigtran/sccp_sap.h: No such file or directory
 #include <osmocom/sigtran/sccp_sap.h>
                                      ^
compilation terminated.

Let's make sure the common gsm_data.h have all required CFLAGS to compile.

Change-Id: I30b75db6ffba227b05b5413b84b15f69e0c213f2
2018-01-15 20:14:01 +01:00
Stefan Sperling 090550f5f8 Implement support for paging based on CI (cell identifier).
This builds upon https://gerrit.osmocom.org/#/c/5698/ which implements
support for paging by LAI.

The ttcn3 test TC_paging_imsi_nochan_ci passes with this code when
run in isolation. It does not pass if another paging test (such as
TC_paging_imsi_nochan_lai) is executed beforehand. This problem
looks similar to the scenario tested in TC_paging_imsi_a_reset.

Change-Id: Ic7772e75c3d7fb0df6e17e118bb33b3248352d4d
Depends: Ic3c62ff0fccea586794ea4b3c275a0685cc9326e
Related: OS#2753
2018-01-15 10:46:43 +00:00
Stefan Sperling 7985f980ed Implement support for CELL_IDENT_NO_CELL.
Change-Id: I941477fee041664bd3d256b272e3cafa9bce4e69
2018-01-11 16:08:23 +00:00
Stefan Sperling 33e9009003 Implement support for paging by LAI.
Also, parse the complete cell identifier list for both LAC and LAI.

Change-Id: Ic3c62ff0fccea586794ea4b3c275a0685cc9326e
Related: OS#2751
2018-01-11 12:50:07 +00:00
Philipp Maier f56a28d1c2 cosmetic: mgcp: remove duplicate logging
do not print an additional log lines when the mgcp FSM gets
halted. This is already done by osmo-fsm

Change-Id: I5aebbcacb68eab3c6afb19991dbf63a02524e4d7
2018-01-10 11:12:12 +00:00
Philipp Maier f9ca0204c4 mgcp: log file and line of calls to handle_error()
When the FSM runs into an error condition handle_error() is called with
a cause code. The information about the error is then printed by handle_error(),
by this we do not get the sourcecode line of the location where the error
actually happend.

Convey the source code line number of the actual error in handle_error()

Change-Id: Ifa7f2a655474826630988572616cd26e1e2f3464
2018-01-10 11:11:53 +00:00
Stefan Sperling 55a954bba1 Support control connection status query for a particular MSC.
Add a new control command 'msc.N.connection_status' which can be used
to query the connection status of a particular MSC with number N.

Keep the old control command 'msc_connection_status', which always
queries MSC 0, for backwards compatibility.

Change-Id: Ibd41474a1be80e782b19ec337c856b5efc593fa8
Related: OS#2729
2018-01-09 11:18:10 +00:00
Max ff3fad1aa8 vty: fix OML link state printing
Always print newline regardless of BTS uptime availability.

Change-Id: Ib80049fe66de17bc7acfbb774a30075f40a44dee
2018-01-08 13:02:37 +00:00
Max 94059b00a5 RSL: print link state per-TRX
Change-Id: Ie6fad70b4b11d0bb4927b22e32e842422658ba53
Fixes: OS#2715
2018-01-08 13:02:37 +00:00
Max 6e4f18455f cosmetic: remove duplicated code
Change-Id: I16c446ef7dc66769826f6e8ae118d8b07bbf6930
2018-01-08 13:02:37 +00:00
Neels Hofmeyr ff8ab0ada9 abisip-find: add --interval option
Change-Id: I9540054bdda185b2585209289cee565f61f33dcf
2018-01-08 12:56:12 +00:00
Pau Espin 3b7a31d327 osmo_bsc_bssap.c: Fix discard of const qualifier in assignment
Fixes following compilation warning:
osmo-bsc/src/osmo-bsc/osmo_bsc_bssap.c:442:10: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  enc_key = &data[1];
          ^

Change-Id: Ieeab5a822d50ac1267362f57196b80073a7901f9
2018-01-07 18:36:38 +01:00
Stefan Sperling 607f8c41bc Fix "CTRL GET msc_connection_status" response.
Since 39f62bbcbf the msc_connection_status
variable in osmo_bsc_ctrl.c is no longer updated. Query the connection's
status from the is_connected flag in struct bsc_msc_connection instead.

Makes test BSC_Tests.TC_ctrl_msc_connection_status in ttcn3-bsc-test pass.

However, we only query the connection status of the first MSC. Adapting
the control command to work with mulitple MSCs is left for future work.

Change-Id: I8ab8aac83ef6b7831b6136f7e9e3eddfbb43ecaa
Related: OS#2729
2018-01-05 10:10:56 +00:00
Max 82d25f6ea5 Check and handle SMS encoding failure
The SMS address encoding can fail due to gsm48_encode_bcd_number() which
was not checked for because wrong type was used. Fix this by using
correct type, checking for error and propagating it to the caller.

Change-Id: I9fc16e24f7df5ebad6f4f1b389b2c5e861be95d7
Fixes: CID57882
2017-12-31 11:02:42 +00:00
Max ec54daba5c Fix .deb builds
The code triggers following error:
abisip-find.c:317:3: error: format not a string literal and no format
arguments [-Werror=format-security]

The error was introduced in 5bf1e15c55.

Change-Id: I613781495edbc53916ca70ff7b78d28ffabd3f5d
2017-12-29 14:12:06 +01:00
Max ad1e3cdd6c Migrate from OpenSSL to osmo_get_rand_id()
This avoids potential licensing incompatibility and makes integration of
Debian packaging patches easier.

The libosmocore version requirements are fine already but for jenkins
tests to pass we have to have Ic77866ce65acf524b768882c751a4f9c0635740b
merged into libosmocore master.

Change-Id: Ia57bf1300525cf3c247284fe966b1c415c2d53e2
Related: OS#1694
2017-12-27 11:10:59 +00:00
Neels Hofmeyr 77a9d4e6ce abisip-find: add timeout option
Change-Id: I3b30e2b9cac9c70ba8d272022eee596de39d7b82
2017-12-25 19:24:00 +01:00
Neels Hofmeyr 89ade632be abisip-find: update copyright
Change-Id: Ibb72fa16cc1a8b6809d0510211bfc61a170d1250
2017-12-25 19:24:00 +01:00
Neels Hofmeyr 5bf1e15c55 abisip-find: add -l to list base stations instead of streaming replies
To get an overview of what base stations are present in a network, particularly
with many base stations being present, it is particularly useful to get a list
of connected base stations instead of just output of received replies.

Keep a sorted list of known base stations, which time out after 10 seconds.
Print additions and removals, and total amount of replies received. On each
change, print the entire list.

Output a running total of replies received, to provide comfort to the reader
that something is still happening, and to confirm that the shown listing is
still up-to-date (updated on the same line by means of '\r').

It looks like:

  ----- Mon Dec 25 18:59:43 2017

    0: MAC_Address='00:02:95:07:dc:bd'  IP_Address='192.168.0.124'  Unit_ID='1/1/1'  Location_1='Unknown'  Location_2='3GAP'  Equipment_Version='237B015_C'  Software_Version='unknown'  Unit_Name='Unknown'  Serial_Number='000295-0000152614'
    1: MAC_Address='00:02:95:07:dd:57'  IP_Address='192.168.0.15'  Unit_ID='1/1/1'  Location_1='Unknown'  Location_2='3GAP'  Equipment_Version='237B015_C'  Software_Version='unknown'  Unit_Name='Unknown'  Serial_Number='000295-0000154153'

  Total: 2
  RX: 11

  ----- Mon Dec 25 19:00:12 2017

  LOST:
  MAC_Address='00:02:95:07:dd:57'  IP_Address='192.168.0.15'  Unit_ID='1/1/1'  Location_1='Unknown'  Location_2='3GAP'  Equipment_Version='237B015_C'  Software_Version='unknown'  Unit_Name='Unknown'  Serial_Number='000295-0000154153'

  ----- Mon Dec 25 19:00:12 2017

    0: MAC_Address='00:02:95:07:dc:bd'  IP_Address='192.168.0.124'  Unit_ID='1/1/1'  Location_1='Unknown'  Location_2='3GAP'  Equipment_Version='237B015_C'  Software_Version='unknown'  Unit_Name='Unknown'  Serial_Number='000295-0000152614'

  Total: 1
  RX: 15

  ----- Mon Dec 25 19:00:28 2017

  New:
  MAC_Address='00:02:95:07:dd:57'  IP_Address='192.168.0.15'  Unit_ID='1/1/1'  Location_1='Unknown'  Location_2='3GAP'  Equipment_Version='237B015_C'  Software_Version='unknown'  Unit_Name='Unknown'  Serial_Number='000295-0000154153'

  ----- Mon Dec 25 19:00:28 2017

    0: MAC_Address='00:02:95:07:dc:bd'  IP_Address='192.168.0.124'  Unit_ID='1/1/1'  Location_1='Unknown'  Location_2='3GAP'  Equipment_Version='237B015_C'  Software_Version='unknown'  Unit_Name='Unknown'  Serial_Number='000295-0000152614'
    1: MAC_Address='00:02:95:07:dd:57'  IP_Address='192.168.0.15'  Unit_ID='1/1/1'  Location_1='Unknown'  Location_2='3GAP'  Equipment_Version='237B015_C'  Software_Version='unknown'  Unit_Name='Unknown'  Serial_Number='000295-0000154153'
  RX: 18

Change-Id: I4201876431029b303dbd10e46492228379c9782a
2017-12-25 19:23:49 +01:00
Neels Hofmeyr 2a9ac19863 abisip-find: add getopt option parsing in preparation for a new option
Subsequent patch I4201876431029b303dbd10e46492228379c9782a will add the -l
cmdline option. Add getopt in a separate step here to keep the patch lean.

Change-Id: Idba1a89753510fe6d409277b20c2db86c1b8f7f8
2017-12-25 19:22:37 +01:00
Harald Welte 148ee361b3 cosmetic: Hide all accesses to conn->bts behind conn_get_bts()
This is a new inline function that hides all accesses to conn->bts.

A follow-up patch will then point this to conn->lchan->ts->trx->bts
to get rid of the bts field.

Change-Id: Ib6cf7097ced34eebe80441c29ab1534f21956a33
2017-12-23 00:23:08 +01:00
Harald Welte a8d896954d BSC: Fix bsc_subsc leak on paging
The OsmoBSC code contained a refcount leak on bsc_subscr in the paging
code.  For every PAGING command received from the MSC we consistently
leaked one refcount, resulting in a resulting memory leak.

Change-Id: I3d0fb406ca2a1042c6c3424e0dd263c1933b0d50
Closes: OS#2780
2017-12-22 22:15:08 +01:00
Harald Welte 7c29b094d5 BSC: Add "show subscriber all" command
This command lists the currently-active bsc_subscr and their contents,
the format looks like this:

OsmoBSC> show subscriber all
 IMSI             TMSI      LAC    Use
 001010123456789  ffffffff  65534  3
 001010100000001  a1b2c301  65534  1

Change-Id: Ib9c0c31a0a5a91b42fd832fa0df3460b1a440733
2017-12-22 21:48:55 +01:00
Philipp Maier 57d4fe7157 mgcp: validate rtp connection data in MGW response (ip/port)
Currently the pasing results from the RTP ip/port are fed into
inet_addr without checking the results.

Check the return code of inet_addr to be sure that the IP-Address
got properly decoded.

Change-Id: I1d0aa7e9b8480e1bef57269e3904399cb99815bb
2017-12-20 11:57:19 +01:00
Philipp Maier 75f2c8d47f mgcp: cancel transactions on timeout
when a transaction to the MGW times out, then the context
information is freed. Unfortunately the client is not informed
about this and will try to execute the callback anyway.

explicitly cancel the transaction in order to prevent access
to already freed data structures.

Change-Id: I40794dff7d10e2b6a96863a2da7e9fbd5662a1bf
2017-12-20 11:48:18 +01:00
Harald Welte 472275c301 remove unused 'lac' member of 'struct gsm_subscriber_connection'
This field was used in write-pnly mode, i.e. set but never read.

Change-Id: I319945538fd3e3bc5cf3b9d82533641cb8ba5256
2017-12-19 18:58:51 +01:00
Harald Welte ea0c3203db osmo-bsc: Move user plane/voice related bits into sub-structure
This clarifies which members of the struct are for what.

Change-Id: I618822e6f2d48adce25f9df5c25acbce7c858412
2017-12-19 18:58:51 +01:00
Harald Welte 45f3eccaba osmo_bsc_bssap.c: Spelling fixes in comment
Change-Id: I32b2d08bf25cd2d343755ac8491e4f5f758ccee6
2017-12-19 17:53:14 +00:00
Harald Welte e94d7d1bdf remove libosmo-sccp dependency for osmo-bsc
libosmo-sccp is the old sccp-lite-focused SCCP implementation that we
used before libosmo-sigtran was created.  The new osmo-bsc in this
repository is using libosmo-sigtran and shouldn't be using parts of
libosmo-sccp anymore.

We only keep it around in configure.ac and Makefile.am for osmo-bsc_nat,
which is not even built in this repository anymore (or 'again yet'?)

Change-Id: I8f274be7d196cd7a5b1ec9ada949130fb06e984d
2017-12-19 17:53:14 +00:00
Harald Welte 3edbd0e065 Remove some more dead code
Change-Id: I919bffe88babd90227c89abd4434322965c32ebb
2017-12-19 17:53:14 +00:00
Harald Welte 8311a81bae Remove bogus MM INFO configuration
The network name and other MM INFO is controlled by the MSC, not the BSC.

Change-Id: I1cbf72fc50cff29e7c1633ba752cbf15b4b84c58
2017-12-19 17:53:14 +00:00
Harald Welte c499e5c62e Remove bogus vty config for LU reject cause
The LU reject cause (like anything MM related) is under control of
OsmoMSC, not BSC.

Change-Id: I559ae31d67726845c9699c8b6127e21c6f63ace6
2017-12-19 17:53:14 +00:00
Harald Welte faacb090f6 Remove unused RRLP options/codec
RRLP is handled in OsmoMSC after the split from NITB, so let's remove
any bogus VTY commands left over in the BSC.

Change-Id: Ib626f43a3a3ca69dfc127afe5832eb58f7fb6a38
2017-12-19 17:53:14 +00:00
Harald Welte d9956d91ba Remove dead code left over from NITB split
There still is a lot of dead code that we inherited from the NITB
days, let's remove more of it.

libtrau will be re-introduced as part of osmo-mgw later.

Change-Id: I8e0af56a158f25a4f1384d667c03eb20e72df5b8
2017-12-19 17:53:13 +00:00
Neels Hofmeyr 7abe7ae2d0 fix bssmap_handle_cipher_mode()'s encryption decision
Properly match up any A5/N with the MSC's list of permitted algos.

Properly set the reject cause in case of mismatching algorithm choices.

Actually allow choosing A5/1 thru 3 as configured on the VTY, by passing
a5_encryption through to gsm0808_cipher_mode() (instead of a hardcoded 1).

Properly handle failure rc of gsm0808_cipher_mode() by sending a reject
message.

Cosmetically clarify which GSM0808_IE_ENCRYPTION_INFORMATION bits mean what by
means of local variables; add some comments on expected encryption formats; add
comment that the BSC should be able to have more than one a5_encryption.

Related: OS#2745 OS#2755
Change-Id: Ide8a615905555e35be4584b458d4d40345686175
2017-12-14 21:39:49 +01:00
Neels Hofmeyr 8c6301cf0d debug log: log Cipher Mode info upon sending down RSL/A-bis
Change-Id: I7f7ec44887f6b40fdce8d348e9e9bd200fe0b689
2017-12-14 21:39:49 +01:00
Neels Hofmeyr 64c2920620 log typo fix in gsm0808_cipher_mode()
Change-Id: I3f6d138df9ddc9c6560d04e2e8baa1f3a50a164f
2017-12-14 21:39:44 +01:00
Harald Welte 00d64fd5ec Add new "chan:mode_modify_nack" counter to count RSL MODE MODIFY NACK
Those NACKs shouldn't happen in production, and if they do, you probably
want to have a more persistent figure than a line in the log file about
it.  Having counters allows the user to monitor this efficiently.

Change-Id: Ic82c6baaf4cb88d07bc5cdc200f8279cf130f396
2017-12-14 15:03:43 +01:00
Harald Welte 581398afab Add a new counter "rsl:ipa_nack" to count number of IPA related NACKs
Those NACKs (CRCX/MDCX/PDCH_ACT) shouldn't happen in production, and
if they do, you probably want to have a more persistent figure than
a line in the log file about it.  Having counters allows the user
to monitor this efficiently.

Change-Id: I5edf979c9a2b4c9a5a60eef9f66c26da54f2bddf
2017-12-14 15:03:43 +01:00
Harald Welte 62d9cb0529 Add new per-BTS "rsl:unknown" counter to count unknown RSL messages
Change-Id: I268f222140fa5783e1d19f81fbd45614aaa4b8c4
2017-12-14 15:03:43 +01:00
Harald Welte 4f59892ce6 Add per-BTS rate_ctr for total + failed number of RSL CHAN_ACT
Change-Id: I471b598af194dee78ebaa3414b6290c72d9bbcff
2017-12-14 15:03:43 +01:00
Harald Welte cf9d431e89 libbsc: paging: more reasonable (and detailed) paging statistics
Counting the number of T3113 expirations (one per subscriber per BTS)
vs the number of paging attempts (Bsc global) is a ueseless figure,
as you cannot relate each other.

We count on the BSC level:
	* how many PAGING we received from the MSC (total)
	* how many of those were for cells/LACs we don't serve
	* how many of those resulted in PAGING RESPONSE

We count on the BTS leve:
	* how many PAGING CMD we sent to the BTS (total)
	* how many of those we ignored as we were already paging
	* how many of those resulted in PAGING RESPONSE
	* how many were expired due to T3113 expiring

Change-Id: I410bbcbb2621f95f11238f7a5da01ab438f5fee1
2017-12-14 13:06:33 +01:00
Harald Welte 2ed22c83df Fix per-BTS counter group index
I discovered that the per-BTS counter group could only be requested
for BTS 0 but didn't work for any further BTSs.

This is a bug introduced in Change-Id I5bd9e6e333b1c396beae46630986b17e7f8b82ef
where we introudce the per-BTS counters,t but allocate all of them with
index '0'.

Change-Id: I1b56f8d7b47597ed263e6808074483edca0895de
2017-12-14 13:06:33 +01:00
Philipp Maier 256d09d1f2 paging: paging_flush_bts: be sure pending_requests is initalized
The BSSMAP reset causes the paging requests to be flushed. When
this happens right after startup then calling paging_flush_bts()
may be called when the list bts->paging.pending_requests is not
yet initalized, which causes a segfault.

Call paging_init_if_needed() to be sure that the list is
inizalized (like the other functions also do)

Change-Id: I42ddbfdec6f9d74d858ad13cc38b5b64061d08dc
2017-12-13 20:19:52 +00:00
Neels Hofmeyr 719322693c fix segfault upon release paging on BSSMAP Reset: init llist
Initialize the llist head gsm_bts->paging.pending_requests at the time gsm_bts
is allocated, not only at paging_init_if_needed().

The gsm_bts->paging sub-struct is invalid as long as gsm_bts->paging.bts
doesn't point back to bts. Hence the recently added iteration of
gsm_bts->paging.pending_requests should have checked whether bts is NULL. The
llist_head pending_requests is not initialized unless paging_init_if_needed()
has been called (and paging.bts is hence set). However, this fix is a safer way
to prevent errors like this in general.

The segfault was introduced by d382bf63e2 /
If3f53d3bb66ad2dc02db823cb813590c6b59c700

Related: OS#2747
Change-Id: Idfafac4e2c0e0a241a62aecbbdc22be71febf840
2017-12-13 19:13:44 +01:00
Max 61b0c30cca Generate SI2bis Rest Octets
According to the spec it's an empty 1-byte element reserved for future
extension but we still have to generate padding properly. Add stub
function similar to the used for SI2ter and adjust test output
accordingly.

Related: OS#2711
Change-Id: I3c278c57880a173df3c4648c9724339d23ce94fd
2017-12-12 18:00:56 +00:00
Harald Welte d382bf63e2 paging: Stop all paging if MSC sends us BSSMAP RESET
When the MSC has lost its state and issues a RESET, we should not only
clear all ongoing radio connections, but we should also stop any paging.
There's no point in paging a subscriber if the MSC doesn't know about
this paging anymore.

Change-Id: If3f53d3bb66ad2dc02db823cb813590c6b59c700
Closes: OS#2736
2017-12-11 16:21:38 +01:00
Harald Welte f4b66fb2f1 paging: Remove obsolete paging call-back support
The call-back was needed inside the NITB to determine which part (CC,
SMS, ...) had triggered a given paging.   A pure BSC doesn't need that
feature, so let's get rid of it.

The 'void *cbfn_data' is replaced with a 'struct bsc_msc_data *', as
all callers use it with that type.

Change-Id: I8839e8338d3ad1a91b41e687e8412fcdca3fd9ab
2017-12-11 16:21:38 +01:00
Harald Welte 958cccf89a paging.c: add more documentation on what the functions actually do
This was created during code review towards some upcoming fix for
OS#2736. However, it's not really related to that.

Change-Id: I68d4fc8baaedd1d64cd628b2441c57ebc64ecebc
2017-12-11 16:21:38 +01:00
Max 4bd710d107 Generate SI2ter Rest Octets
Previously we simply omitted SI2ter Rest Octets which is spec violation
which lead to 'Malformed Packet' error in Wireshark RSL dissector. Fix
this by generating empty 'no rest octets' with proper padding. Adjust
test output accordingly.

Change-Id: Ie4419aaaf93a462f501f8d8f7bf2677d37c58f94
Fixes: OS#2711
2017-12-11 12:27:49 +01:00
Philipp Maier eb79614f4e mgcp: cosmetic fixups
- use unique enum/struct fsm struct names
- use macro to shift bits in FSM description
- use OSMO_STRINGIFY to generate the state names
- remove duplicate logging of states and events
- remove unnecessary space in log strings
- prefix hexadecimal enpoint ids with
- remove unnecessary log messages
- rename bsc_mgcp_cause_codes_str to bsc_mgcp_cause_codes_names

Change-Id: I663e03046cde3c786af72d15681bf7497330d7f9
2017-12-10 14:22:41 +00:00
Max 115e2672fe OML: expand status reporting checks
* check GPRS state: if GPRS is enabled for the BTS but NSE, CELL or both
  NSVC are locked than report it as degraded
* check TRX usability: use already available function to check that TRX
  is actually usable when reporting OML status via CTRL
* fix tests linking: libbsc is using gsm48_create_mm_serv_rej() which is
  defined in libcommon-cs but neither libbsc itself nor tests using it
  are actually linked against libcommon-cs

Related: OS#2486
Change-Id: I9dce1d3b0cabe149a90cfca58a3fe55f8d6a72bc
2017-12-10 14:18:41 +00:00
Harald Welte 9311005aff Remove 'msc' counter group from BSC
This is left over from the OsmoNITB days.  We're defining and allocating
these MSC counters, but never actually using them.  This also means that
the automatic counter export will list them, raising the expectation at
users that such counters could be used in OsmoBSC.

Let's remove them.  They are in OsmoMSC, but not OsmoBSC.

Change-Id: I5bd9e6e333b1c396beae46630986b17e7f8b82ef
2017-12-09 23:14:50 +01:00
Harald Welte d82101e663 Move many counters from BSC-global to per-BTS granularity
We used to have a lot of counters only globlly per BSC, but they're
much more useful on a per-BTS level.

Change-Id: I954b9dda72b83b91d46a934c221a8b3375743599
2017-12-09 23:07:38 +01:00
Philipp Maier f4d0889abb cosmetic: use fsm pointer from parameter list
the parameter list of osmo-fsm callbacks contains a pointer
to the fsm instance. Use this pointer instead of reaching
out for mgcp_ctx->fsm.

Change-Id: I05ff62e7e2de64c2dbf5ea2736f5e58faf16df0b
2017-12-01 13:36:30 +01:00
Philipp Maier a89e163e4c cosmetic: correct sourcecode formatting
add missing line break

Change-Id: Ia117e4099046fefcf35ccb94400554062e667869
2017-12-01 13:36:30 +01:00
Philipp Maier e941f88ea1 cosmetic: add missing log prefix
the log messages have prefixes that mark important phases (CRCX/BTS,
etc...). Some lines lack the prefix.

Add missing prefixes.

Change-Id: Iea5ea9e54f4b5c998b1d5fe18a98a94abd7b728b
2017-12-01 13:36:30 +01:00
Philipp Maier 7eeb84271d cosmetic: do not cast void pointer
remove the casting of void *data, just assign directly

Change-Id: I2e37630e315b3602da2f14e2364bb76be9dd2894
2017-12-01 13:36:30 +01:00
Philipp Maier e4cfa74d38 cosmetic: remove duplicate logging
The log output of the reset FSM duplicates lots of the built in
FSM log output.

Remove duplicate logging, use more expressive log messages where
needed.

Change-Id: Ia5af309207476291f88af47878dc1d32b2dada06
2017-12-01 13:36:30 +01:00
Philipp Maier 06c3f8d3cb mgcp: do not fail silently on snprintf()
The snprintf() that is used to compose the fsm name on an assignment
request may cause a silent failure. The buffer is large enough to
take the string under all circumstances. If snprintf() fails, this
would mean we have some other serious problem.

use OSMO_ASSERT in case the snprintf() fails, so the failure
gets noticed.

Change-Id: I3c36df8cfd0880c524244048a993cd136be41f56
2017-12-01 13:36:30 +01:00
Philipp Maier 3ada5397d7 mgcp: add missing switch case
In the beginning of the CRCX phase for the network does not distinguish
between EV_MDCX_BTS_RES and EV_TEARDOWN, so a Teardown due to an error
could be misinterpreted as a successful MGW response.

Add missing case statement to distinguish CV_MDCX_BTS_RES from
EV_TEARDOWN.

Change-Id: I9bf49df167d94b33ad65d8b9382a01f160b5aec0
2017-12-01 13:36:30 +01:00
Philipp Maier fa85d18807 mgcp: use mgw assigned connection identifiers
osmo-mgw assigns connection identifiers which are returned with
the response to the CRCX.

store the assigned connection identifiers and use them to identify
the connections.

Depends: osmo-mgw Iab6a6038e7610c62f34e642cd49c93d11151252c

Closes: OS#2648
Change-Id: Ib379a6f40875bb8f2cf29038a5b5b7a40a21adab
2017-12-01 13:36:30 +01:00
Philipp Maier 2c3bf45449 mgcp: use hexadecimal digits in endpoint names
The current implementation of osmo-mgw parses the numerical
digit inside the endpoint name as hexadecimal number.

also use hexadecimal numbers in endpoint names.

Change-Id: I64a970d300b7290d50ec84b0640d5a321d903f5e
2017-12-01 13:36:30 +01:00
Philipp Maier 20114aa809 auth: remove obsolete VTY commands
authentication (optional|required) is no longer needed, the
related decisions are now made in the HLR.

Change-Id: Ib6c6331cc86004c4862067031e4fcb12a6975b63
2017-11-30 09:21:51 +01:00
Philipp Maier 3b18044859 sccp-lite: remove obsolete VTY commands
remove obsolete vty commands:

- token
- auth-key
- no auth-key

Change-Id: I9101d750a424b8af46d603bc7c877229bbae8727
2017-11-30 08:18:45 +00:00
Philipp Maier bad11ae812 bssap: remove libosmo-legacy-mgcp dependancy
the functions mgcp_timeslot_to_endpoint() and rtp_calculate_port()
which are used to calculate the port in the sccp-lite / non AoIP
case are part of libosmo-legacy-mgcp. Unfortunately libosmo-mgcp
and libosmo-legacy-mgcp cause problems when used at the same
time.

Replace the functions mgcp_timeslot_to_endpoint() and rtp_calculate_port()
with a local helper function.

Change-Id: Id10311332aeabd8fd3ba1922198e34708e04cef9
2017-11-30 08:17:41 +00:00
Neels Hofmeyr 9c6d01173b HO prep: pass gsm_network to gsm_bts_alloc() already
Prepare for a future change that accesses bts->network during gsm_bts_alloc().

Currently, gsm_bts_alloc() takes a ctx parameter, and gsm_bts_alloc_register()
then gets the gsm_network pointer and sets bts->network to it. All callers
anyway pass gsm_network as ctx to gsm_bts_alloc(), and anything else would not
make sense anyway. So enforce passing exactly gsm_network to gsm_bts_alloc()
and already set the bts->network pointer from there.

Prepares-for: I00870a5828703cf397776668d3301c0c3a4e033a
Change-Id: Ie590c14aa08df4c4f345596b23e5226c5577057a
2017-11-29 17:37:18 +00:00
Neels Hofmeyr a2733ae9dc cosmetic: handover.h: use "#pragma once", declare structs, comments
Use new #pragma style instead of #ifndef dance.
Forward-declare all structs we're using pointers of.
Move function comments to their definitions in the .c file.

Change-Id: I3d43ec01897c0ef9eaf506e68d5a1ec1977f70ea
2017-11-29 17:37:18 +00:00
Neels Hofmeyr 27cd0fe430 compiler warnings: constify in abis_nm.c
Constify in- and output arguments for Parse Attribute Response Info chain to
avoid compiler warnings, and more clearly indicate const data in the first
place.

Change-Id: Ib7d069fe1fda69e89dfd171cd76b1ed6d6db0ceb
2017-11-29 17:37:18 +00:00
Neels Hofmeyr 39d50a7f4e compiler warnings: drop some unused variables
Change-Id: I840b0cd8ee3e7c521e7c9053a992deeb9ec22ff4
2017-11-29 17:37:18 +00:00
Max c8d55f2c0b cosmetic: mark gsm_objclass2mo as static
It's only used once in the same file so there's no need to put it into
global header.

Change-Id: Id9674cad54bab6cc04475719678efc2c25d058a9
2017-11-29 14:26:15 +00:00
Max d0ff694cb9 cosmetic: tighten function type signatures
* change return type to bool
* constify parameters

The nm_is_running(), trx_is_usable() and ts_is_usable() always return
boolean value and are always used as such anyway. The also do not change
their parameters.

Change-Id: I6a572fc78371c69f5308edbad0ebe15e143d0505
2017-11-29 14:23:13 +00:00
Pau Espin 8c209c9e2b cosmetic: bsc_vty: Document bvci reserved values
Change-Id: I7a4374c3619cb83ef8beef594281f887d9fbf70a
2017-11-29 11:55:18 +00:00
Pau Espin c5a84166cb cosmetic: bsc_vty: Fix trailing whitespace
Change-Id: I7089062285c40ec11af479c98b43d1d407397c82
2017-11-29 11:55:18 +00:00
Philipp Maier ad47f7108a auth: remove obsolete VTY commands
Authentication is no longer done in the BSC, the variables that
set the authentication policy and the IMSI regex have no longer
any effect.

Remove auth policy and authorized-regexp

Change-Id: Ie31b921b5fd0af5501ec0c77c0f08089c10075e2
2017-11-29 11:48:49 +00:00
Max d0f479e744 cosmetic: remove obsolete ROLE_BSC
It's leftover from the time when gsm_data_shared.* was actually shared
with OsmoBTS. Nowadays ROLE_BSC is always defined so we can just drop it
entirely and make working with gsm_data_shared.h slightly easier.

Change-Id: I34fc9ee5955c14bbbde68d5499cf2acfd329afbc
2017-11-29 12:24:52 +01:00
Max aa954cd10f OML: consider administrative state when reporting
Report state as degraded if BTS or any of its TRX are administratively
locked.

Change-Id: Ic9ee998d972ca870ce5d039c3ed95edb6ba8b36f
Related: OS#2486
2017-11-29 12:18:02 +01:00
Pau Espin e8dda5f296 vty: Add cmd to configure 3g Early Classmark Sending
In state prior to this patch, "3G Early Classmark Sending Restriction"
bit in SI3 rest octets was always set to H, which is a sane default as
the policy to send the information is then controlled by "Early
Classmark Sending Control" bit in the same octet.

However, it seems Quortus SoftCore can have some issues decoding the
option, so let's add a vty cmd to be able to disable it for those
having any issues.

Related: SYS#4021

Change-Id: Ic1afe071038a3bb5871d7ff40f665c8644f801ec
2017-11-24 15:01:20 +01:00
Pau Espin 91c76fd656 Use type bool for boolean fields in gsm48_si_ro_info
Change-Id: Ic0981fca96f4927717ca335be1dab00a5d17fd6c
2017-11-24 12:55:15 +01:00
Neels Hofmeyr 434187533b bsc filter: don't ignore imsi-allow on "global" filter level
First off, there are "global" and "local" IMSI black/whitelist levels:

     "global"  "local"
 VTY 'bsc'     'msc'   for osmo-bsc
 VTY 'nat'     'bsc'   for osmo-bsc_nat

Both in osmo-bsc and osmo-bsc-nat, the "global" IMSI filter so far completely
ignores all 'imsi-allow' rules it may contain. A comment in imsi_allow()
proclaims actions that are missing in the code. Notably, in our example config
osmo-bsc_nat.cfg, there is an imsi-allow on the 'nat' level, which with the
code before this patch cannot have been effective in any way.

Furthermore, on the "local" level the order is to check imsi-allow first, and
imsi-deny after that. The comment says to do that in reverse order on the
"global" level. There is no apparent reason for reversing.

Add evaluation of imsi-allow directives on the "global" level, i.e. 'bsc' in
osmo-bsc and 'nat' in osmo-bsc-nat, in the same order as on "local" level, to
avoid confusion. Swap the comment to be consistent.

Before this patch, to have effective imsi-allow, this config would be necessary
for osmo-bsc:

    bsc
     access-list acl imsi-allow 999999999999999
     access-list acl imsi-allow 9017.*
     access-list acl imsi-deny .*
    msc 0
     access-list-name acl
     ...
    msc 1
     access-list-name acl
     ...

With this patch, imsi-allow also works on the "global" level:

    bsc
     access-list acl imsi-allow 999999999999999
     access-list acl imsi-allow 9017.*
     access-list acl imsi-deny .*
     access-list-name acl
    msc 0
     ...
    msc 1
     ...

Change-Id: Idb6c8dd62aa90666ba6fcd213f59d79f5498da3f
2017-11-23 13:21:12 +00:00
Neels Hofmeyr d663097b8a bsc_init: fix Werror: define rc for 2quater with si2q_count == 0
src/libbsc/bsc_init.c: In function ‘rsl_si’:
  src/libbsc/bsc_init.c:153:2: error: ‘rc’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    return rc;
    ^

Change-Id: Iedad1efcb477c77db8c741777ea076761658c7d1
2017-11-21 14:38:21 +01:00
Philipp Maier 7e0c269e5c reset: remove name variable from reset context
The reset context contains a string buffer to allow for setting
a human readable name, that is then displayed in the logs. Since
OSMO-FSMs already have such a feature there is no need for an
extra name variable.

Use LOGPFSML and the name parameter of osmo_fsm_inst_alloc()
to display the name of the FSM

Fixes: Coverity CID#178664

Change-Id: I34511698923abec7545a6f3defd595f97b4bbeb1
2017-11-20 09:21:16 +00:00
Harald Welte 4a3b044ad7 osmo-bsc: Print NOTICE message on unimplemented BSSMAP UDT
When we receive unimplemented/unhandled message types, we shouldn't
simply silently discard them, but print a log message for the
benefit of the user.

Change-Id: I65489578b1c214f193b1ce0e9ba59432dcd42a3e
2017-11-12 14:36:11 +00:00
Philipp Maier 4aa2bac0bc mgcp: remove unused variable
The function handle_error asserts mgcp_ctx->conn to be non null,
but it does not access it otherwise.

remove unused variable conn

Change-Id: I09851c957395d1ddb2f9471b99ffc091bc250404
2017-11-12 14:22:46 +00:00
Philipp Maier 2a4c077fca mgcp: add missing out state
Even in the very early ST_CRCX_BTS phase, the error handler may
decide to go to ST_CALL in order to initate the termination of
a possibly half open connection.

Add ST_CALL to the out state list in ST_CRCX_BTS

Change-Id: Ic67aa7c67a4e98a38bff156be3ebf612012eb842
2017-11-12 14:22:46 +00:00
Philipp Maier 7cbea54544 cosmetic: replace term MGCP-GW with MGW
The term MGCP-GW is deprecated, use now MGW

Change-Id: Ibccda7e95c42267ce5f44e9fc4256a0083b6f68f
2017-11-12 14:22:46 +00:00
Philipp Maier 9b7678d65c cosmetic: reorder case list
the switch statement in fsm_send_assignment_complete() has the
default case at the beginning.

Move the default case to the end to match common coding style
rules

Change-Id: I360842fe899b95972c44da3cb74a3dc51b379fdc
2017-11-12 14:22:46 +00:00
Neels Hofmeyr 7c980544f8 use osmo_sccp_inst_addr_name() instead of looking up ss7
Depends: libosmo-sccp I70ec5c8b42682a23f11a5820431c7e34e225709b
Change-Id: Idb451597c724ac87a391121cebd0b0a927dd49d1
2017-11-10 23:36:12 +00:00