Commit Graph

143 Commits

Author SHA1 Message Date
Vadim Yanitskiy bb04495251 oml: use regular TLVP_PRES() in rx_oml_ipa_rsl_connect()
Both NM_ATT_IPACC_DST_IP and NM_ATT_IPACC_DST_IP_PORT are defined
as TLV_TYPE_FIXED, and NM_ATT_IPACC_STREAM_ID is TLV_TYPE_TV, so
the TLV parser already does check the length for us.

Change-Id: I1e493e552bb22bb42bb196ce71214e28d23fd19e
2021-02-07 03:40:32 +00:00
Vadim Yanitskiy 187effa00d oml: make 'struct tlv_parsed' pointer const where possible
Change-Id: I077f5aba50cc4d1a86feff527784de07394c5c0a
2021-02-07 03:39:53 +00:00
Vadim Yanitskiy fe45b4eb1f oml: avoid redundant ntohl() / htonl() conversion
Change-Id: I2ae84dcd2987ff0cee5ca06ced06e65a30847a81
2021-02-07 03:39:53 +00:00
Vadim Yanitskiy f7afeb1fa9 oml: cosmetic code style changes in rx_oml_ipa_rsl_connect()
Change-Id: I2841e15865596bbb24cfe1f27691404514d3b6f0
2021-02-06 15:14:05 +01:00
Pau Espin 4d7c6ad860 oml: Set NM_OPSTATE_DISABLED by default
Otherwise, some objects are announced at startup of osmo-bts towards BSC
during State Changed Report as being "NULL".

According to TS 12.21:
"NULL(Operat. state not supported) FF"

Which doesn't make much sense in startup situation. They are in known
state Disabled until they are OPSTARTed.

Change-Id: I5ba6756ea069d0f995f453ee4b27e6839c914eb1
2020-10-21 18:32:08 +02:00
Pau Espin ca5d1e6ba6 Drop unused param in oml_init()
Change-Id: I96d8359f4ae13c9f47cc87d87fde6d2047169a49
2020-10-13 08:54:36 +00:00
Vadim Yanitskiy 74750fe2b0 oml: fix handling of NSVC local port in oml_ipa_mo_set_attr_nsvc()
This is another regresion introduced by [1].  Both local and remote
port numbers recived in the network order, and must be stored as-is.

Change-Id: I3c21a2c27dcbf6de728ce2c7ccbae9e2f517c450
Fixes: I310699fabbfec4255f0474f31717f215c1201eca
Related: SYS#4915
2020-10-08 20:50:07 +00:00
Alexander Couzens 9096461507 OML: correct parse the NM_ATT_OSMO_NS_LINK_CFG field address_family
The address_family is 8 bit and have a padding byte afterwards.
By using osmo_load16be it's encoding it wrong and result in an
empty/invalid NSVC configuration.

Change-Id: Ie070b5745124d48e74a6dedd8903b74bfb3ce9d2
2020-10-08 00:33:33 +02:00
Alexander Couzens 650a0c31a7 Introduce the new OML NM_ATT_OSMO_NS_LINK_CFG to configure IPv6 NSVC for PCU
With PCU interface version 10 it supports IPv6 NSVC. The new OML IE
NM_ATT_OSMO_NS_LINK_CFG allows to configure IPv6 NSVC.

Change-Id: I310699fabbfec4255f0474f31717f215c1201eca
2020-10-06 11:36:45 +00:00
Harald Welte 90e0c205b5 bts: Add VTY command to manually override Radio Link Timeout
There are some situations where it is useful to be able to change the
Radio Link Timeout at runtime, without restarting the BTS.

This adds a new (hidden) command for this:
	"bts <0-255> radio-link-timeout (oml|infinite|<4-64>)"

Change-Id: I64674a432cf7751b16d5d0b52f66766fa6e37028
2020-10-05 18:23:06 +02:00
Vadim Yanitskiy 0cd8df2184 gsm_data: rename hopping.{ma,ma_len} to hopping.arfcn_{list,num}
MA (Mobile Allocation) is actually a bit-mask indicating those ARFCNs
of the Cell Allocation, which must be used as the hopping sequence.

What we store in struct gsm_bts_trx_ts is the actual list of hopping
channels, so let's name it properly and eliminate possible confusion.

