fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-sccp/+/35999?usp=email )
Change subject: [RFC] osmo_sccp_simple_{client,server}(): allow passing trans_proto
......................................................................
[RFC] osmo_sccp_simple_{client,server}(): allow passing trans_proto
Change-Id: Ife62326daedaa3bf2f4d1fbff596ead209cb3656
Related: SYS#5424
---
M examples/sccp_demo_user.c
M include/osmocom/sigtran/osmo_ss7.h
M src/sccp_user.c
3 files changed, 248 insertions(+), 89 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/99/35999/1
diff --git a/examples/sccp_demo_user.c b/examples/sccp_demo_user.c
index 9308083..33969cb 100644
--- a/examples/sccp_demo_user.c
+++ b/examples/sccp_demo_user.c
@@ -31,18 +31,18 @@
static struct osmo_sccp_instance *g_sccp;
-static struct osmo_sccp_instance *sua_server_helper(enum osmo_ss7_asp_protocol protocol,
+static struct osmo_sccp_instance *sua_server_helper(int trans_proto, enum
osmo_ss7_asp_protocol proto,
int local_port, const char *local_address, int local_pc,
int remote_port, const char *remote_address, int remote_pc)
{
struct osmo_sccp_instance *sccp;
- sccp = osmo_sccp_simple_server(NULL, local_pc, protocol, local_port, local_address);
+ sccp = osmo_sccp_simple_server2(NULL, local_pc, trans_proto, proto, local_port,
local_address);
if (sccp == NULL)
return NULL;
- osmo_sccp_simple_server_add_clnt(sccp, protocol, "client", remote_pc,
local_port,
- remote_port, remote_address);
+ osmo_sccp_simple_server_add_clnt2(sccp, trans_proto, proto, "client",
remote_pc,
+ local_port, remote_port, remote_address);
return sccp;
}
@@ -113,7 +113,9 @@
" [-r REMOTE_ADDRESS[:REMOTE_PORT]]\n"
" [-L LOCAL_POINT_CODE] [-R REMOTE_POINT_CODE]\n"
"Options:\n"
- " -p: protocol to use (m3ua, sua, ipa; default is m3ua)\n"
+ " -p: ASP protocol to use (m3ua, sua, ipa; default is m3ua)\n"
+ " -P: transport protocol to use (sctp, tcp; default is tcp for ipa,\n"
+ " sctp for other ASP
protocols)\n"
" -c: Run in client mode (default is server mode)\n"
" -C filename The config file to use\n"
" -l: local IP address and SCTP port (default is %s:%d in server mode,\n"
@@ -185,18 +187,27 @@
int remote_port = DEFAULT_REMOTE_PORT_SERVER;
int remote_pc = DEFAULT_PC_CLIENT;
bool lflag = false, rflag = false, Lflag = false, Rflag = false;
- enum osmo_ss7_asp_protocol protocol = OSMO_SS7_ASP_PROT_M3UA;
+ enum osmo_ss7_asp_protocol proto = OSMO_SS7_ASP_PROT_M3UA;
+ int trans_proto = IPPROTO_SCTP;
void *tall_ctx = talloc_named_const(NULL, 1, "sccp_demo_user");
init_logging(tall_ctx);
- while ((ch = getopt(argc, argv, "p:cl:r:L:R:C:d:")) != -1) {
+ while ((ch = getopt(argc, argv, "p:P:cl:r:L:R:C:d:")) != -1) {
switch (ch) {
case 'p':
rc = get_string_value(osmo_ss7_asp_protocol_vals, optarg);
if (rc < 0)
exit(1);
- protocol = rc;
+ proto = rc;
+ break;
+ case 'P':
+ if (!strcmp(optarg, "sctp"))
+ trans_proto = IPPROTO_SCTP;
+ else if (!strcmp(optarg, "tcp"))
+ trans_proto = IPPROTO_TCP;
+ else
+ exit(1);
break;
case 'c':
client = true;
@@ -292,15 +303,18 @@
}
if (client) {
- g_sccp = osmo_sccp_simple_client(NULL, "client", local_pc, protocol,
- local_port, local_address, remote_port, remote_address);
+ g_sccp = osmo_sccp_simple_client2(NULL, "client", local_pc,
+ trans_proto, proto,
+ local_port, local_address,
+ remote_port, remote_address);
if (g_sccp == NULL) {
perror("Could not create SCCP client");
exit (1);
}
sccp_test_user_vty_install(g_sccp, OSMO_SCCP_SSN_BSSAP);
} else {
- g_sccp = sua_server_helper(protocol, local_port, local_address, local_pc,
+ g_sccp = sua_server_helper(trans_proto, proto,
+ local_port, local_address, local_pc,
remote_port, remote_address, remote_pc);
if (g_sccp == NULL) {
perror("Could not create SCCP server");
diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index 1afccea..bc399d1 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -601,35 +601,73 @@
struct osmo_sccp_instance *
osmo_sccp_simple_client(void *ctx, const char *name, uint32_t default_pc,
- enum osmo_ss7_asp_protocol prot, int default_local_port,
- const char *default_local_ip, int default_remote_port,
- const char *default_remote_ip);
+ enum osmo_ss7_asp_protocol proto,
+ int default_local_port,
+ const char *default_local_ip,
+ int default_remote_port,
+ const char *default_remote_ip)
+ OSMO_DEPRECATED("Use osmo_sccp_simple_client2() instead");
+struct osmo_sccp_instance *
+osmo_sccp_simple_client2(void *ctx, const char *name, uint32_t default_pc,
+ int trans_proto, enum osmo_ss7_asp_protocol proto,
+ int default_local_port,
+ const char *default_local_ip,
+ int default_remote_port,
+ const char *default_remote_ip);
struct osmo_sccp_instance *
osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
uint32_t default_pc,
- enum osmo_ss7_asp_protocol prot,
+ enum osmo_ss7_asp_protocol proto,
int default_local_port,
const char *default_local_ip,
int default_remote_port,
- const char *default_remote_ip);
+ const char *default_remote_ip)
+ OSMO_DEPRECATED("Use osmo_sccp_simple_client_on_ss7_id2() instead");
+struct osmo_sccp_instance *
+osmo_sccp_simple_client_on_ss7_id2(void *ctx, uint32_t ss7_id, const char *name,
+ uint32_t default_pc,
+ int trans_proto,
+ enum osmo_ss7_asp_protocol proto,
+ int default_local_port,
+ const char *default_local_ip,
+ int default_remote_port,
+ const char *default_remote_ip);
struct osmo_sccp_instance *
osmo_sccp_simple_server(void *ctx, uint32_t pc,
- enum osmo_ss7_asp_protocol prot, int local_port,
- const char *local_ip);
+ enum osmo_ss7_asp_protocol proto,
+ int local_port, const char *local_ip)
+ OSMO_DEPRECATED("Use osmo_sccp_simple_server2() instead");
+struct osmo_sccp_instance *
+osmo_sccp_simple_server2(void *ctx, uint32_t pc,
+ int trans_proto, enum osmo_ss7_asp_protocol proto,
+ int local_port, const char *local_ip);
struct osmo_sccp_instance *
osmo_sccp_simple_server_on_ss7_id(void *ctx, uint32_t ss7_id, uint32_t pc,
- enum osmo_ss7_asp_protocol prot,
- int local_port, const char *local_ip);
+ enum osmo_ss7_asp_protocol proto,
+ int local_port, const char *local_ip)
+ OSMO_DEPRECATED("Use osmo_sccp_simple_server_on_ss7_id2() instead");
+struct osmo_sccp_instance *
+osmo_sccp_simple_server_on_ss7_id2(void *ctx, uint32_t ss7_id, uint32_t pc,
+ int trans_proto, enum osmo_ss7_asp_protocol proto,
+ int local_port, const char *local_ip);
struct osmo_sccp_instance *
osmo_sccp_simple_server_add_clnt(struct osmo_sccp_instance *inst,
- enum osmo_ss7_asp_protocol prot,
+ enum osmo_ss7_asp_protocol proto,
const char *name, uint32_t pc,
int local_port, int remote_port,
- const char *remote_ip);
+ const char *remote_ip)
+ OSMO_DEPRECATED("Use osmo_sccp_simple_server_add_clnt2() instead");
+struct osmo_sccp_instance *
+osmo_sccp_simple_server_add_clnt2(struct osmo_sccp_instance *inst,
+ int trans_proto,
+ enum osmo_ss7_asp_protocol proto,
+ const char *name, uint32_t pc,
+ int local_port, int remote_port,
+ const char *remote_ip);
void osmo_sccp_set_max_optional_data(struct osmo_sccp_instance *inst, int val);
diff --git a/src/sccp_user.c b/src/sccp_user.c
index f79832f..3a8d23a 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -490,7 +490,8 @@
* \param[in] ss7_id of the SS7/CS7 instance
* \param[in] name human readable name
* \param[in] default_pc pointcode to be used on missing VTY setting
- * \param[in] prot protocol to be used (e.g OSMO_SS7_ASP_PROT_M3UA)
+ * \param[in] trans_proto transport protocol to be used (one of IPPROTO_*)
+ * \param[in] proto ASP protocol to be used (e.g OSMO_SS7_ASP_PROT_M3UA)
* \param[in] default_local_port local port to be used on missing VTY setting
* \param[in] default_local_ip local IP-address to be used on missing VTY setting (NULL:
use library own defaults)
* \param[in] default_remote_port remote port to be used on missing VTY setting
@@ -498,13 +499,14 @@
* \returns callee-allocated SCCP instance on success; NULL on error */
struct osmo_sccp_instance *
-osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
- uint32_t default_pc,
- enum osmo_ss7_asp_protocol prot,
- int default_local_port,
- const char *default_local_ip,
- int default_remote_port,
- const char *default_remote_ip)
+osmo_sccp_simple_client_on_ss7_id2(void *ctx, uint32_t ss7_id, const char *name,
+ uint32_t default_pc,
+ int trans_proto,
+ enum osmo_ss7_asp_protocol proto,
+ int default_local_port,
+ const char *default_local_ip,
+ int default_remote_port,
+ const char *default_remote_ip)
{
struct osmo_ss7_instance *ss7;
bool ss7_created = false;
@@ -515,9 +517,6 @@
struct osmo_ss7_asp *asp;
bool asp_created = false;
char *as_name, *asp_name = NULL;
- int trans_proto;
-
- trans_proto = ss7_default_trans_proto_for_asp_proto(prot);
/*! The function will examine the given CS7 instance and its sub
* components (as, asp, etc.). If necessary it will allocate
@@ -525,12 +524,19 @@
* under the caller supplied ID, a new instance will be created
* beforehand. */
+ if (!ss7_asp_protocol_check_trans_proto(proto, trans_proto)) {
+ LOGP(DLSCCP, LOGL_ERROR,
+ "ASP protocol '%s' is not compatible with transport protocol
%d\n",
+ osmo_ss7_asp_protocol_name(proto), trans_proto);
+ return NULL;
+ }
+
/* Choose default ports when the caller does not supply valid port
* numbers. */
if (!default_remote_port || default_remote_port < 0)
- default_remote_port = osmo_ss7_asp_protocol_port(prot);
+ default_remote_port = osmo_ss7_asp_protocol_port(proto);
if (default_local_port < 0)
- default_local_port = osmo_ss7_asp_protocol_port(prot);
+ default_local_port = osmo_ss7_asp_protocol_port(proto);
/* Check if there is already an ss7 instance present under
* the given id. If not, we will create a new one. */
@@ -568,12 +574,12 @@
/* Check if there is already an application server that matches
* the protocol we intend to use. If not, we will create one. */
- as = osmo_ss7_as_find_by_proto(ss7, prot);
+ as = osmo_ss7_as_find_by_proto(ss7, proto);
if (!as) {
LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating AS instance\n",
name);
as_name = talloc_asprintf(ctx, "as-clnt-%s", name);
- as = osmo_ss7_as_find_or_create(ss7, as_name, prot);
+ as = osmo_ss7_as_find_or_create(ss7, as_name, proto);
talloc_free(as_name);
if (!as)
goto out_ss7;
@@ -599,17 +605,17 @@
* that is associated with the application server we have choosen
* the application server process must also match the protocol
* we intend to use. */
- asp = osmo_ss7_asp_find_by_proto2(as, trans_proto, prot);
+ asp = osmo_ss7_asp_find_by_proto2(as, trans_proto, proto);
if (!asp) {
/* Check if the user has created an ASP for this proto that is not added on any AS yet.
*/
struct osmo_ss7_asp *asp_i;
llist_for_each_entry(asp_i, &ss7->asp_list, list) {
struct osmo_ss7_as *as_i;
bool is_on_as = false;
- if (asp_i->cfg.proto != prot)
- continue;
if (asp_i->cfg.trans_proto != trans_proto)
continue;
+ if (asp_i->cfg.proto != proto)
+ continue;
llist_for_each_entry(as_i, &ss7->as_list, list) {
if (!osmo_ss7_as_has_asp(as_i, asp_i))
continue;
@@ -623,23 +629,22 @@
/* This ASP matches the protocol and is not yet associated to any AS. Use it. */
asp = asp_i;
LOGP(DLSCCP, LOGL_NOTICE, "%s: ASP %s for %s is not associated with any AS, using
it\n",
- name, asp->cfg.name, osmo_ss7_asp_protocol_name(prot));
+ name, asp->cfg.name, osmo_ss7_asp_protocol_name(proto));
break;
}
if (!asp) {
asp_name = talloc_asprintf(ctx, "asp-clnt-%s", name);
LOGP(DLSCCP, LOGL_NOTICE, "%s: No unassociated ASP for %s, creating new ASP
%s\n",
- name, osmo_ss7_asp_protocol_name(prot), asp_name);
- asp =
- osmo_ss7_asp_find_or_create2(ss7, asp_name,
- default_remote_port,
- default_local_port,
- trans_proto, prot);
+ name, osmo_ss7_asp_protocol_name(proto), asp_name);
+ asp = osmo_ss7_asp_find_or_create2(ss7, asp_name,
+ default_remote_port,
+ default_local_port,
+ trans_proto, proto);
talloc_free(asp_name);
if (!asp)
goto out_rt;
asp_created = true;
- /* Ensure that the ASP we use is set to operate as a client. */
+ /* Ensure that the ASP we use is set to sctp-role client. */
asp->cfg.is_server = false;
/* Ensure that the ASP we use is set to role ASP. */
asp->cfg.role = OSMO_SS7_ASP_ROLE_ASP;
@@ -658,7 +663,7 @@
/* Extra sanity checks if the ASP asp-clnt-* was pre-configured over VTY: */
if (!asp->simple_client_allocated) {
/* Forbid ASPs defined through VTY that are not entirely
- * configured. "role" and "transport-role" must be explicitly
provided:
+ * configured. "role" and "sctp-role" must be explicitly provided:
*/
if (!asp->cfg.role_set_by_vty) {
LOGP(DLSCCP, LOGL_ERROR,
@@ -668,7 +673,7 @@
}
if (!asp->cfg.trans_role_set_by_vty) {
LOGP(DLSCCP, LOGL_ERROR,
- "%s: ASP %s defined in VTY but 'transport-role' was not set there,
please set it.\n",
+ "%s: ASP %s defined in VTY but 'sctp-role' was not set there, please
set it.\n",
name, asp->cfg.name);
goto out_asp;
}
@@ -676,17 +681,17 @@
/* 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 transport-role server if properly configured through VTY.
+ * 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
'transport-role server'\n",
+ "%s: Requesting an SCCP simple client on ASP %s configured with
'sctp-role server'\n",
name, asp->cfg.name);
- xs = osmo_ss7_xua_server_find2(ss7, trans_proto, prot, asp->cfg.local.port);
+ xs = osmo_ss7_xua_server_find2(ss7, trans_proto, proto, asp->cfg.local.port);
if (!xs) {
LOGP(DLSCCP, LOGL_ERROR, "%s: Requesting an SCCP simple client on ASP %s
configured "
- "with 'transport-role server' but no matching xUA server was
configured!\n",
+ "with 'sctp-role server' but no matching xUA server was
configured!\n",
name, asp->cfg.name);
goto out_asp;
}
@@ -694,7 +699,7 @@
}
/* Restart ASP */
- if (prot != OSMO_SS7_ASP_PROT_IPA)
+ if (proto != OSMO_SS7_ASP_PROT_IPA)
osmo_ss7_asp_use_default_lm(asp, LOGL_DEBUG);
osmo_ss7_asp_restart(asp);
LOGP(DLSCCP, LOGL_NOTICE, "%s: Using ASP instance %s\n", name,
@@ -722,31 +727,74 @@
return NULL;
}
+/*! \brief deprecated ancestor of osmo_sccp_simple_client_on_ss7_id2() */
+struct osmo_sccp_instance *
+osmo_sccp_simple_client_on_ss7_id(void *ctx, uint32_t ss7_id, const char *name,
+ uint32_t default_pc,
+ enum osmo_ss7_asp_protocol proto,
+ int default_local_port,
+ const char *default_local_ip,
+ int default_remote_port,
+ const char *default_remote_ip)
+{
+ const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto);
+
+ return osmo_sccp_simple_client_on_ss7_id2(ctx, ss7_id, name,
+ default_pc,
+ trans_proto, proto,
+ default_local_port,
+ default_local_ip,
+ default_remote_port,
+ default_remote_ip);
+}
+
/*! \brief request an sccp client instance
* \param[in] ctx talloc context
* \param[in] name human readable name
* \param[in] default_pc pointcode to be used on missing VTY setting
- * \param[in] prot protocol to be used (e.g OSMO_SS7_ASP_PROT_M3UA)
+ * \param[in] trans_proto transport protocol to be used (one of IPPROTO_*)
+ * \param[in] proto ASP protocol to be used (e.g OSMO_SS7_ASP_PROT_M3UA)
* \param[in] default_local_port local port to be used on missing VTY setting
* \param[in] default_local_ip local IP-address to be used on missing VTY setting
* \param[in] default_remote_port remote port to be used on missing VTY setting
* \param[in] default_remote_ip remote IP-address to be used on missing VTY setting
* \returns callee-allocated SCCP instance on success; NULL on error */
struct osmo_sccp_instance *
-osmo_sccp_simple_client(void *ctx, const char *name, uint32_t default_pc,
- enum osmo_ss7_asp_protocol prot, int default_local_port,
- const char *default_local_ip, int default_remote_port,
- const char *default_remote_ip)
+osmo_sccp_simple_client2(void *ctx, const char *name, uint32_t default_pc,
+ int trans_proto, enum osmo_ss7_asp_protocol proto,
+ int default_local_port,
+ const char *default_local_ip,
+ int default_remote_port,
+ const char *default_remote_ip)
{
/*! This is simplified version of osmo_sccp_simple_client_on_ss7_id().
* the only difference is that the ID of the CS7 instance will be
* set to 0 statically */
- return osmo_sccp_simple_client_on_ss7_id(ctx, 0, name, default_pc, prot,
- default_local_port,
- default_local_ip,
- default_remote_port,
- default_remote_ip);
+ return osmo_sccp_simple_client_on_ss7_id2(ctx, 0, name, default_pc,
+ trans_proto, proto,
+ default_local_port,
+ default_local_ip,
+ default_remote_port,
+ default_remote_ip);
+}
+
+/*! \brief deprecated ancestor of osmo_sccp_simple_client2() */
+struct osmo_sccp_instance *
+osmo_sccp_simple_client(void *ctx, const char *name, uint32_t default_pc,
+ enum osmo_ss7_asp_protocol proto, int default_local_port,
+ const char *default_local_ip, int default_remote_port,
+ const char *default_remote_ip)
+{
+ const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto);
+
+ return osmo_sccp_simple_client_on_ss7_id2(ctx, 0, name,
+ default_pc,
+ trans_proto, proto,
+ default_local_port,
+ default_local_ip,
+ default_remote_port,
+ default_remote_ip);
}
/***********************************************************************
@@ -754,19 +802,23 @@
***********************************************************************/
struct osmo_sccp_instance *
-osmo_sccp_simple_server_on_ss7_id(void *ctx, uint32_t ss7_id, uint32_t pc,
- enum osmo_ss7_asp_protocol prot,
- int local_port, const char *local_ip)
+osmo_sccp_simple_server_on_ss7_id2(void *ctx, uint32_t ss7_id, uint32_t pc,
+ int trans_proto, enum osmo_ss7_asp_protocol proto,
+ int local_port, const char *local_ip)
{
struct osmo_ss7_instance *ss7;
struct osmo_xua_server *xs;
- int trans_proto;
int rc;
- trans_proto = ss7_default_trans_proto_for_asp_proto(prot);
+ if (!ss7_asp_protocol_check_trans_proto(proto, trans_proto)) {
+ LOGP(DLSCCP, LOGL_ERROR,
+ "ASP protocol '%s' is not compatible with transport protocol
%d\n",
+ osmo_ss7_asp_protocol_name(proto), trans_proto);
+ return NULL;
+ }
if (local_port < 0)
- local_port = osmo_ss7_asp_protocol_port(prot);
+ local_port = osmo_ss7_asp_protocol_port(proto);
/* allocate + initialize SS7 instance */
ss7 = osmo_ss7_instance_find_or_create(ctx, ss7_id);
@@ -774,7 +826,7 @@
return NULL;
ss7->cfg.primary_pc = pc;
- xs = osmo_ss7_xua_server_create2(ss7, trans_proto, prot, local_port, local_ip);
+ xs = osmo_ss7_xua_server_create2(ss7, trans_proto, proto, local_port, local_ip);
if (!xs)
goto out_ss7;
@@ -798,20 +850,46 @@
}
struct osmo_sccp_instance *
-osmo_sccp_simple_server(void *ctx, uint32_t pc,
- enum osmo_ss7_asp_protocol prot, int local_port,
- const char *local_ip)
+osmo_sccp_simple_server_on_ss7_id(void *ctx, uint32_t ss7_id, uint32_t pc,
+ enum osmo_ss7_asp_protocol proto,
+ int local_port, const char *local_ip)
{
- return osmo_sccp_simple_server_on_ss7_id(ctx, 0, pc, prot,
- local_port, local_ip);
+ const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto);
+
+ return osmo_sccp_simple_server_on_ss7_id2(ctx, ss7_id, pc,
+ trans_proto, proto,
+ local_port, local_ip);
}
struct osmo_sccp_instance *
-osmo_sccp_simple_server_add_clnt(struct osmo_sccp_instance *inst,
- enum osmo_ss7_asp_protocol prot,
- const char *name, uint32_t pc,
- int local_port, int remote_port,
- const char *remote_ip)
+osmo_sccp_simple_server2(void *ctx, uint32_t pc,
+ int trans_proto, enum osmo_ss7_asp_protocol proto,
+ int local_port, const char *local_ip)
+{
+ return osmo_sccp_simple_server_on_ss7_id2(ctx, 0, pc,
+ trans_proto, proto,
+ local_port, local_ip);
+}
+
+struct osmo_sccp_instance *
+osmo_sccp_simple_server(void *ctx, uint32_t pc,
+ enum osmo_ss7_asp_protocol proto,
+ int local_port, const char *local_ip)
+{
+ const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto);
+
+ return osmo_sccp_simple_server_on_ss7_id2(ctx, 0, pc,
+ trans_proto, proto,
+ local_port, local_ip);
+}
+
+struct osmo_sccp_instance *
+osmo_sccp_simple_server_add_clnt2(struct osmo_sccp_instance *inst,
+ int trans_proto,
+ enum osmo_ss7_asp_protocol proto,
+ const char *name, uint32_t pc,
+ int local_port, int remote_port,
+ const char *remote_ip)
{
struct osmo_ss7_instance *ss7 = inst->ss7;
struct osmo_ss7_as *as;
@@ -819,21 +897,25 @@
struct osmo_ss7_asp *asp;
struct osmo_xua_server *oxs;
char *as_name, *asp_name;
- int trans_proto;
- trans_proto = ss7_default_trans_proto_for_asp_proto(prot);
+ if (!ss7_asp_protocol_check_trans_proto(proto, trans_proto)) {
+ LOGP(DLSCCP, LOGL_ERROR,
+ "ASP protocol '%s' is not compatible with transport protocol
%d\n",
+ osmo_ss7_asp_protocol_name(proto), trans_proto);
+ return NULL;
+ }
if (local_port < 0)
- local_port = osmo_ss7_asp_protocol_port(prot);
+ local_port = osmo_ss7_asp_protocol_port(proto);
if (remote_port < 0)
- remote_port = osmo_ss7_asp_protocol_port(prot);
+ remote_port = osmo_ss7_asp_protocol_port(proto);
as_name = talloc_asprintf(ss7, "as-srv-%s", name);
asp_name = talloc_asprintf(ss7, "asp-srv-%s", name);
/* application server */
- as = osmo_ss7_as_find_or_create(ss7, as_name, prot);
+ as = osmo_ss7_as_find_or_create(ss7, as_name, proto);
if (!as)
goto out_strings;
@@ -844,10 +926,10 @@
asp = osmo_ss7_asp_find_or_create2(ss7, asp_name,
remote_port, local_port,
- trans_proto, prot);
+ trans_proto, proto);
if (!asp)
goto out_rt;
- oxs = osmo_ss7_xua_server_find2(ss7, trans_proto, prot, local_port);
+ oxs = osmo_ss7_xua_server_find2(ss7, trans_proto, proto, local_port);
if (!oxs)
goto out_asp;
if (osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp,
@@ -878,6 +960,21 @@
return NULL;
}
+struct osmo_sccp_instance *
+osmo_sccp_simple_server_add_clnt(struct osmo_sccp_instance *inst,
+ enum osmo_ss7_asp_protocol proto,
+ const char *name, uint32_t pc,
+ int local_port, int remote_port,
+ const char *remote_ip)
+{
+ const int trans_proto = ss7_default_trans_proto_for_asp_proto(proto);
+
+ return osmo_sccp_simple_server_add_clnt2(inst,
+ trans_proto, proto,
+ name, pc, local_port,
+ remote_port, remote_ip);
+}
+
/*! Adjust the upper bound for the optional data length (the payload) for CR, CC, CREF
and RLSD messages.
* For any Optional Data part larger than this value in octets, send CR, CC, CREF and
RLSD messages without any payload,
* and send the data payload in a separate Data Form 1 message. ITU-T Q.713 sections 4.2
thru 4.5 define a limit of 130
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sccp/+/35999?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: Ife62326daedaa3bf2f4d1fbff596ead209cb3656
Gerrit-Change-Number: 35999
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange