pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-sigtran/+/38642?usp=email )
Change subject: sigtran: Make osmo_ss7_xua_server APIs private
......................................................................
sigtran: Make osmo_ss7_xua_server APIs private
xua_srv objects are managed so far exclusively through libosmo-sigtran
VTY interface, hence make the struct as well as all its APIs private
Change-Id: Ie03697fdb2c9f95de011b21771261e52befb6018
---
M include/osmocom/sigtran/osmo_ss7.h
M src/Makefile.am
M src/osmo_ss7.c
M src/osmo_ss7_asp.c
M src/osmo_ss7_vty.c
M src/osmo_ss7_xua_srv.c
M src/sccp_user.c
M src/ss7_internal.h
A src/ss7_xua_srv.h
M src/xua_asp_fsm.c
M src/xua_default_lm_fsm.c
11 files changed, 165 insertions(+), 138 deletions(-)
Approvals:
Jenkins Builder: Verified
osmith: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index 8f33115..d4fb87b 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -20,7 +20,6 @@
struct osmo_ss7_user;
struct osmo_sccp_instance;
struct osmo_mtp_prim;
-struct osmo_xua_layer_manager;
struct osmo_ss7_route_table;
int osmo_ss7_init(void);
@@ -42,6 +41,14 @@
}
/***********************************************************************
+ * xUA Servers
+ ***********************************************************************/
+
+struct osmo_xua_layer_manager;
+
+struct osmo_xua_server;
+
+/***********************************************************************
* SS7 Instances
***********************************************************************/
@@ -435,70 +442,6 @@
void osmo_ss7_register_rx_unknown_cb(osmo_ss7_asp_rx_unknown_cb *cb);
-/***********************************************************************
- * xUA Servers
- ***********************************************************************/
-
-struct osmo_xua_layer_manager {
- osmo_prim_cb prim_cb;
-};
-
-struct osmo_xua_server {
- struct llist_head list;
- struct osmo_ss7_instance *inst;
-
- /* list of ASPs established via this server */
- struct llist_head asp_list;
-
- struct osmo_stream_srv_link *server;
-
- struct {
- bool accept_dyn_reg;
- struct osmo_ss7_asp_peer local;
- enum osmo_ss7_asp_protocol proto;
- struct {
- bool num_ostreams_present;
- bool max_instreams_present;
- uint16_t num_ostreams_value;
- uint16_t max_instreams_value;
- } sctp_init;
-
- /*! The underlaying transport protocol (one of IPPROTO_*) */
- int trans_proto;
- } cfg;
-};
-
-struct osmo_xua_server *
-osmo_ss7_xua_server_find(struct osmo_ss7_instance *inst,
- enum osmo_ss7_asp_protocol proto,
- uint16_t local_port)
- OSMO_DEPRECATED("Use osmo_ss7_xua_server_find2() instead");
-struct osmo_xua_server *
-osmo_ss7_xua_server_find2(struct osmo_ss7_instance *inst,
- int trans_proto,
- enum osmo_ss7_asp_protocol proto,
- uint16_t local_port);
-
-struct osmo_xua_server *
-osmo_ss7_xua_server_create(struct osmo_ss7_instance *inst,
- enum osmo_ss7_asp_protocol proto,
- uint16_t local_port, const char *local_host)
- OSMO_DEPRECATED("Use osmo_ss7_xua_server_create2() instead");
-struct osmo_xua_server *
-osmo_ss7_xua_server_create2(struct osmo_ss7_instance *inst,
- int trans_proto, enum osmo_ss7_asp_protocol proto,
- uint16_t local_port, const char *local_host);
-
-int
-osmo_ss7_xua_server_bind(struct osmo_xua_server *xs);
-
-int
-osmo_ss7_xua_server_set_local_host(struct osmo_xua_server *xs, const char *local_host);
-int
-osmo_ss7_xua_server_set_local_hosts(struct osmo_xua_server *xs, const char **local_hosts,
size_t local_host_cnt);
-int osmo_ss7_xua_server_add_local_host(struct osmo_xua_server *xs, const char
*local_host);
-int osmo_ss7_xua_server_del_local_host(struct osmo_xua_server *xs, const char
*local_host);
-void osmo_ss7_xua_server_destroy(struct osmo_xua_server *xs);
struct osmo_sccp_instance *
osmo_sccp_simple_client(void *ctx, const char *name, uint32_t default_pc,
diff --git a/src/Makefile.am b/src/Makefile.am
index 6dd338e..78e9764 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,6 +9,7 @@
ss7_linkset.h \
ss7_route.h \
ss7_route_table.h \
+ ss7_xua_srv.h \
xua_asp_fsm.h \
xua_as_fsm.h \
xua_internal.h \
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index e89f7bd..3659516 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -780,51 +780,6 @@
trans_proto, proto);
}
-/*! \brief find an xUA server with the given parameters
- * \param[in] inst SS7 Instance on which we operate
- * \param[in] trans_proto transport protocol in use (one of IPPROTO_*)
- * \param[in] proto protocol (xUA variant) in use
- * \param[in] local_port local port of the server
- * \returns \ref osmo_xua_server or NULL (not found)
- */
-struct osmo_xua_server *
-osmo_ss7_xua_server_find2(struct osmo_ss7_instance *inst,
- int trans_proto,
- enum osmo_ss7_asp_protocol proto,
- uint16_t local_port)
-{
- struct osmo_xua_server *xs;
-
- OSMO_ASSERT(ss7_initialized);
- llist_for_each_entry(xs, &inst->xua_servers, list) {
- if (trans_proto != xs->cfg.trans_proto)
- continue;
- if (proto != xs->cfg.proto)
- continue;
- if (local_port != xs->cfg.local.port)
- continue;
- return xs;
- }
-
- return NULL;
-}
-
-/*! \brief find an xUA server with the given parameters
- * \param[in] inst SS7 Instance on which we operate
- * \param[in] proto protocol (xUA variant) in use
- * \param[in] local_port local port of the server
- * \returns \ref osmo_xua_server or NULL (not found)
- */
-struct osmo_xua_server *
-osmo_ss7_xua_server_find(struct osmo_ss7_instance *inst,
- enum osmo_ss7_asp_protocol proto,
- uint16_t local_port)
-{
- const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto);
-
- return osmo_ss7_xua_server_find2(inst, trans_proto, proto, local_port);
-}
-
bool osmo_ss7_pc_is_local(const struct osmo_ss7_instance *inst, uint32_t pc)
{
OSMO_ASSERT(ss7_initialized);
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index 9bb4b40..6058304 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -52,6 +52,7 @@
#include "sccp_internal.h"
#include "xua_internal.h"
#include "ss7_internal.h"
+#include "ss7_xua_srv.h"
#include "xua_asp_fsm.h"
#include "xua_as_fsm.h"
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 6c9db5a..7f9aa39 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -49,6 +49,7 @@
#include "ss7_route.h"
#include "ss7_route_table.h"
#include "ss7_internal.h"
+#include "ss7_xua_srv.h"
#include <netinet/tcp.h>
@@ -583,13 +584,13 @@
if (trans_proto < 0)
return CMD_WARNING;
- xs = osmo_ss7_xua_server_find2(inst, trans_proto, proto, port);
+ xs = ss7_xua_server_find2(inst, trans_proto, proto, port);
if (!xs) {
- xs = osmo_ss7_xua_server_create2(inst, trans_proto, proto, port, NULL);
+ xs = ss7_xua_server_create2(inst, trans_proto, proto, port, NULL);
if (!xs)
return CMD_WARNING;
/* Drop first dummy address created automatically by _create(): */
- osmo_ss7_xua_server_set_local_hosts(xs, NULL, 0);
+ ss7_xua_server_set_local_hosts(xs, NULL, 0);
}
vty->node = L_CS7_XUA_NODE;
@@ -618,12 +619,12 @@
if (trans_proto < 0)
return CMD_WARNING;
- xs = osmo_ss7_xua_server_find2(inst, trans_proto, proto, port);
+ xs = ss7_xua_server_find2(inst, trans_proto, proto, port);
if (!xs) {
vty_out(vty, "No xUA server for port %u found%s", port, VTY_NEWLINE);
return CMD_WARNING;
}
- osmo_ss7_xua_server_destroy(xs);
+ ss7_xua_server_destroy(xs);
return CMD_SUCCESS;
}
@@ -636,7 +637,7 @@
{
struct osmo_xua_server *xs = vty->index;
- osmo_ss7_xua_server_add_local_host(xs, argv[0]);
+ ss7_xua_server_add_local_host(xs, argv[0]);
return CMD_SUCCESS;
}
@@ -650,7 +651,7 @@
{
struct osmo_xua_server *xs = vty->index;
- if (osmo_ss7_xua_server_del_local_host(xs, argv[0]) != 0) {
+ if (ss7_xua_server_del_local_host(xs, argv[0]) != 0) {
vty_out(vty, "%% Failed deleting local address '%s' from set%s",
argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
@@ -2947,7 +2948,7 @@
oxs = vty->index;
/* If no local addr was set, or erased after _create(): */
ss7_xua_server_set_default_local_hosts(oxs);
- if (osmo_ss7_xua_server_bind(oxs) < 0)
+ if (ss7_xua_server_bind(oxs) < 0)
vty_out(vty, "%% Unable to bind xUA server to IP(s)%s", VTY_NEWLINE);
vty->node = L_CS7_NODE;
vty->index = oxs->inst;
diff --git a/src/osmo_ss7_xua_srv.c b/src/osmo_ss7_xua_srv.c
index 473826f..4fb2115 100644
--- a/src/osmo_ss7_xua_srv.c
+++ b/src/osmo_ss7_xua_srv.c
@@ -54,6 +54,7 @@
#include "ss7_internal.h"
#include "xua_asp_fsm.h"
#include "xua_as_fsm.h"
+#include "ss7_xua_srv.h"
/***********************************************************************
* SS7 xUA Server
@@ -196,7 +197,7 @@
* \returns callee-allocated \ref osmo_xua_server in case of success
*/
struct osmo_xua_server *
-osmo_ss7_xua_server_create2(struct osmo_ss7_instance *inst,
+ss7_xua_server_create2(struct osmo_ss7_instance *inst,
int trans_proto, enum osmo_ss7_asp_protocol proto,
uint16_t local_port, const char *local_host)
{
@@ -232,7 +233,7 @@
osmo_stream_srv_link_set_port(oxs->server, oxs->cfg.local.port);
osmo_stream_srv_link_set_proto(oxs->server, trans_proto);
- osmo_ss7_xua_server_set_local_host(oxs, local_host);
+ ss7_xua_server_set_local_host(oxs, local_host);
LOGP(DLSS7, LOGL_INFO, "Created %s server on %s:%" PRIu16 "\n",
get_value_string(osmo_ss7_asp_protocol_vals, proto), local_host, local_port);
@@ -255,13 +256,13 @@
* \returns callee-allocated \ref osmo_xua_server in case of success
*/
struct osmo_xua_server *
-osmo_ss7_xua_server_create(struct osmo_ss7_instance *inst,
+ss7_xua_server_create(struct osmo_ss7_instance *inst,
enum osmo_ss7_asp_protocol proto,
uint16_t local_port, const char *local_host)
{
const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto);
- return osmo_ss7_xua_server_create2(inst, trans_proto, proto,
+ return ss7_xua_server_create2(inst, trans_proto, proto,
local_port, local_host);
}
@@ -270,7 +271,7 @@
* \returns 0 on success, negative value on error.
*/
int
-osmo_ss7_xua_server_bind(struct osmo_xua_server *xs)
+ss7_xua_server_bind(struct osmo_xua_server *xs)
{
char buf[512];
int rc;
@@ -303,13 +304,13 @@
}
int
-osmo_ss7_xua_server_set_local_host(struct osmo_xua_server *xs, const char *local_host)
+ss7_xua_server_set_local_host(struct osmo_xua_server *xs, const char *local_host)
{
- return osmo_ss7_xua_server_set_local_hosts(xs, &local_host, 1);
+ return ss7_xua_server_set_local_hosts(xs, &local_host, 1);
}
int
-osmo_ss7_xua_server_set_local_hosts(struct osmo_xua_server *xs, const char **local_hosts,
size_t local_host_cnt)
+ss7_xua_server_set_local_hosts(struct osmo_xua_server *xs, const char **local_hosts,
size_t local_host_cnt)
{
int rc;
OSMO_ASSERT(ss7_initialized);
@@ -321,7 +322,7 @@
}
int
-osmo_ss7_xua_server_add_local_host(struct osmo_xua_server *xs, const char *local_host)
+ss7_xua_server_add_local_host(struct osmo_xua_server *xs, const char *local_host)
{
int rc;
@@ -332,7 +333,7 @@
}
int
-osmo_ss7_xua_server_del_local_host(struct osmo_xua_server *xs, const char *local_host)
+ss7_xua_server_del_local_host(struct osmo_xua_server *xs, const char *local_host)
{
int rc;
@@ -348,15 +349,15 @@
if (!oxs->cfg.local.host_cnt) {
/* "::" Covers both IPv4 and IPv6 */
if (ss7_ipv6_sctp_supported("::", true))
- osmo_ss7_xua_server_set_local_host(oxs, "::");
+ ss7_xua_server_set_local_host(oxs, "::");
else
- osmo_ss7_xua_server_set_local_host(oxs, "0.0.0.0");
+ ss7_xua_server_set_local_host(oxs, "0.0.0.0");
return true;
}
return false;
}
-void osmo_ss7_xua_server_destroy(struct osmo_xua_server *xs)
+void ss7_xua_server_destroy(struct osmo_xua_server *xs)
{
struct osmo_ss7_asp *asp, *asp2;
@@ -372,3 +373,48 @@
llist_del(&xs->list);
talloc_free(xs);
}
+
+/*! \brief find an xUA server with the given parameters
+ * \param[in] inst SS7 Instance on which we operate
+ * \param[in] trans_proto transport protocol in use (one of IPPROTO_*)
+ * \param[in] proto protocol (xUA variant) in use
+ * \param[in] local_port local port of the server
+ * \returns \ref osmo_xua_server or NULL (not found)
+ */
+struct osmo_xua_server *
+ss7_xua_server_find2(struct osmo_ss7_instance *inst,
+ int trans_proto,
+ enum osmo_ss7_asp_protocol proto,
+ uint16_t local_port)
+{
+ struct osmo_xua_server *xs;
+
+ OSMO_ASSERT(ss7_initialized);
+ llist_for_each_entry(xs, &inst->xua_servers, list) {
+ if (trans_proto != xs->cfg.trans_proto)
+ continue;
+ if (proto != xs->cfg.proto)
+ continue;
+ if (local_port != xs->cfg.local.port)
+ continue;
+ return xs;
+ }
+
+ return NULL;
+}
+
+/*! \brief find an xUA server with the given parameters
+ * \param[in] inst SS7 Instance on which we operate
+ * \param[in] proto protocol (xUA variant) in use
+ * \param[in] local_port local port of the server
+ * \returns \ref osmo_xua_server or NULL (not found)
+ */
+struct osmo_xua_server *
+ss7_xua_server_find(struct osmo_ss7_instance *inst,
+ enum osmo_ss7_asp_protocol proto,
+ uint16_t local_port)
+{
+ const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto);
+
+ return ss7_xua_server_find2(inst, trans_proto, proto, local_port);
+}
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 6edbfd1..4f94bf8 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -42,6 +42,7 @@
#include "ss7_route.h"
#include "ss7_route_table.h"
#include "ss7_internal.h"
+#include "ss7_xua_srv.h"
/*! \brief Find a SCCP User registered for given PC+SSN or SSN only
* First search all users with a valid PC for a full PC+SSN match.
@@ -682,7 +683,7 @@
LOGP(DLSCCP, LOGL_NOTICE,
"%s: Requesting an SCCP simple client on ASP %s configured with
'transport-role server'\n",
name, asp->cfg.name);
- xs = osmo_ss7_xua_server_find2(ss7,
+ xs = ss7_xua_server_find2(ss7,
asp->cfg.trans_proto, prot,
asp->cfg.local.port);
if (!xs) {
@@ -775,11 +776,11 @@
return NULL;
ss7->cfg.primary_pc = pc;
- xs = osmo_ss7_xua_server_create2(ss7, trans_proto, prot, local_port, local_ip);
+ xs = ss7_xua_server_create2(ss7, trans_proto, prot, local_port, local_ip);
if (!xs)
goto out_ss7;
- rc = osmo_ss7_xua_server_bind(xs);
+ rc = ss7_xua_server_bind(xs);
if (rc < 0)
goto out_xs;
@@ -791,7 +792,7 @@
return ss7->sccp;
out_xs:
- osmo_ss7_xua_server_destroy(xs);
+ ss7_xua_server_destroy(xs);
out_ss7:
osmo_ss7_instance_destroy(ss7);
@@ -848,7 +849,7 @@
trans_proto, prot);
if (!asp)
goto out_rt;
- oxs = osmo_ss7_xua_server_find2(ss7, asp->cfg.trans_proto, prot, local_port);
+ oxs = ss7_xua_server_find2(ss7, asp->cfg.trans_proto, prot, local_port);
if (!oxs)
goto out_asp;
if (osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp,
diff --git a/src/ss7_internal.h b/src/ss7_internal.h
index 9a10fab..5d576c5 100644
--- a/src/ss7_internal.h
+++ b/src/ss7_internal.h
@@ -36,8 +36,6 @@
bool ss7_asp_peer_match_host(const struct osmo_ss7_asp_peer *peer, const char *host, bool
host_is_v6);
int ss7_asp_peer_find_host(const struct osmo_ss7_asp_peer *peer, const char *host);
-bool ss7_xua_server_set_default_local_hosts(struct osmo_xua_server *oxs);
-
int xua_tcp_segmentation_cb(struct msgb *msg);
enum ss7_as_ctr {
diff --git a/src/ss7_xua_srv.h b/src/ss7_xua_srv.h
new file mode 100644
index 0000000..770d369
--- /dev/null
+++ b/src/ss7_xua_srv.h
@@ -0,0 +1,79 @@
+#pragma once
+
+#include <stdint.h>
+#include <unistd.h>
+#include <osmocom/core/defs.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/prim.h>
+#include <osmocom/netif/stream.h>
+
+#include <osmocom/sigtran/osmo_ss7.h>
+
+/***********************************************************************
+ * xUA Servers
+ ***********************************************************************/
+
+struct osmo_ss7_instance;
+
+struct osmo_xua_layer_manager {
+ osmo_prim_cb prim_cb;
+};
+
+struct osmo_xua_server {
+ struct llist_head list;
+ struct osmo_ss7_instance *inst;
+
+ /* list of ASPs established via this server */
+ struct llist_head asp_list;
+
+ struct osmo_stream_srv_link *server;
+
+ struct {
+ bool accept_dyn_reg;
+ struct osmo_ss7_asp_peer local;
+ enum osmo_ss7_asp_protocol proto;
+ struct {
+ bool num_ostreams_present;
+ bool max_instreams_present;
+ uint16_t num_ostreams_value;
+ uint16_t max_instreams_value;
+ } sctp_init;
+
+ /*! The underlaying transport protocol (one of IPPROTO_*) */
+ int trans_proto;
+ } cfg;
+};
+
+struct osmo_xua_server *
+ss7_xua_server_find(struct osmo_ss7_instance *inst,
+ enum osmo_ss7_asp_protocol proto,
+ uint16_t local_port)
+ OSMO_DEPRECATED("Use ss7_xua_server_find2() instead");
+struct osmo_xua_server *
+ss7_xua_server_find2(struct osmo_ss7_instance *inst,
+ int trans_proto,
+ enum osmo_ss7_asp_protocol proto,
+ uint16_t local_port);
+
+struct osmo_xua_server *
+ss7_xua_server_create(struct osmo_ss7_instance *inst,
+ enum osmo_ss7_asp_protocol proto,
+ uint16_t local_port, const char *local_host)
+ OSMO_DEPRECATED("Use ss7_xua_server_create2() instead");
+struct osmo_xua_server *
+ss7_xua_server_create2(struct osmo_ss7_instance *inst,
+ int trans_proto, enum osmo_ss7_asp_protocol proto,
+ uint16_t local_port, const char *local_host);
+
+int
+ss7_xua_server_bind(struct osmo_xua_server *xs);
+
+int
+ss7_xua_server_set_local_host(struct osmo_xua_server *xs, const char *local_host);
+int
+ss7_xua_server_set_local_hosts(struct osmo_xua_server *xs, const char **local_hosts,
size_t local_host_cnt);
+int ss7_xua_server_add_local_host(struct osmo_xua_server *xs, const char *local_host);
+int ss7_xua_server_del_local_host(struct osmo_xua_server *xs, const char *local_host);
+void ss7_xua_server_destroy(struct osmo_xua_server *xs);
+
+bool ss7_xua_server_set_default_local_hosts(struct osmo_xua_server *oxs);
diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index 3a9be3f..9e9f8ac 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -28,6 +28,7 @@
#include <osmocom/sigtran/protocol/sua.h>
#include "ss7_internal.h"
+#include "ss7_xua_srv.h"
#include "xua_asp_fsm.h"
#include "xua_as_fsm.h"
#include "xua_internal.h"
diff --git a/src/xua_default_lm_fsm.c b/src/xua_default_lm_fsm.c
index 639d30a..b55f982 100644
--- a/src/xua_default_lm_fsm.c
+++ b/src/xua_default_lm_fsm.c
@@ -37,6 +37,7 @@
#include "xua_internal.h"
#include "xua_asp_fsm.h"
+#include "ss7_xua_srv.h"
#define S(x) (1 << (x))
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sigtran/+/38642?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Ie03697fdb2c9f95de011b21771261e52befb6018
Gerrit-Change-Number: 38642
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>