Commit Graph

17 Commits

Author SHA1 Message Date
Oliver Smith 499e1117a6 Support forwarding messages with multiple BSCs
Implement a proper subscriber connection mapping. Create a new
subscr_conn when one of the stored BSCs sends a conn.ind and use that
subscr_conn for all related connection-oriented messages with the same
RAN-side conn_id to send messages back and forth between BSC and MSC.

Add subscr_conn_get_next_id based on OsmoBSC's
bsc_sccp_inst_next_conn_id.

With this patch, it's possible to do a successful Location Updating
procedure between MS2 and MSC in the following network:

  MS1 --- BTS1 --- BSC1 --.
                          BSCNAT --- MSC
  MS2 --- BTS2 --- BSC2 --'

Related: SYS#5560
Change-Id: I1556aa665fbb0a97507f98794e74820731fa6935
2022-03-21 16:36:32 +01:00
Oliver Smith 1968ca922b sccp_sap_up_ran: ignore RAN until MSC is connected
Related: SYS#5560
Change-Id: Idf9501412484fa92e8836952609fba7c5443d6c9
2022-03-21 16:36:32 +01:00
Oliver Smith 70cd49dcae Send RESET to MSC on start up
Automatically send RESET to the MSC as the BSCNAT starts up. Try it
again if it fails, in case the MSC was not started yet or if the SCCP
connection was not up yet (right now it does not seem possible to get
notified when the SCCP connection is up).

Related: SYS#5560
Related: https://osmocom.org/projects/osmo-bscnat/wiki/AoIP_OsmoBSCNAT#RESET
Change-Id: Icfec3ec0168c7040e88a536fa48da339349fb6cf
2022-03-21 16:36:32 +01:00
Oliver Smith 49e50de426 Store MSC
Expect one MSC to be configured in the address book (part of the cs7
section in the config, see doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg)
and store it on start up.

Store the MSC in a list, as we may potentially support multiple MSCs in
the future. Also that makes it symmetric to the BSC list.

Don't use the stored MSCs in the forwarding logic just yet, a future
commit will replace the current forwarding code with proper connection
mappings.

Related: SYS#5560
Change-Id: I711df0c649728f1007857fbfda500ed5ef69287b
2022-03-21 16:36:32 +01:00
Oliver Smith 793ca23f07 Store BSCs
Once a BSC has sent a RESET to BSCNAT, store it. This will be used in
future patches to build connection mappings between MSC and BSCs, and to
block messages from BSCs that did not send a RESET.

