pespin has uploaded this change for review.

View Change

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, 139 insertions(+), 112 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/42/38642/1
diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index d558014..0027426 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -17,7 +17,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);
@@ -39,6 +38,14 @@
}

/***********************************************************************
+ * xUA Servers
+ ***********************************************************************/
+
+struct osmo_xua_layer_manager;
+
+struct osmo_xua_server;
+
+/***********************************************************************
* SS7 Instances
***********************************************************************/

@@ -402,70 +409,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 b258a02..8f848de 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,7 @@
ss7_route.h \
ss7_route_table.h \
ss7_user.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 59012bc..0402038 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -655,51 +655,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(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..6f149cd 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>

diff --git a/src/osmo_ss7_xua_srv.c b/src/osmo_ss7_xua_srv.c
index 473826f..3d57c63 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
@@ -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 *
+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);
+}
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 1ca5f1c..61b0829 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.
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..95f0914
--- /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 *
+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);
+
+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 change 38642. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Ie03697fdb2c9f95de011b21771261e52befb6018
Gerrit-Change-Number: 38642
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>