blob: 7c6fdeb0e7bccc9f9eaf6f2f2740f951524407ce [file] [log] [blame]
Harald Welte17a892f2020-12-07 21:39:03 +01001#pragma once
2#include <stdint.h>
3
4struct gprs_ns2_inst;
5struct osmo_fsm_inst;
6struct gprs_ra_id;
7
8enum bssp_ptp_bvc_fsm_state {
9 BSSGP_BVCFSM_S_NULL,
10 BSSGP_BVCFSM_S_BLOCKED,
11 BSSGP_BVCFSM_S_WAIT_RESET_ACK,
12 BSSGP_BVCFSM_S_UNBLOCKED,
13};
14
15enum bssgp_ptp_bvc_fsm_event {
16 /* Rx of BSSGP PDUs from the remote side; 'data' is 'struct tlv_parsed', and
17 * the assumption is that the caller has already validated all mandatory IEs
18 * are present and of sufficient length */
19 BSSGP_BVCFSM_E_RX_BLOCK,
20 BSSGP_BVCFSM_E_RX_BLOCK_ACK,
21 BSSGP_BVCFSM_E_RX_UNBLOCK,
22 BSSGP_BVCFSM_E_RX_UNBLOCK_ACK,
23 BSSGP_BVCFSM_E_RX_RESET,
24 BSSGP_BVCFSM_E_RX_RESET_ACK,
25 /* Requests of the local user */
26 BSSGP_BVCFSM_E_REQ_BLOCK, /* data: uint8_t *cause */
27 BSSGP_BVCFSM_E_REQ_UNBLOCK,
28 BSSGP_BVCFSM_E_REQ_RESET, /* data: uint8_t *cause */
29};
30
31struct bssgp_bvc_fsm_ops {
32 /* call-back notifying the user of a state change */
33 void (*state_chg_notification)(uint16_t nsei, uint16_t bvci, int old_state, int new_state,
34 void *priv);
35 /* call-back notifying the user of a BVC-RESET event */
36 void (*reset_notification)(uint16_t nsei, uint16_t bvci, const struct gprs_ra_id *ra_id,
37 uint16_t cell_id, uint8_t cause, void *priv);
38};
39
40struct osmo_fsm_inst *
41bssgp_bvc_fsm_alloc_sig_bss(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint32_t features);
42
43struct osmo_fsm_inst *
44bssgp_bvc_fsm_alloc_ptp_bss(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint16_t bvci,
45 const struct gprs_ra_id *ra_id, uint16_t cell_id);
46
47struct osmo_fsm_inst *
48bssgp_bvc_fsm_alloc_sig_sgsn(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint32_t features);
49
50struct osmo_fsm_inst *
51bssgp_bvc_fsm_alloc_ptp_sgsn(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint16_t bvci);
52
53void bssgp_bvc_fsm_set_ops(struct osmo_fsm_inst *fi, const struct bssgp_bvc_fsm_ops *ops, void *ops_priv);
54
55bool bssgp_bvc_fsm_is_unblocked(struct osmo_fsm_inst *fi);
56
57uint8_t bssgp_bvc_fsm_get_block_cause(struct osmo_fsm_inst *fi);
58
59uint32_t bssgp_bvc_get_features_advertised(struct osmo_fsm_inst *fi);
60uint32_t bssgp_bvc_get_features_received(struct osmo_fsm_inst *fi);
61uint32_t bssgp_bvc_get_features_negotiated(struct osmo_fsm_inst *fi);