libosmo-sigtran: src/xua_as_fsm.c File Reference

libosmo-sigtran 2.2.1.95-893c Osmocom SIGTRAN library

Data Structures | Macros | Functions | Variables
xua_as_fsm.c File Reference
`#include <string.h>`
`#include <arpa/inet.h>`
`#include <osmocom/core/fsm.h>`
`#include <osmocom/core/linuxlist.h>`
`#include <osmocom/core/utils.h>`
`#include <osmocom/core/timer.h>`
`#include <osmocom/core/prim.h>`
`#include <osmocom/core/logging.h>`
`#include <osmocom/sigtran/osmo_ss7.h>`
`#include <osmocom/sigtran/sigtran_sap.h>`
`#include "xua_msg.h"`
`#include <osmocom/sigtran/protocol/sua.h>`
`#include <osmocom/sigtran/protocol/m3ua.h>`
`#include <sys/types.h>`
`#include "sccp_internal.h"`
`#include "ss7_as.h"`
`#include "ss7_asp.h"`
`#include "ss7_combined_linkset.h"`
`#include "ss7_route.h"`
`#include "ss7_route_table.h"`
`#include "xua_asp_fsm.h"`
`#include "xua_as_fsm.h"`
`#include "xua_internal.h"`

## Data Structures
struct | xua_as_fsm_priv

## Macros
#define | S(x) (1 << (x))
#define | MSEC_TO_S_US(x) (x/1000), ((x%1000)*10)

