libosmo-sigtran 2.2.1.64-e866 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
17 struct osmo_ss7_user;
18 struct osmo_ss7_route_table;
19 struct osmo_ss7_route_label;
20 struct 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 /* This must remain the last item: */
26 SS7_INST_XUA_TIMERS_LEN
27};
28 extern const struct value_string ss7_instance_xua_timer_names[];
29 extern const struct osmo_tdef ss7_instance_xua_timer_defaults[SS7_INST_XUA_TIMERS_LEN];
30/* According to SUA RFC3868 Section 8, M3UA RFC4666 Section 4.3.4.1 */
31#define SS7_INST_XUA_DEFAULT_T8_MSEC 1000
32
33 enum ss7_instance_ctr {
34 SS7_INST_CTR_PKT_RX_TOTAL,
35 SS7_INST_CTR_PKT_RX_UNKNOWN,
36 SS7_INST_CTR_PKT_RX_NI_MISMATCH,
37 SS7_INST_CTR_PKT_TX_TOTAL,
38};
39
40 struct osmo_ss7_pc_fmt {
41 char delimiter;
42 uint8_t component_len[3];
43};
44
45 struct osmo_ss7_instance {
47 struct llist_head list;
49 struct llist_head linksets;
51 struct llist_head as_list;
53 struct llist_head asp_list;
55 struct llist_head rtable_list;
57 struct llist_head xua_servers;
58 /* array for faster lookup of user (indexed by service
59 * indicator) */
60 struct osmo_ss7_user *user[16];
61
62 struct osmo_ss7_route_table *rtable_system;
63
64 struct osmo_sccp_instance *sccp;
65
66 struct rate_ctr_group *ctrg;
67
68 /* Q.704 Figure 44 and section 13.2: List to store remote PCs with T8 started */
69 struct {
70 /* list of struct t8_inaccessible_sp_entry, sorted by entry->ts_started */
71 struct llist_head list;
72 struct osmo_timer_list timer;
73 } t8_inaccessible_sp;
74
75 struct {
76 uint32_t id;
77 char *name;
78 char *description;
79 uint32_t primary_pc;
80 /* capability PCs */
81 enum mtp_network_indicator network_indicator;
82 struct osmo_ss7_pc_fmt pc_fmt;
83 bool permit_dyn_rkm_alloc;
84 struct llist_head sccp_address_book;
85 uint32_t secondary_pc;
86 /* How many bits from ITU OPC/DPC field (starting from least-significant-bit)
87 * to skip for routing decisions (always takes 6 bits).
88 * range 0-8, defaults to 0, which means take least significant 6 bits. */
89 uint8_t opc_shift;
90 uint8_t dpc_shift;
91 /* How many bits from ITU SLS field (starting from least-significant-bit)
92 * to skip for routing decisions.
93 * range 0-3, defaults to 0, which means take all 4 bits. */
94 uint8_t sls_shift;
95
96 /* T_defs defined at instance level: */
97 struct osmo_tdef *T_defs_xua;
98 } cfg;
99};
100
101 struct osmo_ss7_instance *
102 ss7_instance_alloc(void *ctx, uint32_t id);
103
104uint32_t ss7_find_free_l_rk_id(struct osmo_ss7_instance *inst);
105 struct osmo_ss7_route *
106 ss7_instance_lookup_route(struct osmo_ss7_instance *inst, const struct osmo_ss7_route_label *rtlabel);
107
108#define _LOGSS7(inst, subsys, level, fmt, args ...) \
109 LOGP(subsys, level, "%u: " fmt, inst ? (inst)->cfg.id : 0, ## args)
110#define LOGSS7(inst, level, fmt, args ...) \
111 _LOGSS7(inst, DLSS7, level, fmt, ## args)
112
113
114/***********************************************************************
115 * ITUQ.704 13.2.2: Timer T8 concerning one SP
116 ***********************************************************************/
117 struct t8_inaccessible_sp_entry {
118 struct llist_head entry; /* item in (struct osmo_ss7_instance)->t8_inaccessible_sp.list */
119 uint32_t dpc; /* SP inaccessible */
120 struct timespec ts_started; /* Timestamp T8 was started for this SP */
121};
122 bool ss7_instance_t8_inaccessible_sp_running(const struct osmo_ss7_instance *inst, uint32_t dpc);
123 void 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:263
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:864
ss7_find_free_l_rk_id
uint32_t ss7_find_free_l_rk_id(struct osmo_ss7_instance *inst)
Definition: ss7_instance.c:250
ss7_instance_xua_timer
ss7_instance_xua_timer
Definition: ss7_instance.h:22
SS7_INST_XUA_TIMERS_LEN
@ SS7_INST_XUA_TIMERS_LEN
Definition: ss7_instance.h:26
SS7_INST_XUA_T8
@ SS7_INST_XUA_T8
Definition: ss7_instance.h:24
ss7_instance_ctr
ss7_instance_ctr
Definition: ss7_instance.h:33
SS7_INST_CTR_PKT_RX_NI_MISMATCH
@ SS7_INST_CTR_PKT_RX_NI_MISMATCH
Definition: ss7_instance.h:36
SS7_INST_CTR_PKT_RX_TOTAL
@ SS7_INST_CTR_PKT_RX_TOTAL
Definition: ss7_instance.h:34
SS7_INST_CTR_PKT_RX_UNKNOWN
@ SS7_INST_CTR_PKT_RX_UNKNOWN
Definition: ss7_instance.h:35
SS7_INST_CTR_PKT_TX_TOTAL
@ SS7_INST_CTR_PKT_TX_TOTAL
Definition: ss7_instance.h:37
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:874
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:86
ss7_instance_xua_timer_names
const struct value_string ss7_instance_xua_timer_names[]
Definition: ss7_instance.c:74
osmo_sccp_instance
Definition: sccp_instance.h:47
osmo_ss7_instance
Definition: ss7_instance.h:45
osmo_ss7_instance::sccp
struct osmo_sccp_instance * sccp
Definition: ss7_instance.h:64
osmo_ss7_instance::secondary_pc
uint32_t secondary_pc
Definition: ss7_instance.h:85
osmo_ss7_instance::rtable_system
struct osmo_ss7_route_table * rtable_system
Definition: ss7_instance.h:62
osmo_ss7_instance::ctrg
struct rate_ctr_group * ctrg
Definition: ss7_instance.h:66
osmo_ss7_instance::user
struct osmo_ss7_user * user[16]
Definition: ss7_instance.h:60
osmo_ss7_instance::dpc_shift
uint8_t dpc_shift
Definition: ss7_instance.h:90
osmo_ss7_instance::linksets
struct llist_head linksets
list of osmo_ss7_linkset
Definition: ss7_instance.h:49
osmo_ss7_instance::name
char * name
Definition: ss7_instance.h:77
osmo_ss7_instance::primary_pc
uint32_t primary_pc
Definition: ss7_instance.h:79
osmo_ss7_instance::cfg
struct osmo_ss7_instance::@32 cfg
osmo_ss7_instance::T_defs_xua
struct osmo_tdef * T_defs_xua
Definition: ss7_instance.h:97
osmo_ss7_instance::pc_fmt
struct osmo_ss7_pc_fmt pc_fmt
Definition: ss7_instance.h:82
osmo_ss7_instance::as_list
struct llist_head as_list
list of osmo_ss7_as
Definition: ss7_instance.h:51
osmo_ss7_instance::rtable_list
struct llist_head rtable_list
list of osmo_ss7_route_table
Definition: ss7_instance.h:55
osmo_ss7_instance::description
char * description
Definition: ss7_instance.h:78
osmo_ss7_instance::id
uint32_t id
Definition: ss7_instance.h:76
osmo_ss7_instance::sls_shift
uint8_t sls_shift
Definition: ss7_instance.h:94
osmo_ss7_instance::asp_list
struct llist_head asp_list
list of osmo_ss7_asp
Definition: ss7_instance.h:53
osmo_ss7_instance::permit_dyn_rkm_alloc
bool permit_dyn_rkm_alloc
Definition: ss7_instance.h:83
osmo_ss7_instance::network_indicator
enum mtp_network_indicator network_indicator
Definition: ss7_instance.h:81
osmo_ss7_instance::sccp_address_book
struct llist_head sccp_address_book
Definition: ss7_instance.h:84
osmo_ss7_instance::opc_shift
uint8_t opc_shift
Definition: ss7_instance.h:89
osmo_ss7_instance::t8_inaccessible_sp
struct osmo_ss7_instance::@31 t8_inaccessible_sp
osmo_ss7_instance::list
struct llist_head list
member of global list of instances
Definition: ss7_instance.h:47
osmo_ss7_instance::timer
struct osmo_timer_list timer
Definition: ss7_instance.h:72
osmo_ss7_instance::xua_servers
struct llist_head xua_servers
list of osmo_xua_servers
Definition: ss7_instance.h:57
osmo_ss7_pc_fmt
Definition: ss7_instance.h:40
osmo_ss7_pc_fmt::delimiter
char delimiter
Definition: ss7_instance.h:41
osmo_ss7_pc_fmt::component_len
uint8_t component_len[3]
Definition: ss7_instance.h:42
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:117
t8_inaccessible_sp_entry::entry
struct llist_head entry
Definition: ss7_instance.h:118
t8_inaccessible_sp_entry::ts_started
struct timespec ts_started
Definition: ss7_instance.h:120
t8_inaccessible_sp_entry::dpc
uint32_t dpc
Definition: ss7_instance.h:119