Commit Graph

35 Commits

Author SHA1 Message Date
Pau Espin 7fbd6aa472 Catch and forbid configuring peers before configuring main protocol node
When the user enters each "peer" node, the related object is created if
not yet existing, and its updated config is applied (connect()) upon
exiting the node (cbc_peer_apply_cfg_chg()). When connect happens, it
needs to obtain the local IP address from the main protocol node
(cbsp|sbcap)", which means it must be configured beforehand, otherwise
the peers connect using the default values.

Hence, it makes no sense to configure peers if the main protocol
information has not yet been configured. The usual example configs as
well as the write-config VTY commands provide correct order of things.
Catch and forbid the user providing a config file where the peers are
configured before the main protocol nodes.

Related: OS#6154
Change-Id: I678f9e6715c85b1eb9116cc892f1a8299577c0c2
2023-08-29 17:26:56 +02:00
Pau Espin 292b2e895b sbcap: Update asn1c skeleton files
Update skeleton files using newest asn1c with APER support [1],
commit 08b293e8aa342d465d26805d1d66f3595b2ce261.

This contains among others, fix to automatically disable stack overflow checks [2]
when using ASan, in order to avoid failing during unit test run.

[1] https://github.com/mouse07410/asn1c/tree/vlm_master
[2] https://github.com/mouse07410/asn1c/pull/128

Related: OS#6025
Change-Id: I385d14d4be308b991a48ce1033087f07bd1f47ea
2023-05-15 17:34:45 +02:00
Pau Espin e86af042fd Propagate error to caller when tx cbsp/sbcap Write-Replace-Req fails
Change-Id: Ie40c8e41c297398bbec48f7bb2c60cfdc703fa5d
2022-07-29 17:55:33 +02:00
Pau Espin d24c3dfba0 Split smscb_peer_fsm into CBSP and SBcAP specific FSMs
This further simplifies tracking of events and simplifies and clears
code on each of the FSMs.

Change-Id: I0fd00b60cdc6bc6a088be1336d849548ca89c847
2022-07-29 14:54:26 +02:00
Pau Espin c190939f0c Split event list for smscb_message_fsm and smscb_peer_fsm
It really doesn't make sense to share the event list betwen those for
several reasons.
First, because ech of those FSM relate to different things:
* smscb_message_fsm: Handling/scheduling of 1 smscb towards all peers
* smscb_peer_fsm: Handling/scheduling of 1 smscb towards 1 peer.

The former has higher level interface used by the REST
API, plus some mid level interface used by smscb_peer_fsm.
The later has a mid level interface used by smscb_message_fsm to
interact, and a lower level interface used by the SBcAP/CBSP links to
talk to.

Furthermore, this makes it a lot easier understanding which events are
sent from one to another FSM.

Change-Id: I909474d1ff4ec7ed20aff0981da47074397df6cb
2022-07-29 14:49:30 +02:00
Pau Espin cb99991127 Introduce logging category smscb
The smscb_message_fsm is totally independent of CBSP.

Change-Id: I6e686747ddde9540ff3f765ef461bfca812615ba
2022-07-29 14:49:30 +02:00
Pau Espin d8a537aca8 sbcap: Store reported failed TAIs from WriteReplaceResponse in cbc_message_peer
Change-Id: I37b08aa374c1097d2871bf69a7bb7893f32bccd3
2022-07-29 14:49:30 +02:00
Pau Espin 4a9d22e5a0 sbcap: Request and handle Write Replace Warning Indication
Change-Id: I563e7d1c999f14b8197bb41e85b7bcf6262fe2a0
2022-07-29 14:49:30 +02:00
Pau Espin 1429377005 Move ASN1C enc/dec logging to its own category
ASN1C encoding/decoding can get really verbose. Furthermore, it should
only be enabled under really specific conditions, so it makes sense to
have it under its own category.

Change-Id: Ia4cbae2395532d9b5b7b9177a7d0f31bf777d751
2022-07-29 14:49:30 +02:00
Pau Espin bc21b3ae81 Move cbc_cell_id2str() and make it public
It will be used later on to log whenever new cell ids are added to a
message_peer.

Change-Id: I74ccbbc810a2fa76fb2999a7588b3f67d4d21e03
2022-07-29 14:49:30 +02:00
Pau Espin ab8b8402a4 sbcap: Log info about messages received and trasmitted
Change-Id: Ifd1eca79bf4fac63de8066cd6a18004138d51d04
2022-07-29 14:49:26 +02:00
Pau Espin e67faef4ec Move sbcap_as_find_ie() to libsbcap
This function is generic and can be (will be) used in more places.

