Commit Graph

3831 Commits

Author SHA1 Message Date
Philipp Maier 1eaa7bc931 gprs_bssgp: add handling for BSSGP RIM primitives
Receive and forward RIM messages to bssgp_prim_cb()

Change-Id: Idfd0a65872a2cc6089885afd8d31b0b029d85d47
Related: SYS#5103
2021-01-04 21:47:19 +00:00
Vadim Yanitskiy 833e8fac82 gsmtap_util: SNR can be negative, use a signed integer
In 'struct gsmtap_hdr' field 'snr_db' is defined as a signed integer,
however all functions that fill this structure accept an unsigned
integer.  This is wrong, because SNR can be negative.

Let's use 'int8_t' instead of 'uint8_t'.  Changing from unsigned
to signed should be relatively safe compared to the opposite.
Most of the callers I am aware of always do pass 0 anyway.

Change-Id: I9f432be5c346d563bf518111c14ff04d4a63f592
Related: SYS#5073
2021-01-04 17:49:18 +01:00
Vadim Yanitskiy 8f5844ed01 gsm_08_58: add flexible array member to 'struct ipac_preproc_ave_cfg'
Some averaging methods may have additional parameters, so let's
make it easier to access them for the API user.

Change-Id: I2f4ed56837dd479dbbd10c0a7df0ed7565d3946a
Related: SYS#4918
2021-01-03 22:23:11 +00:00
Harald Welte 886e742935 cbsp: Fix parsing DCS in decode of WRITE-REPLACE
The encoder generates the DCS IE, but the decoder forgot to parse it :/

Change-Id: I05d489f91a2cc5df372e8e695126659eedac9485
2021-01-03 14:18:58 +01:00
Harald Welte fdd71c822a cbsp: Fix osmo_cbsp_recv_buffered() for KEEP-ALIVE-COMPLETE
We used to suppress/drop any "zero length" messages, but we didn't
include the header when computing the length.  However, in CBSP there
are messages (at least KEEP-ALIVE-COMPLETE) which only consist of the
header without any information elements.  We cannot simply drop such
messages.

This also fixes the return value of osmo_cbsp_recv_buffered() to be
the total number of received octets (including the header).

Change-Id: Ib620128a167cb77f061ee57e8f8ad707b96b1c0d
2021-01-03 14:18:58 +01:00
Harald Welte 64b9407c4e cbsp: Fix encoding of "ETWS Warning Security Info" IE
This is a fixed-length Tag-Value IE.  Our decoder already parsed
it correctly, but the encoder encoded it as TLV, which is wrong.

Change-Id: I7e1d7eab8b8e51acd9a24c38e2d3d30bbf00847a
2021-01-03 14:18:58 +01:00
Alexander Couzens 5a3eb5d99a gprs_ns2: call python vty tests
Also checks vty docs

Change-Id: Ia8b77ae5bc3fed835dd1fc2cce0acbc41f199d54
2021-01-01 22:49:23 +01:00
Alexander Couzens c0d02cc163 utils: add osmo-ns-dummy
A dummy client to do integration tests of the ns2 layer.
It drop all unit data. But allows vty tests.

Change-Id: I127c178426bc1a3da8de251740eda93853030d6d
2021-01-01 22:46:57 +01:00
Alexander Couzens f737535432 gprs_ns2: use zero initialized memory for vty_binds
Change-Id: I5635d98c52948fddcc375e1be9b1cd04aa32bc3c
2021-01-01 17:24:57 +01:00
Alexander Couzens fdea03b408 gprs_ns2: fr: check the device state before changing state
Reduce the required capabilities if the device is already
set up.

Change-Id: I72eb2567078758694c648a493324b212461ee735
2020-12-29 22:41:41 +00:00
Daniel Willmann 0a2b257868 Declare osmo_ctx_init() in talloc.h
This function is called automatically on the main thread, but needs to
ba called explicitly in order to run the select loop on another thread.
Make it available for applications through talloc.h

Change-Id: Ie710ca9ad01d3fadb9f4ff344a55d6c01004727b
2020-12-28 22:29:01 +01:00
Alexander Couzens 8c33d4a485 gprs_ns2_fr: setup_device: allow to setup a new dahdi device
When a dahdi device hasn't been set up yet, ioctl IF_GET_PROTO fails
with invalid argument.
Also fix the device check to skip ioctl's if the device is also in the
correct state.

Change-Id: I398d056546e35465a2944e1b4a86a8c93b3e5f7a
2020-12-27 19:59:52 +00:00
Alexander Couzens 8a2a1a4959 gprs_ns2: rework frame relay load distribution function
For frame relay the traffic will be even distributed across
all NS-VCs. Do not differentiate between signalling and
data traffic.

