libosmogb  1.4.0.160-7619
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))
 
#define DNS   10
 

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_ALIVE
}
 
enum  gprs_ns2_vc_event {
  GPRS_NS2_EV_START ,
  GPRS_NS2_EV_RESET ,
  GPRS_NS2_EV_RESET_ACK ,
  GPRS_NS2_EV_UNBLOCK ,
  GPRS_NS2_EV_UNBLOCK_ACK ,
  GPRS_NS2_EV_BLOCK ,
  GPRS_NS2_EV_BLOCK_ACK ,
  GPRS_NS2_EV_ALIVE ,
  GPRS_NS2_EV_ALIVE_ACK ,
  GPRS_NS2_EV_STATUS ,
  GPRS_NS2_EV_UNITDATA
}
 

Functions

static struct gprs_ns2_instns_inst_from_fi (struct osmo_fsm_inst *fi)
 
static void start_test_procedure (struct gprs_ns2_vc_priv *priv)
 
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 gprs_ns2_st_unconfigured (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void gprs_ns2_st_reset_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void gprs_ns2_st_reset (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void gprs_ns2_st_blocked_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void gprs_ns2_st_blocked (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void gprs_ns2_st_unblocked_on_enter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void gprs_ns2_st_unblocked (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void gprs_ns2_st_alive (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void gprs_ns2_st_alive_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void gprs_ns2_st_alive_onleave (struct osmo_fsm_inst *fi, uint32_t next_state)
 
static int gprs_ns2_vc_fsm_timer_cb (struct osmo_fsm_inst *fi)
 
static void gprs_ns2_recv_unitdata (struct osmo_fsm_inst *fi, struct msgb *msg)
 
static void gprs_ns2_vc_fsm_allstate_action (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
struct osmo_fsm_instgprs_ns2_vc_fsm_alloc (struct gprs_ns2_vc *nsvc, const char *id, bool initiater)
 gprs_ns2_vc_fsm_alloc More...
 
int gprs_ns2_vc_fsm_start (struct gprs_ns2_vc *nsvc)
 Start a NS-VC FSM. More...
 
int gprs_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 gprs_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 gprs_ns2_vc_event_names []
 
static const struct osmo_fsm_state gprs_ns2_vc_states []
 
static struct osmo_fsm gprs_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

◆ DNS

#define DNS   10

◆ S

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

Enumeration Type Documentation

◆ gprs_ns2_vc_event

Enumerator
GPRS_NS2_EV_START 
GPRS_NS2_EV_RESET 
GPRS_NS2_EV_RESET_ACK 
GPRS_NS2_EV_UNBLOCK 
GPRS_NS2_EV_UNBLOCK_ACK 
GPRS_NS2_EV_BLOCK 
GPRS_NS2_EV_BLOCK_ACK 
GPRS_NS2_EV_ALIVE 
GPRS_NS2_EV_ALIVE_ACK 
GPRS_NS2_EV_STATUS 
GPRS_NS2_EV_UNITDATA 

◆ gprs_ns2_vc_state

Enumerator
GPRS_NS2_ST_UNCONFIGURED 
GPRS_NS2_ST_RESET 
GPRS_NS2_ST_BLOCKED 
GPRS_NS2_ST_UNBLOCKED 
GPRS_NS2_ST_ALIVE 

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

References osmo_gettimeofday(), priv, and timersub.

Referenced by recv_test_procedure().

◆ gprs_ns2_recv_unitdata()

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

◆ gprs_ns2_st_alive()

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

◆ gprs_ns2_st_alive_onenter()

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

◆ gprs_ns2_st_alive_onleave()

static void gprs_ns2_st_alive_onleave ( struct osmo_fsm_inst fi,
uint32_t  next_state 
)
static

◆ gprs_ns2_st_blocked()

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

◆ gprs_ns2_st_blocked_onenter()

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

◆ gprs_ns2_st_reset()

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

◆ gprs_ns2_st_reset_onenter()

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

◆ gprs_ns2_st_unblocked()

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

◆ gprs_ns2_st_unblocked_on_enter()

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

◆ gprs_ns2_st_unconfigured()

◆ gprs_ns2_vc_fsm_alloc()

struct osmo_fsm_inst* gprs_ns2_vc_fsm_alloc ( struct gprs_ns2_vc nsvc,
const char *  id,
bool  initiater 
)

gprs_ns2_vc_fsm_alloc

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

References alive_timeout_handler(), gprs_ns2_vc::fi, gprs_ns2_vc_fsm, gprs_ns2_vc_priv::initiater, LOGL_DEBUG, gprs_ns2_vc_priv::nsvc, osmo_fsm_inst_alloc(), osmo_timer_setup(), osmo_fsm_inst::priv, and priv.

Referenced by ns2_vc_alloc().

◆ gprs_ns2_vc_fsm_allstate_action()

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

◆ gprs_ns2_vc_fsm_start()

int gprs_ns2_vc_fsm_start ( struct gprs_ns2_vc nsvc)

Start a NS-VC FSM.

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

References gprs_ns2_vc::fi, GPRS_NS2_EV_START, GPRS_NS2_ST_UNCONFIGURED, gprs_ns2_vc_priv::nsvc, osmo_fsm_inst_dispatch, and osmo_fsm_inst::state.

Referenced by gprs_ns2_ip_connect(), gprs_ns2_start_alive_all_nsvcs(), handle_nsfrgre_read(), and handle_nsip_read().

◆ gprs_ns2_vc_fsm_timer_cb()

◆ gprs_ns2_vc_is_unblocked()

int gprs_ns2_vc_is_unblocked ( struct gprs_ns2_vc nsvc)

◆ gprs_ns2_vc_rx()

int gprs_ns2_vc_rx ( struct gprs_ns2_vc nsvc,
struct msgb msg,
struct tlv_parsed tp 
)

◆ ns_inst_from_fi()

◆ recv_test_procedure()

◆ start_test_procedure()

◆ stop_test_procedure()

static void stop_test_procedure ( struct gprs_ns2_vc_priv priv)
static

References osmo_timer_del(), and priv.

Referenced by gprs_ns2_st_reset_onenter().

Variable Documentation

◆ gprs_ns2_vc_event_names

const struct value_string gprs_ns2_vc_event_names[]
static
Initial value:
= {
{ GPRS_NS2_EV_START, "START" },
{ GPRS_NS2_EV_RESET, "RESET" },
{ GPRS_NS2_EV_RESET_ACK, "RESET_ACK" },
{ GPRS_NS2_EV_UNBLOCK, "UNBLOCK" },
{ GPRS_NS2_EV_UNBLOCK_ACK, "UNBLOCK_ACK" },
{ GPRS_NS2_EV_BLOCK, "BLOCK" },
{ GPRS_NS2_EV_BLOCK_ACK, "BLOCK_ACK" },
{ GPRS_NS2_EV_ALIVE, "ALIVE" },
{ GPRS_NS2_EV_ALIVE_ACK, "ALIVE_ACK" },
{ GPRS_NS2_EV_STATUS, "STATUS" },
{ GPRS_NS2_EV_UNITDATA, "UNITDATA" },
{ 0, NULL }
}
@ GPRS_NS2_EV_RESET_ACK
Definition: gprs_ns2_vc_fsm.c:102
@ GPRS_NS2_EV_UNBLOCK_ACK
Definition: gprs_ns2_vc_fsm.c:104
@ GPRS_NS2_EV_ALIVE
Definition: gprs_ns2_vc_fsm.c:107
@ GPRS_NS2_EV_ALIVE_ACK
Definition: gprs_ns2_vc_fsm.c:108
@ GPRS_NS2_EV_START
Definition: gprs_ns2_vc_fsm.c:98
@ GPRS_NS2_EV_RESET
Definition: gprs_ns2_vc_fsm.c:101
@ GPRS_NS2_EV_UNITDATA
Definition: gprs_ns2_vc_fsm.c:111
@ GPRS_NS2_EV_BLOCK_ACK
Definition: gprs_ns2_vc_fsm.c:106
@ GPRS_NS2_EV_UNBLOCK
Definition: gprs_ns2_vc_fsm.c:103
@ GPRS_NS2_EV_STATUS
Definition: gprs_ns2_vc_fsm.c:109
@ GPRS_NS2_EV_BLOCK
Definition: gprs_ns2_vc_fsm.c:105

◆ gprs_ns2_vc_fsm

struct osmo_fsm gprs_ns2_vc_fsm
static
Initial value:
= {
.name = "GPRS-NS2-VC",
.states = gprs_ns2_vc_states,
.allstate_event_mask = S(GPRS_NS2_EV_UNITDATA) |
.allstate_action = gprs_ns2_vc_fsm_allstate_action,
.cleanup = NULL,
.event_names = gprs_ns2_vc_event_names,
.pre_term = NULL,
.log_subsys = DLNS,
}
static void gprs_ns2_vc_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
Definition: gprs_ns2_vc_fsm.c:485
static const struct value_string gprs_ns2_vc_event_names[]
Definition: gprs_ns2_vc_fsm.c:114
static int gprs_ns2_vc_fsm_timer_cb(struct osmo_fsm_inst *fi)
Definition: gprs_ns2_vc_fsm.c:414
static const struct osmo_fsm_state gprs_ns2_vc_states[]
Definition: gprs_ns2_vc_fsm.c:368
#define S(x)
Definition: gprs_ns2_vc_fsm.c:50
#define DLNS
#define ARRAY_SIZE(x)

Referenced by __attribute__(), and gprs_ns2_vc_fsm_alloc().

◆ gprs_ns2_vc_states

const struct osmo_fsm_state gprs_ns2_vc_states[]
static