aboutsummaryrefslogtreecommitdiffstats
path: root/src/sccp_user.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-06-07 13:12:36 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-06-13 20:05:58 +0200
commit0aff5d101df25978524d52624c7137987820eb1d (patch)
tree2478c3a05ea26d5ca5aca04ec12a32c0b8f00e0a /src/sccp_user.c
parent2a0ccafbf8c13c6affb9ec4a0e47524c9f20b0ae (diff)
osmo_sccp_simple_client_on_ss7_id(): Support ASP explicitly configured as sctp server
Right now, if a user configures an cs7 instance, as and asp (with sctp-role server) in the VTY, then the function osmo_sccp_simple_client_on_ss7_id() (used by osmo-bsc, osmo-msc, osmo-hnbgw, etc.) will silently change the config to be SCTP client. This is really confusing, since the user configured explicitly the ASP as server but ends up running as client. Instead, if the user explicitly configured the ASP as SCTP server, allow it (after validating the user also properly configured a xUA server through VTY). Change-Id: I20de33edb8751a515d6719c49efadfc387dd85f8
Diffstat (limited to 'src/sccp_user.c')
-rw-r--r--src/sccp_user.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 2be9cd4..f1a4203 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -642,8 +642,30 @@ osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
osmo_ss7_as_add_asp(as, asp->cfg.name);
}
- /* Ensure that the ASP we use is set to client mode. */
- asp->cfg.is_server = false;
+ /* Make sure that the sctp-role of this ASP is set to "client" unless the user
+ * made a conscious decision about the role via the VTY */
+ if (!asp->cfg.sctp_role_set_by_vty)
+ asp->cfg.is_server = false;
+
+ /* If ASP was configured through VTY it may be explicitly configured as
+ * SCTP server. It may be a bit confusing since this function is to create
+ * a "SCCP simple client", but this allows users of this API such as
+ * osmo-hnbgw to support SCTP-role server if properly configured through VTY.
+ */
+ if (asp->cfg.is_server) {
+ struct osmo_xua_server *xs;
+ LOGP(DLSCCP, LOGL_NOTICE,
+ "%s: Requesting an SCCP simple client on ASP %s configured with 'sctp-role server'\n",
+ name, asp->cfg.name);
+ xs = osmo_ss7_xua_server_find(ss7, prot, asp->cfg.local.port);
+ if (!xs) {
+ LOGP(DLSCCP, LOGL_ERROR,
+ "%s: Requesting an SCCP simple client on ASP %s configured with 'sctp-role server' "
+ "but no matching xUA server was configured!\n",
+ name, asp->cfg.name);
+ goto out_asp;
+ }
+ }
/* Make sure that the role of this ASP is set to ASP unless the user
* made a conscious decision about the role via the VTY */