libosmogb 1.9.0.192-1c24
Osmocom Gb library
bssgp_bvc_fsm.c File Reference
#include <string.h>
#include <stdio.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/tdef.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gprs/gprs_msgb.h>
#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/gprs/gprs_bssgp2.h>
#include <osmocom/gprs/bssgp_bvc_fsm.h>
#include "common_vty.h"

Data Structures

struct  bvc_fsm_priv
 

Macros

#define S(x)   (1 << (x))
 
#define T1   1
 
#define T2   2
 
#define T1_SECS   osmo_tdef_get(bssgp_bvc_fsm_tdefs, 1, OSMO_TDEF_S, 5)
 
#define T2_SECS   osmo_tdef_get(bssgp_bvc_fsm_tdefs, 2, OSMO_TDEF_S, 10)
 

Functions

static int fi_tx_ptp (struct osmo_fsm_inst *fi, struct msgb *msg)
 
static int fi_tx_sig (struct osmo_fsm_inst *fi, struct msgb *msg)
 
static void _tx_bvc_reset (struct osmo_fsm_inst *fi, uint8_t cause)
 
static void _tx_bvc_reset_ack (struct osmo_fsm_inst *fi)
 
static void _tx_status (struct osmo_fsm_inst *fi, enum gprs_bssgp_cause cause, const struct msgb *rx)
 
static void update_negotiated_features (struct osmo_fsm_inst *fi, const struct tlv_parsed *tp)
 
static void _onenter_tail (struct osmo_fsm_inst *fi, uint32_t prev_state)
 
static void bssgp_bvc_fsm_null (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void bssgp_bvc_fsm_blocked_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state)
 
