Commit Graph

1034 Commits

Author SHA1 Message Date
Neels Hofmeyr fc622c7241 drop dead code: conn->T10, handled by gscon instead
Change-Id: Ief20cb0f46dd93f46dd765dca307724dc2b3487c
2018-06-08 16:16:42 +00:00
Neels Hofmeyr 0abe84e679 HO: introduce T7, T8, T101 timers
Will be used in upcoming inter-BSC handover.

Change-Id: If9ecccc793426d214019f299b19d6ffa5a186546
2018-06-08 16:16:42 +00:00
Neels Hofmeyr 76739a7109 cosmetic: gscon: drop odd use of OSMO_STRINGIFY
Do not invoke OSMO_STRINGIFY() with arbitrary names, just quote instead.

The idea was that OSMO_STRINGIFY() avoids typos by ensuring well-defined names
are stringified, but this highlights that OSMO_STRINGIFY() is in fact usable
with completely arbitrary arguments and actually lacks the validation part :/

Change-Id: I458cd2cd0d6ddb0e6db3bb8d546a20336ae8c5f1
2018-06-08 16:16:42 +00:00
Neels Hofmeyr 7c68e9048f store subscriber identity on paging
Another small step towards being aware of the subscriber identity.

Any connection initiated by paging will subsequently log the subscriber's
identity -- of course not necessarily the IMSI, if paging was done by TMSI.

This is only for Paging, not the Paging Response; for that see, L3 Complete.

Related: OS#2969
Change-Id: I0ab7bedfe693bb4e42a04fb0585b94a730ff2d9b
2018-06-08 16:16:42 +00:00
Neels Hofmeyr 81e912fa78 try to pick up subsrc IMSI on l3-compl
This is a tiny step towards being aware of a connection's subscriber identity.
Iff the Layer 3 Complete message contains an IMSI, associate a bsc_subscr with
the conn, so that subsequent logging and possibly meas_feed contains the IMSI.

For any L3 Complete using TMSI, this has no effect whatsoever.

Related: OS#2969
Change-Id: I3b696a0c0932e3abcb682ba231db65755d8c27a6
2018-06-08 16:16:42 +00:00
Neels Hofmeyr 8d6f444191 gscon: put subscriber a little later
Keep the bsc_subscr associated with the conn as long as possible, to benefit
logging, which then contains the subscriber identity (if any).

Change-Id: Ifa528b58842a02509bfe0af6915c64bd67058bcd
2018-06-08 16:16:42 +00:00
Neels Hofmeyr d3fff6f532 cosmetic: bsc_subscr_alloc: log initial get
Instead of silently setting the use count to 1, instead increment with an
explicit bsc_subsct_get(), which then logs the event along with the place that
created the subscriber.

Change-Id: Ia72f8010b7b2e1ca44e3b005c0f2c05f3eeae8d5
2018-06-08 16:16:42 +00:00
Neels Hofmeyr fb75d109a1 cosmetic: penalty timers: constify, tweak doc
Change-Id: I28addc9a16a4c81978290303d368f630a8334228
2018-06-08 16:16:42 +00:00
Neels Hofmeyr dd24cd39c0 use libosmocore's gsm0808_permitted_speech(), gsm0808_chosen_channel()
The guts of bssap_speech_from_lchan() and lchan_to_chosen_channel() have been
moved to libosmocore; call those instead.

The return value of bssap_speech_from_lchan() used to be -1 on error, now the
error value is 0. The only caller did not handle -1 properly, but fed it
directly to a uint8_t.

On gsm0808_chosen_channel() error, log the error. Proper handling is missing.

Fixing the error handling in send_ass_compl() is a separate issue: currently it
is limited to logging, there is no way to return an error yet, nor any actions
to take on error.

Depends: Icca23940791f97fa64dbc3f2734270b99f9550c1 (libosmocore)
Change-Id: Ib5c940a9dae11c5e26d4b47fa9d95fef889ad2f6
2018-06-08 16:16:42 +00:00
Neels Hofmeyr 8cb570cd06 log: assignment: add two logs on unexpected lchan release
Change-Id: Ib61125ebc41e55dc4a6595db8c8559c62b3ed2c0
2018-06-08 16:16:42 +00:00
Neels Hofmeyr 57f32626e3 log: fix logging in rsl_rx_chan_act_nack()
In each code path within rsl_rx_chan_act_nack(), do separate logging of the
NACK to ensure proper termination of each log line.

When receiving a Chan Act NACK, we possibly mixed a LOGP() within an
unterminated other LOGP() that had not been ended with a LOGPC() yet.

Change-Id: Icd2772b21ef3a2ff5af11b7c92dff0ecb4d87ff0
2018-06-08 16:16:42 +00:00
Neels Hofmeyr 0935546b2b assignment: signal assignment failure on chan act nack
When the BTS responds with a Chan Act NACK, i.e. the lchan could not be
activated, immediately signal Assignment Failure to the MSC (in
handle_chan_nack()).

In handle_chan_nack(), adjust log: instead of waiting for timeout, we now
signal Assignment Failure.

Drop misleading logging from bsc_assign_fail(): instead of transmitting the
Assignment Failure message, it actually signals an FSM event. Leave logging of
that to the FSM logging.

Change-Id: Ib204b4a5272f9b7b60ca5f932cd8a4c857316270
2018-06-08 05:47:54 +02:00
Neels Hofmeyr 13269b0f9b cosmetic: gscon: undup code: add common assignment_failed()
Call one common function to signal Assignment Failure and transition back to
ST_ACTIVE.

Change-Id: I1ce10a3ead286cdb6ad529fc293b6cecd151cc9a
2018-06-07 19:09:06 +02:00
Neels Hofmeyr 74c07c7b9c cosmetic: magic number: use RSL_ACT_ constant for chan act
Change-Id: I64ac2a17634f18322828ee2aa2284b0513130488
2018-06-07 19:09:06 +02:00
Neels Hofmeyr c19581f268 remove struct bsc_api
struct bsc_api was used to provide an abstract API for both osmo-bsc and
osmo-msc, between BSC and MSC. That's no longer needed, so get rid of it, to
prevent code turbulences it creates for no reason.

Change-Id: I3fd5888c63a0b4f95520a498320aa105a6d60579
2018-06-07 19:09:06 +02:00
Neels Hofmeyr 958f259f95 dissolve libbsc: move all to src/osmo-bsc, link .o files
Move all of libbsc/ into osmo-bsc/, and separate/move some implementations to
allow linking from utils/* and ipaccess/* without pulling in unccessary
dependencies.

Some utilities use gsm_network and gsm_bts structs, which already include data
structures for fairly advanced uses. Move initialization that only osmo-bsc
needs into new bsc_network_init() and bsc_bts_alloc_register() functions, so
that the leaner tools can use the old gsm_* versions without the need to link
everything (e.g. handover and lchan alloc code).

In some instances, there need to be stubs if to cut off linking "just before
the RSL level" and prevent dependencies from creeping in.
- abis_rsl_rcvmsg(): the only program currently interpreting RSL messages is
  osmo-bsc, the utils are merely concerned with OML, if at all.
- paging_flush_bts(): ip.access nanobts models call this when the RSL link is
  dropped. Only osmo-bsc actually needs to do anything there.
- on_gsm_ts_init(): the mechanism to trigger timeslot initialization is related
  to OML, while this action to take on init would pull in RSL dependencies.
utils/ and ipaccess/ each have a stubs.c file to implement these stubs. Tests
implement stubs inline where required.

From src/utils/, src/ipaccess/ and tests/*/, link in .o files from osmo-bsc/.
In order for this to work, the osmo-bsc subdir must be built before the other
source trees. (An alternative would be to include the .c files as sources, but
that would re-compile them in every source tree. Not a large burden really, but
unless linking .o files gives problems, let's have the quicker build.)

Minor obvious cleanups creep in with this patch, I will not bother to name them
individually now unless code review asks me to.

Rationale:

1) libbsc has been separate to use it for osmo-nitb and osmo-bsc in the old
openbsc.git. This is no longer required, and spreading over libbsc and osmo-bsc
is distracting.

