Commit Graph

39 Commits

Author SHA1 Message Date
Harald Welte d51a8de505 M3UA/SUA: Implement handling of SCON (signaling congestion)
If we receive any M3UA/SUA SNM SCON mesasages, distribute them
to any other active ASP to make everyone aware of the congestion
situation.

This makes STP_Tests_M3UA.TC_ssnm_distribution_scon pass and hence
should turn the entire osmo-stp test suite "green"

Change-Id: Iac7aeba980fbbd8b58f8872a29ba10745eb0a730
2022-05-05 18:45:42 +02:00
Harald Welte ff7404c742 stp: Add basic RX/TX rate counters on AS and ASP level
This adds some very basic rx/px rate counters to the SS7 AS and ASP

OsmoSTP> show rate-counters
SIGTRAN Application Server 0 (as-rkm-1):
             rx:msu:total:      86078 (1888/s 86078/m 0/h 0/d)
             tx:msu:total:          0 (0/s 0/m 0/h 0/d)
SIGTRAN Application Server Process 0 (asp-dyn-0):
         rx:packets:total:      86081 (1888/s 86081/m 0/h 0/d)
         tx:packets:total:          5 (0/s 5/m 0/h 0/d)

Change-Id: Idb811ca81adfe47152d484f6b981e661dc569e15
2021-11-15 18:05:01 +01:00
Harald Welte 3639af549c m3ua/sua: Add new snm_inactive quirk
This quirk allows the M3UA + SUA code to accept SSNM/SNM traffic despite
being in AS-INACTIVE state.  This is forbidden by the RFCs but there
are some implementations that apparently just don't care what is
specified.

Change-Id: I193dd546b3e3c00e29f192d0d1bf7819b3e194be
Closes: OS#5148
2021-05-13 18:11:53 +02:00
Harald Welte 0f769392a5 m3ua/sua: Add quirk for allowing inbound DAUD from SG in ASP role.
The M3UA RFC talks about this message being used in ASP->SG direction,
not the other way around.

Closes: OS#5147
Change-Id: I36ff172b47142a877b37bbd149073bef35b36a74
2021-05-13 18:11:53 +02:00
Harald Welte afbcc5d532 xua_snm: Implement handling of DUPU messages
A DUPU message in SUA and M3UA indicates the unavailability of
a (MTP-level) user, i.e. the entire SCCP, ISUP, ... is not available.

If we receive a DUPU (destination user part unavailable) message in ASP
role, then we must
 * distribute it to any other ASPs for which we operate in SG mode
 * pass it as MTP-STATUS.ind to SCCP, which can then generates
   N-PCSTATE.ind to the SCCP User

Change-Id: I1559ed0f761a8495b222df48c6bd43798e220471
2021-02-10 19:58:38 +01:00
Harald Welte 6cb841b92b xua: Implement SNM availability/unavailability messaging
M3UA and SUA have one sub-protocol called [S]SNM, through which the
SG informs the ASP about certain destinations (point codes) becoming
available (DAVA) or unavailable (DUNA) in the SS7 network.

This patch adds support for
* generating DAVA/DUAN on a SGP when the AS FSM changes to/from AS-ACTIVE
* receiving DAVA/DUNA on an ASP and informing other "SG role" AS/ASP
* processing DAUD from ASP received by SG, generating relate DAVA/DUNA
  responses

Related: OS#2623
Change-Id: Id92be4691b0fd77598a6edb642c028bbd8c5b623
2021-02-08 18:00:56 +01:00
Harald Welte f5d90c46e1 SUA: Verify routing context IE of incoming CL and CO messages
When receiving user-data (connectionless / connection-oriented),
we must make sure that there either
a) no routing context IE in the message, and only one AS within the ASP, or
b) a valid routing context IE for an AS within the ASP

This important input validation has been done in M3UA for a long time,
but somehow never been implemented on the SUA side so far.

Change-Id: Icc232250513009137add3b45fecbb5d2a07c0645
2021-02-08 11:42:33 +01:00
Pau Espin 95e2ec698d sua: Support SUA_IEI_IPv6
Change-Id: I5bd69e8400fd2d9251b5d4edd9bf3514e1194b5a
2020-09-14 12:16:02 +02:00
Harald Welte b393b3f4cc Add SPDX-License-Identifier + missing copyright statements
Change-Id: I113232bbeaa7a835871df7f9b883ba573d8a2534
2017-11-13 01:25:47 +09:00
Harald Welte f4a127ef99 initialize msg->l2h in sccp_msgb_alloc()
Change-Id: I5fb11075593696b110bfd3e0541e3aa790029903
2017-11-12 04:41:29 +09:00
Harald Welte 6548d1b9c4 SUA: Make sure to reject unknown CO message types
Found using sua-sgp-mtr-i-04 from Michael Tuexen's sua-testtool.