Change-Id: I677d66e428fa0fe119ebc37bc2a4e6cc05c251c4
2020-09-17 15:45:48 +00:00
Vadim Yanitskiy 4d61c67392 oml: fix ARFCN range check in oml_rx_set_bts_attr()
Change-Id: I52c15de3c59cd654207599ae410a4c1fed48ee58
2020-08-04 14:28:56 +00:00
Vadim Yanitskiy 48ff5313cd oml: fix ARFCN range check in oml_rx_set_radio_attr()
Change-Id: I11c8203dfe26175632974e5c6859eeaea962e878
2020-08-04 14:28:56 +00:00
Pau Espin 912ff0d759 common: Avoid call to bts_model_chg_adm_state() if there's no ADM state change
Let's handle it in common code to simplify and avoid duplication in
model specific code.

Change-Id: Icea3ea1108d360193cac478f366be97ff38246d4
2020-07-27 12:19:22 +02:00
Pau Espin 23fd316dea Move nm_state and Mo related code gsm_data.* => oml.*
Change-Id: I57ea9c4ddbe5443b9b6afe3f8e6b38170d0e5a0e
2020-07-05 18:17:46 +02:00
Pau Espin 8ca8a26ce9 gsm_data.h: Use enum type for NM state fields
Change-Id: I21fa1688a0c8a3788a5ecedd5912f596a69a1beb
2020-07-05 18:16:08 +02:00
Vadim Yanitskiy 842e4fab44 A-bis/OML: handle hopping params in Set Channel Attributes
Change-Id: Ieac26c7aca118c16889cdde2565a514681dc137b
Related: OS#4546
2020-06-29 08:51:11 +00:00
Vadim Yanitskiy c3fdee43dd A-bis/OML: fix logging: do not print A-bis MO name twice
LOGPFOH() itself prepends A-bis MO name to the logging message.

Change-Id: I513efeb441a69e9eee1ad7bbd8cb0b552b7195eb
2020-06-15 22:51:24 +07:00
Vadim Yanitskiy ba0e5c7d50 gsm_data_shared: use bitvec API to allocate the feature vector
Change-Id: I19ecfc619c0dc2bfd14f054d17e222c4e16f6238
2020-06-11 00:35:51 +07:00
Vadim Yanitskiy 46aa972411 oml: fix TL16V length calculation in add_bts_feat()
An additional octet is only needed if total number of features
cannot be devided by 8 without the remainder. Fix this.

Change-Id: Ie501e5a635493830e0597f7b2fa287b6448e660d
2020-06-10 23:21:28 +07:00
Pau Espin 66564ed696 oml.c: Log ADM STATE change locked/unlocked
Use same forma tuse for other OMl states, like OPER and AVAIL states.

Change-Id: Icb176e2215841509bf15a6dfc163ceddcb602954
2020-06-09 08:46:32 +00:00
Pau Espin 5969988754 oml.c: Fix whitespace in log line
Change-Id: I5e9b07303dda374e9196d7d4503ad652970ab6c5
2020-06-09 07:37:37 +00:00
Vadim Yanitskiy 7726eaa477 oml: fix oml_mo_tx_sw_act_rep(): do not allocate FOM header twice
This redundant call to msgb_put() appends five '00'O octets to the
"Software Activated Report" message, so they look like an unknown
attribute(s). I accidentally noticed this in Wireshark.

Change-Id: I7377575135f4a154572891d1b5b39ff814b97f38
2020-05-16 19:22:19 +07:00
Vadim Yanitskiy e5711efbb5 common/abis.c: make use of RSL TEI from OML IPA RSL Connect
Change-Id: I5927f59a49724170a63e87be604973f7c9d5d8be
2020-01-11 00:51:43 +01:00
Eric Wild 5b9212d6c5 revert changes to T200
The timers are unfortunately completely broken, so let's go back to the
long default timeout values from 1ff0a2addd

See related issues OS#4066 and OS#4074



Change-Id: Ia44310245a348675dbbf3ffc3dc5b6d207fd62d3
2019-06-21 17:00:04 +00:00
Harald Welte 46d62b984a lapdm: Use new libosmocore API to ensure per-channel-type N200 values
By using new libosmocore LAPDm API we can specify the GSM channel type
and hence enable the LAPDm code to use a per-channel-type specific N200
value.

At the same time, this new API also allows us to specify T200 values
when initializing the LAPDm channel, so we don't have to fiddle with
low-level lapdm data structures in what used to be oml_set_lchan_t200().

