blob: cdb17c288cbb9fd21228459390fe296a66e97261 [file] [log] [blame]
Philipp Maierfbf66102017-04-09 12:32:51 +02001/* (C) 2017 by sysmocom s.f.m.c. GmbH
2 * All Rights Reserved
3 *
4 * Author: Philipp Maier
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (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 Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#pragma once
22
23
24
25/* Reset context data (callbacks, state machine etc...) */
26struct a_reset_ctx {
27
28 /* FSM instance, which handles the reset procedure */
29 struct osmo_fsm_inst *fsm;
30
31 /* Connection failure counter. When this counter
32 * reaches a certain threshold, the reset procedure
33 * will be triggered */
34 int conn_loss_counter;
35
36 /* A human readable name to display in the logs */
37 char name[256];
38
39 /* Callback function to be called when a connection
40 * failure is detected and a rest must occur */
41 void (*cb)(void *priv);
42
43 /* Privated data for the callback function */
44 void *priv;
45};
46
47/* Create and start state machine which handles the reset/reset-ack procedure */
Harald Welteb6777fb2018-02-08 23:59:19 +010048struct a_reset_ctx *a_reset_alloc(const void *ctx, const char *name, void *cb, void *priv,
49 bool already_connected);
Philipp Maierfbf66102017-04-09 12:32:51 +020050
51/* Tear down state machine */
52void a_reset_free(struct a_reset_ctx *reset);
53
54/* Confirm that we sucessfully received a reset acknowlege message */
55void a_reset_ack_confirm(struct a_reset_ctx *reset);
56
57/* Report a failed connection */
58void a_reset_conn_fail(struct a_reset_ctx *reset);
59
60/* Report a successful connection */
61void a_reset_conn_success(struct a_reset_ctx *reset);
62
63/* Check if we have a connection to a specified msc */
64bool a_reset_conn_ready(struct a_reset_ctx *reset);