2) Recently, ridiculous linking requirements have made adding new functions
cumbersome, because libbsc has started depending on osmo-bsc/*.c
implementations: on gscon FSM and bssap functions. For example, neither
bs11_config nor ipaccess-config nor bts_test need handover_cfg or BSSMAP
message composition. It makes no sense to link the entire osmo-bsc to it, nor
do we want to keep adding stubs to each linking realm.

Change-Id: I36a586726f5818121abe54d25654819fc451d3bf
2018-06-07 19:09:06 +02:00
Stefan Sperling 39a1d10c11 increment 'paging responded' counter for active paging only
Only count paging responses which can be mapped to an active paging.

Unsolicited paging responses which do not correspond to an active paging
would increment the 'paging response' counter. This means the number of
paging attempts could be smaller than the number of paging responses,
which can look confusing in the 'show statistics' VTY command.

Change-Id: I7cfc7c29fb7570d41e3ac23cca17f5b98b303506
Related: OS#66
2018-06-07 17:14:16 +02:00
Harald Welte b5f81b9fbd Reject ASSIGNMENT REQ with CIC but no AoIP transp addr in AoIP case
If we receive a BSSMAP ASSIGNMENT REQ for a speech channel
containing only a CIC but no AoIP transport layer address, then that's
illegal and must be rejected.

In Change-Id If362a0084de452727cd063063dfb645eca2f9beb we re-introduced
accepting CIC-only ASSIGNMENT REQ, but we failed to verify that this
actually only happens over a SCCPlite A interface.

This fixes the BSC_Tests.TC_assignment_cic_only testcase.

Change-Id: Ia6e3897edca48b9f838ea69939d9b8be7185abf8
2018-06-05 21:57:54 +02:00
Harald Welte 1f1c56c622 LCLS: add VTY config to enable/disable LCLS on per-MSC basis
The user might not want to enable LCLS support for administrative
reasons.  So let's keep it disabled by default, until somebody
explicitly enables it with "lcls-mode mgw-loop".

In the future, we may want to introduce a "lcls-mode bts-loop" where we
don't loop at the BSC-colocated MGW, but where we instruct the BTSs to
feed the RTP directly to each other.  This would require a
falt/transparent IP routing between the BTSs in the RAN.

Change-Id: Ied7985056c8cd182bf16119007a08cc5be14459b
Related: OS#1602
2018-06-03 12:26:42 +02:00
Harald Welte c997ceb750 Add initial 3GPP LCLS support to OsmoBSC
This code contains the following code:
* receive/parse/interpret LCLS specific BSSMAP IEs and PDUs
* osmo_fsm handling the various states and their transitions
* call leg correlation (finding the other subscr_conn with same GCR)
* communication between the two call-leg LCLS FSMs
* detection of supported / unsupported LCLS configurations
* display of GCR / LCLS information in "show conns"
* switch the media streams locally using MDCX to the MGW

Closes: OS#1602
Change-Id: I614fade62834def5cafc94c4d2578cd747a3f9f7
2018-06-02 20:56:17 +02:00
Harald Welte 00965dca2b VTY: Print some more information in "show conns"
We now print information such as
* SCCP connection ID
* MSC number
* handover decision2 fail count
* channel mode (SIGN/SPEECH)
* MGW endpoint
* secondary lchan (if any, e.g. during assignment)
* don't crash if conn->lchan == NULL

Change-Id: I2f8000844afc9da93ca39976399e5f76a45530de
2018-06-02 20:56:17 +02:00
Pau Espin 8bf8142dba abis_rsl: rsl_rx_chan_rqd: Format bts log string as in everywhere else
Change-Id: I7928d78e2ce3e6eca545455d08bc89ca67e01f9f
2018-05-30 14:32:59 +00:00
Pau Espin fe82012b01 abis_rsl.c: Fix whitespace
Change-Id: I67659275beda1b6a89bdf11eb0231438b0c8b912
2018-05-30 14:32:59 +00:00
Pau Espin 18a4ae818f chan_alloc: Print bts nr on chan alloc failure
Also change format of related debug message to match similar format than
gsm_ts_and_pchan_name().

Change-Id: Id4f875944c40fd862fc63feec82216c45d2e41c2
2018-05-30 14:32:59 +00:00
Pau Espin 67f20bc356 acc_ramp: Increase log level of some messages
Right now, it's impossible to see any ACC Ramping information unless RSL
category is set to DEBUG. Barring and Allowing Access Control Class is
an important event which should be printed in most cases.

Increase log levels of messages printed during some error conditions to
be handled as errors.

Change-Id: I5404e91fe7c0b3209e8033594e659387bbc924d6
2018-05-28 11:58:06 +00:00
Harald Welte 1876c3108c move 'extern struct gsm_network *bsc_gsmnet" to header file
It's not a good idea to keep extern declarations copied over
half a dozen C files.  Let's move it to a header.

Change-Id: I6f643f1393ba0955d9c0cf1cf78d5c604e7b9451
2018-05-27 20:17:06 +02:00
Harald Welte 68e4be9c84 Remove 'struct bsc_msc_connection' + fix IPA-encapsulated CTRL
The bsc_msc_connection dates back to the old pre-libosmo-sigtran
days, and 90% of the field members weren't used at all (even the
new sigtran specific ones!).  Let's merge what remains into struct
bsc_msc_data.

As a side effect, the already dysfunctional "dest A.B.C.D" VTY
command has been removed from the MSC node.

There's quite a bit of fall-out in the CTRL interface, which was
the code with strongest ties to bsc_msc_connection.  This was
resolved by properly porting CTRL handling over to libosmo-sigtran,
meaning that an IPA/SCCPlite connected MSC can now again send CTRL
GET/SET commands, and can also receive those selective few TRAPs
that old osmo-bsc-sccplite also sent to its MSC[s].

Change-Id: I6b7354f3b23a26bb4eab12213ca3d3b614c8154f
Related: OS#2012
2018-05-27 20:17:02 +02:00
Harald Welte 1c9b8b1917 remove remaining bits of osmo-bsc_nat
osmo-bsc_nat is too heavily tied into legacy SCCPlite code, as it
is not using libosmo-sigtran/osmo_ss7 so far.  It's also full of
customer-specific code and it's shared use of some libbsc code here
has been complicating osmo-bsc development.

The current plan is to continue to use osmo-bsc_nat from openbsc.git
for those legacy users that need it, and not use osmo-bsc_nat in
new 3GPP AoIP setups.  Should we ever get a strong demand for an AoIP
based bsc_nat, we can still revisit this later.

Change-Id: Ia05dc76336a64a7f08962843b9a7cc19f2c83387
2018-05-27 17:48:49 +02:00
Harald Welte 7b897dfea5 bsc: Don't create MSC-side MGCP connection in IPA/SCCPlite case
In IPA/SCCPlite, the MSC is handling MGCP to the BSC-MGW directly
and the BSC only takes care of the BTS-side MGCP connection.  We
achieve this by transitioning directly from WAIT_MDCX_BTS into ACTIVE
in this case.

Change-Id: I96179b4324b976bded36023a8ccbdc007b6b3e05
Related: OS#2544
2018-05-25 20:59:13 +02:00
Harald Welte 200a0e2d0a bsc: Don't include AoIP IEs in ASSIGNMENT COMPLETE over SCCPlite
Change-Id: I6ace15f368b5ba6e5c8845ea21d17dd3a7a15be7
2018-05-25 18:58:16 +00:00
Harald Welte f6029bac5e bsc: Don't reject ASSIGNMENT for Audio in IPA/SCCPlite case
Change-Id: If362a0084de452727cd063063dfb645eca2f9beb
2018-05-25 18:58:16 +00:00
Harald Welte 2dd05a85f9 bsc: Use correct MGCP endpoint name for IPA/SCCPlite
In IPA/SCCPlite, we have to use the CIC to construct the MGCP
endpoint name instead of the usual dynamic endpoint allocation.

Change-Id: I03e2cdbc8e40169e52df3720c40b66734e880525
2018-05-25 18:58:16 +00:00
Harald Welte 584ab8e11f bsc: Add mgcp_port_to_cic() to determine CIC from RTP Port
Also: Move mgcp_timeslot_to_port() next to it, as they are
more or less the inverse transformation of each other.

Change-Id: Ica908e2bb8fc4e59e0d146b428c93a9efc385688
2018-05-25 18:58:16 +00:00
Harald Welte 3909d99fae vty: Permit selection of other ASP protocol than M3UA
We used to have hard-coded M3UA.  Let's allow the user to configure
this per MSC using a new "asp-protocol (m3ua|sua|ipa)" VTY command.

For SUA this should just work 1:1 without any trouble.  For IPA,
this of course only changes the underlying transport without reflecting
the various differences in terms of BSSMAP ASSIGNMENT, MGCP handling,
etc.

Change-Id: I0800c709e574cedd7f5dd98be81c78782245cd13
Related: OS#2544
2018-05-25 18:58:16 +00:00
Harald Welte 631bde0e9b bsc: Fix check for MSC-side FSM allocation failure
In gscon_fsm_wait_mdcx_bts() we try to allocate conn->user_plane.fi_msc
but then check whether conn->user_plane.fi_bts is set, possibly due to
a copy+paste error.  Let's fix that.

Change-Id: I1f515910f67492257866791588f32b350fadf815
2018-05-25 17:33:42 +00:00
Stefan Sperling 5de80ca696 fix misaligned memory write access in abis_nm_ipaccess_rsl_connect()
Use memcpy() to avoid unaligned access, instead of writing through a
pointer cast to uint32_t. Problem spotted by address sanitizer:

abis_nm.c:2802:24: runtime error: store to misaligned address 0x7ffc95396706
for type 'uint32_t', which requires 4 byte alignment
0x7ffc95396706: note: pointer points here
 81 0b bb 80 00 00  00 00 ed 79 28 56 00 00  e0 9c 00 00 a0 61 00 00 ...
             ^
Related: OS#3196

Change-Id: I8e591a56ae522b371da01ea968151a7e6fa24bb9
2018-05-24 13:06:46 +00:00
Philipp Maier 02d20da183 gscon: remove dead code
The state ST_WAIT_MODE_MODIFY_ACK can never be reached by the
current FSM model.

- Remove ST_WAIT_MODE_MODIFY_ACK and all related code

Change-Id: Iacaae2ee50ca1956066b7dce4517bbc9c2b0897e
Related: OS#2762
2018-05-23 16:04:18 +00:00
Neels Hofmeyr 74e4daa695 cosmetic: logging and ordering in handle_ass_compl()
* Check the message length once at the start, before any other actions.
* Use only one local gsm48_hdr pointer.
* Read the cause value once near the top, re-use it.
* Log "ASSIGNMENT COMPLETE" always, not only during handover.
* Fully initialize local struct lchan_signal_data.

Change-Id: Idcfd932d3dfb0b621ed6d8c4f92c0231abcdcec8
2018-05-23 13:32:02 +02:00
Neels Hofmeyr 746d1ea9fe cosmetic: bsc_dyn_ts.c: make local functions static
Change-Id: Iee47b4ffefedf9532e11f17d5f9b603fc8872cb9
2018-05-23 13:32:02 +02:00
Neels Hofmeyr 8da2233426 bsc_api.c: actually log with context
bsc_api.c notoriously lacks log context. Provide gsm_lchan_name() and/or
bsc_subscr_name() in roughly a million instances, using new LOGPLCHAN macro.

Add LOGPLCHAN() to gsm_data.h, to encourage use of it in other .c files.

Change-Id: If469defcc6fe8950dac5df61db3f39d297893318
2018-05-23 07:27:39 +00:00
Pau Espin 20388b781d nat: Add jitter buffer on the uplink receiver
Default usage values are defined in mgcp node, and can be per-BSC
overriden on each bsc node.

This commit is a forward-port of openbsc.git Change-Id
Ibf3932adc07442fb5e9c7a06404853f9d0a20959.

Depends on osmo-mgw.git Change-Id Ie19a64ac09f9d51f2434ad0d7925610fc919a90e.

Change-Id: Ie07b8a577caf731d59d68e3b3510ae2f9fd3dc93
2018-05-22 09:57:42 +00:00
Stefan Sperling 7926d98509 add counter for connection attempts from BTS with unknown unit id
Add a global counter to the BSC which shows the number of failed
connections attempts due to a unit_id mismatch between the BSC
and the BTS.

Change-Id: I58866aff36a1c8463bf84b4392a5124ffeaa32ea
Related: OS#3245
2018-05-22 10:11:34 +02:00
Stefan Sperling 71d524c059 show all global counters of osmo-bsc in vty
The 'show statistics' VTY command was not showing all counters
maintained by osmo-bsc. Instead of printing just two counters
related to paging, print all available counters in a generic way.

Adjust descriptions of some counters for nicer display.

After startup (all counters are zero) is now looks like this:

OsmoBSC# show statistics
       handover:attempted:          0 Received handover attempts.
      handover:no_channel:          0 Sent no channel available responses.
         handover:timeout:          0 Timeouts of timer T3103.
       handover:completed:          0 Received handover completed.
          handover:failed:          0 Received HO FAIL messages.
         paging:attempted:          0 Paging attempts for a subscriber.
          paging:detached:          0 Paging request send failures because no responsible BTS was found.
         paging:responded:          0 Paging attempts with successful response.
OsmoBSC#

Change-Id: I58ae04e1960774d760e3ebb54a4f307c9f753655
Related: OS#3245
2018-05-18 11:38:24 +00:00
Philipp Maier 0b10399937 a_reset: cleanup + remove dead code
The function a_reset_free() is not used anywhere at the code. The
reason for this is that a BSC instance is never cleared once it
is started up. Also the timer number is not according to the spec.

- Remove a_reset_free()
- Fix timer identification number (T4)
- use fi->priv to hold context info
- Fix sourcecode formatting

Change-Id: I72095d52304c520e383755eee6c889bce492cbd4
Related: OS#3102
2018-05-17 20:13:52 +00:00
Neels Hofmeyr 5deea620dc cosmetic: dyn ts init: undup logging for gprs = none
Reshuffle the decision not to activate PDCH when GPRS is off:
Even though all current callers should avoid passing a PDCH activation in case
GPRS is off, it's a better idea to not assert on it and crash osmo-bsc.

Move the decision to omit PDCH activation and logging about it into the actual
functions that do PDCH activation. If PDCH activation is skipped, the lchan
then just stays as it was, and that's what it should anyway be doing.

Change-Id: Ib26642f08044d71a2469e6dbabf1e6fbcb02044d
2018-05-14 11:56:11 +00:00
Neels Hofmeyr d16732f693 log: indicate hr/fr in audio_support_to_gsm88() error
Change-Id: Iaaa710d0274fe813d227cb658d82a24db68c4161
2018-05-14 11:56:11 +00:00
Neels Hofmeyr 3ed1c593c6 fix default fallbacks in audio_support_to_gsm88()
For audio->hr == true, use HR1, and for hr == false use FR1; not vice versa.

Change-Id: Ifb4dba7c8e9c1d0a22a007355fbd2eda57e789d3
2018-05-14 11:56:11 +00:00
Neels Hofmeyr 78faf70fef deprecate dyn_ts_allow_tch_f and by default allow all TCH
In osmo-nitb, the way TCH lchans were assigned often resulted in mismatching
TCH kinds, causing problems in the lack of transcoding. Hence
dyn_ts_allow_tch_f was introduced as a workaround.

Now however, we always assign an SDCCH to a requesting MS first, and only later
assign a TCH channel, which then adheres to the codec list configured at 'msc'
in the vty config. Hence it is now considerably harder to obtain a mismatch.

Furthermore, forcing specific codecs is possible by simply omitting the
unwanted ones from the msc config's codec-list. The equivalent of
'dyn_ts_allow_tch_f 0' could be e.g. 'codec-list hr3 hr2 hr1'.

Change-Id: Ib2335d02ea545aff837aadd49f15b2fdb418c46e
2018-05-14 11:52:56 +00:00
Neels Hofmeyr a70084b035 debug log: verbosely log all lchan alloc choices
Change-Id: If0070b8f7b6cc7fffbc582cf9f472e60f3096000
2018-05-10 05:50:30 +02:00
Neels Hofmeyr 4281b7daa7 dyn TS: allow any pchan type changes, fix for gprs mode none
In rsl_chan_activate_lchan(), remove a condition to also allow switching pchan
modes when not in PDCH mode, which is actually not needed and would hinder
switching from pchan=NONE or between TCH/F <-> TCH/H.

Refactor the part where lchan_alloc() decides to switch a pchan mode into a
separate function, ts_usable_as_pchan(), which transparently checks both dyn TS
kinds for:

- Already in switchover? (missing check for ip.access style dyn TS)
- Is the lchan->state in error? (missing check for ip.access style dyn TS)
- Switch from pchan=NONE? (missing feature for Osmocom style dyn TS, for proper
  handling with gprs mode none)
- Switch between TCH/F <-> TCH/H when all subslots are unused?
  (missing feature for Osmocom style dyn TS, also useful for gprs mode none)

Always pass the desired pchan in the dyn_as_pchan argument to the _lc_find_*
functions to make switchover decisions transparent. Use the _lc_dyn_find_bts()
function for ip.access style dyn TS for the same reason.

Related: OS#3244
Change-Id: I72d5d833b186b1e1925d513885b405d8c19aa496
2018-05-10 04:53:53 +02:00
Neels Hofmeyr 91aa68f762 dyn TS: init only when both RSL and the Channel OM are established
Recent Icf6e25ff068e8a2600562d52726ead65e864ec02 changed the dyn_ts_init() hook
from bootstrap_rsl() to the Channel OPSTART ACK, but this is not sufficient.
Now RBS2k never calls dyn_ts_init(), and we may need to wait for RSL:

Dyn TS should actually be initialized only when *both* OML opstart and RSL link
are established. To that end, introduce a generalized API to query OML and RSL
status and to trigger a timeslot init at the appropriate time.

Add gsm_ts_check_init() to be called both when RSL and OML opstart are
established: trigger gsm_ts_init() only when both are given.

Add gsm_bts_trx_ts->initialized flag to mark whether initialization has already
taken place. Add gsm_bts_mark_all_ts_uninitialized() to conveniently clear this
flag for all TS in a BTS.

Add gsm_bts_model.oml_is_ts_ready() callback so that each BTS implementation
can return the OML status of a timeslot in its own OML implementation.
Actually, currently all BTS models that need this init mechanism store the TS'
OML status in ts->mo.nm_state. While we would in practice correctly init dyn TS
by just looking at ts->mo.nm_state, semantically, the decision whether the TS
is ready is up to the BTS models' specific OML implementations.

From bootstrap_rsl(), call gsm_ts_check_init(), in case the TS OML Opstart has
happened before RSL is established -- applies to all BTS models.

For all BTS models:
- call gsm_{bts,trx}_mark_all_ts_uninitialized() when OM is torn down, to make
  sure the TS init mechanism will work a second time.

For all BTS models supporting dyn TS, i.e. osmo-bts, nanobts and RBS2k:
- implement oml_is_ts_ready().
- call gsm_ts_check_init() when a Channel OM is taken into operation.

Any BTS models that don't set oml_is_ts_ready() will see a ts init as soon as
RSL is bootstrapped (incidentally, the old dyn TS behavior before recent
Icf6e25ff068e8a2600562d52726ead65e864ec02).

This firstly fixes dyn TS for RBS2k by re-adding the initial switch to PDCH,
and furthermore does so only after both OML TS opstart and RSL are through.

This fixes the ttcn3-bsc-tests around dyn TS, since for the osmo-bts-virtual,
the RSL is established only after OML opstart on the TS, which was broken by
Icf6e25ff068e8a2600562d52726ead65e864ec02.

Nokia Site and Siemens BS11 practically do not require this init mechanism,
since all that happens there so far is dyn TS init, and these BTS models do not
support dyn TS of any kind. A future patch may add oml_is_ts_ready().

Related: OS#3205
Change-Id: I99f29d2ba079f6f4b77f0af12d9784588d2f56b3
2018-05-10 04:53:53 +02:00
Vadim Yanitskiy 83e3280ebe osmo_bsc_vty.c: fix: write MGW configuration
Previously the MGW configuration was ignored during writing
of the MSC configuration. Let's fix this by calling the
mgcp_client_config_write() function.

Change-Id: I7d1eedb782a4f30bd089838969ce54f27cde060d
2018-05-08 13:00:22 +00:00
Neels Hofmeyr 968c142327 dyn TS, assignment: allow switch from PDCH with associated conn
Typically, an lchan that is released should no longer be associated with
subscriber connection. If that is the case, an S_LCHAN_UNEXPECTED_RELEASE is
triggered, which aborts, e.g., an ongoing assignment.

However, with dynamic timeslots, we may set lchan->conn and then start to
switch over from PDCH to a TCH mode, in which case it is perfectly fine to
release an lchan that is associated to a conn.

In lchan_free(), do not fire S_LCHAN_UNEXPECTED_RELEASE for a dyn TS that is
currently in switchover.

This is the second and last part to fix dynamic timeslots handling of the
gscon.

Related: OS#3211
Change-Id: Id7d9dd06451722eb328db77bb586826c954bd85c
2018-05-05 01:50:49 +02:00
Neels Hofmeyr a82c0b1c42 dyn TS, assignment: set lchan state to LCHAN_S_ACT_REQ in the proper place
Set lchan->state to LCHAN_S_ACT_REQ in rsl_chan_activate_lchan(), not in
handle_new_assignment().

This is the first part of a fix for dynamic timeslots handling in the gscon.

Rationale:

In rsl_chan_activate_lchan(), we may choose to set the lchan state to
LCHAN_S_REL_REQ and wait for dyn TS switchover from PDCH.

So the caller from bsc_api.c handle_new_assignment() must not bluntly set the
state to LCHAN_S_ACT_REQ, which is not accurate in the case of dyn TS
switchover.

In case of dyn TS switchover, a later release ack received from the BTS will
cause rsl_chan_activate_lchan() to be called again, at which point we may
accurately set state LCHAN_S_ACT_REQ, and continue the Assignment.

Related: OS#3211
Change-Id: Iedb4fb63bf1959d5f1d2c6edb6a7f5097ff16bd7
2018-05-05 01:50:49 +02:00
Neels Hofmeyr bf7099262a dyn ts, bts_ipaccess_nanobts.c: init PDCH on Chan OPSTART ACK
Sending PDCH activation upon RSL bootstrap is too early. Introduce OPSTART ACK
handling to call dyn_ts_init() only when the dynamic timeslot is indeed ready
to receive a PDCH activation.

Related: OS#3205
Change-Id: Icf6e25ff068e8a2600562d52726ead65e864ec02
2018-05-05 01:50:49 +02:00
Neels Hofmeyr f28f1ef9af resurrect meas_feed.c: vty, vty-test
At this point, meas-feed is usable again, however, osmo-bsc is not able to
include the IMSI in every report like osmo-nitb did.

In consequence, the meas-vis and meas-web tools are unable to handle the
current measurement reports: these so far use the IMSI to list reports, and all
reports without an IMSI are collapsed onto the same line, swapping values.

So though osmo-bsc now sends usable measurement reports via meas-feed, two
avenues to improve should be pursued:

OS#3192: the visualization tools should use bts,ts,ss numbers, not IMSI.
OS#2969: osmo-bsc should always know a mobile identity.

Related: OS#2968
Change-Id: I186c7a995dd2b81746c32a58b55da64ed195a1ce
2018-05-04 15:02:24 +00:00
Philipp Maier ad7277073c bsc_api/GSCON: prevent unnecessary channel mode modifications
gsm0808_assign_req() checks if the new channel mode is compatible
with the new mode. If it is, it does a gsm48_lchan_modify(), but
it does not actually check if the new mode is equal to the current
mode.

- skip when the channel is compatible and the new mode is equal to
  the old mode.

- send the ASSIGNMENT COMPLETE directly from ST_ACTIVE when no
  mode modify was necessary.

Change-Id: I86a2d52836c54d2dbd77441b182f757327ec7262
Related: OS#2936
2018-05-04 09:25:40 +00:00
Neels Hofmeyr 42ab17bdff resurrect meas_feed.c: make it compile, add logging
Change-Id: I34ac25bcc460e87e813090b6d7c5085cffa2d78f
2018-05-03 15:26:32 +02:00
Neels Hofmeyr 79176bf50b resurrect meas_feed.c from openbsc.git history
meas_feed.c used to live in libmsc, to send out measurement reports to external
entities for evaluation. When splitting osmo-bsc and osmo-msc from openbsc.git,
meas_feed.c should have moved to osmo-bsc.git, but was dropped with libmsc.

Re-add the old meas_feed.c now into libbsc. This is the latest version that
existed in libmsc, and will not compile as-is here. Modifications to
incorporate in the osmo-bsc build will follow with subsequent patches.

Change-Id: Ic070d82e61c122061fe7297a8c5aabbbcef6b301
2018-05-03 15:26:32 +02:00
Stefan Sperling 7b70926ff9 flush paging when RSL link is dropped
Flush the paging queue if the link to TRX 0 is dropped from a BTS.
This should prevent stale paging requests sent to the BTS when it
disconnects or reconnects, as seen in the TTCN3 BSC_Tests test suite.

Also, add entries to the log when RSL or OML links are dropped so
that related error messages in the log can be interpreted in context.

Change-Id: If4401c1139cd01faf5ff374301a9a701898c3777
Related: OS#2901
2018-04-24 16:19:19 +00:00
Stefan Sperling 0eb9169567 extend documentation of paging_flush_bts()
Document the semantics of a NULL msc argument.

Change-Id: Ib3f6fd4e4e6108f03d688eba2416c0714393e6e9
Related: OS#2901
2018-04-24 14:26:11 +00:00
Pau Espin be32b4c80b abis_rsl.c: Clean ericsson specific imm assign code
Move to its own function, store pointer to proper header format and use
the already defined IE define from libosmocore instead of using
hardcoded values.

Depends on: Change-Id I7cb65f3ff1cfdbe4eee97b7545bcd13a38c72e25

Change-Id: I845fd3f0c6ff31f268f68a31e1d55981f7ec6129
2018-04-23 11:59:01 +02:00
Pau Espin 286212c8de abis_rsl.c: abis_rsl_rx_cchan: Print msg type name for unimplemented messages received
Change-Id: I2e2e40bcb9365420f7e79d8d954505b0d2376bed
2018-04-23 11:58:31 +02:00
Stefan Sperling c04d40477a properly skip paging is OML link is down
If the OML link is found down while a paging request is issued,
no paging message is sent. However, we were still counting such
pagings as an actual attempt, and counted them towards the number
of available slots on the paging request queue.

Move the OML link check to the caller of page_ms() where the
accounting steps can be properly skipped as they should be.

Change-Id: I5b6db681da7d45c49e1f2f99d7789c8a29372ef3
Related: OS#2901
2018-04-19 15:49:50 +00:00
Pau Espin fa422556ad chan_alloc.c: Fix log var formatting issues
Change-Id: I7a5e5d26f250f954853c12cfd4de08fed68c178e
2018-04-19 14:31:17 +02:00
Philipp Maier 1f4851e703 gscon: fix assignment of signalling channels
On the assignmen of signalling channels, the voice related fields
do not play a role. However the function send_ass_compl() that
generates the assignment complete message is very strict about the
presence of those voice related parameters.

- Add a parameter to function send_ass_compl() to generate the
  different types of assignment complete messages

Change-Id: I316ebcb1f27b668e17fe48fff028e047aac47f76
Related: OS#2762
2018-04-17 13:16:43 +02:00
Keith Whyte d925c7c00f Cosmetic: Fix typo: Siganlling->Signalling
Change-Id: I92b39eebfba396ee7690e99de09ee20593b7139d
2018-04-16 16:19:19 +00:00
Pau Espin fe49bf0c14 bsc_nat: ctrl: Fix crash on receveing bsc reply
Since libosmocore 7c0031fc8063771e604976233fb7b46d2b85c077, the cmd
param passed to handlers in ctrl_handle_msg is always freed afterwards,
thus it is owned by the same function. Avoid keeping it alive and
accessing it later when it has already been freed.

Related: OS#3157

Change-Id: I764917f641b170597e405f1865b0f7b94bae1597
2018-04-16 13:28:34 +02:00
Philipp Maier 3ddb12d52e inform A-RESET FSM about MSC CR timeouts
The SUBSCR_CONN (GSCON) fsm starts a timer (993210, 20sec.) when the
CR to the MSC is made. When the timer reaches its timeout, then the
SUBSC_CONN FSM terminates. Such a timeout event is also an indicator
for a bad SCCP connection so we should call a_reset_conn_fail() to
inform the A-RESET FSM about the event in order to cause a BSSMAP
reset when too many timeouts occurr consecutively

- Call a_reset_conn_fail() when 993210 expires

Change-Id: I836a552f2ad37c160081246579f842d104d0dd35
Related: OS#3102
2018-04-14 19:01:57 +00:00
Stefan Sperling cda994edb2 fix handling of state changes in acc ramping
Take both the operative and administrative states into account
when deciding whether to start ACC ramping, and examine old/new
state values to avoid triggering ramping for a no-op state change.

This requires a fix to gsm_trx_lock_rf(): This function overwrote
the old administrative state of a trx before enqueuing a state
change request towards the BTS.
The BTS will confirm this request with an ACK, at which time a
signal is generated which the ACC ramp code listens to. We must
not overwrite the old state value until the signal has been handled,
otherwise the signal handler cannot tell what the old state was.

Tested with a virtphy setup, nanobts, and osmo-bts.

Change-Id: Ib3291439655598fb5ddc891a3e4cc35b0bad250f
Related: OS#2591
2018-04-13 14:42:57 +02:00
Stefan Sperling 4d3d2436cd only trigger acc ramping if trx 0 is usable and unlocked
Starting an ACC ramping process while TRX 0 is unusable or locked is
pointless. For instance, after loading a config with 'rf_locked 1'
for trx 0, the ramping process was started as soon as the BTS
established RSL, even though the air interface was still down.
ACC ramping should instead be triggered once TRX 0 is unlocked.

Change-Id: I054829a936f0aa1e3fa34fad6466a1cd6150e307
Related: OS#2591
2018-04-12 12:51:51 +00:00
Stefan Sperling b06c7a2537 trigger acc ramping on state-changed-event reports
Trigger ACC ramping not only when an Administrative State Change
ACK is received from a BTS, but also when an administrative state
change is reported for TRX 0 in a State Changed Event Report.

This should allow ACC ramping to work with any BTS which reports
an administrative state change to 'unlock' using either of these
OML messages.

Tested with a sysmobts and a nanobts.

The sysmobts only reports TRX locked/unlock changes in Administrative
State Change ACKs, not via State Changed Event Reports.

The nanobts is known to send both of these OML messages in quick
succession, so do not re-trigger ramping if it's already in progress.

Change-Id: I097a113a3a63de02bcb8277020beb59cf485b176
Related: OS#2591
2018-04-12 09:38:59 +02:00
Stefan Sperling 0ad90b39b9 rename helper functions in the acc ramp code to avoid confusion
The word 'enabled' was used in two contexts: Whether ACC ramp is
enabled as a feature, and whether a particular access control class
is permantly allowed/disallowed via VTY configuration.

Rename some helper functions to avoid the use of the word 'enabled'
in the latter context.

Change-Id: Ia67e84270cd50f4c55b8cf616ca38b00482f765c
Related: OS#2591
2018-04-11 21:02:17 +02:00
Stefan Sperling 60ecdeffec trigger acc ramping based on trx rf-locked state
Make ACC ramping listen to network management signals and trigger
or abort ACC ramping based on the RF locked state of TRX 0.

This works as expected with a virtphy setup when RF lock state is
changed via VTY. However, this change still needs to be tested with
a nanobts. It's also not quite clear yet whether operational state
changes, as opposed to administrative ones, should be taken into
account as well.

Change-Id: I4124f1da3dadec003de45c1da8435506ee8f0a34
Depends: Ia25bff85d9e5c277da76bffa11d31972e9fdc323
2018-04-11 16:53:05 +00:00
Stefan Sperling ea33341cf7 ensure that acc_ramp_init() is only called once
There are plans to register signal handlers in acc_ramp_init(). Once we
do that, the acc_ramp_init() function should only be called once to
avoid duplicate signal handlers on the handler list.

However, the acc_ramp_init() function currently serves a dual-purpose:

 1) Initialize the acc_ramp structure for a bts
 2) Enable or disable ACC ramping

Add new functions to support use case 2, and call acc_ramp_init()
just once while reading the configuration file. The VTY commands
which enable/disable ACC ramping use the new APIs instead.

Also, rename acc_ramp_start() to acc_ramp_trigger() and tweak its
semantics so that it can always be called regardless of what the
current configuration settings are. This prepares us for triggering
ACC ramping upon events other than "RSL link-up".

Change-Id: Ia25bff85d9e5c277da76bffa11d31972e9fdc323
Related: OS2591
2018-04-11 16:53:05 +00:00
Pau Espin 881836a770 bsc_nat: Drop redundant ccon ptr in bsc_cmd_list
It can be obtained from cmd field, so no need to store it in pending.
This way we simplify the ad-hoc struct bsc_cmd_list.

Change-Id: I6de64fc128ad623ca30b9e6cebebaff8de18f95d
2018-04-11 16:52:49 +00:00
Pau Espin df7a975076 bsc_nat: forward_to_bsc: Fix memleak on send failure
Change-Id: I56235eb05e4beed1bf9151319b64d67de4718e36
2018-04-11 16:52:49 +00:00
Pau Espin 56e564dbd0 bsc_nat: forward_to_bsc: remove one level of indentation
Change-Id: I12d86a45a6b2cdc3af7a7b6c28f8f337fa95c903
2018-04-11 16:52:49 +00:00
Pau Espin 637e6da34a bsc_nat: ctrl: fix memleak on reply receival
Change-Id: I163d4d12d8656628dc88ff3e59a4c3e53b760a0c
2018-04-11 16:52:49 +00:00
Pau Espin 8ae73375b8 libbsc: set_net_mcc_mnc_apply: Fix memleak on parsing incorrect mcc mnc
Change-Id: I43513e108dfba24efb091d56b3fdfdb0cd0af727
2018-04-11 16:52:49 +00:00
Stefan Sperling 53d40e078e only log actual access control class ramping changes
Silence log messages about no-op changes to access granted to access
control classes. For example, these always occur while configuration
files are being loaded.

Change-Id: I37580f4058f6e3a21d338234b1e22ea46f9538c6
Related: OS#2591
2018-04-10 16:25:26 +02:00
Stefan Sperling c0587d0da2 fix initialization of acc ramping
Remove a redundant call to acc_ramp_init() during bootstrap_bts().
ACC ramping state is already initialized during VTY config parsing,
and bootstrap_bts() accidentally disabled ACC ramping again even
if it was enabled in the configuration.

This bug was introduced in last-minute refactoring during
review of https://gerrit.osmocom.org/#/c/6324/ when the
acc_ramping_enabled flag was moved from struct gsm_bts to
the acc_ramp structure itself.

Also remove an acc_ramp_init() call in bootstrap_rsl().
It is no longer needed as it serves no purpose other than
initializing the bitmasks of barred ACCs. To ensure that
ACC ramping configuration provided to the BTS via system
information stays correct, we move the call to acc_ramp_start(),
which has the same effect on barred ACCs, further up.

Change-Id: Ib7d99c9d3d5d424e21bb7710f719c42f9aef3e95
Fixes: 6442e4327b
Related: OS#2591
2018-04-09 17:38:56 +00:00
Stefan Sperling 5b6aa650f1 fix a format string error in bts_update_t3122_chan_load()
In a debug log message, an unsigned 64-bit value was printed with
%lu but it should be printed with PRIu64 from inttypes.h instead.

Change-Id: I09bb519e68886e650647b1369fd49d1964e76c7e
2018-04-09 15:04:24 +02:00
Harald Welte 0383a09131 "show timeslot": Show dynamic PDCH state also for Osmocom-style dyn PDCH
So far we only used to show the current mode of the timeslot for IPA
style dynamic PDCH, but not for osmocom-style.

Old output for osmocom-style dyn PDCH:

BTS 0, TRX 0, Timeslot 6, phys cfg TCH/F_TCH/H_PDCH, TSC 7
  NM State: Oper 'Enabled', Admin 'Unlocked', Avail 'OK'

new output with this patch:

BTS 0, TRX 0, Timeslot 6, phys cfg TCH/F_TCH/H_PDCH, TSC 7 (PDCH mode)
  NM State: Oper 'Enabled', Admin 'Unlocked', Avail 'OK'

where "PDCH mode" changes from "NONE mode" to "TCH/F mode" to "TCH/H mode"
depending on the current state.

Change-Id: If5044d6bec76b869bd6a7c0260a4c77e229dcd0d
Related: OS#3099
2018-04-07 19:02:33 +02:00
Harald Welte 0a405f13fc Start Dynamic PDCH Initialization after RSL is up
We used to start the dynamic PDCH initialization right after the
respective OML initialization of the related timeslot.  However, this
is problematic as the RSL link may very well not even be up yet at
that point.  So let's do this at RSL link esetablishment time, not
from OML.

Change-Id: I8ac30ca075a1db4b624dc38a423d844d705fda7e
Closes: OS#1841
2018-04-07 11:35:12 +02:00
Stefan Sperling 44311ea6e9 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.

This was already committed in faf0982ae2
but subsequently reverted in 383a059a12
because it introduced a regression. The underlying problem causing this
regression has now been addressed by https://gerrit.osmocom.org/#/c/7462/
(libosmo-abis commit 49917c129b1456585258b0ebe89a513ecef823a8).

Change-Id: I78a152671a00b95c997830f7161fca92bb898fa3
Depends: I52f7c903212b38e9c87e4d45e52b231b6f1ae9f5
Related: OS#2719
2018-04-07 09:01:05 +00:00
Neels Hofmeyr 03ddccc132 vty: re-add 'timeout-ping' and 'timeout-pong' as dummy commands
Legacy VTY commands were removed in commit
c74a5616bf
== I5cf3fec31cc774c902f3cfe6d16fb85ef301694a

Removing the dead VTY commands currently breaks our ttcn3-bts-test and is
likely to create problems with users of osmo-bsc, when their config osmo-bsc
stops working with a mere upgrade.

Instead, add deprecated dummy commands that don't do anything, to not break
existing configs.

Catch all of these legacy commands:
 timeout-ping <number>
 timeout-pong <number>
 timeout-ping advanced
 no timeout-ping
 no timeout-ping advanced
by defining
 timeout-ping ARG
 timeout-pong ARG
 no timeout-ping [ARG]

I verified manually that starting osmo-bsc with all the abovementioned VTY
commands in the config file works (and produces the deprecation messages).

Change-Id: I95a5bad1ade66ded849cfc20bebb7fc522aecc38
2018-04-05 01:04:18 +02:00
Philipp Maier dd185d60b1 cosmetic: Add fixme note for OS#3112
Change-Id: I0c3ffb567aff08014f8fb96928077afb8c2f229c
2018-04-02 19:33:11 +00:00
Philipp Maier c74a5616bf cosmetic: remove dead code
There is a lot of dead code in osmo_bsc_msc.c that used to handle
the IPA multiplexed SSCP lite A interface.

- remove portions of the dead code
- remove IPA Ping related VTY commands

Change-Id: I5cf3fec31cc774c902f3cfe6d16fb85ef301694a
2018-04-02 19:33:11 +00:00
Neels Hofmeyr e34161832d ctx cleanup: use non-NULL talloc ctx for osmo_init_logging2()
Fix various sanitizer complaints about memory leaks using a sanitizer build
with gcc (Debian 7.3.0-12) 7.3.0.

Also fix deprecation warnings on osmo_init_logging().

Depends: I216837780e9405fdaec8059c63d10699c695b360 (libosmocore)
Change-Id: I970c6f8a0e36a8b63e42349dbc92baff649e5cef
2018-03-28 19:24:34 +02:00
Neels Hofmeyr 8206f20f89 move init from gsm_bts_alloc_register() to gsm_bts_alloc(); fix gsm0408_test
gsm_bts_alloc() ought to do all static initialization, so that e.g. unit tests
can use an initialized bts struct that is fully usable, just not registered at
the gsm_network.

For example, two INIT_LLIST_HEAD() and various system information data pointers
(pointing to proper places within the same bts struct) should definitely never
be omitted.

This fixes the remaining errors of gsm0408_test's SI tests, as revealed by a
sanitizer build using gcc (Debian 7.3.0-12) 7.3.0.

Fixes:

  ../../../../src/osmo-bsc/src/libbsc/system_information.c:613:3: runtime error: null pointer passed as argument 1, which is declared to never be null

Initializing the bts->si_common.rach_control results in different expected
bytes for SI2. The initialized values are

  bts->si_common.rach_control.re = 1; /* no re-establishment */
  bts->si_common.rach_control.tx_integer = 9;  /* 12 slots spread - 217/115 slots delay */
  bts->si_common.rach_control.max_trans = 3; /* 7 retransmissions */
  bts->si_common.rach_control.t2 = 4; /* no emergency calls */

