Commit Graph

2306 Commits

Author SHA1 Message Date
Vadim Yanitskiy 7e104d96ba bts_features: s/Repeation/Repetition/ in osmo_bts_features_descs[]
Change-Id: Ia8c77766842ce80eae969774959cbf46e86f97b9
2021-01-07 14:22:56 +01:00
Pau Espin Pedrol 9584cd718a ctrl: Allow handling CTRL get/set replies in user defined code
Prior to this patch, it was not possible to gather SET/GET reply
information when implementing a CTRL client using libosmocontrol. This
is specially important when using the GET command, since one wants to
receive the queried value.
CTRL traps can also be handled this way by extending this patch in the
future if needed.

Change-Id: Id3c4631cd32c13e78e11b6e8194b8c16307ec4f1
2021-01-06 12:32:36 +00:00
Harald Welte e4cd267ab1 Add inter-thread queue
This adds an inter-thread queue "it_q" to libosmocore. With it_q,
one can perform thread-safe enqueing of messages to another thread,
who will receive the related messages triggered via an eventfd
handled in the usual libosmocore select loop abstraction.

Change-Id: Ie7d0c5fec715a2a577fae014b0b8a0e9c38418ef
2021-01-06 00:22:13 +01:00
Daniel Willmann fbb78a73b4 bssgp: Add SUSPEND_NACK to osmo_pdef_bssgp
Change-Id: Ic996a343215ad32e3f301712411006e5d41f9084
Related: SYS#4865
2021-01-05 15:31:08 +00:00
Vadim Yanitskiy c9f4c49f81 gprs_bssgp: fix uninitialized struct fields in bssgp_create_rim_ri()
Change-Id: Ifc3dda1fe5e9743072751dbb14c2d973388cb3b2
Fixes: CID#215836
2021-01-05 15:21:39 +00:00
Vadim Yanitskiy 222e844718 gprs_ns2_fr: fix resource leaks due to early return in set_ifupdown()
Change-Id: Ie52bf8ac6d62e7f2d760294bf2fe90119cc96b4b
Related: CID#215869
2021-01-05 15:21:39 +00:00
Vadim Yanitskiy d8b7003df7 gprs_ns2_sns: always check rc of osmo_sockaddr_str_from_sockaddr()
Writing a configuration that will be rejected by the VTY parser
is not the best solution, but still better than printing values
from previous iterations or the stack garbage.  In any case,
this is unlikely to happen, just making Coverity happy.

Change-Id: I26644fe544c82c90767ec1a9709918474bd1be53
Fixes: CID#215852
2021-01-05 15:21:39 +00:00
Alexander Couzens 1c8785dd81 gprs_ns2: set transfer cap in NS Status primitive
Related: SYS#5153 OS#4835
Change-Id: Ia1046db9e0d50855bff9de670b612ffc57af9995
2021-01-05 14:24:03 +00:00
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
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 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
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
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
Alexander Couzens aaa55a663e gprs_ns2: add member name to bind
Every bind will have a unique name. Add a name argument
to all bind creating functions and require them to be unique.

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

Change-Id: I8f1d66b7b3b12da12db8b5e6bd08c1beff085b3e
2020-12-15 11:46:45 +00:00
Alexander Couzens 93ad499832 gprs_ns2: move allocation of the SNS fsm into create_nse
The allocation of the SNS fsm can be done in create_nse
because the dialect is now known at that time.

Change-Id: I64e1f3dcc63d38e65bb486c9ac08d4032b7ad222
2020-12-15 11:46:45 +00:00
Alexander Couzens d923cff170 gprs_ns2: introduce NS dialects
A NS dialect describes how the NS Entity interacts with
different virtual circuits. E.g. ipaccess use reset/block on udp
and is a dynamic connection.
A single NS Entity can only support one dialect. This can be later
used to protect a NS Entity against dynamic NS virtual circuits of a
different type.

It further allows a bind to support multiple dialects at the same time.

Change-Id: Ia118bb6f994845d84db09de7a94856f5ca573404
2020-12-15 11:46:45 +00:00
Pau Espin Pedrol 0f619de715 gsm: append_eutran_neib_cell: Fix SI2quater EARFCN list
Commit bd6e7a9f2d did the initial porting
of rest_octet APIs from osmo-bsc, but introduced a bug when moving
bts->e_offset to a generic pointer independent of bts structure.
As a result, using this API from osmo-bsc makes gsm0408 unit test fail
due to bad encoding of several EARFCNs in si2quater.

Fixes: bd6e7a9f2d
Change-Id: I2bf5635b8536b11d69774d17ac1908019633e3af
2020-12-14 17:58:23 +01:00
Pau Espin Pedrol c4286ad056 si2quater: fix budget calculation for multiple EARFCNs
In rest_octets.c append_earfcn(), the unconditional bits added are 40, not 25.
Removing only 25 bits from the budget resulted in malformed SI2quater starting
with 4 configured EARFCNs, by adding more EARFCNs than fit in 20 bits.

These malformed SI2quater were also expected in gsm0408_test.c. Update the
expected SI2quater to what is being generated now. This patch passes the ttcn3
testing added in I45382f88686ca60e68569e93569fc4cfb63a0e0d, which provides some
confidence that the coding expected in gsm0408_test.c is now correct.