I've considered using a FSM, but at least right now there doesn't seem
to be multiple states worth storing. We only have the BSC before it has
done the RESET (and then it's simply not in our list) and after it did
the RESET (in the list).

Don't use the stored BSCs in the forwarding logic just yet, a future
commit will replace the current forwarding code with proper connection
mappings.

Related: SYS#5560
Change-Id: Icd7316c49ef26fb45ad45a2ccc1a7916bfb0a387
2022-03-21 16:36:32 +01:00
Oliver Smith 318b4820fc bsc_nat: use sub-structs for cn, ran
As suggested in code review, create sub-structs for cn and ran. The
following patches will fill them up with mscs, bscs etc.

Related: SYS#5560
Change-Id: I6a3cc0d837a3d89e7153c2296812df0863f3471f
2022-03-21 16:36:32 +01:00
Oliver Smith 0aa4cb372b bsc_nat_print_addr: pass net enum, not sccp_inst
The sccp_inst was only used to differentiate between CN / RAN. Instead
of passing that, pass an enum and add bsc_nat_print_addr_cn and _ran
defines to keep it short.

This is in preparation for refactoring struct bsc_nat as suggested in
code review.

Related: SYS#5560
Change-Id: I3c6046a6726c31bf137223c46c2c96b3898ad324
2022-03-21 16:36:32 +01:00
Oliver Smith d0059e2bd2 Reply to BSC's RESET with RESET ACK directly
Let the BSCNAT directly reply to RESET sent from BSC with RESET ACK.
bssap_ran_handle_reset() is a bit empty right now but will be used in a
future patch to store the BSC.

Related: SYS#5560
Related: https://osmocom.org/projects/osmo-bscnat/wiki/AoIP_OsmoBSCNAT#RESET
Change-Id: I3223409e25c93b625d67634caf68efe9772e2558
2022-03-21 16:36:21 +01:00
Oliver Smith 8ca3a1ad8f bsc_nat_sccp_inst: local_sccp_addr -> addr
Make it a bit shorter, it's clear that this refers to the local address
of the OsmoBSCNAT in CN/RAN.

Related: SYS#5560
Change-Id: I3083374d589487ed960507e7a431c45914afc5dd
2022-03-10 18:55:16 +01:00
Oliver Smith 6e4f7e9b2b bsc_nat_fsm: tweak forwarding log messages
Shorten them and don't use the LOG_SCCP macro anymore that will be
dropped in a follow-up patch. Change the level to DEBUG.

Related: SYS#5560
Change-Id: I85f65ad3c15a10958fbfe97aef00fc386e85ef63
2022-03-10 18:55:16 +01:00
Oliver Smith 122beff8bb treewide: tweak includes
Categorize includes by:
* (library includes)
* Osmocom includes except for OsmoBSCNAT
* OsmoBSCNAT includes

Order the includes in each category alphabetically, and remove empty
lines between them. This allows me to keep them consistent, and with
empty lines removed between these categories it doesn't look
inconsistent if there is only one include from two categories in one
file, but multiple includes from the same category in another file.

While at it, also have one empty line after the license header in all
c, h files, and one after the includes.

Related: SYS#5560
Change-Id: I1a7b95ccb0c87fd53645c72f0c02449e8403043b
2022-03-10 18:52:31 +01:00
Oliver Smith d586b71e8b bsc_nat_sccp_inst: store ss7_inst
Get ss7_inst once and store it inside bsc_nat_sccp_inst to avoid
multiple calls to osmo_ss7_instance_find().

Related: SYS#5560
Change-Id: I9a8b69fb3df17c85a67958fbca88948573d39694
2022-03-10 17:19:16 +01:00
Oliver Smith 399df14b6d bsc_nat_sccp_inst: rename from bsc_nat_ss7_inst
This name seems more fitting, since the code mostly interacts with the
sccp addr and scu contained in the struct.

Related: SYS#5560
Change-Id: Id0f965811eff0eb7b387d5ae2eec2451d6d8e415
2022-03-10 13:28:23 +01:00
Oliver Smith 6afc0e3314 vty: use osmo_ss7_vty_go_parent
Remove unnecessary bsc_nat_vty_go_parent function, and use
osmo_ss7_vty_go_parent instead. Without the latter, it segfaults while
attempting to parse a config segment like this:

  cs7 instance 0
   point-code 0.23.3
   asp asp-clnt-OsmoBSCNAT-CN 2905 0 m3ua
    remote-ip 127.0.0.1
    local-ip 127.0.0.3
   sccp-address msc  # segfault here, vty->index == NULL
    routing-indicator PC
    point-code 0.23.1

Related: SYS#5560
Related: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/26659/comment/c99b8cca_865449aa/
Change-Id: Iee6ece062f11694acb771463be7effb7342e92f2
2022-01-31 18:51:22 +01:00
Oliver Smith 8f7b750b22 Add bsc_nat fsm
Create the initial FSM that starts and stops two SS7 instances (one for
CN, one for RAN), and binds an sccp user to each.

Related: SYS#5560
Depends: libosmocore I81c64a7ae440304522c2179c212023a566ddced8
Change-Id: I7d52fa649c397582b18a1a7dcc40bb407f3b2c97
2022-01-31 18:50:59 +01:00
Oliver Smith c448efb3aa Add vty interface
Related: OS#2545
Change-Id: I6f2d8d1d62b97be471ebcf1bb14aac0b895833d1
2021-12-23 10:47:26 +01:00
Oliver Smith 6a2ac0a0d5 Add project skeleton
It was decided to write OsmoBSCNAT with 3GPP AoIP support from scratch,
in a separate repository from OsmoBSC. The previous codebase was too
heavily tied into legacy SCCPlite code and had been removed from
osmo-bsc.git in Ia05dc76336a64a7f08962843b9a7cc19f2c83387.

Related: OS#2545
Change-Id: Iae5d37483dcb9db00578d5c9cd1736f08754a65e
2021-12-23 10:47:21 +01:00