Change-Id: Iec5c8deb6cc48a1269fd85243c1350bafd1dd815
2017-04-17 10:33:10 +02:00
Harald Welte 161cd0dcd7 SUA: Reject unknown Connectionless Message Types
This was found by sua-sgp-mtr-i-03 of Michael Tuexen's sua-testtool.

Change-Id: I09e96a26d9f9398de07ab46cdc5af10b2ea5acc0
2017-04-17 10:26:59 +02:00
Harald Welte d95958b5fb SUA/M3UA: Implement T(r) recovery timer of Application Server FSM
When an AS goes "down" it first entres a recovery state, in which any
to-be-transmitted messages are enqueued until the timer T(r) expires.

Once the timer expires, the messages are discarded.  If the AS goes
ACTIVE before timer expiration, queued messages are sent.

Change-Id: I22725bf35306299a00c66d7b3637f5e198c26247
2017-04-14 22:48:41 +02:00
Harald Welte a04c47acae sua: Reject DATA messages on SCTP stream 0
RFC3868 states clearly that DATA messages MUST be sent o a stream other
than stream '0'.  So at the receiver side, we should validate that (just
like we do in M3UA.

Change-Id: I0784e221ef791557a69be04f7d246de059ea84c8
2017-04-14 14:53:59 +02:00
Harald Welte 02e7530671 xua: move notfiy parameters from xua_internal to sigtran_sap and rename them
Change-Id: I295b9d6755a4bb52a817d2791a302bdd9fc775dd
2017-04-10 11:48:35 +02:00
Harald Welte c860f9a41e sigtran: fix various memory leaks (msgb and xua_msg)
The general rule for 'struct xua_msg' is now that it is free'd by the
function that also allocates it in the first place.  Any downstream
consumer of the xua_msg may interpret it, but not hold any references or
free() it.

Change-Id: I708505d129da5824c69b31a13a9c93201929bada
2017-04-10 11:48:35 +02:00
Harald Welte d40b9f842b SUA: Port to new osmo_ss7 and SCCP code
If we use the infrastructure provided by osmo_ss7 on the lower layer and
the SCCP SCRC, SCLC and SCOC code on the upper side, not much of the
original sua.c code remains.  It looks much like the M3UA code now.

Change-Id: I193b74f58aa70c443ae17e78b5604246d6bc3f71
2017-04-10 11:48:34 +02:00
Harald Welte cd13b68e67 sua.c: Replace sua_msgb_alloc() with new sccp_msgb_alloc()
Change-Id: I7067a85dcc5dda66f4b17b0fe08da8cb3efe79ef
2017-04-10 11:48:34 +02:00
Harald Welte dd59a11667 sua: Extend address parsing with GT, RI and IPv4 support
Change-Id: I186df77cbdbedfe1a60b855be3626b6766f4681c
2017-04-10 11:48:23 +02:00
Harald Welte 1471dc9764 sua: Make use of xua_msg_dialect
We fill in the data structures of a xua_msg_dialect and make use of it
for generic mandatory IE checking and messageheader printing.

Change-Id: I966103f30b9be247ba6905ba8e06b87654d9981a
2017-04-10 10:41:16 +02:00
Harald Welte d75e8967ef License headers: Should always have been GPLv2-or-later
libosmo-sigtran is GPLv2-or-later, there were some files that
accidentially had an AGPLv3 license header, which was a copy+paste
mistake at that time.

Change-Id: I67dfd0ae6157afafd3873a3baaa4c6107c04ddfd
2017-04-10 10:41:16 +02:00
Harald Welte 0dd089f17d Move xua_msg_add_sccp_addr() to xua_msg.h and export it
Change-Id: I07fa00dd71d8ecdf1542734598fab8ecad5a7b53
2017-02-13 15:09:17 +01:00
Harald Welte 1c43cc2918 migrate some generic XUA helpers from sua.c to xua_msg.c
Change-Id: I59e55d21a05b5d770c120da4c17220d5f21d44bd
2017-02-13 15:09:12 +01:00
Harald Welte 0c72c1c0d3 Start to log + handle SCTP notifications
Change-Id: Ie00c4fc65c66e55262e2db084826084dcaf34b91
2017-01-27 22:14:27 +00:00
Neels Hofmeyr 1f94c07ed2 fix: use proper disconnect prim param type
For the N-DISCONNECT prim, parse CREF, RLC and RLSD from the proper parameter
struct type: osmo_scu_disconn_param instead of osmo_scu_connect_param.

Before this, the conn_id ended up in the wrong place and the other side always
received a zero conn_id.

Tested only for the RLSD case, which fixes Iu-Release message evaluation for
all except the very first SUA conn received by the CN components.

In all three cases, set:

* param->responding_addr to conn->called_addr.
* param->originator to OSMO_SCCP_ORIG_UNDEFINED.

Change-Id: I446f2fe57cc3b7c52723f3ab82836513a5d37752
2017-01-27 09:59:31 +01:00
Neels Hofmeyr 6075f6ad51 cosmetic: sua.c: comments
Add some human readable names.

Change-Id: If4aa15aae8b03c764a45b866a751eb3fbabebec1
2017-01-27 09:59:31 +01:00
Neels Hofmeyr eddf138666 parse SCCP src+dst addresses
In order to receive a Paging command with a valid RANAP SSN, decode the SCCP
source and destination address IEs. This is used by hnbgw to forward a Paging
from CN to RNC.

This may be done more generally as soon as more IEs need parsing of their sub
parts. For now, iterate the higher level IE's data chunk and obtain the address
sub part IEs without storing sub part locations.

Change-Id: I03d0c2a9003fda59c5b88c8738df009c30fbc11c
2017-01-27 09:59:31 +01:00
Neels Hofmeyr b79a61de9a remove two compiler warnings for unused variables
Change-Id: I173dc67050d907f9b09b99265af9dee9d142ace3
2017-01-27 09:59:31 +01:00
Neels Hofmeyr db3a4bb5a5 SUA COIT: send dest ref nr, not dest addr
See RFC 3868 3.3.11
https://tools.ietf.org/html/rfc3868#section-3.3.11

Change-Id: I083384876d4a8d7fa9c03409fbdc9e00e3c8f416
2017-01-27 09:59:30 +01:00
Harald Welte b5f0d1c9bc sua: Ensure that a SUA client will continuously try to reconnect
Change-Id: Ic05a2b78e29e4ede214a3395430ef54bacd84e60
2017-01-27 09:59:30 +01:00
Harald Welte 32a1d54279 sua: call conn_disconnect() in sua_disconnect_req()
disconnect is not a class3/4 operation. We simply generate + send the
DISCONNECT.ind message to the remote side and drop all local state about the
connection.

Change-Id: I4e336f9dfd4ebd0122cd9e5a70db3d05e9dc1764
2017-01-27 09:59:30 +01:00
Harald Welte edfab6fdf5 sua: Fix typo in log message
Change-Id: I13bb0e2f4ec688fefd9b98d6d2389562e2a2dad7
2017-01-27 09:59:30 +01:00
Harald Welte 452b87285b allow user to give private data to osmo_sua_user_create()
... which can be resolved from the primitive call back prim_cb() by
calling osmo_sccp_link_get_user_priv().

Change-Id: If4c0f96f0621fb2adf4c78dc5994d3398431d92f
2017-01-27 09:59:06 +01:00
Neels Hofmeyr 26bcc0b9c4 fix NULL deref: sua_accept_cb: missing error-return
When server creation failed, besides closing the fd also return an error,
instead of continuing to use the NULL srv.

Change-Id: Iabfae7e5a880d10e4050da4945200ce9b848e577
Fixes: coverity CID#57684
2016-12-12 10:59:20 +00:00
Harald Welte dfb4d91892 sua: Remove unused 'cur' variables
There are some compiler warnings about other unused variables which we
rather keep as a reminder that the SUA code is partially incomplete and
should be finished at some day.

Change-Id: I42b76351f1bbdfb7fe339d5fad98c5a065822a45
2016-11-11 15:40:06 +01:00
Neels Hofmeyr 03ad002c28 cosmetic: rename osmo_sua_link and osmo_sua_user to osmo_sccp_*
hwelte requested this change for the addition of libiu in openbsc. In a
conversation we came to the conclusion that a rename of these two opaque
structs would suffice.

This is the "upstream" rename and will require adaptation of:

* the sysmocom/iu branch in this repository
* the iu related branches in openbsc.git
* the hnbgw and dummy_cn code in osmo-iuh.git

See https://gerrit.osmocom.org/#/c/192/2/openbsc/src/libiu/iu.c@57

Change-Id: Icbf64dd96f8e0e27695df73d1144519b88360b94
2016-07-06 15:55:02 +02:00
Neels Hofmeyr e076bf2107 fix log msg typo, x5
Change-Id: I00ff99ef14d62d3b353fe69762ae49f374938f94
Reviewed-on: https://gerrit.osmocom.org/265
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-14 22:19:11 +00:00
Neels Hofmeyr 1a698a537d clarify fixme comment, x7
The fixme is about an actual message sent back, not about the error log.

Change-Id: I6de8fb202c7beb025232e9b97605e9f46778506a
Reviewed-on: https://gerrit.osmocom.org/228
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-14 10:36:23 +00:00
Harald Welte bf49cc1c00 Import SUA (SCCP User Adaptation) and SCCP User SAP
... this code originates from the osmo-iuh repository, but is now part
of a new shared libosmo-sigtran.so library generated in this repository.
2015-12-22 23:03:41 +01:00