Change-Id: I0e814fbae13e0feddd148c47255dcc38cb718f48
Depends: libosmocore I90fdc4dd4720d4e02213197c894eb0a55a39158c
Closes: OS#4037
2019-06-13 15:38:01 +00:00
Harald Welte 1ff0a2addd Update T200 timer default values
The default values of 1s were *very* long, particularly for fast
channels such as FACCH.  Let's use much more aggressive values
that are more in-line with various recommendations that cold be
found online, such as
https://pcstelconext.wordpress.com/2011/05/02/2g-timer-explanations/
https://www.erlang.com/forum/erlang/thread.htx?thread=2844
https://www.erlang.com/forum/erlang/thread.htx?thread=7180
https://de.slideshare.net/BisiAdebambo/138078380-gsmtimers-59637131

Change-Id: Ic1268ae2d769b12da6cdd4ac8375e4bc033a9e3e
2019-06-13 15:38:01 +00:00
Harald Welte 8ea9ba6af8 [correctly] use the LAPDm T200 values received via OML
As per GSM TS 12.21, the LAPDm timers (T200) of the LAPDm instances
in the BTS are configured via OML from the BSC.  While OsmoBSC
is sending them and OsmoBTS is parsing them, OsmoBTS stopped to
make use of them from commit 3ca59512d2
(January 2016) onwards.

The cause for this has been documented and discovered in May 2017
in https://osmocom.org/issues/2294 and it is quite obvious:  LAPDm
timers are supposed to start when a given frame is actually transmitted
on the radio interface.  PH-RTS.ind and PH-DATA.req are suppsed to be
used over a synchronous interface in some deeply embedded processor.

With OsmoBTS however, we have an asynchronous L1/L2 interface between
a DSP (osmo-bts-{sysmo,lc15,oc2g,octphy}) or OsmoTRX (osmo-bts-trx)
and we receive PH-RTS.ind quite some time ahead.  So if we start T200
at that point, then it will start running way before it has been sent
or before the MS has had a chance to receive the message.

The "correct" way to handle this is to actually measure the difference
between frame numbers in PH-RTS.ind (uplink, advanced) and PH-DATA.ind
(downlink) or PH-TIME.ind, and then add that amount to the actual
timeout value.  This ensures that the timers will time-out the
user-specified amount of time after the actual transmit.

Change-Id: If8babda9e3e5e219908911ddd9c0756b5ea0bca4
Closes: OS#2294
Closes: OS#3906
2019-06-13 15:38:01 +00:00
Harald Welte dfa3bb8a10 Add severity to OML FAILURE EVENT REPORT
Example: The fact that the PCU has connected with a given version is not
a *failure* in the first place, particularly not a MAJOR one.  Let's
allow callers of oml_tx_failure_event_rep() specify the serverity of the
event that they're reporting to the BSC.

Change-Id: I49af04212568892648e0e8704ba1cc6de8c8ae89
2019-05-25 10:24:13 +02:00
Harald Welte b8265c63cc oml: Have one generic log message for all transmitted messages
Rather than open-coding "Tx foobar..." in various functions (and
forgetting it in half of them), let's add a generic message into
oml_mo_send_msg().

Change-Id: I5dd4b1749e68fb7fc74cb2e3a778d2418f46b770
2019-05-24 11:08:20 +02:00
Harald Welte 7f1b61df5f oml: Print more context from FOM Header or using MO
Some of our OML log lines were missing any context.  Try making more
sense by printing any context information about the given managed
object, TRX, ... as we have it.

Change-Id: I60d1660c6d574f206d7b8cc10082b413142365dd
2019-05-24 11:08:20 +02:00
Harald Welte b07e271994 Use LOGPLCHAN whenever possible
There's no point in open-coding what LOGPLCHAN was created to do:
Log some event while stating the name of the logical channel.

Change-Id: I6913ac8fb543811126b85a54118333155c03bc03
2019-05-24 00:02:34 +02:00
Vadim Yanitskiy 27ee75e4c0 common/oml.c: fix: properly encode NM_ATT_SW_CONFIG
According to 3GPP TS 52.021, sections 9.4.61-62, 'SW Configuration'
shall contain a list of 'SW Descriptions' related to the MO. In
other words, all 'NM_ATT_SW_DESCR' blobs shall be encapsulated
into a single NM_ATT_SW_CONFIG attribute.

For some reason, they were not encapsulated properly, so
OsmoBSC were unable to parse the 'SW Descriptions'.

However, unlike OsmoBSC the old OpenBSC does not expect this
encapsulation, thus after this change it will be unable to
parse the 'SW Descriptions'.

Change-Id: Id26104719891944f3e2151df362bd45bb057a9c5
Related: OS#3938
2019-05-07 00:40:14 +07:00
Vadim Yanitskiy 038a1fa047 common/oml.c: refactor Get Attribute Response message generation
Instead of allocating two transitional buffers (one static,
another dynamic), we can use the existing message buffer.

