From 2af648f443257284d994ea6d79d9554ed866dfa6 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 23 Nov 2017 00:39:53 +0100 Subject: osmo-hnbgw: auto-config local and remote PCs if omitted The current default point-code for OsmoMSC is 0.23.1 and for OsmoSGSN 0.23.4. See https://osmocom.org/projects/cellular-infrastructure/wiki/Point_Codes. Before this patch, osmo-hnbgw requires a cs7 config and explicit point-codes for MSC and SGSN as well as a local one. Provide default config if none is provided: Use above default point-codes if no MSC and/or SGSN address are provided. Also create a default cs7 instance with local PC 0.23.5. This allows completely omitting cs7 instance and SCCP addresses from osmo-hnbgw.cfg in a single-box setup. Change-Id: I056547f26858d3ad52e66a15f7a4273dcc300e97 --- src/hnbgw_cn.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/hnbgw_cn.c b/src/hnbgw_cn.c index a48b651..eba05a4 100644 --- a/src/hnbgw_cn.c +++ b/src/hnbgw_cn.c @@ -410,13 +410,16 @@ static bool addr_has_pc_and_ssn(const struct osmo_sccp_addr *addr) } static int resolve_addr_name(struct osmo_sccp_addr *dest, struct osmo_ss7_instance **ss7, - const char *addr_name, const char *label) + const char *addr_name, const char *label, + uint32_t default_pc) { struct osmo_ss7_instance *ss7_tmp; if (!addr_name) { - LOGP(DMAIN, LOGL_ERROR, "Missing config: %s remote-addr\n", label); - return -1; + osmo_sccp_make_addr_pc_ssn(dest, default_pc, OSMO_SCCP_SSN_RANAP); + LOGP(DMAIN, LOGL_INFO, "%s remote addr not configured, using default: %s\n", label, + osmo_sccp_addr_name(*ss7, dest)); + return 0; } ss7_tmp = osmo_sccp_addr_by_name(dest, addr_name); @@ -458,12 +461,19 @@ int hnbgw_cnlink_init(struct hnb_gw *gw, const char *stp_host, uint16_t stp_port ss7 = NULL; if (resolve_addr_name(&gw->sccp.iucs_remote_addr, &ss7, - gw->config.iucs_remote_addr_name, "IuCS")) + gw->config.iucs_remote_addr_name, "IuCS", (23 << 3) + 1)) return -1; if (resolve_addr_name(&gw->sccp.iups_remote_addr, &ss7, - gw->config.iups_remote_addr_name, "IuPS")) + gw->config.iups_remote_addr_name, "IuPS", (23 << 3) + 4)) return -1; + if (!ss7) { + LOGP(DRANAP, LOGL_NOTICE, "No cs7 instance configured for IuCS nor IuPS," + " creating default instance\n"); + ss7 = osmo_ss7_instance_find_or_create(gw, 0); + ss7->cfg.primary_pc = (23 << 3) + 5; + } + if (!osmo_ss7_pc_is_valid(ss7->cfg.primary_pc)) { LOGP(DMAIN, LOGL_ERROR, "IuCS/IuPS uplink cannot be setup: CS7 instance %d has no point-code set\n", ss7->cfg.id); -- cgit v1.2.3