Commit Graph

59 Commits

Author SHA1 Message Date
Andreas Eversberg cbf40fb64b Use uniform log format for default config files
Related: OS#6272
Change-Id: I811f7ede8d8b5ae4036bfd9cb530b1100ba0fb07
2023-12-01 12:34:51 +01:00
Harald Welte 7057fedc33 the git:// protocol is deprecated for a long time; use https:// instead
Change-Id: Ic31d381b25d31f6ab5ce609a544321bc74008902
2023-11-07 16:47:11 +00:00
Oliver Smith a9d321866d Write explicit role & sctp-role fields in ASP configurations
Change-Id: Ib186b59ce33b202a7adb6159c93f7db7b677d8ef
2023-06-08 19:45:45 +02:00
Oliver Smith 9aa56a3160 systemd: depend on networking-online.target
Related: SYS#6400
Change-Id: I9c0cc0779f9ddb7520a565668b7cde07c6ad55d8
2023-05-26 14:10:44 +02:00
Oliver Smith cf2bc81fdd debian: set compat level to 10
Related: OS#5958
Change-Id: Id0f168a7d3c2ae6869121397e65ca1d0cfea30d3
2023-04-25 16:48:20 +02:00
arehbein c871c2f4b3 osmo-bsc-nat: Transition to use of 'telnet_init_default'
Related: OS#5809
Change-Id: I7450b8618710bc7e51bfc57bdf1464c323471f16
2022-12-19 22:34:37 +01:00
Oliver Smith cce4b03bd3 bssap_conn: fix missing length check
Check length of msg_new before trying to encode a copy of the IE into
it. The code path for IE_AOIP_TRASP_ADDR is different since it gets
replaced. With the libosmocore patch in Depends below the
gsm0808_enc_aoip_trasp_addr function checks the length.

Depends: libosmocore I632986b99d841abff0f14c6da65f030175f5c4a1
Fixes: Coverity CID#273004
Change-Id: I1fc4c81e139bab3d7d977ef9467f62d8088884db
2022-08-05 14:08:47 +02:00
Oliver Smith 07180351c4 bsc_nat_print_addr: handle NULL
Fixes: Coverity CID#273006, CID#273005
Fixes: OS#5597
Change-Id: I37cfc7ae32d85142d73b523b2f13b94a0bffba7a
2022-07-12 16:05:05 +02:00
Oliver Smith f7bedf5a23 subscr_conn_fsm: refactor timeouts
Use osmo_tdef_state_timeout instead of passing timers every time. Rename
g_mgw_tdefs to g_bsc_nat_tdefs and add the new TDEF_ASS_COMPL there, so
the TDEF_MGCP can be used in subscr_conn_fsm and by mgcp client without
duplicating it.

Related: SYS#5560
Change-Id: Ib34e6ccc34901ebc37d2dbe347d9644cb70921ca
2022-06-09 11:53:20 +02:00
Oliver Smith b83c755b31 subscr_conn_fsm: handle dialing invalid number
Reset the FSM to idle when receiving a clear command from the MSC during
ST_WAITING_FOR_ASSIGNMENT_COMPLETE.

Related: SYS#5560
Change-Id: Ic0589be21f0ee4dbbbe0ffa6b0acdbe152909700
2022-06-09 11:15:06 +02:00
Oliver Smith 9b3de0183b Add subscr_conn_fsm
Insert the BSCNAT's MGW into phone calls by replacing the AoIP
transport layer address IE inside BSSMAP Assignment Request and
Assignment Confirm. Accomplish this with a new subscr_conn_fsm that
parses and stores the original ass_req / ass_conf messages, communicates
with the BSCNAT MGW, and then creates new ass_req / ass_conf messages
based on the original ones but with new RTP information.

With this patch it is possible to do a successful voice call with the
following network:

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