Change-Id: Ib0c7fa12a8f6faa4271e4132ca5a5c656e717400
2022-07-27 13:42:17 +02:00
Pau Espin 6db8c13fea sbcap: Drop unused events
Those events doesn't exist in SBc-AP.

Change-Id: Ie4843ed5debbd4282df487ada9596b4d75f4b46c
2022-07-26 14:33:47 +02:00
Pau Espin 3f9d78e2a3 sbcap: Send Error Indication if decoding rx msg fails
Change-Id: I444290f3d697e7485e04eaa38acd8fc3623e0eab
2022-07-26 14:33:47 +02:00
Pau Espin 9ce5d4bad7 Rename functions generating CBSP/SBc-AP Write-Replace request
Previous naming is misleading, as it seems to indicate the function is
used to generate any kind of message, which is wrong.

Change-Id: Ib0228c64bbf104accdbbebb6076004a6a1f44c6f
2022-07-26 14:33:43 +02:00
Pau Espin 7beca6fda0 Rearrange cbc_message and cbsp message code
Move code from message_handling containing both code for generic
cbc_message and specific cbsp_message into thers files. The former are
moved to cbc_message.c and the later to cbsp_msg.c, similar to what's
already done for SBc-AP messages.

Change-Id: Ie4082e40f23170cfd6c573fbbb7beb8c6226b6e6
2022-07-26 10:01:05 +02:00
Pau Espin 5ae411980b vty: Add command to delete expired messages
Otherwise there's no way to remove expired messages, which keep filling
the expired list forever.

Change-Id: Ie7ed2d9ec8fc23cdc4cb007dce4150458085a6a3
2022-07-26 08:03:20 +02:00
Pau Espin 93a588ba60 vty: Fix 'show message' not finding expired messages
Change-Id: I23523876f1df167e8afd730b2164f133c2776085
2022-07-25 16:27:26 +02:00
Pau Espin 3ef5020007 Support CBSP/TCP and SBc-AP/SCTP client mode
This patch adds support to set up a CBSP link so that osmo-cbc connects
as a TCP client to the BSC, which runs as a TCP server.
Similary, support to set up a SBc-AP link so that osmo-cbc connects
as a SCTP client to the MME, which runs as SCTP server.

A new "mode (client|server|disabled)" VTY command is added to use one
mother or the other, and also to disable the link and hence the peer
until it is set again. This is useful if the peer is under manintenance
for instance.

client sockets are created automatically when the "peer" vty node is
exited if the link is not yet created, hence creating it at startup or
if moved back from "disabled" mode. If client socket dies, it will
keep attempting reconnect every 5 seconds.

Related: OS#4945
Change-Id: I3ec54b615b41b56f7a9c64298e3fcaac37f4b60e
2022-07-25 16:27:26 +02:00
Pau Espin a97e166ee7 Split cbsp/sbcap server socket creation from struct allocation
This will be needed when we add client support, since clients will
require the mgr structs to be available during VTY parsing.

Change-Id: I14e49d8d2e603925d7f06a7edb710c0eceb02ea3
2022-07-22 16:13:15 +02:00
Pau Espin 5661cef889 Move struct cbc bring up code to its own file and functions
This way it's clear and we have in one place all the related code that
neds to be run at a given time.t

Change-Id: I00fe755340664d4ca4a5cfdcae8d4cd33b2f40a1
2022-07-22 15:45:09 +02:00
Pau Espin 7a8a388edf Make cbsp,sbcap mgr available in data model
Change-Id: I60c3ded80c38bcf50b831c6e9db719a8d2cba5b1
2022-07-21 20:39:23 +02:00
Pau Espin 678a9cb385 Refactor {cbsp,sbcap}_cbc_accept_cb
Delay allocating the structures until really needed.
First do checks agains the opened connection, and if an issue is
detected simply close the fd.
Next, fetch or allocate the related peer.
Finally, create the link from the fd.
This makes it easier to add early extra checks later when peers will
contain info on link_mode (client|server|disabled) later on.

Change-Id: Id4f83ec6b0b14e556b1caa9c80e7f68d062fec57
2022-07-21 20:33:38 +02:00
Pau Espin 907c4013c4 Rename fields in cbc_{cbsp,sbcap}_mgr
* link -> srv_link to avoid confusing with cbsp/sbcap links
* clients -> links, since it holds links, which in the future will be
  both TCP/SCTP clients and servers.

