Commit Graph

1452 Commits

Author SHA1 Message Date
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
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
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
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 412bc3494d gprs_ns2: add new vty2
Change-Id: I163279cf57e84198dc8c53e1c109f5a9474670e9
2020-12-22 16:36:19 +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
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
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 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 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 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
Vadim Yanitskiy c8158ecfc4 protocol/gsm_08_58.h: add Osmocom specific EWMA AVG algo
Change-Id: Ib436fd8b81afdb06c6d936f6839f847a705d00e2
Related: SYS#4918
2020-12-15 09:52:42 +00:00
Vadim Yanitskiy a346c45ceb protocol/gsm_08_58.h: add ip.access Power Control structures
Change-Id: I9430bcb79c269efb4f9527f565cf4e12e4444940
Related: SYS#4918
2020-12-15 09:52:42 +00: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 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
Harald Welte dec201a606 tlv.h: Add msgb_tvlv_put_{16,32}be()
Those routines are very useful when puzzling together BSSGP messages
with 16-bit and 32bit sized IEs.

Change-Id: I033f9a708c9d7ffad91336178231dc66233e1693
2020-12-08 21:37:45 +01:00
Harald Welte a6f896232e gsm_08_18.h: Add #defines for [extended] feature bits
Change-Id: I7743cb901988c8fddd91127cfdca6e54b3d44ea8
2020-12-08 12:27:38 +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
Pau Espin Pedrol 896a9bb2ed Include mnl.h iif --enable-libmnl
Change-Id: I06016e3a6e90b09b76634a00081d0d40a8e2f94b
2020-12-07 13:24:30 +01:00
Harald Welte 7fc88b3248 log2.h: Avoid redefining __always_inline
/build/deps/install/stow/libosmocore/include/osmocom/core/log2.h:10:0: error: "__always_inline" redefined [-Werror]
 #define __always_inline               inline __attribute__((always_inline))
/usr/include/x86_64-linux-gnu/sys/cdefs.h:311:0: note: this is the location of the previous definition
 # define __always_inline __inline __attribute__ ((__always_inline__))

Change-Id: I738d2a72f835a29e30b8ba20456e5c4c9aa844c9
2020-12-06 15:45:52 +01:00
Harald Welte c172d9fe8d log2.h: Use uintXX_t instead of kernel specific types
Change-Id: Ieb872551bdbe514f2c77f9aeb2b9ee42f6573909
2020-12-06 15:14:35 +01:00
Harald Welte 622cda3802 hash/log2: Add generic implementations of fls() and fls64()
When importing the hashtable code in I8ef73a62fe9846ce45058eb21cf999dd3eed5741
I didn't import actual implementations of the fls() and fls64()
implementations, as at least gcc-10 was smart enough to detect
we only use it on constant types and hence the computation can happen
at build time via const_ilog2()

However, in our jenkins build verification' this doesn't appear to
happen, as we get below errors:

/build/deps/install/stow/libosmocore/include/osmocom/core/log2.h: In function ‘__ilog2_u32’:
/build/deps/install/stow/libosmocore/include/osmocom/core/log2.h:20:9: error: implicit declaration of function ‘fls’ [-Werror=implicit-function-declaration]
  return fls(n) - 1;
         ^~~
/build/deps/install/stow/libosmocore/include/osmocom/core/log2.h: In function ‘__ilog2_u64’:
/build/deps/install/stow/libosmocore/include/osmocom/core/log2.h:28:9: error: implicit declaration of function ‘fls64’ [-Werror=implicit-function-declaration]
  return fls64(n) - 1;
         ^~~~~

Let's provide some generic implementations for this case.  If needed
one could also introduce architecture-specific assembly implementations
like in the Linux kernel, but so far we managed to keep libosmocore free
of any assembly tweaks.

Change-Id: Ifa4898eb66c8d949618edd47961b7a0330ed35b5
2020-12-06 14:40:55 +01:00
Harald Welte c22e002890 gsm_08_18.h: Add some PDU definitions still missing
In I7da8b25c9a89a7e3ae6c1680ba838e136d7d5293 I seem to have failed
to realize that 3GPP TS 48.018 v15.0.0.0 Table 11.3.26 continues
on yet another page.  Let's add those missing PDU types definitions.

Change-Id: I9173c35240ff78048b2b76a1155d90467ef16b2d
2020-12-06 12:56:29 +01:00
Harald Welte 77530b4619 Use explicit type-casting in hlist_del() for C++ compatibility
/usr/local/include/osmocom/core/linuxlist.h:479:12: error: invalid conversion from ‘void*’ to ‘hlist_node*’ [-fpermissive]
  479 |  n->next = LLIST_POISON1;

Fixes: I8ef73a62fe9846ce45058eb21cf999dd3eed5741
Change-Id: I75b0a5fe097562007c53987d8d41811e9f35798d
2020-12-05 20:16:51 +01:00
Vadim Yanitskiy 59e13e4d25 core/linuxlist: do not use 'new' as a parameter name
'new' is a reserved keyword in C++, so including this header from
a C++ project (like osmo-pcu) breaks compilation.  Let's rename
it in the same way as it's already done in this file: add '_'.

Change-Id: I7f7d9143edca75ce932601386a8766b0a62c0e24
Fixes: I8ef73a62fe9846ce45058eb21cf999dd3eed5741
2020-12-05 15:07:51 +01:00
Harald Welte 7101ca2751 Add hlist and hashtable from Linux kernel
For more than a decade we've used the linuxlist.h for double-linked
lists.  Let's also add the hlist (double-linked lists with single
pointer sized head, and the hashtable that builds on top of it.

This reflects the versions included in Linux 5.8 with some modifications
to make them build in userspace (remove RCU versions, adjust for
userspace include files and types, convert to doxygen).

Change-Id: I8ef73a62fe9846ce45058eb21cf999dd3eed5741
2020-12-05 11:39:42 +01:00
Harald Welte e3b20edec5 bssgp: Fix typo in BSSGP Message Type enum
Change-Id: I63941f8b38485e569f56ba5065c2c00232703028
2020-12-04 18:20:15 +00: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
Harald Welte 6e887ebd3e gsm_08_18.h: Update enums for message types and IEs with Release 15
Lots of newly introduced message types and information elements.

Change-Id: I7da8b25c9a89a7e3ae6c1680ba838e136d7d5293
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
Daniel Willmann fd3478ca4f logging: Calculate LOG_MAX_{CTX,FILTERS} from the enum
Change-Id: I1ee1278b029e42321932b87f94aa3e0eeed4108a
Related: SYS#5232
2020-12-02 18:14:17 +01:00
Harald Welte a20248a361 cosmetic: frame_relay: Fix typos
Change-Id: Ifc29ddb43745571096b458393692a68052898daa
2020-12-01 18:01:43 +01:00
Pau Espin bfcce40618 gsm: Add enum for Network Feature Support IE
Change-Id: Ie409fd163b612bc3e2d7b8bf22d720705f0f6af1
2020-12-01 11:26:57 +00: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
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