osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/38736?usp=email )
Change subject: Make compatible with private sigtran structs ......................................................................
Make compatible with private sigtran structs
Adjust OsmoHNBGW to build with newer versions of libosmo-sigtran, where several structs were made private. This is based on Pau's patch a3c0a005 ("Use new libosmo-sigtran APIs to access osmo_ss7_instance").
Related: OS#6617 Change-Id: I9e53953bc56fc5920eefb0a39dbf1e0b9843e00e --- M configure.ac M include/osmocom/hnbgw/hnbgw.h M src/osmo-hnbgw/context_map.c M src/osmo-hnbgw/hnbgw_cn.c 4 files changed, 68 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/36/38736/1
diff --git a/configure.ac b/configure.ac index ac1fc0f..8275ec9 100644 --- a/configure.ac +++ b/configure.ac @@ -233,6 +233,10 @@ [AC_DEFINE(PFCP_PRIVATE_STRUCTS, [1], ["OS#6617"])], [], [[#include <osmocom/pfcp/pfcp_cp_peer.h>]]) +AC_CHECK_DECL([osmo_ss7_instance_get_primary_pc], + [AC_DEFINE(SIGTRAN_PRIVATE_STRUCTS, [1], ["OS#6617"])], + [], + [[#include <osmocom/sigtran/osmo_ss7.h>]])
dnl Generate the output AM_CONFIG_HEADER(config.h) diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h index caaff5f..48f4536 100644 --- a/include/osmocom/hnbgw/hnbgw.h +++ b/include/osmocom/hnbgw/hnbgw.h @@ -1,5 +1,8 @@ #pragma once
+/* This is fine because hnbgw.h is in noinst_HEADERS in Makefile.am */ +#include "config.h" + #include <osmocom/core/select.h> #include <osmocom/core/linuxlist.h> #include <osmocom/core/hashtable.h> @@ -333,7 +336,11 @@ return NULL; if (!cnlink->hnbgw_sccp_user->ss7) return NULL; +#ifdef SIGTRAN_PRIVATE_STRUCTS + return osmo_ss7_get_sccp(cnlink->hnbgw_sccp_user->ss7); +#else return cnlink->hnbgw_sccp_user->ss7->sccp; +#endif }
/* The lifecycle of the hnb_context object is the same as its conn */ diff --git a/src/osmo-hnbgw/context_map.c b/src/osmo-hnbgw/context_map.c index 08d6a39..8bfe844 100644 --- a/src/osmo-hnbgw/context_map.c +++ b/src/osmo-hnbgw/context_map.c @@ -111,7 +111,11 @@ return -EIO; }
+#ifdef SIGTRAN_PRIVATE_STRUCTS + new_scu_conn_id = osmo_sccp_instance_next_conn_id(osmo_ss7_get_sccp(hsu->ss7)); +#else new_scu_conn_id = osmo_sccp_instance_next_conn_id(hsu->ss7->sccp); +#endif if (new_scu_conn_id < 0) { LOG_MAP(map, DCN, LOGL_ERROR, "Unable to allocate SCCP conn ID on %s\n", hsu->name); return new_scu_conn_id; diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c index 7bfe526..259ca77 100644 --- a/src/osmo-hnbgw/hnbgw_cn.c +++ b/src/osmo-hnbgw/hnbgw_cn.c @@ -435,7 +435,11 @@ cnlink = hnbgw_cnlink_find_by_addr(hsu, calling_addr); if (!cnlink) { LOG_HSI(hsu, DRANAP, LOGL_ERROR, "Rx from unknown SCCP peer: %s: %s\n", +#ifdef SIGTRAN_PRIVATE_STRUCTS + osmo_sccp_inst_addr_name(osmo_ss7_get_sccp(hsu->ss7), calling_addr), +#else osmo_sccp_inst_addr_name(hsu->ss7->sccp, calling_addr), +#endif osmo_scu_prim_hdr_name_c(OTC_SELECT, oph)); return NULL; } @@ -795,7 +799,11 @@ { struct osmo_ss7_instance *ss7 = cnlink->hnbgw_sccp_user->ss7; LOG_CNLINK(cnlink, DCN, LOGL_NOTICE, "using: cs7-%u %s <-> %s %s %s\n", +#ifdef SIGTRAN_PRIVATE_STRUCTS + osmo_ss7_instance_get_id(ss7), +#else ss7->cfg.id, +#endif /* printing the entire SCCP address is quite long, rather just print the point-code */ osmo_ss7_pointcode_print(ss7, cnlink->hnbgw_sccp_user->local_addr.pc), osmo_ss7_pointcode_print2(ss7, cnlink->remote_addr.pc), @@ -841,7 +849,11 @@ }
LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "remote-addr is '%s', using cs7 instance %u\n", +#ifdef SIGTRAN_PRIVATE_STRUCTS + cnlink->use.remote_addr_name, osmo_ss7_instance_get_id(ss7)); +#else cnlink->use.remote_addr_name, ss7->cfg.id); +#endif } else { /* If no address is configured, use the default remote CN address, according to legacy behavior. */ osmo_sccp_make_addr_pc_ssn(&cnlink->remote_addr, cnlink->pool->default_remote_pc, OSMO_SCCP_SSN_RANAP); @@ -861,35 +873,72 @@ continue; cnlink->hnbgw_sccp_user = hsu; LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "using existing SCCP instance %s on cs7 instance %u\n", +#ifdef SIGTRAN_PRIVATE_STRUCTS + hsu->name, osmo_ss7_instance_get_id(ss7)); +#else hsu->name, ss7->cfg.id); +#endif hnbgw_cnlink_log_self(cnlink); return 0; } /* else cnlink->hnbgw_sccp_user stays NULL and is set up below. */ +#ifdef SIGTRAN_PRIVATE_STRUCTS + LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "cs7 instance %u has no configured SCCP instance yet\n", osmo_ss7_instance_get_id(ss7)); +#else LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "cs7 instance %u has no configured SCCP instance yet\n", ss7->cfg.id); +#endif }
/* No SCCP instance yet for this ss7. Create it. If no address name is given that resolves to a * particular cs7 instance above, use 'cs7 instance 0'. */ +#ifdef SIGTRAN_PRIVATE_STRUCTS + sccp = osmo_sccp_simple_client_on_ss7_id(g_hnbgw, + ss7 ? osmo_ss7_instance_get_id(ss7) : 0, + cnlink->name, + DEFAULT_PC_HNBGW, + OSMO_SS7_ASP_PROT_M3UA, + 0, + "localhost", + -1, + "localhost"); +#else sccp = osmo_sccp_simple_client_on_ss7_id(g_hnbgw, ss7 ? ss7->cfg.id : 0, cnlink->name, DEFAULT_PC_HNBGW, OSMO_SS7_ASP_PROT_M3UA, 0, "localhost", -1, "localhost"); +#endif if (!sccp) { LOG_CNLINK(cnlink, DCN, LOGL_ERROR, "Failed to configure SCCP on 'cs7 instance %u'\n", +#ifdef SIGTRAN_PRIVATE_STRUCTS + ss7 ? osmo_ss7_instance_get_id(ss7) : 0); +#else ss7 ? ss7->cfg.id : 0); +#endif return -1; } ss7 = osmo_sccp_get_ss7(sccp); +#ifdef SIGTRAN_PRIVATE_STRUCTS + LOG_CNLINK(cnlink, DCN, LOGL_NOTICE, "created SCCP instance on cs7 instance %u\n", osmo_ss7_instance_get_id(ss7)); +#else LOG_CNLINK(cnlink, DCN, LOGL_NOTICE, "created SCCP instance on cs7 instance %u\n", ss7->cfg.id); +#endif
/* Bind the SCCP user, using the cs7 instance's default point-code if one is configured, or osmo-hnbgw's default * local PC. */ +#ifdef SIGTRAN_PRIVATE_STRUCTS + local_pc = osmo_ss7_instance_get_primary_pc(ss7); + if (!osmo_ss7_pc_is_valid(local_pc)) +#else if (osmo_ss7_pc_is_valid(ss7->cfg.primary_pc)) local_pc = ss7->cfg.primary_pc; else +#endif local_pc = DEFAULT_PC_HNBGW;
LOG_CNLINK(cnlink, DCN, LOGL_DEBUG, "binding OsmoHNBGW user to cs7 instance %u, local PC %u = %s\n", +#ifdef SIGTRAN_PRIVATE_STRUCTS + osmo_ss7_instance_get_id(ss7), local_pc, osmo_ss7_pointcode_print(ss7, local_pc)); +#else ss7->cfg.id, local_pc, osmo_ss7_pointcode_print(ss7, local_pc)); +#endif
sccp_user = osmo_sccp_user_bind_pc(sccp, "OsmoHNBGW", sccp_sap_up, OSMO_SCCP_SSN_RANAP, local_pc); if (!sccp_user) { @@ -899,7 +948,11 @@
hsu = talloc_zero(cnlink, struct hnbgw_sccp_user); *hsu = (struct hnbgw_sccp_user){ +#ifdef SIGTRAN_PRIVATE_STRUCTS + .name = talloc_asprintf(hsu, "cs7-%u.sccp", osmo_ss7_instance_get_id(ss7)), +#else .name = talloc_asprintf(hsu, "cs7-%u.sccp", ss7->cfg.id), +#endif .ss7 = ss7, .sccp_user = sccp_user, };