static void bssgp_bvc_fsm_blocked (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void bssgp_bvc_fsm_wait_reset_ack (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void bssgp_bvc_fsm_unblocked (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void bssgp_bvc_fsm_allstate (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static int bssgp_bvc_fsm_timer_cb (struct osmo_fsm_inst *fi)
 
static struct osmo_fsm_inst_bvc_fsm_alloc (void *ctx, struct gprs_ns2_inst *nsi, bool role_sgsn, uint16_t nsei, uint16_t bvci)
 
struct osmo_fsm_instbssgp_bvc_fsm_alloc_sig_bss (void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint32_t features)
 Allocate a SIGNALING-BVC FSM for the BSS role (facing a remote SGSN). More...
 
struct osmo_fsm_instbssgp_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)
 Allocate a PTP-BVC FSM for the BSS role (facing a remote SGSN). More...
 
struct osmo_fsm_instbssgp_bvc_fsm_alloc_sig_sgsn (void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint32_t features)
 Allocate a SIGNALING-BVC FSM for the SGSN role (facing a remote BSS). More...
 
struct osmo_fsm_instbssgp_bvc_fsm_alloc_ptp_sgsn (void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint16_t bvci)
 Allocate a PTP-BVC FSM for the SGSN role (facing a remote BSS). More...
 
void bssgp_bvc_fsm_set_ops (struct osmo_fsm_inst *fi, const struct bssgp_bvc_fsm_ops *ops, void *ops_priv)
 Set the 'operations' callbacks + private data. More...
 
bool bssgp_bvc_fsm_is_unblocked (struct osmo_fsm_inst *fi)
 Return if the given BVC FSM is in UNBLOCKED state. More...
 
uint8_t bssgp_bvc_fsm_get_block_cause (struct osmo_fsm_inst *fi)
 Determine the cause value why given BVC FSM is blocked. More...
 
uint32_t bssgp_bvc_fsm_get_features_advertised (struct osmo_fsm_inst *fi)
 Return the advertised features / extended features. More...
 
uint32_t bssgp_bvc_fsm_get_features_received (struct osmo_fsm_inst *fi)
 Return the received features / extended features. More...
 
uint32_t bssgp_bvc_fsm_get_features_negotiated (struct osmo_fsm_inst *fi)
 Return the negotiated features / extended features. More...
 
void bssgp_bvc_fsm_set_max_pdu_len (struct osmo_fsm_inst *fi, uint16_t max_pdu_len)
 Set the maximum size of a BSSGP PDU. More...
 
uint16_t bssgp_bvc_fsm_get_max_pdu_len (const struct osmo_fsm_inst *fi)
 Return the maximum size of a BSSGP PDU ! On the NS layer this corresponds to the size of an NS SDU in NS-UNITDATA (3GPP TS 48.016 Ch. More...
 
static __attribute__ ((constructor))
 

Variables

struct osmo_tdef bssgp_bvc_fsm_tdefs []
 
static struct osmo_fsm bssgp_bvc_fsm
 
static const struct value_string ptp_bvc_event_names []
 
static const struct osmo_fsm_state bssgp_bvc_fsm_states []
 

Macro Definition Documentation

◆ S

#define S (   x)    (1 << (x))

◆ T1

#define T1   1

◆ T1_SECS

#define T1_SECS   osmo_tdef_get(bssgp_bvc_fsm_tdefs, 1, OSMO_TDEF_S, 5)

◆ T2

#define T2   2

◆ T2_SECS

#define T2_SECS   osmo_tdef_get(bssgp_bvc_fsm_tdefs, 2, OSMO_TDEF_S, 10)

Function Documentation

◆ __attribute__()

static __attribute__ ( (constructor)  )
static

◆ _bvc_fsm_alloc()

◆ _onenter_tail()

◆ _tx_bvc_reset()

◆ _tx_bvc_reset_ack()

◆ _tx_status()

◆ bssgp_bvc_fsm_alloc_ptp_bss()

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 
)

Allocate a PTP-BVC FSM for the BSS role (facing a remote SGSN).

Parameters
[in]ctxtalloc context from which to allocate
[in]nsiNS Instance on which this BVC operates
[in]nseiNS Entity Identifier on which this BVC operates
[in]bvciBVCI of this FSM
[in]ra_idRouting Area Identity of the cell (reported to SGSN)
[in]cell_idCell Identifier of the cell (reported to SGSN)
Returns
newly-allocated FSM Instance; NULL in case of error

References _bvc_fsm_alloc(), bvci, bvc_fsm_priv::cell_id, nsei, bvc_fsm_priv::nsi, OSMO_ASSERT, osmo_fsm_inst::priv, and bvc_fsm_priv::ra_id.

◆ bssgp_bvc_fsm_alloc_ptp_sgsn()

struct osmo_fsm_inst * bssgp_bvc_fsm_alloc_ptp_sgsn ( void *  ctx,
struct gprs_ns2_inst nsi,
uint16_t  nsei,
uint16_t  bvci 
)

Allocate a PTP-BVC FSM for the SGSN role (facing a remote BSS).

Parameters
[in]ctxtalloc context from which to allocate
[in]nsiNS Instance on which this BVC operates
[in]nseiNS Entity Identifier on which this BVC operates
[in]bvciBVCI of this FSM
Returns
newly-allocated FSM Instance; NULL in case of error

References _bvc_fsm_alloc(), bvci, nsei, and OSMO_ASSERT.

◆ bssgp_bvc_fsm_alloc_sig_bss()

struct osmo_fsm_inst * bssgp_bvc_fsm_alloc_sig_bss ( void *  ctx,
struct gprs_ns2_inst nsi,
uint16_t  nsei,
uint32_t  features 
)

Allocate a SIGNALING-BVC FSM for the BSS role (facing a remote SGSN).

Parameters
[in]ctxtalloc context from which to allocate
[in]nsiNS Instance on which this BVC operates
[in]nseiNS Entity Identifier on which this BVC operates
[in]featuresFeature [byte 0] and Extended Feature [byte 1] bitmap
Returns
newly-allocated FSM Instance; NULL in case of error

References _bvc_fsm_alloc(), bvc_fsm_priv::advertised, bvc_fsm_priv::features, nsei, and osmo_fsm_inst::priv.

◆ bssgp_bvc_fsm_alloc_sig_sgsn()

struct osmo_fsm_inst * bssgp_bvc_fsm_alloc_sig_sgsn ( void *  ctx,
struct gprs_ns2_inst nsi,
uint16_t  nsei,
uint32_t  features 
)

Allocate a SIGNALING-BVC FSM for the SGSN role (facing a remote BSS).

Parameters
[in]ctxtalloc context from which to allocate
[in]nsiNS Instance on which this BVC operates
[in]nseiNS Entity Identifier on which this BVC operates
[in]featuresFeature [byte 0] and Extended Feature [byte 1] bitmap
Returns
newly-allocated FSM Instance; NULL in case of error

References _bvc_fsm_alloc(), bvc_fsm_priv::advertised, bvc_fsm_priv::features, nsei, and osmo_fsm_inst::priv.

◆ bssgp_bvc_fsm_allstate()

◆ bssgp_bvc_fsm_blocked()

◆ bssgp_bvc_fsm_blocked_onenter()

static void bssgp_bvc_fsm_blocked_onenter ( struct osmo_fsm_inst fi,
uint32_t  prev_state 
)
static

◆ bssgp_bvc_fsm_get_block_cause()

uint8_t bssgp_bvc_fsm_get_block_cause ( struct osmo_fsm_inst fi)

Determine the cause value why given BVC FSM is blocked.

References bvc_fsm_priv::block_cause, bssgp_bvc_fsm, osmo_fsm_inst::fsm, OSMO_ASSERT, and osmo_fsm_inst::priv.

◆ bssgp_bvc_fsm_get_features_advertised()

uint32_t bssgp_bvc_fsm_get_features_advertised ( struct osmo_fsm_inst fi)

Return the advertised features / extended features.

References bvc_fsm_priv::advertised, bssgp_bvc_fsm, bvc_fsm_priv::features, osmo_fsm_inst::fsm, OSMO_ASSERT, and osmo_fsm_inst::priv.

◆ bssgp_bvc_fsm_get_features_negotiated()

uint32_t bssgp_bvc_fsm_get_features_negotiated ( struct osmo_fsm_inst fi)

Return the negotiated features / extended features.

References bssgp_bvc_fsm, bvc_fsm_priv::features, osmo_fsm_inst::fsm, bvc_fsm_priv::negotiated, OSMO_ASSERT, and osmo_fsm_inst::priv.

◆ bssgp_bvc_fsm_get_features_received()

uint32_t bssgp_bvc_fsm_get_features_received ( struct osmo_fsm_inst fi)

Return the received features / extended features.

References bssgp_bvc_fsm, bvc_fsm_priv::features, osmo_fsm_inst::fsm, OSMO_ASSERT, osmo_fsm_inst::priv, and bvc_fsm_priv::received.

◆ bssgp_bvc_fsm_get_max_pdu_len()

uint16_t bssgp_bvc_fsm_get_max_pdu_len ( const struct osmo_fsm_inst fi)

Return the maximum size of a BSSGP PDU ! On the NS layer this corresponds to the size of an NS SDU in NS-UNITDATA (3GPP TS 48.016 Ch.

9.2.10)

References bssgp_bvc_fsm, osmo_fsm_inst::fsm, bvc_fsm_priv::max_pdu_len, OSMO_ASSERT, and osmo_fsm_inst::priv.

◆ bssgp_bvc_fsm_is_unblocked()

bool bssgp_bvc_fsm_is_unblocked ( struct osmo_fsm_inst fi)

Return if the given BVC FSM is in UNBLOCKED state.

References BSSGP_BVCFSM_S_UNBLOCKED, and osmo_fsm_inst::state.

◆ bssgp_bvc_fsm_null()

static void bssgp_bvc_fsm_null ( struct osmo_fsm_inst fi,
uint32_t  event,
void *  data 
)
static

References OSMO_ASSERT.

◆ bssgp_bvc_fsm_set_max_pdu_len()

void bssgp_bvc_fsm_set_max_pdu_len ( struct osmo_fsm_inst fi,
uint16_t  max_pdu_len 
)

Set the maximum size of a BSSGP PDU.

! On the NS layer this corresponds to the size of an NS SDU in NS-UNITDATA (3GPP TS 48.016 Ch. 9.2.10)

References bssgp_bvc_fsm, osmo_fsm_inst::fsm, bvc_fsm_priv::max_pdu_len, OSMO_ASSERT, and osmo_fsm_inst::priv.

◆ bssgp_bvc_fsm_set_ops()

void bssgp_bvc_fsm_set_ops ( struct osmo_fsm_inst fi,
const struct bssgp_bvc_fsm_ops ops,
void *  ops_priv 
)

Set the 'operations' callbacks + private data.

Parameters
[in]fiFSM instance for which the data shall be set
[in]opsBSSGP BVC FSM operations (call-back functions) to register
[in]ops_privopaque/private data pointer passed through to call-backs

References bssgp_bvc_fsm, osmo_fsm_inst::fsm, bvc_fsm_priv::ops, bvc_fsm_priv::ops_priv, OSMO_ASSERT, and osmo_fsm_inst::priv.

◆ bssgp_bvc_fsm_timer_cb()

◆ bssgp_bvc_fsm_unblocked()

◆ bssgp_bvc_fsm_wait_reset_ack()

◆ fi_tx_ptp()

◆ fi_tx_sig()

◆ update_negotiated_features()

Variable Documentation

◆ bssgp_bvc_fsm

static struct osmo_fsm bssgp_bvc_fsm
static
Initial value:
= {
.name = "BSSGP-BVC",
.allstate_event_mask = S(BSSGP_BVCFSM_E_REQ_RESET) |
.allstate_action = bssgp_bvc_fsm_allstate,
.log_subsys = DLBSSGP,
.event_names = ptp_bvc_event_names,
}
static const struct osmo_fsm_state bssgp_bvc_fsm_states[]
Definition: bssgp_bvc_fsm.c:596
static void bssgp_bvc_fsm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data)
Definition: bssgp_bvc_fsm.c:514
#define S(x)
Definition: bssgp_bvc_fsm.c:42
static const struct value_string ptp_bvc_event_names[]
Definition: bssgp_bvc_fsm.c:97
static int bssgp_bvc_fsm_timer_cb(struct osmo_fsm_inst *fi)
Definition: bssgp_bvc_fsm.c:551
@ BSSGP_BVCFSM_E_REQ_RESET
Definition: bssgp_bvc_fsm.h:31
@ BSSGP_BVCFSM_E_RX_RESET
Definition: bssgp_bvc_fsm.h:24
#define DLBSSGP
#define ARRAY_SIZE(x)

Referenced by __attribute__(), _bvc_fsm_alloc(), _tx_bvc_reset(), _tx_bvc_reset_ack(), bssgp_bvc_fsm_get_block_cause(), bssgp_bvc_fsm_get_features_advertised(), bssgp_bvc_fsm_get_features_negotiated(), bssgp_bvc_fsm_get_features_received(), bssgp_bvc_fsm_get_max_pdu_len(), bssgp_bvc_fsm_set_max_pdu_len(), bssgp_bvc_fsm_set_ops(), fi_tx_ptp(), fi_tx_sig(), and update_negotiated_features().

◆ bssgp_bvc_fsm_states

const struct osmo_fsm_state bssgp_bvc_fsm_states[]
static

◆ bssgp_bvc_fsm_tdefs

struct osmo_tdef bssgp_bvc_fsm_tdefs[]

◆ ptp_bvc_event_names

const struct value_string ptp_bvc_event_names[]
static
Initial value:
= {
{ BSSGP_BVCFSM_E_RX_BLOCK, "RX-BVC-BLOCK" },
{ BSSGP_BVCFSM_E_RX_BLOCK_ACK, "RX-BVC-BLOCK-ACK" },
{ BSSGP_BVCFSM_E_RX_UNBLOCK, "RX-BVC-UNBLOCK" },
{ BSSGP_BVCFSM_E_RX_UNBLOCK_ACK, "RX-BVC-UNBLOCK-ACK" },
{ BSSGP_BVCFSM_E_RX_RESET, "RX-BVC-RESET" },
{ BSSGP_BVCFSM_E_RX_RESET_ACK, "RX-BVC-RESET-ACK" },
{ BSSGP_BVCFSM_E_RX_FC_BVC, "RX-FLOW-CONTROL-BVC" },
{ BSSGP_BVCFSM_E_RX_FC_BVC_ACK, "RX-FLOW-CONTROL-BVC-ACK" },
{ BSSGP_BVCFSM_E_REQ_BLOCK, "REQ-BLOCK" },
{ BSSGP_BVCFSM_E_REQ_UNBLOCK, "REQ-UNBLOCK" },
{ BSSGP_BVCFSM_E_REQ_RESET, "REQ-RESET" },
{ BSSGP_BVCFSM_E_REQ_FC_BVC, "REQ-FLOW-CONTROL-BVC" },
{ 0, NULL }
}
@ BSSGP_BVCFSM_E_RX_FC_BVC_ACK
Definition: bssgp_bvc_fsm.h:27
@ BSSGP_BVCFSM_E_RX_BLOCK_ACK
Definition: bssgp_bvc_fsm.h:21
@ BSSGP_BVCFSM_E_REQ_FC_BVC
Definition: bssgp_bvc_fsm.h:32
@ BSSGP_BVCFSM_E_RX_UNBLOCK_ACK
Definition: bssgp_bvc_fsm.h:23
@ BSSGP_BVCFSM_E_RX_FC_BVC
Definition: bssgp_bvc_fsm.h:26
@ BSSGP_BVCFSM_E_REQ_BLOCK
Definition: bssgp_bvc_fsm.h:29
@ BSSGP_BVCFSM_E_REQ_UNBLOCK
Definition: bssgp_bvc_fsm.h:30
@ BSSGP_BVCFSM_E_RX_BLOCK
Definition: bssgp_bvc_fsm.h:20
@ BSSGP_BVCFSM_E_RX_UNBLOCK
Definition: bssgp_bvc_fsm.h:22
@ BSSGP_BVCFSM_E_RX_RESET_ACK
Definition: bssgp_bvc_fsm.h:25