This commit is a cherry-pick of osmo-bsc.git 6589f7c3a8dfdaaf66dda3afa6bbb1118ec825f9

Change-Id: Icc1ece39ad162d09720e104c5cbc12b07d6771a8
Related: OS#4652
2020-12-14 17:19:30 +01:00
Pau Espin Pedrol 30bf0e6745 gsm: si13: Fix encode of EGPRS_PACKET_CHANNEL_REQUEST
Cherry-pick from osmo-bsc.git e981f17200bf3a5d5114f46d9f7515fd10b96dbb

Change-Id: I0aae385a427205cc73f60feca161e38608e608d8
2020-12-14 17:13:47 +01:00
Pau Espin Pedrol 908224c1a4 rest_octets: add Serving Cell Priority Parameters
When we add an EARFCN to to the SI2quater struct we do not add Serving
Cell Priority Parameters. This essentially causes to MS to ignore the
EARFCN because it is still undefined under which conditions the MS
should change to LTE.

This is a cherry-pick from osmo-bsc.git 295c965c063a8c431507191f6aef1ef78b720685

Related: SYS#4510
Change-Id: If9134759e9bc4ae0920800972632fd8c5dc9c2d9
2020-12-14 17:11:21 +01:00
Harald Welte 5bea72e1e0 gprs_ns2_fr: use ETH_P_HDLC instead of ETH_P_ALL
When opening the socket, use ETH_P_HLDC to restrict the socket to
packet received on HLDC interfaces.  This avoids packets from random
other (ethernet, ...) interfaces to appear before we can bind()
it to the actual hdlc-net-device we're interested in.

We still are racing against other HLDC net-devices, but those have
lower PPS and throughput ratese as 1G/10G or even higher speed ethernet
devices that might exist on the same machine.

Change-Id: I6a556e6e2d012c17a2777cc8b30fed0f318db178
2020-12-10 22:08:02 +01:00
Harald Welte 41b188b90b gprs_ns2_fr: guard against race between socket(AF_PACKET) and bind()
An AF_PACKET socket will immediately receive packets of _all_ interfaces
until it is bound to one specific interface.  This introduces a race
condition between the socket() and the bind() syscall.

Let's use the ifindex passed for each packet in recvmsg() to drop
any packets received for other interfaces.

Change-Id: I8f708ba4f9b7f76525acce17b24a8f7b125a1c1c
Related: SYS#5245
2020-12-10 22:01:33 +01:00
Harald Welte 4ed0f4e994 gprs_ns2_fr.c: Skip extraneous FIONBIO
The socket is marked non-blocking inside osmo_fd_register(), there
is no need to do it twice.

Change-Id: I2068ce8280357b14970d01e5c86de5c59c933650
2020-12-10 22:01:33 +01:00
Pau Espin Pedrol 0e61716881 bssgp: Remove newly added log line warning about NOOP
osmo-pcu unit tests fail ue to this new log line. Let's rather simply
leave a comment there, since anyway known apps will be migrating soon
the new APIs.

Fixes: fde19ed579
Change-Id: Ib9bf528db08f7aaa4adaf7b6a320679a4f11a53d
2020-12-10 13:39:44 +01:00
Harald Welte 1fcfce86cb bssgp_bvc_fsm: Add basic BVC flow control rx/tx support
The FSM doesn't actually implement the flow control logic,
it only decodes / dispatches and encodes messages.

Related: OS#4891
Change-Id: Ie59be6761177c43456898be9148727f15861a622
2020-12-09 22:57:53 +01:00
Harald Welte 4394bb9629 bssgp2: Encoding + Decoding functions for BVC and MS flow control
Change-Id: I9c89bb1c03550930c07aad7ff8f67129ee7a6320
Related: OS#4891
2020-12-09 22:56:07 +01:00
Harald Welte 4c0e1a1f4c logging: Assing different 8bit colors to built-in subsystems
The 16 ANSI colors we started to use for OpenBSC in 2008 were
sufficient for those few sub-systems that occurred in the BSC/NITB.

Over time, most sub-systems did not get colors anymore.  Let's
change that and assign more or less random colors from the 8bit
color palette.

Change-Id: Ia8c0f91a61fbca0441faf66b3f368f45f886187c
2020-12-09 22:56:07 +01:00
Harald Welte 17a892ff2b gb: Add beginnings of a new BSSGP implementation
Similar to ns2 superseding ns, we now also intoduce a next generation
of BSSGP related code to libosmogb.  However, this is not aiming to
be a full implementation yet, but simply those parts that we currently
need from the revamped osmo-gbproxy.

The gprs_bssgp2.[ch] differs in two ways from the old code:
* it separates message encoding from message transmission
* it supports more recent specs / IEs

bssgp_bvc_fsm.c is a genric implementation of the BSSGP BVC
RESET/BLOCK/UNBLOCK logic with support for both PTP and signaling,
both on the SGSN side and the BSS side.

