libosmo-sigtran  1.9.0.4-dc82
Osmocom SIGTRAN library
xua_asp_fsm.c File Reference
#include <errno.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/prim.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/select.h>
#include <osmocom/gsm/ipa.h>
#include <osmocom/netif/stream.h>
#include <osmocom/netif/ipa.h>
#include <osmocom/sigtran/osmo_ss7.h>
#include <osmocom/sigtran/sigtran_sap.h>
#include <osmocom/sigtran/xua_msg.h>
#include <osmocom/sigtran/protocol/sua.h>
#include "xua_asp_fsm.h"
#include "xua_as_fsm.h"
#include "xua_internal.h"

Data Structures

struct  xua_asp_fsm_priv
 
struct  ipa_asp_fsm_priv
 

Macros

#define S(x)   (1 << (x))
 
#define XUA_T_ACK_SEC   2
 
#define ENSURE_ASP_OR_IPSP(fi, event)
 
#define ENSURE_SG_OR_IPSP(fi, event)
 

Enumerations

enum  ipa_asp_state {
  IPA_ASP_S_DOWN = XUA_ASP_S_DOWN, IPA_ASP_S_INACTIVE = XUA_ASP_S_INACTIVE, IPA_ASP_S_ACTIVE = XUA_ASP_S_ACTIVE, IPA_ASP_S_WAIT_ID_RESP,
  IPA_ASP_S_WAIT_ID_GET, IPA_ASP_S_WAIT_ID_ACK, IPA_ASP_S_WAIT_ID_ACK2
}
 
enum  ipa_asp_fsm_t { T_WAIT_ID_RESP = 1, T_WAIT_ID_ACK, T_WAIT_ID_GET }
 

Functions

struct osmo_xlm_primxua_xlm_prim_alloc (enum osmo_xlm_prim_type prim_type, enum osmo_prim_operation op)
 
void xua_asp_send_xlm_prim (struct osmo_ss7_asp *asp, struct osmo_xlm_prim *prim)
 
void xua_asp_send_xlm_prim_simple (struct osmo_ss7_asp *asp, enum osmo_xlm_prim_type prim_type, enum osmo_prim_operation op)
 
static void send_xlm_prim_simple (struct osmo_fsm_inst *fi, enum osmo_xlm_prim_type prim_type, enum osmo_prim_operation op)
 
static int determine_traf_mode (struct osmo_ss7_asp *asp)
 
static int xua_msg_add_asp_rctx (struct xua_msg *xua, struct osmo_ss7_asp *asp)
 
static int peer_send (struct osmo_fsm_inst *fi, int out_event, struct xua_msg *in)
 
static int peer_send_error (struct osmo_fsm_inst *fi, uint32_t err_code)
 
static void xua_t_ack_cb (void *data)
 
static int peer_send_and_start_t_ack (struct osmo_fsm_inst *fi, int out_event)
 
static void dispatch_to_all_as (struct osmo_fsm_inst *fi, uint32_t event)
 
static void check_stop_t_ack (struct osmo_fsm_inst *fi, uint32_t event)
 
static void xua_asp_fsm_down_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state)
 
static void xua_asp_fsm_down (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void xua_asp_fsm_inactive_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state)
 
static void xua_asp_fsm_inactive (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void xua_asp_fsm_active_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state)
 