Change-Id: I6c060941db335a7a6a555ac8d1b9269fa8fb2023
2020-12-26 18:43:08 +01:00
Pau Espin Pedrol d01163a977 rest_octets: Fix decoding of SI3 3G Early Classmark Sending Restriction
Restriction is applied if the value is L, so fix it.

Fixes: f85b33f68f
Change-Id: Idd170bc0f12e8b215a624e0632a106bde076179b
2020-12-23 12:39:17 +00:00
Pau Espin Pedrol 3f6a282a14 Revert "rest_octets: fix encoding of 3G Early Classmark Sending Restriction"
This reverts commit c9eab828ea.

The initial code was correct, which has also been used in osmo-bsc until
recently, where it moved to use this function from libosmocore and
errors started to show up in TTCN3 tests.

See 3GPP TS 44.018 Section 10.5.2.34 / Table 10.5.2.34.1: "SI 3 Rest
Octets information element":

"""
<SI3 Rest Octet> ::=
...
<3G Early Classmark Sending Restriction>
...

<3G Early Classmark Sending Restriction>::= L | H;
"""

Change-Id: I0ee48d3240c62c4d2e15063b26da7a2a617f383e
Related: OS#3075
Related: SYS#4021
2020-12-23 12:39:17 +00:00
Alexander Couzens b6b62cded0 frame_relay: link_alloc: move log message to the end
The link->name is still not set resulting in logging a (null)

Change-Id: I67cd4bce8238340e6ecb8d04a9a39c8b8d7d63e7
2020-12-23 06:32:29 +01:00
Alexander Couzens e249e36339 frame_relay: prevent null pointer exception when talloc fails
Change-Id: Ib39682ad0c7f30c97303b3d0bb6240fddd23ec0b
2020-12-23 06:32:29 +01:00
Alexander Couzens 280ed789a8 gprs_ns2: fix force-unconfigured for IP-SNS NSE
The IP-SNS need to do a reselection of the IP-SNS remote
for testing. Freeing all nsvc will force this.

Change-Id: I367c215a830c02eae2a470cba314828b5e0fb5c9
2020-12-23 06:32:29 +01:00
Alexander Couzens 6f3b738c74 gprs_ns2: don't start unconfigured fsm via FORCE_UNCONFIGURED
IP-SNS NSVC are unconfigured and not started when the IP-SNS is doing the SNS configuration.
If those NSVC would be started it would result in unsolicitated NS-Alive PDUs.

Change-Id: Ifec7288dbe71f10109e8b5c3849bf8f23ac7b557
2020-12-23 06:32:29 +01:00
Alexander Couzens a367d0863f gprs_ns2: sns: add log message when size/config retries exhausted
Change-Id: I5f7c04b364807418f5ba22132fc889b46d66aed0
2020-12-23 06:32:29 +01:00
Alexander Couzens cc65a25818 gprs_ns2: sns: don't send duplicated packets on retries
When all retries are exhausted it should change the state and not
send out a packet.

Change-Id: Ie33df4a12298882bc46633200486dc34c6e34d8e
2020-12-23 06:32:29 +01:00
Alexander Couzens 3ad73368be gprs_ns2: sns: correct log message when no nsvcs available
The log message should only shown if a reselection will be triggered.

Change-Id: I96b280a927aba6ac09ce88aedfcf469243c4dffe
2020-12-23 06:32:29 +01:00
Alexander Couzens 412bc3494d gprs_ns2: add new vty2
Change-Id: I163279cf57e84198dc8c53e1c109f5a9474670e9
2020-12-22 16:36:19 +01:00
Harald Welte d2a61179a3 lapd_core: Don't dereference data link after sending PRIM_DL_REL
We must always send the RELEASE.{indication,confirm} last before
returning from a function.  We cannot rely on the datalink to
still be around after the call, as the SAP user might have destroyed
the data link meanwhile.

This fixes a heap use-after-free (at least) with RBS2000 when the BTS
is fully brought up and the OML data link is lost, see OS#1762

Change-Id: I8ccca8d5e5d07b666557afe12ab8ac4910ddfb00
Related: OS#1761
Related: OS#1762
2020-12-21 17:43:54 +01:00
Harald Welte c296e2921a vty: Fix left shifting out of range on signed variable
Fixes following ASan runtime errors while running vty tests:
command.c:730:27: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Somehow we didn't catch this one in Ie11ff18d6fd9f6e1e91a51b6156fb6b0b7d3a9a8

Change-Id: I601caf7daa947f3cf391316f1011007ef9188c90
2020-12-21 15:45:45 +01:00
Harald Welte 4eb0f16e25 fsm: Add osmo_fsm_inst_broadcast_children()
This is a helper function to broadcast an event to all of the
siblings of a specified FSM instance.

