libosmo-sigtran  0.10.0
Osmocom SIGTRAN library
sccp_scoc.c File Reference
#include <string.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/fsm.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/sigtran/protocol/sua.h>
#include <sccp/sccp_types.h>
#include "xua_internal.h"
#include "sccp_internal.h"
#include <osmocom/vty/vty.h>

Data Structures

struct  sccp_connection
 

Macros

#define S(x)   (1 << (x))
 
#define SCU_MSGB_SIZE   1024
 
#define CONNECTION_TIMER   ( 1 * 60 * 100)
 
#define TX_INACT_TIMER   ( 7 * 60 * 100) /* RFC 3868 Ch. 8. */
 
#define RX_INACT_TIMER   (15 * 60 * 100) /* RFC 3868 Ch. 8. */
 
#define RELEASE_TIMER   ( 10 * 100)
 
#define RELEASE_REP_TIMER   ( 10 * 100)
 
#define INT_TIMER   ( 1 * 60 * 100)
 
#define GUARD_TIMER   (23 * 60 * 100)
 
#define RESET_TIMER   ( 10 * 100)
 
#define MSEC_TO_S_US(x)   (x/100), ((x%100)*10)
 
#define INIT_TIMER(x, fn, priv)   do { (x)->cb = fn; (x)->data = priv; } while (0)
 

Enumerations

enum  sccp_connection_state {
  S_IDLE, S_CONN_PEND_IN, S_CONN_PEND_OUT, S_ACTIVE,
  S_DISCONN_PEND, S_RESET_IN, S_RESET_OUT, S_BOTHWAY_RESET,
  S_WAIT_CONN_CONF
}
 
enum  sccp_scoc_event {
  SCOC_E_SCU_N_CONN_REQ, SCOC_E_SCU_N_CONN_RESP, SCOC_E_SCU_N_DISC_REQ, SCOC_E_SCU_N_DATA_REQ,
  SCOC_E_SCU_N_EXP_DATA_REQ, SCOC_E_RCOC_CONN_IND, SCOC_E_RCOC_ROUT_FAIL_IND, SCOC_E_RCOC_RLSD_IND,
  SCOC_E_RCOC_REL_COMPL_IND, SCOC_E_RCOC_CREF_IND, SCOC_E_RCOC_CC_IND, SCOC_E_RCOC_DT1_IND,
  SCOC_E_RCOC_DT2_IND, SCOC_E_RCOC_IT_IND, SCOC_E_RCOC_OTHER_NPDU, SCOC_E_RCOC_ERROR_IND,
  SCOC_E_T_IAR_EXP, SCOC_E_T_IAS_EXP, SCOC_E_CONN_TMR_EXP, SCOC_E_T_REL_EXP,
  SCOC_E_T_INT_EXP, SCOC_E_T_REP_REL_EXP
}
 

Functions

static void tx_inact_tmr_cb (void *data)
 
static void rx_inact_tmr_cb (void *data)
 
static void rel_tmr_cb (void *data)
 
static void int_tmr_cb (void *data)
 
static void rep_rel_tmr_cb (void *data)
 
static void conn_tmr_cb (void *data)
 
static void conn_restart_tx_inact_timer (struct sccp_connection *conn)
 
static void conn_restart_rx_inact_timer (struct sccp_connection *conn)
 
static void conn_start_inact_timers (struct sccp_connection *conn)
 
static void conn_stop_inact_timers (struct sccp_connection *conn)
 
static void conn_start_rel_timer (struct sccp_connection *conn)
 
static void conn_start_rep_rel_timer (struct sccp_connection *conn)
 
static void conn_start_int_timer (struct sccp_connection *conn)
 
static void conn_stop_release_timers (struct sccp_connection *conn)
 
static void conn_start_connect_timer (struct sccp_connection *conn)
 
static void conn_stop_connect_timer (struct sccp_connection *conn)
 
static void conn_destroy (struct sccp_connection *conn)
 
