diff options
author | Pau Espin Pedrol <pespin@espeweb.net> | 2021-02-10 17:12:02 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@espeweb.net> | 2021-02-11 12:26:24 +0100 |
commit | 0c10b3cdc1c7c4eda5f62b4185782dad1ac077e3 (patch) | |
tree | d3b6e4072cccdba08838d59f4488bd6895515f4d /src | |
parent | abba102d7b26333f92a3a334c80d5fceb2a6b21b (diff) |
nacc_fsm: Move code filling struct to helper function
Same filler will be needed in different places since that message can
arrive at different points of time (different states).
It also helps supporting newer key types in the future.
Change-Id: Idfd4db8408f767b1847b04c88047a1c4996e543e
Diffstat (limited to 'src')
-rw-r--r-- | src/nacc_fsm.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/nacc_fsm.c b/src/nacc_fsm.c index 6a92f83c..f9dea98e 100644 --- a/src/nacc_fsm.c +++ b/src/nacc_fsm.c @@ -268,6 +268,22 @@ static int fill_rim_ran_info_req(const struct nacc_fsm_ctx *ctx, struct bssgp_ra return 0; } +static int fill_neigh_key_from_bts_pkt_cell_chg_not(struct neigh_cache_entry_key *neigh_key, + const struct gprs_rlcmac_bts *bts, + const Packet_Cell_Change_Notification_t *notif) +{ + switch (notif->Target_Cell.UnionType) { + case 0: /* GSM */ + neigh_key->local_lac = bts->cgi_ps.rai.lac.lac; + neigh_key->local_ci = bts->cgi_ps.cell_identity; + neigh_key->tgt_arfcn = notif->Target_Cell.u.Target_Cell_GSM_Notif.ARFCN; + neigh_key->tgt_bsic = notif->Target_Cell.u.Target_Cell_GSM_Notif.BSIC; + return 0; + default: + return -ENOTSUP; + } +} + #define SI_HDR_LEN 2 static void bts_fill_si_cache_value(const struct gprs_rlcmac_bts *bts, struct si_cache_value *val) { @@ -303,19 +319,12 @@ static void st_initial(struct osmo_fsm_inst *fi, uint32_t event, void *data) switch (event) { case NACC_EV_RX_CELL_CHG_NOTIFICATION: notif = (Packet_Cell_Change_Notification_t *)data; - switch (notif->Target_Cell.UnionType) { - case 0: /* GSM */ - ctx->neigh_key.local_lac = bts->cgi_ps.rai.lac.lac; - ctx->neigh_key.local_ci = bts->cgi_ps.cell_identity; - ctx->neigh_key.tgt_arfcn = notif->Target_Cell.u.Target_Cell_GSM_Notif.ARFCN; - ctx->neigh_key.tgt_bsic = notif->Target_Cell.u.Target_Cell_GSM_Notif.BSIC; - nacc_fsm_state_chg(fi, NACC_ST_WAIT_RESOLVE_RAC_CI); - break; - default: + if (fill_neigh_key_from_bts_pkt_cell_chg_not(&ctx->neigh_key, bts, notif) < 0) { LOGPFSML(fi, LOGL_NOTICE, "TargetCell type=0x%x not supported\n", notif->Target_Cell.UnionType); osmo_fsm_inst_term(fi, OSMO_FSM_TERM_ERROR, NULL); - return; + } else { + nacc_fsm_state_chg(fi, NACC_ST_WAIT_RESOLVE_RAC_CI); } break; default: |