static void xua_asp_fsm_active (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void xua_asp_allstate (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static int xua_asp_fsm_timer_cb (struct osmo_fsm_inst *fi)
 
static void xua_asp_fsm_cleanup (struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
 
static struct osmo_fsm_inst * ipa_asp_fsm_start (struct osmo_ss7_asp *asp, enum osmo_ss7_asp_role role, int log_level)
 Start a new ASP finite state machine for given ASP. More...
 
struct osmo_fsm_inst * xua_asp_fsm_start (struct osmo_ss7_asp *asp, enum osmo_ss7_asp_role role, int log_level)
 Start a new ASP finite stae machine for given ASP. More...
 
static int get_fd_from_iafp (struct ipa_asp_fsm_priv *iafp)
 
static void ipa_asp_fsm_down (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ipa_asp_fsm_wait_id_resp (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ipa_asp_fsm_wait_id_ack2 (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ipa_asp_fsm_wait_id_get (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ipa_asp_fsm_wait_id_ack (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ipa_asp_fsm_active_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state)
 
static void ipa_asp_fsm_active (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ipa_asp_fsm_inactive_onenter (struct osmo_fsm_inst *fi, uint32_t prev_state)
 
static void ipa_asp_fsm_inactive (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ipa_asp_allstate (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ipa_pong_timer_cb (void *_fi)
 
static int ipa_asp_fsm_timer_cb (struct osmo_fsm_inst *fi)
 

Variables

static const struct value_string xua_asp_event_names []
 
static const uint32_t evt_ack_map [_NUM_XUA_ASP_E]
 
static const struct osmo_fsm_state xua_asp_states []
 
struct osmo_fsm xua_asp_fsm
 
static const struct osmo_fsm_state ipa_asp_states []
 
struct osmo_fsm ipa_asp_fsm
 

Macro Definition Documentation

◆ ENSURE_ASP_OR_IPSP

#define ENSURE_ASP_OR_IPSP (   fi,
  event 
)
Value:
do { \
struct xua_asp_fsm_priv *_xafp = fi->priv; \
if (_xafp->role != OSMO_SS7_ASP_ROLE_ASP && \
_xafp->role != OSMO_SS7_ASP_ROLE_IPSP) { \
LOGPFSML(fi, LOGL_ERROR, "event %s not permitted " \
"in role %s\n", \
osmo_fsm_event_name(fi->fsm, event), \
get_value_string(osmo_ss7_asp_role_names, _xafp->role));\
return; \
} \
} while(0)
Definition: xua_asp_fsm.c:78
const struct value_string osmo_ss7_asp_role_names[]
Definition: osmo_ss7_asp.c:124
Definition: osmo_ss7.h:383
Definition: osmo_ss7.h:385

Referenced by xua_asp_fsm_active(), xua_asp_fsm_down(), and xua_asp_fsm_inactive().

◆ ENSURE_SG_OR_IPSP

#define ENSURE_SG_OR_IPSP (   fi,
  event 
)
Value:
do { \
struct xua_asp_fsm_priv *_xafp = fi->priv; \
if (_xafp->role != OSMO_SS7_ASP_ROLE_SG && \
_xafp->role != OSMO_SS7_ASP_ROLE_IPSP) { \
LOGPFSML(fi, LOGL_ERROR, "event %s not permitted " \
"in role %s\n", \
osmo_fsm_event_name(fi->fsm, event), \
get_value_string(osmo_ss7_asp_role_names, _xafp->role));\
return; \
} \
} while(0)
Definition: osmo_ss7.h:384
Definition: xua_asp_fsm.c:78
const struct value_string osmo_ss7_asp_role_names[]
Definition: osmo_ss7_asp.c:124
Definition: osmo_ss7.h:385

Referenced by xua_asp_fsm_active(), xua_asp_fsm_down(), and xua_asp_fsm_inactive().

◆ S

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

◆ XUA_T_ACK_SEC

#define XUA_T_ACK_SEC   2

Enumeration Type Documentation

◆ ipa_asp_fsm_t

Enumerator
T_WAIT_ID_RESP 
T_WAIT_ID_ACK 
T_WAIT_ID_GET 

◆ ipa_asp_state

Enumerator
IPA_ASP_S_DOWN 
IPA_ASP_S_INACTIVE 
IPA_ASP_S_ACTIVE 
IPA_ASP_S_WAIT_ID_RESP 
IPA_ASP_S_WAIT_ID_GET 
IPA_ASP_S_WAIT_ID_ACK 
IPA_ASP_S_WAIT_ID_ACK2 

Function Documentation

◆ check_stop_t_ack()

static void check_stop_t_ack ( struct osmo_fsm_inst *  fi,
uint32_t  event 
)
static

◆ determine_traf_mode()

◆ dispatch_to_all_as()

◆ get_fd_from_iafp()

◆ ipa_asp_allstate()

◆ ipa_asp_fsm_active()

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

◆ ipa_asp_fsm_active_onenter()

static void ipa_asp_fsm_active_onenter ( struct osmo_fsm_inst *  fi,
uint32_t  prev_state 
)
static

◆ ipa_asp_fsm_down()

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

◆ ipa_asp_fsm_inactive()

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

◆ ipa_asp_fsm_inactive_onenter()

static void ipa_asp_fsm_inactive_onenter ( struct osmo_fsm_inst *  fi,
uint32_t  prev_state 
)
static

◆ ipa_asp_fsm_start()

static struct osmo_fsm_inst * ipa_asp_fsm_start ( struct osmo_ss7_asp asp,
enum osmo_ss7_asp_role  role,
int  log_level 
)
static

Start a new ASP finite state machine for given ASP.

Parameters
[in]aspApplication Server Process for which to start FSM
[in]roleRole (ASP, SG, IPSP) of this FSM
[in]log_levelLogging Level for ASP FSM logging
Returns
FSM instance on success; NULL on error

References xua_asp_fsm_priv::asp, ipa_asp_fsm_priv::asp, osmo_ss7_as::cfg, osmo_ss7_asp::cfg, osmo_ss7_asp::dyn_allocated, osmo_ss7_as::fi, ipa_asp_fsm, ipa_find_as_for_asp(), ipa_pong_timer_cb(), ipa_asp_fsm_priv::ipa_unit, osmo_ss7_as::name, osmo_ss7_asp::name, OSMO_SS7_ASP_ROLE_ASP, ipa_asp_fsm_priv::pong_timer, xua_asp_fsm_priv::role, ipa_asp_fsm_priv::role, and XUA_ASP_E_M_ASP_UP_REQ.

Referenced by xua_asp_fsm_start().

◆ ipa_asp_fsm_timer_cb()

static int ipa_asp_fsm_timer_cb ( struct osmo_fsm_inst *  fi)
static

◆ ipa_asp_fsm_wait_id_ack()

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

◆ ipa_asp_fsm_wait_id_ack2()

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

◆ ipa_asp_fsm_wait_id_get()

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

◆ ipa_asp_fsm_wait_id_resp()

◆ ipa_pong_timer_cb()

static void ipa_pong_timer_cb ( void *  _fi)
static

◆ peer_send()

◆ peer_send_and_start_t_ack()

static int peer_send_and_start_t_ack ( struct osmo_fsm_inst *  fi,
int  out_event 
)
static

◆ peer_send_error()

◆ send_xlm_prim_simple()

static void send_xlm_prim_simple ( struct osmo_fsm_inst *  fi,
enum osmo_xlm_prim_type  prim_type,
enum osmo_prim_operation  op 
)
static

◆ xua_asp_allstate()

◆ xua_asp_fsm_active()

◆ xua_asp_fsm_active_onenter()

static void xua_asp_fsm_active_onenter ( struct osmo_fsm_inst *  fi,
uint32_t  prev_state 
)
static

◆ xua_asp_fsm_cleanup()

static void xua_asp_fsm_cleanup ( struct osmo_fsm_inst *  fi,
enum osmo_fsm_term_cause  cause 
)
static

◆ xua_asp_fsm_down()

◆ xua_asp_fsm_down_onenter()

static void xua_asp_fsm_down_onenter ( struct osmo_fsm_inst *  fi,
uint32_t  prev_state 
)
static

◆ xua_asp_fsm_inactive()

◆ xua_asp_fsm_inactive_onenter()

static void xua_asp_fsm_inactive_onenter ( struct osmo_fsm_inst *  fi,
uint32_t  prev_state 
)
static

◆ xua_asp_fsm_start()

struct osmo_fsm_inst* xua_asp_fsm_start ( struct osmo_ss7_asp asp,
enum osmo_ss7_asp_role  role,
int  log_level 
)

Start a new ASP finite stae machine for given ASP.

Parameters
[in]aspApplication Server Process for which to start FSM
[in]roleRole (ASP, SG, IPSP) of this FSM
[in]log_levelLogging Level for ASP FSM logging
Returns
FSM instance on success; NULL on error

References xua_asp_fsm_priv::asp, osmo_ss7_asp::cfg, ipa_asp_fsm_start(), osmo_ss7_asp::name, OSMO_SS7_ASP_PROT_IPA, osmo_ss7_asp::proto, xua_asp_fsm_priv::role, and xua_asp_fsm.

Referenced by osmo_ss7_asp_restart().

◆ xua_asp_fsm_timer_cb()

static int xua_asp_fsm_timer_cb ( struct osmo_fsm_inst *  fi)
static

◆ xua_asp_send_xlm_prim()

◆ xua_asp_send_xlm_prim_simple()

void xua_asp_send_xlm_prim_simple ( struct osmo_ss7_asp asp,
enum osmo_xlm_prim_type  prim_type,
enum osmo_prim_operation  op 
)

◆ xua_msg_add_asp_rctx()

◆ xua_t_ack_cb()

static void xua_t_ack_cb ( void *  data)
static

◆ xua_xlm_prim_alloc()

struct osmo_xlm_prim* xua_xlm_prim_alloc ( enum osmo_xlm_prim_type  prim_type,
enum osmo_prim_operation  op 
)

Variable Documentation

◆ evt_ack_map

const uint32_t evt_ack_map[_NUM_XUA_ASP_E]
static
Initial value:
= {
}
Definition: xua_asp_fsm.h:23
Definition: xua_asp_fsm.h:28
Definition: xua_asp_fsm.h:26
Definition: xua_asp_fsm.h:19
Definition: xua_asp_fsm.h:22
Definition: xua_asp_fsm.h:24
Definition: xua_asp_fsm.h:25
Definition: xua_asp_fsm.h:20
Definition: xua_asp_fsm.h:21
Definition: xua_asp_fsm.h:29

Referenced by check_stop_t_ack().

◆ ipa_asp_fsm

struct osmo_fsm ipa_asp_fsm
Initial value:
= {
.name = "IPA_ASP",
.states = ipa_asp_states,
.num_states = ARRAY_SIZE(ipa_asp_states),
.timer_cb = ipa_asp_fsm_timer_cb,
.log_subsys = DLSS7,
.event_names = xua_asp_event_names,
.allstate_event_mask = S(XUA_ASP_E_SCTP_COMM_DOWN_IND) |
.allstate_action = ipa_asp_allstate,
}
static const struct osmo_fsm_state ipa_asp_states[]
Definition: xua_asp_fsm.c:1123
Definition: xua_asp_fsm.h:28
static const struct value_string xua_asp_event_names[]
Definition: xua_asp_fsm.c:46
#define S(x)
Definition: xua_asp_fsm.c:34
Definition: xua_asp_fsm.h:32
static void ipa_asp_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data)
Definition: xua_asp_fsm.c:1066
Definition: xua_asp_fsm.h:15
Definition: xua_asp_fsm.h:16
static int ipa_asp_fsm_timer_cb(struct osmo_fsm_inst *fi)
Definition: xua_asp_fsm.c:1113
Definition: xua_asp_fsm.h:29

Referenced by ipa_asp_fsm_start(), and osmo_ss7_init().

◆ ipa_asp_states

const struct osmo_fsm_state ipa_asp_states[]
static

◆ xua_asp_event_names

const struct value_string xua_asp_event_names[]
static
Initial value:
= {
{ XUA_ASP_E_M_ASP_UP_REQ, "M-ASP_UP.req" },
{ XUA_ASP_E_M_ASP_ACTIVE_REQ, "M-ASP_ACTIVE.req" },
{ XUA_ASP_E_M_ASP_DOWN_REQ, "M-ASP_DOWN.req" },
{ XUA_ASP_E_M_ASP_INACTIVE_REQ, "M-ASP_INACTIVE.req" },
{ XUA_ASP_E_SCTP_COMM_DOWN_IND, "SCTP-COMM_DOWN.ind" },
{ XUA_ASP_E_SCTP_RESTART_IND, "SCTP-RESTART.ind" },
{ XUA_ASP_E_SCTP_EST_IND, "SCTP-EST.ind" },
{ XUA_ASP_E_ASPSM_ASPUP, "ASPSM-ASP_UP" },
{ XUA_ASP_E_ASPSM_ASPUP_ACK, "ASPSM-ASP_UP_ACK" },
{ XUA_ASP_E_ASPTM_ASPAC, "ASPTM-ASP_AC" },
{ XUA_ASP_E_ASPTM_ASPAC_ACK, "ASPTM-ASP_AC_ACK" },
{ XUA_ASP_E_ASPSM_ASPDN, "ASPSM-ASP_DN" },
{ XUA_ASP_E_ASPSM_ASPDN_ACK, "ASPSM-ASP_DN_ACK" },
{ XUA_ASP_E_ASPTM_ASPIA, "ASPTM-ASP_IA" },
{ XUA_ASP_E_ASPTM_ASPIA_ACK, "ASPTM_ASP_IA_ACK" },
{ XUA_ASP_E_ASPSM_BEAT, "ASPSM_BEAT" },
{ XUA_ASP_E_ASPSM_BEAT_ACK, "ASPSM_BEAT_ACK" },
{ XUA_ASP_E_AS_ASSIGNED, "AS_ASSIGNED" },
{ IPA_ASP_E_ID_RESP, "IPA_CCM_ID_RESP" },
{ IPA_ASP_E_ID_GET, "IPA_CCM_ID_GET" },
{ IPA_ASP_E_ID_ACK, "IPA_CCM_ID_ACK" },
{ 0, NULL }
}
Definition: xua_asp_fsm.h:37
Definition: xua_asp_fsm.h:23
Definition: xua_asp_fsm.h:28
Definition: xua_asp_fsm.h:10
Definition: xua_asp_fsm.h:26
Definition: xua_asp_fsm.h:19
Definition: xua_asp_fsm.h:32
Definition: xua_asp_fsm.h:12
Definition: xua_asp_fsm.h:17
Definition: xua_asp_fsm.h:15
Definition: xua_asp_fsm.h:16
Definition: xua_asp_fsm.h:22
Definition: xua_asp_fsm.h:24
Definition: xua_asp_fsm.h:25
Definition: xua_asp_fsm.h:11
Definition: xua_asp_fsm.h:36
Definition: xua_asp_fsm.h:35
Definition: xua_asp_fsm.h:20
Definition: xua_asp_fsm.h:13
Definition: xua_asp_fsm.h:21
Definition: xua_asp_fsm.h:29

◆ xua_asp_fsm

struct osmo_fsm xua_asp_fsm
Initial value:
= {
.name = "XUA_ASP",
.states = xua_asp_states,
.num_states = ARRAY_SIZE(xua_asp_states),
.timer_cb = xua_asp_fsm_timer_cb,
.log_subsys = DLSS7,
.event_names = xua_asp_event_names,
.allstate_event_mask = S(XUA_ASP_E_SCTP_COMM_DOWN_IND) |
.allstate_action = xua_asp_allstate,
.cleanup = xua_asp_fsm_cleanup,
}
Definition: xua_asp_fsm.h:28
static const struct value_string xua_asp_event_names[]
Definition: xua_asp_fsm.c:46
#define S(x)
Definition: xua_asp_fsm.c:34
Definition: xua_asp_fsm.h:32
static const struct osmo_fsm_state xua_asp_states[]
Definition: xua_asp_fsm.c:716
Definition: xua_asp_fsm.h:15
Definition: xua_asp_fsm.h:16
static void xua_asp_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data)
Definition: xua_asp_fsm.c:674
static void xua_asp_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
Definition: xua_asp_fsm.c:709
static int xua_asp_fsm_timer_cb(struct osmo_fsm_inst *fi)
Definition: xua_asp_fsm.c:702
Definition: xua_asp_fsm.h:29

Referenced by osmo_ss7_init(), and xua_asp_fsm_start().

◆ xua_asp_states

const struct osmo_fsm_state xua_asp_states[]
static