libosmogb 1.9.0.192-1c24
Osmocom Gb library
gprs_ns2_vc_fsm.c File Reference

NS virtual circuit FSM implementation 3GPP TS 08.16 version 8.0.1 Release 1999 / ETSI TS 101 299 V8.0.1 (2002-05) as well as its successor 3GPP TS 48.016. More...

#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/stat_item.h>
#include <osmocom/gsm/prim.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gprs/gprs_msgb.h>
#include <osmocom/gprs/protocol/gsm_08_16.h>
#include "gprs_ns2_internal.h"

Data Structures

struct  gprs_ns2_vc_priv
 

Macros

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

Enumerations

enum  gprs_ns2_vc_state {
  GPRS_NS2_ST_UNCONFIGURED ,
  GPRS_NS2_ST_RESET ,
  GPRS_NS2_ST_BLOCKED ,
  GPRS_NS2_ST_UNBLOCKED ,
  GPRS_NS2_ST_RECOVERING
}
 
enum  gprs_ns2_vc_event {
  GPRS_NS2_EV_REQ_START ,
  GPRS_NS2_EV_RX_RESET ,
  GPRS_NS2_EV_RX_RESET_ACK ,
  GPRS_NS2_EV_RX_UNBLOCK ,
  GPRS_NS2_EV_RX_UNBLOCK_ACK ,
  GPRS_NS2_EV_RX_BLOCK ,
  GPRS_NS2_EV_RX_BLOCK_ACK ,
  GPRS_NS2_EV_RX_ALIVE ,
  GPRS_NS2_EV_RX_ALIVE_ACK ,
  GPRS_NS2_EV_RX_STATUS ,
  GPRS_NS2_EV_RX_UNITDATA ,
  GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED ,
  GPRS_NS2_EV_REQ_OM_RESET ,
  GPRS_NS2_EV_REQ_OM_BLOCK ,
  GPRS_NS2_EV_REQ_OM_UNBLOCK ,
  GPRS_NS2_EV_RX_BLOCK_FOREIGN
}
 

Functions

static struct gprs_ns2_instns_inst_from_fi (struct osmo_fsm_inst *fi)
 
static void start_test_procedure (struct osmo_fsm_inst *fi, bool start_tx_alive)
 
static void stop_test_procedure (struct gprs_ns2_vc_priv *priv)
 
static int alive_timer_elapsed_ms (struct gprs_ns2_vc_priv *priv)
 
static void recv_test_procedure (struct osmo_fsm_inst *fi)
 
static void alive_timeout_handler (void *data)
 