Causing a change to e5 04. 04 is t2 = 4, and the remaining values are verified by:

  uint8_t re :1,
           cell_bar :1,
           tx_integer :4,
           max_trans :2;

  >>> hex(1 + (9 << 2) + (3 << 6))
  '0xe5'

Change-Id: I13ef24bbe0f1fbe49465e67a0b67d6fd69fff3b1
2018-03-28 18:59:48 +02:00
Neels Hofmeyr cf4a5735e6 range_enc_arfcns: avoid runtime error on zero size
If size <= 1, avoid allocating arfcns_left[size / 2], which results in a zero
size and causes, with gcc 7.3.0 sanitizer, runtime errors:

../../../../src/osmo-bsc/src/libbsc/arfcn_range_encode.c:95:6: runtime error: variable length array bound evaluates to non-positive value 0
../../../../src/osmo-bsc/src/libbsc/arfcn_range_encode.c:96:6: runtime error: variable length array bound evaluates to non-positive value 0

This fixes some of the errors of gsm0408_test, as revealed by a sanitizer build
using gcc (Debian 7.3.0-12) 7.3.0.

Change-Id: Idab2a194fb9d7c41ed3367f935080eaae4ce367f
2018-03-28 18:59:04 +02:00
Stefan Sperling a8eafef966 change return type of page_subscriber() to void
We deliberately ignore errors from page_subscriber() so there is
no point in having a non-void return value.
Provide more context in the error message logged if paging failed.