Change-Id: Icbe8e4f03b68fd73b8eae95f6f6cccd4fa9af95a
2020-12-09 22:56:01 +01:00
Harald Welte fde19ed579 logging: Introduce DLBSSGP logging constant
Historically, BSSGP uses a non-constant, user-configurable integer
varieable for the logging sub-system.  Let's replace this with a
statically-allocated library logging constant.

This is required if we want to use the subsystem number in e.g.
static initialized for osmo_fsm.log_subsys.

Change-Id: I506190aae9217c0956e4b5764d1a0c0772268e93
2020-12-09 22:50:01 +01:00
Alexander Couzens 45a25a3222 gprs_ns2_sns: correct dynamic calculation
The wrong argument was used to multiply by 4. However it was still
compliant because the SNS code would always supports 16 NSVCs.
Use the correct multiplier.

Fixes: ttnc3 pcu sns test cases
Fixes: 42ad549152 ("gprs_ns2_sns: dynamic calculate the maximum NS-VCs")

Change-Id: I58d706c6fffb4237b90b37cade4dc00c6aba6ac9
2020-12-09 16:13:42 +00:00
Harald Welte 8f82528bf7 bssgp: Add osmo_tlv_prot_def for BSSGP
Change-Id: I7e4226463f3c935134b5c2c737696fbfd1dd5815
2020-12-08 12:27:38 +00:00
Harald Welte 30a9294306 tlv: Introduce enum with error codes for TLV parser functions
Change-Id: I0b352792089c5c0c714712d2ea237beb92e1d73f
2020-12-08 12:27:38 +00:00
Harald Welte 9510992c53 Introduce 'osmo_tlv_prot' abstraction for validation of TLV protocols
This extends our existing TLV parser with the ability to
* validate that mandatory IEs of a given message are present
* validate that all present IEs are of required minimum length

Introducing this generic layer will help us to reduce open-coded
imperative verification across virtually all the protocols we
implement, as well as add validation to those protocols where we
don't properly perform related input validation yet.

Change-Id: If1e1d9adfa141ca86001dbd62a6a339f9bf9a912
2020-12-08 12:27:38 +00:00
Harald Welte e24a5b559c ns2: Accept NS-UNBLOCK-ACK in UNBLOCKED state
if we transition to UNBLOCKED as a result of a locally-generated
unblock action, then of course we will receive an inbound UNBLOCK-ACK.

Let's avoid error log messages and confusign the peer with NS-STATUS
in this case:

DLNS DEBUG GPRS-NS2-VC(FR-hdlcnet3-DLCI18-NSEI2001-NSVCI3)[0x612000001720]{UNBLOCKED}: Received Event UNBLOCK_ACK (gprs_ns2_vc_fsm.c:692)
DLNS ERROR GPRS-NS2-VC(FR-hdlcnet3-DLCI18-NSEI2001-NSVCI3)[0x612000001720]{UNBLOCKED}: Event UNBLOCK_ACK not permitted (gprs_ns2_vc_fsm.c:692)

Change-Id: Icc4d960ddad82e3ebbf571d8ff9f24854b52a946
2020-12-08 12:27:38 +00:00
Philipp Maier b73a3ded04 gprs_bssgp_util: complete bssgp_pdu_strings
The value strings for the BSSGP lack some items, lets make it complete.

Change-Id: I94956ca12df7f7ba912da05397b3fb39956277f7
Related: SYS#5103
2020-12-07 20:55:52 +01:00
Alexander Couzens e78207f16b gprs_ns2_sns: fix whitespaces and superflous comment
Change-Id: Ica0033c88cad71827ad843e92ccd54663426de23
2020-12-07 13:13:06 +00:00
Alexander Couzens db1c3fb114 gprs_ns2_sns: add missing S() to allow GPRS_SNS_EV_NO_NSVC happen
The event GPRS_SNS_EV_NO_NSVC was never dispatched because the
S() was missing to convert it into a bitmask.

Change-Id: I4af01293ff0ba8629e1426b1ba92f72f0520c7f0
2020-12-07 13:13:06 +00:00
Alexander Couzens 42ad549152 gprs_ns2_sns: dynamic calculate the maximum NS-VCs
The previous hard-coded value could be not enough if the user configures
too many local binds. Allow at least 8 NS-VCs. In case the user
configures too many binds (> 2) increase the maximum NS-VCs to allow
the SGSN to have 4 redundant connections.

Change-Id: Iae859dc504716fd6f705e72db5fc293b4b3298e7
2020-12-07 13:13:06 +00:00
Alexander Couzens e03d863e1f gprs_ns2_sns: add missing transistion UNCONFIGURED -> SIZE
The SNS FSM can go into the SIZE state when all NS-VC are failing.
This is the case if the network connection to the SGSN got interrupted.

Change-Id: I7e7da9451458505c1c2d73836dd916aee7704fda
2020-12-07 13:13:06 +00:00
Pau Espin Pedrol d41800c7ec gb: Import mnl.h iif --enable-libmnl
Change-Id: Ic0100493a9256e9c30a4bbb92be404270a8b9393
2020-12-07 13:35:24 +01:00
Harald Welte 61e9de8f15 bssgp: Update bssgp_pdu_strings with Release 15
In I7da8b25c9a89a7e3ae6c1680ba838e136d7d5293 we introduced the enum
values for all the new BSSGP message types up to Release 15.  Let's
also add value_strings for them here.

