libosmo-sigtran 2.1.0.93-5cebd.202505162026
Osmocom SIGTRAN library
sccp_internal.h
Go to the documentation of this file.
1#pragma once
2
3#include <inttypes.h>
4
5#include <osmocom/core/fsm.h>
6#include <osmocom/core/prim.h>
7#include <osmocom/core/linuxlist.h>
8#include <osmocom/core/linuxrbtree.h>
9#include <osmocom/core/tdef.h>
13
14#define SCCP_STR "Signalling Connection Control Part\n"
15
16#include "ss7_user.h"
17
18/* Appendix C.4 of Q.714 */
20 /* 0 kept unused on purpose since it's handled specially by osmo_fsm */
30 /* This must remain the last item: */
32};
33
34extern const struct osmo_tdef osmo_sccp_timer_defaults[OSMO_SCCP_TIMERS_LEN];
35
36extern const struct value_string osmo_sccp_timer_names[];
37static inline const char *osmo_sccp_timer_name(enum osmo_sccp_timer val)
38{ return get_value_string(osmo_sccp_timer_names, val); }
39
40/* an instance of the SCCP stack */
42 /* entry in global list of ss7 instances */
43 struct llist_head list;
44 /* rbtree root of 'struct sccp_connection' in this instance */
45 struct rb_root connections;
46 /* list of SCCP users in this instance */
47 struct llist_head users;
48 /* routing context to be used in all outbound messages */
49 uint32_t route_ctx;
50 /* next connection ID to allocate */
51 uint32_t next_id;
53 void *priv;
54
56
57 struct osmo_tdef *tdefs;
58
60};
61#define _LOGPSCI(sci, subsys, level, fmt, args ...) \
62 _LOGSS7((sci)->ss7, subsys, level, "SCCP(rctx=%" PRIu32 ") " fmt, (sci)->route_ctx, ## args)
63#define LOGPSCI(sci, level, fmt, args ...) \
64 _LOGPSCI(sci, DLSCCP, level, fmt, ## args)
65
66
69 struct llist_head list;
73 char *name;
74
76 uint16_t ssn;
77 uint32_t pc;
78
79 /* set if we are a server */
80 struct llist_head links;
81
82 /* user call-back function in case of incoming primitives */
83 osmo_prim_cb prim_cb;
84 void *priv;
85
86 /* Application Server FSM Instance */
87 struct osmo_fsm_inst *as_fi;
88};
89#define _LOGPSCU(scu, subsys, level, fmt, args ...) \
90 _LOGPSCI((scu)->inst, subsys, level, "SCU(%s) " fmt, osmo_sccp_user_name(scu), ## args)
91#define LOGPSCU(scu, level, fmt, args ...) \
92 _LOGPSCU(scu, DLSCCP, level, fmt, ## args)
93
94extern int DSCCP;
95
96struct xua_msg;
97
98struct osmo_sccp_user *
99sccp_user_find(struct osmo_sccp_instance *inst, uint16_t ssn, uint32_t pc);
100
101/* Message from SCOC -> SCRC */
103 struct xua_msg *xua);
104
105/* Message from SCLC -> SCRC */
106int sccp_scrc_rx_sclc_msg(struct osmo_sccp_instance *inst, struct xua_msg *xua);
107
108/* Message from MTP (SUA) -> SCRC */
110 struct xua_msg *xua);
111
112/* Message from SCRC -> SCOC */
114 struct xua_msg *xua);
116 struct xua_msg *xua, uint32_t cause);
117
119
120/* Message from SCRC -> SCLC */
122 struct xua_msg *xua);
124 struct xua_msg *xua, uint32_t cause);
125
126int sccp_user_prim_up(struct osmo_sccp_user *scut, struct osmo_scu_prim *prim);
127
128/* SCU -> SCLC */
129int sccp_sclc_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph);
130int sccp_sclc_user_sap_down_nofree(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph);
131
132struct msgb *sccp_msgb_alloc(const char *name);
133
134extern struct osmo_fsm sccp_scoc_fsm;
135
136void sccp_scoc_show_connections(struct vty *vty, struct osmo_sccp_instance *inst);
137
138void osmo_sccp_vty_write_cs7_node(struct vty *vty, const char *indent, struct osmo_sccp_instance *inst);
139
140/* Local Broadcast (LBCS) */
142 const struct osmo_scu_pcstate_param *pcstate);
144 const struct osmo_scu_state_param *state);
145
146/* SCCP Management (SCMG) */
147void sccp_scmg_rx_ssn_allowed(struct osmo_sccp_instance *inst, uint32_t dpc, uint32_t ssn, uint32_t smi);
148void sccp_scmg_rx_ssn_prohibited(struct osmo_sccp_instance *inst, uint32_t dpc, uint32_t ssn, uint32_t smi);
149void sccp_scmg_rx_mtp_pause(struct osmo_sccp_instance *inst, uint32_t dpc);
150void sccp_scmg_rx_mtp_resume(struct osmo_sccp_instance *inst, uint32_t dpc);
151void sccp_scmg_rx_mtp_status(struct osmo_sccp_instance *inst, uint32_t dpc, enum mtp_unavail_cause cause);
152int sccp_scmg_init(struct osmo_sccp_instance *inst);
uint32_t dpc
Definition: m3ua.h:1
mtp_unavail_cause
Definition: mtp.h:28
void osmo_sccp_vty_write_cs7_node(struct vty *vty, const char *indent, struct osmo_sccp_instance *inst)
Definition: sccp_vty.c:254
void sccp_sclc_rx_scrc_rout_fail(struct osmo_sccp_instance *inst, struct xua_msg *xua, uint32_t cause)
SCRC -> SCLC (Routing Failure.
Definition: sccp_sclc.c:392
void sccp_scmg_rx_ssn_allowed(struct osmo_sccp_instance *inst, uint32_t dpc, uint32_t ssn, uint32_t smi)
Definition: sccp_scmg.c:41
int sccp_scrc_rx_scoc_conn_msg(struct osmo_sccp_instance *inst, struct xua_msg *xua)
Definition: sccp_scrc.c:460
struct msgb * sccp_msgb_alloc(const char *name)
Definition: sua.c:67
osmo_sccp_timer
Definition: sccp_internal.h:19
@ OSMO_SCCP_TIMER_REPEAT_REL
Definition: sccp_internal.h:25
@ OSMO_SCCP_TIMER_INT
Definition: sccp_internal.h:26
@ OSMO_SCCP_TIMER_GUARD
Definition: sccp_internal.h:27
@ OSMO_SCCP_TIMER_REASSEMBLY
Definition: sccp_internal.h:29
@ OSMO_SCCP_TIMERS_LEN
Definition: sccp_internal.h:31
@ OSMO_SCCP_TIMER_REL
Definition: sccp_internal.h:24
@ OSMO_SCCP_TIMER_IAS
Definition: sccp_internal.h:22
@ OSMO_SCCP_TIMER_CONN_EST
Definition: sccp_internal.h:21
@ OSMO_SCCP_TIMER_RESET
Definition: sccp_internal.h:28
@ OSMO_SCCP_TIMER_IAR
Definition: sccp_internal.h:23
int scrc_rx_mtp_xfer_ind_xua(struct osmo_sccp_instance *inst, struct xua_msg *xua)
Definition: sccp_scrc.c:548
void sccp_scmg_rx_mtp_status(struct osmo_sccp_instance *inst, uint32_t dpc, enum mtp_unavail_cause cause)
Definition: sccp_scmg.c:126
int sccp_sclc_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph)
Main entrance function for primitives from SCCP User.
Definition: sccp_sclc.c:174
struct osmo_sccp_user * sccp_user_find(struct osmo_sccp_instance *inst, uint16_t ssn, uint32_t pc)
Find a SCCP User registered for given PC+SSN or SSN only First search all users with a valid PC for a...
Definition: sccp_user.c:57
int sccp_sclc_user_sap_down_nofree(struct osmo_sccp_user *scu, struct osmo_prim_hdr *oph)
Main entrance function for primitives from SCCP User.
Definition: sccp_sclc.c:151
void sccp_scmg_rx_ssn_prohibited(struct osmo_sccp_instance *inst, uint32_t dpc, uint32_t ssn, uint32_t smi)
Definition: sccp_scmg.c:59
void sccp_scmg_rx_mtp_pause(struct osmo_sccp_instance *inst, uint32_t dpc)
brief MTP -> SNM (MTP-PAUSE.ind) - inability to providing MTP service Q.714 5.2.2
Definition: sccp_scmg.c:80
int DSCCP
int sccp_scmg_init(struct osmo_sccp_instance *inst)
Definition: sccp_scmg.c:313
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)
Definition: sccp_scoc.c:1847
int sccp_sclc_rx_from_scrc(struct osmo_sccp_instance *inst, struct xua_msg *xua)
SCRC -> SCLC (connectionless message)
Definition: sccp_sclc.c:315
int sccp_scrc_rx_sclc_msg(struct osmo_sccp_instance *inst, struct xua_msg *xua)
Definition: sccp_scrc.c:488
void sccp_scoc_rx_scrc_rout_fail(struct osmo_sccp_instance *inst, struct xua_msg *xua, uint32_t cause)
SCOC: Receive SCRC Routing Failure.
Definition: sccp_scoc.c:1600
void sccp_scmg_rx_mtp_resume(struct osmo_sccp_instance *inst, uint32_t dpc)
brief MTP -> SNM (MTP-RESUME.ind) - ability of providing the MTP service Q.714 5.2....
Definition: sccp_scmg.c:103
void sccp_scoc_show_connections(struct vty *vty, struct osmo_sccp_instance *inst)
Definition: sccp_scoc.c:2048
void sccp_lbcs_local_bcast_state(struct osmo_sccp_instance *inst, const struct osmo_scu_state_param *state)
Definition: sccp_lbcs.c:55
void sccp_lbcs_local_bcast_pcstate(struct osmo_sccp_instance *inst, const struct osmo_scu_pcstate_param *pcstate)
Definition: sccp_lbcs.c:39
void sccp_scoc_flush_connections(struct osmo_sccp_instance *inst)
Definition: sccp_scoc.c:2011
int sccp_user_prim_up(struct osmo_sccp_user *scut, struct osmo_scu_prim *prim)
Send a SCCP User SAP Primitive up to the User.
Definition: sccp_user.c:195
struct osmo_fsm sccp_scoc_fsm
Definition: sccp_scoc.c:1513
static const char * osmo_sccp_timer_name(enum osmo_sccp_timer val)
Definition: sccp_internal.h:37
const struct value_string osmo_sccp_timer_names[]
Definition: sccp_scoc.c:275
const struct osmo_tdef osmo_sccp_timer_defaults[OSMO_SCCP_TIMERS_LEN]
Definition: sccp_scoc.c:251
uint8_t smi
Definition: sccp_scmg.h:3
Definition: sccp_internal.h:41
uint32_t next_id
Definition: sccp_internal.h:51
struct osmo_ss7_user * ss7_user
Definition: sccp_internal.h:55
uint32_t route_ctx
Definition: sccp_internal.h:49
struct osmo_tdef * tdefs
Definition: sccp_internal.h:57
struct osmo_ss7_instance * ss7
Definition: sccp_internal.h:52
struct llist_head list
Definition: sccp_internal.h:43
void * priv
Definition: sccp_internal.h:53
uint32_t max_optional_data
Definition: sccp_internal.h:59
struct llist_head users
Definition: sccp_internal.h:47
struct rb_root connections
Definition: sccp_internal.h:45
Definition: sccp_internal.h:67
struct osmo_fsm_inst * as_fi
Definition: sccp_internal.h:87
struct osmo_sccp_instance * inst
pointer back to SCCP instance
Definition: sccp_internal.h:71
uint32_t pc
Definition: sccp_internal.h:77
struct llist_head links
Definition: sccp_internal.h:80
void * priv
Definition: sccp_internal.h:84
uint16_t ssn
SSN and/or point code to which we are bound.
Definition: sccp_internal.h:76
char * name
human-readable name of this user
Definition: sccp_internal.h:73
osmo_prim_cb prim_cb
Definition: sccp_internal.h:83
struct llist_head list
entry in list of sccp users of osmo_sccp_instance
Definition: sccp_internal.h:69
Definition: sccp_sap.h:273
Definition: sccp_sap.h:280
Definition: sccp_sap.h:265
Definition: ss7_instance.h:21
Definition: ss7_user.h:13
Definition: xua_msg.h:31