Both handle_attrs_bts() and handle_attrs_trx() can put (append)
the reported attributes, and push (prepend) non-reported ones
as per 3GPP TS 52.021, 9.4.64 "Get Attribute Response Info".

Change-Id: I349447a43bce360f59e0c6b435906c65167d158b
2019-05-07 00:30:09 +07:00
Vadim Yanitskiy 5efbd4e862 common/oml.c: fix broken debug print in down_mom()
Change-Id: Ideac59946d50c6e06052a9590e02cfcfbf23d003
2019-05-05 16:47:49 +03:00
Vadim Yanitskiy 40b1b4b20d common/oml.c: use proper format specifier for uint16_t
Change-Id: I8f372a689b3c1cc2cf925654b2db44a0f4ee7603
2019-05-05 16:46:20 +03:00
Vadim Yanitskiy 57e26c3e16 common/oml.c: introduce and use both LOGPFOH and DEBUGPFOH
Change-Id: I9e9d6ccb88c9c9d35b2ce5778fa2580382704089
2019-05-05 16:45:06 +03:00
Vadim Yanitskiy d16322f5ed common/oml.c: fix total length calculation in cleanup_attr_msg()
Both callers of cleanup_attr_msg(), i.e. handle_attrs_trx() and
handle_attrs_bts(), always pass out_offset >= 1, so the length
of the unsupported attributes counter is already accounted.

Otherwise, both callers would copy an additional garbage byte
from uninitialized memory. Discovered using Valgrind:

DOML DEBUG oml.c:539 OC=BTS(01) INST=(ff,ff,ff) Rx GET ATTR
DOML INFO oml.c:265 BTS Tx Get Attribute Response
==25467== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==25467==    at 0x623E0BD: send (send.c:27)
==25467==    by 0x5685846: __handle_ts1_write (ipaccess.c:358)
==25467==    by 0x5683F8B: ipa_client_write (ipa.c:79)
==25467==    by 0x5683F8B: ipa_client_fd_cb (ipa.c:140)
==25467==    by 0x5F1DC23: osmo_fd_disp_fds (select.c:223)
==25467==    by 0x5F1DC23: osmo_select_main (select.c:263)
==25467==    by 0x42980B: bts_main (main.c:354)
==25467==    by 0x6160F44: (below main) (libc-start.c:287)
==25467==  Address 0x7d83895 is 23,669 bytes inside a block of size 102,528 alloc'd
==25467==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25467==    by 0x589A6B4: talloc_pool (in /usr/lib/x86_64-linux-gnu/libtalloc.so.2.1.5)
==25467==    by 0x5F1E28B: msgb_talloc_ctx_init (msgb.c:316)
==25467==    by 0x4293D0: bts_main (main.c:234)
==25467==    by 0x6160F44: (below main) (libc-start.c:287)
==25467==  Uninitialised value was created by a stack allocation
==25467==    at 0x415FE5: oml_tx_attr_resp (oml.c:259)
==25467==    by 0x415FE5: oml_rx_get_attr (oml.c:561)
==25467==

Change-Id: Ic7c2c4e54e9f99b60aaf70604044933978be945c
Related: OS#3938
2019-04-19 20:22:29 +07:00
Vadim Yanitskiy 77b98d4a16 common/oml.c: use proper OML object for Get Attribute Response
It was noticed that the Get Attribute Response message always
indicates BTS(00,ff,ff) as the addressed OML entity, even if
e.g. Baseband Transceiver(00,00,ff) was requested by the BSC.

Despite neither OsmoBSC nor OpenBSC does complain about this,
such behaviour violates 3GPP TS 52.021. Let's fix this.

Change-Id: Icb1ee75d4bf680deb6365288d8c2053816a12217
Related: OS#3938
2019-04-19 20:22:26 +07:00
Vadim Yanitskiy d1e9ded94d common/oml.c: use proper NACK reason in oml_tx_attr_resp()
Change-Id: I482caa0747f81da2979bfbdbd22bd6962af728cd
2019-04-19 20:20:47 +07:00
Vadim Yanitskiy b873b91c5f common/oml.c: constify argument 'trx' of handle_attrs_trx()
Change-Id: Id476d492b3c1d0c728fca9eb0fb2254512bdef72
2019-04-19 20:20:47 +07:00
Vadim Yanitskiy 45a8d4b2be common/oml.c: fix: properly push abis_nm_ipa_magic
In oml_send_msg() we optionally push the A-bis IPA magic string
("com.ipaccess") to a given message buffer as LV (Length Value),
including the terminating null byte ('\0').