Change-Id: Ia108ba0d5f1f2c9d46f0c0bd11cd93104b9d62ea
2020-12-04 18:20:15 +00:00
Harald Welte 798efea27e gprs_ns2: Use TLVP_PRES_LEN instead of TLVP_PRESENT
With TLVP_PRESENT we only check if a given TLV/IE is present,
but don't verify that it's length matches our expectation.  This can
lead to out-of-bounds reads, so let's always use TLVP_PRES_LEN.

Change-Id: I4c438bc82ea6a48243db568f96a234adf784dc0b
2020-12-04 18:20:15 +00:00
Harald Welte 2d9ce71fcb bssgp: Use TLVP_PRES_LEN instead of TLVP_PRESENT
With TLVP_PRESENT we only check if a given TLV/IE is present,
but don't verify that it's length matches our expectation.  This can
lead to out-of-bounds reads, so let's always use TLVP_PRES_LEN.

Change-Id: I56e8b31ce51602d2681e3db501c48f84bfe7e438
2020-12-04 18:20:15 +00:00
Daniel Willmann 89106524a0 ns2: Fix argv index in logging filter VTY commands
Change-Id: I8adaf8094ef028b2d580e918532d6712d2ebbc2c
Related: SYS#5232
2020-12-04 16:52:11 +00:00
Harald Welte a59e6dbee3 gprs_ns2_fr: remove include <linux/if.h>
It's not needed because net/if.h already include
the required parts. Furthermore the linux/if.h generates
a compiler error in combination with net/if.h on older systems
(e.g. debian jessie)

Change-Id: I53650e9c55bb9dd98ba60269025e72673e9f82c1
2020-12-04 10:30:43 +01:00
Harald Welte 26fc9136b0 mnl: Use mnl_socket_open() insatead of mnl_socket_open2()
mnl_socket_open2 is not yet available on e.g. Debian 8.  Furthermore,
osmo_fd_register() will set the CLOEXEC flag on every file descriptor
anyway, so there is no benefit from using mnl_socket_open2() at all.

Change-Id: I0b37ffa148ff0c0a22281b490820353f5fef00eb
2020-12-04 10:29:07 +01:00
Harald Welte d8e59b208c libosmogb: Add missing LIBMNL_CFLAGS
In Change-Id I779556991bfc88b7751b2be17bb81c329cfb9e01 we introduced
the use of libmnl via osmo_mnl to libosmogb.  Howver, we didn't add
LIBMNL_CFLAGS in Makefile.am, which now (rightfully) fails on some
distributions like the SuSE family of distributions.

Let's fix this.

Change-Id: Ib8740e8fd677026efb9dad5d5fe6b95147fb3c23
2020-12-04 10:17:21 +01:00
Daniel Willmann 751977be6f ns2: Add log filtering by NSE/NSEI, fix NSVC filter on receive
NSVC filtering was only implemented on sending messages, this also adds
log_set_context() calls to  ns2_recv_vc()
Filtering by NSE is implemented similar to NSVC.

Change-Id: I63c0e85f82f5d08c5a6f535da94b8648498439d2
Related: SYS#5232
2020-12-03 15:14:18 +01:00
Alexander Couzens d87a2f14e6 gprs_ns2: use switch() case instead of multiple if in ns2_create_vc()
Improve readibilty and allows it to extend for future ns2 vty changes

Change-Id: I8bd9c75fb04169a166b7a3f5e13a5902250cfd0e
2020-12-03 06:15:09 +01:00
Alexander Couzens 036bf140c9 gprs_ns2: fix typo in comment
Change-Id: Ic0653ce7de8d2d64bd7cf10e148b07da8cbeb0a2
2020-12-03 06:15:09 +01:00
Harald Welte 25ee755cc7 gprs_ns2_vty: Re-introduce a 'show ns' command
In I157467d6a74d6109bc23521c978c5aac6d29fe50 we introduced a split
between 'show ns entities' and 'show ns binds'.  However, there is
at least one test case in osmo-sgsn.git which depends on 'show ns'
working.  So let's re-add it as a backwards compatible, hidden command.

Change-Id: I7571c6d82f7a712803d09d165abb6c7cb5ae2e5c
2020-12-02 22:15:34 +01:00
Harald Welte 56f08a377c gprs_ns2_fr: Monitor the kernel net-device link state
We use the newly-introduced libmnl integration of libosmocore in order
to receive netlink events from the kernel on link state changes.

If one of "our" interfaces changed link state, we report this in the log
and also store it within the "bind".

Change-Id: I779556991bfc88b7751b2be17bb81c329cfb9e01
2020-12-02 21:04:51 +00:00
Harald Welte 53a2fde368 Integrate libmnl (minimal netlink) library with libosmocore select loop
This adds an easy way to listen to netlink events form the Linux kernel
from within libosmocore applications.

The new dependency can be disabled via the "--disable-lbimnl" configure flag.

