Commit Graph

3701 Commits

Author SHA1 Message Date
Daniel Willmann c4426d382b WIP Fix
Change-Id: Ibb832a39876362d094cce635192f7b4f84dc2b10
2021-01-14 18:32:43 +01:00
Pau Espin dec7b8c238 ctrl: ports.h: Add OSMO_CTRL_PORT_BSC_NEIGH
Hence 4248 becomes the well-known port for osmo-bsc's Neighbor
Resolution Service.

Related: SYS#4909
Change-Id: Ic77a8cff022c2f939a684ebd1f9f62a82e0de510
2021-01-13 14:48:53 +01:00
Harald Welte efdd641c29 tlv_parser: Fix various out-of-bounds accesses
The libosmocore TLV parser had a number of insufficient bounds checks
leading to reads beyond the end of the respective input buffer.

This patch
* adds proper out-of-bounds checks to all TLV types
* simplifies some of the existing checks
* introduces test cases to test all the corner cases
  where either TAG, or length, or value are not fully contained
  in the input buffer.

Thanks to Ilja Van Sprundel for reporting these problems.

Change-Id: I98b02c914c9e3ecf56050af846292aa6979d7508
2021-01-12 21:11:20 +01:00
Pau Espin ca33a71ca8 Intoduce Packet Switch CGI
This structure is needed in order to identify a given cell within the
BSS during RIM transactions.
The naming was made up by myself since I couldn't find any naming
reference for this kind of data (RAI + CI).
Since LAI + CI = CGI, then RAI + CI = CGI-PS

osmo_rai_name2 family of functions get a "2" suffix due to already
existing functions handling struct struct gprs_ra_id in gsm48.h

Change-Id: If48f412c32e8e5a3e604a78d12b74787a4786374
2021-01-11 14:22:21 +00:00
Vadim Yanitskiy e2ad6ebb7a gprs_bssgp: abuse gsm48_encode_ra() to encode TAC
Both LAC and TAC take 2 octets and follow MCC/MNC fields on the wire.
We abuse gsm48_encode_ra() for encoding of MCC/MNC, but it can also
be abused to encode TAC in bssgp_create_rim_ri().  There is no need
to encode '0000'O and then override it with osmo_store16be().

Change-Id: I986552aa52cf38b1c5290d2e5cd3ff2d1c36a4e5
2021-01-11 14:21:21 +00:00
Harald Welte 5d797c4264 Revert "pkgconfig: link to mnl if available"
This reverts commit 2253224b33.

Reason for revert: Causes massive build failure for osmo-pcu and osmo-sgsn on all the distributions/architectures we build for

Change-Id: I6dbe4507701bee013b29dcc26f32c4e1a3c23613
Closes: OS#4936
2021-01-08 10:14:02 +00:00
Daniel Willmann 09bea0152a bssgp_bvc_fsm: Handle block request from application correctly
This is no event from an incoming message so rx is NULL, and we can't send a
status PDU. Also blocking the signalling BVC is not allowed (unblocking it is already
forbidden).

Change-Id: I3e384b71d57e939efc1596ac1d92380ed5eb916d
Fixes: CID#215716
2021-01-07 18:57:57 +00:00
Daniel Willmann 210774f60b ns2_frgre: Fix missing break statement for recv from IPV6
Change-Id: I549277483fee55f390e0b5ae1dafec6f2d68eae7
Fixes: CID#215836
2021-01-07 18:57:28 +00:00
Daniel Willmann 7dccf8ede5 logging: Remove duplicate color for DLSMS
Change-Id: Ia797efce36e0afff74de54374d568521ecedf486
2021-01-07 18:57:18 +00:00
Eric Wild 2253224b33 pkgconfig: link to mnl if available
The dependency on mnl breaks builds of osmo-pcu et al if mnl is used for
libosmogb, but not linked in for lib users

Change-Id: Ib4df95d5c922f8edfa33e68645652fd30d321ff8
2021-01-07 14:28:42 +00:00
Vadim Yanitskiy 7e104d96ba bts_features: s/Repeation/Repetition/ in osmo_bts_features_descs[]
Change-Id: Ia8c77766842ce80eae969774959cbf46e86f97b9
2021-01-07 14:22:56 +01:00
Philipp Maier cea0c30507 gsm_08_18: add struct to parse RIM PDU Indications
3GPP TS 48.018, section 11.3.65 describes an IE to transfer some control
flags via a RIM container. The IE is essentially just a bitfield, so it
can be parsed by overlaying it with a C-struct. Lets add an appropiate
struct to protocol/gsm_08_18.h

Change-Id: I781ab838bd02ac1b13d384ce3f4259e26cedb61e
Related: SYS#5103
2021-01-06 18:33:42 +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
Pau Espin Pedrol 463dca0b9c gitignore: Ignore *~
They seem to be generated by newer versions of autofoo.

Change-Id: Ia4514da3c3dcbc383487a3d98b322a5ecb918568
2021-01-05 18:39:37 +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
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