## Functions
static struct msgb * | encode_notify (const struct osmo_xlm_prim_notify *npar)
static int | fill_notify_route_ctx (const struct osmo_ss7_asp *asp, struct osmo_xlm_prim_notify *npar)
static void | tx_notify (struct osmo_ss7_asp *asp, struct osmo_xlm_prim_notify *npar)
static void | as_tx_duna_during_asp_act (struct osmo_ss7_as *as, struct osmo_ss7_asp *asp)
static int | as_notify_all_asp (struct osmo_ss7_as *as, struct osmo_xlm_prim_notify *npar)
static struct msgb * | xua_as_encode_msg (const struct osmo_ss7_as *as, struct xua_msg *xua)
int | xua_as_transmit_msg_broadcast (struct osmo_ss7_as *as, struct xua_msg *xua)
int | xua_as_transmit_msg (struct osmo_ss7_as *as, struct xua_msg *xua)
static void | fill_notify_statchg_pars (const struct osmo_fsm_inst *fi, struct osmo_xlm_prim_notify *npar)
static bool | check_any_other_asp_not_down (struct osmo_ss7_as *as, struct osmo_ss7_asp *asp_cmp)
static bool | check_any_other_asp_in_active (struct osmo_ss7_as *as, struct osmo_ss7_asp *asp_cmp)
static void | notify_any_other_active_asp_as_inactive (struct osmo_ss7_as *as, struct osmo_ss7_asp *asp_cmp)
static void | t_r_callback (void *_fi)
static void | xua_as_fsm_down (struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void | as_snm_pc_unavailable (struct osmo_ss7_as *as)
static void | as_snm_pc_available (struct osmo_ss7_as *as)
static void | xua_as_fsm_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
static void | xua_as_fsm_inactive (struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void | xua_as_fsm_active (struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void | xua_as_fsm_pending (struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void | xua_as_fsm_cleanup (struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
struct osmo_fsm_inst * | xua_as_fsm_start (struct osmo_ss7_as *as, int log_level)
| Start an AS FSM for a given Application Server. More...

## Variables
static const struct value_string | xua_as_event_names []
static const struct osmo_fsm_state | xua_as_fsm_states []
struct osmo_fsm | xua_as_fsm

## Macro Definition Documentation

## ◆ MSEC_TO_S_US

#define MSEC_TO_S_US | ( |  | x | ) | (x/1000), ((x%1000)*10)

## ◆ S

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

## Function Documentation

## ◆ as_notify_all_asp()

static int as_notify_all_asp | ( | struct osmo_ss7_as * | as,
|  | struct osmo_xlm_prim_notify * | npar
| ) |  |
| static

References ss7_as_asp_assoc::as, ss7_as_asp_assoc::as_entry, ss7_as_asp_assoc::asp, osmo_xlm_prim_notify::asp_id, osmo_ss7_as::assoc_asp_list, osmo_ss7_as::cfg, osmo_ss7_asp::cfg, encode_notify(), osmo_ss7_as::fi, osmo_ss7_asp::fi, fill_notify_route_ctx(), osmo_xlm_prim_notify::info_string, LOGPASP, m3ua_ntfy_info_name(), m3ua_ntfy_type_names, NOTIFY_PAR_P_ASP_ID, OSMO_SS7_ASP_PROT_IPA, OSMO_SS7_ASP_ROLE_ASP, osmo_ss7_asp_send(), osmo_xlm_prim_notify::presence, osmo_ss7_as::proto, osmo_ss7_asp::remote_asp_id, osmo_ss7_asp::remote_asp_id_present, osmo_ss7_asp::role, osmo_xlm_prim_notify::status_info, osmo_xlm_prim_notify::status_type, and XUA_ASP_S_DOWN.

Referenced by xua_as_fsm_onenter().

## ◆ as_snm_pc_available()

static void as_snm_pc_available | ( | struct osmo_ss7_as * | as | ) |
| static

References osmo_sccp_addr_entry::addr, osmo_ss7_route::as, osmo_ss7_instance::cfg, osmo_ss7_route::cfg, osmo_ss7_route::clset, osmo_ss7_route_table::combined_linksets, osmo_ss7_route::dest, osmo_ss7_as::inst, osmo_sccp_addr_entry::list, osmo_ss7_route::list, LOGPAS, NULL, OSMO_SCCP_ADDR_T_PC, osmo_ss7_pc_is_local(), osmo_ss7_pointcode_print(), osmo_sccp_addr::pc, osmo_ss7_route::pc, osmo_sccp_addr::presence, osmo_ss7_combined_linkset::routes, osmo_ss7_instance::rtable_system, osmo_ss7_instance::sccp_address_book, ss7_route_is_summary(), ss7_route_table_dpc_is_accessible(), ss7_route_table_dpc_is_accessible_skip_as(), ss7_route_table_dpc_is_accessible_via_as(), and xua_snm_pc_available().

Referenced by xua_as_fsm_onenter().

## ◆ as_snm_pc_unavailable()

static void as_snm_pc_unavailable | ( | struct osmo_ss7_as * | as | ) |
| static

References osmo_sccp_addr_entry::addr, osmo_ss7_route::as, osmo_ss7_instance::cfg, osmo_ss7_route::cfg, osmo_ss7_route::clset, osmo_ss7_route_table::combined_linksets, osmo_ss7_route::dest, osmo_ss7_as::inst, osmo_sccp_addr_entry::list, osmo_ss7_route::list, LOGPAS, NULL, OSMO_SCCP_ADDR_T_PC, osmo_ss7_pc_is_local(), osmo_ss7_pointcode_print(), OSMO_SS7_ROUTE_STATUS_UNAVAILABLE, osmo_sccp_addr::pc, osmo_ss7_route::pc, osmo_sccp_addr::presence, osmo_ss7_combined_linkset::routes, osmo_ss7_instance::rtable_system, osmo_ss7_instance::sccp_address_book, ss7_route_is_summary(), ss7_route_table_dpc_is_accessible(), ss7_route_table_dpc_is_accessible_skip_as(), osmo_ss7_route::status, and xua_snm_pc_available().

Referenced by xua_as_fsm_onenter().

## ◆ as_tx_duna_during_asp_act()

static void as_tx_duna_during_asp_act | ( | struct osmo_ss7_as * | as,
|  | struct osmo_ss7_asp * | asp
| ) |  |
| static

References osmo_ss7_instance::as_list, osmo_ss7_as::cfg, osmo_ss7_routing_key::context, osmo_ss7_as::inst, osmo_ss7_route_table::inst, osmo_ss7_as::list, osmo_ss7_routing_key::pc, osmo_ss7_as::routing_key, osmo_ss7_instance::rtable_system, ss7_route_table_dpc_is_accessible_skip_as(), and xua_tx_snm_available().

Referenced by xua_as_fsm_inactive(), and xua_as_fsm_pending().

## ◆ check_any_other_asp_in_active()

static bool check_any_other_asp_in_active | ( | struct osmo_ss7_as * | as,
|  | struct osmo_ss7_asp * | asp_cmp
| ) |  |
| static

References ss7_as_asp_assoc::as, ss7_as_asp_assoc::as_entry, ss7_as_asp_assoc::asp, osmo_ss7_as::assoc_asp_list, and osmo_ss7_asp_active().

Referenced by xua_as_fsm_active().

## ◆ check_any_other_asp_not_down()

static bool check_any_other_asp_not_down | ( | struct osmo_ss7_as * | as,
|  | struct osmo_ss7_asp * | asp_cmp
| ) |  |
| static

References ss7_as_asp_assoc::as, ss7_as_asp_assoc::as_entry, ss7_as_asp_assoc::asp, osmo_ss7_as::assoc_asp_list, osmo_ss7_asp::fi, and XUA_ASP_S_DOWN.

Referenced by xua_as_fsm_inactive(), and xua_as_fsm_pending().

## ◆ encode_notify()

static struct msgb * encode_notify | ( | const struct osmo_xlm_prim_notify * | npar | ) |
| static

References m3ua_encode_notify(), M3UA_VERSION, xua_msg_free(), and xua_to_msg().

Referenced by as_notify_all_asp(), notify_any_other_active_asp_as_inactive(), and tx_notify().

## ◆ fill_notify_route_ctx()

static int fill_notify_route_ctx | ( | const struct osmo_ss7_asp * | asp,
|  | struct osmo_xlm_prim_notify * | npar
| ) |  |
| static

References NOTIFY_PAR_P_ROUTE_CTX, NULL, osmo_xlm_prim_notify::presence, osmo_xlm_prim_notify::route_ctx, osmo_xlm_prim_notify::route_ctx_count, and ss7_asp_get_all_rctx().

Referenced by as_notify_all_asp(), and tx_notify().

## ◆ fill_notify_statchg_pars()

static void fill_notify_statchg_pars | ( | const struct osmo_fsm_inst * | fi,
|  | struct osmo_xlm_prim_notify * | npar
| ) |  |
| static

References M3UA_NOTIFY_I_AS_ACT, M3UA_NOTIFY_I_AS_INACT, M3UA_NOTIFY_I_AS_PEND, M3UA_NOTIFY_T_STATCHG, osmo_xlm_prim_notify::status_info, osmo_xlm_prim_notify::status_type, XUA_AS_S_ACTIVE, XUA_AS_S_DOWN, XUA_AS_S_INACTIVE, and XUA_AS_S_PENDING.

Referenced by xua_as_fsm_active(), xua_as_fsm_inactive(), xua_as_fsm_onenter(), and xua_as_fsm_pending().

## ◆ notify_any_other_active_asp_as_inactive()

static void notify_any_other_active_asp_as_inactive | ( | struct osmo_ss7_as * | as,
|  | struct osmo_ss7_asp * | asp_cmp
| ) |  |
| static

References ss7_as_asp_assoc::asp, osmo_xlm_prim_notify::asp_id, osmo_ss7_as::assoc_asp_list, osmo_ss7_asp::cfg, encode_notify(), osmo_ss7_asp::fi, M3UA_NOTIFY_I_OT_ALT_ASP_ACT, M3UA_NOTIFY_T_OTHER, osmo_ss7_asp_active(), OSMO_SS7_ASP_PROT_IPA, osmo_ss7_asp_send(), osmo_ss7_asp::proto, osmo_ss7_asp::remote_asp_id, osmo_ss7_asp::remote_asp_id_present, osmo_xlm_prim_notify::status_type, and XUA_ASP_S_INACTIVE.

Referenced by xua_as_fsm_active().

## ◆ t_r_callback()

static void t_r_callback | ( | void * | _fi | ) |
| static

References NULL, and XUA_AS_E_RECOVERY_EXPD.

Referenced by xua_as_fsm_start().

## ◆ tx_notify()

static void tx_notify | ( | struct osmo_ss7_asp * | asp,
|  | struct osmo_xlm_prim_notify * | npar
| ) |  |
| static

References encode_notify(), fill_notify_route_ctx(), osmo_xlm_prim_notify::info_string, LOGPASP, m3ua_ntfy_info_name(), m3ua_ntfy_type_names, osmo_ss7_asp_send(), osmo_xlm_prim_notify::status_info, and osmo_xlm_prim_notify::status_type.

Referenced by xua_as_fsm_active(), xua_as_fsm_inactive(), and xua_as_fsm_pending().

## ◆ xua_as_encode_msg()

static struct msgb * xua_as_encode_msg | ( | const struct osmo_ss7_as * | as,
|  | struct xua_msg * | xua
| ) |  |
| static

References osmo_ss7_as::cfg, ipa_to_msg(), m3ua_to_msg(), OSMO_SS7_ASP_PROT_IPA, OSMO_SS7_ASP_PROT_M3UA, and osmo_ss7_as::proto.

Referenced by xua_as_transmit_msg(), and xua_as_transmit_msg_broadcast().

## ◆ xua_as_fsm_active()

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

References xua_as_fsm_priv::as, osmo_ss7_as::cfg, check_any_other_asp_in_active(), data, fill_notify_statchg_pars(), osmo_ss7_as::mode, MSEC_TO_S_US, notify_any_other_active_asp_as_inactive(), OSMO_SS7_AS_TMOD_OVERRIDE, xua_as_fsm_priv::recovery, osmo_ss7_as::recovery_timeout_msec, xua_as_fsm_priv::t_r, tx_notify(), XUA_AS_E_TRANSFER_REQ, XUA_AS_S_PENDING, xua_as_transmit_msg(), XUA_ASPAS_ASP_ACTIVE_IND, XUA_ASPAS_ASP_DOWN_IND, and XUA_ASPAS_ASP_INACTIVE_IND.

## ◆ xua_as_fsm_cleanup()

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

References xua_as_fsm_priv::recovery, and xua_as_fsm_priv::t_r.

## ◆ xua_as_fsm_down()

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

References XUA_AS_S_INACTIVE, XUA_ASPAS_ASP_DOWN_IND, and XUA_ASPAS_ASP_INACTIVE_IND.

## ◆ xua_as_fsm_inactive()

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

References xua_as_fsm_priv::as, as_tx_duna_during_asp_act(), check_any_other_asp_not_down(), data, fill_notify_statchg_pars(), OSMO_SS7_ASP_ROLE_SG, tx_notify(), XUA_AS_S_ACTIVE, XUA_AS_S_DOWN, XUA_ASPAS_ASP_ACTIVE_IND, XUA_ASPAS_ASP_DOWN_IND, and XUA_ASPAS_ASP_INACTIVE_IND.

## ◆ xua_as_fsm_onenter()

static void xua_as_fsm_onenter | ( | struct osmo_fsm_inst * | fi,
|  | uint32_t | old_state
| ) |  |
| static

References xua_as_fsm_priv::as, as_notify_all_asp(), as_snm_pc_available(), as_snm_pc_unavailable(), osmo_ss7_as::cfg, fill_notify_statchg_pars(), osmo_ss7_as::inst, osmo_ss7_as::mode, osmo_ss7_as::mode_set_by_peer, osmo_ss7_as::mode_set_by_vty, NULL, OSMO_SS7_AS_TMOD_OVERRIDE, OSMO_SS7_ASP_ROLE_ASP, OSMO_SS7_ASP_ROLE_IPSP, OSMO_SS7_ASP_ROLE_SG, osmo_ss7_routing_key::pc, osmo_ss7_as::routing_key, ss7_as_get_local_role(), XUA_AS_S_ACTIVE, XUA_AS_S_DOWN, XUA_AS_S_INACTIVE, XUA_AS_S_PENDING, and xua_snm_pc_available().

## ◆ xua_as_fsm_pending()

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

References xua_as_fsm_priv::as, as_tx_duna_during_asp_act(), check_any_other_asp_not_down(), data, xua_msg::entry, fill_notify_statchg_pars(), NULL, OSMO_SS7_ASP_ROLE_SG, xua_as_fsm_priv::queued_xua_msgs, xua_as_fsm_priv::recovery, xua_as_fsm_priv::t_r, tx_notify(), XUA_AS_E_RECOVERY_EXPD, XUA_AS_E_TRANSFER_REQ, XUA_AS_S_ACTIVE, XUA_AS_S_DOWN, XUA_AS_S_INACTIVE, xua_as_transmit_msg(), XUA_ASPAS_ASP_ACTIVE_IND, XUA_ASPAS_ASP_DOWN_IND, XUA_ASPAS_ASP_INACTIVE_IND, and xua_msg_free().

## ◆ xua_as_fsm_start()

struct osmo_fsm_inst * xua_as_fsm_start | ( | struct osmo_ss7_as * | as,
|  | int | log_level
| ) |  |

Start an AS FSM for a given Application Server.

Parameters

  [in] | as | Application Server for which to start the AS FSM
  [in] | log_level | Logging level for logging of this FSM

Returns
  FSM instance in case of success; NULL in case of error

References xua_as_fsm_priv::as, osmo_ss7_as::cfg, osmo_ss7_as::name, NULL, xua_as_fsm_priv::queued_xua_msgs, xua_as_fsm_priv::recovery, xua_as_fsm_priv::t_r, t_r_callback(), and xua_as_fsm.

Referenced by ss7_as_alloc().

## ◆ xua_as_transmit_msg()

int xua_as_transmit_msg | ( | struct osmo_ss7_as * | as,
|  | struct xua_msg * | xua
| ) |  |

References _NUM_OSMO_SS7_ASP_TMOD, osmo_ss7_as::cfg, osmo_ss7_as::fi, osmo_ss7_as::mode, NULL, OSMO_SS7_AS_TMOD_BCAST, OSMO_SS7_AS_TMOD_LOADSHARE, OSMO_SS7_AS_TMOD_OVERRIDE, OSMO_SS7_AS_TMOD_ROUNDROBIN, osmo_ss7_asp_send(), ss7_as_select_asp(), xua_as_encode_msg(), xua_as_transmit_msg_broadcast(), and xua_msg_free().

Referenced by ipa_tx_xua_as(), xua_as_fsm_active(), and xua_as_fsm_pending().

## ◆ xua_as_transmit_msg_broadcast()

int xua_as_transmit_msg_broadcast | ( | struct osmo_ss7_as * | as,
|  | struct xua_msg * | xua
| ) |  |

References ss7_as_asp_assoc::asp, osmo_ss7_as::assoc_asp_list, osmo_ss7_asp_active(), osmo_ss7_asp_send(), xua_as_encode_msg(), and xua_msg_free().

Referenced by xua_as_transmit_msg().

## Variable Documentation

## ◆ xua_as_event_names

const struct value_string xua_as_event_names[]
| static

Initial value:
= {
{ XUA_ASPAS_ASP_INACTIVE_IND, "ASPAS-ASP_INACTIVE.ind" },
{ XUA_ASPAS_ASP_DOWN_IND, "ASPAS-ASP_DOWN.ind" },
{ XUA_ASPAS_ASP_ACTIVE_IND, "ASPAS-ASP_ACTIVE.ind" },
{ XUA_AS_E_RECOVERY_EXPD, "AS-T_REC_EXPD.ind" },
{ XUA_AS_E_TRANSFER_REQ, "AS-TRANSFER.req" },
{ 0, NULL }
}
NULL
int and can be left NULL
Definition: osmo_ss7.h:353
XUA_ASPAS_ASP_DOWN_IND
@ XUA_ASPAS_ASP_DOWN_IND
Definition: xua_as_fsm.h:24
XUA_ASPAS_ASP_ACTIVE_IND
@ XUA_ASPAS_ASP_ACTIVE_IND
Definition: xua_as_fsm.h:25
XUA_AS_E_TRANSFER_REQ
@ XUA_AS_E_TRANSFER_REQ
Definition: xua_as_fsm.h:27
XUA_ASPAS_ASP_INACTIVE_IND
@ XUA_ASPAS_ASP_INACTIVE_IND
Definition: xua_as_fsm.h:23
XUA_AS_E_RECOVERY_EXPD
@ XUA_AS_E_RECOVERY_EXPD
Definition: xua_as_fsm.h:26

## ◆ xua_as_fsm

struct osmo_fsm xua_as_fsm

Initial value:
= {
.name = "XUA_AS",
.states = xua_as_fsm_states,
.num_states = ARRAY_SIZE(xua_as_fsm_states),
.log_subsys = DLSS7,
.event_names = xua_as_event_names,
.cleanup = xua_as_fsm_cleanup,
}
xua_as_fsm_cleanup
static void xua_as_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
Definition: xua_as_fsm.c:674
xua_as_event_names
static const struct value_string xua_as_event_names[]
Definition: xua_as_fsm.c:232
xua_as_fsm_states
static const struct osmo_fsm_state xua_as_fsm_states[]
Definition: xua_as_fsm.c:681

Referenced by osmo_ss7_init(), and xua_as_fsm_start().

## ◆ xua_as_fsm_states

const struct osmo_fsm_state xua_as_fsm_states[]
| static