Change-Id: I4f787ee68f0d6d04f0a5655eb57d55b3b326a42f
2020-12-02 21:04:51 +00:00
Alexander Couzens b7fc3a0a6d gprs_ns2_fr: remove include <linux/if.h>
It's not needed because net/if.h already include
the required parts. Furthermore the linux/if.h generates
a compiler error in combination with net/if.h on older systems
(e.g. debian jessie)

Change-Id: Iccf931207d8bea19969fbfc4225f622a1a709972
2020-12-02 20:49:48 +00:00
Daniel Willmann cb3e9b5847 ns2: Fix docs for some NS2 vty commands
Change-Id: Ie58607424340c102c930330e444c2e219c1803e0
2020-12-02 15:50:22 +01:00
Harald Welte 1e72df0208 gprs_ns2_udp.c: Fix typo - it's a DSCP and not a DCSP
also, acronyms are typically all-caps.

Change-Id: Ia12d1fd66348f0b317405f46589f041045c513a2
2020-12-01 18:21:17 +01:00
Harald Welte dc2d080813 gprs_ns2_vty: Print all relevant data on each NS-VC
After this patch, we can finally see the BLOCKED/UNBLOCKED state,
weights, persistence, etc. in the VTY.

Example:

OsmoGbProxy> show ns entities
NSEI 00101: UDP, DEAD
 NSVCI 00101: RESET PERSIST data_weight=1 sig_wight=1 udp)[127.0.0.1]:23000<101>[127.0.0.1]:7777
NSEI 00001: FR, ALIVE
 NSVCI 00001: UNBLOCKED PERSIST data_weight=1 sig_wight=1 fr)netif: hdlcnet1 dlci: 16
 NSVCI 00002: UNBLOCKED PERSIST data_weight=1 sig_wight=1 fr)netif: hdlcnet2 dlci: 17
 NSVCI 00003: UNBLOCKED PERSIST data_weight=1 sig_wight=1 fr)netif: hdlcnet3 dlci: 18
 NSVCI 00004: UNBLOCKED PERSIST data_weight=1 sig_wight=1 fr)netif: hdlcnet4 dlci: 19

Change-Id: I1cf8fe55d1d0cecc46113532c8550880558b0155
2020-12-01 18:19:02 +01:00
Harald Welte 96ec84a035 gprs_ns_vty: Unify display of NSVCI on VTY in 'show ns entities'
Change-Id: I2915b47a5fc4ed9ac16f611c9e9f71dc0955426a
2020-12-01 18:01:43 +01:00
Harald Welte 7aa609929c gprs_ns2_vty: Show NSVCI in dump_nsvc()
also, indent the statistics one more character

Change-Id: I2726d6f1c5f83255925d6a1b22f1ee71b8d6fdc5
2020-12-01 18:01:43 +01:00
Harald Welte 2fce19a243 gprs_ns2_vty: Differentiate 'show ns binds' and 'show ns entities'
Change-Id: I157467d6a74d6109bc23521c978c5aac6d29fe50
2020-12-01 18:01:43 +01:00
Harald Welte 0ff12ad0ba gprs_ns2: Print link layer and global ALIVE/DEAD state
Change-Id: I56455d1fef2f99d72bc0c4811f307428aec12b96
2020-12-01 18:01:43 +01:00
Harald Welte 6188e004d2 gprs_ns2: Don't return an empty string in case of unknown LL
Change-Id: Id2c689ab83ada18a5cb6d70ded31aacaa701f99c
2020-12-01 18:01:43 +01:00
Harald Welte 37322bc714 gprs-ns2: Fix stringification of NS/FR NSVCI
Before this commit, gprs_ns2_ll_str_buf() would always return an empty
string.

Change-Id: I6ec07f58fa5cbb7ec4be967b2c72ae75935e4f75
2020-12-01 18:01:43 +01:00
Harald Welte 48bd76cbc0 gprs_ns2_fr: Print Frame Relay 'role' in VTY
Change-Id: I23182e5d952fd28a0bbfa76a4fc94d8e03b7a65d
2020-12-01 18:01:43 +01:00
Harald Welte a24e7ee3bd gprs_ns2: Introduce gprs_ns2_lltype_str() for link layer name
Change-Id: I4b257c09d9d3c97d6da04240c7a74a95c7c93675
2020-11-30 13:30:14 +00:00
Harald Welte b6b82da56c frame_relay: Fix error path on ioctl() failure
We don't want to pass -EINVAL as file descriptor into the bind() call.

Closes: CID#215529
Change-Id: Ic4d411c0ade6867c4fe2c01eb3368e6420158724
2020-11-30 13:29:33 +00:00
Harald Welte 29b77a61ff frame_relay: Fix null pointer dereference in DLC/PVC delete
Change-Id: I71de58f6ca15e2057f26d9c5502c8bc3e03e714f
Closes: CID#215530
2020-11-30 13:29:33 +00:00
Pau Espin 3f2775b4d2 statsd report: Fix wrong fmt specificier generating wrong stats
Fixes: OS#4871
Change-Id: I04aba0f3a4ff6563a4e285b982077184645d1180
2020-11-28 01:11:25 +01:00
Harald Welte 920491936e gprs_ns2_vty: Fix VTY documentation errors
Those two documentation errors made e.g. gb-proxy VTY tests fail.