Change-Id: I4717f49413af45b45059c1601a667f4161b4ca8a
2022-07-20 20:16:35 +02:00
Pau Espin 5f6dfe77d4 Rename {cbsp,sbcap}_server(_fsm).h s/server/link/
Change-Id: I1e56dd1fcba23f6efd209e9d4dcdc88c8866d250
2022-07-20 20:10:16 +02:00
Pau Espin d3be026b93 Rename CBSP,SABP,SBcAP structs and APIs
Rename osmo_*_cbc -> cbc_*_mgr:
Now they only hold TCP/SCTP server related conns, but will also hold
TCP/SCTP client conns in the near future.

Rename osmo_cbc_*_client -> cbc_*_link:
The term "client" is confusing, since it doesn't exist in CBSP/SBcAP,
and will later support connecting to server at TCP/SCTP level.
Let's use "link" instead, similar to what's used in osmo-bsc which
already supports both TCP client and server modes.

Change-Id: Ia9d26dc1593c8ee08dce348fe9f5f4c9398ea2a5
2022-07-20 20:10:13 +02:00
Pau Espin 782d431068 sbcap_server.h: Remove unused fields
Change-Id: I3086a264557b976985d166e56fb7f70ad96b81df
2022-07-20 19:23:36 +02:00
Pau Espin 881d5bab4b Get rid of internal.h
Let's create missing header files and move stuff around to have a clear
view of who implements what.

Change-Id: Ib32091d716b33bca58e2d3acf8840b52824c0bd3
2022-07-20 19:23:36 +02:00
Pau Espin 36be606dd4 Split cbc_message related code to its own .c and .h file
Change-Id: I41f6e169b1ee6731cd472f6b72ea922260e30ceb
2022-07-20 19:23:36 +02:00
Pau Espin 28ccced217 Move vty stuff to its own header cbc_vty.h
Change-Id: Ib793a74befb7eaad66d19967c28acb4baf52ea69
2022-07-20 19:23:36 +02:00
Pau Espin a346b88b42 Move function defined in rest_it_op.c to rest_it_op.h
Change-Id: I434357d995a3c90342dbc7d2ac7e568c049ff7ae
2022-07-20 19:23:36 +02:00
Pau Espin 1486ac0191 Split cbc_peer to its own .c and .h files
Change-Id: I41c890d81e76ac1a1c89d42af70a1f0631e9724e
2022-07-20 17:58:45 +02:00
Pau Espin 6e59534d6b Add initial SBc-AP support to osmo-cbc
This patch makes use of the newly introduced sbcap library, and
introduces new code (and extends existing one) to handle all the aspects
of MME peers talking SBc-AP and its underlaying SCTP connection.

This commit doesn't aim to implement all the SBc-AP features, but to
implement a minimal subset of features already available for CBSP in
osmo-cbc, in order to have similar support level for both 2G and 4G
networks.

Related: OS#4945
Change-Id: Ib278bc1d1a74459814016fef7a8fe21cc29d46c9
2022-07-19 09:10:12 +00:00
Pau Espin 4b8175d189 Add sbcap library
This commit adds initial support to encode/decode SBc-AP messages in the
form of a library, under src/sbcap/ (includes in
include/osmocom/sbcap/).
asn1c is used to generate all suport code and structures for ASN.1 APER
encoding/decoding, based on asn files obtained from 3GPP TS 29.168 and
stored under src/sbcap/asn1/.
Currently, mainstream asn1c doesn't yet support ASN.1 APER
encoding/decoding, hence mouse07410 's fork is used [1]. Furthermore,
several encdoing/decoding bugs where found during the process and fixed,
which means asn1.c git >= 30219de2d3da888b4f1eea0dd79f2a505000401a must
be used to generate proper code.

A new "make -C src/ gen" target is added which can be used to regenerate
all C code from the available ASN.1 files in src/sbcap/asn1/*.asn (after
properly setting configure.ac ASN_* variables if needed).

[1] https://github.com/mouse07410/asn1c

Related: OS#4945
Change-Id: If76f8619a9b2d46af6d94b8ae49348b8514e53aa
2022-07-15 15:53:35 +02:00
Pau Espin 8dc5648176 Move header files to include/osmocom/cbc/ dir
Change-Id: Id6c9f99805169d624a2c6e001fe1983e24fdc5c3
2022-07-04 13:35:47 +02:00