Related: SYS#5560
Related: https://osmocom.org/projects/osmo-bscnat/wiki/Ladder_diagrams_for_key_procedures
Change-Id: I7e491aada6f5db0eb35ef2039869c6ba07f9ca3b
2022-06-09 10:13:45 +02:00
Oliver Smith 9b5e22b2d2 bsc_nat_fsm: check for error from get_next_id_ran
Related: SYS#5560
Change-Id: Ic55ba119e9c736c396f06a58ec9bc1f4682e9b11
2022-04-11 11:44:47 +02:00
Oliver Smith 1d20ac48fc Make subscr_conn_get_next_id RAN specific
Instead of having RAN/CN as parameter, make the function a bit simpler
and only allow RAN. The motivation for this change is, that for MGW a
similar function is required, and it was recommended in code review to
rather duplicate the short function instead of making it more complex.
I'm dropping the CN part here since it wasn't used anyway, and if used
in the future, the function could be duplicated for CN as well.

Related: SYS#5560
Change-Id: I77b0ef33f94c401d24f38eb8d79e1007234e0ab4
2022-04-11 11:14:22 +02:00
Oliver Smith ea079426ef Parse BSSMAP in conn-oriented data
Add functions to parse the BSSMAP part of BSSAP messages, and in theory
do other things than just forwarding the messages depending on the
BSSMAP message type. This will be used in follow-up patches to change
the AoIP transport layer address in Assignment Request and related
messages.

Related: SYS#5560
Change-Id: I3e2599a9a07925afdbe69f7b8dbcec227681dfa2
2022-04-11 11:07:01 +02:00
Oliver Smith fcdd54d849 main: use osmo_fsm_set_dealloc_ctx(OTC_SELECT)
Prepare to use osmo_mgcp_ep_alloc in a future patch, which requires
using osmo_fsm_set_dealloc_ctx(OTC_SELECT) for deferred FSM deallocation
(see the warning in src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c).

Related: SYS#5560
Change-Id: I97abf88fa64cc1a4906f356c57912593d4366a37
2022-04-11 11:03:47 +02:00
Oliver Smith ba1c49028f Proper exit if bsc_nat_fsm fails to start
Instead of segfaulting later on, properly exit if the bsc_nat_fsm does
not start. One reason for having it fail could be a missing mgw pool
config block.

Related: SYS#5560
Change-Id: Ia8bbe6ae908d5c3ce49f71b43c950497aeebb6d6
2022-04-11 11:03:12 +02:00
Oliver Smith e04bf1402d Initialize MGW pool on start up
Make the MGW pool configurable in the VTY and connect to each configured
MGW instance on start up. This is in preparation for the
subscr_conn_fsm, which will allocate own MGCP connections while
processing BSSMAP assignment request and related messages.

Related: SYS#5560
Change-Id: I6030a1f5a9d5fb06f148b2a2e03ae57bcb6b3766
2022-04-08 18:37:24 +02:00
Oliver Smith 99dd4efaa2 bssap.h, subscr_conn.h: fix missing includes
Related: SYS#5560
Change-Id: Ieb048c0f299bca1b194979c26cbeadbc81dee05f
2022-04-08 14:20:20 +02:00
Oliver Smith d9ae50e96d README: osmo-dev: add BSC{0,1}_CODEC_LIST="fr2"
In the test setup, let the real BSC and virtual BSC use the same codec.
With this the voice frames are successfully sent back by the virtual MS.
When using a different codec, since transcoding is not implemented in
OsmoMGW, the stream becomes invalid in MGW-MSC and gets dropped by BTS1,
never reaching the virtual MS.

Related: SYS#5560
Change-Id: I78d666ad77c03459f5369b64e651e47ce1d4f12c
2022-03-23 18:26:22 +01:00
Oliver Smith a73b45a934 bssap: forward paging from MSC to all BSCs
I've considered only forwarding to specific BSCs based on the cell
identifier list inside the paging. For that, the cell identifier would
need to be stored beforehand (read it from location update? or put it in
vty config?) and I'm not sure if it is required, so don't do this for
now and extend it later if needed.

