libosmo-sigtran: src/ss7_instance.h Source File

libosmo-sigtran 2.2.1.99-1c6a Osmocom SIGTRAN library

ss7_instance.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <stdbool.h>
5#include <osmocom/core/linuxlist.h>
6#include <osmocom/core/tdef.h>
7#include <osmocom/core/timer.h>
8#include <osmocom/core/timer_compat.h>
9#include <osmocom/core/rate_ctr.h>
10
11#include <osmocom/sigtran/protocol/mtp.h>
12
13/***********************************************************************
14 * SS7 Instances
15 ***********************************************************************/
16
17struct osmo_ss7_user;
18struct osmo_ss7_route_table;
19struct osmo_ss7_route_label;
20struct osmo_sccp_instance;
21
22 enum ss7_instance_xua_timer {
23 /* 0 kept unused on purpose since it's handled specially by osmo_fsm */
24 SS7_INST_XUA_T8 = 1, /* Q.704 T8 */
25 SS7_INST_XUA_T10, /* Q.704 T10 */
26 /* This must remain the last item: */
27 SS7_INST_XUA_TIMERS_LEN
28};
29extern const struct value_string ss7_instance_xua_timer_names[];
30extern const struct osmo_tdef ss7_instance_xua_timer_defaults[SS7_INST_XUA_TIMERS_LEN];
31/* According to SUA RFC3868 Section 8, M3UA RFC4666 Section 4.3.4.1 */
32#define SS7_INST_XUA_DEFAULT_T8_MSEC 1000
33#define SS7_INST_XUA_DEFAULT_T10_SEC 45
34
35 enum ss7_instance_ctr {
36 SS7_INST_CTR_PKT_RX_TOTAL,
37 SS7_INST_CTR_PKT_RX_UNKNOWN,
38 SS7_INST_CTR_PKT_RX_NI_MISMATCH,
39 SS7_INST_CTR_PKT_TX_TOTAL,
40};
41
42 struct osmo_ss7_pc_fmt {
43 char delimiter;
44 uint8_t component_len[3];
45};
46
47 struct osmo_ss7_instance {
49 struct llist_head list;
51 struct llist_head linksets;
53 struct llist_head as_list;
55 struct llist_head asp_list;
57 struct llist_head rtable_list;
59 struct llist_head xua_servers;
60 /* array for faster lookup of user (indexed by service
61 * indicator) */
62 struct osmo_ss7_user *user[16];
63
64 struct osmo_ss7_route_table *rtable_system;
65
66 struct osmo_sccp_instance *sccp;
67
68 struct rate_ctr_group *ctrg;
69
70 /* Q.704 Figure 44 and section 13.2: List to store remote PCs with T8 started */
71 struct {
72 /* list of struct t8_inaccessible_sp_entry, sorted by entry->ts_started */
73 struct llist_head list;
74 struct osmo_timer_list timer;
75 } t8_inaccessible_sp;
76
77 struct {
78 uint32_t id;
79 char *name;
80 char *description;
81 uint32_t primary_pc;
82 /* capability PCs */
83 enum mtp_network_indicator network_indicator;
84 struct osmo_ss7_pc_fmt pc_fmt;
85 bool permit_dyn_rkm_alloc;
86 struct llist_head sccp_address_book;
87 uint32_t secondary_pc;
88 /* How many bits from ITU OPC/DPC field (starting from least-significant-bit)
89 * to skip for routing decisions (always takes 6 bits).
90 * range 0-8, defaults to 0, which means take least significant 6 bits. */
91 uint8_t opc_shift;
92 uint8_t dpc_shift;
93 /* How many bits from ITU SLS field (starting from least-significant-bit)
94 * to skip for routing decisions.
95 * range 0-3, defaults to 0, which means take all 4 bits. */
96 uint8_t sls_shift;
97
98 /* T_defs defined at instance level: */
99 struct osmo_tdef *T_defs_xua;
100 } cfg;
101};
102
103struct osmo_ss7_instance *
104 ss7_instance_alloc(void *ctx, uint32_t id);
105
106uint32_t ss7_find_free_l_rk_id(struct osmo_ss7_instance *inst);
107struct osmo_ss7_route *
108 ss7_instance_lookup_route(struct osmo_ss7_instance *inst, const struct osmo_ss7_route_label *rtlabel);
109
110#define _LOGSS7(inst, subsys, level, fmt, args ...) \
111 LOGP(subsys, level, "%u: " fmt, inst ? (inst)->cfg.id : 0, ## args)
112#define LOGSS7(inst, level, fmt, args ...) \
113 _LOGSS7(inst, DLSS7, level, fmt, ## args)
114
115
116/***********************************************************************
117 * ITUQ.704 13.2.2: Timer T8 concerning one SP
118 ***********************************************************************/
119 struct t8_inaccessible_sp_entry {
120 struct llist_head entry; /* item in (struct osmo_ss7_instance)->t8_inaccessible_sp.list */
121 uint32_t dpc; /* SP inaccessible */
122 struct timespec ts_started; /* Timestamp T8 was started for this SP */
123};
124bool ss7_instance_t8_inaccessible_sp_running(const struct osmo_ss7_instance *inst, uint32_t dpc);
125void ss7_instance_t8_inaccessible_sp_start(struct osmo_ss7_instance *inst, uint32_t dpc);
dpc
uint32_t dpc
Definition: m3ua.h:1
mtp.h
mtp_network_indicator
mtp_network_indicator
Definition: mtp.h:39
ss7_instance_lookup_route
struct osmo_ss7_route * ss7_instance_lookup_route(struct osmo_ss7_instance *inst, const struct osmo_ss7_route_label *rtlabel)
Find a SS7 route for given destination point code in given SS7.
Definition: ss7_instance.c:283
ss7_instance_t8_inaccessible_sp_running
bool ss7_instance_t8_inaccessible_sp_running(const struct osmo_ss7_instance *inst, uint32_t dpc)
Definition: ss7_instance.c:884
ss7_find_free_l_rk_id
uint32_t ss7_find_free_l_rk_id(struct osmo_ss7_instance *inst)
Definition: ss7_instance.c:266
ss7_instance_xua_timer
ss7_instance_xua_timer
Definition: ss7_instance.h:22
SS7_INST_XUA_T10
@ SS7_INST_XUA_T10
Definition: ss7_instance.h:25
SS7_INST_XUA_TIMERS_LEN
@ SS7_INST_XUA_TIMERS_LEN
Definition: ss7_instance.h:27
SS7_INST_XUA_T8
@ SS7_INST_XUA_T8
Definition: ss7_instance.h:24
ss7_instance_ctr
ss7_instance_ctr
Definition: ss7_instance.h:35
SS7_INST_CTR_PKT_RX_NI_MISMATCH
@ SS7_INST_CTR_PKT_RX_NI_MISMATCH
Definition: ss7_instance.h:38
SS7_INST_CTR_PKT_RX_TOTAL
@ SS7_INST_CTR_PKT_RX_TOTAL
Definition: ss7_instance.h:36
SS7_INST_CTR_PKT_RX_UNKNOWN
@ SS7_INST_CTR_PKT_RX_UNKNOWN
Definition: ss7_instance.h:37
SS7_INST_CTR_PKT_TX_TOTAL
@ SS7_INST_CTR_PKT_TX_TOTAL
Definition: ss7_instance.h:39
ss7_instance_t8_inaccessible_sp_start
void ss7_instance_t8_inaccessible_sp_start(struct osmo_ss7_instance *inst, uint32_t dpc)
Definition: ss7_instance.c:894
ss7_instance_xua_timer_defaults
const struct osmo_tdef ss7_instance_xua_timer_defaults[SS7_INST_XUA_TIMERS_LEN]
Definition: ss7_instance.c:66
ss7_instance_alloc
struct osmo_ss7_instance * ss7_instance_alloc(void *ctx, uint32_t id)
Definition: ss7_instance.c:90
ss7_instance_xua_timer_names
const struct value_string ss7_instance_xua_timer_names[]
Definition: ss7_instance.c:77
osmo_sccp_instance
Definition: sccp_instance.h:47
osmo_ss7_instance
Definition: ss7_instance.h:47
osmo_ss7_instance::sccp
struct osmo_sccp_instance * sccp
Definition: ss7_instance.h:66
osmo_ss7_instance::secondary_pc
uint32_t secondary_pc
Definition: ss7_instance.h:87
osmo_ss7_instance::rtable_system
struct osmo_ss7_route_table * rtable_system
Definition: ss7_instance.h:64
osmo_ss7_instance::cfg
struct osmo_ss7_instance::@33 cfg
osmo_ss7_instance::ctrg
struct rate_ctr_group * ctrg
Definition: ss7_instance.h:68
osmo_ss7_instance::user
struct osmo_ss7_user * user[16]
Definition: ss7_instance.h:62
osmo_ss7_instance::t8_inaccessible_sp
struct osmo_ss7_instance::@32 t8_inaccessible_sp
osmo_ss7_instance::dpc_shift
uint8_t dpc_shift
Definition: ss7_instance.h:92
osmo_ss7_instance::linksets
struct llist_head linksets
list of osmo_ss7_linkset
Definition: ss7_instance.h:51
osmo_ss7_instance::name
char * name
Definition: ss7_instance.h:79
osmo_ss7_instance::primary_pc
uint32_t primary_pc
Definition: ss7_instance.h:81
osmo_ss7_instance::T_defs_xua
struct osmo_tdef * T_defs_xua
Definition: ss7_instance.h:99
osmo_ss7_instance::pc_fmt
struct osmo_ss7_pc_fmt pc_fmt
Definition: ss7_instance.h:84
osmo_ss7_instance::as_list
struct llist_head as_list
list of osmo_ss7_as
Definition: ss7_instance.h:53
osmo_ss7_instance::rtable_list
struct llist_head rtable_list
list of osmo_ss7_route_table
Definition: ss7_instance.h:57
osmo_ss7_instance::description
char * description
Definition: ss7_instance.h:80
osmo_ss7_instance::id
uint32_t id
Definition: ss7_instance.h:78
osmo_ss7_instance::sls_shift
uint8_t sls_shift
Definition: ss7_instance.h:96
osmo_ss7_instance::asp_list
struct llist_head asp_list
list of osmo_ss7_asp
Definition: ss7_instance.h:55
osmo_ss7_instance::permit_dyn_rkm_alloc
bool permit_dyn_rkm_alloc
Definition: ss7_instance.h:85
osmo_ss7_instance::network_indicator
enum mtp_network_indicator network_indicator
Definition: ss7_instance.h:83
osmo_ss7_instance::sccp_address_book
struct llist_head sccp_address_book
Definition: ss7_instance.h:86
osmo_ss7_instance::opc_shift
uint8_t opc_shift
Definition: ss7_instance.h:91
osmo_ss7_instance::list
struct llist_head list
member of global list of instances
Definition: ss7_instance.h:49
osmo_ss7_instance::timer
struct osmo_timer_list timer
Definition: ss7_instance.h:74
osmo_ss7_instance::xua_servers
struct llist_head xua_servers
list of osmo_xua_servers
Definition: ss7_instance.h:59
osmo_ss7_pc_fmt
Definition: ss7_instance.h:42
osmo_ss7_pc_fmt::delimiter
char delimiter
Definition: ss7_instance.h:43
osmo_ss7_pc_fmt::component_len
uint8_t component_len[3]
Definition: ss7_instance.h:44
osmo_ss7_route_label
Definition: ss7_route_table.h:14
osmo_ss7_route_table
Definition: ss7_route_table.h:21
osmo_ss7_route
Definition: ss7_route.h:28
osmo_ss7_user
Definition: ss7_user.h:15
t8_inaccessible_sp_entry
Definition: ss7_instance.h:119
t8_inaccessible_sp_entry::entry
struct llist_head entry
Definition: ss7_instance.h:120
t8_inaccessible_sp_entry::ts_started
struct timespec ts_started
Definition: ss7_instance.h:122
t8_inaccessible_sp_entry::dpc
uint32_t dpc
Definition: ss7_instance.h:121