Change-Id: I487ee3532aed4de38494005106ae9686d590608d
2020-11-25 20:57:09 +01:00
Harald Welte 6d4db2367d Revert "ns2: permit multiple nsvci in one nse in VTY"
This reverts commit 0bd8a4b5b3, which
was causing massive VTY test failures for osmo-pcu.git and osmo-sgsn.git

Change-Id: I0236d1e835111604e58c5d8c3f84221e055ce59d
2020-11-25 20:56:46 +01:00
Harald Welte 78ebc3fa31 frame_relay: Fix some spelling/language issues
Change-Id: I0ec34c0b452a46008a629f664c10dabd3f836d56
2020-11-25 17:39:06 +01:00
Alexander Couzens 10e991b224 ns2: remove obsolete type GPRS_NS2_LL_E1
There is already frame relay type GRPS_NS2_LL_FR
to support frame relay.

Change-Id: Iabb4608d91ccb32a07cad67519166dabfba76612
2020-11-24 03:53:22 +01:00
Alexander Couzens aac9016570 ns2: move link layer type into NSE
Even it was in theory possible to mix NS-VC ll types within
a NSE. This is an unrealistic configuration.
Further more to select the correct load sharing mechanism
the NSE must know the correct link layer.

Change-Id: I18dfd40a2429cd61b7c4a3dad5f226c64296f7d8
2020-11-24 03:53:22 +01:00
Alexander Couzens 24a14ac80c ns2: move LL into public api
Also fix prefix. GPRS_NS -> GPRS_NS2.
In preparation to move LL into upper layer.

Change-Id: I3b5e0d51ce69b095095e5160ca0cf0d4534db1b8
2020-11-24 03:53:22 +01:00
Harald Welte 0bd8a4b5b3 ns2: permit multiple nsvci in one nse in VTY
Change-Id: I4ad454320d0a03e81b399f55e8bd0ee57402dad0
2020-11-24 03:53:22 +01:00
Alexander Couzens fc3dd1fb14 ns2: implement link sharing selector
Change-Id: I212fa1a65e8c16cf1e525d1962d5689446c7e49e
2020-11-24 03:53:22 +01:00
Alexander Couzens 841817ec52 ns2: add support for frame relay
Add support for frame relay over dahdi hdlc device.
It's supporting lmi by q933 and supports both
SGSN and BSS.

Change-Id: Id3b49f93d33c271f77cd9c9db03cde6b727a4d30
2020-11-24 03:53:22 +01:00
Daniel Willmann dbab714343 ns2: Add a VTY command to reset NSVC FSM
Mainly useful for testing so implemented as a hidden command

Change-Id: I83b9cd7381c25da0e8aa847038a2d422c8dd63cf
Related: SYS#5002
2020-11-20 15:38:00 +01:00
Daniel Willmann ed0c982079 ns2: Add a function to set the NSVC FSM back to unconfigured
The function gprs_ns2_vs_force_unconfigured() resets the NSVC state back
to the initial value when it was first started. This can be useful for
testing.

Related: SYS#5002
Change-Id: If96d56b19959372af4eba009661be19e985b4d51
2020-11-20 15:38:00 +01:00
Daniel Willmann f5b2e28c87 ns2: Split 'initiater' into initiate_{reset,block}
Related: SYS#5002
Change-Id: Iff5aff0cf8d19d9c718dd11c4e731ced2aeb16ba
2020-11-20 15:37:46 +01:00
Alexander Couzens c06aa710d0 ns2: check if ns_vc_alloc() fails in bind_connect()
Change-Id: I82c984b9808451a72a62ff03b0495a1d09473e1c
2020-11-20 08:51:19 +00:00
Vadim Yanitskiy c1c420ce3d bts_features: add missing description for BTS_FEAT_ACCH_REP
Change-Id: Ie1d7f00b1bed43c41274bba4ce767a61cd71bb61
Fixes: Ib4d1d8d8a1a1d58bc320a1c0eff2d52100267f09
2020-11-20 01:41:15 +07:00
Harald Welte 702c998391 card_fs_usim: Add definitions of DF.ProSe and DF.ACDC
those are the only two sub-directories of Release 15 we didn't cover
yet.

Change-Id: I1f85430cbb0041766b0725df9fa97c5a82e4f38d
2020-11-17 09:56:01 +00:00
Vadim Yanitskiy 7031ac1dd2 vty/command: add 'hidden only' VTY reference generation mode
Change-Id: I511ce26350cd04bb0f66d130b5286cab84f16df2
Related: SYS#4910
2020-11-17 16:23:11 +07:00
Pau Espin 4fe8a7598a serial: Introduce API osmo_serial_speed_t
This allows usual integer parsing at app level and calling this function
to make sure correct values will be passed to
osmo_serial_set_baudrate().

