From fec3785156cb86ecf71a1e9c0b5e5ca6eb637440 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Wed, 6 Nov 2019 17:54:35 +0100 Subject: xua: On new ASPAC, set and notify other ASPs as inactive RFC4666 sec 4.3.4.3. ASP Active Procedures: """ In the case of an Override mode AS, receipt of an ASP Active message at an SGP causes the (re)direction of all traffic for the AS to the ASP that sent the ASP Active message. Any previously active ASP in the AS is now considered to be in the state ASP-INACTIVE and SHOULD no longer receive traffic from the SGP within the AS. The SGP or IPSP then MUST send a Notify message ("Alternate ASP_Active") to the previously active ASP in the AS and SHOULD stop traffic to/from that ASP. The ASP receiving this Notify MUST consider itself now in the ASP-INACTIVE state, if it is not already aware of this via inter-ASP communication with the Overriding ASP. """ Change-Id: I474f5cc1f6cbab72d010d1f8ac7ed2285e4c1c45 --- src/xua_as_fsm.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c index 5d0b327..c25902e 100644 --- a/src/xua_as_fsm.c +++ b/src/xua_as_fsm.c @@ -211,6 +211,37 @@ static bool check_any_other_asp_in_active(struct osmo_ss7_as *as, struct osmo_ss return false; } +/* Tell other previously-active ASPs that a new ASP has been activated and mark + them as inactive. Used in override mode when an ASP becomes active. */ +static void notify_any_other_active_asp_as_inactive(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp_cmp) +{ + unsigned int i; + struct msgb *msg; + struct osmo_xlm_prim_notify npar = { + .status_type = M3UA_NOTIFY_T_OTHER, + .status_info = M3UA_NOTIFY_I_OT_ALT_ASP_ACT, + }; + + if (asp_cmp->asp_id_present) + npar.asp_id = asp_cmp->asp_id; + + for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) { + struct osmo_ss7_asp *asp = as->cfg.asps[i]; + if (!asp || !osmo_ss7_asp_active(asp)) + continue; + + if (asp_cmp == asp) + continue; + + msg = encode_notify(&npar); + osmo_ss7_asp_send(asp, msg); + + osmo_fsm_inst_state_chg(asp->fi, XUA_ASP_S_INACTIVE, 0, 0); + } + + return; +} + static void t_r_callback(void *_fi) { struct osmo_fsm_inst *fi = _fi; @@ -321,7 +352,10 @@ static void xua_as_fsm_active(struct osmo_fsm_inst *fi, uint32_t event, void *da } break; case XUA_ASPAS_ASP_ACTIVE_IND: - /* ignore */ + asp = data; + /* RFC466 sec 4.3.4.3 ASP Active Procedures*/ + if (xafp->as->cfg.mode == OSMO_SS7_AS_TMOD_OVERRIDE) + notify_any_other_active_asp_as_inactive(xafp->as, asp); break; case XUA_AS_E_TRANSFER_REQ: /* message for transmission */ -- cgit v1.2.3