libosmo-sigtran  2.3.0
Osmocom SIGTRAN library
ss7_as.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "config.h"
4 
5 #include <stdint.h>
6 #include <osmocom/core/linuxlist.h>
7 #include <osmocom/core/fsm.h>
8 #include <osmocom/core/hashtable.h>
9 #include <osmocom/core/msgb.h>
10 #include <osmocom/core/tdef.h>
11 #include <osmocom/netif/stream.h>
12 
14 
15 #include "ss7_internal.h"
16 #include "xua_msg.h"
17 
18 /***********************************************************************
19  * SS7 Application Server
20  ***********************************************************************/
21 
22 struct osmo_ss7_instance;
23 struct osmo_ss7_asp;
25 struct xua_msg;
26 
28  OSMO_SS7_PATCH_NONE, /* no patching of SCCP */
29  OSMO_SS7_PATCH_BOTH, /* patch both OPC and DPC into SCCP addresses */
30 };
31 
32 enum ss7_as_ctr {
68 #ifdef WITH_TCAP_LOADSHARING
69  SS7_AS_CTR_RX_TCAP_DECODED,
70  SS7_AS_CTR_RX_TCAP_FAILED,
71  SS7_AS_CTR_TCAP_ASP_SELECTED,
72  SS7_AS_CTR_TCAP_ASP_FALLBACK,
73  SS7_AS_CTR_TCAP_ASP_FAILED,
74  SS7_AS_CTR_TCAP_ASP_MISS,
75 #endif /* WITH_TCAP_LOADSHARING */
76 };
77 
78 /* when receiving an TCAP Continue/End/Abort which can't be associated to a node (either by sesssion tracking or by DTID over TCAP ranges,
79  * how to handle those */
84 };
85 extern struct value_string osmo_ss7_as_tcap_unroutable_vals[];
86 
87 #define NUM_AS_EXT_SLS 128
88 typedef uint8_t as_ext_sls_t; /* range: 0-127, 7 bit */
90  /* ITU Q.704 4.2.1: "normal signallink link" */
92  /* ITU Q.704 4.2.1: "alternative signallink link" */
94 };
95 
97  /* Entry in (struct osmo_ss7_as*)->assoc_asp_list */
98  struct llist_head as_entry;
99  /* Entry in (struct osmo_ss7_asp*)->assoc_as_list */
100  struct llist_head asp_entry;
101  struct osmo_ss7_as *as; /* backpointer */
102  struct osmo_ss7_asp *asp; /* backpointer */
103 };
104 
105 struct osmo_ss7_as {
107  struct llist_head list;
109 
111  struct osmo_fsm_inst *fi;
112 
115 
118 
120  struct rate_ctr_group *ctrg;
121 
122  /* ASP loadshare: */
124 
125 #ifdef WITH_TCAP_LOADSHARING
126  struct {
127  /* optimisation: true if tid_ranges contains PCs (not only wildcards) */
128  bool contains_pc;
129  /* optimisation: true if tid_ranges contains SSNs (not only wildcards (0)) */
130  bool contains_ssn;
131  DECLARE_HASHTABLE(tid_ranges, 10);
132  /* gargabe collector timer */
133  struct osmo_timer_list gc_timer;
134  /* TODO: the hash tables size might not be optimal */
135  DECLARE_HASHTABLE(trans_track_own, 10);
136  DECLARE_HASHTABLE(trans_track_peer, 10);
138  } tcap;
139 #endif /* WITH_TCAP_LOADSHARING */
140 
141  /* used for load-sharing traffic mode (round robin implementation) */
144 
145  struct llist_head assoc_asp_list; /* list of struct ss7_as_asp_assoc */
146  unsigned int num_assoc_asps; /* amount of ss7_as_asp_assoc/ss7_asp in assoc_asp_list */
147 
148  struct {
149  char *name;
150  char *description;
154  /* traffic mode was configured by VTY / config file */
156  /* traffic mode was configured by RKM (routing key management) or first ASPAC */
159  uint8_t qos_class;
160  struct {
163  uint32_t opc;
164  uint32_t dpc;
167 
168  struct {
169  /* How many bits from ITU SLS field (starting from least-significant-bit)
170  * to skip for routing decisions.
171  * range 0-3, defaults to 0, which means take all 4 bits. */
172  uint8_t sls_shift;
173  /* Whether to generate a extended-SLS with OPC information, see opc_shift below. */
174  bool opc_sls;
175  /* How many bits from ITU OPC field (starting from least-significant-bit)
176  * to skip for routing decisions (always takes 12 bits).
177  * range 0-2, defaults to 0, which means take least significant 12 bits. */
178  uint8_t opc_shift;
179 #ifdef WITH_TCAP_LOADSHARING
180  /* Should we do load-sharing based on tcap ids? */
181  struct {
182  bool enabled;
183  unsigned int timeout_s;
184  enum ss7_as_tcap_unroutable unroutable_tcap_msg;
185  /* when unroutable_tcap_msg == SS7_AS_TCPA_UNROUTABLE_ROUTE_FALLBACK, replace DPC with this */
186  uint32_t unroutable_tcap_fallback_dpc;
187  } tcap;
188 #endif /* WITH_TCAP_LOADSHARING */
190  } cfg;
191 };
192 struct osmo_ss7_as *ss7_as_alloc(struct osmo_ss7_instance *inst, const char *name,
194 struct osmo_ss7_asp *ss7_as_select_asp(struct osmo_ss7_as *as, const struct xua_msg *xua);
195 
196 int ss7_as_add_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp);
197 int ss7_as_del_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp);
198 int ss7_as_get_local_role(const struct osmo_ss7_as *as);
199 struct osmo_ss7_asp *ss7_as_find_asp_by_remote_asp_id(const struct osmo_ss7_as *as, uint32_t asp_id,
200  const struct osmo_ss7_asp *excl_asp);
202 
203 void ss7_as_del_asp_update_llist_round_robin(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp, struct ss7_as_asp_assoc **state);
204 #define ss7_as_asp_assoc_llist_round_robin(as, state) \
205  ss7_llist_round_robin(&(as)->assoc_asp_list, (void **)state, struct ss7_as_asp_assoc, as_entry)
206 
207 #define LOGPAS(as, subsys, level, fmt, args ...) \
208  _LOGSS7((as)->inst, subsys, level, "AS(%s) " fmt, (as)->cfg.name, ## args)
osmo_ss7_asp_protocol
Definition: osmo_ss7.h:157
osmo_ss7_as_traffic_mode
Definition: osmo_ss7.h:183
osmo_ss7_as_patch_sccp_mode
Definition: ss7_as.h:27
@ OSMO_SS7_PATCH_BOTH
Definition: ss7_as.h:29
@ OSMO_SS7_PATCH_NONE
Definition: ss7_as.h:28
void ss7_as_loadshare_binding_table_reset(struct osmo_ss7_as *as)
Definition: ss7_as.c:505
struct value_string osmo_ss7_as_tcap_unroutable_vals[]
Definition: ss7_as.c:96
uint8_t as_ext_sls_t
Definition: ss7_as.h:88
struct osmo_ss7_asp * ss7_as_select_asp(struct osmo_ss7_as *as, const struct xua_msg *xua)
Select an AS to transmit a message, according to AS configuration and ASP availability.
Definition: ss7_as.c:641
int ss7_as_get_local_role(const struct osmo_ss7_as *as)
Definition: ss7_as.c:415
#define NUM_AS_EXT_SLS
Definition: ss7_as.h:87
int ss7_as_add_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp)
Add given ASP to given AS.
Definition: ss7_as.c:215
ss7_as_ctr
Definition: ss7_as.h:32
@ SS7_AS_CTR_TX_MSU_SLS_8
Definition: ss7_as.h:60
@ SS7_AS_CTR_TX_MSU_SLS_15
Definition: ss7_as.h:67
@ SS7_AS_CTR_RX_MSU_SLS_10
Definition: ss7_as.h:45
@ SS7_AS_CTR_RX_MSU_TOTAL
Definition: ss7_as.h:34
@ SS7_AS_CTR_TX_MSU_SLS_14
Definition: ss7_as.h:66
@ SS7_AS_CTR_TX_MSU_SLS_7
Definition: ss7_as.h:59
@ SS7_AS_CTR_RX_MSU_SLS_15
Definition: ss7_as.h:50
@ SS7_AS_CTR_RX_MSU_SLS_1
Definition: ss7_as.h:36
@ SS7_AS_CTR_TX_MSU_SLS_5
Definition: ss7_as.h:57
@ SS7_AS_CTR_RX_MSU_SLS_2
Definition: ss7_as.h:37
@ SS7_AS_CTR_TX_MSU_SLS_3
Definition: ss7_as.h:55
@ SS7_AS_CTR_RX_MSU_SLS_5
Definition: ss7_as.h:40
@ SS7_AS_CTR_TX_MSU_SLS_10
Definition: ss7_as.h:62
@ SS7_AS_CTR_RX_MSU_SLS_8
Definition: ss7_as.h:43
@ SS7_AS_CTR_TX_MSU_SLS_12
Definition: ss7_as.h:64
@ SS7_AS_CTR_RX_MSU_SLS_4
Definition: ss7_as.h:39
@ SS7_AS_CTR_TX_MSU_SLS_9
Definition: ss7_as.h:61
@ SS7_AS_CTR_TX_MSU_SLS_2
Definition: ss7_as.h:54
@ SS7_AS_CTR_TX_MSU_SLS_0
Definition: ss7_as.h:52
@ SS7_AS_CTR_TX_MSU_TOTAL
Definition: ss7_as.h:51
@ SS7_AS_CTR_RX_MSU_SLS_7
Definition: ss7_as.h:42
@ SS7_AS_CTR_RX_MSU_DISCARD
Definition: ss7_as.h:33
@ SS7_AS_CTR_TX_MSU_SLS_11
Definition: ss7_as.h:63
@ SS7_AS_CTR_TX_MSU_SLS_6
Definition: ss7_as.h:58
@ SS7_AS_CTR_RX_MSU_SLS_6
Definition: ss7_as.h:41
@ SS7_AS_CTR_RX_MSU_SLS_14
Definition: ss7_as.h:49
@ SS7_AS_CTR_RX_MSU_SLS_9
Definition: ss7_as.h:44
@ SS7_AS_CTR_TX_MSU_SLS_13
Definition: ss7_as.h:65
@ SS7_AS_CTR_RX_MSU_SLS_13
Definition: ss7_as.h:48
@ SS7_AS_CTR_RX_MSU_SLS_12
Definition: ss7_as.h:47
@ SS7_AS_CTR_TX_MSU_SLS_1
Definition: ss7_as.h:53
@ SS7_AS_CTR_RX_MSU_SLS_3
Definition: ss7_as.h:38
@ SS7_AS_CTR_RX_MSU_SLS_11
Definition: ss7_as.h:46
@ SS7_AS_CTR_RX_MSU_SLS_0
Definition: ss7_as.h:35
@ SS7_AS_CTR_TX_MSU_SLS_4
Definition: ss7_as.h:56
void ss7_as_del_asp_update_llist_round_robin(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp, struct ss7_as_asp_assoc **state)
Definition: ss7_as.c:276
struct osmo_ss7_asp * ss7_as_find_asp_by_remote_asp_id(const struct osmo_ss7_as *as, uint32_t asp_id, const struct osmo_ss7_asp *excl_asp)
Find ASP with a given announced remote ASP Id.
Definition: ss7_as.c:395
int ss7_as_del_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp)
Delete given ASP from given AS.
Definition: ss7_as.c:299
struct osmo_ss7_as * ss7_as_alloc(struct osmo_ss7_instance *inst, const char *name, enum osmo_ss7_asp_protocol proto)
Allocate an Application Server.
Definition: ss7_as.c:164
ss7_as_tcap_unroutable
Definition: ss7_as.h:80
@ SS7_AS_TCAP_UNROUTABLE_REJECT_UDTS
Definition: ss7_as.h:81
@ SS7_AS_TCAP_UNROUTABLE_LOAD_SHARE_AS
reject the unroutable TCAP message with a UDTS
Definition: ss7_as.h:82
@ SS7_AS_TCAP_UNROUTABLE_ROUTE_FALLBACK
fallback to round robin load-share over all available ASP
Definition: ss7_as.h:83
Definition: mtp_sap.h:42
Definition: ss7_as.h:89
struct osmo_ss7_asp * normal_asp
Definition: ss7_as.h:91
struct osmo_ss7_asp * alt_asp
Definition: ss7_as.h:93
Definition: ss7_as.h:105
struct ss7_as_asp_assoc * last_asp_idx_sent
Definition: ss7_as.h:143
struct osmo_ss7_routing_key routing_key
Definition: ss7_as.h:152
unsigned int num_assoc_asps
Definition: ss7_as.h:146
uint8_t opc_shift
Definition: ss7_as.h:178
uint8_t sls_shift
Definition: ss7_as.h:172
uint32_t recovery_timeout_msec
Definition: ss7_as.h:158
struct osmo_ss7_as_esls_entry aesls_table[NUM_AS_EXT_SLS]
Definition: ss7_as.h:123
bool opc_enabled
Definition: ss7_as.h:161
struct llist_head list
entry in 'ref osmo_ss7_instance.as_list
Definition: ss7_as.h:107
char * description
Definition: ss7_as.h:150
struct ss7_as_asp_assoc * last_asp_idx_assigned
Definition: ss7_as.h:142
bool rkm_dyn_allocated
Were we dynamically allocated by RKM?
Definition: ss7_as.h:114
struct osmo_ss7_as::@23::@25 loadshare
struct rate_ctr_group * ctrg
Rate Counter Group.
Definition: ss7_as.h:120
char * name
Definition: ss7_as.h:149
uint32_t opc
Definition: ss7_as.h:163
bool mode_set_by_vty
Definition: ss7_as.h:155
struct osmo_fsm_inst * fi
AS FSM.
Definition: ss7_as.h:111
bool simple_client_allocated
Were we allocated by "simple client" support?
Definition: ss7_as.h:117
uint32_t dpc
Definition: ss7_as.h:164
bool opc_sls
Definition: ss7_as.h:174
enum osmo_ss7_as_traffic_mode mode
Definition: ss7_as.h:153
struct llist_head assoc_asp_list
Definition: ss7_as.h:145
enum osmo_ss7_asp_protocol proto
Definition: ss7_as.h:151
enum osmo_ss7_as_patch_sccp_mode sccp_mode
Definition: ss7_as.h:165
struct osmo_ss7_instance * inst
Definition: ss7_as.h:108
struct osmo_ss7_as::@23 cfg
bool mode_set_by_peer
Definition: ss7_as.h:157
uint8_t qos_class
Definition: ss7_as.h:159
struct osmo_ss7_as::@23::@24 pc_override
bool dpc_enabled
Definition: ss7_as.h:162
Definition: ss7_asp.h:55
Definition: ss7_instance.h:47
Definition: osmo_ss7.h:142
Definition: ss7_as.h:96
struct osmo_ss7_as * as
Definition: ss7_as.h:101
struct llist_head asp_entry
Definition: ss7_as.h:100
struct osmo_ss7_asp * asp
Definition: ss7_as.h:102
struct llist_head as_entry
Definition: ss7_as.h:98
Definition: xua_msg.h:31