Commit Graph

190 Commits

Author SHA1 Message Date
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 e416069cf6 sbcap: Fix typo in comment
Change-Id: I6d519cb80a90e2a7e80e4608c713996f94043f21
2022-07-27 13:42:17 +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 745a2d6600 sbcap: Tx Error ind if Rx ProcedureCode is unknown
Change-Id: I3ee760b98d87f179917acbc369f56d72d0db571d
2022-07-27 13:42:17 +02:00
Pau Espin b093e6708d sbcap: Improve logging on non-implemented PWS Restart/Failure Ind
Change-Id: I0085ac40a7676d9c3626a9da38d02d3b1b2cf6b4
2022-07-27 13:42:17 +02:00
Pau Espin 66625de21c sbcap: Improve logging of rx Error Indication
Change-Id: I63871a57f219a98f8191e6ee4787fc33edb21528
2022-07-27 13:42:06 +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 692243baf5 sbcap: Fix typo in sbcap_cause_vals
Change-Id: I519a86e5292c39bf1ad502c587838e7b62a0e64f
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 4dd20eec56 vty: Fix typo in vty output
Change-Id: I601f9ebcf17c5129edbce5b3ac7f0fd8294dd572
2022-07-26 08:04:06 +02:00
Pau Espin 9144fd1fd8 sbcap_msg: Improve spec references for used IEs
Change-Id: I55749aa84415e0af240c3cc46f2b274e1d24e403
2022-07-26 08:03:33 +02:00
Pau Espin 3c804efcc6 vty: Print created and expired times for each message
This also allows differentiating between expired and active
messages.

Change-Id: I9ee49b99546a44be706700c3db94d45210c47e54
2022-07-26 08:03:33 +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 56d1ef3b52 cbc_vty: Fix missing indent char in dump_one_etws_msg
Change-Id: I8cdced4fa108dede8d5f5dba37dde9cb199198ab
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 5044524f01 cosmetic: smscb_message_fsm.c: Fix typo in comment
Change-Id: I2eb15c2401efa9b07a51dbe71997da01aab30bba
2022-07-25 14:27:48 +02:00
Pau Espin 3468e90ab3 sbcap: Fix encoding of Warning-Type
Change-Id: I9f6a0779c20ba86962aaaebc9b40ad162d2f2f3e
2022-07-25 14:27:48 +02:00
Pau Espin 028b48b967 cbc-apitool: print usage instead of crashing if no subcmd passed
The "required" param was added in python 3.7.

Change-Id: Ia8d13beeb8da64644d1aaf36deeddda4de889a6c
2022-07-25 14:27:48 +02:00
Pau Espin 01338add1d cbc-apitool: Fix port stored in var as a string
Passing "-p 12345" on the cmd line, fixes:
"""
  File "/osmo-cbc/contrib/./cbc-apitool.py", line 20, in build_url
    return "http://%s:%u%s%s" % (server_host, server_port, BASE_PATH, suffix)
TypeError: %u format: a real number is required, not str
"""

Change-Id: Ief688bb8c2a6cfa410608a6896ce3cb5df4eb48e
2022-07-22 17:58:33 +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 d462e452e1 vty: Define peer proto during 'peer' node cmd
This way we lock the type (proto) of each peer at creation time.
Otherwise, having the possibility of changing the protocol of the peer
makes all the code too complex and there's no good way to prevent the
protocol from being changed at any time creating unexpected issues.
If the user wants to change the protocol, she can do so by removing the
peer and re-adding it through the VTY with the desired protocol.

Change-Id: I47756dddd8f9b8450ba14c914614fd2391d5486e
2022-07-22 14:16:10 +02:00
Pau Espin b05a9a6615 cbc_main: Fix setting default SBc-AP local address
The issue was not spotted until now because until recently
cbc_vty_go_parent was not called due to another bug.

Change-Id: I697597438d8c45f5956b12e2a6ea76413e945e5e
2022-07-22 14:16:10 +02:00
Pau Espin 54f50a4857 Fix cbc_vty_go_parent() not being called
Change-Id: I946c503f5a40eafbee6e7fa359781548b74e45a6
2022-07-21 21:50:04 +02:00
Pau Espin 7a8a388edf Make cbsp,sbcap mgr available in data model
Change-Id: I60c3ded80c38bcf50b831c6e9db719a8d2cba5b1
2022-07-21 20:39:23 +02:00
Vadim Yanitskiy bc606f8ea1 cbc_vty: use install_element[_ve](), not install_lib_element[_ve]()
As the naming suggests, install_lib_element[_ve]() should be used
for commands registered by libraries.  This API allows to enforce
some rules for command attribute letters and should not be used
by application specific commands.

Change-Id: I8c0c8ac66dfc4fc2b8bf9102fba0df2dd988e7c9
2022-07-21 20:33:42 +02:00
Pau Espin b4f7404b6c cbc_vty: write peer config nodes at the end
This way we end up with more "global" configs at the start of the file,
which are read/applied first, and later all the per-peer information,
which is a list of variable length.

Change-Id: I7623ea5874552e57764327e94a9c3a4de7b71d67
2022-07-21 20:33:42 +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 85bc27d394 cbc_vty: print correct protocol when writing config
Change-Id: Id9fc0b42827f9a74ff1de4b35339de02aeeefee2
2022-07-20 21:02:53 +02:00
Pau Espin 053018abeb cbc_vty: Use value_string to define proto names used in vty
This will be used in other places in a follow up patch.

Change-Id: I125c7e5ca1f86c2ef390a85975465330c3ae1eb0
2022-07-20 21:02:21 +02:00
Pau Espin 351b2c8c2b Use cbc_{cbsp,sbcap}_link_close when possible
This way we abstract whether the underlaying stream is a TCP/SCTP client
or server.

Change-Id: Ie020b9b5ee93ae8d0c9e7266177728185e8635f2
2022-07-20 20:27:50 +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 0f17a212d1 cbsp_server.c: Drop unused code
This will be properly implemented soon.

Change-Id: I5165e3c64d2c933027019264f68f94fb0c18e0e9
2022-07-20 19:48:02 +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 f9d73a1cc1 cbc_peer: Close SBcAP conn when removing active peer
Change-Id: I50751856ba10640ecf036ab587c5e821d37863e2
2022-07-20 19:23:27 +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 f4741401e2 sbcap_server: Fix double-free of rx msg if conn is destroyed
In sbcap_cbc_read_cb(), if sctp_recvmsg() fails and we end up calling
osmo_stream_srv_destroy(conn), then both conn and client will end up
being freed by sbcap_cbc_closed_cb(), so we cannot use them anymore
after calling osmo_stream_srv_destroy(conn).
Furthermore, since msg was allocated with "client" ctx as parent, it
would also be freed when "client" was freed.
Let's make the logic easier and alloc it under g_cbc, which is
guaranteed to always be kept there.

Change-Id: I201f44efa24a514e0087b6dcd01115b9b2b8e9db
2022-07-20 17:58:45 +02:00
Pau Espin f955099737 sbcap_server: Log all sctp notif
Change-Id: Ibe73f1e976f088154c2a20e2c7dd98b39a475c08
2022-07-20 17:58:45 +02:00
Pau Espin 5c39ea182d sbcap_server.c: Remove unneeded goto
Change-Id: I02cf8e7ec05d5189d9c6dcc9a7b1e4def80220d7
2022-07-20 17:58:45 +02:00