Change-Id: I41415c99d26128b33a8bf5ef7b38948bd1fe5d50
2020-11-13 22:58:14 +01:00
Pau Espin 28acb21321 serial: Log error if tcgetattr() or tcsetattr() fail
Change-Id: I79121e016f045c9d0555881359cd3008320223ed
2020-11-13 22:58:02 +01:00
Pau Espin 71ba873cc1 serial: Fix typo in debug log line
Change-Id: Ibfe70a42649512719be3c3ae42b5fad8b28a800a
2020-11-13 22:58:00 +01:00
Pau Espin 23999dac6e cosmetic: serial: Fix typo in comment
Change-Id: I5d4901e01af477ebb815f70a5326ada6224c4be8
2020-11-13 22:57:49 +01:00
Pau Espin 4c951adcf4 bitvec: Fix left shifting out of range on signed variable
Fixes following ASan runtime errors spotted by TypeTest osmo-pcu unit test:
libosmocore/src/bitvec.c:275:13: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Change-Id: I70502044d05c0505a4b65c1e12e89ff657afe804
2020-11-13 12:09:02 +01:00
Philipp Maier e36be56fc8 gsm_04_08: add parser for Mobile Station Classmark 3
3GPP TS 24.008 section 10.5.1.7 describes a Mobile Station Classmark 3
IE, which is encoded as CSN.1 struct. This means that it can not be
parsed by just casting a memory location to a struct pointer, so lets
add a parser to parse the CM3 IE.

This is fixed version of Ic8b2bfd00330235f5bed00771e421588abfaac1f,
which got reverted because it used the keyword "class" as struct member,
which lead into problems with c++ builds. This is now fixed.

Change-Id: Id8732551b33616227609cd6fcf6c3133751a89eb
Related: OS#4796 SYS#5114
2020-11-12 15:55:31 +00:00
Harald Welte c2118940aa Revert "gsm_04_08: add parser for Mobile Station Classmark 3"
This reverts commit a4939dc846,
which caused massive build failures in C++ programs like osmo-pcu
- unsurprisingly, as it calls a struct member "class", which is a
reserved keyword in C++.

Change-Id: Ia43e56385e7b580f492c560aee8ff8b1e8a0e1d8
2020-11-11 23:11:15 +01:00
Pau Espin 1b75e4bbd1 tdef: Introduce OSMO_TDEF_US unit
Some applications may need submillisecond timers, such as those
interacting with modbus serial lines (RS-485, RTU), which require
timers of values around 1.5 char-time (T1.5), where a data char is
composed of 11 bits sent on the line: 1 start bit, 8 data bits,
1 stop bit, and and parity bit (or 2nd stop bits if no parity).

For instance, for a baudrate of 9600:
1.5 * 11 / 9600 = 1.718 ms = 1718 us

So having a granularity of MS is not enough here.

Change-Id: I71848d7c1ee0649929ce07680ee7320bb2a42f0e
2020-11-11 20:08:26 +00:00
Philipp Maier a4939dc846 gsm_04_08: add parser for Mobile Station Classmark 3
3GPP TS 24.008 section 10.5.1.7 describes a Mobile Station Classmark 3
IE, which is encoded as CSN.1 struct. This means that it can not be
parsed by just casting a memory location to a struct pointer, so lets
add a parser to parse the CM3 IE.

Change-Id: Ic8b2bfd00330235f5bed00771e421588abfaac1f
Related: OS#4796 SYS#5114
2020-11-10 16:36:54 +01:00
Harald Welte f396b96e66 card_fs_usim.c: Add support for DF.5GS directory
card_fs_usim already contained definitions up to Rel-15, but somehow
didn't add the DF.5GS yet.

Change-Id: I9f8102dc7e5a865193ff9930dfc48c5f2e6ecbcf
2020-11-10 15:33:49 +00:00
Philipp Maier a15967ba98 gsm_08_58: add proprietary IE to signal Repeated ACCH Capability
3GPP TS 24.008, section 10.5.1.7 specifies a Repeated ACCH Capability
bit in the Classmark 3 IE. Unfortunately, there is no way specified how
the Repeated ACCH feature should be controlled on RSL level. Since it is
not unusual that BTS/BSC vendors occassionally add proprietary IEs to
different RSL messages we may pick this as a solution as well and add a
propritary RSL_IE_OSMO_REP_ACCH_CAP IE, so that we can enable repeated
FACCH/SACCH on the BTS side when we send RSL CHAN ACT or RSL CHAN MODE MODIFY
messages.

Change-Id: I61ea6bf54ea90bd69b73ea0f0f3dc19a4214207b
Related: OS#4796 SYS#5114
2020-11-09 23:41:10 +01:00
Alexander Couzens 0ab028c84e ns2: fixup gprs_ns2_prim_strs
The gprs_ns2_prim_strs was merged to early. The renaming
in the last gerrit patchset wasn't done correct.

Change-Id: Ie8e1e003d70af48f2d647b2c2701d4fc0f17e307
2020-11-09 11:07:17 +00:00
Pau Espin 64c67bb088 vty: Mark cpu_sched_vty commands with attr immediate
Change-Id: I85c80376c13c7dddf34dadd2a6c09caf23fd70ce
2020-11-09 11:24:21 +01:00
Daniel Willmann ed1fa018c3 ns2: Improve NSVC output
In show ns lots of info was printed many times. We can just use
gprs_ns2_ll_str() to get the information about an NSVC so use that and
ensure newlines.
The NSVC are still printed twice - at least for the UDP bind: Once in
dump_nse and once in dump_bind.

