libosmo-sigtran 2.1.0.194-89e3 Osmocom SIGTRAN library

ss7_as.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <osmocom/core/linuxlist.h>
5#include <osmocom/core/fsm.h>
6#include <osmocom/core/msgb.h>
7#include <osmocom/core/tdef.h>
8#include <osmocom/netif/stream.h>
9
10#include <osmocom/sigtran/osmo_ss7.h>
11
12#include "ss7_internal.h"
13#include "xua_msg.h"
14
15/***********************************************************************
16 * SS7 Application Server
17 ***********************************************************************/
18
19struct osmo_ss7_instance;
20struct osmo_ss7_asp;
21struct osmo_mtp_transfer_param;
22
23 enum osmo_ss7_as_patch_sccp_mode {
24 OSMO_SS7_PATCH_NONE, /* no patching of SCCP */
25 OSMO_SS7_PATCH_BOTH, /* patch both OPC and DPC into SCCP addresses */
26};
27
28 enum ss7_as_ctr {
29 SS7_AS_CTR_RX_MSU_DISCARD,
30 SS7_AS_CTR_RX_MSU_TOTAL,
31 SS7_AS_CTR_RX_MSU_SLS_0,
32 SS7_AS_CTR_RX_MSU_SLS_1,
33 SS7_AS_CTR_RX_MSU_SLS_2,
34 SS7_AS_CTR_RX_MSU_SLS_3,
35 SS7_AS_CTR_RX_MSU_SLS_4,
36 SS7_AS_CTR_RX_MSU_SLS_5,
37 SS7_AS_CTR_RX_MSU_SLS_6,
38 SS7_AS_CTR_RX_MSU_SLS_7,
39 SS7_AS_CTR_RX_MSU_SLS_8,
40 SS7_AS_CTR_RX_MSU_SLS_9,
41 SS7_AS_CTR_RX_MSU_SLS_10,
42 SS7_AS_CTR_RX_MSU_SLS_11,
43 SS7_AS_CTR_RX_MSU_SLS_12,
44 SS7_AS_CTR_RX_MSU_SLS_13,
45 SS7_AS_CTR_RX_MSU_SLS_14,
46 SS7_AS_CTR_RX_MSU_SLS_15,
47 SS7_AS_CTR_TX_MSU_TOTAL,
48 SS7_AS_CTR_TX_MSU_SLS_0,
49 SS7_AS_CTR_TX_MSU_SLS_1,
50 SS7_AS_CTR_TX_MSU_SLS_2,
51 SS7_AS_CTR_TX_MSU_SLS_3,
52 SS7_AS_CTR_TX_MSU_SLS_4,
53 SS7_AS_CTR_TX_MSU_SLS_5,
54 SS7_AS_CTR_TX_MSU_SLS_6,
55 SS7_AS_CTR_TX_MSU_SLS_7,
56 SS7_AS_CTR_TX_MSU_SLS_8,
57 SS7_AS_CTR_TX_MSU_SLS_9,
58 SS7_AS_CTR_TX_MSU_SLS_10,
59 SS7_AS_CTR_TX_MSU_SLS_11,
60 SS7_AS_CTR_TX_MSU_SLS_12,
61 SS7_AS_CTR_TX_MSU_SLS_13,
62 SS7_AS_CTR_TX_MSU_SLS_14,
63 SS7_AS_CTR_TX_MSU_SLS_15,
64};
65
66#define NUM_AS_EXT_SLS 128
67 typedef uint8_t as_ext_sls_t; /* range: 0-127, 7 bit */
68 struct osmo_ss7_as_esls_entry {
69 /* ITU Q.704 4.2.1: "normal signallink link" */
70 struct osmo_ss7_asp *normal_asp;
71 /* ITU Q.704 4.2.1: "alternative signallink link" */
72 struct osmo_ss7_asp *alt_asp;
73};
74
75 struct osmo_ss7_as {
77 struct llist_head list;
78 struct osmo_ss7_instance *inst;
79
81 struct osmo_fsm_inst *fi;
82
84 bool rkm_dyn_allocated;
85
87 bool simple_client_allocated;
88
90 struct rate_ctr_group *ctrg;
91
92 /* ASP loadshare: */
93 struct osmo_ss7_as_esls_entry aesls_table[NUM_AS_EXT_SLS];
94
95 struct {
96 char *name;
97 char *description;
98 enum osmo_ss7_asp_protocol proto;
99 struct osmo_ss7_routing_key routing_key;
100 enum osmo_ss7_as_traffic_mode mode;
101 /* traffic mode was configured by VTY / config file */
102 bool mode_set_by_vty;
103 /* traffic mode was configured by RKM (routing key management) or first ASPAC */
104 bool mode_set_by_peer;
105 uint32_t recovery_timeout_msec;
106 uint8_t qos_class;
107 struct {
108 bool opc_enabled;
109 bool dpc_enabled;
110 uint32_t opc;
111 uint32_t dpc;
112 enum osmo_ss7_as_patch_sccp_mode sccp_mode;
113 } pc_override;
114
115 struct osmo_ss7_asp *asps[16];
116 /* used for load-sharing traffic mode (round robin implementation) */
117 uint8_t last_asp_idx_assigned;
118 uint8_t last_asp_idx_sent;
119
120 struct {
121 /* How many bits from ITU SLS field (starting from least-significant-bit)
122 * to skip for routing decisions.
123 * range 0-3, defaults to 0, which means take all 4 bits. */
124 uint8_t sls_shift;
125 /* Whether to generate a extended-SLS with OPC information, see opc_shift below. */
126 bool opc_sls;
127 /* How many bits from ITU OPC field (starting from least-significant-bit)
128 * to skip for routing decisions (always takes 12 bits).
129 * range 0-2, defaults to 0, which means take least significant 12 bits. */
130 uint8_t opc_shift;
131 } loadshare;
132 } cfg;
133};
134struct osmo_ss7_as *ss7_as_alloc(struct osmo_ss7_instance *inst, const char *name,
135 enum osmo_ss7_asp_protocol proto);
136struct osmo_ss7_asp *ss7_as_select_asp(struct osmo_ss7_as *as, const struct xua_msg *xua);
137
138unsigned int osmo_ss7_as_count_asp(const struct osmo_ss7_as *as);
139int ss7_as_add_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp);
140int ss7_as_del_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp);
141int ss7_as_get_local_role(const struct osmo_ss7_as *as);
142void ss7_as_loadshare_binding_table_reset(struct osmo_ss7_as *as);
143
144#define LOGPAS(as, subsys, level, fmt, args ...) \
145 _LOGSS7((as)->inst, subsys, level, "AS(%s) " fmt, (as)->cfg.name, ## args)
osmo_ss7.h
osmo_ss7_asp_protocol
osmo_ss7_asp_protocol
Definition: osmo_ss7.h:157
osmo_ss7_as_traffic_mode
osmo_ss7_as_traffic_mode
Definition: osmo_ss7.h:183
xua_msg.h
osmo_ss7_as_patch_sccp_mode
osmo_ss7_as_patch_sccp_mode
Definition: ss7_as.h:23
OSMO_SS7_PATCH_BOTH
@ OSMO_SS7_PATCH_BOTH
Definition: ss7_as.h:25
OSMO_SS7_PATCH_NONE
@ OSMO_SS7_PATCH_NONE
Definition: ss7_as.h:24
ss7_as_loadshare_binding_table_reset
void ss7_as_loadshare_binding_table_reset(struct osmo_ss7_as *as)
Definition: ss7_as.c:394
as_ext_sls_t
uint8_t as_ext_sls_t
Definition: ss7_as.h:67
ss7_as_get_local_role
int ss7_as_get_local_role(const struct osmo_ss7_as *as)
Definition: ss7_as.c:290
NUM_AS_EXT_SLS
#define NUM_AS_EXT_SLS
Definition: ss7_as.h:66
ss7_as_add_asp
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:154
ss7_as_alloc
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:112
ss7_as_select_asp
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:531
ss7_as_ctr
ss7_as_ctr
Definition: ss7_as.h:28
SS7_AS_CTR_TX_MSU_SLS_8
@ SS7_AS_CTR_TX_MSU_SLS_8
Definition: ss7_as.h:56
SS7_AS_CTR_TX_MSU_SLS_15
@ SS7_AS_CTR_TX_MSU_SLS_15
Definition: ss7_as.h:63
SS7_AS_CTR_RX_MSU_SLS_10
@ SS7_AS_CTR_RX_MSU_SLS_10
Definition: ss7_as.h:41
SS7_AS_CTR_RX_MSU_TOTAL
@ SS7_AS_CTR_RX_MSU_TOTAL
Definition: ss7_as.h:30
SS7_AS_CTR_TX_MSU_SLS_14
@ SS7_AS_CTR_TX_MSU_SLS_14
Definition: ss7_as.h:62
SS7_AS_CTR_TX_MSU_SLS_7
@ SS7_AS_CTR_TX_MSU_SLS_7
Definition: ss7_as.h:55
SS7_AS_CTR_RX_MSU_SLS_15
@ SS7_AS_CTR_RX_MSU_SLS_15
Definition: ss7_as.h:46
SS7_AS_CTR_RX_MSU_SLS_1
@ SS7_AS_CTR_RX_MSU_SLS_1
Definition: ss7_as.h:32
SS7_AS_CTR_TX_MSU_SLS_5
@ SS7_AS_CTR_TX_MSU_SLS_5
Definition: ss7_as.h:53
SS7_AS_CTR_RX_MSU_SLS_2
@ SS7_AS_CTR_RX_MSU_SLS_2
Definition: ss7_as.h:33
SS7_AS_CTR_TX_MSU_SLS_3
@ SS7_AS_CTR_TX_MSU_SLS_3
Definition: ss7_as.h:51
SS7_AS_CTR_RX_MSU_SLS_5
@ SS7_AS_CTR_RX_MSU_SLS_5
Definition: ss7_as.h:36
SS7_AS_CTR_TX_MSU_SLS_10
@ SS7_AS_CTR_TX_MSU_SLS_10
Definition: ss7_as.h:58
SS7_AS_CTR_RX_MSU_SLS_8
@ SS7_AS_CTR_RX_MSU_SLS_8
Definition: ss7_as.h:39
SS7_AS_CTR_TX_MSU_SLS_12
@ SS7_AS_CTR_TX_MSU_SLS_12
Definition: ss7_as.h:60
SS7_AS_CTR_RX_MSU_SLS_4
@ SS7_AS_CTR_RX_MSU_SLS_4
Definition: ss7_as.h:35
SS7_AS_CTR_TX_MSU_SLS_9
@ SS7_AS_CTR_TX_MSU_SLS_9
Definition: ss7_as.h:57
SS7_AS_CTR_TX_MSU_SLS_2
@ SS7_AS_CTR_TX_MSU_SLS_2
Definition: ss7_as.h:50
SS7_AS_CTR_TX_MSU_SLS_0
@ SS7_AS_CTR_TX_MSU_SLS_0
Definition: ss7_as.h:48
SS7_AS_CTR_TX_MSU_TOTAL
@ SS7_AS_CTR_TX_MSU_TOTAL
Definition: ss7_as.h:47
SS7_AS_CTR_RX_MSU_SLS_7
@ SS7_AS_CTR_RX_MSU_SLS_7
Definition: ss7_as.h:38
SS7_AS_CTR_RX_MSU_DISCARD
@ SS7_AS_CTR_RX_MSU_DISCARD
Definition: ss7_as.h:29
SS7_AS_CTR_TX_MSU_SLS_11
@ SS7_AS_CTR_TX_MSU_SLS_11
Definition: ss7_as.h:59
SS7_AS_CTR_TX_MSU_SLS_6
@ SS7_AS_CTR_TX_MSU_SLS_6
Definition: ss7_as.h:54
SS7_AS_CTR_RX_MSU_SLS_6
@ SS7_AS_CTR_RX_MSU_SLS_6
Definition: ss7_as.h:37
SS7_AS_CTR_RX_MSU_SLS_14
@ SS7_AS_CTR_RX_MSU_SLS_14
Definition: ss7_as.h:45
SS7_AS_CTR_RX_MSU_SLS_9
@ SS7_AS_CTR_RX_MSU_SLS_9
Definition: ss7_as.h:40
SS7_AS_CTR_TX_MSU_SLS_13
@ SS7_AS_CTR_TX_MSU_SLS_13
Definition: ss7_as.h:61
SS7_AS_CTR_RX_MSU_SLS_13
@ SS7_AS_CTR_RX_MSU_SLS_13
Definition: ss7_as.h:44
SS7_AS_CTR_RX_MSU_SLS_12
@ SS7_AS_CTR_RX_MSU_SLS_12
Definition: ss7_as.h:43
SS7_AS_CTR_TX_MSU_SLS_1
@ SS7_AS_CTR_TX_MSU_SLS_1
Definition: ss7_as.h:49
SS7_AS_CTR_RX_MSU_SLS_3
@ SS7_AS_CTR_RX_MSU_SLS_3
Definition: ss7_as.h:34
SS7_AS_CTR_RX_MSU_SLS_11
@ SS7_AS_CTR_RX_MSU_SLS_11
Definition: ss7_as.h:42
SS7_AS_CTR_RX_MSU_SLS_0
@ SS7_AS_CTR_RX_MSU_SLS_0
Definition: ss7_as.h:31
SS7_AS_CTR_TX_MSU_SLS_4
@ SS7_AS_CTR_TX_MSU_SLS_4
Definition: ss7_as.h:52
osmo_ss7_as_count_asp
unsigned int osmo_ss7_as_count_asp(const struct osmo_ss7_as *as)
Determine amount of ASPs associated to an AS.
Definition: ss7_as.c:276
ss7_as_del_asp
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:197
ss7_internal.h
osmo_mtp_transfer_param
Definition: mtp_sap.h:42
osmo_ss7_as_esls_entry
Definition: ss7_as.h:68
osmo_ss7_as_esls_entry::normal_asp
struct osmo_ss7_asp * normal_asp
Definition: ss7_as.h:70
osmo_ss7_as_esls_entry::alt_asp
struct osmo_ss7_asp * alt_asp
Definition: ss7_as.h:72
osmo_ss7_as
Definition: ss7_as.h:75
osmo_ss7_as::routing_key
struct osmo_ss7_routing_key routing_key
Definition: ss7_as.h:99
osmo_ss7_as::opc_shift
uint8_t opc_shift
Definition: ss7_as.h:130
osmo_ss7_as::sls_shift
uint8_t sls_shift
Definition: ss7_as.h:124
osmo_ss7_as::recovery_timeout_msec
uint32_t recovery_timeout_msec
Definition: ss7_as.h:105
osmo_ss7_as::aesls_table
struct osmo_ss7_as_esls_entry aesls_table[NUM_AS_EXT_SLS]
Definition: ss7_as.h:93
osmo_ss7_as::opc_enabled
bool opc_enabled
Definition: ss7_as.h:108
osmo_ss7_as::list
struct llist_head list
entry in 'ref osmo_ss7_instance.as_list
Definition: ss7_as.h:77
osmo_ss7_as::last_asp_idx_assigned
uint8_t last_asp_idx_assigned
Definition: ss7_as.h:117
osmo_ss7_as::description
char * description
Definition: ss7_as.h:97
osmo_ss7_as::rkm_dyn_allocated
bool rkm_dyn_allocated
Were we dynamically allocated by RKM?
Definition: ss7_as.h:84
osmo_ss7_as::loadshare
struct osmo_ss7_as::@23::@25 loadshare
osmo_ss7_as::ctrg
struct rate_ctr_group * ctrg
Rate Counter Group.
Definition: ss7_as.h:90
osmo_ss7_as::asps
struct osmo_ss7_asp * asps[16]
Definition: ss7_as.h:115
osmo_ss7_as::last_asp_idx_sent
uint8_t last_asp_idx_sent
Definition: ss7_as.h:118
osmo_ss7_as::name
char * name
Definition: ss7_as.h:96
osmo_ss7_as::opc
uint32_t opc
Definition: ss7_as.h:110
osmo_ss7_as::mode_set_by_vty
bool mode_set_by_vty
Definition: ss7_as.h:102
osmo_ss7_as::fi
struct osmo_fsm_inst * fi
AS FSM.
Definition: ss7_as.h:81
osmo_ss7_as::simple_client_allocated
bool simple_client_allocated
Were we allocated by "simple client" support?
Definition: ss7_as.h:87
osmo_ss7_as::dpc
uint32_t dpc
Definition: ss7_as.h:111
osmo_ss7_as::opc_sls
bool opc_sls
Definition: ss7_as.h:126
osmo_ss7_as::mode
enum osmo_ss7_as_traffic_mode mode
Definition: ss7_as.h:100
osmo_ss7_as::proto
enum osmo_ss7_asp_protocol proto
Definition: ss7_as.h:98
osmo_ss7_as::sccp_mode
enum osmo_ss7_as_patch_sccp_mode sccp_mode
Definition: ss7_as.h:112
osmo_ss7_as::inst
struct osmo_ss7_instance * inst
Definition: ss7_as.h:78
osmo_ss7_as::cfg
struct osmo_ss7_as::@23 cfg
osmo_ss7_as::mode_set_by_peer
bool mode_set_by_peer
Definition: ss7_as.h:104
osmo_ss7_as::qos_class
uint8_t qos_class
Definition: ss7_as.h:106
osmo_ss7_as::pc_override
struct osmo_ss7_as::@23::@24 pc_override
osmo_ss7_as::dpc_enabled
bool dpc_enabled
Definition: ss7_as.h:109
osmo_ss7_asp
Definition: ss7_asp.h:43
osmo_ss7_instance
Definition: ss7_instance.h:31
osmo_ss7_routing_key
Definition: osmo_ss7.h:142
xua_msg
Definition: xua_msg.h:31