static void ns2_st_unconfigured_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void ns2_st_unconfigured (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_st_reset_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void ns2_st_reset (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_st_blocked_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void ns2_st_blocked (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_st_unblocked_on_enter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void ns2_st_unblocked (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_st_alive (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_st_alive_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static int ns2_vc_fsm_timer_cb (struct osmo_fsm_inst *fi)
 
static void ns2_recv_unitdata (struct osmo_fsm_inst *fi, struct msgb *msg)
 
static void ns2_vc_fsm_allstate_action (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_vc_fsm_clean (struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
 
struct osmo_fsm_instns2_vc_fsm_alloc (struct gprs_ns2_vc *nsvc, const char *id, bool initiator)
 gprs_ns2_vc_fsm_alloc More...
 
int ns2_vc_fsm_start (struct gprs_ns2_vc *nsvc)
 Start a NS-VC FSM. More...
 
int ns2_vc_force_unconfigured (struct gprs_ns2_vc *nsvc)
 Reset a NS-VC FSM. More...
 
int ns2_vc_block (struct gprs_ns2_vc *nsvc)
 Block a NS-VC. More...
 
int ns2_vc_unblock (struct gprs_ns2_vc *nsvc)
 Unblock a NS-VC. More...
 
int ns2_vc_reset (struct gprs_ns2_vc *nsvc)
 Reset a NS-VC. More...
 
int ns2_vc_rx (struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp)
 entry point for messages from the driver/VL More...
 
int ns2_vc_is_unblocked (struct gprs_ns2_vc *nsvc)
 is the given NS-VC unblocked? More...
 
static __attribute__ ((constructor))
 

Variables

static const struct value_string ns2_vc_event_names []
 
static const struct osmo_fsm_state ns2_vc_states []
 
static struct osmo_fsm ns2_vc_fsm
 

Detailed Description

NS virtual circuit FSM implementation 3GPP TS 08.16 version 8.0.1 Release 1999 / ETSI TS 101 299 V8.0.1 (2002-05) as well as its successor 3GPP TS 48.016.

Macro Definition Documentation

◆ S

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

Enumeration Type Documentation

◆ gprs_ns2_vc_event

Enumerator
GPRS_NS2_EV_REQ_START 
GPRS_NS2_EV_RX_RESET 
GPRS_NS2_EV_RX_RESET_ACK 
GPRS_NS2_EV_RX_UNBLOCK 
GPRS_NS2_EV_RX_UNBLOCK_ACK 
GPRS_NS2_EV_RX_BLOCK 
GPRS_NS2_EV_RX_BLOCK_ACK 
GPRS_NS2_EV_RX_ALIVE 
GPRS_NS2_EV_RX_ALIVE_ACK 
GPRS_NS2_EV_RX_STATUS 
GPRS_NS2_EV_RX_UNITDATA 
GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED 
GPRS_NS2_EV_REQ_OM_RESET 
GPRS_NS2_EV_REQ_OM_BLOCK 
GPRS_NS2_EV_REQ_OM_UNBLOCK 
GPRS_NS2_EV_RX_BLOCK_FOREIGN 

◆ gprs_ns2_vc_state

Enumerator
GPRS_NS2_ST_UNCONFIGURED 
GPRS_NS2_ST_RESET 
GPRS_NS2_ST_BLOCKED 
GPRS_NS2_ST_UNBLOCKED 
GPRS_NS2_ST_RECOVERING 

Function Documentation

◆ __attribute__()

static __attribute__ ( (constructor)  )
static

◆ alive_timeout_handler()

◆ alive_timer_elapsed_ms()

static int alive_timer_elapsed_ms ( struct gprs_ns2_vc_priv priv)
static

◆ ns2_recv_unitdata()

static void ns2_recv_unitdata ( struct osmo_fsm_inst fi,
struct msgb msg 
)
static

◆ ns2_st_alive()

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

◆ ns2_st_alive_onenter()

◆ ns2_st_blocked()

◆ ns2_st_blocked_onenter()

◆ ns2_st_reset()

◆ ns2_st_reset_onenter()

◆ ns2_st_unblocked()

◆ ns2_st_unblocked_on_enter()

◆ ns2_st_unconfigured()

◆ ns2_st_unconfigured_onenter()

static void ns2_st_unconfigured_onenter ( struct osmo_fsm_inst fi,
uint32_t  old_state 
)
static

◆ ns2_vc_block()

int ns2_vc_block ( struct gprs_ns2_vc nsvc)

Block a NS-VC.

Parameters
nsvcthe virtual circuit
Returns
0 on success; negative on error

References gprs_ns2_vc::fi, GPRS_NS2_EV_REQ_OM_BLOCK, gprs_ns2_vc_priv::nsvc, gprs_ns2_vc::om_blocked, osmo_fsm_inst_dispatch, and osmo_fsm_inst::priv.

Referenced by DEFUN().

◆ ns2_vc_force_unconfigured()

int ns2_vc_force_unconfigured ( struct gprs_ns2_vc nsvc)

Reset a NS-VC FSM.

Parameters
nsvcthe virtual circuit
Returns
0 on success; negative on error

References gprs_ns2_vc::fi, GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED, gprs_ns2_vc_priv::nsvc, and osmo_fsm_inst_dispatch.

Referenced by fr_dlci_status_cb(), ns2_sns_st_all_action_sgsn(), and nsvc_force_unconf_cb().

◆ ns2_vc_fsm_alloc()

struct osmo_fsm_inst * ns2_vc_fsm_alloc ( struct gprs_ns2_vc nsvc,
const char *  id,
bool  initiator 
)

gprs_ns2_vc_fsm_alloc

Parameters
ctx
vc
ida char representation of the virtual curcuit
initiatorinitiator is the site which starts the connection. Usually the BSS.
Returns
NULL on error, otherwise the fsm

References gprs_ns2_vc_priv::alive, alive_timeout_handler(), gprs_ns2_vc::fi, gprs_ns2_vc_priv::initiator, LOGL_DEBUG, ns2_vc_fsm, gprs_ns2_vc_priv::nsvc, osmo_fsm_inst_alloc(), osmo_timer_setup(), osmo_fsm_inst::priv, and gprs_ns2_vc_priv::timer.

Referenced by ns2_vc_alloc().

◆ ns2_vc_fsm_allstate_action()

◆ ns2_vc_fsm_clean()

static void ns2_vc_fsm_clean ( struct osmo_fsm_inst fi,
enum osmo_fsm_term_cause  cause 
)
static

◆ ns2_vc_fsm_start()

int ns2_vc_fsm_start ( struct gprs_ns2_vc nsvc)

◆ ns2_vc_fsm_timer_cb()

◆ ns2_vc_is_unblocked()

◆ ns2_vc_reset()

int ns2_vc_reset ( struct gprs_ns2_vc nsvc)

Reset a NS-VC.

Parameters
nsvcthe virtual circuit
Returns
0 on success; negative on error

References gprs_ns2_vc::fi, GPRS_NS2_EV_REQ_OM_RESET, gprs_ns2_vc_priv::nsvc, and osmo_fsm_inst_dispatch.

Referenced by DEFUN().

◆ ns2_vc_rx()

◆ ns2_vc_unblock()

int ns2_vc_unblock ( struct gprs_ns2_vc nsvc)

Unblock a NS-VC.

Parameters
nsvcthe virtual circuit
Returns
0 on success; negative on error

References gprs_ns2_vc::fi, GPRS_NS2_EV_REQ_OM_UNBLOCK, gprs_ns2_vc_priv::nsvc, gprs_ns2_vc::om_blocked, osmo_fsm_inst_dispatch, and osmo_fsm_inst::priv.

Referenced by DEFUN().

◆ ns_inst_from_fi()

◆ recv_test_procedure()

◆ start_test_procedure()

◆ stop_test_procedure()

Variable Documentation

◆ ns2_vc_event_names

const struct value_string ns2_vc_event_names[]
static
Initial value:
= {
{ GPRS_NS2_EV_REQ_START, "REQ-START" },
{ GPRS_NS2_EV_RX_RESET, "RX-RESET" },
{ GPRS_NS2_EV_RX_RESET_ACK, "RX-RESET_ACK" },
{ GPRS_NS2_EV_RX_UNBLOCK, "RX-UNBLOCK" },
{ GPRS_NS2_EV_RX_UNBLOCK_ACK, "RX-UNBLOCK_ACK" },
{ GPRS_NS2_EV_RX_BLOCK, "RX-BLOCK" },
{ GPRS_NS2_EV_RX_BLOCK_FOREIGN, "RX-BLOCK_FOREIGN" },
{ GPRS_NS2_EV_RX_BLOCK_ACK, "RX-BLOCK_ACK" },
{ GPRS_NS2_EV_RX_ALIVE, "RX-ALIVE" },
{ GPRS_NS2_EV_RX_ALIVE_ACK, "RX-ALIVE_ACK" },
{ GPRS_NS2_EV_RX_STATUS, "RX-STATUS" },
{ GPRS_NS2_EV_RX_UNITDATA, "RX-UNITDATA" },
{ GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED, "REQ-FORCE_UNCONFIGURED" },
{ GPRS_NS2_EV_REQ_OM_RESET, "REQ-O&M-RESET"},
{ GPRS_NS2_EV_REQ_OM_BLOCK, "REQ-O&M-BLOCK"},
{ GPRS_NS2_EV_REQ_OM_UNBLOCK, "REQ-O&M-UNBLOCK"},
{ 0, NULL }
}
@ GPRS_NS2_EV_RX_BLOCK_ACK
Definition: gprs_ns2_vc_fsm.c:108
@ GPRS_NS2_EV_RX_RESET_ACK
Definition: gprs_ns2_vc_fsm.c:104
@ GPRS_NS2_EV_RX_ALIVE_ACK
Definition: gprs_ns2_vc_fsm.c:110
@ GPRS_NS2_EV_REQ_START
Definition: gprs_ns2_vc_fsm.c:100
@ GPRS_NS2_EV_RX_BLOCK
Definition: gprs_ns2_vc_fsm.c:107
@ GPRS_NS2_EV_RX_UNBLOCK
Definition: gprs_ns2_vc_fsm.c:105
@ GPRS_NS2_EV_RX_ALIVE
Definition: gprs_ns2_vc_fsm.c:109
@ GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED
Definition: gprs_ns2_vc_fsm.c:115
@ GPRS_NS2_EV_REQ_OM_RESET
Definition: gprs_ns2_vc_fsm.c:116
@ GPRS_NS2_EV_RX_UNITDATA
Definition: gprs_ns2_vc_fsm.c:113
@ GPRS_NS2_EV_RX_BLOCK_FOREIGN
Definition: gprs_ns2_vc_fsm.c:119
@ GPRS_NS2_EV_RX_STATUS
Definition: gprs_ns2_vc_fsm.c:111
@ GPRS_NS2_EV_REQ_OM_BLOCK
Definition: gprs_ns2_vc_fsm.c:117
@ GPRS_NS2_EV_RX_RESET
Definition: gprs_ns2_vc_fsm.c:103
@ GPRS_NS2_EV_RX_UNBLOCK_ACK
Definition: gprs_ns2_vc_fsm.c:106
@ GPRS_NS2_EV_REQ_OM_UNBLOCK
Definition: gprs_ns2_vc_fsm.c:118

◆ ns2_vc_fsm

struct osmo_fsm ns2_vc_fsm
static
Initial value:
= {
.name = "GPRS-NS2-VC",
.states = ns2_vc_states,
.num_states = ARRAY_SIZE(ns2_vc_states),
.allstate_event_mask = S(GPRS_NS2_EV_RX_UNITDATA) |
.allstate_action = ns2_vc_fsm_allstate_action,
.cleanup = ns2_vc_fsm_clean,
.timer_cb = ns2_vc_fsm_timer_cb,
.event_names = ns2_vc_event_names,
.pre_term = NULL,
.log_subsys = DLNS,
}
static void ns2_vc_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
Definition: gprs_ns2_vc_fsm.c:630
static void ns2_vc_fsm_clean(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
Definition: gprs_ns2_vc_fsm.c:753
static const struct value_string ns2_vc_event_names[]
Definition: gprs_ns2_vc_fsm.c:122
static const struct osmo_fsm_state ns2_vc_states[]
Definition: gprs_ns2_vc_fsm.c:489
static int ns2_vc_fsm_timer_cb(struct osmo_fsm_inst *fi)
Definition: gprs_ns2_vc_fsm.c:543
#define S(x)
Definition: gprs_ns2_vc_fsm.c:50
#define DLNS
#define ARRAY_SIZE(x)

Referenced by __attribute__(), and ns2_vc_fsm_alloc().

◆ ns2_vc_states

const struct osmo_fsm_state ns2_vc_states[]
static