Change-Id: I6f734d92ec1e17f339f7b32e449ffd614efa7319
Related: SYS#4998
2020-11-06 15:40:27 +01:00
Daniel Willmann 15c09a81e9 ns2: Send NSVC representation in NS_AFF_CAUSE_VC_* status indication
NS_AFF_CAUSE_VC_* failure and recovery should indicate the NSVC in
question. Use the string representation reported by gprs_ns2_ll_str()
for that.

NS_AFF_CAUSE_VC_RECOVERY was never sent so do that on unblock as well.

Change-Id: Iad6f0dc4565a46868cbbe17c361dcd473006c83d
Related: SYS#4998
2020-11-06 11:41:16 +01:00
Daniel Willmann f128654c7f ns2: Add gprs_ns2_nsvc_state_name() to get the current state of a VC
Change-Id: I4c4c5b9142d7240ed452218e263ba12e2b70d1a0
Related: SYS#4998
2020-11-06 10:23:44 +00:00
Alexander Couzens cce8828238 libosmocore: change the memory management of NS2
Until now NS2 always free'd it's own memory. Even when the msg
was sent as primitive to the upper layer.
Change the memory ownership when sending a primitive to the upper layer.
The upper layer has to free the msg buffer.

Merge together with: I180433735bfbb3375c41318d7a7709d5845199ba (osmo-pcu)

Change-Id: Id844d7acbcab102a7dc472d608a5e97a748ecb43
2020-11-03 22:37:45 +00:00
Daniel Willmann 2d42b90dbb libosmogb: Add a function to tx BVC RESET by nsei/bvci
This is needed for osmo-gbproxy where we need more control over BSSGP.

Related: SYS#4998
Change-Id: Ifa769bce920a08cf93553dcb164a3fcf50162517
2020-11-03 10:14:00 +00:00
Vadim Yanitskiy f5f0d4304a gsm48: add missing RR cause value definitions
3GPP TS 44.018 version 15.4.0 Release 15 (2019-04).

Change-Id: If7187e005d65fd2bf067d258148281c5df0526ff
2020-10-29 18:23:06 +07:00
Vadim Yanitskiy 65954bac13 fix spelling in 'value_string' arrays: existAnt -> existEnt
It could be that this spelling variant was originally used in the
specs., but now at least in 3GPP TS 44.018 they use 'existEnt'.

Change-Id: I847de910411f2edf7cc45b8c296b43e65fed5447
2020-10-29 18:09:36 +07:00
Alexander Couzens b3b837c5e8 gprs_ns2: convert gprs_ns2_cause_str into an static inline
Be consistent with other implementation of get_value_string() in
libosomocore.

Change-Id: Ic79757df8683e0461c04f7ef9279e4fe645eb821
2020-10-27 14:49:03 +00:00
Alexander Couzens 2498f1db9d ns2: add value strings for ns2_affecting_cause_prim_str & ns2_prim_str
Change-Id: Ibf610fbd929dddc4a4e235152447caff522d4eb2
2020-10-27 15:24:47 +01:00
Alexander Couzens 0346b643b5 gprs_ns2: remove the nsvc fsm timer when cleaning up the fsm
Change-Id: I9c7f767077ed2e354d0980a9f11246c1151c65e2
2020-10-27 13:53:08 +00:00
Pau Espin 0a446a1804 gb: ns2_sns: Add missing value_string entry for GPRS_SNS_EV_NO_NSVC
Change-Id: Ifd4501676217f1a27f3ee02156be4e3dcb847703
2020-10-27 13:30:08 +01:00
Pau Espin 7fbe7cfcd7 gb: ns2_sns: Fix missing trailing newline char in log line
Change-Id: I8dc45237a605e76e852a74a0de91ac2a812387d0
2020-10-27 13:27:18 +01:00
Vadim Yanitskiy 0a2d9bdfae vty/command: fix: restrict the expert mode to the current session
Having the expert mode flag stored in the global 'host' structure
was a bad idea, because this way it applies globally.  In other
words, if user Bob activates the expert mode in his dedicated
session (e.g. a telnet connection), then not only him, but all
other users would see the hidden commands in their VTYs.

Moreover, if somebody deactivates the expert mode, it would also
affect the Bob's VTY session.  And finally, terminating a VTY
session would not deactivate the expert mode.

Let's move that flag from the global 'struct host' to 'struct vty'
representing an individual VTY session, so then the expert mode
would only affect the session where it was activated.

In functions related to the XML VTY reference generation we don't
have access to 'struct vty' (there may be no VTY session at all).
Add two additional arguments to vty_dump_nodes(), indicating the
global flag mask and a matching mode.  This would allow to match
the VTY commands in many different ways, e.g. one can dump hidden
commands only, or all commands except the library specific ones.

Change-Id: Iba13f0949061e3dadf9cf92829d15e97074fe4ad
Related: SYS#4910
2020-10-25 16:52:42 +07:00