Change-Id: I2ce398741a8672d7b7c4058d056f46e2fe7353c1
2020-12-21 15:45:45 +01:00
Harald Welte b8de188b54 gprs_ns2_fr: Use OSMO_STRLCPY_ARRAY() where possible
Change-Id: I8ce461ecc36a81a4221336e82a36a69f49f89a0a
2020-12-21 11:41:55 +00:00
Harald Welte 7f01b68671 gprs_ns2_fr: Avoid stringop-truncation warning
gprs_ns2_fr.c:448:2: error: ‘strncpy’ specified bound 16 equals destination size [-Werror=stringop-truncation]
  448 |  strncpy(req.ifr_name, netif, IFNAMSIZ);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: Ied9fd1bea091075fad266258da39e674d10d4dcb
2020-12-21 12:41:03 +01:00
Alexander Couzens 5c96f5dbc6 gprs_ns2: fr: setup the device to correct FR/LMI settings
A hdlc can be used in different modes. Also a FR device can be used
with lmi and certain settings as without it.
ns2 will use FR with no lmi in the kernel.

Related: SYS#5169
Change-Id: I04786d2b864860b08c2e1afdb199470f4b80cc3b
2020-12-20 17:16:44 +01:00
Alexander Couzens 60021a46ce gprs_ns2: fr: implement a write queue
Related: SYS#5228
Change-Id: Id6eba04d5fb744f791b333c168729bbbd28cabd9
2020-12-20 17:14:04 +01:00
Alexander Couzens 3c22f91bad gprs_ns2: don't pass the return code of reject_status_msg
When reject_stats_msg() fails the code can't do anything about it.
Stick to the original failure code and log it

Change-Id: I105363957e59c41a68835b7a9830c048dba73e93
2020-12-20 15:34:53 +00:00
Alexander Couzens 12e5e6bd78 gprs_ns2: improve handling of TLV errors on new nsvcs
The specification says the PDU should be ignored if the PDU type is
unknown.

Change-Id: I2992d06b37ed122b7ff315d4852e86acc936800b
2020-12-20 15:34:49 +00:00
Vadim Yanitskiy 2060bbb4c1 gsm_08_58: fix wrong field order in 'struct ipac_preproc_pc_thresh'
Thanks to the CLI of nanoBTS, I noticed that upper and lower RxQual
thresholds are sent in wrong order.  Only the little-endian variant
needs to be fixed, the big-endian one looks good.

Change-Id: If6ab2377bae6742f871589b529a349498775552f
Related: SYS#4918
2020-12-19 17:33:52 +01:00
Neels Hofmeyr 8fef761d14 fix strncpy bug in gprs_ns2_fr_bind()
This use of strncpy() fails to account for the terminating nul
character. Use OSMO_STRLCPY_ARRAY() instead.

(Interestingly my compiler doesn't complain about this one, though it
failed on another similar use of strncpy().)

Change-Id: Id53e940c7a39ab154966548f4173a179c5bc9151
2020-12-18 11:12:16 +00:00
Neels Hofmeyr 475a0acc64 gprs_ns2_fr.c: compiler error: replace strncpy() with OSMO_STRLCPY_ARRAY()
My gcc (Debian 8.3.0-6) 8.3.0 refuses to build this strncpy() use: it
issues the buffer length as n and thus potentially fails to account for
the terminating nul. The line after that fixes the problem, so it's not
an actual bug. Anyway, we have a policy to never use strncpy(), and have
osmo_strlcpy() and OSMO_STRLCPY_ARRAY() for this.

This strncpy() was introduced last month during first addition of
gprs_ns2_fr.c:

    commit 841817ec52
    ns2: add support for frame relay
    Change-Id Id3b49f93d33c271f77cd9c9db03cde6b727a4d30

Change-Id: I494a6fb7ccd7938a39e8956f73ec4282da38d7fb
2020-12-18 11:12:16 +00:00
Alexander Couzens 6f89c770c7 gprs_ns2: fr: fix crash when frame relay interface doesn't exists
When a frame relay interface doesn't exist gprs_ns2_fr_bind() would
detect this but still return a success.

Change-Id: I815b6ef5c3df780ac94461a05975a2b70898b01e
2020-12-18 10:52:37 +00:00
Vadim Yanitskiy d82ba90825 logging: revert color of LGLOBAL category back to white
"\033[38;5;19m" is unreadable on terminals with dark background.

Change-Id: I8ed40522b07c2028de4986d1f976609510faa894
2020-12-17 17:50:18 +00:00
Pau Espin Pedrol 946bb95af1 GPRS Cell Options (SI13): Add REL-4 CCN_ACTIVE bit
This is required in order to tell MS that osmo-pcu now supports
Network Assisted Cell Change (NACC).

