libosmogb  1.4.0.171-b3b83
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)
 
static void gprs_ns2_vc_fsm_clean (struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
 
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

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

Enumeration Type Documentation

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 
Enumerator
GPRS_NS2_ST_UNCONFIGURED 
GPRS_NS2_ST_RESET 
GPRS_NS2_ST_BLOCKED 
GPRS_NS2_ST_UNBLOCKED 
GPRS_NS2_ST_ALIVE 

Function Documentation

static __attribute__ ( (constructor)  )
static

References OSMO_ASSERT, and osmo_fsm_register().

static int alive_timer_elapsed_ms ( struct gprs_ns2_vc_priv priv)
static
static void gprs_ns2_recv_unitdata ( struct osmo_fsm_inst fi,
struct msgb msg 
)
static
static void gprs_ns2_st_alive ( struct osmo_fsm_inst fi,
uint32_t  event,
void *  data 
)
static
static void gprs_ns2_st_alive_onleave ( struct osmo_fsm_inst fi,
uint32_t  next_state 
)
static
static void gprs_ns2_st_blocked_onenter ( struct osmo_fsm_inst fi,
uint32_t  old_state 
)
static
static void gprs_ns2_st_unblocked ( struct osmo_fsm_inst fi,
uint32_t  event,
void *  data 
)
static
static void gprs_ns2_st_unblocked_on_enter ( struct osmo_fsm_inst fi,
uint32_t  old_state 
)
static
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 gprs_ns2_vc_priv::alive, alive_timeout_handler(), gprs_ns2_vc::fi, gprs_ns2_vc_priv::initiater, LOGL_DEBUG, gprs_ns2_vc_priv::nsvc, osmo_fsm_inst_alloc(), osmo_timer_setup(), osmo_fsm_inst::priv, priv, and gprs_ns2_vc_priv::timer.

Referenced by ns2_vc_alloc().

static void gprs_ns2_vc_fsm_clean ( struct osmo_fsm_inst fi,
enum osmo_fsm_term_cause  cause 
)
static
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, 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().

int gprs_ns2_vc_is_unblocked ( struct gprs_ns2_vc nsvc)
int gprs_ns2_vc_rx ( struct gprs_ns2_vc nsvc,
struct msgb msg,
struct tlv_parsed tp 
)
static void stop_test_procedure ( struct gprs_ns2_vc_priv priv)
static

Variable Documentation

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 }
}
Definition: gprs_ns2_vc_fsm.c:106
Definition: gprs_ns2_vc_fsm.c:104
Definition: gprs_ns2_vc_fsm.c:107
Definition: gprs_ns2_vc_fsm.c:101
Definition: gprs_ns2_vc_fsm.c:98
Definition: gprs_ns2_vc_fsm.c:109
Definition: gprs_ns2_vc_fsm.c:111
Definition: gprs_ns2_vc_fsm.c:103
Definition: gprs_ns2_vc_fsm.c:102
Definition: gprs_ns2_vc_fsm.c:108
Definition: gprs_ns2_vc_fsm.c:105
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,
.event_names = gprs_ns2_vc_event_names,
.pre_term = NULL,
.log_subsys = DLNS,
}
static const struct value_string gprs_ns2_vc_event_names[]
Definition: gprs_ns2_vc_fsm.c:114
Definition: gprs_ns2_vc_fsm.c:107
static const struct osmo_fsm_state gprs_ns2_vc_states[]
Definition: gprs_ns2_vc_fsm.c:368
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
Definition: gprs_ns2_vc_fsm.c:101
#define DLNS
#define S(x)
Definition: gprs_ns2_vc_fsm.c:50
static int gprs_ns2_vc_fsm_timer_cb(struct osmo_fsm_inst *fi)
Definition: gprs_ns2_vc_fsm.c:414
Definition: gprs_ns2_vc_fsm.c:111
static void gprs_ns2_vc_fsm_clean(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
Definition: gprs_ns2_vc_fsm.c:543
Definition: gprs_ns2_vc_fsm.c:108
#define ARRAY_SIZE(x)
const struct osmo_fsm_state gprs_ns2_vc_states[]
static