From 6c81adda452a2eb9b5e25c3ed36bb61ba46c2c34 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 7 Sep 2021 14:43:46 +0200 Subject: [PATCH] nacc_fsm: Move logic checking if SI is being waited for to a func helper We already have a similar function for Neighbor Address Resolution. This way we keep as much as possible internal state related logic into the nacc_fsm.c file. Change-Id: I7378939825cc3ec3280f76bc51233c0a172d8a27 --- src/gprs_bssgp_rim.c | 9 ++------- src/nacc_fsm.c | 8 ++++++++ src/nacc_fsm.h | 3 +++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/gprs_bssgp_rim.c b/src/gprs_bssgp_rim.c index c19ed813..f1679a6b 100644 --- a/src/gprs_bssgp_rim.c +++ b/src/gprs_bssgp_rim.c @@ -158,13 +158,8 @@ static int handle_ran_info_response_nacc(const struct bssgp_ran_inf_app_cont_nac llist_for_each(tmp, bts_ms_list(bts)) { struct GprsMs *ms = llist_entry(tmp, typeof(*ms), list); - if (!ms->nacc) - continue; - if (ms->nacc->fi->state != NACC_ST_WAIT_REQUEST_SI) - continue; - if (osmo_cgi_ps_cmp(&nacc->reprt_cell, &ms->nacc->cgi_ps) != 0) - continue; - osmo_fsm_inst_dispatch(ms->nacc->fi, NACC_EV_RX_SI, entry); + if (ms->nacc && nacc_fsm_is_waiting_si_resolution(ms->nacc, &nacc->reprt_cell)) + osmo_fsm_inst_dispatch(ms->nacc->fi, NACC_EV_RX_SI, entry); } return 0; } diff --git a/src/nacc_fsm.c b/src/nacc_fsm.c index ca226acb..df389271 100644 --- a/src/nacc_fsm.c +++ b/src/nacc_fsm.c @@ -887,3 +887,11 @@ bool nacc_fsm_is_waiting_addr_resolution(const struct nacc_fsm_ctx *ctx, return false; return neigh_cache_entry_key_eq(&ctx->neigh_key, neigh_key); } + +bool nacc_fsm_is_waiting_si_resolution(const struct nacc_fsm_ctx *ctx, + const struct osmo_cell_global_id_ps *cgi_ps) +{ + if (ctx->fi->state != NACC_ST_WAIT_REQUEST_SI) + return false; + return !osmo_cgi_ps_cmp(&ctx->cgi_ps, cgi_ps); +} diff --git a/src/nacc_fsm.h b/src/nacc_fsm.h index 04c9ba4e..68ebd52c 100644 --- a/src/nacc_fsm.h +++ b/src/nacc_fsm.h @@ -72,3 +72,6 @@ struct nacc_fsm_ctx *nacc_fsm_alloc(struct GprsMs* ms); bool nacc_fsm_is_waiting_addr_resolution(const struct nacc_fsm_ctx *ctx, const struct neigh_cache_entry_key *neigh_key); + +bool nacc_fsm_is_waiting_si_resolution(const struct nacc_fsm_ctx *ctx, + const struct osmo_cell_global_id_ps *cgi_ps);