Add a comment in an implementation override of base_grace_paging_request()
in the test suite to make return value semantics more clear.

Change-Id: Ie18c2ba53d2055d3eaff8c9ed939eb844af6dd2e
Related: I48f5efbcddd98e15256edfca06ba0ae6acb5bab1
2018-03-27 12:25:19 +00:00
Philipp Maier ecb0308e74 gscon: fix illegal state transitions
The GSCON fsm has two illegal state transions. The transions
themselves are logically legal but theur respective entries
in out_state_mask are missing.

- remove unnecessary transition from ST_ACTIVE to ST_ACTIVE
- Add ST_CLEARING to the out_state_mask of ST_WAIT_HO_COMPL

Change-Id: I165c3e8b4b268b50e5f4a482b0fe890e940637b3
Closes: OS#3109
2018-03-27 11:31:47 +00:00
Pau Espin bc893d3e14 bssap: Log non handled paging requests
Return code in bssap_test is changed to ack it was sent and prevent the
log from being printed.

Change-Id: Ie8075d076cc34570fefce3beb577567707a29d4e
2018-03-26 18:51:05 +02:00
Pau Espin a9e4268a0a paging: paging_request_bts: Fix wrong return value
Change-Id: I48f5efbcddd98e15256edfca06ba0ae6acb5bab1
2018-03-26 18:33:35 +02:00
Pau Espin cf48c54e47 bsc_vty: Fix uninitialized var false positive on gcc 7.3.1
Change-Id: If2b315d76081f7ef5f2faf07c502f20196ba6a09
2018-03-26 18:20:34 +02:00
Pau Espin 39fb1fb916 libbsc: nokia_site: Fix uninitialized return val
Fixes following compilation warning:
bts_nokia_site.c:1248:9: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  return ret;

This could happen if parameter len is passed with value 0.
If we reach the end of the function, it means everything went fine, so
we can return 0 instead of using ret, which is only used to store error
code before returning.

Change-Id: Ic60c8c632a6ddadb8f197d56cc68c2dbfc121d05
2018-03-26 18:10:15 +02:00
Philipp Maier 63d619edef cosmetic: remove dead code: osmo_bsc_reset.c
Change-Id: I22f92541982489a0948bd1dedc008439981fb33e
Related: OS#3102
2018-03-23 15:24:06 +00:00
Philipp Maier 200f5b9921 bs11: make bs11_config build again
The BS-11 related tool bs11_config is currently not built due
to dependancy issues added by GSCON FSM.

- Re-Add bs11_config to makefile.am
- Add dependencies and stubs

Change-Id: I77ee8d2d36813ad98542317d003a9057c4f84e75
Related: OS#2823
2018-03-22 19:05:57 +00:00
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