aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-12-07 21:39:03 +0100
committerHarald Welte <laforge@osmocom.org>2020-12-09 22:56:01 +0100
commit17a892ff2b7e4129a5b228addf0b647396c1d3a2 (patch)
tree816c960a92ed6688897c8da1ecacf4e791dbc267 /include/osmocom
parentfde19ed579c3145959301bbe75fde15509276040 (diff)
gb: Add beginnings of a new BSSGP implementation
Similar to ns2 superseding ns, we now also intoduce a next generation of BSSGP related code to libosmogb. However, this is not aiming to be a full implementation yet, but simply those parts that we currently need from the revamped osmo-gbproxy. The gprs_bssgp2.[ch] differs in two ways from the old code: * it separates message encoding from message transmission * it supports more recent specs / IEs bssgp_bvc_fsm.c is a genric implementation of the BSSGP BVC RESET/BLOCK/UNBLOCK logic with support for both PTP and signaling, both on the SGSN side and the BSS side. Change-Id: Icbe8e4f03b68fd73b8eae95f6f6cccd4fa9af95a
Diffstat (limited to 'include/osmocom')
-rw-r--r--include/osmocom/gprs/bssgp_bvc_fsm.h61
-rw-r--r--include/osmocom/gprs/gprs_bssgp2.h31
2 files changed, 92 insertions, 0 deletions
diff --git a/include/osmocom/gprs/bssgp_bvc_fsm.h b/include/osmocom/gprs/bssgp_bvc_fsm.h
new file mode 100644
index 00000000..7c6fdeb0
--- /dev/null
+++ b/include/osmocom/gprs/bssgp_bvc_fsm.h
@@ -0,0 +1,61 @@
+#pragma once
+#include <stdint.h>
+
+struct gprs_ns2_inst;
+struct osmo_fsm_inst;
+struct gprs_ra_id;
+
+enum bssp_ptp_bvc_fsm_state {
+ BSSGP_BVCFSM_S_NULL,
+ BSSGP_BVCFSM_S_BLOCKED,
+ BSSGP_BVCFSM_S_WAIT_RESET_ACK,
+ BSSGP_BVCFSM_S_UNBLOCKED,
+};
+
+enum bssgp_ptp_bvc_fsm_event {
+ /* Rx of BSSGP PDUs from the remote side; 'data' is 'struct tlv_parsed', and
+ * the assumption is that the caller has already validated all mandatory IEs
+ * are present and of sufficient length */
+ BSSGP_BVCFSM_E_RX_BLOCK,
+ BSSGP_BVCFSM_E_RX_BLOCK_ACK,
+ BSSGP_BVCFSM_E_RX_UNBLOCK,
+ BSSGP_BVCFSM_E_RX_UNBLOCK_ACK,
+ BSSGP_BVCFSM_E_RX_RESET,
+ BSSGP_BVCFSM_E_RX_RESET_ACK,
+ /* Requests of the local user */
+ BSSGP_BVCFSM_E_REQ_BLOCK, /* data: uint8_t *cause */
+ BSSGP_BVCFSM_E_REQ_UNBLOCK,
+ BSSGP_BVCFSM_E_REQ_RESET, /* data: uint8_t *cause */
+};
+
+struct bssgp_bvc_fsm_ops {
+ /* call-back notifying the user of a state change */
+ void (*state_chg_notification)(uint16_t nsei, uint16_t bvci, int old_state, int new_state,
+ void *priv);
+ /* call-back notifying the user of a BVC-RESET event */
+ void (*reset_notification)(uint16_t nsei, uint16_t bvci, const struct gprs_ra_id *ra_id,
+ uint16_t cell_id, uint8_t cause, void *priv);
+};
+
+struct osmo_fsm_inst *
+bssgp_bvc_fsm_alloc_sig_bss(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint32_t features);
+
+struct osmo_fsm_inst *
+bssgp_bvc_fsm_alloc_ptp_bss(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint16_t bvci,
+ const struct gprs_ra_id *ra_id, uint16_t cell_id);
+
+struct osmo_fsm_inst *
+bssgp_bvc_fsm_alloc_sig_sgsn(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint32_t features);
+
+struct osmo_fsm_inst *
+bssgp_bvc_fsm_alloc_ptp_sgsn(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint16_t bvci);
+
+void bssgp_bvc_fsm_set_ops(struct osmo_fsm_inst *fi, const struct bssgp_bvc_fsm_ops *ops, void *ops_priv);
+
+bool bssgp_bvc_fsm_is_unblocked(struct osmo_fsm_inst *fi);
+
+uint8_t bssgp_bvc_fsm_get_block_cause(struct osmo_fsm_inst *fi);
+
+uint32_t bssgp_bvc_get_features_advertised(struct osmo_fsm_inst *fi);
+uint32_t bssgp_bvc_get_features_received(struct osmo_fsm_inst *fi);
+uint32_t bssgp_bvc_get_features_negotiated(struct osmo_fsm_inst *fi);
diff --git a/include/osmocom/gprs/gprs_bssgp2.h b/include/osmocom/gprs/gprs_bssgp2.h
new file mode 100644
index 00000000..0ab36191
--- /dev/null
+++ b/include/osmocom/gprs/gprs_bssgp2.h
@@ -0,0 +1,31 @@
+#pragma once
+#include <stdint.h>
+
+#include <osmocom/gprs/protocol/gsm_08_18.h>
+#include <osmocom/gprs/gprs_ns2.h>
+
+struct gprs_ns2_inst;
+struct gprs_ra_id;
+struct msgb;
+
+int bssgp2_nsi_tx_ptp(struct gprs_ns2_inst *nsi, uint16_t nsei, uint16_t bvci,
+ struct msgb *msg, uint32_t lsp);
+
+int bssgp2_nsi_tx_sig(struct gprs_ns2_inst *nsi, uint16_t nsei, struct msgb *msg, uint32_t lsp);
+
+struct msgb *bssgp2_enc_bvc_block(uint16_t bvci, enum gprs_bssgp_cause cause);
+
+struct msgb *bssgp2_enc_bvc_block_ack(uint16_t bvci);
+
+struct msgb *bssgp2_enc_bvc_unblock(uint16_t bvci);
+
+struct msgb *bssgp2_enc_bvc_unblock_ack(uint16_t bvci);
+
+struct msgb *bssgp2_enc_bvc_reset(uint16_t bvci, enum gprs_bssgp_cause cause,
+ const struct gprs_ra_id *ra_id, uint16_t cell_id,
+ const uint8_t *feat_bm, const uint8_t *ext_feat_bm);
+
+struct msgb *bssgp2_enc_bvc_reset_ack(uint16_t bvci, const struct gprs_ra_id *ra_id, uint16_t cell_id,
+ const uint8_t *feat_bm, const uint8_t *ext_feat_bm);
+
+struct msgb *bssgp2_enc_status(uint8_t cause, const uint16_t *bvci, const struct msgb *orig_msg);