Related: SYS#5560
Related: https://osmocom.org/projects/osmo-bscnat/wiki/AoIP_OsmoBSCNAT#PAGING-BSC
Change-Id: I2532d94aab82d136b932d57fa53c8ecf2d8d1fd9
2022-03-23 18:26:17 +01:00
Oliver Smith af61b08191 bssap: name bssmap functions properly
Almost all functions in bssap.c actually handle bssmap, so name them
accordingly.

Related: SYS#5560
Change-Id: Ib583b64187bcf3138399e7a099248ee79492bb03
2022-03-23 18:23:28 +01:00
Oliver Smith 066aa8cd45 bssap: fix printing bssmap names
Use the proper function to print BSSMAP names, so it doesn't say
"unknown 0x52" etc.

Related: SYS#5560
Change-Id: I353a9d13b14de6d0ba9aabe8cb3057dd7a98cb51
2022-03-23 11:28:50 +01:00
Oliver Smith 175fed1327 bssap: make "not implemented" log msgs consistent
Use LOGL_ERROR and word them the same way as the not implemented
message in sccp_sap_up_cn and sccp_sap_up_ran.

Related: SYS#5560
Change-Id: Ice8d67a30064a91d68256f43dcfb052d237e5594
2022-03-23 11:26:20 +01:00
Oliver Smith 5c11306e45 bsc_nat_fsm: tweak get_peer_addr
Rename the function from sccp_sap_get_peer_addr_in to get_peer_addr to
make the code using it slightly more readable.  The _in at the end of
the function is not needed anymore, this was used to differentiate from
peer_addr_out which was used in the caller code before the connection
mapping was implemented in I1556aa665fbb0a97507f98794e74820731fa6935.
Now instead of peer_addr_out, subscr_conn->bsc->addr or
subscr_conn->msc->addr are used.

Rename variable arguments to sccp_inst and addr to be consistent with
the variable names in the callers.

Related: SYS#5560
Change-Id: Ie023360724254be54cbaac4490b0341dfe68399f
2022-03-23 09:22:21 +00:00
Oliver Smith 9722b0fa61 README: add Manual Testing With osmo-dev
Describe the manual testing that can be done with osmo-dev with the
changes up to I78ef36c72ff9a7b801e922eccc89dc44fbba7f23.

Related: SYS#5560
Change-Id: I3c3369b6d1a50ec3af19ee826cf2f94530d5d7fd
2022-03-23 09:21:48 +00:00
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 2ec692d73b bsc_nat_fsm: split up sccp_sap_up in _cn, _ran
Prepare for future patches where more will happen in the callback
function. Split it up into two functions, one for CN and one for RAN, so
we don't need to constantly think through both cases while
changing/trying to understand the function.

Related: SYS#5560
Change-Id: I8eb8f24ad33a59de8fbaf512547d389ee86c13dc
2022-03-10 18:55:16 +01:00
Oliver Smith edc61b4519 bsc_nat_fsm: drop LOG_SCCP macro
After implementing more functionallity (see follow-up patches), it
became clear that this macro is not so useful:

* Using the macro creates unnecessary overhead,
  'LOG_SCCP(sccp_inst, peer_addr_in,' is much longer than 'LOGP('

* The RI and SSN are always the same, so it's not useful to print them
  all the time, this is the generated prefix:
  '(RI=SSN_PC,PC=0.23.3,SSN=BSSAP from CN)'

Related: SYS#5560
Change-Id: I49187d4e3d804c4786ee52eaebdd911e6c6cfa6c
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 1bee8ddae8 bsc_nat_fsm: log prim_name once, not in each case
Move the log message outside of the switch case to make it a bit
shorter. Use LOGP instead of LOG_SCCP, because the latter is about to
get removed in a follow-up patch.

Related: SYS#5560
Change-Id: I1f181ff38f86d83969da4e9d3da72dd9d69d298a
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 f0a26d8ecc bsc_nat_fsm: move conn.ind before conn.conf
conn.ind happens before conn.conf, so use the same order in the switch
statement.

Related: SYS#5560
Change-Id: Ibdb5a9b092ab481f35cf5920f3635fdf4a9b85c2
2022-03-10 17:19:22 +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 f2fe7d626a bsc_nat_fsm: fix sccp_sap_get_peer_addr_in
Fix the logic to not always return src->local_sccp_addr. What we need to
know is the peer's address.

Related: SYS#5560
Change-Id: I0055c0fafe672db5ce7a616d94c8964e8d58968f
2022-03-10 13:28:18 +01:00
Oliver Smith 9acbb0b790 bsc_nat_fsm: initial conn-oriented forwarding
Implement a simple version of forwarding Connection Request, Connection
Confirm, Data Form, Released SCCP messages. This is still assuming that
there is just one BSC, one MSC, the same connection ID is used in RAN
and CN. Future patches will add a mapping between RAN and CN sides and
allow multiple BSCs.

With this patch it is possible to perform a call between two MS in the
following network structure:

  MS1 --.
        BTS --- BSC --- BSCNAT --- MSC
  MS2 --'

Related: SYS#5560
Change-Id: I3df79e4dfaa60f4fd098961ee57cda71e9773b82
2022-02-24 08:30:09 +01:00
Oliver Smith 2a1e1d0617 bsc_nat_fsm: split sccp_sap_get_peer_addr_out
Split this code into an extra function, as it will be used by other
message types in sccp_sap_up too (following patches).

Related: SYS#5560
Change-Id: I6bc59445d65f812ccd46eb33dd6cca6b34dd0867
2022-02-18 18:30:36 +01:00
Oliver Smith 6515a891af bsc_nat_fsm: rename vars to peer_addr_{in,out}
Only in connection-less messages, the called party address is always the
address of the receiving peer. Prepare for connection-oriented messages
by renaming:
  dest_called -> peer_addr_out
  peer_addr   -> peer_addr_in

Related: SYS#5560
Change-Id: Ib58a4e8eb8beca23cb9f11c46576f8b17bb66f3c
2022-02-18 18:29:09 +01:00
Oliver Smith 0108033823 bsc_nat_fsm: drop called addr verify
This is already done by the SCCP stack, as Harald explained it:
"Think of a TCP socket where you have already bound a socket and then
 still do recvmsg to check if the destination address is what you expect."

Related: SYS#5560
Change-Id: Id9bfbf38a61ef66a4246f752ef487d8a09fea173
2022-02-18 18:25:05 +01:00
Oliver Smith 445dc2483e bsc_nat_fsm: sccp_sap_up: err if not implemented
Make it more obvious if a message is ignored, because it is not
implemented.

Related: SYS#5560
Change-Id: Ibc71e6aaed4fd51d090ab31fc3e49f3a82111506
2022-02-18 13:27:26 +01:00
Oliver Smith b80f2c33c8 bsc_nat_fsm: fix SSN of OsmoBSCNAT-CN
Related: SYS#5560
Change-Id: Ic0e64e002bccf1115cc53566bdab9d84dc680b03
2022-02-18 13:27:11 +01:00
Oliver Smith ba1f0d0691 bsc_nat_fsm: initial msc <> bsc msg forwarding
Add an initial implementation of sccp_sap_up, that assumes one BSC and
one MSC, and successfully forwards RESET and RESET ACK between both.

Related: SYS#5560
Depends: libosmo-sccp I0f38b0d038b0dd8cd355e7284e5b56d438811bd9
Change-Id: I4af398bb433341a98f818822e6c3af28b6d9dacd
2022-02-01 12:07:52 +01:00