static struct sccp_connectionconn_find_by_id (struct osmo_sccp_instance *inst, uint32_t id)
 
static struct sccp_connectionconn_create_id (struct osmo_sccp_instance *inst, uint32_t conn_id)
 
static struct sccp_connectionconn_create (struct osmo_sccp_instance *inst)
 
static struct msgb * scu_msgb_alloc (void)
 
static struct xua_msgxua_gen_relre (struct sccp_connection *conn, uint32_t cause, struct osmo_scu_prim *prim)
 
static int xua_gen_relre_and_send (struct sccp_connection *conn, uint32_t cause, struct osmo_scu_prim *prim)
 
static struct xua_msgxua_gen_msg_co (struct sccp_connection *conn, uint32_t event, struct osmo_scu_prim *prim, int msg_type)
 
static int xua_gen_encode_and_send (struct sccp_connection *conn, uint32_t event, struct osmo_scu_prim *prim, int msg_type)
 
static struct osmo_scu_primscu_prim_alloc (unsigned int primitive, enum osmo_prim_operation operation)
 
static void scu_gen_encode_and_send (struct sccp_connection *conn, uint32_t event, struct xua_msg *xua, unsigned int primitive, enum osmo_prim_operation operation)
 
static void scoc_fsm_idle (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void scoc_fsm_idle_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void scoc_fsm_conn_pend_in (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void scoc_fsm_conn_pend_out (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void scoc_fsm_wait_conn_conf (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void scoc_fsm_active (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void scoc_fsm_disconn_pend (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static uint8_t get_cref_cause_for_ret (uint8_t ret_cause)
 
static struct xua_msggen_coref_without_conn (struct osmo_sccp_instance *inst, struct xua_msg *xua_in, uint32_t ref_cause)
 
void sccp_scoc_rx_scrc_rout_fail (struct osmo_sccp_instance *inst, struct xua_msg *xua, uint32_t return_cause)
 SCOC: Receive SCRC Routing Failure. More...
 
static struct osmo_sccp_usersccp_find_user (struct osmo_sccp_instance *inst, struct xua_msg *xua)
 
static struct xua_msggen_coerr (uint32_t route_ctx, uint32_t dest_ref, uint32_t err_cause)
 
static void tx_coerr_from_xua (struct osmo_sccp_instance *inst, struct xua_msg *in, uint32_t err_cause)
 
static struct xua_msggen_relco (uint32_t route_ctx, uint32_t dest_ref, uint32_t src_ref)
 
static void tx_relco_from_xua (struct osmo_sccp_instance *inst, struct xua_msg *in)
 
static struct xua_msggen_rlsd (uint32_t route_ctx, uint32_t dest_ref, uint32_t src_ref)
 
static void tx_rlsd_from_xua_twoway (struct sccp_connection *conn, struct xua_msg *in)
 
static void sccp_scoc_rx_unass_local_ref (struct osmo_sccp_instance *inst, struct xua_msg *xua)
 
static void sccp_scoc_rx_inval_src_ref (struct sccp_connection *conn, struct xua_msg *xua, uint32_t inval_src_ref)
 
static void sccp_scoc_rx_inval_opc (struct sccp_connection *conn, struct xua_msg *xua)
 
void sccp_scoc_rx_from_scrc (struct osmo_sccp_instance *inst, struct xua_msg *xua)
 Main entrance function for primitives from the SCRC (Routing Control) More...
 
static uint32_t scu_prim_conn_id (const struct osmo_scu_prim *prim)
 
int osmo_sccp_user_sap_down (struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph)
 Main entrance function for primitives from SCCP User. More...
 
void sccp_scoc_flush_connections (struct osmo_sccp_instance *inst)
 
static void vty_show_connection (struct vty *vty, struct sccp_connection *conn)
 
void sccp_scoc_show_connections (struct vty *vty, struct osmo_sccp_instance *inst)
 

Variables

static const struct value_string scoc_event_names []
 
static const struct xua_msg_event_map sua_scoc_event_map []
 
static const struct osmo_prim_event_map scu_scoc_event_map []
 
static const struct osmo_fsm_state sccp_scoc_states []
 
struct osmo_fsm sccp_scoc_fsm
 
static const uint8_t cause_map_cref []
 

Macro Definition Documentation

◆ CONNECTION_TIMER

#define CONNECTION_TIMER   ( 1 * 60 * 100)

◆ GUARD_TIMER

#define GUARD_TIMER   (23 * 60 * 100)

◆ INIT_TIMER

#define INIT_TIMER (   x,
  fn,
  priv 
)    do { (x)->cb = fn; (x)->data = priv; } while (0)

Referenced by conn_create_id().

◆ INT_TIMER

#define INT_TIMER   ( 1 * 60 * 100)

Referenced by conn_start_int_timer().

◆ MSEC_TO_S_US

◆ RELEASE_REP_TIMER

#define RELEASE_REP_TIMER   ( 10 * 100)

◆ RELEASE_TIMER

#define RELEASE_TIMER   ( 10 * 100)

Referenced by conn_start_rel_timer().

◆ RESET_TIMER

#define RESET_TIMER   ( 10 * 100)

◆ RX_INACT_TIMER

#define RX_INACT_TIMER   (15 * 60 * 100) /* RFC 3868 Ch. 8. */

◆ S

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

◆ SCU_MSGB_SIZE

#define SCU_MSGB_SIZE   1024

Referenced by scu_msgb_alloc().

◆ TX_INACT_TIMER

#define TX_INACT_TIMER   ( 7 * 60 * 100) /* RFC 3868 Ch. 8. */

Enumeration Type Documentation

◆ sccp_connection_state

Enumerator
S_IDLE 
S_CONN_PEND_IN 
S_CONN_PEND_OUT 
S_ACTIVE 
S_DISCONN_PEND 
S_RESET_IN 
S_RESET_OUT 
S_BOTHWAY_RESET 
S_WAIT_CONN_CONF 

◆ sccp_scoc_event

Enumerator
SCOC_E_SCU_N_CONN_REQ 
SCOC_E_SCU_N_CONN_RESP 
SCOC_E_SCU_N_DISC_REQ 
SCOC_E_SCU_N_DATA_REQ 
SCOC_E_SCU_N_EXP_DATA_REQ 
SCOC_E_RCOC_CONN_IND 
SCOC_E_RCOC_ROUT_FAIL_IND 
SCOC_E_RCOC_RLSD_IND 
SCOC_E_RCOC_REL_COMPL_IND 
SCOC_E_RCOC_CREF_IND 
SCOC_E_RCOC_CC_IND 
SCOC_E_RCOC_DT1_IND 
SCOC_E_RCOC_DT2_IND 
SCOC_E_RCOC_IT_IND 
SCOC_E_RCOC_OTHER_NPDU 
SCOC_E_RCOC_ERROR_IND 
SCOC_E_T_IAR_EXP 
SCOC_E_T_IAS_EXP 
SCOC_E_CONN_TMR_EXP 
SCOC_E_T_REL_EXP 
SCOC_E_T_INT_EXP 
SCOC_E_T_REP_REL_EXP 

Function Documentation

◆ conn_create()

static struct sccp_connection* conn_create ( struct osmo_sccp_instance inst)
static

◆ conn_create_id()

◆ conn_destroy()

◆ conn_find_by_id()

◆ conn_restart_rx_inact_timer()

static void conn_restart_rx_inact_timer ( struct sccp_connection conn)
static

◆ conn_restart_tx_inact_timer()

static void conn_restart_tx_inact_timer ( struct sccp_connection conn)
static

◆ conn_start_connect_timer()

static void conn_start_connect_timer ( struct sccp_connection conn)
static

◆ conn_start_inact_timers()

static void conn_start_inact_timers ( struct sccp_connection conn)
static

◆ conn_start_int_timer()

static void conn_start_int_timer ( struct sccp_connection conn)
static

◆ conn_start_rel_timer()

static void conn_start_rel_timer ( struct sccp_connection conn)
static

◆ conn_start_rep_rel_timer()

static void conn_start_rep_rel_timer ( struct sccp_connection conn)
static

◆ conn_stop_connect_timer()

static void conn_stop_connect_timer ( struct sccp_connection conn)
static

◆ conn_stop_inact_timers()

static void conn_stop_inact_timers ( struct sccp_connection conn)
static

◆ conn_stop_release_timers()

static void conn_stop_release_timers ( struct sccp_connection conn)
static

◆ conn_tmr_cb()

static void conn_tmr_cb ( void *  data)
static

◆ gen_coerr()

static struct xua_msg* gen_coerr ( uint32_t  route_ctx,
uint32_t  dest_ref,
uint32_t  err_cause 
)
static

◆ gen_coref_without_conn()

◆ gen_relco()

static struct xua_msg* gen_relco ( uint32_t  route_ctx,
uint32_t  dest_ref,
uint32_t  src_ref 
)
static

◆ gen_rlsd()

static struct xua_msg* gen_rlsd ( uint32_t  route_ctx,
uint32_t  dest_ref,
uint32_t  src_ref 
)
static

◆ get_cref_cause_for_ret()

static uint8_t get_cref_cause_for_ret ( uint8_t  ret_cause)
static

References cause_map_cref.

Referenced by sccp_scoc_rx_scrc_rout_fail().

◆ int_tmr_cb()

static void int_tmr_cb ( void *  data)
static

References data, sccp_connection::fi, and SCOC_E_T_INT_EXP.

Referenced by conn_create_id().

◆ osmo_sccp_user_sap_down()

int osmo_sccp_user_sap_down ( struct osmo_sccp_user scu,
struct osmo_prim_hdr *  oph 
)

◆ rel_tmr_cb()

static void rel_tmr_cb ( void *  data)
static

References data, sccp_connection::fi, and SCOC_E_T_REL_EXP.

Referenced by conn_create_id().

◆ rep_rel_tmr_cb()

static void rep_rel_tmr_cb ( void *  data)
static

◆ rx_inact_tmr_cb()

static void rx_inact_tmr_cb ( void *  data)
static

References data, sccp_connection::fi, and SCOC_E_T_IAR_EXP.

Referenced by conn_create_id().

◆ sccp_find_user()

◆ sccp_scoc_flush_connections()

void sccp_scoc_flush_connections ( struct osmo_sccp_instance inst)

◆ sccp_scoc_rx_from_scrc()

◆ sccp_scoc_rx_inval_opc()

◆ sccp_scoc_rx_inval_src_ref()

◆ sccp_scoc_rx_scrc_rout_fail()

void sccp_scoc_rx_scrc_rout_fail ( struct osmo_sccp_instance inst,
struct xua_msg xua,
uint32_t  return_cause 
)

SCOC: Receive SCRC Routing Failure.

Parameters
[in]instSCCP Instance on which we operate
[in]xuaSUA message that was failed to route
[in]return_causeReason (cause) for routing failure

References conn_find_by_id(), sccp_connection::conn_id, sccp_connection::fi, gen_coref_without_conn(), get_cref_cause_for_ret(), sccp_scrc_rx_scoc_conn_msg(), SCOC_E_RCOC_ROUT_FAIL_IND, SUA_IEI_DEST_REF, xua_msg_free(), and xua_msg_get_u32().

Referenced by scrc_node_2(), scrc_node_4(), and scrc_node_6().

◆ sccp_scoc_rx_unass_local_ref()

◆ sccp_scoc_show_connections()

void sccp_scoc_show_connections ( struct vty *  vty,
struct osmo_sccp_instance inst 
)

◆ scoc_fsm_active()

◆ scoc_fsm_conn_pend_in()

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

◆ scoc_fsm_conn_pend_out()

◆ scoc_fsm_disconn_pend()

◆ scoc_fsm_idle()

◆ scoc_fsm_idle_onenter()

static void scoc_fsm_idle_onenter ( struct osmo_fsm_inst *  fi,
uint32_t  old_state 
)
static

References conn_destroy().

◆ scoc_fsm_wait_conn_conf()

◆ scu_gen_encode_and_send()

◆ scu_msgb_alloc()

static struct msgb* scu_msgb_alloc ( void  )
static

References SCU_MSGB_SIZE.

Referenced by scu_prim_alloc().

◆ scu_prim_alloc()

static struct osmo_scu_prim* scu_prim_alloc ( unsigned int  primitive,
enum osmo_prim_operation  operation 
)
static

◆ scu_prim_conn_id()

◆ tx_coerr_from_xua()

◆ tx_inact_tmr_cb()

static void tx_inact_tmr_cb ( void *  data)
static

References data, sccp_connection::fi, and SCOC_E_T_IAS_EXP.

Referenced by conn_create_id().

◆ tx_relco_from_xua()

◆ tx_rlsd_from_xua_twoway()

◆ vty_show_connection()

◆ xua_gen_encode_and_send()

◆ xua_gen_msg_co()

◆ xua_gen_relre()

◆ xua_gen_relre_and_send()

Variable Documentation

◆ cause_map_cref

const uint8_t cause_map_cref[]
static
Initial value:
= {
[SCCP_RETURN_CAUSE_SUBSYSTEM_CONGESTION] =
SCCP_REFUSAL_SUBSYTEM_CONGESTION,
[SCCP_RETURN_CAUSE_SUBSYSTEM_FAILURE] =
SCCP_REFUSAL_SUBSYSTEM_FAILURE,
[SCCP_RETURN_CAUSE_UNEQUIPPED_USER] =
SCCP_REFUSAL_UNEQUIPPED_USER,
[SCCP_RETURN_CAUSE_UNQUALIFIED] =
SCCP_REFUSAL_UNQUALIFIED,
[SCCP_RETURN_CAUSE_SCCP_FAILURE] =
SCCP_REFUSAL_SCCP_FAILURE,
[SCCP_RETURN_CAUSE_HOP_COUNTER_VIOLATION] =
SCCP_REFUSAL_HOP_COUNTER_VIOLATION,
}

Referenced by get_cref_cause_for_ret().

◆ sccp_scoc_fsm

struct osmo_fsm sccp_scoc_fsm
Initial value:
= {
.name = "SCCP-SCOC",
.states = sccp_scoc_states,
.num_states = ARRAY_SIZE(sccp_scoc_states),
.event_names = scoc_event_names,
}
static const struct value_string scoc_event_names[]
Definition: sccp_scoc.c:175
static const struct osmo_fsm_state sccp_scoc_states[]
Definition: sccp_scoc.c:1089

Referenced by conn_create_id().

◆ sccp_scoc_states

const struct osmo_fsm_state sccp_scoc_states[]
static

◆ scoc_event_names

const struct value_string scoc_event_names[]
static
Initial value:
= {
{ SCOC_E_SCU_N_CONN_REQ, "N-CONNECT.req" },
{ SCOC_E_SCU_N_CONN_RESP, "N-CONNECT.resp" },
{ SCOC_E_SCU_N_DISC_REQ, "N-DISCONNECT.req" },
{ SCOC_E_SCU_N_DATA_REQ, "N-DATA.req" },
{ SCOC_E_SCU_N_EXP_DATA_REQ, "N-EXPEDITED_DATA.req" },
{ SCOC_E_RCOC_CONN_IND, "RCOC-CONNECT.ind" },
{ SCOC_E_RCOC_ROUT_FAIL_IND, "RCOC-ROUT_FAIL.ind" },
{ SCOC_E_RCOC_RLSD_IND, "RCOC-RELEASED.ind" },
{ SCOC_E_RCOC_REL_COMPL_IND, "RCOC-RELEASE_COMPLETE.ind" },
{ SCOC_E_RCOC_CREF_IND, "RCOC-CONNECT_REFUSED.ind" },
{ SCOC_E_RCOC_CC_IND, "RCOC-CONNECT_CONFIRM.ind" },
{ SCOC_E_RCOC_DT1_IND, "RCOC-DT1.ind" },
{ SCOC_E_RCOC_DT2_IND, "RCOC-DT2.ind" },
{ SCOC_E_RCOC_IT_IND, "RCOC-IT.ind" },
{ SCOC_E_RCOC_OTHER_NPDU, "RCOC-OTHER_NPDU.ind" },
{ SCOC_E_RCOC_ERROR_IND, "RCOC-ERROR.ind" },
{ SCOC_E_T_IAR_EXP, "T(iar)_expired" },
{ SCOC_E_T_IAS_EXP, "T(ias)_expired" },
{ SCOC_E_CONN_TMR_EXP, "T(conn)_expired" },
{ SCOC_E_T_REL_EXP, "T(rel)_expired" },
{ SCOC_E_T_INT_EXP, "T(int)_expired" },
{ SCOC_E_T_REP_REL_EXP, "T(rep_rel)_expired" },
{ 0, NULL }
}
Definition: sccp_scoc.c:157
Definition: sccp_scoc.c:147
Definition: sccp_scoc.c:162
Definition: sccp_scoc.c:166
Definition: sccp_scoc.c:155
Definition: sccp_scoc.c:158
Definition: sccp_scoc.c:153
Definition: sccp_scoc.c:148
Definition: sccp_scoc.c:171
Definition: sccp_scoc.c:160
Definition: sccp_scoc.c:154
Definition: sccp_scoc.c:165
Definition: sccp_scoc.c:170
Definition: sccp_scoc.c:168
Definition: sccp_scoc.c:146
Definition: sccp_scoc.c:161
Definition: sccp_scoc.c:152
Definition: sccp_scoc.c:159
Definition: sccp_scoc.c:145
Definition: sccp_scoc.c:172
Definition: sccp_scoc.c:156
Definition: sccp_scoc.c:149

◆ scu_scoc_event_map

const struct osmo_prim_event_map scu_scoc_event_map[]
static
Initial value:
= {
{ SCCP_SAP_USER, OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_RESPONSE,
{ SCCP_SAP_USER, OSMO_SCU_PRIM_N_DATA, PRIM_OP_REQUEST,
{ 0, 0, 0, OSMO_NO_EVENT }
}
Definition: sccp_scoc.c:147
Definition: sigtran_sap.h:7
Definition: sccp_sap.h:36
Definition: sccp_scoc.c:148
Definition: sccp_sap.h:34
Definition: sccp_scoc.c:146
Definition: sccp_scoc.c:145
Definition: sccp_sap.h:35
Definition: sccp_sap.h:37
Definition: sccp_scoc.c:149

Referenced by osmo_sccp_user_sap_down().

◆ sua_scoc_event_map

const struct xua_msg_event_map sua_scoc_event_map[]
static
Initial value:
= {
}
Definition: sccp_scoc.c:157
#define SUA_CO_RELCO
Definition: sua.h:74
#define SUA_CO_CODT
Definition: sua.h:77
Definition: sccp_scoc.c:162
Definition: sccp_scoc.c:155
Definition: sccp_scoc.c:158
#define SUA_MSGC_CO
Definition: sua.h:36
#define SUA_CO_COREF
Definition: sua.h:72
#define SUA_CO_RELRE
Definition: sua.h:73
Definition: sccp_scoc.c:160
Definition: sccp_scoc.c:154
#define SUA_CO_COAK
Definition: sua.h:71
#define SUA_CO_COIT
Definition: sua.h:80
#define SUA_CO_CORE
Definition: sua.h:70
Definition: sccp_scoc.c:152
#define SUA_CO_COERR
Definition: sua.h:79
Definition: sccp_scoc.c:156