blob: 9107dafd1a021a8e86a8e8189d4764ce4d6e2db2 [file] [log] [blame]
Pau Espin Pedrolc0a250d2021-01-21 18:46:13 +01001/* nacc_fsm.h
2 *
3 * Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
4 * Author: Pau Espin Pedrol <pespin@sysmocom.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20#pragma once
21
22#include <osmocom/core/fsm.h>
23#include <osmocom/gsm/gsm23003.h>
24
25#include <neigh_cache.h>
26
27struct GprsMs;
28struct gprs_rlcmac_tbf;
29
30enum nacc_fsm_event {
31 NACC_EV_RX_CELL_CHG_NOTIFICATION, /* data: Packet_Cell_Change_Notification_t* */
32 NACC_EV_RX_RAC_CI, /* no data passed, RAC_CI became available in neigh_cache */
33 NACC_EV_RX_SI, /* data: struct si_cache_entry* */
34 NACC_EV_CREATE_RLCMAC_MSG, /* data: struct nacc_ev_create_rlcmac_msg_ctx* */
35};
36
37enum nacc_fsm_states {
38 NACC_ST_INITIAL,
39 NACC_ST_WAIT_RESOLVE_RAC_CI,
40 NACC_ST_WAIT_REQUEST_SI,
41 NACC_ST_TX_NEIGHBOUR_DATA,
42 NACC_ST_TX_CELL_CHG_CONTINUE,
43 NACC_ST_DONE,
44};
45
46struct nacc_fsm_ctx {
47 struct osmo_fsm_inst *fi;
48 struct GprsMs* ms; /* back pointer */
49 struct ctrl_handle *neigh_ctrl;
50 struct ctrl_connection *neigh_ctrl_conn;
51 struct neigh_cache_entry_key neigh_key; /* target cell info from MS */
52 struct osmo_cell_global_id_ps cgi_ps; /* target cell info resolved from req_{arfcn+bsic} */
53 struct si_cache_value si_info; /* SI info resolved from SGSN, to be sent to MS */
54 size_t si_info_bytes_sent; /* How many bytes out of si_info->si_len were already sent to MS */
55 size_t container_idx; /* Next container_idx to assign when sending Packet Neighbor Data message */
56};
57
58/* passed as data in NACC_EV_CREATE_RLCMAC_MSG */
59struct nacc_ev_create_rlcmac_msg_ctx {
60 struct gprs_rlcmac_tbf *tbf; /* target tbf to create messages for */
61 struct msgb *msg; /* to be filled by FSM during event processing */
62};
63
64struct nacc_fsm_ctx *nacc_fsm_alloc(struct GprsMs* ms);