Related: SYS#4909
Change-Id: I2aaa8c1107c977f711c2d7530034f57e36e3a237
2020-12-17 15:22:09 +00:00
Philipp Maier bd10c21cc4 gprs_bssgp: add IE parser/generator for RIM Routing Information
The RIM Routing Information IE (see also 3GPP TS 48.018, section
11.3.70) is used to control the flow of BSSGP rim messages at the SGSN.

Change-Id: I6f88a9aeeb50a612d32e9efd23040c9740bc4f11
Related: SYS#5103
2020-12-16 21:58:04 +01:00
Alexander Couzens 8806796976 gprs_ns2_vty: udp: fixup dialect changes
Only accept receiving ipaccess style messages when use-reset-block
is selected.
If use-reset-block is disabled allow static NSVCs.

Change-Id: Ia787528b1a6fac6bf1570c21643ef6cd8c209108
2020-12-16 21:34:03 +01:00
Harald Welte 33c3c0655b gors_ns2_vty: Fix saving of new NS2 timers
In I00e9023a6e7adc6ad48f4016fcaef189ac8b353e we introduced
two new timers, but failed to add the related value_string[]
entries.  This caused the VTY code to save something like

 timer unknown 0x8 3
 timer unknown 0x9 3

which fails to parse on re-start.

Change-Id: If5cfdf1ef68d98933985406d0ac071a0a1185646
2020-12-16 12:05:37 +01:00
Harald Welte 3a44d17a99 Fix VTY syntax for newly-introduced NS2 timers
In I00e9023a6e7adc6ad48f4016fcaef189ac8b353e we introduced two new
"timers": Number of retries for SNS-CONFIG and for SNS-SIZE.

Yet, the VTY syntax only added one string (tsns-prov-retires), probably
dating back to an earlier version.

Change-Id: I25fa579c7d68a8e4cb1175ae2245f009ab40fda7
2020-12-16 12:04:44 +01:00
Alexander Couzens bac5b0153b gprs_ns2: on ns2_create_vc parse the tlv before using it
reject_status_msg require a parsed tlv. Otherwise an
uninitialized tlv is passed.

Change-Id: I82cab518966b8b49c3522ff5f7b6f82d1027a526
2020-12-15 11:56:29 +00:00
Alexander Couzens c782cec663 gprs_ns2: add gprs_ns2_fr_bind_role() to retrieve the fr role
Change-Id: I277b805e588ba68536789b4a64a428ea0b31728a
2020-12-15 11:46:45 +00:00
Alexander Couzens 22c26e0610 gprs_ns2: make nsvc argument const
The nsvc isn't change. It can be const

Change-Id: Ie5052f02781d7fdc639456c6f02515a927cee1f3
2020-12-15 11:46:45 +00:00
Alexander Couzens 90ee963570 gprs_ns2_sns: introduce SNS Size/Config retries
According to 3GPP Size and Config procedure can
have retries in case the timeout of the procedure runs out.

Change-Id: I00e9023a6e7adc6ad48f4016fcaef189ac8b353e
2020-12-15 11:46:45 +00:00
Alexander Couzens 81ae0aa67f gprs_ns2_sns: use different binds for the initial connection
In case the first bind is not working the SNS would never build a
succesful connection to the SGSN. Iterate over all binds by
using an offset.
Instead of tracking the binds use an offset instead of a direct pointer.
This might result in skipping the order of the next bind.

Change-Id: I4a0a0608dac6ad8b5769ada2a14ca23f61eb0bcb
2020-12-15 11:46:45 +00:00
Alexander Couzens e769f5226b gprs_ns2_sns: rework IP-SNS initial remote
The IP-SNS requires at least one initial remote address of the SGSN.
However it should be multiple initial remote address instead of a single
in case the interface might fail.
Rework the SNS to support multiple initial remote addresses.

Change-Id: I71cdbfb53e361e6112fed5e2712236d797ef3ab2
2020-12-15 11:46:45 +00:00
Alexander Couzens 4755879fbe gprs_ns2: add gprs_ns2_free_nsvcs() to free all NS-VC of a NSE
Change-Id: I909443b540dbf75146297f1d7f94940690be6c0d
2020-12-15 11:46:45 +00:00
Alexander Couzens ebcbd726ee gprs_ns2: rework gprs_ns2_fr_connect*()
Add gprs_ns2_fr_connect2() and change gprs_ns2_fr_connect() to
be similar to gprs_ns2_ip_connect() and gprs_ns2_connect2().

This is an API break but there wasn't yet a release with NS2.

Change-Id: I4e1374b0e979b3293302c5ed46a91a58f3a5a916
2020-12-15 11:46:45 +00:00