There was a mix of both sizeof() and strlen() calls, and worse
luck, memcpy() has been used in a wrong way, skipping the '\0':

  memcpy(dest, src, strlen(src));

In general, this is not critical because the headroom of a given
message buffer would most likely be zero-initialized, so the '\0'
is already there. However, msgb_push() gives no such guarantee.

Let's use the libosmocore's TLV API (in particular, lv_put()),
and stick to sizeof(), so the null byte will always be included.

Change-Id: I0c7f8776d0caec40f9ed992db541f43b732e47ae
Closes: OS#3022
2019-04-01 07:18:32 +07:00
Philipp Maier 945c09381d oml: use oml_tx_failure_event_rep() instead of signals to SS_FAIL
At some locations in the code a signal to SS_FAIL is dispatched in order
to trigger the sending of an OML failure event report in oml.c. This is
a bit overcomplicated for the task. Lets use oml_tx_failure_event_rep()
to send the failure event reports and lets remove the signal handler for
SS_FAIL.

Change-Id: Ie4fce1273a19cc14f37ff6fc7582b2945c7e7c47
Related: OS#3843
2019-03-27 11:10:57 +00:00
Philipp Maier a5a03d6b35 oml: use oml_tx_failure_event_rep() instead of oml_fail_rep()
The function oml_tx_failure_event_rep() replaces oml_fail_rep(), so lets
use only oml_tx_failure_event_rep() and remove oml_fail_rep()

Change-Id: I83c4fa9ebd519299fd54b37b5d95d6d7c1da24f6
Related: OS#3843
2019-03-27 11:10:57 +00:00
Philipp Maier 3dd90a09e4 oml: make oml_tx_failure_event_rep() public
The static function oml_tx_failure_event_rep() is a lot easier to use
than the currently implemented signal scheme. Lets make it public so
that we can quickly generate failure event reports.

Change-Id: I9c4601840a06119f35cfe4da453fff3b293fe615
Related: OS#3823
2019-03-18 09:20:58 +01:00
Harald Welte 5eddf98dfc OML: Store merged attributes of IPA OML Managed Objects
For the TS 12.21 standard OML attributes, we store a copy of the
most-recently set value for each attribute in "mo->nm_attr".  This
somehow was missed when adding support for the IPA specific MOs like
those relevant for GPRS.

Change-Id: I75ebda46da9c1fcecc484311bf3833f31c536ee1
2019-02-23 15:59:10 +01:00
Harald Welte 3933e930c3 OML: Work around OsmoBSC sending "GET ATTRIBUTES" with short length
OsmoBSC used to have a bug in encoding the "GET ATTRIBUTES" OML message,
resulting in the actual message length being three bytes longer than the
encoded length value.

As in Ib98f0d7c2cff9172714ed18667c02564540d65d7 we have introduced
proper consistency checks on length values, all "GET ATTRIBUTES" from
OsmoBSC version suntil today will fail.  This patch introduces a
work-around to remain compatible with old OsmoBSC while still keeping
the consistency checks for all other messages.

Change-Id: Ifa24e9e2c71feb2c597557807d675438c2825b2d
Related: OS#3799
2019-02-12 20:29:50 +01:00
Harald Welte 906357c5e2 OML: Properly reject short messages and truncate over-long messages
For OML, what matters is the length indicated in the OML message header.

If we don't have sufficient bytes, reject the message and send a failure
event report.

If we have more bytes, truncate the message at the number of bytes
indicated in the OML length header.

Change-Id: Ib98f0d7c2cff9172714ed18667c02564540d65d7
2019-02-12 20:28:49 +01:00
Harald Welte e160ac6ea5 OML: Reject segmented OML messages
TS 12.21 describes segmenting of OML messages using placement
fist/middle/last and the "sequence' number of the OML header. We don't
implement this and hence must ignore or reject any related messages.

Before this patch however, we simply treated such segments as if they
were a complete OML message.  Let's fix that.

Change-Id: Idd42cf4edc1bf9ab366853bd9b0f7afd9c060910
Closes: OS#3795
2019-02-12 20:08:56 +01:00
Harald Welte 96bded3ebd OML: Use 'const struct abis_oml_mo *' whenever users only read
Try to constrain the code a bit further by making all read-only
accesses use 'const *'.

Change-Id: I5a61e6d1b4e5e083bb24017166186dc87d035cd0
2019-02-12 20:08:18 +01:00