pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/41992?usp=email ) Change subject: Lb: Handle SCCP N-NOTICE.ind ...................................................................... Lb: Handle SCCP N-NOTICE.ind Change-Id: I689bf2f2c4311fbc1da92f02c27078a1c00dda1a --- M src/osmo-bsc/lb.c 1 file changed, 49 insertions(+), 0 deletions(-) Approvals: daniel: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/src/osmo-bsc/lb.c b/src/osmo-bsc/lb.c index d4f645a..63ab92b 100644 --- a/src/osmo-bsc/lb.c +++ b/src/osmo-bsc/lb.c @@ -21,6 +21,8 @@ * */ +#include <osmocom/sccp/sccp_types.h> + #include <osmocom/bsc/lb.h> #include <osmocom/gsm/bssmap_le.h> @@ -131,6 +133,48 @@ } } +/* Find an SMLC by its remote SCCP address */ +static struct smlc_config *get_smlc_by_addr(const struct osmo_sccp_addr *smlc_addr) +{ + struct smlc_config *smlc = bsc_gsmnet->smlc; + if (osmo_sccp_addr_ri_cmp(smlc_addr, &smlc->smlc_addr) == 0) + return smlc; + LOGP(DMSC, LOGL_ERROR, "Unable to find SMLC data under address: %s\n", + osmo_sccp_addr_dump(smlc_addr)); + return NULL; +} + +static int handle_notice_ind(const struct osmo_scu_notice_param *ni) +{ + int rc = 0; + struct smlc_config *smlc = get_smlc_by_addr(&ni->calling_addr); + if (!smlc) { + LOGP(DLCS, LOGL_DEBUG, "(calling_addr=%s) N-NOTICE.ind cause=%u='%s' importance=%u didn't match SMLC, ignoring\n", + osmo_sccp_addr_dump(&ni->calling_addr), + ni->cause, osmo_sccp_return_cause_name(ni->cause), + ni->importance); + return -EINVAL; + } + + LOGP(DLCS, LOGL_NOTICE, "(calling_addr=%s) N-NOTICE.ind cause=%u='%s' importance=%u\n", + osmo_sccp_addr_dump(&ni->calling_addr), + ni->cause, osmo_sccp_return_cause_name(ni->cause), + ni->importance); + + switch (ni->cause) { + case SCCP_RETURN_CAUSE_SUBSYSTEM_CONGESTION: + case SCCP_RETURN_CAUSE_NETWORK_CONGESTION: + /* Transient failures (hopefully), keep going. */ + return rc; + default: + break; + } + + /* Messages are not arriving to SMLC. Kick the BSSMAP back to DISC state. */ + bssmap_reset_set_disconnected(smlc->bssmap_reset); + return rc; +} + static int sccp_sap_up(struct osmo_prim_hdr *oph, void *_scu) { struct osmo_scu_prim *scu_prim = (struct osmo_scu_prim *)oph; @@ -147,6 +191,11 @@ rc = handle_unitdata_from_smlc(&scu_prim->u.unitdata.calling_addr, oph->msg, scu); break; + case OSMO_PRIM(OSMO_SCU_PRIM_N_NOTICE, PRIM_OP_INDICATION): + DEBUGP(DMSC, "N-NOTICE.ind(%s)\n", osmo_hexdump(msgb_l2(oph->msg), msgb_l2len(oph->msg))); + rc = handle_notice_ind(&scu_prim->u.notice); + break; + case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_INDICATION): /* Handle inbound connections. A Location Request is always started on the A interface, and OsmoBSC * forwards this to the SMLC by performing an N-CONNECT from BSC -> SMLC. This is the reverse -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/41992?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I689bf2f2c4311fbc1da92f02c27078a1c00dda1a Gerrit-Change-Number: 41992 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann@sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> Gerrit-Reviewer: pespin <pespin@sysmocom.de>